@ai-sdk/harness-opencode 1.0.152 → 1.0.154

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.
@@ -0,0 +1,106 @@
1
+ type Emit = (message: Record<string, unknown>) => void;
2
+
3
+ /*
4
+ * Host input that cannot be attributed to an OpenCode call id. Host tool
5
+ * relay requests carry their own ids, and permission requests or questions
6
+ * raised inside a subagent belong to the parent's `agent` tool call. Calls of
7
+ * such a group are matched to the group's waits by count.
8
+ */
9
+ export type OpenCodeHostInputGroup = 'host-tool' | 'subagent';
10
+
11
+ export type OpenCodeHostInputTracker = {
12
+ observeToolCall(input: {
13
+ callID: string;
14
+ status: 'started' | 'settled';
15
+ group: OpenCodeHostInputGroup | undefined;
16
+ }): void;
17
+ markWaiting(input: { toolCallId: string }): void;
18
+ clearWaiting(input: { toolCallId: string; settled?: boolean }): void;
19
+ markGroupWaiting(input: { group: OpenCodeHostInputGroup; id: string }): void;
20
+ clearGroupWaiting(input: { group: OpenCodeHostInputGroup; id: string }): void;
21
+ observeFinishStep(): void;
22
+ };
23
+
24
+ /*
25
+ * Tracks whether OpenCode can only make progress after host input: every tool
26
+ * call that started and has not settled either waits on a permission request
27
+ * or question, or belongs to a group with enough waits. In that case an early
28
+ * `finish-step` lets the host pause the turn; the OpenCode step stays open
29
+ * until its regular `finish-step`.
30
+ */
31
+ export function createOpenCodeHostInputTracker({
32
+ emit,
33
+ }: {
34
+ emit: Emit;
35
+ }): OpenCodeHostInputTracker {
36
+ const unsettledToolCalls = new Map<
37
+ string,
38
+ OpenCodeHostInputGroup | undefined
39
+ >();
40
+ const waitingToolCallIds = new Set<string>();
41
+ const groupWaits = new Map<OpenCodeHostInputGroup, Set<string>>([
42
+ ['host-tool', new Set()],
43
+ ['subagent', new Set()],
44
+ ]);
45
+ const coveredIds = new Set<string>();
46
+
47
+ const emitEarlyFinishStepIfReady = (): void => {
48
+ if (unsettledToolCalls.size === 0) return;
49
+ const notWaitingByGroup = new Map<OpenCodeHostInputGroup, number>();
50
+ for (const [callID, group] of unsettledToolCalls) {
51
+ if (waitingToolCallIds.has(callID)) continue;
52
+ if (group == null) return;
53
+ notWaitingByGroup.set(group, (notWaitingByGroup.get(group) ?? 0) + 1);
54
+ }
55
+ for (const [group, count] of notWaitingByGroup) {
56
+ if (count > groupWaits.get(group)!.size) return;
57
+ }
58
+ const uncovered = [
59
+ ...waitingToolCallIds,
60
+ ...[...groupWaits.values()].flatMap(ids => [...ids]),
61
+ ].filter(id => !coveredIds.has(id));
62
+ if (uncovered.length === 0) return;
63
+ for (const id of uncovered) coveredIds.add(id);
64
+ emit({
65
+ type: 'finish-step',
66
+ finishReason: { unified: 'tool-calls', raw: 'host-input' },
67
+ usage: {
68
+ inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
69
+ outputTokens: { total: 0, text: 0 },
70
+ },
71
+ harnessMetadata: { opencode: { inferredStep: true } },
72
+ });
73
+ };
74
+
75
+ return {
76
+ observeToolCall({ callID, status, group }) {
77
+ if (status === 'started') {
78
+ unsettledToolCalls.set(callID, group);
79
+ } else {
80
+ unsettledToolCalls.delete(callID);
81
+ }
82
+ emitEarlyFinishStepIfReady();
83
+ },
84
+ markWaiting({ toolCallId }) {
85
+ if (!unsettledToolCalls.has(toolCallId)) {
86
+ unsettledToolCalls.set(toolCallId, undefined);
87
+ }
88
+ waitingToolCallIds.add(toolCallId);
89
+ emitEarlyFinishStepIfReady();
90
+ },
91
+ clearWaiting({ toolCallId, settled = false }) {
92
+ waitingToolCallIds.delete(toolCallId);
93
+ if (settled) unsettledToolCalls.delete(toolCallId);
94
+ },
95
+ markGroupWaiting({ group, id }) {
96
+ groupWaits.get(group)!.add(id);
97
+ emitEarlyFinishStepIfReady();
98
+ },
99
+ clearGroupWaiting({ group, id }) {
100
+ groupWaits.get(group)!.delete(id);
101
+ },
102
+ observeFinishStep() {
103
+ coveredIds.clear();
104
+ },
105
+ };
106
+ }
@@ -1,9 +1,10 @@
1
1
  import path from 'node:path';
