Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/openhuman-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ never written back to the config file.
| `run`, `serve` | Start the HTTP JSON-RPC and Socket.IO server. Flags: `--host`, `--port`, `--jsonrpc-only` (no Socket.IO), `--headless-api` (JSON-RPC only, no background services), `-v`/`--verbose`. |
| `call --method <name> [--params '<json>' \| --params-stdin]` | Invoke one controller in-process (no server needed) and print the JSON result. Runs on a runtime with the agent worker stack size, so methods that run a turn work. |
| `mcp`, `mcp-server` | Run the stdio MCP server. No banner, since stdout carries JSON-RPC. |
| `agent <dump-prompt \| dump-all \| prompt-size \| list>` | Inspect agent definitions and rendered prompts (`core/agent_cli.rs`), for example `agent dump-prompt --agent <id> --json --with-tools`. |
| `agent <dump-prompt \| dump-all \| prompt-size \| list>` | Inspect agent definitions and rendered prompts (`agent/cli.rs`), for example `agent dump-prompt --agent <id> --json --with-tools`. |
| `sentry-test [--message <text>] [--panic]` | Send a test event to verify Sentry wiring. Reports a disabled-build error without `crash-reporting`. |
| `tui`, `chat` | Print a migration notice: the terminal UI is the separate `openhuman-tui` executable. |
| `<namespace> <function> [--param value ...]` | Generic dispatch to any registered controller, for example `skills ...` or `voice ...`. `<namespace> --help` lists functions; `<namespace> <function> --help` lists parameters. |
Expand Down Expand Up @@ -165,7 +165,7 @@ directly. Gates local to this crate:
## Boundaries

- Subcommand parsing and dispatch live in the core
([`crates/openhuman-core/src/core/cli.rs`](../openhuman-core/src/core/cli.rs), `core/agent_cli.rs`). New
([`crates/openhuman-core/src/core/cli.rs`](../openhuman-core/src/core/cli.rs), `agent/cli.rs`). New
functionality is a controller registered in `core/all.rs`, reached through
the generic namespace dispatch, not a new branch in `cli.rs`.
- The JSON-RPC server, Socket.IO and the listener belong to
Expand Down
2 changes: 1 addition & 1 deletion crates/openhuman-core/src/agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Definitions, prompts and context:
| `prompts/` | Bundled identity files, `SystemPromptBuilder`, prompt sections ([README](prompts/README.md)) |
| `context/` | Shared TinyAgents context defaults ([README](context/README.md)) |
| [`context_breakdown.rs`](./context_breakdown.rs) | `agent.context_breakdown`: system/tools/history split of prompt size for the UI |
| `debug/` | Dumps the exact system prompt and prompt-size report for an agent |
| [`cli.rs`](./cli.rs), [`cli/debug/`](./cli/debug/) | `openhuman agent dump-prompt / dump-all / prompt-size / list`; `cli/debug/` dumps the exact system prompt and prompt-size report for an agent, which `agent.context_breakdown` also reuses |
| [`../agent_registry/library/`](../agent_registry/library/) | Display-safe projection of definitions (`AgentDefinitionDisplay`) |

Persistence, setup and RPC:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
use anyhow::{anyhow, Result};
use std::path::PathBuf;

