@ai-sdk/harness-claude-code 1.0.171 → 1.0.173

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.
@@ -99,6 +99,23 @@ export type ClaudeCodeHarnessSettings = {
99
99
  * underlying runtime's native MCP server configuration format.
100
100
  */
101
101
  readonly mcpServers?: Record<string, unknown>;
102
+ /**
103
+ * Claude Code hints for host tools, keyed by tool name.
104
+ *
105
+ * - `readOnly`: the tool has no side effects. Claude Code can run read-only
106
+ * tool calls in parallel, and runs each call to any other host tool on
107
+ * its own. It also allows read-only tools in plan mode, so mark only
108
+ * tools that change nothing.
109
+ * - `alwaysLoad`: when Claude Code's tool search is on, it defers MCP tools
110
+ * until the model looks them up; this sends the tool's definition from
111
+ * the first request instead.
112
+ */
113
+ readonly toolHints?: Readonly<
114
+ Record<
115
+ string,
116
+ { readonly readOnly?: boolean; readonly alwaysLoad?: boolean }
117
+ >
118
+ >;
102
119
  /**
103
120
  * Hard cap on how many internal turns the CLI can take before yielding
104
121
  * back to the caller. Unset means the CLI's default.
@@ -1101,6 +1118,7 @@ export function createClaudeCode(
1101
1118
  sandbox: toolSafeSandboxSession,
1102
1119
  sandboxHomeDir,
1103
1120
  mcpServers: settings.mcpServers,
1121
+ toolHints: settings.toolHints,
1104
1122
  supportsUserMessageResponses: () => supportsUserMessageResponses,
1105
1123
  });
1106
1124
  } catch {
@@ -1266,6 +1284,15 @@ export function createClaudeCode(
1266
1284
  continueOnFirstPrompt: respawnStrategy !== undefined,
1267
1285
  ...(resumeSessionId ? { resumeSessionId } : {}),
1268
1286
  rerunContinue: respawnStrategy === 'rerun',
1287
+ ...(respawnStrategy === 'rerun'
1288
+ ? {
1289
+ deferredToolUseId: (
1290
+ startOpts.continueFrom ?? startOpts.resumeFrom?.continueFrom
1291
+ )?.pendingToolApprovals?.find(
1292
+ approval => approval.kind === 'builtin',
1293
+ )?.toolCallId,
1294
+ }
1295
+ : {}),
1269
1296
  bridgePort: boundPort,
1270
1297
  bridgeToken: token,
1271
1298
  sandboxId,
@@ -1276,6 +1303,7 @@ export function createClaudeCode(
1276
1303
  sandbox: toolSafeSandboxSession,
1277
1304
  sandboxHomeDir,
1278
1305
  mcpServers: settings.mcpServers,
1306
+ toolHints: settings.toolHints,
1279
1307
  supportsUserMessageResponses: () => supportsUserMessageResponses,
1280
1308
  });
1281
1309
  },
@@ -1308,6 +1336,7 @@ function createSession({
1308
1336
  continueOnFirstPrompt,
1309
1337
  resumeSessionId,
1310
1338
  rerunContinue,
1339
+ deferredToolUseId,
1311
1340
  bridgePort,
1312
1341
  bridgeToken,
1313
1342
  sandboxId,
@@ -1318,6 +1347,7 @@ function createSession({
1318
1347
  sandbox,
1319
1348
  sandboxHomeDir,
1320
1349
  mcpServers,
1350
+ toolHints,
1321
1351
  supportsUserMessageResponses,
1322
1352
  }: {
1323
1353
  sessionId: string;
@@ -1344,6 +1374,12 @@ function createSession({
1344
1374
  */
1345
1375
  resumeSessionId?: string;
1346
1376
  rerunContinue: boolean;
1377
+ /**
1378
+ * Built-in tool call the previous bridge deferred while it waited for host
1379
+ * approval. The respawned bridge resumes it once the host answers instead
1380
+ * of starting a new turn.
1381
+ */
1382
+ deferredToolUseId?: string;
1347
1383
  bridgePort: number;
1348
1384
  bridgeToken: string;
1349
1385
  sandboxId: string | undefined;
@@ -1354,6 +1390,7 @@ function createSession({
1354
1390
  sandbox: SandboxSession;
1355
1391
  sandboxHomeDir: string;
1356
1392
  mcpServers: Record<string, unknown> | undefined;
1393
+ toolHints: ClaudeCodeHarnessSettings['toolHints'];
1357
1394
  supportsUserMessageResponses: () => boolean;
1358
1395
  }): HarnessV1Session {
1359
1396
  let stopped = false;
@@ -1624,6 +1661,7 @@ function createSession({
1624
1661
  ? { skills: promptOpts.skills.map(skill => skill.name) }
1625
1662
  : {}),
1626
1663
  ...(mcpServers == null ? {} : { mcpServers }),
1664
+ ...(toolHints == null ? {} : { toolHints }),
1627
1665
  ...(permissionMode ? { permissionMode } : {}),
1628
1666
  ...(builtinToolFiltering ? { builtinToolFiltering } : {}),
1629
1667
  ...(debug ? { debug } : {}),
@@ -1701,12 +1739,14 @@ function createSession({
1701
1739
  ? { skills: continueOpts.skills.map(skill => skill.name) }
1702
1740
  : {}),
1703
1741
  ...(mcpServers == null ? {} : { mcpServers }),
1742
+ ...(toolHints == null ? {} : { toolHints }),
1704
1743
  ...(permissionMode ? { permissionMode } : {}),
1705
1744
  ...(builtinToolFiltering ? { builtinToolFiltering } : {}),
1706
1745
  ...(debug ? { debug } : {}),
1707
1746
  ...(lastClaudeSessionId
1708
1747
  ? { resumeSessionId: lastClaudeSessionId }
1709
1748
  : { continue: true }),
1749
+ ...(deferredToolUseId != null ? { deferredToolUseId } : {}),
1710
1750
  });
1711
1751
  }
1712
1752