diff --git a/package-lock.json b/package-lock.json index 0f0519f1..c4426415 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.88.0", "license": "Apache-2.0", "dependencies": { - "@agentclientprotocol/sdk": "1.7.0", + "@agentclientprotocol/sdk": "1.8.0", "@anthropic-ai/claude-agent-sdk": "0.3.293", "diff": "9.0.0", "zod": "4.6.5" @@ -39,9 +39,9 @@ } }, "node_modules/@agentclientprotocol/sdk": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@agentclientprotocol/sdk/-/sdk-1.7.0.tgz", - "integrity": "sha512-ZORuxsuEnLjRly7t6Ad7zAsWitjWsyprswyPUHz/yycPb+tTm3DGa8XheaHhRXqX8LS9snuxaYavXSRA50TlHw==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@agentclientprotocol/sdk/-/sdk-1.8.0.tgz", + "integrity": "sha512-fbP7qHZsFyTJVT0/RPrcWJ8An26qLXHEuGCHHEKDyxD1xpXV+Ejyh2LAE6vBAFePkpVjZeeohnbgvuEhZ7wLMg==", "license": "Apache-2.0", "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" diff --git a/package.json b/package.json index 7a0da34a..d68b28c6 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "node": ">=22" }, "dependencies": { - "@agentclientprotocol/sdk": "1.7.0", + "@agentclientprotocol/sdk": "1.8.0", "@anthropic-ai/claude-agent-sdk": "0.3.293", "diff": "9.0.0", "zod": "4.6.5" diff --git a/src/v2/prompt.ts b/src/v2/prompt.ts index fc1b5abd..df15e195 100644 --- a/src/v2/prompt.ts +++ b/src/v2/prompt.ts @@ -14,7 +14,7 @@ import { import * as v2 from "@agentclientprotocol/sdk/experimental/v2"; import type { ClaudeAcpAgent } from "../acp-agent.js"; import { splitNoticeText } from "../session-notices.js"; -import type { TurnEvents, TurnOutcome } from "../turn-events.js"; +import type { StopReason, TurnEvents, TurnOutcome } from "../turn-events.js"; /** * Starts a turn for `params`, and answers when Claude Code takes the prompt @@ -126,14 +126,19 @@ function jsonRpcError(error: unknown): { code: number; message: string; data?: u }; } +/** + * The `idle` of a turn that ended. Every stop reason the agent reports is one + * of v2's own, so the state is typed as those members of `IdleStateUpdate`: + * the type checker matches each stop reason to its member, which it cannot do + * against the whole union with its custom and unknown members. + */ function idle({ stopReason, usage, _meta }: TurnOutcome): v2.SessionUpdate { - return { - sessionUpdate: "state_update", - state: "idle", + const state: Extract = { stopReason, ...(usage ? { usage } : {}), ...(_meta ? { _meta } : {}), }; + return { sessionUpdate: "state_update", state: "idle", ...state }; } /**