use crate::agent_registry::host_definition::AgentDefinitionRegistry;
use crate::core::agent_cli::debug::prompt_size::{render_text, PromptSizeReport};
use crate::core::agent_cli::debug::{
use crate::agent::cli::debug::prompt_size::{render_text, PromptSizeReport};
use crate::agent::cli::debug::{
dump_agent_prompt, dump_all_agent_prompts, write_prompt_dumps, DumpPromptOptions, DumpedPrompt,
};
use crate::agent_registry::host_definition::AgentDefinitionRegistry;

pub(crate) mod debug;

Expand Down Expand Up @@ -468,10 +468,7 @@ fn run_dump_prompt(args: &[String]) -> Result<()> {
// and splitting the header onto stderr the way `print_human` does
// would make `> turn.txt` drop the byte counts that give the payload
// its meaning.
print!(
"{}",
crate::core::agent_cli::debug::render_wire_dump(&dumped)
);
print!("{}", crate::agent::cli::debug::render_wire_dump(&dumped));
} else if flags.json {
print_json(&dumped, flags.with_tools)?;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ async fn session_report_measures_the_visible_belt_not_the_registry() {
.await
.expect("test-owned prompt-size session build");

let dumped =
crate::core::agent_cli::debug::session_dump(&agent, "prompt_size_probe", String::new());
let dumped = crate::agent::cli::debug::session_dump(&agent, "prompt_size_probe", String::new());
let report = PromptSizeReport::from_dump(&dumped);

let mut visible: Vec<String> = agent
Expand Down
3 changes: 3 additions & 0 deletions crates/openhuman-core/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
//! within a parent agent's tool loop, enabling hierarchical delegation.
pub use crate::attachments::HostAttachment;
pub mod bus;
/// `openhuman agent ...`: the developer CLI that dumps and sizes agent
/// prompts, and the prompt-dump helpers `agent.context_breakdown` reuses.
pub mod cli;
pub mod context;
pub(crate) mod cost;
pub mod goals;
Expand Down
10 changes: 5 additions & 5 deletions crates/openhuman-core/src/agent_runs/context_breakdown.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! RPC `agent.context_breakdown` — a UI-friendly view over
//! [`PromptSizeReport`](super::debug::prompt_size::PromptSizeReport) plus,
//! [`PromptSizeReport`](crate::agent::cli::debug::prompt_size::PromptSizeReport) plus,
//! when a `thread_id` is given, that thread's persisted history spend, so
//! the composer's context-usage indicator can show a system/tools/history
//! split instead of just the fixed per-turn prefix.
Expand All @@ -18,9 +18,9 @@ use crate::core::runtime::Tenant;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};

use crate::agent::cli::debug::prompt_size::{PromptSizeReport, SectionSize, ToolSize};
use crate::agent::cli::debug::DumpPromptOptions;
use crate::config::Config;
use crate::core::agent_cli::debug::prompt_size::{PromptSizeReport, SectionSize, ToolSize};
use crate::core::agent_cli::debug::DumpPromptOptions;
use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;

Expand Down Expand Up @@ -66,7 +66,7 @@ pub struct ContextBreakdownResponse {
}

fn est_tokens(bytes: usize) -> usize {
bytes / crate::core::agent_cli::debug::prompt_size::EST_BYTES_PER_TOKEN.max(1)
bytes / crate::agent::cli::debug::prompt_size::EST_BYTES_PER_TOKEN.max(1)
}

/// Coarse "did anything in config change" fingerprint. Correctness only
Expand Down Expand Up @@ -181,7 +181,7 @@ async fn history_section(
// the module's own byte-per-token estimate so `bytes` stays a consistent
// (if approximate) unit across every section in the response.
let est = history_tokens(usage.last_turn_context_tokens as usize, fixed_prompt_tokens);
let bytes = est.saturating_mul(crate::core::agent_cli::debug::prompt_size::EST_BYTES_PER_TOKEN);
let bytes = est.saturating_mul(crate::agent::cli::debug::prompt_size::EST_BYTES_PER_TOKEN);
Some(ContextSection {
label: "history".to_string(),
bytes,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use crate::core::agent_cli::debug::prompt_size::PromptSizeReport;
use crate::core::agent_cli::debug::DumpedPrompt;
use crate::agent::cli::debug::prompt_size::PromptSizeReport;
use crate::agent::cli::debug::DumpedPrompt;

fn sample_dump() -> DumpedPrompt {
DumpedPrompt {
Expand Down Expand Up @@ -44,7 +44,7 @@ fn tools_section_rolls_up_every_tool_into_one_row() {
fn est_tokens_divides_by_the_shared_bytes_per_token_constant() {
assert_eq!(
est_tokens(400),
400 / crate::core::agent_cli::debug::prompt_size::EST_BYTES_PER_TOKEN
400 / crate::agent::cli::debug::prompt_size::EST_BYTES_PER_TOKEN
);
assert_eq!(est_tokens(0), 0);
}
Expand Down
23 changes: 8 additions & 15 deletions crates/openhuman-core/src/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Errors travel as `Err(String)`. When a controller needs a typed error, it
encodes a `StructuredRpcError` ([`structured_error.rs`](./structured_error.rs)) into that string behind
the `STRUCTURED_RPC_ERROR_SENTINEL` prefix, and the transport decodes it. A
few surfaces (`threads`, desktop provider surfaces) wrap results in the
`{data, error, meta}` envelope built by [`envelope.rs`](./envelope.rs).
`{data, error, meta}` envelope built by [`threads/envelope.rs`](../threads/envelope.rs).

### Registration

Expand Down Expand Up @@ -227,7 +227,7 @@ the first argument:
| `mcp`, `mcp-server` | run the stdio MCP server (`mcp::server::run_stdio_from_cli`) |
| `tui`, `chat` | print a pointer to the separate `openhuman-tui` binary |
| `call --method <m> --params <json>` | one raw RPC call through `invoke_method` (`--params-stdin` reads params from stdin) |
| `agent dump-prompt / dump-all / prompt-size / list` | prompt inspection tools in [`agent_cli.rs`](./agent_cli.rs) |
| `agent dump-prompt / dump-all / prompt-size / list` | prompt inspection tools in [`agent/cli.rs`](../agent/cli.rs) |
| `sentry-test` | send a test event to Sentry |
| `<namespace> <function> [--flags]` | generic dispatcher over the registry schemas |

Expand All @@ -236,7 +236,7 @@ from their descriptions (`namespace_description` in `all.rs`), and turns
flags into params. A namespace with no function can fall through to a
standalone `RegisteredCliAdapter`: today `voice` (which stays registered with
the `voice` feature off and reports that voice is disabled) and `subsystems`
([`subsystems_cli.rs`](./subsystems_cli.rs), which prints the subsystem table). Wire new CLI
([`memory/status.rs`](../memory/status.rs), which prints the subsystem table). Wire new CLI
behavior through the registry; do not add namespace branches to [`cli.rs`](./cli.rs) or
the JSON-RPC server.

Expand Down Expand Up @@ -282,15 +282,12 @@ through `openhuman_rpc::server::serve` or `CoreRuntime::start_services`.
`MAX_BLOCKING_THREADS` (64). One agent turn is a very large async state
machine and a sub-agent nests another, which overflows tokio's default 2 MiB
worker stack, so every multi-thread runtime that can host a turn (the desktop
shell, `openhuman-core run`, `agent_cli`) sets both.
shell, `openhuman-core run`, `agent::cli`) sets both.

`subsystem/` serves the `subsystems` RPC namespace and its CLI table: one
`SubsystemStatus` row per kernel capability slot (class, health, contract
version, advertised capabilities). It is the one controller registered from
`core/` itself, tagged `DomainGroup::Platform`, because the subsystem table is
a kernel binding table like the controller registry. Memory is the only
occupant today; `crate::memory::status` builds its row, and a new subsystem
appends its adapter call in `subsystem::schemas::subsystems_status`.
The `subsystems` RPC namespace and its CLI table (one `SubsystemStatus` row
per kernel capability slot) live in [`memory/status.rs`](../memory/status.rs),
because memory is the only slot. `all.rs` still tags it
`DomainGroup::Platform`, like `health`.

## Layout

Expand All @@ -301,7 +298,6 @@ Contract and registry:
| `mod.rs` | `ControllerSchema`, `FieldSchema`, `TypeSchema`; module declarations; re-exports `Outcome` and `StructuredRpcError`. |
| `outcome.rs` | `Outcome<T>`, `apply_log_envelope` (the one wire-shape rule) and `unwrap_rpc`. |
| `structured_error.rs` | `StructuredRpcError`, a typed error sentinel-encoded into a controller's `Err(String)`. |
| `envelope.rs` | `ApiEnvelope`, `ApiError`, `ApiMeta`, `PaginationMeta`: the `{data, error, meta}` shape some namespaces use. |
| `params.rs` | Params shape (`params_to_object`, `parse_json_params`), validation messages and `is_param_validation_error`. |
| `all.rs` | The registry: `RegisteredController`, `RegisteredCliAdapter`, `DomainGroup`, `ControllerExtension`, `register_controller_extension`, `validate_params`, `schema_for_rpc_method`, `try_invoke_registered_rpc`, `all_http_method_schemas` (adds `core.ping` and `core.version` for `/schema`), `namespace_description`. |
| [`types.rs`](./types.rs) | `AppState`, `HostKind`, `InvocationResult`, `approval_gate_boot_decision`. |
Expand Down Expand Up @@ -332,8 +328,6 @@ CLI:
| Path | What it does |
| --- | --- |
| `cli.rs` | `run_from_cli_args`, launch flags, help output, `call` and the generic namespace dispatcher. |
| `agent_cli.rs` | `openhuman-core agent ...`: `dump-prompt`, `dump-all`, `prompt-size`, `list`. |
| `subsystems_cli.rs` | `run_subsystems_command`, the table printed by bare `openhuman-core subsystems`. |

Process plumbing:

Expand All @@ -346,7 +340,6 @@ Process plumbing:
| `sentry_transport.rs` | Sentry transport over reqwest (`crash-reporting` feature). |
| `shutdown.rs` | SIGINT/SIGTERM signal and the registered shutdown hooks. |
| `runtime/` | `CoreBuilder`, `CoreRuntime`, `CoreContext`, `ServiceSet`, `DomainSet`, bootstrap and subscribers. See [runtime/README.md](runtime/README.md). |
| `subsystem/` | `SubsystemStatus` and the `subsystems` controller. |

## Key types and entry points

Expand Down
18 changes: 9 additions & 9 deletions crates/openhuman-core/src/core/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ fn cli_adapters() -> &'static [RegisteredCliAdapter] {
// dispatcher and prints JSON.
RegisteredCliAdapter {
namespace: "subsystems",
handler: crate::core::subsystems_cli::run_subsystems_command,
handler: crate::memory::status::run_subsystems_command,
},
]
})
Expand Down Expand Up @@ -367,17 +367,17 @@ fn build_registered_controllers() -> Vec<GroupedController> {
crate::platform::health::all_health_registered_controllers(),
);
// Kernel subsystem/driver bindings: slot, bound driver, class, health,
// contract version, capabilities (docs/specs/kernel.md §6 item 6). The one
// controller registered from `crates/openhuman-core/src/core/` — it is a kernel binding table
// with no `crates/openhuman-core/src/` family of its own, so it is tagged `Platform`
// rather than earning a `DomainGroup` variant for a single read-only
// function. Consequence: like `health`, it is absent under
// `DomainSet::harness()`, while `memory.provider_status` (a `Memory`
// family method) stays reachable there.
// contract version, capabilities (docs/specs/kernel.md §6 item 6).
// Memory is the only slot, so `memory::status` owns it (RPC and CLI
// table), but the table is a kernel binding view rather than a memory
// operation: it stays tagged `Platform` instead of `Memory` or a
// `DomainGroup` variant of its own. Consequence:
// like `health`, it is absent under `DomainSet::harness()`, while
// `memory.provider_status` (a `Memory` family method) stays reachable there.
push(
&mut controllers,
DomainGroup::Platform,
crate::core::subsystem::all_subsystems_registered_controllers(),
crate::memory::status::all_subsystems_registered_controllers(),
);
// Diagnostic tools
push_entries(
Expand Down
2 changes: 1 addition & 1 deletion crates/openhuman-core/src/core/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub fn run_from_cli_args_with(
"[cli] dispatching to agent subcommand, args={:?}",
&args[1..]
);
crate::core::agent_cli::run_agent_command(&args[1..])
crate::agent::cli::run_agent_command(&args[1..])
}
"sentry-test" => run_sentry_test_command(&args[1..]),
// Generic namespace dispatcher: `openhuman <namespace> <function> ...`
Expand Down
4 changes: 0 additions & 4 deletions crates/openhuman-core/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use serde::Serialize;

pub mod agent_cli;
pub mod all;
pub mod auth;
pub mod bus;
Expand All @@ -15,7 +14,6 @@ pub mod cli;
mod cli_serve;
pub mod dispatch;
pub mod domain_group;
pub mod envelope;
pub mod event_bind_tokens;
pub mod events;
// Ungated compile-time marker for the `http-server` gate (#5048) — the desktop
Expand All @@ -38,8 +36,6 @@ pub mod session_expiry;
pub mod shutdown;
pub mod slots;
pub mod structured_error;
pub mod subsystem;
pub mod subsystems_cli;
pub mod types;

pub use outcome::{apply_log_envelope, unwrap_rpc, Outcome};
Expand Down
7 changes: 2 additions & 5 deletions crates/openhuman-core/src/core/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
//!
//! PR #3155 set this on the standalone `openhuman-core run` JSON-RPC server.
//! Issue #3159 calls out that every other multi-thread runtime that can host
//! an agent turn (the desktop Tauri host's runtime, `agent_cli`, the rest of
//! an agent turn (the desktop Tauri host's runtime, `agent::cli`, the rest of
//! `cli.rs`, …) shares the same exposure. Centralising the value keeps them
//! in sync; downstream call sites should set `.thread_stack_size(AGENT_WORKER_STACK_BYTES)`
//! on every multi-thread runtime that may host an agent turn.
pub const AGENT_WORKER_STACK_BYTES: usize = 20 * 1024 * 1024;

/// Upper bound on tokio's blocking-thread pool for the long-lived multi-thread
/// runtimes tuned with [`AGENT_WORKER_STACK_BYTES`] (the desktop Tauri host and
/// the `openhuman-core` JSON-RPC / `agent_cli` servers).
/// the `openhuman-core` JSON-RPC / `agent::cli` servers).
///
/// Tokio defaults `max_blocking_threads` to **512**. That is doubly wasteful on
/// these runtimes: `thread_stack_size` sizes *blocking* threads too, not just
Expand Down Expand Up @@ -75,6 +75,3 @@ pub use tenant::{
current_tenant, session_key, session_key_prefix, split_session_key, tenant_key, NoTenant,
Tenant,
};

/// Operator-owned direct inference settings.
pub mod direct_profile_provider;
2 changes: 1 addition & 1 deletion crates/openhuman-core/src/core/runtime/saas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct SaasConfig {
pub root: PathBuf,
/// Validated direct inference defaults shared by profile chat, relay, and cron.
#[serde(default)]
pub chat_provider: Option<super::direct_profile_provider::DirectProfileProvider>,
pub chat_provider: Option<crate::profiles::direct_profile_provider::DirectProfileProvider>,
/// Operator-owned direct Exa/Gemini policy; never a user settings RPC.
#[serde(default)]
pub search: Option<crate::config::SearchConfig>,
Expand Down
21 changes: 0 additions & 21 deletions crates/openhuman-core/src/core/subsystem/mod.rs

This file was deleted.

Loading
Loading