A `start` may now name a role: `role: "reviewer"` loads the spawning agent's own `subagent_roles/reviewer.md` and renders it, alone, into one per-session file that `--append-system-prompt-file` points at. The role is the system prompt; the task is the turn, never the other way round — a task baked into the system prompt would re-assert itself as an instruction on every later turn of a continued session, not just the one it was written for. The task instructions (`prompt_file`) are read and folded ahead of the turn's own prompt instead, the same channel that carries them to the subagent without a role. The argument is optional, so every existing call is unchanged — pinned by a test that a pre-role payload still deserializes with `role` absent from the schema's required set, and another that the no-role path reaches claude with the caller's own file, unrendered, and the trigger untouched. With a role, one test pins the system-prompt file to the role's text and nothing of the task, and another pins the task still reaching the subagent as the turn's prompt. A role name with no file fails the call, before the session name is even reserved, and the error lists the roles the directory does hold. No agent ships roles yet, so named-but-missing is the ordinary first-run state; a fallback there would spawn a subagent under a prompt missing every clause the role existed to carry. An empty file and a name that is not a plain identifier refuse the same way.
23 lines
1.2 KiB
Rust
23 lines
1.2 KiB
Rust
//! Library for `hive-subagent-daemon`: spawns nested claude sessions on
|
|
//! request and serves the `start`/`continue`/`status`/`interrupt` MCP tool
|
|
//! surface directly over streamable-http — no stdio bridge, no round-trip
|
|
//! socket. Independent of `hive-bash-mcp` — a subagent is a much heavier
|
|
//! capability than a bash command (a full nested `claude` process), worth
|
|
//! its own deployable/restartable unit rather than sharing one.
|
|
//!
|
|
//! A second route on the same listener serves `goal_reached`/`need_help` to
|
|
//! the *subagents*, which is how a run says it's done or stuck; see
|
|
//! [`mcp`]'s module doc for why that is a separate surface rather than two
|
|
//! more tools on the parent's, and why it is served per session under a
|
|
//! minted token rather than at one shared path — neither tool takes a
|
|
//! session name, so a subagent has no way to say it is somebody else.
|
|
//!
|
|
//! See [`session`]'s module doc for the actual design: no task files, no
|
|
//! restart recovery, no mid-turn compaction — the daemon's only state is a
|
|
//! handful of in-memory maps, live only as long as the process is.
|
|
|
|
pub mod mcp;
|
|
pub mod mcp_config;
|
|
pub mod paths;
|
|
pub mod role;
|
|
pub mod session;
|