@agentclientprotocol/claude-agent-acp 0.102.0 → 0.102.1-preview.2

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.
Files changed (206) hide show
  1. package/README.md +5 -1
  2. package/dist/acp-agent.d.ts +119 -439
  3. package/dist/acp-agent.d.ts.map +1 -1
  4. package/dist/acp-agent.js +380 -2412
  5. package/dist/acp-subagents.d.ts +1 -2
  6. package/dist/acp-subagents.d.ts.map +1 -1
  7. package/dist/auth-methods.d.ts +21 -0
  8. package/dist/auth-methods.d.ts.map +1 -0
  9. package/dist/auth-methods.js +68 -0
  10. package/dist/auth-status-reporter.d.ts +112 -0
  11. package/dist/auth-status-reporter.d.ts.map +1 -0
  12. package/dist/auth-status-reporter.js +253 -0
  13. package/dist/background-work.d.ts +12 -265
  14. package/dist/background-work.d.ts.map +1 -1
  15. package/dist/background-work.js +8 -558
  16. package/dist/client-system-prompt.d.ts +7 -0
  17. package/dist/client-system-prompt.d.ts.map +1 -1
  18. package/dist/client-system-prompt.js +24 -0
  19. package/dist/context-compaction.d.ts +20 -0
  20. package/dist/context-compaction.d.ts.map +1 -1
  21. package/dist/context-compaction.js +26 -0
  22. package/dist/context-window.d.ts +70 -0
  23. package/dist/context-window.d.ts.map +1 -0
  24. package/dist/context-window.js +132 -0
  25. package/dist/diff.d.ts +1 -1
  26. package/dist/diff.js +1 -1
  27. package/dist/elicitation.d.ts +66 -1
  28. package/dist/elicitation.d.ts.map +1 -1
  29. package/dist/elicitation.js +109 -0
  30. package/dist/file-change-audit.d.ts +4 -3
  31. package/dist/file-change-audit.d.ts.map +1 -1
  32. package/dist/file-change-audit.js +3 -2
  33. package/dist/mcp-oauth.d.ts +44 -0
  34. package/dist/mcp-oauth.d.ts.map +1 -0
  35. package/dist/mcp-oauth.js +142 -0
  36. package/dist/mcp-servers.d.ts +10 -0
  37. package/dist/mcp-servers.d.ts.map +1 -0
  38. package/dist/mcp-servers.js +29 -0
  39. package/dist/native-subagents.d.ts +18 -8
  40. package/dist/native-subagents.d.ts.map +1 -1
  41. package/dist/native-subagents.js +7 -35
  42. package/dist/permissions/presentation.d.ts +29 -0
  43. package/dist/permissions/presentation.d.ts.map +1 -1
  44. package/dist/permissions/presentation.js +38 -11
  45. package/dist/plans.d.ts +36 -6
  46. package/dist/plans.d.ts.map +1 -1
  47. package/dist/plans.js +49 -11
  48. package/dist/prompt-suggestions.d.ts +29 -0
  49. package/dist/prompt-suggestions.d.ts.map +1 -1
  50. package/dist/prompt-suggestions.js +45 -0
  51. package/dist/providers.d.ts +139 -0
  52. package/dist/providers.d.ts.map +1 -0
  53. package/dist/providers.js +286 -0
  54. package/dist/remote-control.d.ts +62 -0
  55. package/dist/remote-control.d.ts.map +1 -0
  56. package/dist/remote-control.js +78 -0
  57. package/dist/result-end.d.ts +39 -0
  58. package/dist/result-end.d.ts.map +1 -0
  59. package/dist/result-end.js +50 -0
  60. package/dist/serve.d.ts +7 -2
  61. package/dist/serve.d.ts.map +1 -1
  62. package/dist/serve.js +10 -5
  63. package/dist/session-config-ids.d.ts +1 -0
  64. package/dist/session-config-ids.d.ts.map +1 -1
  65. package/dist/session-config-ids.js +1 -0
  66. package/dist/session-config-options.d.ts +64 -0
  67. package/dist/session-config-options.d.ts.map +1 -0
  68. package/dist/session-config-options.js +162 -0
  69. package/dist/session-effort.d.ts +67 -0
  70. package/dist/session-effort.d.ts.map +1 -1
  71. package/dist/session-effort.js +98 -0
  72. package/dist/session-env.d.ts +22 -0
  73. package/dist/session-env.d.ts.map +1 -0
  74. package/dist/session-env.js +66 -0
  75. package/dist/session-fast-mode.d.ts +83 -0
  76. package/dist/session-fast-mode.d.ts.map +1 -0
  77. package/dist/session-fast-mode.js +142 -0
  78. package/dist/session-index/connection.d.ts +2 -5
  79. package/dist/session-index/connection.d.ts.map +1 -1
  80. package/dist/session-index/connection.js +3 -5
  81. package/dist/session-mode.d.ts +1 -0
  82. package/dist/session-mode.d.ts.map +1 -1
  83. package/dist/session-mode.js +1 -1
  84. package/dist/session-model.d.ts +41 -0
  85. package/dist/session-model.d.ts.map +1 -1
  86. package/dist/session-model.js +110 -45
  87. package/dist/session-notices.d.ts +44 -0
  88. package/dist/session-notices.d.ts.map +1 -1
  89. package/dist/session-notices.js +68 -0
  90. package/dist/session-titles.d.ts +34 -12
  91. package/dist/session-titles.d.ts.map +1 -1
  92. package/dist/session-titles.js +7 -6
  93. package/dist/session-usage.d.ts +125 -0
  94. package/dist/session-usage.d.ts.map +1 -0
  95. package/dist/session-usage.js +196 -0
  96. package/dist/streamed-text.d.ts +33 -0
  97. package/dist/streamed-text.d.ts.map +1 -0
  98. package/dist/streamed-text.js +71 -0
  99. package/dist/subagent-configuration.d.ts +32 -0
  100. package/dist/subagent-configuration.d.ts.map +1 -0
  101. package/dist/subagent-configuration.js +70 -0
  102. package/dist/subagent-replay.d.ts +18 -0
  103. package/dist/subagent-replay.d.ts.map +1 -1
  104. package/dist/subagent-replay.js +25 -15
  105. package/dist/tool-calls/client-capabilities.d.ts +8 -8
  106. package/dist/tool-calls/client-capabilities.js +4 -4
  107. package/dist/tool-calls/renderer.d.ts +4 -5
  108. package/dist/tool-calls/renderer.d.ts.map +1 -1
  109. package/dist/tool-calls/renderer.js +4 -5
  110. package/dist/turn-events.d.ts +6 -46
  111. package/dist/turn-events.d.ts.map +1 -1
  112. package/dist/v2/agent.d.ts +7 -11
  113. package/dist/v2/agent.d.ts.map +1 -1
  114. package/dist/v2/agent.js +751 -331
  115. package/dist/v2/air.d.ts +33 -0
  116. package/dist/v2/air.d.ts.map +1 -0
  117. package/dist/v2/air.js +29 -0
  118. package/dist/v2/auth.d.ts +97 -0
  119. package/dist/v2/auth.d.ts.map +1 -0
  120. package/dist/v2/auth.js +216 -0
  121. package/dist/v2/background.d.ts +27 -16
  122. package/dist/v2/background.d.ts.map +1 -1
  123. package/dist/v2/background.js +4 -32
  124. package/dist/v2/child-config.d.ts +55 -0
  125. package/dist/v2/child-config.d.ts.map +1 -0
  126. package/dist/v2/child-config.js +92 -0
  127. package/dist/v2/clear-context.d.ts +94 -0
  128. package/dist/v2/clear-context.d.ts.map +1 -0
  129. package/dist/v2/clear-context.js +176 -0
  130. package/dist/v2/commands.d.ts +46 -0
  131. package/dist/v2/commands.d.ts.map +1 -0
  132. package/dist/v2/commands.js +54 -0
  133. package/dist/v2/config.d.ts +187 -0
  134. package/dist/v2/config.d.ts.map +1 -0
  135. package/dist/v2/config.js +494 -0
  136. package/dist/v2/elicitation.d.ts +93 -0
  137. package/dist/v2/elicitation.d.ts.map +1 -0
  138. package/dist/v2/elicitation.js +160 -0
  139. package/dist/v2/file-changes.d.ts +61 -0
  140. package/dist/v2/file-changes.d.ts.map +1 -0
  141. package/dist/v2/file-changes.js +108 -0
  142. package/dist/v2/file-preview.d.ts +18 -0
  143. package/dist/v2/file-preview.d.ts.map +1 -0
  144. package/dist/v2/file-preview.js +29 -0
  145. package/dist/v2/initialize.d.ts +10 -24
  146. package/dist/v2/initialize.d.ts.map +1 -1
  147. package/dist/v2/initialize.js +4 -111
  148. package/dist/v2/outcome.d.ts +81 -0
  149. package/dist/v2/outcome.d.ts.map +1 -0
  150. package/dist/v2/outcome.js +165 -0
  151. package/dist/v2/permissions.d.ts +92 -0
  152. package/dist/v2/permissions.d.ts.map +1 -0
  153. package/dist/v2/permissions.js +162 -0
  154. package/dist/v2/prompt.d.ts +2 -42
  155. package/dist/v2/prompt.d.ts.map +1 -1
  156. package/dist/v2/prompt.js +2 -119
  157. package/dist/v2/remote-control.d.ts +41 -0
  158. package/dist/v2/remote-control.d.ts.map +1 -0
  159. package/dist/v2/remote-control.js +63 -0
  160. package/dist/v2/reports.d.ts +198 -0
  161. package/dist/v2/reports.d.ts.map +1 -0
  162. package/dist/v2/reports.js +487 -0
  163. package/dist/v2/restarts.d.ts +128 -0
  164. package/dist/v2/restarts.d.ts.map +1 -0
  165. package/dist/v2/restarts.js +348 -0
  166. package/dist/v2/session-requests.d.ts +20 -0
  167. package/dist/v2/session-requests.d.ts.map +1 -0
  168. package/dist/v2/session-requests.js +108 -0
  169. package/dist/v2/session-update.d.ts +2 -13
  170. package/dist/v2/session-update.d.ts.map +1 -1
  171. package/dist/v2/session-update.js +2 -22
  172. package/dist/v2/session.d.ts +340 -41
  173. package/dist/v2/session.d.ts.map +1 -1
  174. package/dist/v2/session.js +1223 -141
  175. package/dist/v2/setup.d.ts +49 -0
  176. package/dist/v2/setup.d.ts.map +1 -0
  177. package/dist/v2/setup.js +62 -0
  178. package/dist/v2/stopped-work.d.ts +123 -0
  179. package/dist/v2/stopped-work.d.ts.map +1 -0
  180. package/dist/v2/stopped-work.js +210 -0
  181. package/dist/v2/stream.d.ts +228 -0
  182. package/dist/v2/stream.d.ts.map +1 -0
  183. package/dist/v2/stream.js +506 -0
  184. package/dist/v2/subagent-replay.d.ts +115 -0
  185. package/dist/v2/subagent-replay.d.ts.map +1 -0
  186. package/dist/v2/subagent-replay.js +479 -0
  187. package/dist/v2/subscription-guard.d.ts +60 -0
  188. package/dist/v2/subscription-guard.d.ts.map +1 -0
  189. package/dist/v2/subscription-guard.js +84 -0
  190. package/dist/v2/tasks.d.ts +492 -0
  191. package/dist/v2/tasks.d.ts.map +1 -0
  192. package/dist/v2/tasks.js +1728 -0
  193. package/dist/v2/terminal.d.ts.map +1 -1
  194. package/dist/v2/terminal.js +6 -1
  195. package/dist/v2/tool-call.d.ts +3 -2
  196. package/dist/v2/tool-call.d.ts.map +1 -1
  197. package/dist/v2/update-translator.d.ts +36 -0
  198. package/dist/v2/update-translator.d.ts.map +1 -0
  199. package/dist/v2/update-translator.js +80 -0
  200. package/dist/workflow-progress.d.ts +23 -0
  201. package/dist/workflow-progress.d.ts.map +1 -1
  202. package/dist/workflow-progress.js +31 -8
  203. package/package.json +1 -1
  204. package/dist/v2/permission.d.ts +0 -28
  205. package/dist/v2/permission.d.ts.map +0 -1
  206. package/dist/v2/permission.js +0 -41
