@lucascouts/claude-agent-acp-plus 0.34.1 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,8 @@ export type ChildLaunch = {
25
25
  /** The SDK agent id — the child's session id. */
26
26
  agentId: string;
27
27
  title: string;
28
- description: string;
28
+ /** The child's role; absent when it is already the title (upstream #1479). */
29
+ description?: string;
29
30
  prompt?: string;
30
31
  /** True when the SDK can stop this subagent on its own (`Query.stopTask`). */
31
32
  cancellable: boolean;
@@ -45,6 +46,9 @@ export declare class ChildSessionRouter {
45
46
  * stamp (a progress beat, an edit diff) follows its call, even after its
46
47
  * child settled. Keyed like `byToolUse`; bounded by `place`. */
47
48
  private readonly toolCalls;
49
+ /** A child's working directory reported before its announcement, when it differs from its
50
+ * parent's. Taken by the announcement. */
51
+ private readonly pendingCwds;
48
52
  constructor(send: Send, debug: (line: string) => void);
49
53
  isChild(sessionId: string): boolean;
50
54
  /** The parent session a child belongs to. */
@@ -73,6 +77,15 @@ export declare class ChildSessionRouter {
73
77
  restore(launch: ChildLaunch, options: {
74
78
  announce: boolean;
75
79
  }): Promise<void>;
80
+ /**
81
+ * Upstream #1496: the child's working directory, from the `cwd` of its own hook. A child that
82
+ * Claude Code runs elsewhere (Agent `isolation: "worktree"`) reports its worktree. The client
83
+ * gets it only when it differs from the parent's -- in the announcement, or in a
84
+ * `subagent_update` right after it -- and `null` when the child is back in the parent's.
85
+ * SubagentStart runs before the child's first model request, so the `cwd` reaches the client
86
+ * before the child's first tool call.
87
+ */
88
+ reportCwd(childId: string, cwd: string, parentCwd: string): Promise<void>;
76
89
  private announce;
77
90
  private sendPrompt;
78
91
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"child-sessions.d.ts","sourceRoot":"","sources":["../src/child-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAE7E;;;;;;;;;;;;;;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AE;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BjF;;;;;;;OAOG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAmBjE,QAAQ;YAwBR,UAAU;IAgBxB;;;;OAIG;IACH,KAAK,CAAC,YAAY,EAAE,mBAAmB,GAAG,mBAAmB;IAM7D,sEAAsE;IAChE,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/C,4EAA4E;IACtE,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS/C,8DAA8D;IAC9D,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIrC,yEAAyE;IACnE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;YAQ3D,QAAQ;CAYvB"}
@@ -1,3 +1,6 @@
1
+ import path from "node:path";
2
+ /** Hooks can report a child's `cwd` before it is announced; bound what waits for one. */
3
+ const MAX_PENDING_CWDS = 64;
1
4
  /** A subagent's SDK task status mapped onto the RFD's idle stop reason. */
2
5
  export function childStopReasonOf(status) {
3
6
  switch (status) {
@@ -28,6 +31,9 @@ export class ChildSessionRouter {
28
31
  * stamp (a progress beat, an edit diff) follows its call, even after its
29
32
  * child settled. Keyed like `byToolUse`; bounded by `place`. */
30
33
  toolCalls = new Map();
34
+ /** A child's working directory reported before its announcement, when it differs from its
35
+ * parent's. Taken by the announcement. */
36
+ pendingCwds = new Map();
31
37
  constructor(send, debug) {
32
38
  this.send = send;
33
39
  this.debug = debug;
@@ -159,14 +165,48 @@ export class ChildSessionRouter {
159
165
  await this.announce(record, launch);
160
166
  await this.sendPrompt(record, launch);
161
167
  }
168
+ /**
169
+ * Upstream #1496: the child's working directory, from the `cwd` of its own hook. A child that
170
+ * Claude Code runs elsewhere (Agent `isolation: "worktree"`) reports its worktree. The client
171
+ * gets it only when it differs from the parent's -- in the announcement, or in a
172
+ * `subagent_update` right after it -- and `null` when the child is back in the parent's.
173
+ * SubagentStart runs before the child's first model request, so the `cwd` reaches the client
174
+ * before the child's first tool call.
175
+ */
176
+ async reportCwd(childId, cwd, parentCwd) {
177
+ if (!path.isAbsolute(cwd))
178
+ return;
179
+ const value = path.resolve(cwd) === path.resolve(parentCwd) ? undefined : cwd;
180
+ const record = this.byChild.get(childId);
181
+ if (!record || record.unannounced) {
182
+ if (value === undefined)
183
+ this.pendingCwds.delete(childId);
184
+ else if (this.pendingCwds.has(childId) || this.pendingCwds.size < MAX_PENDING_CWDS) {
185
+ this.pendingCwds.set(childId, value);
186
+ }
187
+ return;
188
+ }
189
+ if (record.reportedCwd === value)
190
+ return;
191
+ record.reportedCwd = value;
192
+ await this.send({
193
+ sessionId: record.announcedOn,
194
+ update: { sessionUpdate: "subagent_update", sessionId: record.childId, cwd: value ?? null },
195
+ });
196
+ }
162
197
  async announce(record, launch, state) {
198
+ const cwd = this.pendingCwds.get(record.childId);
199
+ this.pendingCwds.delete(record.childId);
200
+ if (cwd !== undefined)
201
+ record.reportedCwd = cwd;
163
202
  await this.send({
164
203
  sessionId: record.announcedOn,
165
204
  update: {
166
205
  sessionUpdate: "subagent_update",
167
206
  sessionId: record.childId,
168
207
  title: launch.title,
169
- description: launch.description,
208
+ ...(launch.description ? { description: launch.description } : {}),
209
+ ...(record.reportedCwd ? { cwd: record.reportedCwd } : {}),
170
210
  // `SubagentSessionCapabilities.cancel` is an object when supported;
171
211
  // absent, Zed disables Stop for the child (design.md, Security).
172
212
  ...(launch.cancellable ? { capabilities: { cancel: {} } } : {}),
@@ -33,6 +33,7 @@ export type ClearContextSession<Turn extends ClearContextTurn = ClearContextTurn
33
33
  turnQueue?: Turn[];
34
34
  pendingExitPlanContextReset?: ClearContextReset;
35
35
  contextUsedTokens?: number;
36
+ contextWindowSize: number;
36
37
  input: {
37
38
  push(message: SDKUserMessage): unknown;
38
39
  };
@@ -45,7 +46,9 @@ export type ClearContextCoordinatorHost<Session extends ClearContextSession<Turn
45
46
  permissionMode: PermissionMode;
46
47
  }): Promise<Session>;
47
48
  applyFastMode(session: Session, enabled: boolean): Promise<void>;
48
- publishSessionState(sessionId: string, mode: PermissionMode, configOptions: SessionConfigOption[]): Promise<void>;
49
+ /** Publishes the fresh context's mode, config options, and usage: the
50
+ * context starts empty in a window of `contextWindowSize` tokens (upstream #1484). */
51
+ publishSessionState(sessionId: string, mode: PermissionMode, configOptions: SessionConfigOption[], contextWindowSize: number): Promise<void>;
49
52
  continuationMessage(sessionId: string, plan: string, promptUuid: string): SDKUserMessage;
50
53
  ensureConsumer(session: Session, sessionId: string): void;
51
54
  logError(message: string, error: unknown): void;
@@ -1 +1 @@
1
- {"version":3,"file":"clear-context-coordinator.d.ts","sourceRoot":"","sources":["../src/clear-context-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAChG,OAAO,KAAK,EAGV,cAAc,EACd,cAAc,EACf,MAAM,gCAAgC,CAAC;AAGxC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;CACtB,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,KAAK,CAAC;CACtB,CAAC;AAEF;;+EAE+E;AAC/E,MA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E,EACpC,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,cAAc,CAAC;IACzF,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1D,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CACjD,CAAC;AAoCF;;kEAEkE;AAClE,wBAAsB,0BAA0B,CAC9C,IAAI,SAAS,gBAAgB,EAC7B,OAAO,SAAS,mBAAmB,CAAC,IAAI,CAAC,EAEzC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,OAAO,EACnB,KAAK,EAAE,iBAAiB,EACxB,IAAI,EAAE,2BAA2B,CAAC,OAAO,EAAE,IAAI,CAAC,EAChD,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAsDf"}
@@ -67,7 +67,7 @@ export async function continuePlanInFreshContext(sessionId, oldSession, reset, h
67
67
  freshSession.turnQueue = [turn];
68
68
  freshSession.contextUsedTokens = 0;
69
69
  try {
70
- await host.publishSessionState(sessionId, reset.mode, freshSession.configOptions);
70
+ await host.publishSessionState(sessionId, reset.mode, freshSession.configOptions, freshSession.contextWindowSize);
71
71
  }
72
72
  catch (error) {
73
73
  host.logError("Failed to publish clear-context session state:", error);
@@ -1 +1 @@
1
- {"version":3,"file":"exit-plan.d.ts","sourceRoot":"","sources":["../src/exit-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EA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,EAAE,OAAO,GAAG,IAAI,CAAC;CAC1E,CAAC;AAEF;;oEAEoE;AACpE,qBAAa,mBAAmB,CAC9B,OAAO,SAAS,mBAAmB,CAAC,IAAI,CAAC,EACzC,IAAI,SAAS,gBAAgB;IAIjB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsC;gBAElC,IAAI,EAAE,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC;IAErE,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIzB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAwE/F"}
package/dist/exit-plan.js CHANGED
@@ -106,7 +106,7 @@ export class ExitPlanCoordinator {
106
106
  try {
107
107
  const clearContextHost = {
108
108
  ...this.host,
109
- publishSessionState: async (id, mode, configOptions) => {
109
+ publishSessionState: async (id, mode, configOptions, contextWindowSize) => {
110
110
  await this.host.sessionUpdate({
111
111
  sessionId: id,
112
112
  update: { sessionUpdate: "current_mode_update", currentModeId: mode },
@@ -115,6 +115,13 @@ export class ExitPlanCoordinator {
115
115
  sessionId: id,
116
116
  update: { sessionUpdate: "config_option_update", configOptions },
117
117
  });
118
+ // Upstream #1484: otherwise the client shows the old context's usage until the
119
+ // fresh context first reports its own. `used: 0` understates it slightly (the
120
+ // system prompt and the plan) until Claude's next usage report.
121
+ await this.host.sessionUpdate({
122
+ sessionId: id,
123
+ update: { sessionUpdate: "usage_update", used: 0, size: contextWindowSize },
124
+ });
118
125
  },
119
126
  continuationMessage: (id, plan, promptUuid) => ({
120
127
  type: "user",
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The session's task list as a keyed plan (Zeo next proposal §5.1, F1).
3
+ *
4
+ * A legacy `plan` update is pruned by Zed: when the next message is sent, it
5
+ * drops the completed entries, so a fully completed plan vanished at the next
6
+ * turn. A keyed `plan_update` (zed#66345) is never pruned, and Zed applies v1
7
+ * `plan_update`/`plan_removed` as they arrive. It advertises the `plan` client
8
+ * capability behind `acp-beta`, which Zeo's patch `0001` forces on.
9
+ *
10
+ * The gate and the id are upstream's, not new ones: `supportsPlanOperations`
11
+ * (upstream `acp-agent.ts`, `clientCapabilities?.plan != null`) and
12
+ * `SESSION_PLAN_ID` (upstream `src/v2/session-update.ts`).
13
+ */
14
+ import type { ClientCapabilities, PlanEntry, SessionNotification } from "@agentclientprotocol/sdk/unstable";
15
+ /** The one plan id this adapter's task list lives under. */
16
+ export declare const SESSION_PLAN_ID = "plan";
17
+ /** True when the client applies keyed plan updates. */
18
+ export declare function supportsPlanOperations(caps: ClientCapabilities | null | undefined): boolean;
19
+ /** The task list as the update this client understands. */
20
+ export declare function planSessionUpdate(entries: PlanEntry[], keyed: boolean): SessionNotification["update"];
21
+ /** Removes the session plan from a client that applies keyed plans. */
22
+ export declare function planRemovedUpdate(): SessionNotification["update"];
23
+ //# sourceMappingURL=keyed-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed-plan.d.ts","sourceRoot":"","sources":["../src/keyed-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,SAAS,EACT,mBAAmB,EACpB,MAAM,mCAAmC,CAAC;AAE3C,4DAA4D;AAC5D,eAAO,MAAM,eAAe,SAAS,CAAC;AAEtC,uDAAuD;AACvD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAE3F;AAED,2DAA2D;AAC3D,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,EAAE,EACpB,KAAK,EAAE,OAAO,GACb,mBAAmB,CAAC,QAAQ,CAAC,CAM/B;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAEjE"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The session's task list as a keyed plan (Zeo next proposal §5.1, F1).
3
+ *
4
+ * A legacy `plan` update is pruned by Zed: when the next message is sent, it
5
+ * drops the completed entries, so a fully completed plan vanished at the next
6
+ * turn. A keyed `plan_update` (zed#66345) is never pruned, and Zed applies v1
7
+ * `plan_update`/`plan_removed` as they arrive. It advertises the `plan` client
8
+ * capability behind `acp-beta`, which Zeo's patch `0001` forces on.
9
+ *
10
+ * The gate and the id are upstream's, not new ones: `supportsPlanOperations`
11
+ * (upstream `acp-agent.ts`, `clientCapabilities?.plan != null`) and
12
+ * `SESSION_PLAN_ID` (upstream `src/v2/session-update.ts`).
13
+ */
14
+ /** The one plan id this adapter's task list lives under. */
15
+ export const SESSION_PLAN_ID = "plan";
16
+ /** True when the client applies keyed plan updates. */
17
+ export function supportsPlanOperations(caps) {
18
+ return caps?.plan != null;
19
+ }
20
+ /** The task list as the update this client understands. */
21
+ export function planSessionUpdate(entries, keyed) {
22
+ if (!keyed)
23
+ return { sessionUpdate: "plan", entries };
24
+ return {
25
+ sessionUpdate: "plan_update",
26
+ plan: { type: "items", planId: SESSION_PLAN_ID, entries },
27
+ };
28
+ }
29
+ /** Removes the session plan from a client that applies keyed plans. */
30
+ export function planRemovedUpdate() {
31
+ return { sessionUpdate: "plan_removed", planId: SESSION_PLAN_ID };
32
+ }
@@ -24,6 +24,16 @@ export declare function noticeTranscriptText(notice: SessionNotice): string;
24
24
  * bold-label rendering of the notice) and `transcriptMeta`, so clients
25
25
  * without the capability can still tell the line apart from Claude's reply. */
26
26
  export declare function noticeOrTranscriptUpdate(notice: SessionNotice, supportsNotices: boolean, transcriptText?: string, transcriptMeta?: Record<string, unknown>): SessionNotification["update"];
27
+ /** Clients render consecutive agent_message_chunks as one markdown stream, so
28
+ * a bare `**Notice:** …` chunk lands mid-sentence: "…all done.**Notice:** Stop
29
+ * says: …". Put it in its own blockquote paragraph, blank lines on both sides,
30
+ * so it starts on a new line and Claude's next chunk does not continue the
31
+ * quote. */
32
+ export declare function transcriptBlock(text: string): string;
33
+ /** Claude Code prefixes every line of a hook's `systemMessage` with
34
+ * "<HookEvent> says: ", so a two-line message reads "Stop says: a\nStop says:
35
+ * b". Keep the prefix on the first line only when every line repeats it. */
36
+ export declare function collapseHookSpeaker(text: string): string;
27
37
  /** Fragments that read on after a bold label stand alone as a notice
28
38
  * description, so start them with a capital. */
29
39
  export declare function sentenceCase(text: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"session-notices.d.ts","sourceRoot":"","sources":["../src/session-notices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAEjG;;8DAE8D;AAC9D,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IACvC,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;kEACkE;AAClE,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;oEAEoE;AACpE,wBAAgB,qBAAqB,CAAC,YAAY,CAAC,EAAE,kBAAkB,GAAG,IAAI,GAAG,OAAO,CAGvF;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAOjF;AAED,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAElE;AAED;;;gFAGgF;AAChF,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,aAAa,EACrB,eAAe,EAAE,OAAO,EACxB,cAAc,GAAE,MAAqC,EACrD,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,mBAAmB,CAAC,QAAQ,CAAC,CAO/B;AAED;iDACiD;AACjD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAA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BAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGpD;AAID;;6EAE6E;AAC7E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOxD;AAED;iDACiD;AACjD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;4EAC4E;AAC5E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;4DAE4D;AAC5D,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKpD;AAED;;0DAE0D;AAC1D,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,GACpB,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,aAAa,CAAC,CAU9C"}
@@ -29,10 +29,31 @@ export function noticeOrTranscriptUpdate(notice, supportsNotices, transcriptText
29
29
  return noticeUpdate(notice);
30
30
  return {
31
31
  sessionUpdate: "agent_message_chunk",
32
- content: { type: "text", text: transcriptText },
32
+ content: { type: "text", text: transcriptBlock(transcriptText) },
33
33
  ...(transcriptMeta ? { _meta: transcriptMeta } : {}),
34
34
  };
35
35
  }
36
+ /** Clients render consecutive agent_message_chunks as one markdown stream, so
37
+ * a bare `**Notice:** …` chunk lands mid-sentence: "…all done.**Notice:** Stop
38
+ * says: …". Put it in its own blockquote paragraph, blank lines on both sides,
39
+ * so it starts on a new line and Claude's next chunk does not continue the
40
+ * quote. */
41
+ export function transcriptBlock(text) {
42
+ const lines = text.trim().split(/\r?\n/);
43
+ return `\n\n${lines.map((line) => (line ? `> ${line}` : ">")).join("\n")}\n\n`;
44
+ }
45
+ const HOOK_SPEAKER = /^[^\n:]{1,80} says: /;
46
+ /** Claude Code prefixes every line of a hook's `systemMessage` with
47
+ * "<HookEvent> says: ", so a two-line message reads "Stop says: a\nStop says:
48
+ * b". Keep the prefix on the first line only when every line repeats it. */
49
+ export function collapseHookSpeaker(text) {
50
+ const lines = text.split(/\r?\n/);
51
+ const prefix = lines[0].match(HOOK_SPEAKER)?.[0];
52
+ if (!prefix || lines.length < 2 || !lines.every((line) => line.startsWith(prefix))) {
53
+ return text;
54
+ }
55
+ return [lines[0], ...lines.slice(1).map((line) => line.slice(prefix.length))].join("\n");
56
+ }
36
57
  /** Fragments that read on after a bold label stand alone as a notice
37
58
  * description, so start them with a capital. */
38
59
  export function sentenceCase(text) {
@@ -0,0 +1,16 @@
1
+ import { RequestError } from "@agentclientprotocol/sdk/unstable";
2
+ /** Makes the CLI write an `error_during_execution` result with a
3
+ * `startup_failure_reason` before it exits on a known startup failure. Without
4
+ * it, some failures (e.g. `proxy_invalid`) end with stderr and an exit code
5
+ * alone. The SDK then rejects `initializationResult()` with an error that
6
+ * carries the reason as `startupFailureReason`. */
7
+ export declare const STARTUP_FAILURE_RESULTS_ENV: {
8
+ CLAUDE_CODE_STARTUP_FAILURE_RESULTS: string;
9
+ };
10
+ /** The ACP error for a CLI that refused to start, or `undefined` when `error`
11
+ * carries no `startupFailureReason` (older CLIs, failures without a known
12
+ * cause). The message is the CLI's own, which says what to fix, e.g.
13
+ * `Invalid proxy URL in HTTPS_PROXY: … Fix or unset HTTPS_PROXY and restart
14
+ * Claude Code.`; `data.startupFailureReason` carries the reason. */
15
+ export declare function startupFailureError(error: unknown): RequestError | undefined;
16
+ //# sourceMappingURL=startup-failure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startup-failure.d.ts","sourceRoot":"","sources":["../src/startup-failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGjE;;;;oDAIoD;AACpD,eAAO,MAAM,2BAA2B;;CAA+C,CAAC;AAYxF;;;;qEAIqE;AACrE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CAgB5E"}
@@ -0,0 +1,38 @@
1
+ import { RequestError } from "@agentclientprotocol/sdk/unstable";
2
+ /** Makes the CLI write an `error_during_execution` result with a
3
+ * `startup_failure_reason` before it exits on a known startup failure. Without
4
+ * it, some failures (e.g. `proxy_invalid`) end with stderr and an exit code
5
+ * alone. The SDK then rejects `initializationResult()` with an error that
6
+ * carries the reason as `startupFailureReason`. */
7
+ export const STARTUP_FAILURE_RESULTS_ENV = { CLAUDE_CODE_STARTUP_FAILURE_RESULTS: "1" };
8
+ /** The SDK's prefix on the message of an error built from an error result. */
9
+ const ERROR_RESULT_PREFIX = "Claude Code returned an error result: ";
10
+ /** Reasons that signing in again, or with another account, can fix. */
11
+ const AUTH_REQUIRED_REASONS = new Set([
12
+ "gateway_signin_required",
13
+ "org_pin_mismatch",
14
+ "org_config_refused",
15
+ ]);
16
+ /** The ACP error for a CLI that refused to start, or `undefined` when `error`
17
+ * carries no `startupFailureReason` (older CLIs, failures without a known
18
+ * cause). The message is the CLI's own, which says what to fix, e.g.
19
+ * `Invalid proxy URL in HTTPS_PROXY: … Fix or unset HTTPS_PROXY and restart
20
+ * Claude Code.`; `data.startupFailureReason` carries the reason. */
21
+ export function startupFailureError(error) {
22
+ if (!(error instanceof Error))
23
+ return undefined;
24
+ const reason = error.startupFailureReason;
25
+ if (typeof reason !== "string" || reason === "")
26
+ return undefined;
27
+ const message = error.message.startsWith(ERROR_RESULT_PREFIX)
28
+ ? error.message.slice(ERROR_RESULT_PREFIX.length)
29
+ : error.message;
30
+ const data = { startupFailureReason: reason };
31
+ if (AUTH_REQUIRED_REASONS.has(reason)) {
32
+ return RequestError.authRequired(data, message);
33
+ }
34
+ if (reason === "cwd_unavailable") {
35
+ return RequestError.invalidParams(data, message);
36
+ }
37
+ return RequestError.internalError(data, message);
38
+ }
@@ -145,6 +145,15 @@ export declare class TaskFeed {
145
145
  nextReconcileAt(): number | null;
146
146
  /** Ends as `interrupted` every task whose deadline passed with no bookend. */
147
147
  reconcile(now: number): TaskChange;
148
+ /**
149
+ * The turn was cancelled (F3, proposal §5.3). Its foreground work dies with
150
+ * it, but the CLI does not always send the closing event, and `reconcile`
151
+ * only covers background tasks — so a foreground row stayed "running" until
152
+ * the session ended. Running foreground tasks end as `interrupted`; a held
153
+ * foreground shell was never shown, so it is dropped, as on a restart.
154
+ * Background tasks outlive the turn and are left alone.
155
+ */
156
+ onTurnCancelled(): TaskChange;
148
157
  /** The CLI process restarted: whatever was running did not survive it. A
149
158
  * held shell task was never shown, so it is dropped rather than ended. */
150
159
  onProcessRestart(): TaskChange;
@@ -1 +1 @@
1
- {"version":3,"file":"task-feed.d.ts","sourceRoot":"","sources":["../src/task-feed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AAGxC,2EAA2E;AAC3E,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAE9C;2DAC2D;AAC3D,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,aAAa,CAAC;AAExF,MAAM,MAAM,SAAS,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF,0EAA0E;AAC1E,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAA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E,YAA+B,EACvC,UAAU,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAY,EAC1D,GAAG,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAe,EACtC,SAAS,SAAK;IAGjC,wFAAwF;IACxF,IAAI,IAAI,IAAI;IAMZ;;;OAGG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBjD,OAAO,IAAI,IAAI;IAKf,OAAO,CAAC,IAAI;YAKE,IAAI;CA0CnB"}
package/dist/task-feed.js CHANGED
@@ -295,6 +295,30 @@ export class TaskFeed {
295
295
  }
296
296
  return change;
297
297
  }
298
+ /**
299
+ * The turn was cancelled (F3, proposal §5.3). Its foreground work dies with
300
+ * it, but the CLI does not always send the closing event, and `reconcile`
301
+ * only covers background tasks — so a foreground row stayed "running" until
302
+ * the session ended. Running foreground tasks end as `interrupted`; a held
303
+ * foreground shell was never shown, so it is dropped, as on a restart.
304
+ * Background tasks outlive the turn and are left alone.
305
+ */
306
+ onTurnCancelled() {
307
+ for (const [id, task] of this.held) {
308
+ if (task.background)
309
+ continue;
310
+ this.held.delete(id);
311
+ this.outputs.delete(id);
312
+ }
313
+ let change = "none";
314
+ for (const task of this.tasks.values()) {
315
+ if (task.status !== "running" || task.background)
316
+ continue;
317
+ this.end(task, "interrupted");
318
+ change = "terminal";
319
+ }
320
+ return change;
321
+ }
298
322
  /** The CLI process restarted: whatever was running did not survive it. A
299
323
  * held shell task was never shown, so it is dropped rather than ended. */
300
324
  onProcessRestart() {
@@ -527,7 +551,10 @@ export class TaskFeedPublisher {
527
551
  }
528
552
  dispose(options = {}) {
529
553
  this.closed = true;
530
- this.flushOnSettle = options.flush ?? false;
554
+ // A later plain dispose never cancels an earlier flush: teardownSession
555
+ // used to dispose again after retireTaskFeed's `{ flush: true }`, and the
556
+ // retirement's queued `interrupted` endings were dropped (F3).
557
+ this.flushOnSettle = this.flushOnSettle || (options.flush ?? false);
531
558
  this.cancelPending();
532
559
  if (this.reconcileTimer !== null)
533
560
  this.timers.clearTimeout(this.reconcileTimer);
package/dist/tools.d.ts CHANGED
@@ -95,6 +95,7 @@ export declare function toolUpdateFromDiffToolResponse(toolResponse: unknown): {
95
95
  export declare const registerHookCallback: (toolUseID: string, { onPostToolUseHook, }: {
96
96
  onPostToolUseHook?: (toolUseID: string, toolInput: unknown, toolResponse: unknown) => Promise<void>;
97
97
  }) => void;
98
+ export declare function unregisterHookCallback(toolUseID: string): void;
98
99
  export declare const createPostToolUseHook: (options?: {
99
100
  onEnterPlanMode?: () => Promise<void>;
100
101
  }) => HookCallback;
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAaL,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,gBAAgB,EAKjB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAGL,oBAAoB,EAEpB,6BAA6B,EAE9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,yCAAyC,EAGzC,qCAAqC,EAGrC,kCAAkC,EAGlC,+CAA+C,EAI/C,wBAAwB,EACxB,kCAAkC,EAIlC,gCAAgC,EAEhC,iCAAiC,EAClC,MAAM,sCAAsC,CAAC;AA2B9C,UAAU,QAAQ;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAED,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,SAA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AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAiB1F;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAc5E;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,CAMpE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQnD;AAeD;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,OAAO,GAAG;IACrE,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAChC,CA4CA;AAcD,eAAO,MAAM,oBAAoB,GAC/B,WAAW,MAAM,EACjB,wBAEG;IACD,iBAAiB,CAAC,EAAE,CAClB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,OAAO,EAClB,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,SAKF,CAAC;AAIF,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE9D;AAGD,eAAO,MAAM,qBAAqB,GAC/B,UAAU;IAAE,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,KAAG,YAiBtD,CAAC;AAEJ;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GACxB,SAAS;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,KAAG,YAsBpE,CAAC"}
package/dist/tools.js CHANGED
@@ -373,6 +373,10 @@ export function toolInfoFromToolUse(toolUse, supportsTerminalOutput = false, cwd
373
373
  content: [],
374
374
  };
375
375
  }
376
+ // EnterPlanMode switches the session to plan mode, so it has the `switch_mode` kind like
377
+ // ExitPlanMode (upstream #1467, agentclientprotocol/agent-client-protocol#2543).
378
+ case "EnterPlanMode":
379
+ return { title: "EnterPlanMode", kind: "switch_mode", content: [] };
376
380
  case "ExitPlanMode": {
377
381
  const planInput = toolUse.input;
378
382
  return {
@@ -1111,10 +1115,26 @@ export function parseTaskUpdateOutput(content, expectedTaskId) {
1111
1115
  }
1112
1116
  return undefined;
1113
1117
  }
1118
+ /**
1119
+ * Ids a start-over dropped (Zeo next proposal §5.1). The CLI's own task store
1120
+ * keeps a finished list, so a later TaskList would bring it back; while such a
1121
+ * task is still completed it stays out of the plan.
1122
+ */
1123
+ const retiredTaskIds = new WeakMap();
1114
1124
  export function applyTaskCreate(state, input, output) {
1115
1125
  const taskId = output?.task?.id;
1116
1126
  if (!taskId || !input)
1117
1127
  return;
1128
+ // A list starts over when a task is created after every entry completed:
1129
+ // the finished list is not this one's history. Keyed plans are never pruned
1130
+ // by the client, so without this the new task would join the old list.
1131
+ if (state.size > 0 && [...state.values()].every((task) => task.status === "completed")) {
1132
+ const retired = retiredTaskIds.get(state) ?? new Set();
1133
+ for (const id of state.keys())
1134
+ retired.add(id);
1135
+ retiredTaskIds.set(state, retired);
1136
+ state.clear();
1137
+ }
1118
1138
  state.set(taskId, {
1119
1139
  subject: input.subject,
1120
1140
  status: "pending",
@@ -1145,7 +1165,10 @@ export function applyTaskUpdate(state, input) {
1145
1165
  export function applyTaskList(state, output) {
1146
1166
  const previous = new Map(state);
1147
1167
  state.clear();
1168
+ const retired = retiredTaskIds.get(state);
1148
1169
  for (const task of output.tasks) {
1170
+ if (task.status === "completed" && retired?.has(task.id))
1171
+ continue;
1149
1172
  const existing = previous.get(task.id);
1150
1173
  state.set(task.id, {
1151
1174
  subject: task.subject,
@@ -1235,6 +1258,11 @@ export const registerHookCallback = (toolUseID, { onPostToolUseHook, }) => {
1235
1258
  onPostToolUseHook,
1236
1259
  };
1237
1260
  };
1261
+ /* Drops a tool's callbacks when no PostToolUse hook will come for it: a server tool, such as
1262
+ the advisor, settles from its result in assistant content (upstream #1247). */
1263
+ export function unregisterHookCallback(toolUseID) {
1264
+ delete toolUseCallbacks[toolUseID];
1265
+ }
1238
1266
  /* A callback for Claude Code that is called when receiving a PostToolUse hook */
1239
1267
  export const createPostToolUseHook = (options) => async (input, toolUseID) => {
1240
1268
  if (input.hook_event_name === "PostToolUse") {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.34.1",
6
+ "version": "0.36.0",
7
7
  "description": "Claude Code in Zed and other ACP clients with the VS Code extension's UX — multi-select questions, refusal consent, live quota windows, background tasks, Ultracode effort and session notices. Fork of claude-agent-acp.",
8
8
  "main": "dist/lib.js",
9
9
  "types": "dist/lib.d.ts",
@@ -70,11 +70,11 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@agentclientprotocol/sdk": "2.4.0",
73
- "@anthropic-ai/claude-agent-sdk": "0.3.318",
73
+ "@anthropic-ai/claude-agent-sdk": "0.3.319",
74
74
  "zod": "^4.0.0"
75
75
  },
76
76
  "devDependencies": {
77
- "@anthropic-ai/sdk": "1.4.0",
77
+ "@anthropic-ai/sdk": "1.6.0",
78
78
  "@eslint/js": "10.0.1",
79
79
  "@tsconfig/node24": "24.0.5",
80
80
  "@types/node": "26.6.6",