@ai-sdk/harness-claude-code 1.0.196 → 1.0.197

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/harness-claude-code",
3
- "version": "1.0.196",
3
+ "version": "1.0.197",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -26,7 +26,7 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@ai-sdk/harness": "1.0.192",
29
+ "@ai-sdk/harness": "1.0.193",
30
30
  "@ai-sdk/provider": "4.0.39",
31
31
  "@ai-sdk/provider-utils": "5.0.83",
32
32
  "ws": "^8.21.0"
@@ -317,6 +317,21 @@ export function createEmitStreamEvent({
317
317
  // into regular stream parts or let them affect the parent step.
318
318
  if (msg.parent_tool_use_id != null) {
319
319
  emit({ type: 'raw', rawValue: msg });
320
+ // A subagent's host tool call is answered here, outside the parent's
321
+ // steps, so its handler record goes with its result. Left behind, it
322
+ // matched a later identical call of the parent by name and input, and
323
+ // that call never reached the host.
324
+ const content = msg.message?.content;
325
+ if (type === 'user' && Array.isArray(content)) {
326
+ for (const block of content) {
327
+ if (
328
+ block.type === 'tool_result' &&
329
+ typeof block.tool_use_id === 'string'
330
+ ) {
331
+ state.mcpHandlerCalls.delete(block.tool_use_id);
332
+ }
333
+ }
334
+ }
320
335
  return;
321
336
  }
322
337
 
@@ -42,6 +42,7 @@ import {
42
42
  resolveSandboxHomeDir,
43
43
  SandboxChannel,
44
44
  shellQuote,
45
+ stopPreviousBridge,
45
46
  validateBridgeSandboxSettings,
46
47
  warnCredentialBrokeringUnavailable,
47
48
  warnMintBridgeTokenIgnored,
@@ -1094,8 +1095,9 @@ export function createClaudeCode(
1094
1095
  * try to reopen a socket to the still-running bridge. Parked sessions wait
1095
1096
  * for the next `start`; suspended turns request replay of everything past
1096
1097
  * the persisted cursor. No spawn, no fresh key (the existing bridge
1097
- * still authorises the persisted one). If the bridge is gone the open
1098
- * throws and we fall through to a spawn-based recovery.
1098
+ * still authorises the persisted one). If the open throws, because the
1099
+ * bridge is gone or too slow to answer, we fall through to a spawn-based
1100
+ * recovery.
1099
1101
  */
1100
1102
  if (coords) {
1101
1103
  try {
@@ -1170,7 +1172,19 @@ export function createClaudeCode(
1170
1172
  turnStartTimeoutMs: settings.turnStartTimeoutMs ?? 120_000,
1171
1173
  });
1172
1174
  } catch {
1173
- // Bridge no longer reachable — recover by respawning below.
1175
+ /*
1176
+ * Bridge not reachable — recover by respawning below. A bridge that
1177
+ * is only too slow to answer still holds its port and runs its
1178
+ * turn, so stop it and the processes it started, by the pid
1179
+ * `bridge-meta.json` records, before `markBridgeStarting`
1180
+ * overwrites that record.
1181
+ */
1182
+ await stopPreviousBridge({
1183
+ sandbox: toolSafeSandboxSession,
1184
+ bridgeStateDir,
1185
+ bridgeType: 'claude-code',
1186
+ abortSignal: startOpts.abortSignal,
1187
+ });
1174
1188
  }
1175
1189
  }
1176
1190
 
@@ -1909,8 +1923,8 @@ function createSession({
1909
1923
  * rerun: the bridge was respawned with no in-flight turn to attach to, so
1910
1924
  * re-drive the runtime's own thread from the workdir snapshot via
1911
1925
  * `continue: true`. Lossy — work in flight at the suspension is
1912
- * recomputed. This is the rare bridge-died fallback; the common slice path
1913
- * is `attach`.
1926
+ * recomputed. This is the fallback for a bridge that died or did not
1927
+ * answer the attach; the common slice path is `attach`.
1914
1928
  */
1915
1929
  // Same as `doPromptTurn`: an already-aborted signal settled the turn in
1916
1930
  // `wireTurn`, so don't re-drive the thread nobody is waiting on.