@salesforce/sfdx-agent-harness-claude 0.15.0 → 0.17.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to `@salesforce/sfdx-agent-harness-claude` are documented in this file.
4
4
  Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
+ ## [0.17.0] - 2026-06-15
7
+
8
+ ### Fixes
9
+ - **harness-claude,harness-mastra,agent-sdk**: idempotent settle + quiet dispose (#589) ([#598](https://github.com/forcedotcom/agentic-dx/pull/598))
10
+
11
+ ## [0.16.0] - 2026-06-12
12
+
13
+ ### Features
14
+ - **agent-sdk,harness-mastra,harness-claude**: add tool-call-delta ChatEvent for streaming tool-call args @W-22965697@ ([#597](https://github.com/forcedotcom/agentic-dx/pull/597))
15
+ - **agent-sdk,harness-mastra,harness-claude**: add tool-progress ChatEvent variant @W-22951127@ ([#594](https://github.com/forcedotcom/agentic-dx/pull/594))
16
+ - **harness-claude**: map SDKThinkingTokensMessage to UsageMetadata.reasoningTokens ([#595](https://github.com/forcedotcom/agentic-dx/pull/595))
17
+
18
+ ### Fixes
19
+ - **harness-claude**: map SDKResultSuccess.is_error to ChatEvent.error ([#593](https://github.com/forcedotcom/agentic-dx/pull/593))
20
+ - **harness-claude**: map api_retry and mirror_error SDKMessages to ChatEvent.error @W-22930092 ([#585](https://github.com/forcedotcom/agentic-dx/pull/585))
21
+
6
22
  ## [0.15.0] - 2026-06-11
7
23
 
8
24
  ### Fixes
@@ -59,12 +59,48 @@ export declare class ClaudeApprovalCoordinator {
59
59
  /** ToolCallIds the consumer has settled. Rejects double-settle. */
60
60
  private readonly consumerSettled;
61
61
  /**
62
- * ToolCallIds the coordinator auto-resolved (timeout / abort / dispose).
63
- * A subsequent settle for these ids rejects with "already auto-resolved".
62
+ * ToolCallIds the coordinator auto-resolved (timeout / abort / dispose
63
+ * / pump-error). A subsequent settle for these ids is a silent no-op
64
+ * via the idempotent-settle contract (issue #589) — the lost race is
65
+ * unactionable from the consumer's side, and the methods are
66
+ * void-typed so there's no return value to communicate the no-op.
64
67
  */
65
68
  private readonly settledByCoordinator;
69
+ /**
70
+ * ToolCallIds the consumer has settled via {@link submitToolResult},
71
+ * or that the coordinator drained at teardown time. Used as the
72
+ * idempotent-settle ledger for the consumer-tool path (parallel to
73
+ * `consumerSettled` + `settledByCoordinator` on the approve/decline
74
+ * path). A subsequent `submitToolResult` for these ids is a silent
75
+ * no-op rather than throwing `TOOL_CALL_NOT_FOUND` (issue #589).
76
+ */
77
+ private readonly consumerToolSettled;
66
78
  /** Args from the adapter's `tool-call` ChatEvent, keyed by `toolCallId`. */
67
79
  private readonly toolCallArgs;
80
+ /**
81
+ * `toolCallId` of the MCP tool call currently in-flight, or `null` when
82
+ * no MCP tool is awaiting a result. Tracked at `route()` time: set when
83
+ * an MCP-namespaced `tool-call` arrives, cleared on the matching
84
+ * `tool-result`.
85
+ *
86
+ * Used by {@link emitMcpProgress} to attribute incoming
87
+ * `notifications/progress` (delivered via the host-side MCP client's
88
+ * `onprogress` callback in `claude-mcp-bridge.ts`) to the right
89
+ * `toolCallId` for the `tool-progress` ChatEvent.
90
+ *
91
+ * The Claude Agent SDK serializes tool execution per turn (see
92
+ * ARCHITECTURE.md → "Tool Approval"), so at most one MCP tool call is
93
+ * in flight at any time — matching this scalar shape.
94
+ */
95
+ private currentMcpToolCallId;
96
+ /**
97
+ * Captures the (Claude-namespaced) tool name for each `toolCallId`
98
+ * routed through `route()`. Used by {@link emitMcpProgress} to stamp
99
+ * `toolName` on the `tool-progress` ChatEvent so AG-UI Activity
100
+ * translators don't have to consult the originating `tool-call` event
101
+ * to route progress chunks.
102
+ */
103
+ private readonly toolNameForCallId;
68
104
  /**
69
105
  * Consumer-tool: tool-call events pump has seen but no parker invocation
70
106
  * for yet. FIFO list per tool name. Empirically the Claude subprocess
@@ -103,6 +139,24 @@ export declare class ClaudeApprovalCoordinator {
103
139
  private tornDown;
104
140
  constructor(opts: ClaudeApprovalCoordinatorOptions);
105
141
  initialSink(): GenSink<ChatEvent>;
142
+ /**
143
+ * Issue #591: dispatch a host-side MCP `notifications/progress` to the
144
+ * consumer's eventStream as a `tool-progress` ChatEvent.
145
+ *
146
+ * Caller (the bridge handler's `onprogress` callback in
147
+ * `claude-mcp-bridge.ts`) calls this synchronously from inside the
148
+ * MCP SDK's notification dispatcher. Drops the notification when no
149
+ * MCP tool call is currently in flight — the only path that produces
150
+ * `currentMcpToolCallId === null` after a turn started is "progress
151
+ * arrived after the matching tool-result." Losing a straggler is
152
+ * preferable to surfacing a progress event without a meaningful
153
+ * toolCallId.
154
+ */
155
+ emitMcpProgress(params: {
156
+ progress: number;
157
+ total?: number;
158
+ message?: string;
159
+ }): void;
106
160
  onTeardown(callback: () => void): void;
107
161
  private runTeardownCallbacks;
108
162
  start(query: AsyncIterable<SDKMessage>): void;
@@ -111,21 +165,44 @@ export declare class ClaudeApprovalCoordinator {
111
165
  /**
112
166
  * Single teardown path for abort / dispose / approval-timeout /
113
167
  * pump-error. Marks every emitted approval `settledByCoordinator`
114
- * (so a subsequent `approve` / `decline` rejects with
115
- * "already auto-resolved"), drains every parked `PreToolUse` hook
116
- * Promise and per-id timer, rejects every parked consumer-tool
117
- * parker, pushes the synthetic terminal pair on the sink, aborts
118
- * the subprocess via the injected controller, and fires teardown
119
- * callbacks.
168
+ * (so a subsequent `approve` / `decline` is a silent no-op via the
169
+ * idempotent-settle path — issue #589), drains every parked
170
+ * `PreToolUse` hook Promise and per-id timer, rejects every parked
171
+ * consumer-tool parker, pushes the typed `error` + `finish('error')`
172
+ * pair on the sink, aborts the subprocess via the injected
173
+ * controller, and fires teardown callbacks.
174
+ *
175
+ * Every teardown reason — including `'dispose'` — pushes both events
176
+ * (issue #589). Two reasons:
177
+ *
178
+ * - **Consumers route on `error.code`, not on the *presence* of an
179
+ * error event.** AFV's `chat-stream-service.ts` maps
180
+ * `error.code === AgentSDKErrorType.DISPOSED` → its internal
181
+ * `AGENT_CANCELLED` and reaps the turn as cancelled (rather than
182
+ * completed or failed). Suppressing the dispose error event would
183
+ * delete that signal: the for-await would exit cleanly without a
184
+ * terminal event, the consumer would see a "completed" turn, and
185
+ * a turn that was actually torn down by a superseding `chat()` /
186
+ * `destroyThread` / `destroyAgent` / `shutdown` would record as
187
+ * successful in their telemetry pipeline. The original bug
188
+ * (issue #589 failure 2) was *untyped* error noise — `error.code`
189
+ * is already typed as `AgentSDKErrorType.DISPOSED`, which gives
190
+ * consumers a clean discriminator without string-matching.
191
+ *
192
+ * - **The SDK invariant requires every chat turn to end with one
193
+ * terminal `FinishEvent`.** `DefaultChatSession.wrapEventStream`
194
+ * only synthesizes a synthetic `finish` when an error landed on
195
+ * the stream; if dispose ended the sink without an error, there'd
196
+ * be no synthesis path and the turn would end with neither a
197
+ * natural finish nor a synthetic one — breaking the SDK contract
198
+ * pinned in `packages/sfdx-agent-sdk/ARCHITECTURE.md` →
199
+ * "Critical Invariants" → "Every chat turn ends with exactly one
200
+ * terminal FinishEvent".
120
201
  *
121
- * The `reason` parameter changes two things:
122
- * - `'dispose'` pushes an error event only, no `finish` (matches
123
- * pre-#529 dispose contract: disposal is consumer-triggered,
124
- * not a normal turn end).
125
- * - `'timeout'` resolves every parked hook with `decision: 'block'`
126
- * so the agentic loop ends politely; the other reasons reject
127
- * parked hooks with the underlying error so the SDK surfaces
128
- * each as a tool failure.
202
+ * The `reason` parameter changes one thing: `'timeout'` resolves
203
+ * every parked hook with `decision: 'block'` so the agentic loop
204
+ * ends politely; the other reasons reject parked hooks with the
205
+ * underlying error so the SDK surfaces each as a tool failure.
129
206
  *
130
207
  * Mirrors the Mastra coordinator's `teardown` so the pump-throw /
131
208
  * abort / dispose / timeout paths can't drift out of step on either
@@ -53,12 +53,48 @@ export class ClaudeApprovalCoordinator {
53
53
  /** ToolCallIds the consumer has settled. Rejects double-settle. */
54
54
  consumerSettled = new Set();
55
55
  /**
56
- * ToolCallIds the coordinator auto-resolved (timeout / abort / dispose).
57
- * A subsequent settle for these ids rejects with "already auto-resolved".
56
+ * ToolCallIds the coordinator auto-resolved (timeout / abort / dispose
57
+ * / pump-error). A subsequent settle for these ids is a silent no-op
58
+ * via the idempotent-settle contract (issue #589) — the lost race is
59
+ * unactionable from the consumer's side, and the methods are
60
+ * void-typed so there's no return value to communicate the no-op.
58
61
  */
59
62
  settledByCoordinator = new Set();
63
+ /**
64
+ * ToolCallIds the consumer has settled via {@link submitToolResult},
65
+ * or that the coordinator drained at teardown time. Used as the
66
+ * idempotent-settle ledger for the consumer-tool path (parallel to
67
+ * `consumerSettled` + `settledByCoordinator` on the approve/decline
68
+ * path). A subsequent `submitToolResult` for these ids is a silent
69
+ * no-op rather than throwing `TOOL_CALL_NOT_FOUND` (issue #589).
70
+ */
71
+ consumerToolSettled = new Set();
60
72
  /** Args from the adapter's `tool-call` ChatEvent, keyed by `toolCallId`. */
61
73
  toolCallArgs = new Map();
74
+ /**
75
+ * `toolCallId` of the MCP tool call currently in-flight, or `null` when
76
+ * no MCP tool is awaiting a result. Tracked at `route()` time: set when
77
+ * an MCP-namespaced `tool-call` arrives, cleared on the matching
78
+ * `tool-result`.
79
+ *
80
+ * Used by {@link emitMcpProgress} to attribute incoming
81
+ * `notifications/progress` (delivered via the host-side MCP client's
82
+ * `onprogress` callback in `claude-mcp-bridge.ts`) to the right
83
+ * `toolCallId` for the `tool-progress` ChatEvent.
84
+ *
85
+ * The Claude Agent SDK serializes tool execution per turn (see
86
+ * ARCHITECTURE.md → "Tool Approval"), so at most one MCP tool call is
87
+ * in flight at any time — matching this scalar shape.
88
+ */
89
+ currentMcpToolCallId = null;
90
+ /**
91
+ * Captures the (Claude-namespaced) tool name for each `toolCallId`
92
+ * routed through `route()`. Used by {@link emitMcpProgress} to stamp
93
+ * `toolName` on the `tool-progress` ChatEvent so AG-UI Activity
94
+ * translators don't have to consult the originating `tool-call` event
95
+ * to route progress chunks.
96
+ */
97
+ toolNameForCallId = new Map();
62
98
  /**
63
99
  * Consumer-tool: tool-call events pump has seen but no parker invocation
64
100
  * for yet. FIFO list per tool name. Empirically the Claude subprocess
@@ -109,6 +145,32 @@ export class ClaudeApprovalCoordinator {
109
145
  initialSink() {
110
146
  return this.initial;
111
147
  }
148
+ /**
149
+ * Issue #591: dispatch a host-side MCP `notifications/progress` to the
150
+ * consumer's eventStream as a `tool-progress` ChatEvent.
151
+ *
152
+ * Caller (the bridge handler's `onprogress` callback in
153
+ * `claude-mcp-bridge.ts`) calls this synchronously from inside the
154
+ * MCP SDK's notification dispatcher. Drops the notification when no
155
+ * MCP tool call is currently in flight — the only path that produces
156
+ * `currentMcpToolCallId === null` after a turn started is "progress
157
+ * arrived after the matching tool-result." Losing a straggler is
158
+ * preferable to surfacing a progress event without a meaningful
159
+ * toolCallId.
160
+ */
161
+ emitMcpProgress(params) {
162
+ if (this.aborted || this.disposed)
163
+ return;
164
+ const toolCallId = this.currentMcpToolCallId;
165
+ if (!toolCallId)
166
+ return;
167
+ this.initial.push({
168
+ type: 'tool-progress',
169
+ toolCallId,
170
+ toolName: this.toolNameForCallId.get(toolCallId) ?? 'unknown',
171
+ output: { ...params },
172
+ });
173
+ }
112
174
  onTeardown(callback) {
113
175
  if (this.aborted || this.disposed) {
114
176
  queueMicrotask(callback);
@@ -149,21 +211,44 @@ export class ClaudeApprovalCoordinator {
149
211
  /**
150
212
  * Single teardown path for abort / dispose / approval-timeout /
151
213
  * pump-error. Marks every emitted approval `settledByCoordinator`
152
- * (so a subsequent `approve` / `decline` rejects with
153
- * "already auto-resolved"), drains every parked `PreToolUse` hook
154
- * Promise and per-id timer, rejects every parked consumer-tool
155
- * parker, pushes the synthetic terminal pair on the sink, aborts
156
- * the subprocess via the injected controller, and fires teardown
157
- * callbacks.
214
+ * (so a subsequent `approve` / `decline` is a silent no-op via the
215
+ * idempotent-settle path — issue #589), drains every parked
216
+ * `PreToolUse` hook Promise and per-id timer, rejects every parked
217
+ * consumer-tool parker, pushes the typed `error` + `finish('error')`
218
+ * pair on the sink, aborts the subprocess via the injected
219
+ * controller, and fires teardown callbacks.
220
+ *
221
+ * Every teardown reason — including `'dispose'` — pushes both events
222
+ * (issue #589). Two reasons:
223
+ *
224
+ * - **Consumers route on `error.code`, not on the *presence* of an
225
+ * error event.** AFV's `chat-stream-service.ts` maps
226
+ * `error.code === AgentSDKErrorType.DISPOSED` → its internal
227
+ * `AGENT_CANCELLED` and reaps the turn as cancelled (rather than
228
+ * completed or failed). Suppressing the dispose error event would
229
+ * delete that signal: the for-await would exit cleanly without a
230
+ * terminal event, the consumer would see a "completed" turn, and
231
+ * a turn that was actually torn down by a superseding `chat()` /
232
+ * `destroyThread` / `destroyAgent` / `shutdown` would record as
233
+ * successful in their telemetry pipeline. The original bug
234
+ * (issue #589 failure 2) was *untyped* error noise — `error.code`
235
+ * is already typed as `AgentSDKErrorType.DISPOSED`, which gives
236
+ * consumers a clean discriminator without string-matching.
237
+ *
238
+ * - **The SDK invariant requires every chat turn to end with one
239
+ * terminal `FinishEvent`.** `DefaultChatSession.wrapEventStream`
240
+ * only synthesizes a synthetic `finish` when an error landed on
241
+ * the stream; if dispose ended the sink without an error, there'd
242
+ * be no synthesis path and the turn would end with neither a
243
+ * natural finish nor a synthetic one — breaking the SDK contract
244
+ * pinned in `packages/sfdx-agent-sdk/ARCHITECTURE.md` →
245
+ * "Critical Invariants" → "Every chat turn ends with exactly one
246
+ * terminal FinishEvent".
158
247
  *
159
- * The `reason` parameter changes two things:
160
- * - `'dispose'` pushes an error event only, no `finish` (matches
161
- * pre-#529 dispose contract: disposal is consumer-triggered,
162
- * not a normal turn end).
163
- * - `'timeout'` resolves every parked hook with `decision: 'block'`
164
- * so the agentic loop ends politely; the other reasons reject
165
- * parked hooks with the underlying error so the SDK surfaces
166
- * each as a tool failure.
248
+ * The `reason` parameter changes one thing: `'timeout'` resolves
249
+ * every parked hook with `decision: 'block'` so the agentic loop
250
+ * ends politely; the other reasons reject parked hooks with the
251
+ * underlying error so the SDK surfaces each as a tool failure.
167
252
  *
168
253
  * Mirrors the Mastra coordinator's `teardown` so the pump-throw /
169
254
  * abort / dispose / timeout paths can't drift out of step on either
@@ -176,6 +261,10 @@ export class ClaudeApprovalCoordinator {
176
261
  this.tornDown = true;
177
262
  for (const id of this.emittedApprovals)
178
263
  this.settledByCoordinator.add(id);
264
+ for (const id of this.pendingByToolCallId.keys())
265
+ this.consumerToolSettled.add(id);
266
+ for (const id of this.recentToolCallNameById.keys())
267
+ this.consumerToolSettled.add(id);
179
268
  if (reason === 'timeout') {
180
269
  // Resolve every parked PreToolUse hook with the SDK's
181
270
  // polite-halt shape so the agentic loop ends without
@@ -205,15 +294,9 @@ export class ClaudeApprovalCoordinator {
205
294
  // Reject every parked consumer-tool call so the bridge handler
206
295
  // unblocks with an error rather than waiting forever.
207
296
  this.failAllPendingConsumerCalls(error);
208
- if (reason === 'dispose') {
209
- this.initial.push({ type: 'error', error, code });
210
- this.initial.end();
211
- }
212
- else {
213
- this.initial.push({ type: 'error', error, code });
214
- this.initial.push({ type: 'finish', finishReason: 'error' });
215
- this.initial.end();
216
- }
297
+ this.initial.push({ type: 'error', error, code });
298
+ this.initial.push({ type: 'finish', finishReason: 'error' });
299
+ this.initial.end();
217
300
  // Kill the subprocess on every teardown reason. `abort` is
218
301
  // already aborted by the harness's abort listener forwarding
219
302
  // (which calls `controller.abort()` before `coordinator.abort()`);
@@ -309,15 +392,22 @@ export class ClaudeApprovalCoordinator {
309
392
  }));
310
393
  }
311
394
  settlePending(method, toolCallId, decide) {
312
- if (this.settledByCoordinator.has(toolCallId)) {
313
- throw new Error(`ClaudeApprovalCoordinator.${method}(): tool call "${toolCallId}" was already auto-resolved by the coordinator`);
314
- }
315
- if (this.consumerSettled.has(toolCallId)) {
316
- throw new Error(`ClaudeApprovalCoordinator.${method}(): tool call "${toolCallId}" was already settled`);
395
+ // Issue #589: idempotent settle. A tool call the coordinator
396
+ // already auto-resolved (timeout / abort / dispose / pump-error) or
397
+ // the consumer already settled is a lost-race no-op rather than a
398
+ // throw — settle methods are void-typed, so the consumer never
399
+ // branches on a return value, and the outcome they wanted (id is
400
+ // settled) is already true.
401
+ if (this.settledByCoordinator.has(toolCallId) || this.consumerSettled.has(toolCallId)) {
402
+ return;
317
403
  }
318
404
  const pending = this.pendingApprovals.get(toolCallId);
319
405
  if (!pending && !this.emittedApprovals.has(toolCallId)) {
320
- throw new Error(`ClaudeApprovalCoordinator.${method}(): no pending approval for tool call "${toolCallId}"`);
406
+ // Genuine misuse — the coordinator never saw this id (typo,
407
+ // wrong session, or settle called before approval-request /
408
+ // tool-call ever fired). Typed so consumers can branch on
409
+ // err.type instead of string-matching the message.
410
+ throw new AgentSDKError(`ClaudeApprovalCoordinator.${method}(): no pending approval for tool call "${toolCallId}"`, AgentSDKErrorType.TOOL_CALL_NOT_FOUND);
321
411
  }
322
412
  this.consumerSettled.add(toolCallId);
323
413
  const input = pending?.input ?? this.toolCallArgs.get(toolCallId) ?? {};
@@ -387,8 +477,18 @@ export class ClaudeApprovalCoordinator {
387
477
  * consumer is iterating from `chat()`.
388
478
  */
389
479
  submitToolResult(toolCallId, result, isError) {
480
+ // Issue #589: idempotent settle. A submitToolResult for an id the
481
+ // consumer already settled, or that the coordinator drained at
482
+ // teardown time, is a silent no-op — the lost-race shape is
483
+ // unactionable from the consumer's side, and the method is
484
+ // void-typed. Mirrors the approve/decline path's
485
+ // `consumerSettled` + `settledByCoordinator` ledger.
486
+ if (this.consumerToolSettled.has(toolCallId)) {
487
+ return;
488
+ }
390
489
  const entry = this.pendingByToolCallId.get(toolCallId);
391
490
  if (entry) {
491
+ this.consumerToolSettled.add(toolCallId);
392
492
  this.pendingByToolCallId.delete(toolCallId);
393
493
  entry.resolve({ result, isError });
394
494
  return;
@@ -397,10 +497,14 @@ export class ClaudeApprovalCoordinator {
397
497
  // toolCallId) but the bridge handler hasn't parked yet. Stage the
398
498
  // result; the parker resolves as soon as it arrives.
399
499
  if (this.recentToolCallNameById.has(toolCallId)) {
500
+ this.consumerToolSettled.add(toolCallId);
400
501
  this.preSubmittedByToolCallId.set(toolCallId, { result, isError });
401
502
  return;
402
503
  }
403
- throw new Error(`ClaudeApprovalCoordinator.submitToolResult(): no pending tool call for id "${toolCallId}"`);
504
+ // Issue #589: typed error — the coordinator never saw this id, so
505
+ // this is genuine misuse rather than the lost-race shape the
506
+ // idempotent-settle path collapses to a no-op.
507
+ throw new AgentSDKError(`ClaudeApprovalCoordinator.submitToolResult(): no pending tool call for id "${toolCallId}"`, AgentSDKErrorType.TOOL_CALL_NOT_FOUND);
404
508
  }
405
509
  failAllPendingConsumerCalls(err) {
406
510
  for (const list of this.waitingParkersByName.values()) {
@@ -431,12 +535,12 @@ export class ClaudeApprovalCoordinator {
431
535
  // so every parked PreToolUse hook is rejected, every
432
536
  // consumer-tool parker is failed, every emitted approval is
433
537
  // marked `settledByCoordinator` (so a subsequent
434
- // `approve(tc-N)` rejects with "already auto-resolved"
435
- // instead of deadlocking on a sink the pump just torched),
436
- // and the synthetic terminal pair lands on the same `initial`
437
- // sink the consumer is iterating. Mirrors Mastra's
438
- // `pumpUntilSuspendOrTerminal` catch block — closes the
439
- // audit's Claude Finding #1 / Mastra Finding #1.
538
+ // `approve(tc-N)` is a silent no-op via the idempotent-settle
539
+ // path — issue #589 — instead of deadlocking on a sink the
540
+ // pump just torched), and the synthetic terminal pair lands
541
+ // on the same `initial` sink the consumer is iterating.
542
+ // Mirrors Mastra's `pumpUntilSuspendOrTerminal` catch block —
543
+ // closes the audit's Claude Finding #1 / Mastra Finding #1.
440
544
  //
441
545
  // Re-entry from a prior abort/dispose/timeout teardown that
442
546
  // aborted the subprocess (which then surfaces here as the
@@ -471,6 +575,30 @@ export class ClaudeApprovalCoordinator {
471
575
  if (this.mode === 'batch' && !this.emittedApprovals.has(routed.toolCallId) && !isConsumerTool) {
472
576
  this.emitApprovalRequest(routed.toolCallId, routed.toolName, routed.args);
473
577
  }
578
+ // Issue #591: track in-flight MCP tool call so progress
579
+ // notifications received via `client.callTool({ onprogress })`
580
+ // can be attributed to the right `toolCallId`. Set on
581
+ // EXTERNAL-MCP `tool-call`s only; cleared on the matching
582
+ // `tool-result`. Gated on `lookupMcpToolMetadata` which is
583
+ // closed over `agentState.mcpServers` — the host-owned
584
+ // external MCP catalog. In-process bridges (`skill_bridge`,
585
+ // `consumer_tools`) carry the `mcp__` prefix in their wire
586
+ // names but are NOT in that catalog, so the lookup correctly
587
+ // returns `undefined` for them and the tracker stays unset.
588
+ // Without this gate, the field's intent ("external MCP tool
589
+ // call that may emit progress") would drift from its
590
+ // implementation ("any mcp__-prefixed non-consumer-tool")
591
+ // and a future change adding `onprogress` to a built-in
592
+ // bridge would silently misattribute.
593
+ if (!isConsumerTool &&
594
+ routed.toolName.startsWith(MCP_PREFIX) &&
595
+ this.lookupMcpToolMetadata?.(routed.toolName) !== undefined) {
596
+ this.currentMcpToolCallId = routed.toolCallId;
597
+ this.toolNameForCallId.set(routed.toolCallId, routed.toolName);
598
+ }
599
+ }
600
+ else if (routed.type === 'tool-result' && this.currentMcpToolCallId === routed.toolCallId) {
601
+ this.currentMcpToolCallId = null;
474
602
  }
475
603
  if (this.aborted || this.disposed)
476
604
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"claude-approval-coordinator.js","sourceRoot":"","sources":["../src/claude-approval-coordinator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,aAAa,EACb,iBAAiB,GAKpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAG7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,MAAM,UAAU,GAAG,OAAO,CAAC;AA0D3B,MAAM,OAAO,yBAAyB;IACjB,OAAO,CAAqB;IAC5B,qBAAqB,CAAS;IAC9B,eAAe,CAAkB;IACjC,qBAAqB,CAAyB;IAC9C,IAAI,CAAqB;IACzB,wBAAwB,CAAqB;IAE9D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,CAAC,CAAC,CAAC;QACpE,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IAClE,CAAC;CACJ"}
@@ -33,14 +33,43 @@ export declare class ClaudeEventAdapter {
33
33
  */
34
34
  private deferredStepFinish?;
35
35
  /**
36
- * Set when {@link mapAssistantMessage} emits an `error` ChatEvent for a
37
- * synthetic gateway-failure envelope. The terminal `result` SDKMessage that
38
- * follows (typically `subtype: 'success'` with no usage) gets its
39
- * `finishReason` remapped to `'error'` so the public stream's terminal
40
- * event reflects the failure on a single field — consumers don't have to
41
- * correlate the prior `error` event to know the turn failed.
36
+ * Set when {@link mapAssistantMessage} or {@link mapApiRetry} (on retry
37
+ * exhaustion) emits an `error` ChatEvent for a synthetic gateway-failure
38
+ * envelope. The terminal `result` SDKMessage that follows (typically
39
+ * `subtype: 'success'` with no usage) gets its `finishReason` remapped to
40
+ * `'error'` so the public stream's terminal event reflects the failure on
41
+ * a single field — consumers don't have to correlate the prior `error`
42
+ * event to know the turn failed. Not set by {@link mapMirrorError} —
43
+ * transcript-persistence failure is a data-loss signal, not necessarily
44
+ * a turn-fatal one.
42
45
  */
43
46
  private sawSyntheticAssistantError;
47
+ /**
48
+ * Per-step reasoning-token accumulator. Holds the latest cumulative
49
+ * `estimated_tokens` value from `SDKThinkingTokensMessage` for the
50
+ * current step. Folded into the next `step-finish.usage.reasoningTokens`
51
+ * and then **cleared** so a subsequent step without a thinking block
52
+ * doesn't inherit the prior step's count. Mirrors Mastra's per-step
53
+ * shape on `step-finish.usage`. Provider-reported and may be an
54
+ * estimate (Claude) vs. an actual (Mastra); see
55
+ * `UsageMetadata.reasoningTokens`.
56
+ */
57
+ private pendingReasoningTokens;
58
+ /**
59
+ * Per-turn reasoning-token total. The Claude SDK's terminal `result`
60
+ * message carries no thinking-token field, but consumers reading
61
+ * `finish.usage.reasoningTokens` need a turn-level count (Mastra
62
+ * symmetry — Mastra populates it on terminal `finish.usage` too). The
63
+ * per-step `pendingReasoningTokens` value is consumed (and cleared) by
64
+ * each `message_delta`, which means it would always be `undefined` by
65
+ * the time `mapResult` runs on a real turn (the gateway always emits
66
+ * `message_delta` before `result`). This field aggregates each step's
67
+ * count as it's consumed so `mapResult` has the turn total to fold into
68
+ * `finish.usage.reasoningTokens`. Per-stream isolation means the
69
+ * accumulator never leaks across turns — the adapter is constructed
70
+ * fresh per `stream()`.
71
+ */
72
+ private turnReasoningTokens;
44
73
  private readonly logBus?;
45
74
  private readonly lookupMcpToolMetadata?;
46
75
  constructor(logBus?: LogBus, lookupMcpToolMetadata?: McpToolMetadataLookup);
@@ -66,6 +95,68 @@ export declare class ClaudeEventAdapter {
66
95
  * its own `finish` — we do not push one here.
67
96
  */
68
97
  private mapAssistantMessage;
98
+ /**
99
+ * `system`-typed SDKMessages cover several disjoint subtypes
100
+ * (`init`, `compact_boundary`, `notification`, `api_retry`, `mirror_error`,
101
+ * etc.). Two carry error semantics that the public `ChatEvent` stream
102
+ * needs visibility into; the rest fall through to the forward-compat
103
+ * hatch with a `system:<subtype>` chunkType so harness developers can
104
+ * tell them apart from top-level-type unknowns when grepping LogBus.
105
+ */
106
+ private mapSystemMessage;
107
+ /**
108
+ * Transport-level retry attempts. Transient retries
109
+ * (`attempt < max_retries`) are operationally interesting but not
110
+ * turn-fatal — they land on `LogBus.warn` so ops can spot retry storms
111
+ * without polluting the consumer's `ChatEvent` stream. Only retry
112
+ * exhaustion (`attempt === max_retries`) graduates to a
113
+ * `ChatEvent.error`. The terminal `result` SDKMessage that follows
114
+ * lands on `mapResult` and emits its own `finish` — we do not push one
115
+ * here. The synthetic-error flag is set on exhaustion as cheap
116
+ * insurance: if a future SDK ever emits `result(success)` after retry
117
+ * exhaustion, the terminal `finish` reason gets remapped to `'error'`
118
+ * by `mapResult` instead of contradicting the prior error chunk.
119
+ */
120
+ private mapApiRetry;
121
+ /**
122
+ * Transcript-mirror persistence failure. The Claude Agent SDK emits
123
+ * this when `SessionStore.append()` rejects or times out for a batch
124
+ * after bounded retry — the batch is then dropped, so this is a
125
+ * data-loss signal that consumers asked to see (#581). The dropped
126
+ * batch's `key` (`{ projectKey, sessionId, subpath? }`) is preserved
127
+ * on `LogBus.warn` for diagnosis without bloating the consumer-facing
128
+ * ChatEvent payload. `sawSyntheticAssistantError` is intentionally
129
+ * NOT set: a transcript persistence failure isn't necessarily
130
+ * turn-fatal, so we don't poison the terminal `finish` reason.
131
+ */
132
+ private mapMirrorError;
133
+ /**
134
+ * Long-running tool calls (Bash with long-running commands, MCP tools that
135
+ * take seconds to respond, sub-agent tasks) emit `SDKToolProgressMessage`
136
+ * heartbeats while the call is still in flight, before the terminal
137
+ * `tool_result`. Map them to `tool-progress` ChatEvents so consumers can
138
+ * render "tool is working" UI without waiting for the result.
139
+ *
140
+ * `parent_tool_use_id` is non-null when the progress belongs to a nested
141
+ * tool call (e.g. a Task sub-agent invoking another tool); we surface it
142
+ * as `parentToolCallId` so consumers can render the right scope.
143
+ *
144
+ * The Claude SDK also reports `elapsed_time_seconds`. We deliberately do
145
+ * not surface it on the public ChatEvent — consumers needing elapsed time
146
+ * compute it from their own clock against the originating `tool-call`,
147
+ * keeping a single source of truth.
148
+ */
149
+ private mapToolProgress;
150
+ /**
151
+ * Live reasoning-token estimate emitted during the model's redacted-thinking
152
+ * phase. `estimated_tokens` is the running total for the active thinking
153
+ * block; we stash it on per-stream state for the next `step-finish` /
154
+ * `finish` to fold into `usage.reasoningTokens`. No public ChatEvent
155
+ * surfaces here — the `reasoning-delta` ChatEvent (mapped from
156
+ * `thinking_delta` content blocks) is the streaming-text channel; this
157
+ * message is the token-count channel.
158
+ */
159
+ private mapThinkingTokens;
69
160
  private mapResult;
70
161
  private mapStreamEvent;
71
162
  private mapContentBlockStart;