From 27aa182199d35d8c2ba2a63255616122d62912f2 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Sat, 31 Oct 2026 11:32:26 -0500 Subject: [PATCH] Delete AgentModule: a second autonomous agent loop beside the persona minds AgentModule ran its own build/test/fix loop with its own conversation history and tool calling, parallel to the persona minds (CLAUDE.md: no harness; plan line 0). Its agent/start|status|stop|list|wait commands had no caller in the tree and its agent:{handle}:* events had no subscriber. A mind delegates through HER-TASKS. Deleted: modules/agent.rs, modules/agent/tools.rs, commands/agent/ (5 verbs + mod), the 14 ts-rs bindings under protocol/typescript/agent/ and their lines in the master barrel (no TS importer), the mod lines, the import and the registration in ipc/start_server/service_modules.rs. Comments that named it (command_envelope.rs, global_registry.rs, help.rs fixture) now describe what remains. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../continuum-core/src/commands/agent/list.rs | 74 -- core/continuum-core/src/commands/agent/mod.rs | 89 -- .../src/commands/agent/start.rs | 111 --- .../src/commands/agent/status.rs | 92 -- .../continuum-core/src/commands/agent/stop.rs | 87 -- .../continuum-core/src/commands/agent/wait.rs | 109 --- core/continuum-core/src/commands/help.rs | 5 +- core/continuum-core/src/commands/mod.rs | 1 - core/continuum-core/src/ipc/mod.rs | 1 - .../src/ipc/start_server/service_modules.rs | 3 - core/continuum-core/src/modules/agent.rs | 829 ------------------ .../continuum-core/src/modules/agent/tools.rs | 558 ------------ core/continuum-core/src/modules/mod.rs | 1 - .../src/ai/adapter/global_registry.rs | 2 +- .../src/runtime/command_envelope.rs | 2 +- protocol/typescript/agent/AgentAction.ts | 7 - protocol/typescript/agent/AgentListParams.ts | 6 - protocol/typescript/agent/AgentStartParams.ts | 23 - protocol/typescript/agent/AgentStartResult.ts | 11 - protocol/typescript/agent/AgentStatus.ts | 6 - protocol/typescript/agent/AgentStatusInfo.ts | 9 - protocol/typescript/agent/AgentStatusList.ts | 12 - .../typescript/agent/AgentStatusLookup.ts | 13 - .../typescript/agent/AgentStatusParams.ts | 10 - protocol/typescript/agent/AgentStopParams.ts | 10 - protocol/typescript/agent/AgentStopResult.ts | 10 - protocol/typescript/agent/AgentToolCall.ts | 6 - protocol/typescript/agent/AgentToolResult.ts | 6 - protocol/typescript/agent/AgentWaitParams.ts | 14 - protocol/typescript/agent/index.ts | 8 - protocol/typescript/index.ts | 5 - 31 files changed, 4 insertions(+), 2116 deletions(-) delete mode 100644 core/continuum-core/src/commands/agent/list.rs delete mode 100644 core/continuum-core/src/commands/agent/mod.rs delete mode 100644 core/continuum-core/src/commands/agent/start.rs delete mode 100644 core/continuum-core/src/commands/agent/status.rs delete mode 100644 core/continuum-core/src/commands/agent/stop.rs delete mode 100644 core/continuum-core/src/commands/agent/wait.rs delete mode 100644 core/continuum-core/src/modules/agent.rs delete mode 100644 core/continuum-core/src/modules/agent/tools.rs delete mode 100644 protocol/typescript/agent/AgentAction.ts delete mode 100644 protocol/typescript/agent/AgentListParams.ts delete mode 100644 protocol/typescript/agent/AgentStartParams.ts delete mode 100644 protocol/typescript/agent/AgentStartResult.ts delete mode 100644 protocol/typescript/agent/AgentStatus.ts delete mode 100644 protocol/typescript/agent/AgentStatusInfo.ts delete mode 100644 protocol/typescript/agent/AgentStatusList.ts delete mode 100644 protocol/typescript/agent/AgentStatusLookup.ts delete mode 100644 protocol/typescript/agent/AgentStatusParams.ts delete mode 100644 protocol/typescript/agent/AgentStopParams.ts delete mode 100644 protocol/typescript/agent/AgentStopResult.ts delete mode 100644 protocol/typescript/agent/AgentToolCall.ts delete mode 100644 protocol/typescript/agent/AgentToolResult.ts delete mode 100644 protocol/typescript/agent/AgentWaitParams.ts delete mode 100644 protocol/typescript/agent/index.ts diff --git a/core/continuum-core/src/commands/agent/list.rs b/core/continuum-core/src/commands/agent/list.rs deleted file mode 100644 index 996258ca6c..0000000000 --- a/core/continuum-core/src/commands/agent/list.rs +++ /dev/null @@ -1,74 +0,0 @@ -//! `agent/list` — snapshot every live agent (running and just-completed-but-not-yet- -//! evicted). Read → `AiSafe`. - -use std::sync::Arc; - -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use ts_rs::TS; - -use crate::modules::agent::{AgentService, AgentStatusInfo}; - -/// `agent/list` takes no input. -#[derive(Debug, Clone, Default, Serialize, Deserialize, TS, JsonSchema)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentListParams.ts" -)] -pub struct AgentListParams {} - -/// Result of `agent/list` — the live set of tracked agents. A named wrapper so the -/// wire type is a struct, not a bare `Array`. -#[derive(Debug, Clone, Serialize, TS)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentStatusList.ts" -)] -pub struct AgentStatusList { - /// Every agent the runtime is currently tracking (running + not-yet-evicted). - pub agents: Vec, -} - -crate::action_command! { - /// List every agent the runtime is tracking — each with its status, iteration, - /// and file changes. Completed agents are evicted to free memory, so this shows - /// the live set, not full history. - pub struct AgentList { service: Arc } - name: "agent/list", - access: AiSafe, - params: AgentListParams, - output: AgentStatusList, - run(this, _ctx, _p) => { - Ok(AgentStatusList { - agents: this.service.list(), - }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::sdk_codegen::{ActionCommand, Ctx}; - - // what this catches: name/access wiring — listing agents is a read on AiSafe. - #[test] - fn name_and_access_wired() { - assert_eq!(AgentList::NAME, "agent/list"); - assert!(matches!( - AgentList::ACCESS, - crate::sdk_codegen::AccessLevel::AiSafe - )); - } - - // what this catches: a fresh service tracks zero agents — the empty case returns - // an empty Vec (not an error), so callers can always `.len()`. - #[tokio::test] - async fn empty_service_lists_nothing() { - let rt = tokio::runtime::Handle::current(); - let cmd = AgentList { - service: Arc::new(AgentService::new(rt)), - }; - let out = cmd.run(&Ctx::default(), AgentListParams {}).await.unwrap(); - assert!(out.agents.is_empty()); - } -} diff --git a/core/continuum-core/src/commands/agent/mod.rs b/core/continuum-core/src/commands/agent/mod.rs deleted file mode 100644 index c90f83cd55..0000000000 --- a/core/continuum-core/src/commands/agent/mod.rs +++ /dev/null @@ -1,89 +0,0 @@ -//! `agent/` — the autonomous coding-agent surface as typed -//! [`ActionCommand`](crate::sdk_codegen::ActionCommand)s, one command per file. -//! -//! These verbs once lived only in [`AgentModule::handle_command`](crate::modules::agent)'s -//! stringly `match` — dispatchable, but with no descriptor in the registry, so a -//! persona was never OFFERED them. As typed commands each gets a descriptor (so it -//! appears in the persona tool surface, the grid ACL, codegen, `uu`) AND routes -//! through the O(1) lock-free typed path. The wire name mirrors the file path — -//! `commands/agent/start.rs` ⟺ `agent/start`. -//! -//! Access split follows the resource-authority boundary: `start`/`stop` control a -//! background agent that runs arbitrary shell, writes files, and drives git → an -//! authority mutation, gated `Privileged`. `status`/`list`/`wait` are introspection -//! → `AiSafe`. -//! -//! All five share the module's [`AgentService`](crate::modules::agent::AgentService) -//! (the live agent map + runtime handle + bus), captured by `Arc` so one caller's -//! `start` and another's `status` observe the same agents. - -use std::sync::Arc; - -use crate::modules::agent::AgentService; -use crate::sdk_codegen::DynCommand; - -pub mod list; -pub mod start; -pub mod status; -pub mod stop; -pub mod wait; - -use list::AgentList; -use start::AgentStart; -use status::AgentGetStatus; -use stop::AgentStop; -use wait::AgentWait; - -/// The dep-holding `agent/*` command objects [`AgentModule`](crate::modules::agent::AgentModule) -/// contributes to the kernel's typed object map. Each carries the shared -/// `Arc`; the executor routes each name straight here, winning over -/// the (now-dead) legacy prefix arm. -pub fn command_objects(service: Arc) -> Vec> { - vec![ - Arc::new(AgentStart { - service: service.clone(), - }), - Arc::new(AgentGetStatus { - service: service.clone(), - }), - Arc::new(AgentStop { - service: service.clone(), - }), - Arc::new(AgentList { - service: service.clone(), - }), - Arc::new(AgentWait { service }), - ] -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::sdk_codegen::ActionCommand; - - // what this catches: the five agent commands carry their `agent/` wire - // names — the routing keys uu / the persona tool surface / the grid bind to. The - // name mirrors the file path; drift silently breaks "the file tree IS the - // namespace". - #[test] - fn agent_command_names_mirror_their_path() { - assert_eq!(AgentStart::NAME, "agent/start"); - assert_eq!(AgentGetStatus::NAME, "agent/status"); - assert_eq!(AgentStop::NAME, "agent/stop"); - assert_eq!(AgentList::NAME, "agent/list"); - assert_eq!(AgentWait::NAME, "agent/wait"); - } - - // what this catches: the authority split — spawning/stopping a shell-running - // agent is Privileged; reads are AiSafe. A regression here would silently widen - // (or close) the persona surface for a high-capability tool. - #[test] - fn access_levels_follow_the_authority_boundary() { - use crate::sdk_codegen::AccessLevel; - assert!(matches!(AgentStart::ACCESS, AccessLevel::Privileged)); - assert!(matches!(AgentStop::ACCESS, AccessLevel::Privileged)); - assert!(matches!(AgentGetStatus::ACCESS, AccessLevel::AiSafe)); - assert!(matches!(AgentList::ACCESS, AccessLevel::AiSafe)); - assert!(matches!(AgentWait::ACCESS, AccessLevel::AiSafe)); - } -} diff --git a/core/continuum-core/src/commands/agent/start.rs b/core/continuum-core/src/commands/agent/start.rs deleted file mode 100644 index cce03df88c..0000000000 --- a/core/continuum-core/src/commands/agent/start.rs +++ /dev/null @@ -1,111 +0,0 @@ -//! `agent/start` — launch an autonomous coding agent in the background. Returns a -//! handle immediately; poll `agent/status` / block on `agent/wait`. Spawns an agent -//! that runs arbitrary shell, writes files, and drives git in `working_dir` → an -//! authority mutation, gated `Privileged`. - -use std::path::PathBuf; -use std::sync::Arc; - -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use ts_rs::TS; - -use crate::modules::agent::AgentService; - -fn default_max_iterations() -> u32 { - 50 -} - -/// Inputs to `agent/start`. -#[derive(Debug, Clone, Serialize, Deserialize, TS, JsonSchema)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentStartParams.ts" -)] -pub struct AgentStartParams { - /// The task for the agent to accomplish (free-form natural language). - pub task: String, - /// Absolute path to the workspace the agent operates in. - pub working_dir: String, - /// Model name to drive the agent loop, e.g. `deepseek-chat`, - /// `claude-sonnet-4-5-20250929`, `gpt-4`. Must match an available provider. - pub model: String, - /// Maximum build/test/fix iterations before the agent gives up (default 50). - #[serde(default = "default_max_iterations")] - pub max_iterations: u32, -} - -/// Result of `agent/start`: the handle to poll. -#[derive(Debug, Clone, Serialize, Deserialize, TS)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentStartResult.ts" -)] -pub struct AgentStartResult { - /// The handle identifying the spawned agent — pass it back as `agentHandle` to - /// `status`/`stop`/`wait`. - // An OUTCOME never traverses the request envelope, so this field could have kept - // the bare name; it is `agentHandle` so what `start` returns is spelled the way the - // three verbs that consume it must receive it (card ea28d2f6). - #[serde(rename = "agentHandle")] - pub handle: String, -} - -crate::action_command! { - /// Start an autonomous coding agent on a task. The agent explores the workspace, - /// edits files, runs builds/tests, and iterates until done — running real shell - /// commands and git in the given working directory. Returns a handle immediately; - /// use `agent/status` to poll progress or `agent/wait` to block for the result. - pub struct AgentStart { service: Arc } - name: "agent/start", - access: Privileged, - params: AgentStartParams, - output: AgentStartResult, - run(this, _ctx, p) => { - let handle = this.service.spawn_agent( - p.task.clone(), - PathBuf::from(&p.working_dir), - p.max_iterations, - p.model.clone(), - ); - crate::log_info!("module", "agent", "Started agent {} for task: {}", &handle, p.task); - Ok(AgentStartResult { handle }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::sdk_codegen::ActionCommand; - - // what this catches: name/access wiring — starting a shell-running agent is a - // Privileged authority mutation, never offered on the AiSafe surface. - #[test] - fn name_and_access_wired() { - assert_eq!(AgentStart::NAME, "agent/start"); - assert!(matches!( - AgentStart::ACCESS, - crate::sdk_codegen::AccessLevel::Privileged - )); - } - - // what this catches: the doc comment ⟹ DESCRIPTION wiring stays live, so a - // persona offered this tool gets the operating guidance. - #[test] - fn description_from_doc_comment() { - assert!(AgentStart::DESCRIPTION.contains("autonomous coding agent")); - } - - // what this catches: the optional `max_iterations` defaults to 50 when omitted — - // the legacy `u64_or("max_iterations", 50)` contract, preserved via serde default. - #[test] - fn max_iterations_defaults_to_50() { - let p: AgentStartParams = serde_json::from_value(serde_json::json!({ - "task": "do x", - "working_dir": "/tmp/x", - "model": "deepseek-chat" - })) - .unwrap(); - assert_eq!(p.max_iterations, 50); - } -} diff --git a/core/continuum-core/src/commands/agent/status.rs b/core/continuum-core/src/commands/agent/status.rs deleted file mode 100644 index 5ee77a605c..0000000000 --- a/core/continuum-core/src/commands/agent/status.rs +++ /dev/null @@ -1,92 +0,0 @@ -//! `agent/status` — progress snapshot for one agent by handle. Returns `null` when -//! the handle is unknown (or already evicted post-completion). Read → `AiSafe`. - -use std::sync::Arc; - -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use ts_rs::TS; - -use crate::modules::agent::{AgentService, AgentStatusInfo}; - -/// Inputs to `agent/status`. -#[derive(Debug, Clone, Serialize, Deserialize, TS, JsonSchema)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentStatusParams.ts" -)] -pub struct AgentStatusParams { - /// The agent handle returned by `agent/start`. - // `agentHandle` on the wire, NOT `handle`: the envelope owns that name and refuses a - // string for it (`expected struct HandleRef`), so this verb could not be called through - // the envelope at all — card ea28d2f6. The Rust field keeps its name. - #[serde(rename = "agentHandle")] - pub handle: String, -} - -/// Result of `agent/status` — the agent's progress snapshot, or absent when no -/// agent has that handle (unknown, or already finished and evicted). A named -/// wrapper so the wire type is a struct, not a bare `T | null`. -#[derive(Debug, Clone, Serialize, TS)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentStatusLookup.ts" -)] -pub struct AgentStatusLookup { - /// The progress snapshot, or absent when the handle is unknown/evicted. - #[serde(skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub status: Option, -} - -crate::action_command! { - /// Get an agent's progress: status, iteration, files created/modified, and the - /// final summary or error. The `status` field is absent when no agent has that - /// handle (unknown, or already finished and evicted). - pub struct AgentGetStatus { service: Arc } - name: "agent/status", - access: AiSafe, - params: AgentStatusParams, - output: AgentStatusLookup, - run(this, _ctx, p) => { - Ok(AgentStatusLookup { - status: this.service.status_of(&p.handle), - }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::sdk_codegen::{ActionCommand, Ctx}; - - // what this catches: name/access wiring — status is a read on the AiSafe surface. - #[test] - fn name_and_access_wired() { - assert_eq!(AgentGetStatus::NAME, "agent/status"); - assert!(matches!( - AgentGetStatus::ACCESS, - crate::sdk_codegen::AccessLevel::AiSafe - )); - } - - // what this catches: an unknown handle yields None (→ JSON null), preserving the - // legacy "agent not found, no hard error" contract instead of erroring. - #[tokio::test] - async fn unknown_handle_is_none() { - let rt = tokio::runtime::Handle::current(); - let cmd = AgentGetStatus { - service: Arc::new(AgentService::new(rt)), - }; - let out = cmd - .run( - &Ctx::default(), - AgentStatusParams { - handle: "agent-doesnotexist".into(), - }, - ) - .await - .unwrap(); - assert!(out.status.is_none()); - } -} diff --git a/core/continuum-core/src/commands/agent/stop.rs b/core/continuum-core/src/commands/agent/stop.rs deleted file mode 100644 index c75e0104f9..0000000000 --- a/core/continuum-core/src/commands/agent/stop.rs +++ /dev/null @@ -1,87 +0,0 @@ -//! `agent/stop` — request a running agent halt at its next iteration boundary. -//! Controlling background compute is an authority op → `Privileged`. - -use std::sync::Arc; - -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use ts_rs::TS; - -use crate::modules::agent::AgentService; - -/// Inputs to `agent/stop`. -#[derive(Debug, Clone, Serialize, Deserialize, TS, JsonSchema)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentStopParams.ts" -)] -pub struct AgentStopParams { - /// The agent handle returned by `agent/start`. - // `agentHandle` on the wire, NOT `handle`: the envelope owns that name and refuses a - // string for it (`expected struct HandleRef`), so this verb could not be called through - // the envelope at all — card ea28d2f6. The Rust field keeps its name. - #[serde(rename = "agentHandle")] - pub handle: String, -} - -/// Result of `agent/stop`. -#[derive(Debug, Clone, Serialize, Deserialize, TS)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentStopResult.ts" -)] -pub struct AgentStopResult { - /// `true` if the handle was found and flagged to stop; `false` if no such agent. - pub stop_requested: bool, -} - -crate::action_command! { - /// Request a running agent stop. The agent checks the flag at its next iteration - /// boundary and winds down to a `stopped` state. Returns whether the handle was - /// found (`false` = no such agent). - pub struct AgentStop { service: Arc } - name: "agent/stop", - access: Privileged, - params: AgentStopParams, - output: AgentStopResult, - run(this, _ctx, p) => { - Ok(AgentStopResult { stop_requested: this.service.request_stop(&p.handle) }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::sdk_codegen::{ActionCommand, Ctx}; - - // what this catches: name/access wiring — controlling background compute is a - // Privileged authority op, not the AiSafe read surface. - #[test] - fn name_and_access_wired() { - assert_eq!(AgentStop::NAME, "agent/stop"); - assert!(matches!( - AgentStop::ACCESS, - crate::sdk_codegen::AccessLevel::Privileged - )); - } - - // what this catches: stopping an unknown handle reports `stop_requested: false` - // (soft miss), preserving the legacy "agent not found, no panic" contract. - #[tokio::test] - async fn unknown_handle_reports_not_requested() { - let rt = tokio::runtime::Handle::current(); - let cmd = AgentStop { - service: Arc::new(AgentService::new(rt)), - }; - let out = cmd - .run( - &Ctx::default(), - AgentStopParams { - handle: "agent-doesnotexist".into(), - }, - ) - .await - .unwrap(); - assert!(!out.stop_requested); - } -} diff --git a/core/continuum-core/src/commands/agent/wait.rs b/core/continuum-core/src/commands/agent/wait.rs deleted file mode 100644 index 24aef2d2bf..0000000000 --- a/core/continuum-core/src/commands/agent/wait.rs +++ /dev/null @@ -1,109 +0,0 @@ -//! `agent/wait` — block until an agent finishes (or a timeout elapses), returning -//! its final status. Blocking read → `AiSafe`. - -use std::sync::Arc; - -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use ts_rs::TS; - -use crate::modules::agent::{AgentService, AgentStatusInfo}; -use crate::sdk_codegen::CommandError; - -fn default_timeout_ms() -> u64 { - 300_000 -} - -/// Inputs to `agent/wait`. -#[derive(Debug, Clone, Serialize, Deserialize, TS, JsonSchema)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentWaitParams.ts" -)] -pub struct AgentWaitParams { - /// The agent handle returned by `agent/start`. - // `agentHandle` on the wire, NOT `handle`: the envelope owns that name and refuses a - // string for it (`expected struct HandleRef`), so this verb could not be called through - // the envelope at all — card ea28d2f6. The Rust field keeps its name. - #[serde(rename = "agentHandle")] - pub handle: String, - /// Max milliseconds to wait before returning a timeout error (default 300000). - #[serde(default = "default_timeout_ms")] - #[ts(type = "number")] - pub timeout_ms: u64, -} - -crate::action_command! { - /// Block until the agent with this handle finishes, then return its final status - /// (summary or error). Errors on timeout, or if no agent has that handle. Use - /// after `agent/start` to wait for a synchronous result. - pub struct AgentWait { service: Arc } - name: "agent/wait", - access: AiSafe, - params: AgentWaitParams, - output: AgentStatusInfo, - run(this, _ctx, p) => { - match this.service.wait_for(&p.handle, p.timeout_ms).await { - Ok(Some(info)) => Ok(info), - // Unknown handle (or evicted before we could read the final state). - Ok(None) => Err(CommandError::NotFound(format!( - "no agent with handle '{}'", - p.handle - ))), - // Timed out waiting — a runtime condition, not bad input. - Err(e) => Err(CommandError::Internal(e)), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::sdk_codegen::{ActionCommand, Ctx}; - - // what this catches: name/access wiring — waiting is a (blocking) read on AiSafe. - #[test] - fn name_and_access_wired() { - assert_eq!(AgentWait::NAME, "agent/wait"); - assert!(matches!( - AgentWait::ACCESS, - crate::sdk_codegen::AccessLevel::AiSafe - )); - } - - // what this catches: the optional `timeout_ms` defaults to 300000 when omitted — - // the legacy `u64_or("timeout_ms", 300000)` contract, preserved via serde default. - #[test] - fn timeout_defaults_to_300s() { - // Through the REAL envelope, with the wire name: a bare `handle` here is the - // envelope's HandleRef and the call fails to parse (card ea28d2f6). - let req = crate::runtime::CommandRequest::::from_value(serde_json::json!({ - "agentHandle": "agent-abc" - })) - .unwrap(); - assert!(req.handle.is_none()); - assert_eq!(req.params.handle, "agent-abc"); - assert_eq!(req.params.timeout_ms, 300_000); - } - - // what this catches: waiting on an unknown handle is a NotFound error (not a hang - // and not a silent success) — the typed mapping of the service's `Ok(None)`. - #[tokio::test] - async fn unknown_handle_is_not_found() { - let rt = tokio::runtime::Handle::current(); - let cmd = AgentWait { - service: Arc::new(AgentService::new(rt)), - }; - let err = cmd - .run( - &Ctx::default(), - AgentWaitParams { - handle: "agent-doesnotexist".into(), - timeout_ms: 1000, - }, - ) - .await - .unwrap_err(); - assert!(matches!(err, CommandError::NotFound(_))); - } -} diff --git a/core/continuum-core/src/commands/help.rs b/core/continuum-core/src/commands/help.rs index 4e98ebbdee..eb186f6aa0 100644 --- a/core/continuum-core/src/commands/help.rs +++ b/core/continuum-core/src/commands/help.rs @@ -223,14 +223,13 @@ mod tests { // what this catches: the RIGHT command losing the alphabetical coin-flip. #3769 // added the token tier so an invented verb gets suggestions instead of silence, // and then — measured live on the box that produced the original 31-call loop — - // `list_cards` returned agent/list, ai/lora/list, ai/models/list, - // ai/providers/list, benchmark/list, code/list: six names, none of them the two + // `list_cards` returned ai/lora/list, ai/models/list, ai/providers/list, + // benchmark/list, code/list and one since-deleted verb: six names, none of the two // she needed, because twenty commands tie at score 0 and take(6) cuts at `code/`. // Suggestions are not a route unless the route survives the window. #[test] fn the_closest_command_survives_the_window_when_many_share_a_word() { let names = [ - "agent/list", "ai/lora/list", "ai/models/list", "ai/providers/list", diff --git a/core/continuum-core/src/commands/mod.rs b/core/continuum-core/src/commands/mod.rs index 7bc6919a43..094bc69fbb 100644 --- a/core/continuum-core/src/commands/mod.rs +++ b/core/continuum-core/src/commands/mod.rs @@ -13,7 +13,6 @@ pub mod access; mod tool_aliases; pub use continuum_store::commands::adapter; -pub mod agent; pub mod ai; pub mod airc; pub mod auth; diff --git a/core/continuum-core/src/ipc/mod.rs b/core/continuum-core/src/ipc/mod.rs index a99405e650..f0f84d8510 100644 --- a/core/continuum-core/src/ipc/mod.rs +++ b/core/continuum-core/src/ipc/mod.rs @@ -1,6 +1,5 @@ use crate::code::{FileEngine, ShellSession}; use crate::gpu::GpuMemoryManager; -use crate::modules::agent::AgentModule; use crate::modules::ai_provider::AIProviderModule; use crate::modules::airc::AircModule; use crate::modules::airc_bridge_directive::AircBridgeDirectiveModule; diff --git a/core/continuum-core/src/ipc/start_server/service_modules.rs b/core/continuum-core/src/ipc/start_server/service_modules.rs index 6d3b106976..40e5119000 100644 --- a/core/continuum-core/src/ipc/start_server/service_modules.rs +++ b/core/continuum-core/src/ipc/start_server/service_modules.rs @@ -102,9 +102,6 @@ pub(super) fn register_code_data_and_service_modules( // Provides mcp/list-tools, mcp/search-tools, mcp/tool-help runtime.register(Arc::new(crate::modules::mcp::MCPModule::new())); - // AgentModule: Autonomous AI coding agents with structured tool calling - // Provides agent/start, agent/status, agent/stop, agent/list, agent/wait - runtime.register(Arc::new(AgentModule::new(rt_handle.clone()))); CodeHandles { file_engines, shell_sessions, diff --git a/core/continuum-core/src/modules/agent.rs b/core/continuum-core/src/modules/agent.rs deleted file mode 100644 index 79c3498bf5..0000000000 --- a/core/continuum-core/src/modules/agent.rs +++ /dev/null @@ -1,829 +0,0 @@ -//! AgentModule — Autonomous AI coding agent with structured tool calling. -//! -//! Unlike sentinels which are script-based, agents: -//! 1. Have STRUCTURED TOOL DEFINITIONS - LLM sees proper tool schemas -//! 2. Use TOOL CALLING protocol - Real structured output parsing -//! 3. Maintain FULL CONTEXT - Conversation history -//! 4. ITERATE until done - Build, test, fix loop -//! 5. Handle REAL TASKS - Multi-file changes, codebase exploration -//! -//! Commands: -//! - agent/start: Start an autonomous agent (returns handle immediately) -//! - agent/status: Get agent status and progress -//! - agent/stop: Stop a running agent -//! - agent/list: List all agents (running and completed) -//! -//! Events emitted: -//! - agent:{handle}:progress - Progress updates -//! - agent:{handle}:action - Tool calls and results -//! - agent:{handle}:complete - Agent finished (success or failure) -//! -//! Priority: Normal — agents are long-running background tasks. - -use crate::ai::adapter::{AIProviderAdapter, InferenceDevice}; -use crate::log_info; -use crate::runtime::{ - CommandResult, MessageBus, ModuleConfig, ModuleContext, ModulePriority, ServiceModule, -}; -use async_trait::async_trait; -use dashmap::DashMap; -use rayon::prelude::*; -use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; -use std::any::Any; -use std::path::{Path, PathBuf}; -use std::process::Command; -use std::sync::Arc; -use std::time::{Duration, Instant}; -use tokio::sync::Notify; -use ts_rs::TS; -use uuid::Uuid; - -// ============================================================================ -// TOOL DEFINITIONS - Simple structs, generated at runtime when needed -// ============================================================================ - -// ============================================================================ -// AGENT STATE -// ============================================================================ - -/// Agent execution status -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, TS)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentStatus.ts" -)] -#[serde(rename_all = "snake_case")] -pub enum AgentStatus { - Running, - Completed, - Failed, - Stopped, -} - -/// A single tool call made by the agent -#[derive(Debug, Clone, Serialize, Deserialize, TS)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentToolCall.ts" -)] -pub struct ToolCall { - pub name: String, - #[ts(type = "Record")] - pub arguments: Value, -} - -/// Result of executing a tool -#[derive(Debug, Clone, Serialize, Deserialize, TS)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentToolResult.ts" -)] -pub struct ToolResult { - pub success: bool, - pub output: String, - #[serde(skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub error: Option, -} - -/// A single action taken by the agent -#[derive(Debug, Clone, Serialize, Deserialize, TS)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentAction.ts" -)] -pub struct AgentAction { - pub timestamp: String, - pub action_type: String, - #[ts(optional)] - pub tool_name: Option, - #[ts(optional, type = "Record")] - pub tool_args: Option, - #[ts(optional)] - pub result: Option, - #[ts(optional)] - pub thought: Option, -} - -/// A typed snapshot of an agent's progress — the wire output of `agent/status`, -/// `agent/list`, and `agent/wait`. Replaces the old ad-hoc `to_status_json` Value -/// so every reader gets a contracted shape + a ts-rs binding. -#[derive(Debug, Clone, Serialize, Deserialize, TS)] -#[ts( - export, - export_to = "../../../protocol/typescript/agent/AgentStatusInfo.ts" -)] -pub struct AgentStatusInfo { - pub handle: String, - pub task: String, - pub working_dir: String, - pub status: AgentStatus, - pub iteration: u32, - pub max_iterations: u32, - #[ts(type = "number")] - pub elapsed_ms: u64, - pub actions_count: u32, - pub files_created: Vec, - pub files_modified: Vec, - #[ts(optional)] - pub summary: Option, - #[ts(optional)] - pub error: Option, -} - -/// Full agent state -#[derive(Debug)] -pub struct AgentState { - pub handle: String, - pub task: String, - pub working_dir: PathBuf, - pub status: AgentStatus, - pub iteration: u32, - pub max_iterations: u32, - pub started_at: Instant, - pub completed_at: Option, - pub actions: Vec, - pub files_created: Vec, - pub files_modified: Vec, - pub summary: Option, - pub error: Option, - /// Notify when agent completes (for waiters) - pub completion_notify: Arc, - /// Stop signal - pub stop_requested: bool, -} - -impl AgentState { - pub fn new(handle: String, task: String, working_dir: PathBuf, max_iterations: u32) -> Self { - Self { - handle, - task, - working_dir, - status: AgentStatus::Running, - iteration: 0, - max_iterations, - started_at: Instant::now(), - completed_at: None, - actions: Vec::new(), - files_created: Vec::new(), - files_modified: Vec::new(), - summary: None, - error: None, - completion_notify: Arc::new(Notify::new()), - stop_requested: false, - } - } - - pub fn elapsed_ms(&self) -> u64 { - self.started_at.elapsed().as_millis() as u64 - } - - pub fn to_status_info(&self) -> AgentStatusInfo { - AgentStatusInfo { - handle: self.handle.clone(), - task: self.task.clone(), - working_dir: self.working_dir.to_string_lossy().into_owned(), - status: self.status.clone(), - iteration: self.iteration, - max_iterations: self.max_iterations, - elapsed_ms: self.elapsed_ms(), - actions_count: self.actions.len() as u32, - files_created: self.files_created.clone(), - files_modified: self.files_modified.clone(), - summary: self.summary.clone(), - error: self.error.clone(), - } - } -} - -// ============================================================================ -// MODULE -// ============================================================================ - -/// Shared agent-service state captured by the typed `agent/*` command objects and -/// the host [`AgentModule`]. Holds the live agent map, the runtime handle used to -/// spawn background loops, and the event bus (set at module init). Wrapped in `Arc` -/// so every command + the module share ONE map: one caller's `agent/start` and -/// another's `agent/status` see the same agents. -pub struct AgentService { - /// Active and completed agents - agents: Arc>>, - /// Tokio runtime for spawning agent tasks - rt_handle: tokio::runtime::Handle, - /// Message bus for events - bus: std::sync::OnceLock>, -} - -impl AgentService { - pub fn new(rt_handle: tokio::runtime::Handle) -> Self { - Self { - agents: Arc::new(DashMap::new()), - rt_handle, - bus: std::sync::OnceLock::new(), - } - } - - /// Set the event bus (called once from module init). Idempotent. - pub fn set_bus(&self, bus: Arc) { - let _ = self.bus.set(bus); - } - - /// Look up an agent's status snapshot, or `None` if no such handle. - pub fn status_of(&self, handle: &str) -> Option { - self.agents - .get(handle) - .and_then(|entry| entry.lock().ok().map(|state| state.to_status_info())) - } - - /// Snapshot every live agent. - pub fn list(&self) -> Vec { - self.agents - .iter() - .filter_map(|entry| entry.lock().ok().map(|state| state.to_status_info())) - .collect() - } - - /// Request a running agent stop. Returns `true` if the handle was found. - pub fn request_stop(&self, handle: &str) -> bool { - if let Some(entry) = self.agents.get(handle) { - if let Ok(mut state) = entry.lock() { - state.stop_requested = true; - log_info!("module", "agent", "Stop requested for agent {}", handle); - return true; - } - } - false - } - - /// Wait for an agent to finish, up to `timeout_ms`. `Ok(Some(_))` is the final - /// status, `Ok(None)` means the handle was unknown (or vanished post-completion, - /// since completed agents are evicted to free their conversation history), and - /// `Err` is a timeout. - pub async fn wait_for( - &self, - handle: &str, - timeout_ms: u64, - ) -> Result, String> { - // Snapshot the completion-notify under the lock, releasing it before we await - // (never hold a Mutex guard across an await point). Already-finished agents - // return immediately. - let notify = { - match self.agents.get(handle) { - Some(entry) => match entry.lock() { - Ok(state) => { - if state.status != AgentStatus::Running { - return Ok(Some(state.to_status_info())); - } - state.completion_notify.clone() - } - Err(_) => return Ok(None), - }, - None => return Ok(None), - } - }; - - match tokio::time::timeout(Duration::from_millis(timeout_ms), notify.notified()).await { - // Completed: re-read the final state. May already be evicted (None). - Ok(_) => Ok(self.status_of(handle)), - Err(_) => Err("Timeout waiting for agent".to_string()), - } - } - - /// Start an autonomous agent in the background. Generates a fresh handle, - /// inserts the initial state, spawns the agent loop, and returns the handle - /// immediately so the caller can poll `status`/`wait`. - pub fn spawn_agent( - &self, - task: String, - working_dir: PathBuf, - max_iterations: u32, - model: String, - ) -> String { - let handle = format!("agent-{}", airc_core::shown_id::shown_form(Uuid::new_v4())); - let agents = self.agents.clone(); - let bus = self.bus.get().cloned(); - - // Create initial state - let state = AgentState::new( - handle.clone(), - task.clone(), - working_dir.clone(), - max_iterations, - ); - let completion_notify = state.completion_notify.clone(); - agents.insert(handle.clone(), std::sync::Mutex::new(state)); - - // The handle returned to the caller; `handle` itself is moved into the loop. - let returned = handle.clone(); - - // Spawn background task - self.rt_handle.spawn(async move { - let result = run_agent_loop( - handle.clone(), - task, - working_dir, - max_iterations, - model, - agents.clone(), - bus, - ) - .await; - - // Update final state, notify waiters, then remove from map. - // Keeping completed agents in the DashMap leaks memory — each holds - // full conversation history, tool call results, and file contents. - // With 14 personas doing constant tool calls, this is GB/hour. - if let Some(entry) = agents.get(&handle) { - if let Ok(mut state) = entry.lock() { - state.completed_at = Some(Instant::now()); - match result { - Ok((summary, files_created, files_modified)) => { - state.status = AgentStatus::Completed; - state.summary = Some(summary); - state.files_created = files_created; - state.files_modified = files_modified; - } - Err(e) => { - if state.stop_requested { - state.status = AgentStatus::Stopped; - } else { - state.status = AgentStatus::Failed; - } - state.error = Some(e); - } - } - } - } - - // Notify waiters - completion_notify.notify_waiters(); - - // Remove completed agent from map — frees conversation history, - // tool results, and all accumulated state. - agents.remove(&handle); - }); - - returned - } -} - -/// The host shell for the `agent/*` surface. Holds the shared [`AgentService`] -/// (the live agent map + runtime handle + bus) that the typed command objects -/// capture; the verbs themselves are migrated to [`crate::commands::agent`]. -pub struct AgentModule { - service: Arc, -} - -impl AgentModule { - pub fn new(rt_handle: tokio::runtime::Handle) -> Self { - Self { - service: Arc::new(AgentService::new(rt_handle)), - } - } -} - -/// Main agent loop - runs in background tokio task -async fn run_agent_loop( - handle: String, - task: String, - working_dir: PathBuf, - max_iterations: u32, - model: String, - agents: Arc>>, - bus: Option>, -) -> Result<(String, Vec, Vec), String> { - let mut conversation: Vec = vec![ - json!({ - "role": "system", - "content": build_system_prompt(&working_dir) - }), - json!({ - "role": "user", - "content": task - }), - ]; - - let mut files_created: Vec = Vec::new(); - let mut files_modified: Vec = Vec::new(); - - for iteration in 1..=max_iterations { - // Check for stop request - { - if let Some(entry) = agents.get(&handle) { - if let Ok(mut state) = entry.lock() { - if state.stop_requested { - return Err("Agent stopped by user".to_string()); - } - state.iteration = iteration; - } - } - } - - // Emit progress event - if let Some(ref b) = bus { - b.publish_async_only( - &format!("agent:{}:progress", handle), - json!({ - "handle": handle, - "iteration": iteration, - "max_iterations": max_iterations, - }), - ); - } - - // Get LLM response - let response = call_llm(&conversation, &model, &working_dir).await?; - - // Parse tool calls from response - let tool_calls = parse_tool_calls(&response); - - if tool_calls.is_empty() { - // No tool calls - LLM is just thinking, add to context and continue - conversation.push(json!({ - "role": "assistant", - "content": response - })); - - // Record thought action - if let Some(entry) = agents.get(&handle) { - if let Ok(mut state) = entry.lock() { - state.actions.push(AgentAction { - timestamp: chrono::Utc::now().to_rfc3339(), - action_type: "thought".to_string(), - tool_name: None, - tool_args: None, - result: None, - thought: Some(response.clone()), - }); - } - } - continue; - } - - // Record assistant message - conversation.push(json!({ - "role": "assistant", - "content": response, - "tool_calls": tool_calls - })); - - // Execute tools IN PARALLEL using Rayon - let tool_results: Vec<(ToolCall, ToolResult)> = tool_calls - .par_iter() - .map(|call| { - let result = execute_tool(call, &working_dir); - (call.clone(), result) - }) - .collect(); - - // Process results - for (call, result) in &tool_results { - // Add tool result to conversation - conversation.push(json!({ - "role": "tool", - "name": call.name, - "content": result.output - })); - - // Track file changes - if call.name == "write_file" { - if let Some(path) = call.arguments.get("path").and_then(|v| v.as_str()) { - if !files_created.contains(&path.to_string()) - && !files_modified.contains(&path.to_string()) - { - // Check if file existed before - let full_path = working_dir.join(path); - if full_path.exists() { - files_modified.push(path.to_string()); - } else { - files_created.push(path.to_string()); - } - } - } - } - - if call.name == "edit_file" { - if let Some(path) = call.arguments.get("path").and_then(|v| v.as_str()) { - if !files_modified.contains(&path.to_string()) { - files_modified.push(path.to_string()); - } - } - } - - // Record action - if let Some(entry) = agents.get(&handle) { - if let Ok(mut state) = entry.lock() { - state.actions.push(AgentAction { - timestamp: chrono::Utc::now().to_rfc3339(), - action_type: "tool_call".to_string(), - tool_name: Some(call.name.clone()), - tool_args: Some(call.arguments.clone()), - result: Some(result.clone()), - thought: None, - }); - } - } - - // Emit action event - if let Some(ref b) = bus { - b.publish_async_only( - &format!("agent:{}:action", handle), - json!({ - "handle": handle, - "tool": call.name, - "success": result.success, - }), - ); - } - - // Check for completion - if call.name == "complete" { - let summary = call - .arguments - .get("summary") - .and_then(|v| v.as_str()) - .unwrap_or("Task completed") - .to_string(); - - // Emit complete event - if let Some(ref b) = bus { - b.publish_async_only( - &format!("agent:{}:complete", handle), - json!({ - "handle": handle, - "success": true, - "summary": summary, - "files_created": files_created, - "files_modified": files_modified, - }), - ); - } - - return Ok((summary, files_created, files_modified)); - } - - if call.name == "give_up" { - let reason = call - .arguments - .get("reason") - .and_then(|v| v.as_str()) - .unwrap_or("Task failed") - .to_string(); - - // Emit complete event (failure) - if let Some(ref b) = bus { - b.publish_async_only( - &format!("agent:{}:complete", handle), - json!({ - "handle": handle, - "success": false, - "reason": reason, - }), - ); - } - - return Err(reason); - } - } - } - - Err(format!("Max iterations ({}) reached", max_iterations)) -} - -/// Build system prompt with tool definitions -fn build_system_prompt(working_dir: &Path) -> String { - // Tool documentation - the single source of truth for tool descriptions - let tool_docs = r#"read_file: Read a file from the workspace. Returns content with line numbers. - - path: (required) Relative path to the file - - start_line: Start line (1-indexed, optional) - - end_line: End line (1-indexed, optional) - -write_file: Write content to a file. Creates directories if needed. - - path: (required) Relative path to the file - - content: (required) File content to write - -edit_file: Make a targeted edit to a file. Use search/replace pattern. - - path: (required) Relative path to the file - - search: (required) Exact text to find (must be unique in file) - - replace: (required) Text to replace it with - -search_files: Search for a regex pattern across all files. Returns matching lines. - - pattern: (required) Regex pattern to search for - - file_glob: Glob pattern to filter files (e.g., "*.ts") - - max_results: Maximum matches to return (default: 50) - -list_files: List files in a directory. Shows directory tree structure. - - path: Directory path (default: workspace root) - - depth: Max depth to traverse (default: 3) - - pattern: Glob pattern to filter (e.g., "*.ts") - -run_command: Execute a shell command. Use for builds, tests, etc. - - command: (required) Shell command to execute - - timeout_ms: Timeout in milliseconds (default: 60000) - -git_status: Show git status - modified, staged, and untracked files. - (no parameters) - -git_diff: Show git diff of changes. - - path: Specific file to diff (optional) - - staged: Show staged changes only - -complete: Signal that the task is complete. Provide a summary. - - summary: (required) Summary of what was accomplished - - files_changed: List of files created or modified - -give_up: Signal that the task cannot be completed. Explain why. - - reason: (required) Why the task cannot be completed - - attempted: What was attempted"#; - - format!( - r#"You are an expert software engineer working on a coding task. You have access to the following tools: - -{} - -IMPORTANT RULES: -1. Always explore the codebase before making changes (use list_files, search_files, read_file) -2. Make targeted edits rather than rewriting entire files when possible -3. Test your changes by running builds/tests after modifications -4. If a build fails, read the error output carefully and fix the issues -5. When you're done, call 'complete' with a summary -6. If you truly cannot complete the task, call 'give_up' with an explanation - -To use a tool, output a JSON block in this format: -```tool -{{"name": "tool_name", "arguments": {{"arg1": "value1"}}}} -``` - -You can call multiple tools in one response by including multiple tool blocks. - -Working directory: {}"#, - tool_docs, - working_dir.display() - ) -} - -/// Call the LLM for next response via AI provider module -async fn call_llm( - conversation: &[Value], - model: &str, - _working_dir: &Path, -) -> Result { - use crate::ai::{ - AdapterRegistry, AnthropicAdapter, ChatMessage, MessageContent, OpenAICompatibleAdapter, - TextGenerationRequest, - }; - use continuum_base::secrets::get_secret; - - // Build messages array for AI provider - let messages: Vec = conversation - .iter() - .filter_map(|msg| { - let role = msg.get("role").and_then(|v| v.as_str())?; - let content = msg.get("content").and_then(|v| v.as_str())?; - // Map tool role to user (tool results are context) - let mapped_role = match role { - "tool" => "user", - r => r, - }; - Some(ChatMessage { - role: mapped_role.to_string(), - content: MessageContent::Text(content.to_string()), - name: None, - }) - }) - .collect(); - - // Create adapter registry with available providers - let mut registry = AdapterRegistry::new(); - - // Register adapters based on available API keys — init-then- - // register per task #162 (registry stores Arc; no - // initialize_all on the registry). - if get_secret("DEEPSEEK_API_KEY").is_some() { - let mut a = OpenAICompatibleAdapter::from_registry("deepseek"); - a.initialize().await?; - registry.register(std::sync::Arc::new(a), 0); - } - if get_secret("ANTHROPIC_API_KEY").is_some() { - let mut a = AnthropicAdapter::new(); - a.initialize().await?; - registry.register(std::sync::Arc::new(a), 1); - } - if get_secret("OPENAI_API_KEY").is_some() { - let mut a = OpenAICompatibleAdapter::from_registry("openai"); - a.initialize().await?; - registry.register(std::sync::Arc::new(a), 2); - } - if get_secret("GROQ_API_KEY").is_some() { - let mut a = OpenAICompatibleAdapter::from_registry("groq"); - a.initialize().await?; - registry.register(std::sync::Arc::new(a), 3); - } - if get_secret("TOGETHER_API_KEY").is_some() { - let mut a = OpenAICompatibleAdapter::from_registry("together"); - a.initialize().await?; - registry.register(std::sync::Arc::new(a), 4); - } - - // Select adapter based on model - let (_provider_id, adapter) = registry - .select(None, Some(model), InferenceDevice::default()) - .ok_or_else(|| { - let available = registry.available(); - if available.is_empty() { - "No AI providers available. Add API keys to ~/.continuum/config.env".to_string() - } else { - format!( - "Model {} not available. Available providers: {:?}", - model, available - ) - } - })?; - - // Use AI provider module - routes to DeepSeek, Anthropic, OpenAI, etc. - let request = TextGenerationRequest { - messages, - system_prompt: None, - model: Some(model.to_string()), - provider: None, // Auto-select based on model name - temperature: Some(0.7), - // Model owns its length (None → adapter forwards no ceiling). - max_tokens: None, - top_p: None, - top_k: None, - repeat_penalty: None, - frequency_penalty: None, - repeat_last_n: None, - stop_sequences: None, - tools: None, - tail_tools: None, - view_messages: None, - tool_choice: None, - request_id: None, - user_id: None, - room_id: None, - active_adapters: None, - response_format: None, - purpose: None, - // Agent-mode call from the IPC bridge — not a persona-owned conversation. - persona_id: None, - turn_bound: None, - }; - - let response = adapter.generate_text(request).await?; - - Ok(response.text) -} - -mod tools; - -use tools::{execute_tool, parse_tool_calls}; - -// ============================================================================ -// SERVICE MODULE IMPLEMENTATION -// ============================================================================ - -#[async_trait] -impl ServiceModule for AgentModule { - fn config(&self) -> ModuleConfig { - ModuleConfig { - name: "agent", - priority: ModulePriority::Normal, - command_prefixes: &["agent/"], - event_subscriptions: &[], - needs_dedicated_thread: false, - max_concurrency: 0, - tick_interval: None, - } - } - - async fn initialize(&self, ctx: &ModuleContext) -> Result<(), String> { - self.service.set_bus(ctx.bus.clone()); - log_info!("module", "agent", "AgentModule initialized with event bus"); - Ok(()) - } - - async fn handle_command(&self, command: &str, _params: Value) -> Result { - // MIGRATED: every `agent/*` verb is a typed command object (see - // `crate::commands::agent`), contributed via `commands()` below and winning - // at `route_object`. Nothing should reach here. Fail loud — this legacy - // `handle_command` retires entirely in Wave Z. - Err(format!( - "agent command surface is migrated to the typed registry; '{command}' has no legacy handler" - )) - } - - /// The migrated `agent/*` commands as typed self-routing objects on the ONE - /// registry, sharing the module's [`AgentService`]. The executor routes these - /// names directly here (winning over the dead legacy prefix arm), and their - /// descriptors flow into `command_registry()` → the persona tool surface + grid - /// ACL + codegen. - fn commands(&self) -> Vec> { - crate::commands::agent::command_objects(self.service.clone()) - } - - fn as_any(&self) -> &dyn Any { - self - } -} diff --git a/core/continuum-core/src/modules/agent/tools.rs b/core/continuum-core/src/modules/agent/tools.rs deleted file mode 100644 index 447e10af30..0000000000 --- a/core/continuum-core/src/modules/agent/tools.rs +++ /dev/null @@ -1,558 +0,0 @@ -//! Agent tool surface: tool-call parsing from LLM text and the file/search/command/git tool implementations. - -use super::*; - -/// Static regexes for tool call parsing (compiled once) -static TOOL_BLOCK_RE: std::sync::LazyLock = - std::sync::LazyLock::new(|| regex::Regex::new(r"```tool\s*\n?([\s\S]*?)```").unwrap()); // JUSTIFIED: constant literal pattern; invalid only by edit, caught by parse tests -static INLINE_TOOL_RE: std::sync::LazyLock = std::sync::LazyLock::new(|| { - regex::Regex::new(r#"\{"name":\s*"(\w+)",\s*"arguments":\s*(\{[^}]+\})\}"#).unwrap() // JUSTIFIED: constant literal pattern; invalid only by edit, caught by parse tests -}); - -/// Parse tool calls from LLM response -pub(super) fn parse_tool_calls(response: &str) -> Vec { - let mut calls = Vec::new(); - - for cap in TOOL_BLOCK_RE.captures_iter(response) { - if let Some(json_str) = cap.get(1) { - if let Ok(parsed) = serde_json::from_str::(json_str.as_str().trim()) { - calls.push(parsed); - } - } - } - - for cap in INLINE_TOOL_RE.captures_iter(response) { - if let (Some(name), Some(args)) = (cap.get(1), cap.get(2)) { - if let Ok(arguments) = serde_json::from_str::(args.as_str()) { - let call = ToolCall { - name: name.as_str().to_string(), - arguments, - }; - // Avoid duplicates - if !calls - .iter() - .any(|c| c.name == call.name && c.arguments == call.arguments) - { - calls.push(call); - } - } - } - } - - calls -} - -/// Execute a tool call (runs on Rayon thread pool) -pub(super) fn execute_tool(call: &ToolCall, working_dir: &Path) -> ToolResult { - match call.name.as_str() { - "read_file" => tool_read_file(call, working_dir), - "write_file" => tool_write_file(call, working_dir), - "edit_file" => tool_edit_file(call, working_dir), - "search_files" => tool_search_files(call, working_dir), - "list_files" => tool_list_files(call, working_dir), - "run_command" => tool_run_command(call, working_dir), - "git_status" => tool_git_status(working_dir), - "git_diff" => tool_git_diff(call, working_dir), - "complete" | "give_up" => ToolResult { - success: true, - output: "Acknowledged".to_string(), - error: None, - }, - _ => ToolResult { - success: false, - output: format!("Unknown tool: {}", call.name), - error: Some(format!("Unknown tool: {}", call.name)), - }, - } -} - -// ============================================================================ -// TOOL IMPLEMENTATIONS -// ============================================================================ - -fn tool_read_file(call: &ToolCall, working_dir: &Path) -> ToolResult { - let path = match call.arguments.get("path").and_then(|v| v.as_str()) { - Some(p) => p, - None => { - return ToolResult { - success: false, - output: "Missing path argument".to_string(), - error: Some("Missing path".to_string()), - }; - } - }; - - let full_path = working_dir.join(path); - if !full_path.exists() { - return ToolResult { - success: false, - output: format!("File not found: {}", path), - error: Some("File not found".to_string()), - }; - } - - match std::fs::read_to_string(&full_path) { - Ok(content) => { - let lines: Vec<&str> = content.lines().collect(); - let start = call - .arguments - .get("start_line") - .and_then(|v| v.as_u64()) - .map(|n| (n as usize).saturating_sub(1)) - .unwrap_or(0); - let end = call - .arguments - .get("end_line") - .and_then(|v| v.as_u64()) - .map(|n| n as usize) - .unwrap_or(lines.len()); - - let selected: String = lines[start..end.min(lines.len())] - .iter() - .enumerate() - .map(|(i, line)| format!("{:4}: {}", start + i + 1, line)) - .collect::>() - .join("\n"); - - ToolResult { - success: true, - output: format!( - "File: {} ({} lines, showing {}-{})\n\n{}", - path, - lines.len(), - start + 1, - end.min(lines.len()), - selected - ), - error: None, - } - } - Err(e) => ToolResult { - success: false, - output: format!("Error reading file: {}", e), - error: Some(e.to_string()), - }, - } -} - -fn tool_write_file(call: &ToolCall, working_dir: &Path) -> ToolResult { - let path = match call.arguments.get("path").and_then(|v| v.as_str()) { - Some(p) => p, - None => { - return ToolResult { - success: false, - output: "Missing path argument".to_string(), - error: Some("Missing path".to_string()), - }; - } - }; - - let content = match call.arguments.get("content").and_then(|v| v.as_str()) { - Some(c) => c, - None => { - return ToolResult { - success: false, - output: "Missing content argument".to_string(), - error: Some("Missing content".to_string()), - }; - } - }; - - let full_path = working_dir.join(path); - - // Create parent directories - if let Some(parent) = full_path.parent() { - if let Err(e) = std::fs::create_dir_all(parent) { - return ToolResult { - success: false, - output: format!("Failed to create directories: {}", e), - error: Some(e.to_string()), - }; - } - } - - let existed = full_path.exists(); - match std::fs::write(&full_path, content) { - Ok(_) => ToolResult { - success: true, - output: format!( - "{} {} ({} bytes, {} lines)", - if existed { "Updated" } else { "Created" }, - path, - content.len(), - content.lines().count() - ), - error: None, - }, - Err(e) => ToolResult { - success: false, - output: format!("Error writing file: {}", e), - error: Some(e.to_string()), - }, - } -} - -fn tool_edit_file(call: &ToolCall, working_dir: &Path) -> ToolResult { - let path = match call.arguments.get("path").and_then(|v| v.as_str()) { - Some(p) => p, - None => { - return ToolResult { - success: false, - output: "Missing path argument".to_string(), - error: Some("Missing path".to_string()), - }; - } - }; - - let search = match call.arguments.get("search").and_then(|v| v.as_str()) { - Some(s) => s, - None => { - return ToolResult { - success: false, - output: "Missing search argument".to_string(), - error: Some("Missing search".to_string()), - }; - } - }; - - let replace = match call.arguments.get("replace").and_then(|v| v.as_str()) { - Some(r) => r, - None => { - return ToolResult { - success: false, - output: "Missing replace argument".to_string(), - error: Some("Missing replace".to_string()), - }; - } - }; - - let full_path = working_dir.join(path); - if !full_path.exists() { - return ToolResult { - success: false, - output: format!("File not found: {}", path), - error: Some("File not found".to_string()), - }; - } - - match std::fs::read_to_string(&full_path) { - Ok(content) => { - let count = content.matches(search).count(); - if count == 0 { - return ToolResult { - success: false, - output: format!( - "Search string not found in {}. Make sure to use exact text including whitespace.", - path - ), - error: Some("Search string not found".to_string()), - }; - } - if count > 1 { - return ToolResult { - success: false, - output: format!( - "Search string found {} times in {}. Use a more specific search to match exactly one location.", - count, path - ), - error: Some("Multiple matches".to_string()), - }; - } - - let new_content = content.replace(search, replace); - match std::fs::write(&full_path, &new_content) { - Ok(_) => ToolResult { - success: true, - output: format!( - "Edited {}: replaced {} chars with {} chars", - path, - search.len(), - replace.len() - ), - error: None, - }, - Err(e) => ToolResult { - success: false, - output: format!("Error writing file: {}", e), - error: Some(e.to_string()), - }, - } - } - Err(e) => ToolResult { - success: false, - output: format!("Error reading file: {}", e), - error: Some(e.to_string()), - }, - } -} - -fn tool_search_files(call: &ToolCall, working_dir: &Path) -> ToolResult { - let pattern = match call.arguments.get("pattern").and_then(|v| v.as_str()) { - Some(p) => p, - None => { - return ToolResult { - success: false, - output: "Missing pattern argument".to_string(), - error: Some("Missing pattern".to_string()), - }; - } - }; - - let max_results = call - .arguments - .get("max_results") - .and_then(|v| v.as_u64()) - .unwrap_or(50); - - let file_glob = call - .arguments - .get("file_glob") - .and_then(|v| v.as_str()) - .map(|g| format!("--include=\"{}\"", g)) - .unwrap_or_default(); - - let cmd = format!( - "grep -rn {} -E \"{}\" . 2>/dev/null | head -{}", - file_glob, - pattern.replace('"', "\\\""), - max_results - ); - - match Command::new("sh") - .arg("-c") - .arg(&cmd) - .current_dir(working_dir) - .output() - { - Ok(output) => { - let stdout = String::from_utf8_lossy(&output.stdout); - let lines: Vec<&str> = stdout.lines().collect(); - - ToolResult { - success: true, - output: format!( - "Found {} matches:\n{}", - lines.len(), - if stdout.is_empty() { - "No matches found".to_string() - } else { - stdout.to_string() - } - ), - error: None, - } - } - Err(e) => ToolResult { - success: false, - output: format!("Search error: {}", e), - error: Some(e.to_string()), - }, - } -} - -fn tool_list_files(call: &ToolCall, working_dir: &Path) -> ToolResult { - let dir_path = call - .arguments - .get("path") - .and_then(|v| v.as_str()) - .map(|p| working_dir.join(p)) - .unwrap_or_else(|| working_dir.to_path_buf()); - - let depth = call - .arguments - .get("depth") - .and_then(|v| v.as_u64()) - .unwrap_or(3); - - let pattern = call - .arguments - .get("pattern") - .and_then(|v| v.as_str()) - .map(|p| format!("-name \"{}\"", p)) - .unwrap_or_default(); - - let cmd = format!( - "find \"{}\" -maxdepth {} -type f {} 2>/dev/null | head -100", - dir_path.display(), - depth, - pattern - ); - - match Command::new("sh") - .arg("-c") - .arg(&cmd) - .current_dir(working_dir) - .output() - { - Ok(output) => { - let stdout = String::from_utf8_lossy(&output.stdout); - let mut paths: Vec = stdout - .lines() - .filter(|l| !l.is_empty()) - .filter_map(|l| { - // Make paths relative to working_dir - let p = Path::new(l); - p.strip_prefix(working_dir) - .map(|r| r.to_string_lossy().to_string()) - .ok() - .or_else(|| Some(l.to_string())) - }) - .collect(); - paths.sort(); - - ToolResult { - success: true, - output: format!( - "Files in {}:\n{}", - call.arguments - .get("path") - .and_then(|v| v.as_str()) - .unwrap_or("."), - if paths.is_empty() { - "No files found".to_string() - } else { - paths.join("\n") - } - ), - error: None, - } - } - Err(e) => ToolResult { - success: false, - output: format!("List error: {}", e), - error: Some(e.to_string()), - }, - } -} - -fn tool_run_command(call: &ToolCall, working_dir: &Path) -> ToolResult { - let command = match call.arguments.get("command").and_then(|v| v.as_str()) { - Some(c) => c, - None => { - return ToolResult { - success: false, - output: "Missing command argument".to_string(), - error: Some("Missing command".to_string()), - }; - } - }; - - let _timeout_ms = call - .arguments - .get("timeout_ms") - .and_then(|v| v.as_u64()) - .unwrap_or(60000); - - // Execute with timeout using std::process for Rayon compatibility - match Command::new("sh") - .arg("-c") - .arg(command) - .current_dir(working_dir) - .output() - { - Ok(output) => { - let stdout = String::from_utf8_lossy(&output.stdout); - let stderr = String::from_utf8_lossy(&output.stderr); - let success = output.status.success(); - - if success { - ToolResult { - success: true, - output: if stdout.is_empty() { - "Command completed (no output)".to_string() - } else { - stdout.chars().take(5000).collect() - }, - error: None, - } - } else { - ToolResult { - success: false, - output: format!( - "Exit code: {:?}\n\nSTDOUT:\n{}\n\nSTDERR:\n{}", - output.status.code(), - stdout.chars().take(2500).collect::(), - stderr.chars().take(2500).collect::() - ), - error: Some(format!( - "Command failed with exit code {:?}", - output.status.code() - )), - } - } - } - Err(e) => ToolResult { - success: false, - output: format!("Execution error: {}", e), - error: Some(e.to_string()), - }, - } -} - -fn tool_git_status(working_dir: &Path) -> ToolResult { - match Command::new("git") - .args(["status", "--short"]) - .current_dir(working_dir) - .output() - { - Ok(output) => { - let stdout = String::from_utf8_lossy(&output.stdout); - ToolResult { - success: true, - output: if stdout.is_empty() { - "Working tree clean".to_string() - } else { - stdout.to_string() - }, - error: None, - } - } - Err(e) => ToolResult { - success: false, - output: format!("Git error: {}", e), - error: Some(e.to_string()), - }, - } -} - -fn tool_git_diff(call: &ToolCall, working_dir: &Path) -> ToolResult { - let mut args = vec!["diff"]; - - if call - .arguments - .get("staged") - .and_then(|v| v.as_bool()) - .unwrap_or(false) - { - args.push("--staged"); - } - - let path = call.arguments.get("path").and_then(|v| v.as_str()); - - let mut cmd = Command::new("git"); - cmd.args(&args).current_dir(working_dir); - - if let Some(p) = path { - cmd.arg("--").arg(p); - } - - match cmd.output() { - Ok(output) => { - let stdout = String::from_utf8_lossy(&output.stdout); - ToolResult { - success: true, - output: if stdout.is_empty() { - "No changes".to_string() - } else { - stdout.chars().take(5000).collect() - }, - error: None, - } - } - Err(e) => ToolResult { - success: false, - output: format!("Git error: {}", e), - error: Some(e.to_string()), - }, - } -} diff --git a/core/continuum-core/src/modules/mod.rs b/core/continuum-core/src/modules/mod.rs index 59b3f806d5..789bb288cd 100644 --- a/core/continuum-core/src/modules/mod.rs +++ b/core/continuum-core/src/modules/mod.rs @@ -9,7 +9,6 @@ //! Phase 4: data, embedding, inference, search, training, logger (absorb external workers) pub mod acting_provider; -pub mod agent; pub mod ai_provider; pub mod airc; pub mod airc_bridge_directive; diff --git a/core/continuum-engine/src/ai/adapter/global_registry.rs b/core/continuum-engine/src/ai/adapter/global_registry.rs index b17335f616..d907776ba4 100644 --- a/core/continuum-engine/src/ai/adapter/global_registry.rs +++ b/core/continuum-engine/src/ai/adapter/global_registry.rs @@ -93,7 +93,7 @@ pub fn select_failure_message( } /// Generate text using the best available provider -/// This is a convenience function for internal use (e.g., AgentModule) +/// This is a convenience function for internal use (e.g., the recipe generator) pub async fn generate_text( registry: &AdapterRegistry, request: TextGenerationRequest, diff --git a/core/continuum-kernel/src/runtime/command_envelope.rs b/core/continuum-kernel/src/runtime/command_envelope.rs index 01173ab7d2..a1e8c03a6b 100644 --- a/core/continuum-kernel/src/runtime/command_envelope.rs +++ b/core/continuum-kernel/src/runtime/command_envelope.rs @@ -336,7 +336,7 @@ pub fn is_envelope_field(key: &str) -> bool { /// — silently `None` for an option, "invalid type … expected struct HandleRef" for a /// string. Five collisions before the guard (card ea28d2f6): actorKind (#3781), /// requestId (#4178), `handle` on the staging path (#3924 — why `dbPath` exists), and -/// `jobHandle` (#4326); `agent/status`, `agent/stop` and `agent/wait` could not be +/// `jobHandle` (#4326), where a command whose input was named `handle` could not be /// called through the envelope at all. pub const ENVELOPE_FIELDS: &[&str] = &["handle", "sessionId", "userId", "actorKind", "contextId", "requestId"]; diff --git a/protocol/typescript/agent/AgentAction.ts b/protocol/typescript/agent/AgentAction.ts deleted file mode 100644 index 58a83c1571..0000000000 --- a/protocol/typescript/agent/AgentAction.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { ToolResult } from "./AgentToolResult"; - -/** - * A single action taken by the agent - */ -export type AgentAction = { timestamp: string, action_type: string, tool_name?: string, tool_args?: Record, result?: ToolResult, thought?: string, }; diff --git a/protocol/typescript/agent/AgentListParams.ts b/protocol/typescript/agent/AgentListParams.ts deleted file mode 100644 index 0bb231d8ba..0000000000 --- a/protocol/typescript/agent/AgentListParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * `agent/list` takes no input. - */ -export type AgentListParams = Record; diff --git a/protocol/typescript/agent/AgentStartParams.ts b/protocol/typescript/agent/AgentStartParams.ts deleted file mode 100644 index 28c516a821..0000000000 --- a/protocol/typescript/agent/AgentStartParams.ts +++ /dev/null @@ -1,23 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * Inputs to `agent/start`. - */ -export type AgentStartParams = { -/** - * The task for the agent to accomplish (free-form natural language). - */ -task: string, -/** - * Absolute path to the workspace the agent operates in. - */ -working_dir: string, -/** - * Model name to drive the agent loop, e.g. `deepseek-chat`, - * `claude-sonnet-4-5-20250929`, `gpt-4`. Must match an available provider. - */ -model: string, -/** - * Maximum build/test/fix iterations before the agent gives up (default 50). - */ -max_iterations: number, }; diff --git a/protocol/typescript/agent/AgentStartResult.ts b/protocol/typescript/agent/AgentStartResult.ts deleted file mode 100644 index edf9742c25..0000000000 --- a/protocol/typescript/agent/AgentStartResult.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * Result of `agent/start`: the handle to poll. - */ -export type AgentStartResult = { -/** - * The handle identifying the spawned agent — pass it back as `agentHandle` to - * `status`/`stop`/`wait`. - */ -agentHandle: string, }; diff --git a/protocol/typescript/agent/AgentStatus.ts b/protocol/typescript/agent/AgentStatus.ts deleted file mode 100644 index 06ca3a034a..0000000000 --- a/protocol/typescript/agent/AgentStatus.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * Agent execution status - */ -export type AgentStatus = "running" | "completed" | "failed" | "stopped"; diff --git a/protocol/typescript/agent/AgentStatusInfo.ts b/protocol/typescript/agent/AgentStatusInfo.ts deleted file mode 100644 index 29af74130a..0000000000 --- a/protocol/typescript/agent/AgentStatusInfo.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { AgentStatus } from "./AgentStatus"; - -/** - * A typed snapshot of an agent's progress — the wire output of `agent/status`, - * `agent/list`, and `agent/wait`. Replaces the old ad-hoc `to_status_json` Value - * so every reader gets a contracted shape + a ts-rs binding. - */ -export type AgentStatusInfo = { handle: string, task: string, working_dir: string, status: AgentStatus, iteration: number, max_iterations: number, elapsed_ms: number, actions_count: number, files_created: Array, files_modified: Array, summary?: string, error?: string, }; diff --git a/protocol/typescript/agent/AgentStatusList.ts b/protocol/typescript/agent/AgentStatusList.ts deleted file mode 100644 index e50b4d9c52..0000000000 --- a/protocol/typescript/agent/AgentStatusList.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { AgentStatusInfo } from "./AgentStatusInfo"; - -/** - * Result of `agent/list` — the live set of tracked agents. A named wrapper so the - * wire type is a struct, not a bare `Array`. - */ -export type AgentStatusList = { -/** - * Every agent the runtime is currently tracking (running + not-yet-evicted). - */ -agents: Array, }; diff --git a/protocol/typescript/agent/AgentStatusLookup.ts b/protocol/typescript/agent/AgentStatusLookup.ts deleted file mode 100644 index b2c6b1c237..0000000000 --- a/protocol/typescript/agent/AgentStatusLookup.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { AgentStatusInfo } from "./AgentStatusInfo"; - -/** - * Result of `agent/status` — the agent's progress snapshot, or absent when no - * agent has that handle (unknown, or already finished and evicted). A named - * wrapper so the wire type is a struct, not a bare `T | null`. - */ -export type AgentStatusLookup = { -/** - * The progress snapshot, or absent when the handle is unknown/evicted. - */ -status?: AgentStatusInfo, }; diff --git a/protocol/typescript/agent/AgentStatusParams.ts b/protocol/typescript/agent/AgentStatusParams.ts deleted file mode 100644 index b19476fbdf..0000000000 --- a/protocol/typescript/agent/AgentStatusParams.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * Inputs to `agent/status`. - */ -export type AgentStatusParams = { -/** - * The agent handle returned by `agent/start`. - */ -agentHandle: string, }; diff --git a/protocol/typescript/agent/AgentStopParams.ts b/protocol/typescript/agent/AgentStopParams.ts deleted file mode 100644 index 3114cf6dd1..0000000000 --- a/protocol/typescript/agent/AgentStopParams.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * Inputs to `agent/stop`. - */ -export type AgentStopParams = { -/** - * The agent handle returned by `agent/start`. - */ -agentHandle: string, }; diff --git a/protocol/typescript/agent/AgentStopResult.ts b/protocol/typescript/agent/AgentStopResult.ts deleted file mode 100644 index 82d7747b43..0000000000 --- a/protocol/typescript/agent/AgentStopResult.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * Result of `agent/stop`. - */ -export type AgentStopResult = { -/** - * `true` if the handle was found and flagged to stop; `false` if no such agent. - */ -stop_requested: boolean, }; diff --git a/protocol/typescript/agent/AgentToolCall.ts b/protocol/typescript/agent/AgentToolCall.ts deleted file mode 100644 index 5dc1256d09..0000000000 --- a/protocol/typescript/agent/AgentToolCall.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * A single tool call made by the agent - */ -export type ToolCall = { name: string, arguments: Record, }; diff --git a/protocol/typescript/agent/AgentToolResult.ts b/protocol/typescript/agent/AgentToolResult.ts deleted file mode 100644 index cd82df97ae..0000000000 --- a/protocol/typescript/agent/AgentToolResult.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * Result of executing a tool - */ -export type ToolResult = { success: boolean, output: string, error?: string, }; diff --git a/protocol/typescript/agent/AgentWaitParams.ts b/protocol/typescript/agent/AgentWaitParams.ts deleted file mode 100644 index 708d0b9a1b..0000000000 --- a/protocol/typescript/agent/AgentWaitParams.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * Inputs to `agent/wait`. - */ -export type AgentWaitParams = { -/** - * The agent handle returned by `agent/start`. - */ -agentHandle: string, -/** - * Max milliseconds to wait before returning a timeout error (default 300000). - */ -timeout_ms: number, }; diff --git a/protocol/typescript/agent/index.ts b/protocol/typescript/agent/index.ts deleted file mode 100644 index 220d54a20c..0000000000 --- a/protocol/typescript/agent/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Auto-generated barrel export — do not edit manually -// Source: generator/generate-rust-bindings.ts -// Re-generate: npx tsx generator/generate-rust-bindings.ts - -export type { AgentAction } from './AgentAction'; -export type { AgentStatus } from './AgentStatus'; -export type { ToolCall } from './AgentToolCall'; -export type { ToolResult } from './AgentToolResult'; diff --git a/protocol/typescript/index.ts b/protocol/typescript/index.ts index dc69fc7663..70f6c1c923 100644 --- a/protocol/typescript/index.ts +++ b/protocol/typescript/index.ts @@ -2,11 +2,6 @@ // Source: generator/generate-rust-bindings.ts // Re-generate: npx tsx generator/generate-rust-bindings.ts -// agent: explicit exports (has duplicate types) -export type { AgentAction } from './agent'; -export type { AgentStatus } from './agent'; -export type { ToolCall } from './agent'; -export type { ToolResult } from './agent'; // ai: explicit exports (has duplicate types) export type { ActiveAdapterRequest } from './ai'; export type { AudioInput } from './ai';