@ai-sdk/harness-claude-code 1.0.169 → 1.0.170

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.
@@ -1,11 +1,18 @@
1
- export function createClaudeCodeSystemPrompt(instructions?: string): {
1
+ export function createClaudeCodeSystemPrompt(
2
+ instructions?: string,
3
+ options?: { excludeDynamicSections?: boolean },
4
+ ): {
2
5
  type: 'preset';
3
6
  preset: 'claude_code';
4
7
  append?: string;
8
+ excludeDynamicSections?: boolean;
5
9
  } {
6
10
  return {
7
11
  type: 'preset',
8
12
  preset: 'claude_code',
9
13
  ...(instructions ? { append: instructions } : {}),
14
+ ...(options?.excludeDynamicSections !== undefined
15
+ ? { excludeDynamicSections: options.excludeDynamicSections }
16
+ : {}),
10
17
  };
11
18
  }
@@ -570,6 +570,12 @@ async function runTurn(start: StartMessage, turn: BridgeTurn): Promise<void> {
570
570
  options: {
571
571
  ...(start.model ? { model: start.model } : {}),
572
572
  ...(start.maxTurns !== undefined ? { maxTurns: start.maxTurns } : {}),
573
+ ...(start.maxBudgetUsd !== undefined
574
+ ? { maxBudgetUsd: start.maxBudgetUsd }
575
+ : {}),
576
+ ...(start.strictMcpConfig !== undefined
577
+ ? { strictMcpConfig: start.strictMcpConfig }
578
+ : {}),
573
579
  ...(start.agentProgressSummaries !== undefined
574
580
  ? { agentProgressSummaries: start.agentProgressSummaries }
575
581
  : {}),
@@ -582,7 +588,9 @@ async function runTurn(start: StartMessage, turn: BridgeTurn): Promise<void> {
582
588
  ...(inactiveNativeTools.length > 0
583
589
  ? { disallowedTools: inactiveNativeTools }
584
590
  : {}),
585
- systemPrompt: createClaudeCodeSystemPrompt(start.instructions),
591
+ systemPrompt: createClaudeCodeSystemPrompt(start.instructions, {
592
+ excludeDynamicSections: start.excludeDynamicSections,
593
+ }),
586
594
  thinking: start.thinking,
587
595
  ...(start.effort !== undefined ? { effort: start.effort } : {}),
588
596
  ...(start.responseFormat?.type === 'json' &&
@@ -603,6 +611,9 @@ async function runTurn(start: StartMessage, turn: BridgeTurn): Promise<void> {
603
611
  {
604
612
  matcher: 'AskUserQuestion',
605
613
  hooks: [questionPreToolUseHook],
614
+ ...(start.questionTimeoutMs !== undefined
615
+ ? { timeout: Math.ceil(start.questionTimeoutMs / 1000) }
616
+ : {}),
606
617
  },
607
618
  ],
608
619
  PostCompact: [
@@ -37,6 +37,10 @@ export const startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
37
37
  thinking: thinkingSchema,
38
38
  effort: z.enum(['low', 'medium', 'high', 'xhigh', 'max']).optional(),
39
39
  maxTurns: z.number().optional(),
40
+ maxBudgetUsd: z.number().optional(),
41
+ strictMcpConfig: z.boolean().optional(),
42
+ questionTimeoutMs: z.number().optional(),
43
+ excludeDynamicSections: z.boolean().optional(),
40
44
  agentProgressSummaries: z.boolean().optional(),
41
45
  forwardSubagentText: z.boolean().optional(),
42
46
  env: z.record(z.string(), z.string()).optional(),
@@ -104,6 +104,27 @@ export type ClaudeCodeHarnessSettings = {
104
104
  * back to the caller. Unset means the CLI's default.
105
105
  */
106
106
  readonly maxTurns?: number;
107
+ /**
108
+ * Maximum estimated spend in USD for each Claude query. When it is exceeded,
109
+ * the query stops and the turn ends with an error. Unset means no limit.
110
+ */
111
+ readonly maxBudgetUsd?: number;
112
+ /**
113
+ * Only use the MCP servers configured with `mcpServers`, and ignore any other
114
+ * MCP configuration such as a project `.mcp.json` or user settings.
115
+ */
116
+ readonly strictMcpConfig?: boolean;
117
+ /**
118
+ * Maximum milliseconds Claude waits for an answer to an `AskUserQuestion`
119
+ * question before the question fails. Unset means the Claude Code default.
120
+ */
121
+ readonly questionTimeoutMs?: number;
122
+ /**
123
+ * Moves per-session sections (working directory, memory, git status) out of
124
+ * the Claude Code system prompt and into the first user message, so the
125
+ * system prompt can be cached across sessions.
126
+ */
127
+ readonly excludeDynamicSections?: boolean;
107
128
  /**
108
129
  * Enables periodic AI-generated progress summaries for running subagents.
109
130
  * The summaries are forwarded in raw `task_progress` stream parts.
@@ -1058,6 +1079,10 @@ export function createClaudeCode(
1058
1079
  // sandbox is left running, stopped, or destroyed.
1059
1080
  proc: undefined,
1060
1081
  maxTurns: settings.maxTurns,
1082
+ maxBudgetUsd: settings.maxBudgetUsd,
1083
+ strictMcpConfig: settings.strictMcpConfig,
1084
+ questionTimeoutMs: settings.questionTimeoutMs,
1085
+ excludeDynamicSections: settings.excludeDynamicSections,
1061
1086
  agentProgressSummaries: settings.agentProgressSummaries,
1062
1087
  forwardSubagentText: settings.forwardSubagentText,
1063
1088
  env: sandboxClaudeEnvironment,
@@ -1228,6 +1253,10 @@ export function createClaudeCode(
1228
1253
  finishListenerAttachment,
1229
1254
  proc,
1230
1255
  maxTurns: settings.maxTurns,
1256
+ maxBudgetUsd: settings.maxBudgetUsd,
1257
+ strictMcpConfig: settings.strictMcpConfig,
1258
+ questionTimeoutMs: settings.questionTimeoutMs,
1259
+ excludeDynamicSections: settings.excludeDynamicSections,
1231
1260
  agentProgressSummaries: settings.agentProgressSummaries,
1232
1261
  forwardSubagentText: settings.forwardSubagentText,
1233
1262
  env: sandboxClaudeEnvironment,
@@ -1266,6 +1295,10 @@ function createSession({
1266
1295
  finishListenerAttachment,
1267
1296
  proc,
1268
1297
  maxTurns,
1298
+ maxBudgetUsd,
1299
+ strictMcpConfig,
1300
+ questionTimeoutMs,
1301
+ excludeDynamicSections,
1269
1302
  agentProgressSummaries,
1270
1303
  forwardSubagentText,
1271
1304
  env,
@@ -1293,6 +1326,10 @@ function createSession({
1293
1326
  /** Undefined on `attach` — the live bridge was spawned by another process. */
1294
1327
  proc: Experimental_SandboxProcess | undefined;
1295
1328
  maxTurns: number | undefined;
1329
+ maxBudgetUsd: number | undefined;
1330
+ strictMcpConfig: boolean | undefined;
1331
+ questionTimeoutMs: number | undefined;
1332
+ excludeDynamicSections: boolean | undefined;
1296
1333
  agentProgressSummaries: boolean | undefined;
1297
1334
  forwardSubagentText: boolean | undefined;
1298
1335
  env: Readonly<Record<string, string>> | undefined;
@@ -1570,6 +1607,12 @@ function createSession({
1570
1607
  : {}),
1571
1608
  model: promptOpts.model,
1572
1609
  maxTurns,
1610
+ ...(maxBudgetUsd !== undefined ? { maxBudgetUsd } : {}),
1611
+ ...(strictMcpConfig !== undefined ? { strictMcpConfig } : {}),
1612
+ ...(questionTimeoutMs !== undefined ? { questionTimeoutMs } : {}),
1613
+ ...(excludeDynamicSections !== undefined
1614
+ ? { excludeDynamicSections }
1615
+ : {}),
1573
1616
  ...(agentProgressSummaries !== undefined
1574
1617
  ? { agentProgressSummaries }
1575
1618
  : {}),
@@ -1641,6 +1684,12 @@ function createSession({
1641
1684
  : {}),
1642
1685
  model: continueOpts.model,
1643
1686
  maxTurns,
1687
+ ...(maxBudgetUsd !== undefined ? { maxBudgetUsd } : {}),
1688
+ ...(strictMcpConfig !== undefined ? { strictMcpConfig } : {}),
1689
+ ...(questionTimeoutMs !== undefined ? { questionTimeoutMs } : {}),
1690
+ ...(excludeDynamicSections !== undefined
1691
+ ? { excludeDynamicSections }
1692
+ : {}),
1644
1693
  ...(agentProgressSummaries !== undefined
1645
1694
  ? { agentProgressSummaries }
1646
1695
  : {}),