diff --git a/rust/crates/agent-runtime/src/events.rs b/rust/crates/agent-runtime/src/events.rs index 8a0bdcc1..3413c294 100644 --- a/rust/crates/agent-runtime/src/events.rs +++ b/rust/crates/agent-runtime/src/events.rs @@ -177,6 +177,11 @@ pub(crate) struct ToolCallEvent { pub tool_kind: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub title: Option, + /// The command line an `execute` call runs, as its shell sees it; `title` + /// then says what it is for. Sent only to a backend whose `didStart` + /// carried `toolCommands`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub command: Option, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub locations: Vec, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -636,6 +641,10 @@ fn check_bounds(event: &SessionEvent) -> Result<(), String> { SessionEvent::ToolCall(call) => { label(&call.tool_call_id, "toolCallID")?; optional_label(&call.title, "title")?; + if call.command.as_deref().is_some_and(str::is_empty) { + return Err("has an empty command".to_string()); + } + text(call.command.as_deref().unwrap_or_default(), "command")?; if call.locations.len() > MAX_LOCATIONS { return Err("has too many locations".to_string()); } diff --git a/rust/crates/agent-runtime/src/live.rs b/rust/crates/agent-runtime/src/live.rs index cd759535..3bd19211 100644 --- a/rust/crates/agent-runtime/src/live.rs +++ b/rust/crates/agent-runtime/src/live.rs @@ -655,6 +655,9 @@ fn start_checked(runtime: &Arc, request: StartRequest) -> Result, #[serde(default, skip_serializing_if = "Option::is_none")] title: Option, + /// The command line of an `execute` call, as in the live `toolCall` event. + #[serde(default, skip_serializing_if = "Option::is_none")] + command: Option, #[serde(default, skip_serializing_if = "Option::is_none")] locations: Option>, } @@ -1655,6 +1660,7 @@ fn valid_tool_details(message: &ReadMessage) -> bool { || message.status.is_some() || message.tool_kind.is_some() || message.title.is_some() + || message.command.is_some() || message.locations.is_some(); if !details { return true; @@ -1679,6 +1685,10 @@ fn valid_tool_details(message: &ReadMessage) -> bool { ) }) && message.title.as_deref().is_none_or(label) + && message + .command + .as_deref() + .is_none_or(|command| !command.is_empty() && command.len() <= MAX_MESSAGE_TEXT_BYTES) && message.locations.as_ref().is_none_or(|locations| { locations.len() <= MAX_TOOL_LOCATIONS && locations.iter().all(|location| label(&location.path)) @@ -1692,8 +1702,16 @@ struct ReadItem { messages: Vec, } -/// The fields a reader may return only when the request asked for `toolCalls`. -const TOOL_DETAIL_FIELDS: [&str; 5] = ["toolCallID", "status", "toolKind", "title", "locations"]; +/// The fields a reader may return only when the request asked for `toolCalls` +/// (and, for `command`, `toolCommands`, which Core always asks for with it). +const TOOL_DETAIL_FIELDS: [&str; 6] = [ + "toolCallID", + "status", + "toolKind", + "title", + "command", + "locations", +]; /// Decodes one answer item. Without `tool_details` the original strict shape applies: /// a detail field, even an explicit null, makes the reading invalid. diff --git a/rust/crates/agent-runtime/src/tests.rs b/rust/crates/agent-runtime/src/tests.rs index 27f2eb79..d75e1558 100644 --- a/rust/crates/agent-runtime/src/tests.rs +++ b/rust/crates/agent-runtime/src/tests.rs @@ -813,7 +813,12 @@ fn native_session_relays_the_cli_and_checks_reports_against_turns() { ); assert_eq!( harness.link.await_notice(AGENTS_DID_START, |_| true), - json!({ "agentID": AGENT, "cwd": path_text(&harness.work), "session": session }) + json!({ + "agentID": AGENT, + "cwd": path_text(&harness.work), + "session": session, + "toolCommands": true + }) ); let started = harness.next_event(&session, "started"); assert_eq!(started["pluginID"], PLUGIN); @@ -905,6 +910,30 @@ fn native_session_relays_the_cli_and_checks_reports_against_turns() { harness.next_event(&session, "permissionRequested")["permission"], "p1" ); + + // An `execute` call carries its command line apart from its title. + harness + .report( + &session, + json!([{ + "kind": "toolCall", "turn": 1, "toolCallID": "c1", "status": "completed", + "toolKind": "execute", "title": "List the files", "command": "ls -la" + }]), + ) + .expect("a tool call with a command"); + let call = harness.next_event(&session, "toolCall"); + assert_eq!(call["title"], "List the files"); + assert_eq!(call["command"], "ls -la"); + let refusal = harness + .report( + &session, + json!([{ + "kind": "toolCall", "turn": 1, "toolCallID": "c2", "status": "completed", + "toolKind": "execute", "command": "" + }]), + ) + .expect_err("an empty command is refused"); + assert_eq!(refusal.code, codes::HOST_INVALID_PARAMS); let sessions = harness.sessions(); assert_eq!(sessions.len(), 1); assert_eq!(sessions[0]["pendingPermissions"], json!(["p1"])); @@ -2731,6 +2760,7 @@ fn records_page_message_ids_are_opt_in_and_validated() { if function == "sessions.read" && params["mode"] == "messages" { assert_eq!(params["messageIDs"], true); assert_eq!(params["toolCalls"], true); + assert_eq!(params["toolCommands"], true); let mut answer = read(params); for message in answer["items"][0]["messages"].as_array_mut().unwrap() { message["id"] = "source-message-1".into(); @@ -2769,11 +2799,15 @@ fn records_page_tool_call_details_follow_the_live_bounds() { "status": "inProgress", "toolKind": "read", "title": "Read main.go", "locations": [{ "path": "/work/main.go", "line": 3 }] }); let result = json!({ "role": "tool", "text": "package main", "toolCallID": "call-1", "status": "completed" }); - let answer = json!({ "items": [{ "messages": [call, result] }] }); + let command = json!({ "role": "tool", "text": "", "toolCallID": "call-2", "status": "completed", + "toolKind": "execute", "title": "List the files", "command": "ls -la" }); + let answer = json!({ "items": [{ "messages": [call, result, command] }] }); harness.link.set_answer(move |_, _| Ok(answer.clone())); let page = harness.run("agentSessions.page", request.clone()); assert_eq!(page["messages"][0]["locations"][0]["line"], 3); assert_eq!(page["messages"][1]["status"], "completed"); + assert_eq!(page["messages"][2]["title"], "List the files"); + assert_eq!(page["messages"][2]["command"], "ls -la"); let refused = [ json!({ "role": "assistant", "text": "x", "toolCallID": "call-1" }), json!({ "role": "tool", "text": "x", "status": "completed" }), @@ -2781,6 +2815,8 @@ fn records_page_tool_call_details_follow_the_live_bounds() { json!({ "role": "tool", "text": "x", "toolCallID": "call-1", "toolKind": "shell" }), json!({ "role": "tool", "text": "x", "toolCallID": "", "title": "t" }), json!({ "role": "tool", "text": "x", "toolCallID": "c", "locations": [{ "path": "" }] }), + json!({ "role": "tool", "text": "x", "toolCallID": "c", "command": "" }), + json!({ "role": "assistant", "text": "x", "command": "ls" }), ]; for message in refused { harness @@ -2823,6 +2859,13 @@ fn legacy_reads_refuse_tool_details_they_did_not_ask_for() { harness.refused("agentSessions.read", legacy.clone()), "agentSessions.invalidRead" ); + let command = + json!({ "items": [{ "messages": [{ "role": "tool", "text": "x", "command": "ls" }] }] }); + harness.link.set_answer(move |_, _| Ok(command.clone())); + assert_eq!( + harness.refused("agentSessions.read", legacy.clone()), + "agentSessions.invalidRead" + ); // An explicit null is still a field the legacy shape does not have. let null = json!({ "items": [{ "messages": [{ "role": "tool", "text": "x", "status": null }] }] }); diff --git a/shared/plugins/contract/v1/README.md b/shared/plugins/contract/v1/README.md index 2497edd4..00cbbf90 100644 --- a/shared/plugins/contract/v1/README.md +++ b/shared/plugins/contract/v1/README.md @@ -3970,7 +3970,7 @@ Notifications Core sends (the host may not send them): | Notification | Params | | --- | --- | -| `lithe/host/agents/didStart` | `{session, agentID, cwd, resume?}` | +| `lithe/host/agents/didStart` | `{session, agentID, cwd, resume?, toolCommands?}` | | `lithe/host/agents/didOutput` | `{session, lines}` | | `lithe/host/agents/didPrompt` | `{session, turn, text, attachments?, mode?: "steer", input?}`; `mode` and `input` occur together only for running-turn input | | `lithe/host/agents/didCancel` | `{session, turn}` | @@ -3979,6 +3979,10 @@ Notifications Core sends (the host may not send them): | `lithe/host/agents/didSetConfigOption` | `{session, option, value}` | | `lithe/host/agents/didExit` | `{session, exitCode?}` | +- `didStart` carries `toolCommands: true` when Core takes a `command` on + `toolCall` events (see below). A backend sends `command` only to a session + whose `didStart` said so; Core revisions without it reject the field and + refuse the whole report. - `didOutput` carries at most 64 lines or 4 MiB per notification, in order. A line longer than 16 MiB is dropped and the host receives the event `outputLineDropped`; a notification the backend does not take ends the @@ -4059,7 +4063,7 @@ Session events (`report`'s `events[]`, each tagged by `kind`): | --- | --- | | `session` | `agentSessionID, model?, effort?, agentVersion?`: the CLI's own session, for resume and the records | | `message` | `turn, role` (`assistant` or `thought`), `messageID, text, delta`: `delta: true` appends `text` to the message | -| `toolCall` | `turn, toolCallID, status` (`pending`, `inProgress`, `completed`, `failed`), `toolKind?` (`read`, `edit`, `delete`, `move`, `search`, `execute`, `think`, `fetch`, `other`), `title?, locations?` (at most 64 `{path, line?}`), `diff?` (`{path, oldText?, newText}`), `output?` | +| `toolCall` | `turn, toolCallID, status` (`pending`, `inProgress`, `completed`, `failed`), `toolKind?` (`read`, `edit`, `delete`, `move`, `search`, `execute`, `think`, `fetch`, `other`), `title?, command?, locations?` (at most 64 `{path, line?}`), `diff?` (`{path, oldText?, newText}`), `output?` | | `plan` | `turn, entries`: at most 256 `{content, status}` | | `permissionRequested` | `turn, permission, title, toolCallID?, options`: 1–8 `{id, label, optionKind}` with unique IDs, `optionKind` one of `allowOnce`, `allowAlways`, `rejectOnce`, `rejectAlways` | | `usage` | `turn?, model?, tokens, contextUsed?, contextWindow?, costUsd?` (finite, not negative) | @@ -4115,6 +4119,14 @@ original interactions and handle rejection before advertising the extension. replaces the last; an empty list withdraws them. The event names no turn and may come at any time. The host shows `model` and `thoughtLevel` settings by the model picker and the others as menus. +- `command` is the command line an `execute` call runs, as its shell sees + it, 1 byte to 1 MiB; `title` then says in plain words what the command is + for, such as the description the CLI gave it. A CLI that has no such + description leaves `title` out or sets it to the command. Send `command` + only when `didStart` carried `toolCommands: true`. The host shows the title + as the step's heading and the command in its command card, and falls back + to the title alone without `command`. This is an addition within API-45 + and `agents` 0. - `message`, `toolCall`, `plan`, `permissionRequested` and `turnEnded` name the active turn; a `usage` turn is at most the latest one. `turnEnded` ends the turn and drops its pending permission requests. @@ -4296,7 +4308,7 @@ state?}` and has 30 seconds. It answers: conversation text; - `rateLimits`: `{atMs, windows, plan?}`, the latest quota the file shows. -`read` receives `{agentID, sourceID, mode, messageIDs?, items: [{path, lines}]}` and has +`read` receives `{agentID, sourceID, mode, messageIDs?, toolCalls?, toolCommands?, items: [{path, lines}]}` and has 15 seconds. It answers exactly `{items}`, one per request item: in `titles` mode `{title}` (cut to 512 bytes), in `messages` mode `{messages}`, at most 2048 `{role, text, id?, atMs?, toolName?}` with `role` one of `user`, @@ -4315,7 +4327,10 @@ message carry the live [`toolCall`](#native-sessions) details: `toolCallID` (required with any other detail), `status` (`pending`, `inProgress`, `completed`, `failed`), `toolKind` (`read`, `edit`, `delete`, `move`, `search`, `execute`, `think`, `fetch`, `other`), `title` and `locations` -(at most 64 `{path, line?}`), labels and paths 1 byte to 1 KiB. A call and +(at most 64 `{path, line?}`), labels and paths 1 byte to 1 KiB. With +`toolCommands: true`, which `agentSessions.page` sends with `toolCalls`, a +call may also carry the live `command` (1 byte to 1 MiB); without it a +`command` is `agentSessions.invalidRead`. A call and its result are separate messages with the same `toolCallID`, in file order; `text` holds the result's output. A host folds them into one tool call the way it folds live `toolCall` updates, and starts a turn at each `user` diff --git a/shared/plugins/contract/v1/fixtures/agents/native-session.json b/shared/plugins/contract/v1/fixtures/agents/native-session.json index 295287bf..f89c4291 100644 --- a/shared/plugins/contract/v1/fixtures/agents/native-session.json +++ b/shared/plugins/contract/v1/fixtures/agents/native-session.json @@ -1,5 +1,5 @@ { - "description": "How an official SDK delivers the native-session notifications Core sends (contract README: Native sessions) and the agents host methods it sends. The notifications of one session reach the plugin's handler one at a time, in the order Core sent them, whatever other sessions do; a session's handler starts with didStart and ends with didExit. A prompt with attachments reaches the handler's attachment method with each attachment as Core described it (type, path, name, uri, and mimeType for an image), recorded as a fourth element; a prompt without attachments reaches the plain prompt method. A test backend gives every session of agent plain a handler with only the plain prompt method; for it the SDK's default passes a prompt whose attachments are all file links to that method as the text, then a blank line unless the text is blank, then each attachment's link [@name](uri) on its own line, and ends a turn whose prompt has an image as failed. A test backend fails to start every session whose cwd is /work/broken and fails every prompt whose text is fail; for both the SDK reports turnEnded with reason failed for the turn, so the host does not wait for a turn no handler runs. Notifications of a session the SDK never started are ignored.", + "description": "How an official SDK delivers the native-session notifications Core sends (contract README: Native sessions) and the agents host methods it sends. The notifications of one session reach the plugin's handler one at a time, in the order Core sent them, whatever other sessions do; a session's handler starts with didStart and ends with didExit. A didStart's toolCommands reaches the handler as true only when Core sent it as true. A prompt with attachments reaches the handler's attachment method with each attachment as Core described it (type, path, name, uri, and mimeType for an image), recorded as a fourth element; a prompt without attachments reaches the plain prompt method. A test backend gives every session of agent plain a handler with only the plain prompt method; for it the SDK's default passes a prompt whose attachments are all file links to that method as the text, then a blank line unless the text is blank, then each attachment's link [@name](uri) on its own line, and ends a turn whose prompt has an image as failed. A test backend fails to start every session whose cwd is /work/broken and fails every prompt whose text is fail; for both the SDK reports turnEnded with reason failed for the turn, so the host does not wait for a turn no handler runs. Notifications of a session the SDK never started are ignored.", "sessions": { "notifications": [ { @@ -16,7 +16,8 @@ "session": "agent-2", "agentID": "example", "cwd": "/work/orders", - "resume": "previous-session" + "resume": "previous-session", + "toolCommands": true } }, { @@ -133,7 +134,8 @@ "session": "agent-1", "agentID": "example", "cwd": "/work/orders", - "resume": null + "resume": null, + "toolCommands": false } ], [ @@ -201,7 +203,8 @@ "session": "agent-2", "agentID": "example", "cwd": "/work/orders", - "resume": "previous-session" + "resume": "previous-session", + "toolCommands": true } ], [ @@ -384,7 +387,8 @@ "session": "agent-4", "agentID": "example", "cwd": "/work/orders", - "resume": null + "resume": null, + "toolCommands": false } ], [ @@ -409,7 +413,8 @@ "session": "agent-5", "agentID": "plain", "cwd": "/work/orders", - "resume": null + "resume": null, + "toolCommands": false } ], [ @@ -660,7 +665,8 @@ "session": "agent-6", "agentID": "example", "cwd": "/work/orders", - "resume": null + "resume": null, + "toolCommands": false } ], [ diff --git a/shared/plugins/contract/v1/fixtures/agents/record-read.json b/shared/plugins/contract/v1/fixtures/agents/record-read.json index 1bd13969..89f47c49 100644 --- a/shared/plugins/contract/v1/fixtures/agents/record-read.json +++ b/shared/plugins/contract/v1/fixtures/agents/record-read.json @@ -1,11 +1,11 @@ { - "description": "Record-read IDs and tool-call details are opt-in; ordinary function handlers in every SDK pass the JSON request and result unchanged.", + "description": "Record-read IDs, tool-call details and execute commands are opt-in; ordinary function handlers in every SDK pass the JSON request and result unchanged.", "legacy": { "request": {"agentID": "sample", "sourceID": "sessions", "mode": "messages", "items": [{"path": "/work/session.jsonl", "lines": ["question"]}]}, "result": {"items": [{"messages": [{"role": "user", "text": "question"}]}]} }, "withIDs": { - "request": {"agentID": "sample", "sourceID": "sessions", "mode": "messages", "messageIDs": true, "toolCalls": true, "items": [{"path": "/work/session.jsonl", "lines": ["question"]}]}, - "result": {"items": [{"messages": [{"role": "user", "text": "question", "id": "source-1"}, {"role": "tool", "text": "", "id": "source-2", "toolName": "Read", "toolCallID": "call-1", "status": "inProgress", "toolKind": "read", "title": "Read main.go", "locations": [{"path": "/work/main.go", "line": 3}]}, {"role": "tool", "text": "package main", "id": "source-3", "toolCallID": "call-1", "status": "completed"}]}]} + "request": {"agentID": "sample", "sourceID": "sessions", "mode": "messages", "messageIDs": true, "toolCalls": true, "toolCommands": true, "items": [{"path": "/work/session.jsonl", "lines": ["question"]}]}, + "result": {"items": [{"messages": [{"role": "user", "text": "question", "id": "source-1"}, {"role": "tool", "text": "", "id": "source-2", "toolName": "Read", "toolCallID": "call-1", "status": "inProgress", "toolKind": "read", "title": "Read main.go", "locations": [{"path": "/work/main.go", "line": 3}]}, {"role": "tool", "text": "package main", "id": "source-3", "toolCallID": "call-1", "status": "completed"}, {"role": "tool", "text": "", "id": "source-4", "toolName": "Bash", "toolCallID": "call-2", "status": "completed", "toolKind": "execute", "title": "List the files", "command": "ls -la"}]}]} } } diff --git a/shared/plugins/reference/protocol-changelog.md b/shared/plugins/reference/protocol-changelog.md index 8a04e8b7..8291820a 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -18,6 +18,7 @@ | PR | 修改人 | API 编号 | 协议 / 能力 | 改动 | | --- | --- | --- | --- | --- | +| [#246](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/246)(待合入) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-45 | `agents` 0 内的补充 | `toolCall` 事件新增可选 `command`:`execute` 调用实际运行的命令行(1 字节到 1 MiB),此时 `title` 写这条命令要做什么(例如 CLI 给的描述),宿主把标题作为步骤标题、命令放进命令卡片,没有 `command` 时只用标题。`didStart` 新增 `toolCommands: true`,后端只在看到它时才发送 `command`;旧 Core 的 `toolCall` 严格解码,收到 `command` 会拒绝整批报告。会话来源 `read` 函数新增可选请求参数 `toolCommands`,`agentSessions.page` 随 `toolCalls` 一起发送,只有这时 `tool` 消息才可带 `command`,否则以 `agentSessions.invalidRead` 拒绝。四语 SDK 的 `AgentSessionStart` 新增 `toolCommands`(Rust `tool_commands`、Go `ToolCommands`、Java `toolCommands()`、Node `toolCommands`);记录读取仍是普通 JSON 函数,无类型变化。没有新增宿主方法、错误码或能力版本。样例见 `fixtures/agents/native-session.json` 与 `fixtures/agents/record-read.json`。 | | [#245](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/245)(待合入) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-45 | `agents` 0 内的补充 | 宿主命令 `agentSessions.stats` 新增可选 `splitBy`(`agent`/`model`/`provider`/`modelProvider`,在 `groupBy` 之后再拆一层,第二个键在 summary 的 `split`)、筛选 `models`、`providers`、`failed`、`search`(同时作用于 `summaries` 和 `speeds`)和 `detail`(每组增加 `speed` 速度中位数与 `firstToken` 平均首字耗时);`groupBy` 新增只给宿主的 `provider`、`modelProvider`、`all`。`agentSessions.calls` 新增 `models`、`providers`、`search`,与 stats 的筛选规则相同。新增错误码 `agentSessions.invalidSplit`、`agentSessions.invalidFilter`。`agents/usage`(插件)的分组和回答不变。旧 Core 把新字段当未知字段拒绝,把新分组名当 `agentSessions.invalidGroup` 拒绝。没有新增宿主方法、通知或能力版本。 | | [#241](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/241)(待合入) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-45 | `agents` 0 内的补充 | 宿主命令 `agentSessions.search` 的命中新增 `generation` 和 `readBytes`,都是命中所在文件(可能是子代理文件)的值,宿主据此从命中处用 `agentSessions.page` 分页读取该文件。旧 Core 不回答这两个字段。没有新增宿主方法、通知、错误码或能力版本。 | | [#239](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/239)(待合入) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-45 | `agents` 0 / `litheFunctions` 0 内的补充 | 原生会话增加立即补充、FIFO 排队、停止后暂停队列和结构化问答。`agents.prompt` 增加可选 `mode`(默认 `send`,另有 `queue`、`steer`)和 `expectedTurn`;`didPrompt` 仅立即补充时增加 `mode: "steer"`、`input`。新增通知 `didAnswerQuestion`;`report` 新增 `interactionCapabilities`、`questionRequested`、`questionClosed`、`questionAnswered`、`inputResolved`,后者可带封闭的 SDK 失败分类 `code`,四语 SDK 把立即补充失败的唯一终态诊断交给 Core;回答由 SDK 确认交付。Core 新增宿主命令 `agents.updateQueue`、`agents.respondQuestion`;`cancel` 进入 stopping 并暂停队列,真实结束前不宣告停止;通过 `interactionState`、`promptDispatched`、`promptRetracted` 和 `interactionFailed` 投影结果。事件重放同时限制 8192 条 / 16 MiB,交互状态只保留每会话最新快照;`agents.waitEvents` 增加 `recoveries` 与可选 `acknowledge`,拒绝的补充在预留的 64 条 / 16 MiB 容量中保留,直到宿主恢复并显式确认。停止后的有效当前轮次问题被抑制,不阻塞同批结束事件。共享用例为 `agents/native-session.json` 及 `rust/fixtures/agents/turn-interaction-v1.json`。没有提升 API、能力、清单或函数协议版本;旧 Core 严格拒绝新字段和事件,首个支持的 Core revision 为 [`1f843f8ee3aac802cda17ad8df43b51e30862b0d`](https://github.com/Lithe-IDEA/Lithe-core-rust/commit/1f843f8ee3aac802cda17ad8df43b51e30862b0d)(本 PR,尚未合入);桌面端尚未发布。 | @@ -221,9 +222,11 @@ | API-45 | `agents/report` | 0 | 2026-11-27 | [#216](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/216) | | API-45 | `agents/report` | 0(事件新增 `configOptions`) | 2026-11-28 | [#220](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/220) | | API-45 | `agents/report` | 0(交互能力、提问/撤回、回答交付与立即补充确认;封闭失败分类;停止中抑制当前轮次问题,保留整批结束) | 待合入 | [#239](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/239) | +| API-45 | `agents/report` | 0(`toolCall` 新增 `command`,仅在 `didStart` 带 `toolCommands` 时发送) | 待合入 | [#246](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/246) | | API-45 | `agents/usage` | 0 | 2026-11-27 | [#216](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/216) | | API-45 | `agents/usage` | 0(回答新增 `speeds`) | 2026-11-28 | [#217](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/217) | | API-45 | `agents/didStart`(通知) | 0 | 2026-11-27 | [#216](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/216) | +| API-45 | `agents/didStart`(通知) | 0(新增 `toolCommands: true`) | 待合入 | [#246](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/246) | | API-45 | `agents/didOutput`(通知) | 0 | 2026-11-27 | [#216](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/216) | | API-45 | `agents/didPrompt`(通知) | 0 | 2026-11-27 | [#216](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/216) | | API-45 | `agents/didPrompt`(通知) | 0(有附件时带 `attachments`) | 2026-11-28 | [#224](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/224) | diff --git a/shared/plugins/sdk/go/README.md b/shared/plugins/sdk/go/README.md index 846c807e..d8c0f6a7 100644 --- a/shared/plugins/sdk/go/README.md +++ b/shared/plugins/sdk/go/README.md @@ -615,8 +615,10 @@ func main() { } ``` -`AgentSessionStart` carries `Session`, `AgentID`, `Cwd` and `Resume` (the -CLI's own session ID when the user resumes one, or nil). Embed +`AgentSessionStart` carries `Session`, `AgentID`, `Cwd`, `Resume` (the +CLI's own session ID when the user resumes one, or nil) and `ToolCommands` +(whether Core takes `command` on `execute` tool calls; send it only when +true). Embed `AgentSessionBase` for empty `Cancel`, `SetConfigOption` and `Exited`. `Host().Agents()` offers the same `Write` and `Report` for any session ID, and `Usage(params)` for usage totals. diff --git a/shared/plugins/sdk/go/lithe/agents.go b/shared/plugins/sdk/go/lithe/agents.go index 9f0bc616..2a89fd2d 100644 --- a/shared/plugins/sdk/go/lithe/agents.go +++ b/shared/plugins/sdk/go/lithe/agents.go @@ -54,6 +54,10 @@ type AgentSessionStart struct { Cwd string // Resume is the CLI's own session ID to resume, when the user resumes one. Resume *string + // ToolCommands says whether Core takes a command on execute tool calls. A + // backend sends ToolCall command (and a title saying what the command is + // for) only when this is true; older hosts reject the field. + ToolCommands bool } // AgentSession is the plugin's translation of one native session. Every @@ -340,6 +344,7 @@ func (b *Backend) routeAgentNotification(method string, params map[string]any) { start := AgentSessionStart{Session: session} start.AgentID, _ = params["agentID"].(string) start.Cwd, _ = params["cwd"].(string) + start.ToolCommands = params["toolCommands"] == true if resume, ok := params["resume"].(string); ok { start.Resume = &resume } diff --git a/shared/plugins/sdk/go/lithe/agents_test.go b/shared/plugins/sdk/go/lithe/agents_test.go index d65e340e..7d389270 100644 --- a/shared/plugins/sdk/go/lithe/agents_test.go +++ b/shared/plugins/sdk/go/lithe/agents_test.go @@ -136,6 +136,7 @@ func recordingBackend(t *testing.T, calls chan<- []any) *lithe.Backend { r := &recorder{session: start.Session, calls: calls, otherExited: otherExited} r.record("start", map[string]any{ "session": start.Session, "agentID": start.AgentID, "cwd": start.Cwd, "resume": start.Resume, + "toolCommands": start.ToolCommands, }) if start.AgentID == "plain" { return plain{r}, nil diff --git a/shared/plugins/sdk/java/README.md b/shared/plugins/sdk/java/README.md index de82763e..50a39af6 100644 --- a/shared/plugins/sdk/java/README.md +++ b/shared/plugins/sdk/java/README.md @@ -584,8 +584,10 @@ backend.onAgentSessions((start, session) -> new AgentSession() { ``` `map` stands for a helper that builds a `LinkedHashMap` from key-value pairs. -`AgentSessionStart` carries `session()`, `agentId()`, `cwd()` and `resume()` -(the CLI's own session ID when the user resumes one, or null). `cancel`, +`AgentSessionStart` carries `session()`, `agentId()`, `cwd()`, `resume()` +(the CLI's own session ID when the user resumes one, or null) and +`toolCommands()` (whether Core takes `command` on `execute` tool calls; send +it only when true). `cancel`, `setConfigOption` and `exited` have empty defaults. `host().agents()` offers the same `write` and `report` for any session ID, and `usage(params)` for usage totals. diff --git a/shared/plugins/sdk/java/plugin-sdk/src/main/java/io/github/litheidea/plugin/sdk/AgentSessionStart.java b/shared/plugins/sdk/java/plugin-sdk/src/main/java/io/github/litheidea/plugin/sdk/AgentSessionStart.java index 755da2d0..e3db281e 100644 --- a/shared/plugins/sdk/java/plugin-sdk/src/main/java/io/github/litheidea/plugin/sdk/AgentSessionStart.java +++ b/shared/plugins/sdk/java/plugin-sdk/src/main/java/io/github/litheidea/plugin/sdk/AgentSessionStart.java @@ -6,12 +6,14 @@ public final class AgentSessionStart { private final String agentId; private final String cwd; private final String resume; + private final boolean toolCommands; - AgentSessionStart(String session, String agentId, String cwd, String resume) { + AgentSessionStart(String session, String agentId, String cwd, String resume, boolean toolCommands) { this.session = session; this.agentId = agentId; this.cwd = cwd; this.resume = resume; + this.toolCommands = toolCommands; } /** Core's ID of the session, such as {@code agent-1}. */ @@ -33,4 +35,13 @@ public String cwd() { public String resume() { return resume; } + + /** + * Whether Core takes a {@code command} on {@code execute} tool calls. A backend sends + * {@code command} (and a {@code title} saying what the command is for) only when this is + * true; older hosts reject the field. + */ + public boolean toolCommands() { + return toolCommands; + } } diff --git a/shared/plugins/sdk/java/plugin-sdk/src/main/java/io/github/litheidea/plugin/sdk/AgentSessions.java b/shared/plugins/sdk/java/plugin-sdk/src/main/java/io/github/litheidea/plugin/sdk/AgentSessions.java index 66065ca2..d25ef5d5 100644 --- a/shared/plugins/sdk/java/plugin-sdk/src/main/java/io/github/litheidea/plugin/sdk/AgentSessions.java +++ b/shared/plugins/sdk/java/plugin-sdk/src/main/java/io/github/litheidea/plugin/sdk/AgentSessions.java @@ -73,7 +73,8 @@ void route(String method, Map params, Executor executor) { } Object resume = params.get("resume"); AgentSessionStart started = new AgentSessionStart(session, string(params, "agentID"), - string(params, "cwd"), resume instanceof String ? (String) resume : null); + string(params, "cwd"), resume instanceof String ? (String) resume : null, + Boolean.TRUE.equals(params.get("toolCommands"))); Worker queue = worker; executor.execute(() -> run(registered, started, queue)); return; diff --git a/shared/plugins/sdk/java/plugin-sdk/src/test/java/io/github/litheidea/plugin/sdk/AgentsTest.java b/shared/plugins/sdk/java/plugin-sdk/src/test/java/io/github/litheidea/plugin/sdk/AgentsTest.java index b9a7213e..8272e732 100644 --- a/shared/plugins/sdk/java/plugin-sdk/src/test/java/io/github/litheidea/plugin/sdk/AgentsTest.java +++ b/shared/plugins/sdk/java/plugin-sdk/src/test/java/io/github/litheidea/plugin/sdk/AgentsTest.java @@ -74,7 +74,7 @@ private static final class Recorder { } String id = start.session(); record(id, "start", map("session", id, "agentID", start.agentId(), "cwd", start.cwd(), - "resume", start.resume())); + "resume", start.resume(), "toolCommands", start.toolCommands())); AgentSession recorded = new AgentSession() { @Override public void output(List lines) { diff --git a/shared/plugins/sdk/node/README.md b/shared/plugins/sdk/node/README.md index f7ecbc0f..2693f77e 100644 --- a/shared/plugins/sdk/node/README.md +++ b/shared/plugins/sdk/node/README.md @@ -597,8 +597,9 @@ backend.onAgentSessions((start, session) => { }); ``` -`start` carries `session`, `agentID`, `cwd` and `resume` (the CLI's own -session ID when the user resumes one). `cancel`, `setConfigOption` and +`start` carries `session`, `agentID`, `cwd`, `resume` (the CLI's own +session ID when the user resumes one) and `toolCommands` (whether Core takes +`command` on `execute` tool calls; send it only when true). `cancel`, `setConfigOption` and `exited` are optional. `backend.host.agents` offers the same `write` and `report` for any session ID, and `usage(params)` for usage totals. diff --git a/shared/plugins/sdk/node/src/backend.mjs b/shared/plugins/sdk/node/src/backend.mjs index 972ebb91..c3705014 100644 --- a/shared/plugins/sdk/node/src/backend.mjs +++ b/shared/plugins/sdk/node/src/backend.mjs @@ -309,7 +309,7 @@ class Backend { /** * Translates the native sessions of the plugin's agents (plan API-45). For * each `lithe/host/agents/didStart`, `start({ session, agentID, cwd, - * resume }, handle)` makes the session's handler, which then gets the + * resume, toolCommands }, handle)` makes the session's handler, which then gets the * session's `didOutput`, `didPrompt`, `didCancel`, `didDecidePermission`, * `didSetConfigOption` and `didExit` one at a time, in the order Core sent * them: each call waits for the promise of the one before. The handler has @@ -640,6 +640,7 @@ class Backend { agentID: typeof params.agentID === 'string' ? params.agentID : '', cwd: typeof params.cwd === 'string' ? params.cwd : '', resume: typeof params.resume === 'string' ? params.resume : null, + toolCommands: params.toolCommands === true, }, handle)) .then((handler) => { if (!isObject(handler)) throw new TypeError('An agent session start returned no handler.'); diff --git a/shared/plugins/sdk/node/src/index.d.ts b/shared/plugins/sdk/node/src/index.d.ts index 5a9c0f55..31435a22 100644 --- a/shared/plugins/sdk/node/src/index.d.ts +++ b/shared/plugins/sdk/node/src/index.d.ts @@ -930,6 +930,12 @@ export interface AgentSessionStart { cwd: string; /** The CLI's own session ID to resume, or null. */ resume: string | null; + /** + * Whether Core takes a `command` on `execute` tool calls. A backend sends + * `command` (and a `title` saying what the command is for) only when this + * is true; older hosts reject the field. + */ + toolCommands: boolean; } /** diff --git a/shared/plugins/sdk/node/test/types/agents.mts b/shared/plugins/sdk/node/test/types/agents.mts index f128adfe..535f0ad4 100644 --- a/shared/plugins/sdk/node/test/types/agents.mts +++ b/shared/plugins/sdk/node/test/types/agents.mts @@ -18,6 +18,8 @@ void usageMethod; backend.onAgentSessions((start: AgentSessionStart, session: AgentSessionHandle): AgentSession => { const resume: string | null = start.resume; void resume; + const toolCommands: boolean = start.toolCommands; + void toolCommands; return { async output(lines: string[]) { for (const line of lines) { diff --git a/shared/plugins/sdk/rust/README.md b/shared/plugins/sdk/rust/README.md index 5b254025..ecb72c78 100644 --- a/shared/plugins/sdk/rust/README.md +++ b/shared/plugins/sdk/rust/README.md @@ -708,8 +708,9 @@ fn main() { } ``` -`AgentSessionStart` carries `session`, `agent_id`, `cwd` and `resume` (the -CLI's own session ID when the user resumes one). `cancel`, +`AgentSessionStart` carries `session`, `agent_id`, `cwd`, `resume` (the +CLI's own session ID when the user resumes one) and `tool_commands` (whether +Core takes `command` on `execute` tool calls; send it only when true). `cancel`, `set_config_option` and `exited` have empty defaults. `handle.host().agents()` offers the same `write` and `report` for any session ID, and `usage(params)` for usage totals. diff --git a/shared/plugins/sdk/rust/plugin-sdk/src/agents.rs b/shared/plugins/sdk/rust/plugin-sdk/src/agents.rs index 1d48f0f8..129630f2 100644 --- a/shared/plugins/sdk/rust/plugin-sdk/src/agents.rs +++ b/shared/plugins/sdk/rust/plugin-sdk/src/agents.rs @@ -34,6 +34,10 @@ pub struct AgentSessionStart { pub cwd: String, /// The CLI's own session ID to resume, when the user resumes one. pub resume: Option, + /// Whether Core takes a `command` on `execute` tool calls. A backend sends + /// `command` (and a `title` saying what the command is for) only when this + /// is true; older hosts reject the field. + pub tool_commands: bool, } /// One attachment of a prompt, the way an ACP client sends prompt content: @@ -306,6 +310,7 @@ impl AgentWorkers { agent_id: text(¶ms["agentID"]), cwd: text(¶ms["cwd"]), resume: params["resume"].as_str().map(str::to_string), + tool_commands: params["toolCommands"] == true, }; let (sender, receiver) = mpsc::channel(); let spawned = { diff --git a/shared/plugins/sdk/rust/plugin-sdk/tests/agents.rs b/shared/plugins/sdk/rust/plugin-sdk/tests/agents.rs index 8675d475..03a8bbd9 100644 --- a/shared/plugins/sdk/rust/plugin-sdk/tests/agents.rs +++ b/shared/plugins/sdk/rust/plugin-sdk/tests/agents.rs @@ -208,6 +208,7 @@ fn recording_backend(calls: mpsc::Sender) -> Backend { "agentID": start.agent_id, "cwd": start.cwd, "resume": start.resume, + "toolCommands": start.tool_commands, } ])); if start.agent_id == "plain" {