@@ -1,74 +1,10 @@
1
- /**
2
- * The background work of a session: the work that Claude Code keeps running
3
- * independently of the session's foreground work, which ACP v2 lists on every
4
- * `state_update` of the session as `background` (the v2 prompt lifecycle,
5
- * "Background work").
6
- *
7
- * The lists are built from Claude Code's live background task set
8
- * (`background_tasks_changed`). Claude Code marks `ambient` its own
9
- * housekeeping and every live-update watcher; those are left out, except a
10
- * task that a tool call started, such as a `Monitor` call's. The root session and each
11
- * announced subagent session (the subagents RFD form) has its own list. Each
12
- * task is listed once, in the list of the session that runs it:
13
- *
14
- * - A command that went to the background: its display terminal, from the
15
- * Bash tool result until its task ends (`Session.backgroundTerminals`).
16
- * - A detached subagent: its child session, in its parent's list, while it
17
- * works, and while it is idle with background work of its own.
18
- * - A task that a tool call started, such as a `Monitor`, a `Workflow` or a
19
- * backgrounded MCP call: that tool call, kept `in_progress` (or `paused`)
20
- * from its tool result until its task ends (`Session.backgroundToolCalls`).
21
- * - Any other task, once its `task_started` came and the tool call that
22
- * started it, if any, returned: a tool call that the adapter starts for
23
- * it (see `SessionBackgroundWork.adoptTasks`). For example, a task that a
24
- * hook started, or one whose tool call ended before the task joined the
25
- * level.
26
- *
27
- * Only a session whose interrupt spares background tasks reports its lists
28
- * (`Session.reportsBackground`): `session/cancel` must leave listed work
29
- * running.
30
- */
31
- import { RequestError } from "@agentclientprotocol/sdk/unstable";
32
- import { V2_CANCELLED, V2_PAUSED } from "./tool-calls/renderer.js";
33
- import { BackgroundOutputTail } from "./background-output.js";
34
- import { workflowSnapshotText } from "./workflow-progress.js";
35
- import { textContent } from "./tool-calls/content.js";
36
- /** The most returned tool calls that {@link SessionBackgroundWork} remembers. */
37
- const MAX_RETURNED_CALLS = 1024;
38
- /** The tools whose structured result names the task that the call started. */
39
- const TASK_TOOLS = new Set(["Monitor", "Workflow"]);
40
- /**
41
- * The background work of one root session, and of its subagent sessions: the
42
- * terminals and tool calls of the tasks that run in the background, and what
43
- * the client is told of them.
44
- *
45
- * Terminals are kept for every client that renders them, as before the
46
- * background lists. The rest is kept only when `reported`.
47
- */
1
+ /** The terminals of the commands that one root session, and its subagents, run in the background. */
48
2
  export class SessionBackgroundWork {
49
3
  sessionId;
50
- reported;
51
- /** Claude Code's live background task set, from its last `background_tasks_changed`. */
52
- level = new Map();
53
4
  /** The terminals of the commands that went to the background, by task id. */
54
5
  terminals = new Map();
55
- /** The tool calls whose tasks went on in the background, by task id. */
56
- toolCalls = new Map();
57
- /**
58
- * The tool calls that returned, oldest first. A task that a call started
59
- * is part of that call until it returns, and the foreground work waits on
60
- * it. The task's `task_started` can come after the call returned. Bounded
61
- * by {@link MAX_RETURNED_CALLS}: a task joins the level around the time its
62
- * call returns.
63
- */
64
- returned = new Set();
65
- /**
66
- * `reported`: whether the client gets the lists. Only when Claude Code's
67
- * interrupt spares background tasks, as `perTaskStopAffordance` makes it.
68
- */
69
- constructor(sessionId, reported) {
6
+ constructor(sessionId) {
70
7
  this.sessionId = sessionId;
71
- this.reported = reported;
72
8
  }
73
9
  /**
74
10
  * Keeps the display terminal of the command `taskId` running after its Bash
@@ -78,395 +14,17 @@ export class SessionBackgroundWork {
78
14
  this.terminals.set(taskId, terminal);
79
15
  }
80
16
  /**
81
- * Reads what a tool result message tells of the background tasks:
82
- *
83
- * - The returned calls no longer hold the tasks that they started.
84
- * - Each call whose task goes on in the background is registered: a
85
- * `Monitor` or `Workflow` call, whose structured result names its task,
86
- * or a call that a live task names as its tool use, such as a
87
- * backgrounded MCP call. The task must be in the level: one that ended
88
- * already leaves its call as it is. Claude Code marks every live-update
89
- * watcher `ambient`, including the task of a `Monitor` call; a call
90
- * started it, so it is work the client can see and stop, and is
91
- * registered all the same. Ambient tasks without a call of their own,
92
- * such as watchers Claude Code starts by itself, are never registered.
93
- *
94
- * Returns the ids of the registered calls, whose result then reports
95
- * `in_progress` (see `withRunningToolCall`).
17
+ * The task `taskId` ended: exits its command's terminal, with no exit code.
18
+ * Claude Code reports no exit code for a command.
96
19
  */
97
- toolResults(owner, content, toolUseResult, toolUses, parentToolUseId) {
98
- const registered = new Set();
99
- if (!this.reported || !Array.isArray(content))
100
- return registered;
101
- const results = content.filter((block) => typeof block === "object" &&
102
- block !== null &&
103
- block.type === "tool_result" &&
104
- typeof block.tool_use_id === "string");
105
- for (const { tool_use_id: toolCallId } of results) {
106
- this.returned.add(toolCallId);
107
- if (this.returned.size > MAX_RETURNED_CALLS) {
108
- this.returned.delete(this.returned.values().next().value);
109
- }
110
- }
111
- const succeeded = results.filter((block) => block.is_error !== true);
112
- const structuredTaskId = succeeded.length === 1 &&
113
- typeof toolUseResult === "object" &&
114
- toolUseResult !== null &&
115
- typeof toolUseResult.taskId === "string"
116
- ? toolUseResult.taskId
117
- : undefined;
118
- for (const { tool_use_id: toolCallId } of succeeded) {
119
- const toolUse = toolUses[toolCallId];
120
- if (!toolUse)
121
- continue;
122
- const taskId = (TASK_TOOLS.has(toolUse.name) ? structuredTaskId : undefined) ??
123
- [...owner.liveBackgroundTasks].find(([, task]) => task.parentToolUseId === toolCallId && !task.isSubagent)?.[0];
124
- const task = taskId === undefined ? undefined : this.level.get(taskId);
125
- if (!task || task.taskType === "local_bash" || task.taskType === "local_agent") {
126
- continue;
127
- }
128
- this.toolCalls.set(taskId, {
129
- toolCallId,
130
- toolUse,
131
- ...(parentToolUseId ? { parentToolUseId } : {}),
132
- });
133
- registered.add(toolCallId);
134
- }
135
- return registered;
136
- }
137
- /**
138
- * Starts reading the output of the background command `taskId` into its
139
- * terminal, when the client gets the lists and the Bash result named the
140
- * command's output file. `send` sends an update of the terminal's tool
141
- * call, routed as the call's other updates. Called once the Bash result's
142
- * own updates are sent: the first output replaces the placeholder that they
143
- * gave the terminal.
144
- */
145
- followOutput(taskId, send) {
20
+ async taskEnded(taskId, send) {
146
21
  const terminal = this.terminals.get(taskId);
147
- if (!this.reported || !terminal?.outputFilePath || terminal.output)
22
+ if (!terminal)
148
23
  return;
149
- terminal.output = new BackgroundOutputTail(terminal.outputFilePath, (output) => send(terminalOutputUpdate(this.sessionId, terminal, output)));
150
- }
151
- /**
152
- * The task `taskId` ended. Reads the rest of its command's output, then
153
- * exits its terminal, and gives a tool call whose task it was its final
154
- * status: `cancelled` for a task that Claude Code stopped, and `completed`
155
- * for one that ended without saying how, such as one that the level
156
- * dropped: it no longer runs, and reported no failure. Claude Code reports
157
- * no exit code for a command, and `completed` does not mean 0: Claude Code
158
- * accepts some non-zero codes as a success, such as grep's 1.
159
- */
160
- async taskEnded(taskId, end, send) {
161
- const terminal = this.terminals.get(taskId);
162
- if (terminal) {
163
- await terminal.output?.finish();
164
- this.terminals.delete(taskId);
165
- await send(terminalExit(this.sessionId, terminal));
166
- }
167
- const toolCall = this.toolCalls.get(taskId);
168
- if (toolCall) {
169
- this.toolCalls.delete(taskId);
170
- await send(toolCallUpdate(this.sessionId, toolCall, {
171
- status: end === "stopped" ? V2_CANCELLED : end === "failed" ? "failed" : "completed",
172
- }));
173
- }
174
- }
175
- /**
176
- * The update that reports the background tool call of the task `taskId` as
177
- * `paused`, or as `in_progress` again, when `paused` changes it. Claude Code
178
- * pauses a workflow this way.
179
- */
180
- taskPaused(taskId, paused) {
181
- const toolCall = this.toolCalls.get(taskId);
182
- if (!toolCall || (toolCall.paused ?? false) === paused)
183
- return undefined;
184
- toolCall.paused = paused;
185
- return toolCallUpdate(this.sessionId, toolCall, { status: paused ? V2_PAUSED : "in_progress" });
186
- }
187
- /**
188
- * Updates an existing workflow card without changing its work state. A
189
- * report without `workflow` keeps the last phase and agent list.
190
- */
191
- taskProgress(taskId, progress) {
192
- const task = this.level.get(taskId);
193
- if (!task || task.taskType !== "local_workflow")
194
- return undefined;
195
- const previous = workflowProgress(task.progress);
196
- task.progress = { ...task.progress, ...progress };
197
- const current = workflowProgress(task.progress);
198
- if (!current || JSON.stringify(previous) === JSON.stringify(current))
199
- return undefined;
200
- const toolCall = this.toolCalls.get(taskId);
201
- return toolCall ? toolCallUpdate(this.sessionId, toolCall, current) : undefined;
202
- }
203
- /**
204
- * The latest progress of the workflow calls in `toolCallIds`.
205
- *
206
- * A task can report progress before its launch tool returns. Those fields
207
- * wait in the live task level and are sent after the launch result.
208
- */
209
- toolCallProgress(toolCallIds) {
210
- return [...this.toolCalls].flatMap(([taskId, toolCall]) => {
211
- if (!toolCallIds.has(toolCall.toolCallId))
212
- return [];
213
- const progress = workflowProgress(this.level.get(taskId)?.progress);
214
- return progress ? [toolCallUpdate(this.sessionId, toolCall, progress)] : [];
215
- });
216
- }
217
- /**
218
- * Takes Claude Code's new live background task set. The terminals and tool
219
- * calls whose tasks it no longer holds end first, before a list drops them,
220
- * as v2 requires. A terminal or tool call is registered at its tool result,
221
- * after its task joined the level, so a later level without the task means
222
- * that it ended. Claude Code usually sends a task's end before that level,
223
- * which ends them first, but the SDK does not promise that order.
224
- */
225
- async levelChanged(tasks, send) {
226
- if (!this.reported)
227
- return;
228
- const level = new Map(tasks.map((task) => [
229
- task.task_id,
230
- {
231
- ambient: task.ambient === true,
232
- taskType: task.task_type,
233
- description: task.description,
234
- ...(task.parent_task_id !== undefined ? { parentTaskId: task.parent_task_id } : {}),
235
- progress: this.level.get(task.task_id)?.progress,
236
- },
237
- ]));
238
- for (const taskId of [...this.terminals.keys(), ...this.toolCalls.keys()]) {
239
- if (!level.has(taskId))
240
- await this.taskEnded(taskId, undefined, send);
241
- }
242
- this.level = level;
243
- }
244
- /**
245
- * The query closed: Claude Code's background tasks end with its process.
246
- * Stops reading output, and returns the updates that exit the root
247
- * session's terminals and cancel its tool calls. The level empties, so the
248
- * next lists are empty. A subagent's command or tool call is left as it
249
- * was: it is on the child's stream, which the closed query's routing owned.
250
- */
251
- queryClosed() {
252
- for (const terminal of this.terminals.values())
253
- terminal.output?.stop();
254
- if (!this.reported)
255
- return [];
256
- const updates = [];
257
- for (const [taskId, terminal] of this.terminals) {
258
- if (terminal.parentToolUseId)
259
- continue;
260
- this.terminals.delete(taskId);
261
- updates.push(terminalExit(this.sessionId, terminal));
262
- }
263
- for (const [taskId, toolCall] of this.toolCalls) {
264
- if (toolCall.parentToolUseId)
265
- continue;
266
- this.toolCalls.delete(taskId);
267
- updates.push(toolCallUpdate(this.sessionId, toolCall, { status: V2_CANCELLED }));
268
- }
269
- this.level = new Map();
270
- this.returned.clear();
271
- return updates;
272
- }
273
- /**
274
- * Starts a tool call for each live task that no terminal or tool call
275
- * stands for yet, and returns the `tool_call`s to send: v2 lists background work only by an entity
276
- * the client knows. Such a task is one that no tool call started, such as
277
- * one a hook started, or one whose tool call returned, with its final
278
- * status, before the task started. The call has the task's description as
279
- * its title, is `in_progress`, and ends with the task (see `taskEnded`). A
280
- * task that an announced subagent session runs gets its call on that
281
- * session's stream. Ambient tasks are housekeeping and get no call.
282
- *
283
- * The agent sends them before each list it publishes, so the call comes
284
- * before the first list that names it, as v2 requires.
285
- */
286
- adoptTasks(owner) {
287
- if (!this.reported)
288
- return [];
289
- const started = [];
290
- const children = new Map([...(owner.nativeSubagentsByTaskId ?? [])].filter(([, child]) => child.announced));
291
- for (const [taskId, task] of this.level) {
292
- if (task.ambient || this.toolCalls.has(taskId) || this.terminals.has(taskId))
293
- continue;
294
- // A command without a terminal yet is one that foreground work waits on.
295
- // A subagent is listed as its session.
296
- if (task.taskType === "local_bash" || task.taskType === "local_agent")
297
- continue;
298
- // A task joins the level before its `task_started`, and before the tool
299
- // call that starts it returns. Until both, the task is unknown or part
300
- // of that tool call.
301
- const live = owner.liveBackgroundTasks.get(taskId);
302
- if (!live || (live.parentToolUseId && !this.returned.has(live.parentToolUseId)))
303
- continue;
304
- const parent = task.parentTaskId ? children.get(task.parentTaskId) : undefined;
305
- const toolCall = {
306
- toolCallId: adoptedToolCallId(taskId),
307
- title: task.description,
308
- ...(parent?.parentToolUseId ? { parentToolUseId: parent.parentToolUseId } : {}),
309
- };
310
- this.toolCalls.set(taskId, toolCall);
311
- started.push(adoptedToolCall(this.sessionId, toolCall));
312
- }
313
- return started;
314
- }
315
- /**
316
- * The `background` list of the root session and of each of its announced
317
- * subagent sessions, with what their repeated states need, deeper sessions
318
- * first and the root last: a child's own list goes out before its parent's
319
- * list drops it. Each list is empty while the level has not been reported:
320
- * Claude Code sends none before the first background task starts.
321
- */
322
- reports(owner, rootState) {
323
- const children = [...(owner.nativeSubagentsByTaskId ?? [])].filter(([, child]) => child.announced);
324
- const childByToolUse = new Map(children.flatMap(([, child]) => child.parentToolUseId ? [[child.parentToolUseId, child]] : []));
325
- const lists = new Map([
326
- [this.sessionId, []],
327
- ...children.map(([, child]) => [child.sessionId, []]),
328
- ]);
329
- // A subagent's command or tool call runs on the child's stream.
330
- const ownerOf = (parentToolUseId) => parentToolUseId ? childByToolUse.get(parentToolUseId)?.sessionId : this.sessionId;
331
- for (const [taskId, task] of this.level) {
332
- // A registered call's task is listed even when ambient, as a `Monitor`
333
- // call's is (see `toolResults`).
334
- const toolCall = this.toolCalls.get(taskId);
335
- if (toolCall) {
336
- const session = ownerOf(toolCall.parentToolUseId);
337
- if (session)
338
- lists.get(session).push({ type: "tool_call", toolCallId: toolCall.toolCallId });
339
- continue;
340
- }
341
- if (task.ambient)
342
- continue;
343
- const terminal = this.terminals.get(taskId);
344
- if (terminal) {
345
- const session = ownerOf(terminal.parentToolUseId);
346
- if (session)
347
- lists.get(session).push({ type: "terminal", terminalId: terminal.toolCallId });
348
- }
349
- // Any other task is listed by the tool call that `adoptTasks` starts
350
- // for it, or is not background work. A subagent is listed below, as
351
- // its session.
352
- }
353
- // A child is listed in its parent's list while it works in the background,
354
- // and while it is idle with background work of its own. Deeper children
355
- // first, so a child's list is whole before its parent's reads it.
356
- const sessions = new Map(children.map(([, child]) => [child.sessionId, child]));
357
- const depth = (child) => {
358
- const parent = sessions.get(child.parentSessionId);
359
- return parent ? depth(parent) + 1 : 0;
360
- };
361
- const ordered = children.sort(([, a], [, b]) => depth(b) - depth(a));
362
- for (const [taskId, child] of ordered) {
363
- const task = this.level.get(taskId);
364
- const working = child.workState !== undefined &&
365
- child.workState !== "idle" &&
366
- task !== undefined &&
367
- !task.ambient;
368
- if (working || lists.get(child.sessionId).length > 0) {
369
- lists.get(child.parentSessionId)?.push({ type: "subagent", sessionId: child.sessionId });
370
- }
371
- }
372
- return [
373
- ...ordered.map(([, child]) => ({
374
- sessionId: child.sessionId,
375
- items: lists.get(child.sessionId),
376
- state: workStateName(child.workState),
377
- parentSessionId: child.parentSessionId,
378
- })),
379
- { sessionId: this.sessionId, items: lists.get(this.sessionId), state: rootState },
380
- ];
381
- }
382
- /**
383
- * The current state of each background tool call in `toolCallIds`: the
384
- * call as `renderer` shows its tool use, with its status now (see
385
- * `ClaudeAcpAgent.publishBackgroundToolCalls`).
386
- */
387
- toolCallStates(toolCallIds, renderer, cwd) {
388
- return [...this.toolCalls]
389
- .filter(([, toolCall]) => toolCallIds.includes(toolCall.toolCallId))
390
- .map(([taskId, toolCall]) => {
391
- const update = toolCall.toolUse
392
- ? renderer.toolCall({ id: toolCall.toolCallId, ...toolCall.toolUse }, { cwd })
393
- : adoptedToolCall(this.sessionId, toolCall).update;
394
- const status = toolCall.paused ? V2_PAUSED : "in_progress";
395
- return {
396
- sessionId: this.sessionId,
397
- update: {
398
- ...update,
399
- ...workflowProgress(this.level.get(taskId)?.progress),
400
- status,
401
- },
402
- };
403
- });
404
- }
405
- /**
406
- * The task of the terminal or tool call `target` that the session
407
- * `sessionId` lists, or undefined when it lists no such item.
408
- */
409
- listedTask(owner, sessionId, target) {
410
- if (!this.reported)
411
- return undefined;
412
- const listed = this.reports(owner, "idle")
413
- .find((report) => report.sessionId === sessionId)
414
- ?.items.some((item) => "terminalId" in target
415
- ? item.type === "terminal" && item.terminalId === target.terminalId
416
- : item.type === "tool_call" && item.toolCallId === target.toolCallId);
417
- if (!listed)
418
- return undefined;
419
- const id = "terminalId" in target ? target.terminalId : target.toolCallId;
420
- const entries = "terminalId" in target ? this.terminals : this.toolCalls;
421
- return [...entries].find(([, entry]) => entry.toolCallId === id)?.[0];
24
+ this.terminals.delete(taskId);
25
+ await send(terminalExit(this.sessionId, terminal));
422
26
  }
423
27
  }
424
- /**
425
- * Stops the task of a terminal or tool call that the session `sessionId`
426
- * lists (v2 `terminal/cancel` and `tool_call/cancel`). `sessions` are the
427
- * root sessions: a subagent session's list is built with its root's. The
428
- * terminal exits, or the tool call gets its final status, when Claude Code
429
- * reports the task stopped.
430
- */
431
- export async function cancelBackgroundWork(sessions, sessionId, target) {
432
- const notCancellable = () => "terminalId" in target
433
- ? RequestError.invalidParams({ sessionId, terminalId: target.terminalId }, `Terminal ${target.terminalId} is not a command running in the background, so it cannot be cancelled.`)
434
- : RequestError.invalidParams({ sessionId, toolCallId: target.toolCallId }, `Tool call ${target.toolCallId} is not running in the background, so it cannot be cancelled.`);
435
- for (const session of sessions) {
436
- const taskId = session.background?.listedTask(session, sessionId, target);
437
- if (taskId === undefined)
438
- continue;
439
- try {
440
- await session.query.stopTask(taskId);
441
- }
442
- catch (error) {
443
- // The task ended meanwhile: it has ended on the client too, or is about to.
444
- if (session.background?.listedTask(session, sessionId, target) === undefined) {
445
- throw notCancellable();
446
- }
447
- throw error;
448
- }
449
- return;
450
- }
451
- throw notCancellable();
452
- }
453
- /** The update that gives the terminal of `terminal` the text `output`. */
454
- function terminalOutputUpdate(sessionId, terminal, output) {
455
- const data = { terminal_id: terminal.toolCallId, data: output.text };
456
- return {
457
- sessionId,
458
- update: {
459
- sessionUpdate: "tool_call_update",
460
- toolCallId: terminal.toolCallId,
461
- _meta: {
462
- ...(terminal.parentToolUseId
463
- ? { claudeCode: { parentToolUseId: terminal.parentToolUseId } }
464
- : {}),
465
- ...(output.replaces ? { terminal_output: data } : { terminal_output_delta: data }),
466
- },
467
- },
468
- };
469
- }
470
28
  /** The update that exits the terminal of `terminal`, with no exit code. */
471
29
  function terminalExit(sessionId, terminal) {
472
30
  return {
@@ -483,111 +41,3 @@ function terminalExit(sessionId, terminal) {
483
41
  },
484
42
  };
485
43
  }
486
- function toolCallUpdate(sessionId, toolCall, fields) {
487
- return {
488
- sessionId,
489
- update: {
490
- sessionUpdate: "tool_call_update",
491
- toolCallId: toolCall.toolCallId,
492
- ...fields,
493
- ...(toolCall.parentToolUseId
494
- ? { _meta: { claudeCode: { parentToolUseId: toolCall.parentToolUseId } } }
495
- : {}),
496
- },
497
- };
498
- }
499
- /**
500
- * The id of the tool call that the adapter starts for the task `taskId`.
501
- * Claude Code's tool use ids start with `toolu_`, so it names no other call.
502
- */
503
- function adoptedToolCallId(taskId) {
504
- return `task_${taskId}`;
505
- }
506
- /** The `tool_call` that the adapter starts for a task (see `SessionBackgroundWork.adoptTasks`). */
507
- function adoptedToolCall(sessionId, toolCall) {
508
- return {
509
- sessionId,
510
- update: {
511
- sessionUpdate: "tool_call",
512
- toolCallId: toolCall.toolCallId,
513
- title: toolCall.title ?? "Background task",
514
- kind: "other",
515
- status: toolCall.paused ? V2_PAUSED : "in_progress",
516
- ...(toolCall.parentToolUseId
517
- ? { _meta: { claudeCode: { parentToolUseId: toolCall.parentToolUseId } } }
518
- : {}),
519
- },
520
- };
521
- }
522
- /** The latest workflow activity, rendered as one replaceable tool-card body. */
523
- function workflowProgress(progress) {
524
- if (!progress || Object.keys(progress).length === 0)
525
- return undefined;
526
- const activity = progress.description ?? progress.summary;
527
- const usage = progress.usage;
528
- const text = [
529
- progress.summary ?? progress.description,
530
- progress.lastToolName ? `Last activity: ${progress.lastToolName}` : undefined,
531
- usage
532
- ? `${usage.totalTokens.toLocaleString("en-US")} tokens · ${usage.toolUses.toLocaleString("en-US")} tool calls · ${Math.floor(usage.durationMs / 1000)}s`
533
- : undefined,
534
- progress.workflow ? workflowSnapshotText(progress.workflow) : undefined,
535
- ]
536
- .filter((part) => part !== undefined)
537
- .join("\n\n");
538
- return {
539
- title: activity ? `Workflow: ${activity}` : "Workflow",
540
- content: [textContent(text)],
541
- };
542
- }
543
- /**
544
- * Publishes the lists of each session that reports them, each time one
545
- * changes. The sink sends them to the client synchronously, so a list follows
546
- * the updates sent before it.
547
- */
548
- export class BackgroundWorkReporter {
549
- sink;
550
- /** The list last published for each session, as JSON, and the root session it is built with. */
551
- published = new Map();
552
- constructor(sink) {
553
- this.sink = sink;
554
- }
555
- /** Whether the lists are reported at all. */
556
- get enabled() {
557
- return this.sink !== undefined;
558
- }
559
- /**
560
- * Publishes each list of the root session `rootSessionId` that changed. The
561
- * first call for a session publishes its list, also when it is empty.
562
- * `rootState` is the root session's state now.
563
- */
564
- sync(rootSessionId, session, rootState) {
565
- if (!this.sink || !session.background?.reported)
566
- return;
567
- for (const report of session.background.reports(session, rootState)) {
568
- const json = JSON.stringify(report.items);
569
- if (this.published.get(report.sessionId)?.json === json)
570
- continue;
571
- this.published.set(report.sessionId, { json, root: rootSessionId });
572
- this.sink.changed(report);
573
- }
574
- }
575
- /** The root session `rootSessionId` ended, and its subagent sessions with it. */
576
- forget(rootSessionId) {
577
- for (const [sessionId, { root }] of this.published) {
578
- if (root !== rootSessionId)
579
- continue;
580
- this.published.delete(sessionId);
581
- this.sink?.forget(sessionId);
582
- }
583
- }
584
- }
585
- /** A child's work state, when it is one that v2 names. */
586
- function workStateName(state) {
587
- return state === "idle" ||
588
- state === "running" ||
589
- state === "requires_action" ||
590
- state === "unknown"
591
- ? state
592
- : undefined;
593
- }
@@ -38,4 +38,11 @@ export declare function clientSystemPrompt(systemPrompt: SystemPrompt | null | u
38
38
  * client text in both modes.
39
39
  */
40
40
  export declare function sdkSystemPrompt(prompt: ClientSystemPrompt, customInstructions: string | undefined): NonNullable<Options["systemPrompt"]>;
41
+ /**
42
+ * The SDK `systemPrompt` of a session: the spec's `systemPrompt`
43
+ * (`clientPrompt`), else the `_meta.systemPrompt` extension (`metaPrompt`), a
44
+ * string that replaces the preset or an object of preset options, else the
45
+ * Claude Code preset. `customInstructions` are appended to the preset.
46
+ */
47
+ export declare function sessionSystemPrompt(clientPrompt: ClientSystemPrompt | undefined, metaPrompt: unknown, customInstructions?: string): NonNullable<Options["systemPrompt"]>;
41
48
  //# sourceMappingURL=client-system-prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-system-prompt.d.ts","sourceRoot":"","sources":["../src/client-system-prompt.ts"],"names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SAAS,GACrC,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAMtC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,kBAAkB,GAAG,SAAS,EAC5C,UAAU,EAAE,OAAO,EACnB,kBAAkB,CAAC,EAAE,MAAM,GAC1B,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAetC"}
@@ -38,3 +38,27 @@ export function sdkSystemPrompt(prompt, customInstructions) {
38
38
  ? { type: "preset", preset: "claude_code", append: text }
39
39
  : { type: "preset", preset: "claude_code" };
40
40
  }
41
+ /**
42
+ * The SDK `systemPrompt` of a session: the spec's `systemPrompt`
43
+ * (`clientPrompt`), else the `_meta.systemPrompt` extension (`metaPrompt`), a
44
+ * string that replaces the preset or an object of preset options, else the
45
+ * Claude Code preset. `customInstructions` are appended to the preset.
46
+ */
47
+ export function sessionSystemPrompt(clientPrompt, metaPrompt, customInstructions) {
48
+ if (clientPrompt)
49
+ return sdkSystemPrompt(clientPrompt, customInstructions);
50
+ if (typeof metaPrompt === "string" && metaPrompt)
51
+ return metaPrompt;
52
+ if (typeof metaPrompt === "object" && metaPrompt !== null && !Array.isArray(metaPrompt)) {
53
+ // Forward all preset options (append, excludeDynamicSections, and
54
+ // anything the SDK adds later) while locking type/preset.
55
+ return {
56
+ ...metaPrompt,
57
+ type: "preset",
58
+ preset: "claude_code",
59
+ };
60
+ }
61
+ return customInstructions === undefined
62
+ ? { type: "preset", preset: "claude_code" }
63
+ : { type: "preset", preset: "claude_code", append: customInstructions };
64
+ }
@@ -36,6 +36,26 @@ export declare function compactionSummaryText(raw: string): string | undefined;
36
36
  /** True for the post-compaction user message Claude Code persists (and
37
37
  * `getSessionMessages` returns) with the summary of the dropped history. */
38
38
  export declare function isCompactSummaryMessage(message: unknown): boolean;
39
+ /**
40
+ * Replays the compact summary message `message` (see
41
+ * {@link isCompactSummaryMessage}) of the root conversation as one completed
42
+ * `compaction_update` at its transcript position, keyed by the message's
43
+ * uuid. Returns false, and sends nothing, for any other message.
44
+ *
45
+ * The boundary's own system record comes back from `getSessionMessages`
46
+ * without its metadata, so the summary message is the one durable marker.
47
+ * Its uuid differs from the live id (the `compacting` status uuid): replay
48
+ * is terminal-first by the RFD, and no client merges a replay into a live
49
+ * entity store. A summary whose framing is unrecognized is still this
50
+ * compaction, without summary text.
51
+ */
52
+ export declare function replayCompactSummary(message: {
53
+ uuid?: unknown;
54
+ message?: unknown;
55
+ }, sendUpdate: SendUpdate, options: {
56
+ sessionId: string;
57
+ airClient?: boolean;
58
+ }): Promise<boolean>;
39
59
  /**
40
60
  * Translates Claude's compaction signals into one idempotent ACP lifecycle.
41
61
  *
@@ -1 +1 @@
1
- {"version":3,"file":"context-compaction.d.ts","sourceRoot":"","sources":["../src/context-compaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC5F,OAAO,EACL,yBAAyB,EAG1B,MAAM,8BAA8B,CAAC;AAGtC,KAAK,gBAAgB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAG/C;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAAG,WAAW,GAAG,mBAAmB,CAAC;AAevE,KAAK,UAAU,GAAG,CAAC,YAAY,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvE,MAAM,MAAM,iCAAiC,GAAG;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC;gCAC4B;IAC5B,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACrD,0FAA0F;IAC1F,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,wBAAgB,+BAA+B,CAAC,YAAY,CAAC,EAAE,kBAAkB,GAAG,IAAI,GAAG,OAAO,CAGjG;AAyBD;;;;;;;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