mirror of
https://github.com/agentclientprotocol/claude-agent-acp.git
synced 2026-11-16 22:31:36 +00:00
Compare commits
3 Commits
v0.107.3-p
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0073280b97 | ||
|
|
edab713502 | ||
|
|
7ad73cceb9 |
@@ -1,3 +1,3 @@
|
||||
{
|
||||
".": "0.107.2"
|
||||
".": "0.107.3"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## [0.107.3](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.107.2...v0.107.3) (2026-11-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* allow Claude Enterprise accounts under --hide-claude-auth ([#1641](https://github.com/agentclientprotocol/claude-agent-acp/issues/1641)) ([be2219c](https://github.com/agentclientprotocol/claude-agent-acp/commit/be2219cef1f5b2b93129d5eef4b80574f57bdb1b))
|
||||
* pass a model id the picker does not list to Claude Code ([#1630](https://github.com/agentclientprotocol/claude-agent-acp/issues/1630)) ([dc769c1](https://github.com/agentclientprotocol/claude-agent-acp/commit/dc769c132cacc8bbc7aff0d512e5ab587a1802e3))
|
||||
|
||||
## [0.107.2](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.107.1...v0.107.2) (2026-11-16)
|
||||
|
||||
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@agentclientprotocol/claude-agent-acp",
|
||||
"version": "0.107.2",
|
||||
"version": "0.107.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@agentclientprotocol/claude-agent-acp",
|
||||
"version": "0.107.2",
|
||||
"version": "0.107.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "2.7.0",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"version": "0.107.2",
|
||||
"version": "0.107.3",
|
||||
"description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
|
||||
"main": "dist/lib.js",
|
||||
"types": "dist/lib.d.ts",
|
||||
|
||||
@@ -2498,6 +2498,25 @@ describe("toolInfoFromToolUse - Write input aliases", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// The input is what the model wrote. Claude Code rejects a field of the wrong
|
||||
// type when it runs the tool, after the adapter reported the tool use.
|
||||
describe("toolInfoFromToolUse - an input field of the wrong type", () => {
|
||||
it.each([
|
||||
["Read", { file_path: 12345 }, "Read File", toolInfoFromToolUse],
|
||||
["Edit", { file_path: 12345, old_string: "a", new_string: "b" }, "Edit", toolInfoFromToolUse],
|
||||
// Only an AIR client gets the notebook's path.
|
||||
["NotebookEdit", { notebook_path: 12345, new_source: "x" }, "Edit notebook", airToolInfo],
|
||||
["Glob", { path: 12345, pattern: "*.ts" }, "Find `*.ts`", toolInfoFromToolUse],
|
||||
["Bash", { command: 12345 }, "Terminal", toolInfoFromToolUse],
|
||||
])("reports %s %j as %j, without a location or a diff", (name, input, title, toolInfo) => {
|
||||
const info = toolInfo({ name, id: "toolu_wrong_type", input }, false, "/repo");
|
||||
|
||||
expect(info.title).toBe(title);
|
||||
expect(info.locations ?? []).toEqual([]);
|
||||
expect(info.content).not.toContainEqual(expect.objectContaining({ type: "diff" }));
|
||||
});
|
||||
});
|
||||
|
||||
describe("toolInfoFromToolUse - undefined input regression", () => {
|
||||
it("Read with undefined input should not throw", () => {
|
||||
const toolUse = { name: "Read", id: "toolu_read_undef", input: undefined };
|
||||
|
||||
@@ -28392,6 +28392,64 @@ describe("turn steering (_session/steering)", () => {
|
||||
expect(agent.sessions["test-session"].owedTrailingIdles).toBe(0);
|
||||
});
|
||||
|
||||
// The same guard when the autonomous cycle's result is stamped with the
|
||||
// original prompt: answersPendingPrompt then routes it to the user lane, and
|
||||
// its idle must still not settle the turn while the steered work runs.
|
||||
it.each(["end_turn", "refusal"] as const)(
|
||||
"does not settle a steered turn on an autonomous %s result naming the original prompt",
|
||||
async (stopReason) => {
|
||||
const timeline: string[] = [];
|
||||
const agent = new ClaudeAcpAgent(timelineClient(timeline), {
|
||||
log: () => {},
|
||||
error: () => {},
|
||||
});
|
||||
|
||||
injectGeneratorSession(agent, (input) => {
|
||||
async function* messageGenerator() {
|
||||
const iter = input[Symbol.asyncIterator]();
|
||||
const u1 = await iter.next();
|
||||
yield userEcho(u1.value);
|
||||
yield createAssistantText("working on it");
|
||||
const steered = await iter.next();
|
||||
yield { ...interruptedCycleResult(), user_message_uuid: u1.value.uuid };
|
||||
yield userEcho(steered.value);
|
||||
// A background cycle's result, stamped with the original prompt only.
|
||||
yield {
|
||||
...createResultMessage(),
|
||||
stop_reason: stopReason,
|
||||
origin: { kind: "task-notification" },
|
||||
user_message_uuid: u1.value.uuid,
|
||||
user_message_uuids: [u1.value.uuid],
|
||||
};
|
||||
yield idleMessage(); // that cycle's trailer
|
||||
yield createAssistantText("STEERED-OK");
|
||||
yield createResultMessage();
|
||||
yield idleMessage();
|
||||
}
|
||||
return messageGenerator();
|
||||
});
|
||||
|
||||
const turn = agent
|
||||
.prompt({ sessionId: "test-session", prompt: [{ type: "text", text: "start" }] })
|
||||
.then((response) => {
|
||||
timeline.push(`prompt:${response.stopReason}`);
|
||||
return response;
|
||||
});
|
||||
await waitFor(() => !!agent.sessions["test-session"]?.activeTurn);
|
||||
await agent.steer({
|
||||
sessionId: "test-session",
|
||||
prompt: [{ type: "text", text: "also handle X" }],
|
||||
});
|
||||
|
||||
await turn;
|
||||
await agent.sessions["test-session"]?.consumer;
|
||||
|
||||
// The turn keeps one stop reason across its cycles, so a refusal trailer's
|
||||
// reason is reported; what matters here is that the prompt ends last.
|
||||
expect(timeline).toEqual(["working on it", "STEERED-OK", `prompt:${stopReason}`]);
|
||||
},
|
||||
);
|
||||
|
||||
it("always injects at 'now' priority, ignoring any client-supplied priority", async () => {
|
||||
const agent = createMockAgent();
|
||||
const captured: any[] = [];
|
||||
|
||||
@@ -1161,6 +1161,41 @@ describe("tool calls of a background subagent that a cancel stops", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// The model can write an input that Claude Code rejects when it runs the tool,
|
||||
// after the adapter reported the tool use (issue #1308).
|
||||
describe("a tool use whose input Claude Code rejects", () => {
|
||||
it("reports a Read with a number for file_path as failed, and ends the turn", async () => {
|
||||
const id = "toolu_number_path";
|
||||
const error =
|
||||
"InputValidationError: Read failed due to the following issue:\n" +
|
||||
"The parameter `file_path` type is expected as `string` but provided as `number`";
|
||||
const { prompt, updates, logError } = createTestSession(async function* (prompts) {
|
||||
yield* echoNextPrompt(prompts);
|
||||
yield toolUse(id, null, "Read", { file_path: 12345 });
|
||||
yield {
|
||||
...toolResult(id),
|
||||
message: {
|
||||
role: "user",
|
||||
content: [{ type: "tool_result", tool_use_id: id, is_error: true, content: error }],
|
||||
},
|
||||
};
|
||||
yield successfulResultMessage();
|
||||
});
|
||||
|
||||
await expect(prompt()).resolves.toMatchObject({ stopReason: "end_turn" });
|
||||
|
||||
const reports = updates.filter((update) => update.toolCallId === id);
|
||||
expect(reports[0]).toMatchObject({
|
||||
sessionUpdate: "tool_call",
|
||||
title: "Read File",
|
||||
locations: [],
|
||||
rawInput: { file_path: 12345 },
|
||||
});
|
||||
expect(reports.at(-1)).toMatchObject({ status: "failed" });
|
||||
expect(logError).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
function toolStart(id = toolCallId, parent: string | null = null, name = "Bash") {
|
||||
return {
|
||||
type: "stream_event",
|
||||
|
||||
@@ -4086,6 +4086,39 @@ describe("ACP v2 prompts", () => {
|
||||
},
|
||||
);
|
||||
|
||||
// The model can write an input that Claude Code rejects when it runs the
|
||||
// tool, after the adapter reported the tool use (issue #1308).
|
||||
it("reports a Read with a number for file_path as failed, and ends the turn", async () => {
|
||||
scriptTurns(async function* (options) {
|
||||
yield toolUseMessage(options, "toolu_number_path", "Read", { file_path: 12345 });
|
||||
yield toolResultMessage(options, "toolu_number_path", {
|
||||
is_error: true,
|
||||
content:
|
||||
"InputValidationError: Read failed due to the following issue:\n" +
|
||||
"The parameter `file_path` type is expected as `string` but provided as `number`",
|
||||
});
|
||||
yield result(options);
|
||||
});
|
||||
const client = v2Client();
|
||||
await client.app.connectWith(connectRouter(), async (agent) => {
|
||||
await initializeV2(agent);
|
||||
const { sessionId } = await agent.request(v2.methods.agent.session.new, { cwd });
|
||||
await agent.request(v2.methods.agent.session.prompt, { sessionId, prompt: text("hi") });
|
||||
await vi.waitFor(() => expect(turnTrace(client.sessionUpdates)).toContain("idle end_turn"));
|
||||
await client.authUpdate(1);
|
||||
});
|
||||
|
||||
const reports = client.sessionUpdates
|
||||
.map(({ update }) => update)
|
||||
.filter((update) => "toolCallId" in update && update.toolCallId === "toolu_number_path");
|
||||
expect(reports[0]).toMatchObject({
|
||||
title: "Read File",
|
||||
locations: [],
|
||||
rawInput: { file_path: 12345 },
|
||||
});
|
||||
expect(reports.at(-1)).toMatchObject({ status: "failed" });
|
||||
});
|
||||
|
||||
it("reports a turn that fails after it was taken in as idle with the error stop reason", async () => {
|
||||
scriptTurns(async function* (options) {
|
||||
yield result(options, { is_error: true, result: "API Error: 529 Overloaded" });
|
||||
|
||||
@@ -59,6 +59,20 @@ export type ToolResultContent =
|
||||
| BetaTextEditorCodeExecutionStrReplaceResultBlock
|
||||
| BetaTextEditorCodeExecutionToolResultError;
|
||||
|
||||
/**
|
||||
* The field `key` of a tool's input when it holds a non-empty string.
|
||||
*
|
||||
* The input is what the model wrote. Claude Code validates it when it runs the
|
||||
* tool, after the adapter reported the tool use, so a field can hold any type:
|
||||
* `Read {"file_path": 12345}`. A reporter must not pass such a value on as a
|
||||
* path or a title.
|
||||
*/
|
||||
export function inputString(input: unknown, key: string): string | undefined {
|
||||
if (!input || typeof input !== "object") return undefined;
|
||||
const value = (input as Record<string, unknown>)[key];
|
||||
return typeof value === "string" && value !== "" ? value : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an absolute file path to a project-relative path for display.
|
||||
* Returns the original path if it's outside the project directory or if no cwd is provided.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { BashInput, BashOutput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
|
||||
import type { BashOutput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
|
||||
import type { BetaBashCodeExecutionResultBlock } from "@anthropic-ai/sdk/resources/beta.mjs";
|
||||
import { structuredResult, textContent, toAcpContentUpdate } from "../content.js";
|
||||
import { inputString, structuredResult, textContent, toAcpContentUpdate } from "../content.js";
|
||||
import type { ToolReporter, ToolResultContext, ToolResultFacts, ToolUseFacts } from "../facts.js";
|
||||
|
||||
/**
|
||||
@@ -19,10 +19,9 @@ export function shellDescription(input: unknown): string | undefined {
|
||||
/** Bash and PowerShell: a command whose output goes to the terminal channel. */
|
||||
export class BashReporter implements ToolReporter {
|
||||
toolUse(input: unknown): ToolUseFacts {
|
||||
const bash = input as BashInput | undefined;
|
||||
const description = shellDescription(input);
|
||||
return {
|
||||
title: bash?.command ? bash.command : "Terminal",
|
||||
title: inputString(input, "command") ?? "Terminal",
|
||||
kind: "execute",
|
||||
command: true,
|
||||
...(description ? { display: [textContent(description)] } : {}),
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
toolUpdateFromDiffToolResponse,
|
||||
v2UpdateFromDiffToolResponse,
|
||||
} from "../../diff.js";
|
||||
import { markdownEscape, resultText, textContent, toDisplayPath } from "../content.js";
|
||||
import { inputString, markdownEscape, resultText, textContent, toDisplayPath } from "../content.js";
|
||||
import type {
|
||||
ToolReporter,
|
||||
ToolResultContext,
|
||||
@@ -97,21 +97,22 @@ export function normalizeWriteInput(input: unknown): NormalizedWriteInput | unde
|
||||
export class EditReporter implements ToolReporter {
|
||||
toolUse(input: unknown, { cwd, capabilities }: ToolUseContext): ToolUseFacts {
|
||||
const edit = input as FileEditInput | undefined;
|
||||
const displayPath = edit?.file_path ? toDisplayPath(edit.file_path, cwd) : undefined;
|
||||
const filePath = inputString(input, "file_path");
|
||||
const displayPath = filePath ? toDisplayPath(filePath, cwd) : undefined;
|
||||
const facts: ToolUseFacts = {
|
||||
title: displayPath ? `Edit ${displayPath}` : "Edit",
|
||||
kind: "edit",
|
||||
locations: edit?.file_path ? [{ path: edit.file_path }] : [],
|
||||
locations: filePath ? [{ path: filePath }] : [],
|
||||
};
|
||||
// The standard diff, also for a client that negotiated patches: the input
|
||||
// holds a snippet, not the file, so a patch would need line numbers that
|
||||
// the adapter does not know here. A v2 diff cannot hold a snippet, so a v2
|
||||
// client gets the patch from the PostToolUse hook alone.
|
||||
if (edit?.file_path && (edit.old_string || edit.new_string) && !capabilities.v2) {
|
||||
if (filePath && (edit?.old_string || edit?.new_string) && !capabilities.v2) {
|
||||
facts.change = [
|
||||
{
|
||||
type: "diff",
|
||||
path: edit.file_path,
|
||||
path: filePath,
|
||||
oldText: edit.old_string || null,
|
||||
newText: edit.new_string ?? "",
|
||||
},
|
||||
@@ -181,9 +182,8 @@ export class NotebookEditReporter implements ToolReporter {
|
||||
toolUse(input: unknown, { cwd, capabilities }: ToolUseContext): ToolUseFacts {
|
||||
if (!capabilities.air.client) return { title: "NotebookEdit", kind: "other" };
|
||||
const notebook = input as Partial<NotebookEditInput> | undefined;
|
||||
const displayPath = notebook?.notebook_path
|
||||
? toDisplayPath(notebook.notebook_path, cwd)
|
||||
: undefined;
|
||||
const notebookPath = inputString(input, "notebook_path");
|
||||
const displayPath = notebookPath ? toDisplayPath(notebookPath, cwd) : undefined;
|
||||
const cell = notebook?.cell_id ? ` ${notebook.cell_id}` : "";
|
||||
const verb =
|
||||
notebook?.edit_mode === "insert"
|
||||
@@ -195,7 +195,7 @@ export class NotebookEditReporter implements ToolReporter {
|
||||
return {
|
||||
title: displayPath ? `${verb} cell${cell} in ${displayPath}` : "Edit notebook",
|
||||
kind: "edit",
|
||||
locations: notebook?.notebook_path ? [{ path: notebook.notebook_path }] : [],
|
||||
locations: notebookPath ? [{ path: notebookPath }] : [],
|
||||
...(source ? { display: source } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { FileReadInput, FileReadOutput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
|
||||
import {
|
||||
inputString,
|
||||
markdownEscape,
|
||||
structuredResult,
|
||||
textContent,
|
||||
@@ -18,21 +19,20 @@ import type {
|
||||
export class ReadReporter implements ToolReporter {
|
||||
toolUse(input: unknown, { cwd }: ToolUseContext): ToolUseFacts {
|
||||
const read = input as FileReadInput | undefined;
|
||||
const filePath = inputString(input, "file_path");
|
||||
let limit = "";
|
||||
if (read?.limit && read.limit > 0) {
|
||||
limit = " (" + (read.offset ?? 1) + " - " + ((read.offset ?? 1) + read.limit - 1) + ")";
|
||||
} else if (read?.offset) {
|
||||
limit = " (from line " + read.offset + ")";
|
||||
}
|
||||
const displayPath = read?.file_path ? toDisplayPath(read.file_path, cwd) : "File";
|
||||
const displayPath = filePath ? toDisplayPath(filePath, cwd) : "File";
|
||||
return {
|
||||
title: "Read " + displayPath + limit,
|
||||
kind: "read",
|
||||
// Read offsets are 1-based. ACP lines are too, so `offset: 0` (read from
|
||||
// the start) becomes line 1.
|
||||
locations: read?.file_path
|
||||
? [{ path: read.file_path, line: Math.max(read.offset ?? 1, 1) }]
|
||||
: [],
|
||||
locations: filePath ? [{ path: filePath, line: Math.max(read?.offset ?? 1, 1) }] : [],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
import type { GlobInput, GrepInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
|
||||
import { inputString } from "../content.js";
|
||||
import type { ToolReporter, ToolUseFacts } from "../facts.js";
|
||||
|
||||
/** Glob: the file list is the result to show. */
|
||||
export class GlobReporter implements ToolReporter {
|
||||
toolUse(input: unknown): ToolUseFacts {
|
||||
const glob = input as GlobInput | undefined;
|
||||
const searchPath = inputString(input, "path");
|
||||
let label = "Find";
|
||||
if (glob?.path) label += ` \`${glob.path}\``;
|
||||
if (searchPath) label += ` \`${searchPath}\``;
|
||||
if (glob?.pattern) label += ` \`${glob.pattern}\``;
|
||||
return {
|
||||
title: label,
|
||||
kind: "search",
|
||||
locations: glob?.path ? [{ path: glob.path }] : [],
|
||||
locations: searchPath ? [{ path: searchPath }] : [],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -797,7 +797,8 @@ type Turn = {
|
||||
* `steeredSettle`. `steeredSettle` can already hold the interrupted cycle's
|
||||
* outcome (or a held turn's, moved over by `steer()`) when the echo lands, so
|
||||
* while this is set the recorded outcome predates the steered work and an
|
||||
* idle must not settle on it. */
|
||||
* idle must not settle on it. A result of an autonomous cycle that names
|
||||
* none of the turn's steers is not steered work, so it does not clear it. */
|
||||
steeredAwaitingResult?: boolean;
|
||||
/** What a steered turn settles with once its steered work has run: the outcome
|
||||
* of its latest result, so its usage covers every cycle the turn ran. */
|
||||
@@ -3907,14 +3908,19 @@ export class ClaudeAcpAgent {
|
||||
* calling settleActive directly bypasses the hold and re-opens the
|
||||
* out-of-turn permission deadlock (issue #866) through its lane. For a
|
||||
* client with `backgroundSubagents` this always settles now. */
|
||||
const settleOrDefer = async (outcome: TurnOutcome) => {
|
||||
const settleOrDefer = async (
|
||||
outcome: TurnOutcome,
|
||||
{ steeredWork = true }: { steeredWork?: boolean } = {},
|
||||
) => {
|
||||
// No result ends a steered turn: the steer aborted the cycle this result
|
||||
// may belong to, and the steered one is still to come. Record the outcome
|
||||
// for the idle lane (see Turn.steeredEchoes); later cycles overwrite it,
|
||||
// so the last result and its usage win.
|
||||
if (isSteering(session.activeTurn)) {
|
||||
session.activeTurn.steeredSettle = outcome;
|
||||
session.activeTurn.steeredAwaitingResult = false;
|
||||
// Only a result of the steered work ends the wait for it (see
|
||||
// Turn.steeredAwaitingResult).
|
||||
if (steeredWork) session.activeTurn.steeredAwaitingResult = false;
|
||||
return;
|
||||
}
|
||||
if (
|
||||
@@ -5612,6 +5618,10 @@ export class ClaudeAcpAgent {
|
||||
// commands whose shared or late result this is, even when the
|
||||
// result is the ACTIVE turn's (ensureActiveTurn never looks at
|
||||
// the map in that case).
|
||||
// Whether this result names one of the turn's steers. The settle
|
||||
// calls below read it too: a result of a cycle Claude Code started
|
||||
// that names none of them is not the steered work's result.
|
||||
let answersSteer = false;
|
||||
if (!isAutonomousResult) {
|
||||
recordResultForOrphanCommands();
|
||||
await ensureActiveTurn(message.user_message_uuid, message.user_message_uuids);
|
||||
@@ -5629,7 +5639,6 @@ export class ClaudeAcpAgent {
|
||||
const consumed =
|
||||
message.user_message_uuids ??
|
||||
(message.user_message_uuid !== undefined ? [message.user_message_uuid] : []);
|
||||
let answersSteer = false;
|
||||
for (const uuid of consumed) {
|
||||
steeredTurn.steeredEchoes.delete(uuid);
|
||||
if (steeredTurn.steeredUuids?.has(uuid)) answersSteer = true;
|
||||
@@ -6070,7 +6079,9 @@ export class ClaudeAcpAgent {
|
||||
// settling it out from under them would strand their output
|
||||
// and permission requests out-of-turn (issue #866's deadlock,
|
||||
// through the refusal lane).
|
||||
await settleOrDefer(turnOutcome(session, "refusal"));
|
||||
await settleOrDefer(turnOutcome(session, "refusal"), {
|
||||
steeredWork: !startedByClaudeCode || answersSteer,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6258,7 +6269,9 @@ export class ClaudeAcpAgent {
|
||||
await compaction.reset();
|
||||
}
|
||||
if (!session.cancelled) {
|
||||
await settleOrDefer(turnOutcome(session, stopReason));
|
||||
await settleOrDefer(turnOutcome(session, stopReason), {
|
||||
steeredWork: !startedByClaudeCode || answersSteer,
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
if (!isAutonomousResult) {
|
||||
|
||||
Reference in New Issue
Block a user