2
+ import { rgPath } from '@vscode/ripgrep';
2
3
 
3
4
  const fallbackPath =
4
5
  '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin';
5
6
 
6
- export function prependOpenCodeBinToPath({
7
+ export function configureOpenCodePath({
7
8
  bootstrapDir,
8
9
  env,
9
10
  }: {
@@ -13,5 +14,6 @@ export function prependOpenCodeBinToPath({
13
14
  env.PATH = [
14
15
  path.join(bootstrapDir, 'node_modules', '.bin'),
15
16
  env.PATH || fallbackPath,
17
+ path.dirname(rgPath),
16
18
  ].join(path.delimiter);
17
19
  }
@@ -6,6 +6,7 @@
6
6
  "dependencies": {
7
7
  "@modelcontextprotocol/sdk": "1.32.1",
8
8
  "@opencode-ai/sdk": "1.18.34",
9
+ "@vscode/ripgrep": "1.18.0",
9
10
  "opencode-ai": "1.18.34",
10
11
  "ws": "8.21.0",
11
12
  "zod": "3.25.76"
@@ -14,6 +14,9 @@ importers:
14
14
  '@opencode-ai/sdk':
15
15
  specifier: 1.18.34
16
16
  version: 1.18.34
17
+ '@vscode/ripgrep':
18
+ specifier: 1.18.0
19
+ version: 1.18.0
17
20
  opencode-ai:
18
21
  specifier: 1.18.34
19
22
  version: 1.18.34
@@ -45,6 +48,69 @@ packages:
45
48
  '@opencode-ai/sdk@1.18.34':
46
49
  resolution: {integrity: sha512-R9QWUpcngtdQ6FCixz7NC6n1WsSho6CEuRUzYHz/CzZcp3miSklDzXkm0oDwXVCnuEu+ANoeM0f6RDp51kOMzQ==}
47
50
 
51
+ '@vscode/ripgrep-darwin-arm64@1.18.0':
52
+ resolution: {integrity: sha512-r3ktHSvbFycQNF6sl7sNDPocpsI7J+mEzh1IaZFkY0spm3k2Z9t8hPAeOK7+p0l6p6/swkQC14XWX01low+94Q==}
53
+ cpu: [arm64]
54
+ os: [darwin]
55
+
56
+ '@vscode/ripgrep-darwin-x64@1.18.0':
57
+ resolution: {integrity: sha512-25b4gWbL138dGuQU244ebCKKc0q05ULBMoFSz9oAEUHNeqK/lOJViDS7DRvbDazzAzSEdan391Znks/R5mkaTQ==}
58
+ cpu: [x64]
59
+ os: [darwin]
60
+
61
+ '@vscode/ripgrep-linux-arm64@1.18.0':
62
+ resolution: {integrity: sha512-lQ/5zTG++U0E3IhVgS4EPTTn/U4okncaRMM5GOFfOYZywS4nuD31GhkHbNYlDk5CuDC68+hYJ0/eQeyCKJDA+g==}
63
+ cpu: [arm64]
64
+ os: [linux]
65
+
66
+ '@vscode/ripgrep-linux-arm@1.18.0':
67
+ resolution: {integrity: sha512-GDAvufNDHu8zqLEmXstalQF0Wh6wQvdsBi/Vg3Yi3CK4a8XoFXqqXVEHEZ9xQz3t0NfoSEc9JbvK9DDS6FxyxQ==}
68
+ cpu: [arm]
69
+ os: [linux]
70
+
71
+ '@vscode/ripgrep-linux-ia32@1.18.0':
72
+ resolution: {integrity: sha512-YWLkSUtFd4Jh5EepIhA9RJSfv3uMAVMo+2rBIGHPBnvgLrZciIs2cDKei1/p6Wc/aCzUoHyMAg2R6tw4ZCBKGg==}
73
+ cpu: [ia32]
74
+ os: [linux]
75
+
76
+ '@vscode/ripgrep-linux-ppc64@1.18.0':
77
+ resolution: {integrity: sha512-quXVY8fwQ8O/lvU1yrSqSl3jlUzysRSb+AfUfCL/tRtphxsKlFvPAejryZ6vg4Bgvn8XL74xb4qMCDmWgYrT5w==}
78
+ cpu: [ppc64]
79
+ os: [linux]
80
+
81
+ '@vscode/ripgrep-linux-riscv64@1.18.0':
82
+ resolution: {integrity: sha512-f5kBQBrWfQt8Q7OhSORuNDei5dkYagBj3y4jImSUXGMy8B/Ke7SltSRcUtjPv166FAFfHCAmWuZp3+cWnX2/Vw==}
83
+ cpu: [riscv64]
84
+ os: [linux]
85
+
86
+ '@vscode/ripgrep-linux-s390x@1.18.0':
87
+ resolution: {integrity: sha512-rTOcJFGGcl2c07RUOWUo4U1ndnemKhY6A9hnMB18uk7jSgJc0d/QLBGWMWpumdtoJtpizn/wIv5mXIisJukusQ==}
88
+ cpu: [s390x]
89
+ os: [linux]
90
+
91
+ '@vscode/ripgrep-linux-x64@1.18.0':
92
+ resolution: {integrity: sha512-mQ3bVrUpnD2vs7QT0vX90Lt0cnUq467uFtEktIdsJJmW296RoSULRGqWgzG1AKxyBpNDD6l4ZO4qKf6SgyC23Q==}
93
+ cpu: [x64]
94
+ os: [linux]
95
+
96
+ '@vscode/ripgrep-win32-arm64@1.18.0':
97
+ resolution: {integrity: sha512-vfTIjq1OHnzUjxZcHVQAMbnggp8dpGf+0QKFOZHwWPqFwXxQC8eCWM+5NUdoJ6yrElCeMzoUTXoK/LdZaniB+Q==}
98
+ cpu: [arm64]
99
+ os: [win32]
100
+
101
+ '@vscode/ripgrep-win32-ia32@1.18.0':
102
+ resolution: {integrity: sha512-//rfAE+BOw5AC2EMmepmiE36jUuevtQYNQqqlw1s3m9FlRxjxEut97RkRPHAu9BG4mSojatZx+kXZXNdyI9caQ==}
103
+ cpu: [ia32]
104
+ os: [win32]
105
+
106
+ '@vscode/ripgrep-win32-x64@1.18.0':
107
+ resolution: {integrity: sha512-KNPvtElldqILHdnAetujPaowkNbpqJy3ssIGGN6F6Kve9Qi+nNLI2DN01O83JjCEVQbCzl8Ov3QZ9Eov3BR8Dg==}
108
+ cpu: [x64]
109
+ os: [win32]
110
+
111
+ '@vscode/ripgrep@1.18.0':
112
+ resolution: {integrity: sha512-ns5lWe44tSfbTMbVUsyB+I1819PVSw4AdpgK0RNkzfWfwy6+3IUNSxwSrfTno1/oWaS/hERNz+XLWVyga2aJBQ==}
113
+
48
114
  accepts@2.0.0:
49
115
  resolution: {integrity: sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==}
50
116
  engines: {node: '>= 0.6'}
@@ -507,6 +573,57 @@ snapshots:
507
573
  dependencies:
508
574
  cross-spawn: 7.0.6
509
575
 
576
+ '@vscode/ripgrep-darwin-arm64@1.18.0':
577
+ optional: true
578
+
579
+ '@vscode/ripgrep-darwin-x64@1.18.0':
580
+ optional: true
581
+
582
+ '@vscode/ripgrep-linux-arm64@1.18.0':
583
+ optional: true
584
+
585
+ '@vscode/ripgrep-linux-arm@1.18.0':
586
+ optional: true
587
+
588
+ '@vscode/ripgrep-linux-ia32@1.18.0':
589
+ optional: true
590
+
591
+ '@vscode/ripgrep-linux-ppc64@1.18.0':
592
+ optional: true
593
+
594
+ '@vscode/ripgrep-linux-riscv64@1.18.0':
595
+ optional: true
596
+
597
+ '@vscode/ripgrep-linux-s390x@1.18.0':
598
+ optional: true
599
+
600
+ '@vscode/ripgrep-linux-x64@1.18.0':
601
+ optional: true
602
+
603
+ '@vscode/ripgrep-win32-arm64@1.18.0':
604
+ optional: true
605
+
606
+ '@vscode/ripgrep-win32-ia32@1.18.0':
607
+ optional: true
608
+
609
+ '@vscode/ripgrep-win32-x64@1.18.0':
610
+ optional: true
611
+
612
+ '@vscode/ripgrep@1.18.0':
613
+ optionalDependencies:
614
+ '@vscode/ripgrep-darwin-arm64': 1.18.0
615
+ '@vscode/ripgrep-darwin-x64': 1.18.0
616
+ '@vscode/ripgrep-linux-arm': 1.18.0
617
+ '@vscode/ripgrep-linux-arm64': 1.18.0
618
+ '@vscode/ripgrep-linux-ia32': 1.18.0
619
+ '@vscode/ripgrep-linux-ppc64': 1.18.0
620
+ '@vscode/ripgrep-linux-riscv64': 1.18.0
621
+ '@vscode/ripgrep-linux-s390x': 1.18.0
622
+ '@vscode/ripgrep-linux-x64': 1.18.0
623
+ '@vscode/ripgrep-win32-arm64': 1.18.0
624
+ '@vscode/ripgrep-win32-ia32': 1.18.0
625
+ '@vscode/ripgrep-win32-x64': 1.18.0
626
+
510
627
  accepts@2.0.0:
511
628
  dependencies:
512
629
  mime-types: 3.0.2
@@ -1,4 +1,5 @@
1
1
  import { createServer, type Server } from 'node:http';
2
+ import type { BridgeTurn } from '@ai-sdk/harness/bridge';
2
3
  import { ToolRelayAuthorizer, type ToolRelayCall } from './tool-relay-auth';
3
4
 
4
5
  export type ToolRelay = {
@@ -11,13 +12,13 @@ export async function startAuthorizedToolRelay({
11
12
  tools,
12
13
  emit,
13
14
  requestToolResult,
15
+ onWaitingChange,
14
16
  authorizer = new ToolRelayAuthorizer(),
15
17
  }: {
16
18
  tools: ReadonlyArray<{ name: string }>;
17
19
  emit: (message: Record<string, unknown>) => void;
18
- requestToolResult: (
19
- toolCallId: string,
20
- ) => Promise<{ output: unknown; isError?: boolean }>;
20
+ requestToolResult: BridgeTurn['requestToolResult'];
21
+ onWaitingChange?: (input: { requestId: string; waiting: boolean }) => void;
21
22
  authorizer?: ToolRelayAuthorizer;
22
23
  }): Promise<ToolRelay> {
23
24
  const toolNames = new Set(tools.map(tool => tool.name));
@@ -62,7 +63,10 @@ export async function startAuthorizedToolRelay({
62
63
  providerExecuted: false,
63
64
  });
64
65
 
65
- const { output, isError } = await requestToolResult(requestId);
66
+ onWaitingChange?.({ requestId, waiting: true });
67
+ const { output, isError, toolResult } = await requestToolResult(
68
+ requestId,
69
+ ).finally(() => onWaitingChange?.({ requestId, waiting: false }));
66
70
  emit({
67
71
  type: 'tool-result',
68
72
  toolCallId: requestId,
@@ -72,7 +76,13 @@ export async function startAuthorizedToolRelay({
72
76
  });
73
77
 
74
78
  res.writeHead(200, { 'Content-Type': 'application/json' });
75
- res.end(JSON.stringify({ result: output }));
79
+ res.end(
80
+ JSON.stringify({
81
+ result: output,
82
+ ...(isError != null ? { isError } : {}),
83
+ ...(toolResult != null ? { toolResult } : {}),
84
+ }),
85
+ );
76
86
  } catch (error) {
77
87
  res.writeHead(500, { 'Content-Type': 'application/json' });
78
88
  res.end(
@@ -9,17 +9,39 @@ import { z } from 'zod/v4';
9
9
  export const outboundMessageSchema = harnessV1BridgeOutboundMessageSchema;
10
10
  export type OutboundMessage = z.infer<typeof outboundMessageSchema>;
11
11
 
12
- export const startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
13
- operation: z.enum(['prompt', 'compact']).optional(),
14
- provider: z.string().optional(),
15
- variant: z.string().optional(),
16
- instructions: z.string().optional(),
17
- skillsChanged: z.boolean().optional(),
18
- resumeSessionId: z.string().optional(),
19
- openCodeConfig: z.record(z.string(), z.unknown()).optional(),
20
- mcpServers: z.record(z.string(), z.unknown()).optional(),
21
- headers: z.record(z.string(), z.string()).optional(),
22
- });
12
+ const openCodeBuiltinToolNameSchema = z.enum([
13
+ 'askUserQuestions',
14
+ 'read',
15
+ 'write',
16
+ 'edit',
17
+ 'bash',
18
+ 'glob',
19
+ 'grep',
20
+ 'ls',
21
+ 'webfetch',
22
+ 'skill',
23
+ 'todowrite',
24
+ 'agent',
25
+ ]);
26
+
27
+ export type OpenCodeBuiltinToolName = z.infer<
28
+ typeof openCodeBuiltinToolNameSchema
29
+ >;
30
+
31
+ export const startMessageSchema = harnessV1BridgeStartBaseSchema
32
+ .omit({ builtinToolFiltering: true })
33
+ .extend({
34
+ operation: z.enum(['prompt', 'compact']).optional(),
35
+ provider: z.string().optional(),
36
+ variant: z.string().optional(),
37
+ instructions: z.string().optional(),
38
+ skillsChanged: z.boolean().optional(),
39
+ resumeSessionId: z.string().optional(),
40
+ openCodeConfig: z.record(z.string(), z.unknown()).optional(),
41
+ mcpServers: z.record(z.string(), z.unknown()).optional(),
42
+ headers: z.record(z.string(), z.string()).optional(),
43
+ inactiveBuiltinToolNames: z.array(openCodeBuiltinToolNameSchema).optional(),
44
+ });
23
45
 
24
46
  export type StartMessage = z.infer<typeof startMessageSchema>;
25
47
 
@@ -4,6 +4,7 @@ import {
4
4
  HARNESS_V1_BUILTIN_TOOLS,
5
5
  HarnessCapabilityUnsupportedError,
6
6
  harnessV1DiagnosticFromBridgeFrame,
7
+ isHarnessV1BuiltinToolIncluded,
7
8
  type HarnessV1,
8
9
  type HarnessV1BuiltinTool,
9
10
  type HarnessV1BuiltinToolFiltering,
@@ -77,6 +78,7 @@ import {
77
78
  import {
78
79
  outboundMessageSchema,
79
80
  type InboundMessage,
81
+ type OpenCodeBuiltinToolName,
80
82
  type OutboundMessage,
81
83
  } from './opencode-bridge-protocol';
82
84
  import { VERSION } from './version';
@@ -242,7 +244,14 @@ const OPENCODE_BUILTIN_TOOLS = {
242
244
  metadata: optionalStringRecord,
243
245
  }),
244
246
  }),
245
- } as const satisfies Record<string, HarnessV1BuiltinTool<any, any>>;
247
+ } as const satisfies Record<
248
+ OpenCodeBuiltinToolName,
249
+ HarnessV1BuiltinTool<any, any>
250
+ >;
251
+
252
+ const OPENCODE_BUILTIN_TOOL_NAMES = Object.keys(
253
+ OPENCODE_BUILTIN_TOOLS,
254
+ ) as OpenCodeBuiltinToolName[];
246
255
 
247
256
  const openCodeBridgeCoordsSchema = z.object({
248
257
  port: z.number(),
@@ -275,9 +284,11 @@ export function createOpenCode(
275
284
  harnessId: 'opencode',
276
285
  builtinTools: OPENCODE_BUILTIN_TOOLS,
277
286
  supportsBuiltinToolApprovals: true,
287
+ supportsBuiltinToolFiltering: true,
278
288
  lifecycleStateSchema: openCodeResumeStateSchema,
279
289
  getBootstrap: getOpenCodeBootstrap,
280
290
  doStart: async startOpts => {
291
+ validateBuiltinToolFiltering(startOpts.builtinToolFiltering);
281
292
  const sandboxSession = startOpts.sandboxSession;
282
293
  const toolSafeSandboxSession =
283
294
  getRestrictedSandboxSession(sandboxSession);
@@ -672,6 +683,30 @@ export function createOpenCode(
672
683
  };
673
684
  }
674
685
 
686
+ function validateBuiltinToolFiltering(
687
+ toolFiltering: HarnessV1BuiltinToolFiltering | undefined,
688
+ ): void {
689
+ if (toolFiltering == null) return;
690
+ const isActive = (toolName: 'write' | 'edit') =>
691
+ isHarnessV1BuiltinToolIncluded({ toolName, toolFiltering });
692
+ if (isActive('write') !== isActive('edit')) {
693
+ throw new HarnessCapabilityUnsupportedError({
694
+ harnessId: 'opencode',
695
+ message:
696
+ "OpenCode built-in filtering requires 'write' and 'edit' to either both be active or both be inactive.",
697
+ });
698
+ }
699
+ }
700
+
701
+ function resolveInactiveBuiltinToolNames(
702
+ toolFiltering: HarnessV1BuiltinToolFiltering | undefined,
703
+ ): OpenCodeBuiltinToolName[] | undefined {
704
+ if (toolFiltering == null) return undefined;
705
+ return OPENCODE_BUILTIN_TOOL_NAMES.filter(
706
+ toolName => !isHarnessV1BuiltinToolIncluded({ toolName, toolFiltering }),
707
+ );
708
+ }
709
+
675
710
  function resolveBridgePort({
676
711
  sandboxSession,
677
712
  override,
@@ -931,7 +966,10 @@ function createSession({
931
966
  let selectedModel: string | undefined;
932
967
  let activeTurn = false;
933
968
  let pendingTurnDrain: Promise<void> = Promise.resolve();
969
+ let abortedTurnDrain: Promise<void> = Promise.resolve();
934
970
  const pendingCompactionParts: HarnessV1StreamPart[] = [];
971
+ const inactiveBuiltinToolNames =
972
+ resolveInactiveBuiltinToolNames(builtinToolFiltering);
935
973
 
936
974
  channel.on('bridge-thread', msg => {
937
975
  latestOpenCodeSessionId = msg.threadId;
@@ -1066,6 +1104,7 @@ function createSession({
1066
1104
  new DOMException('Aborted', 'AbortError');
1067
1105
  isSettled = true;
1068
1106
  drainingAfterAbort = true;
1107
+ abortedTurnDrain = turnDrain;
1069
1108
  userMessageSubmitter?.close(error);
1070
1109
  pendingReject!(error);
1071
1110
  };
@@ -1122,7 +1161,7 @@ function createSession({
1122
1161
  ...(mcpServers == null ? {} : { mcpServers }),
1123
1162
  ...(headers == null ? {} : { headers }),
1124
1163
  ...(permissionMode ? { permissionMode } : {}),
1125
- ...(builtinToolFiltering ? { builtinToolFiltering } : {}),
1164
+ ...(inactiveBuiltinToolNames == null ? {} : { inactiveBuiltinToolNames }),
1126
1165
  ...(pendingResumeSessionId
1127
1166
  ? { resumeSessionId: pendingResumeSessionId }
1128
1167
  : latestOpenCodeSessionId
@@ -1140,7 +1179,6 @@ function createSession({
1140
1179
  control: HarnessV1PromptControl;
1141
1180
  skillWriteResult: WriteSkillsResult;
1142
1181
  }> => {
1143
- await pendingTurnDrain;
1144
1182
  if (
1145
1183
  opts.responseFormat?.type === 'json' &&
1146
1184
  opts.responseFormat.schema == null
@@ -1173,6 +1211,7 @@ function createSession({
1173
1211
  sessionId,
1174
1212
  isResume,
1175
1213
  doPromptTurn: async promptOpts => {
1214
+ await pendingTurnDrain;
1176
1215
  const { control, skillWriteResult } = await prepareTurn(promptOpts);
1177
1216
  const turnModel = promptOpts.model ?? selectedModel;
1178
1217
  if (turnModel) selectedModel = turnModel;
@@ -1195,11 +1234,14 @@ function createSession({
1195
1234
  ...startBase(turnModel),
1196
1235
  });
1197
1236
  pendingResumeSessionId = undefined;
1237
+ rerunContinue = false;
1198
1238
  return control;
1199
1239
  },
1200
1240
  doContinueTurn: async continueOpts => {
1241
+ await abortedTurnDrain;
1201
1242
  const { control, skillWriteResult } = await prepareTurn(continueOpts);
1202
1243
  if (rerunContinue) {
1244
+ rerunContinue = false;
1203
1245
  const turnModel = continueOpts.model ?? selectedModel;
1204
1246
  if (turnModel) selectedModel = turnModel;
1205
1247
  channel.send({
@@ -1248,6 +1290,7 @@ function createSession({
1248
1290
  provider,
1249
1291
  permissionMode,
1250
1292
  debug,
1293
+ inactiveBuiltinToolNames,
1251
1294
  openCodeConfig,
1252
1295
  mcpServers,
1253
1296
  headers,
@@ -1422,6 +1465,7 @@ async function runCompactOperation({
1422
1465
  provider,
1423
1466
  permissionMode,
1424
1467
  debug,
1468
+ inactiveBuiltinToolNames,
1425
1469
  openCodeConfig,
1426
1470
  mcpServers,
1427
1471
  headers,
@@ -1433,6 +1477,7 @@ async function runCompactOperation({
1433
1477
  provider: string | undefined;
1434
1478
  permissionMode: HarnessV1PermissionMode | undefined;
1435
1479
  debug: HarnessV1DebugConfig | undefined;
1480
+ inactiveBuiltinToolNames: OpenCodeBuiltinToolName[] | undefined;
1436
1481
  openCodeConfig: Record<string, unknown> | undefined;
1437
1482
  mcpServers: Record<string, unknown> | undefined;
1438
1483
  headers: Readonly<Record<string, string>> | undefined;
@@ -1467,6 +1512,7 @@ async function runCompactOperation({
1467
1512
  ...(mcpServers == null ? {} : { mcpServers }),
1468
1513
  ...(headers == null ? {} : { headers }),
1469
1514
  ...(permissionMode ? { permissionMode } : {}),
1515
+ ...(inactiveBuiltinToolNames == null ? {} : { inactiveBuiltinToolNames }),
1470
1516
  ...(resumeSessionId ? { resumeSessionId } : {}),
1471
1517
  ...(debug ? { debug } : {}),
1472
1518
  });