@ai-sdk/harness 1.0.133 → 1.0.135

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,10 +1,9 @@
1
- import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
- import { Experimental_SandboxSession, UserModelMessage, ToolResultPart, ProviderOptions, ToolSet, FlexibleSchema, Tool, Context, InferToolSetContext, SystemModelMessage, MaybePromiseLike, Arrayable, ToolApprovalResponse, ModelMessage } from '@ai-sdk/provider-utils';
3
- import { ToolsContextSettings } from 'ai/internal';
4
- import { OutputInterface, AgentCallParameters, Prompt, StopCondition, GenerateTextOnStartCallback, GenerateTextOnStepStartCallback, OnLanguageModelCallStartCallback, OnLanguageModelCallEndCallback, OnToolExecutionStartCallback, OnToolExecutionEndCallback, GenerateTextOnStepEndCallback, GenerateTextOnEndCallback, ToolApprovalStatus, TelemetryOptions, ActiveTools, StreamTextResult, Agent, GenerateTextResult, AgentStreamParameters, Telemetry } from 'ai';
5
- import { z } from 'zod/v4';
6
- import { JSONSchema7, JSONValue, LanguageModelV4StreamPart, LanguageModelV4ToolCall, LanguageModelV4ToolApprovalRequest, LanguageModelV4ToolResult, LanguageModelV4FinishReason, LanguageModelV4Usage, LanguageModelV4TextPart, LanguageModelV4FilePart, LanguageModelV4CustomPart, LanguageModelV4ReasoningPart, LanguageModelV4ReasoningFilePart, LanguageModelV4ToolCallPart, LanguageModelV4ToolResultPart, LanguageModelV4ToolResultOutput, LanguageModelV4ToolApprovalResponsePart, AISDKError } from '@ai-sdk/provider';
7
-
1
+ import { AISDKError, JSONSchema7, JSONValue, LanguageModelV4CustomPart, LanguageModelV4FilePart, LanguageModelV4FinishReason, LanguageModelV4ReasoningFilePart, LanguageModelV4ReasoningPart, LanguageModelV4StreamPart, LanguageModelV4TextPart, LanguageModelV4ToolApprovalRequest, LanguageModelV4ToolApprovalResponsePart, LanguageModelV4ToolCall, LanguageModelV4ToolCallPart, LanguageModelV4ToolResult, LanguageModelV4ToolResultOutput, LanguageModelV4ToolResultPart, LanguageModelV4Usage } from "@ai-sdk/provider";
2
+ import { Arrayable, Context, Experimental_SandboxSession, FlexibleSchema, InferToolSetContext, MaybePromiseLike, ModelMessage, ProviderOptions, SystemModelMessage, Tool, ToolApprovalResponse, ToolResultPart, ToolSet, UserModelMessage } from "@ai-sdk/provider-utils";
3
+ import { z } from "zod/v4";
4
+ import { ToolsContextSettings } from "ai/internal";
5
+ import { ActiveTools, Agent, AgentCallParameters, AgentStreamParameters, GenerateTextOnEndCallback, GenerateTextOnStartCallback, GenerateTextOnStepEndCallback, GenerateTextOnStepStartCallback, GenerateTextResult, OnLanguageModelCallEndCallback, OnLanguageModelCallStartCallback, OnToolExecutionEndCallback, OnToolExecutionStartCallback, OutputInterface, Prompt, StopCondition, StreamTextResult, Telemetry, TelemetryOptions, ToolApprovalStatus } from "ai";
6
+ //#region src/v1/harness-v1-bootstrap.d.ts
8
7
  /**
9
8
  * One file to write into the sandbox as part of an adapter's bootstrap recipe.
10
9
  * Absolute paths are used as-is. Relative paths are resolved against the
@@ -12,8 +11,8 @@ import { JSONSchema7, JSONValue, LanguageModelV4StreamPart, LanguageModelV4ToolC
12
11
  * {@link HarnessV1Bootstrap.bootstrapDir}.
13
12
  */
14
13
  interface HarnessV1BootstrapFile {
15
- readonly path: string;
16
- readonly content: string;
14
+ readonly path: string;
15
+ readonly content: string;
17
16
  }
18
17
  /**
19
18
  * One command to run in the sandbox as part of an adapter's bootstrap recipe.
@@ -21,7 +20,7 @@ interface HarnessV1BootstrapFile {
21
20
  * aborts the bootstrap.
22
21
  */
23
22
  interface HarnessV1BootstrapCommand {
24
- readonly command: string;
23
+ readonly command: string;
25
24
  }
26
25
  /**
27
26
  * Adapter-owned bootstrap recipe. The adapter declares the files and commands
@@ -30,32 +29,33 @@ interface HarnessV1BootstrapCommand {
30
29
  * reuse, and applies the recipe idempotently before the bridge spawns.
31
30
  */
32
31
  interface HarnessV1Bootstrap {
33
- /**
34
- * Stable id of the adapter that owns this recipe. Conventionally matches
35
- * {@link HarnessV1.harnessId}. Contributes to the recipe hash.
36
- */
37
- readonly harnessId: string;
38
- /**
39
- * Path inside the sandbox where this recipe writes its state. Absolute paths
40
- * are used as-is. Relative paths are resolved against the harness state
41
- * directory (`$HOME/.ai-sdk-harness`). The marker file lives directly under
42
- * it. Files declared in {@link files} should also use this prefix so an
43
- * adapter upgrade can sweep stale state by clearing the directory.
44
- */
45
- readonly bootstrapDir: string;
46
- /** Files to write into the sandbox before any command runs. */
47
- readonly files: ReadonlyArray<HarnessV1BootstrapFile>;
48
- /** Commands to run from the bootstrap directory after files are written. */
49
- readonly commands: ReadonlyArray<HarnessV1BootstrapCommand>;
32
+ /**
33
+ * Stable id of the adapter that owns this recipe. Conventionally matches
34
+ * {@link HarnessV1.harnessId}. Contributes to the recipe hash.
35
+ */
36
+ readonly harnessId: string;
37
+ /**
38
+ * Path inside the sandbox where this recipe writes its state. Absolute paths
39
+ * are used as-is. Relative paths are resolved against the harness state
40
+ * directory (`$HOME/.ai-sdk-harness`). The marker file lives directly under
41
+ * it. Files declared in {@link files} should also use this prefix so an
42
+ * adapter upgrade can sweep stale state by clearing the directory.
43
+ */
44
+ readonly bootstrapDir: string;
45
+ /** Files to write into the sandbox before any command runs. */
46
+ readonly files: ReadonlyArray<HarnessV1BootstrapFile>;
47
+ /** Commands to run from the bootstrap directory after files are written. */
48
+ readonly commands: ReadonlyArray<HarnessV1BootstrapCommand>;
50
49
  }
51
-
50
+ //#endregion
51
+ //#region src/v1/harness-v1-network-sandbox-session.d.ts
52
52
  /**
53
53
  * Connection details for a sandbox-exposed port. Headers are scoped to the
54
54
  * returned URL and must be included when opening the connection.
55
55
  */
56
56
  type HarnessV1PortEndpoint = {
57
- readonly url: string;
58
- readonly headers?: Readonly<Record<string, string>>;
57
+ readonly url: string;
58
+ readonly headers?: Readonly<Record<string, string>>;
59
59
  };
60
60
  /**
61
61
  * Network sandbox session returned by sandbox adapter creation and resume
@@ -69,94 +69,94 @@ type HarnessV1PortEndpoint = {
69
69
  * network access, or transform requests.
70
70
  */
71
71
  interface HarnessV1NetworkSandboxSession extends Experimental_SandboxSession {
72
- /**
73
- * Identifier for the sandbox session. Persist this separately from the
74
- * harness session ID and resume state when reattaching across processes.
75
- */
76
- readonly id: string;
77
- /**
78
- * The sandbox's default working directory — the absolute path that
79
- * `run`/`spawn` resolve relative commands against when no `workingDirectory`
80
- * is given. Read from the live sandbox, never hardcoded.
81
- *
82
- * The framework composes each session's working directory underneath this
83
- * path (`<defaultWorkingDirectory>/<harnessId>-<sessionId>`) so adapters do
84
- * not bake a provider-specific base into their own paths.
85
- */
86
- readonly defaultWorkingDirectory: string;
87
- /** Ports the sandbox exposes; resolvable via `getPortEndpoint`. */
88
- readonly ports: ReadonlyArray<number>;
89
- /**
90
- * Resolve the connection details for a sandbox-exposed port. Bridge-backed
91
- * adapters call this to open their WebSocket to the in-sandbox bridge.
92
- */
93
- readonly getPortEndpoint: (options: {
94
- port: number;
95
- protocol?: 'http' | 'https' | 'ws';
96
- }) => PromiseLike<HarnessV1PortEndpoint>;
97
- /**
98
- * Resolve a publicly-reachable URL for a sandbox-exposed port.
99
- *
100
- * @deprecated Use `getPortEndpoint` instead.
101
- */
102
- readonly getPortUrl: (options: {
103
- port: number;
104
- protocol?: 'http' | 'https' | 'ws';
105
- }) => PromiseLike<string>;
106
- /** Stop the sandbox. Idempotent. */
107
- readonly stop: () => PromiseLike<void>;
108
- /**
109
- * Stop the sandbox session, then perform any additional cleanup necessary
110
- * to destroy it, such as deleting its backing resource or freeing resources.
111
- * Implementations with no cleanup beyond stopping may delegate to `stop()`.
112
- * Implementations must handle both a still-running sandbox and a previously
113
- * stopped sandbox.
114
- */
115
- readonly destroy: () => PromiseLike<void>;
116
- /**
117
- * Update the sandbox's outbound network policy. Optional — implementations
118
- * without a local enforcement primitive omit this. Callers
119
- * use optional-call (`sandboxSession.setNetworkPolicy?.(policy)`); a
120
- * missing implementation is a no-op.
121
- */
122
- readonly setNetworkPolicy?: (policy: HarnessV1NetworkPolicy) => PromiseLike<void>;
123
- /**
124
- * Replace the sandbox's outbound request-transformation rules. Optional —
125
- * implementations expose this only when credentials can be injected outside
126
- * the sandbox security boundary. Calling this method assumes authority over
127
- * the complete transformation set; harness adapters should normally use
128
- * `addRequestTransformations` instead. Adapters may preserve legacy
129
- * credential-forwarding behavior when additive request transformations are
130
- * unavailable.
131
- */
132
- readonly setRequestTransformations?: (transformations: ReadonlyArray<HarnessV1RequestTransformation>) => PromiseLike<void>;
133
- /**
134
- * Add outbound request-transformation rules without replacing rules already
135
- * managed by the sandbox session. Optional for the same reason as
136
- * `setRequestTransformations`. Harness adapters should use this additive
137
- * capability unless they explicitly own the complete transformation set.
138
- */
139
- readonly addRequestTransformations?: (transformations: ReadonlyArray<HarnessV1RequestTransformation>) => PromiseLike<void>;
140
- /**
141
- * Replace the set of ports exposed by the sandbox. Full-replacement
142
- * semantics: ports omitted from the array are deregistered. Optional —
143
- * implementations that cannot expose ports omit this.
144
- */
145
- readonly setPorts?: (ports: ReadonlyArray<number>, options?: {
146
- abortSignal?: AbortSignal;
147
- }) => PromiseLike<void>;
148
- /**
149
- * Reduced view of this session, typed as the bare {@link SandboxSession}
150
- * (file I/O, exec, spawn) — nothing that could stop the sandbox or change
151
- * its network policy. Pass this to user-tool `execute()` calls and other
152
- * code that must not reach the infra surface.
153
- *
154
- * The returned object points at exactly the same underlying sandbox
155
- * resource as the network sandbox session it was produced from; it is only a
156
- * narrower surface over the same resource, not a separate sandbox. In
157
- * particular, it cannot mutate network access or request transformations.
158
- */
159
- readonly restricted: () => Experimental_SandboxSession;
72
+ /**
73
+ * Identifier for the sandbox session. Persist this separately from the
74
+ * harness session ID and resume state when reattaching across processes.
75
+ */
76
+ readonly id: string;
77
+ /**
78
+ * The sandbox's default working directory — the absolute path that
79
+ * `run`/`spawn` resolve relative commands against when no `workingDirectory`
80
+ * is given. Read from the live sandbox, never hardcoded.
81
+ *
82
+ * The framework composes each session's working directory underneath this
83
+ * path (`<defaultWorkingDirectory>/<harnessId>-<sessionId>`) so adapters do
84
+ * not bake a provider-specific base into their own paths.
85
+ */
86
+ readonly defaultWorkingDirectory: string;
87
+ /** Ports the sandbox exposes; resolvable via `getPortEndpoint`. */
88
+ readonly ports: ReadonlyArray<number>;
89
+ /**
90
+ * Resolve the connection details for a sandbox-exposed port. Bridge-backed
91
+ * adapters call this to open their WebSocket to the in-sandbox bridge.
92
+ */
93
+ readonly getPortEndpoint: (options: {
94
+ port: number;
95
+ protocol?: 'http' | 'https' | 'ws';
96
+ }) => PromiseLike<HarnessV1PortEndpoint>;
97
+ /**
98
+ * Resolve a publicly-reachable URL for a sandbox-exposed port.
99
+ *
100
+ * @deprecated Use `getPortEndpoint` instead.
101
+ */
102
+ readonly getPortUrl: (options: {
103
+ port: number;
104
+ protocol?: 'http' | 'https' | 'ws';
105
+ }) => PromiseLike<string>;
106
+ /** Stop the sandbox. Idempotent. */
107
+ readonly stop: () => PromiseLike<void>;
108
+ /**
109
+ * Stop the sandbox session, then perform any additional cleanup necessary
110
+ * to destroy it, such as deleting its backing resource or freeing resources.
111
+ * Implementations with no cleanup beyond stopping may delegate to `stop()`.
112
+ * Implementations must handle both a still-running sandbox and a previously
113
+ * stopped sandbox.
114
+ */
115
+ readonly destroy: () => PromiseLike<void>;
116
+ /**
117
+ * Update the sandbox's outbound network policy. Optional — implementations
118
+ * without a local enforcement primitive omit this. Callers
119
+ * use optional-call (`sandboxSession.setNetworkPolicy?.(policy)`); a
120
+ * missing implementation is a no-op.
121
+ */
122
+ readonly setNetworkPolicy?: (policy: HarnessV1NetworkPolicy) => PromiseLike<void>;
123
+ /**
124
+ * Replace the sandbox's outbound request-transformation rules. Optional —
125
+ * implementations expose this only when credentials can be injected outside
126
+ * the sandbox security boundary. Calling this method assumes authority over
127
+ * the complete transformation set; harness adapters should normally use
128
+ * `addRequestTransformations` instead. Adapters may preserve legacy
129
+ * credential-forwarding behavior when additive request transformations are
130
+ * unavailable.
131
+ */
132
+ readonly setRequestTransformations?: (transformations: ReadonlyArray<HarnessV1RequestTransformation>) => PromiseLike<void>;
133
+ /**
134
+ * Add outbound request-transformation rules without replacing rules already
135
+ * managed by the sandbox session. Optional for the same reason as
136
+ * `setRequestTransformations`. Harness adapters should use this additive
137
+ * capability unless they explicitly own the complete transformation set.
138
+ */
139
+ readonly addRequestTransformations?: (transformations: ReadonlyArray<HarnessV1RequestTransformation>) => PromiseLike<void>;
140
+ /**
141
+ * Replace the set of ports exposed by the sandbox. Full-replacement
142
+ * semantics: ports omitted from the array are deregistered. Optional —
143
+ * implementations that cannot expose ports omit this.
144
+ */
145
+ readonly setPorts?: (ports: ReadonlyArray<number>, options?: {
146
+ abortSignal?: AbortSignal;
147
+ }) => PromiseLike<void>;
148
+ /**
149
+ * Reduced view of this session, typed as the bare {@link SandboxSession}
150
+ * (file I/O, exec, spawn) — nothing that could stop the sandbox or change
151
+ * its network policy. Pass this to user-tool `execute()` calls and other
152
+ * code that must not reach the infra surface.
153
+ *
154
+ * The returned object points at exactly the same underlying sandbox
155
+ * resource as the network sandbox session it was produced from; it is only a
156
+ * narrower surface over the same resource, not a separate sandbox. In
157
+ * particular, it cannot mutate network access or request transformations.
158
+ */
159
+ readonly restricted: () => Experimental_SandboxSession;
160
160
  }
161
161
  /**
162
162
  * Outbound network policy applied by the sandbox runtime.
@@ -174,37 +174,37 @@ interface HarnessV1NetworkSandboxSession extends Experimental_SandboxSession {
174
174
  * equivalent to `'deny-all'`.
175
175
  */
176
176
  type HarnessV1NetworkPolicy = {
177
- mode: 'allow-all';
177
+ mode: 'allow-all';
178
178
  } | {
179
- mode: 'deny-all';
179
+ mode: 'deny-all';
180
180
  } | {
181
- mode: 'custom';
182
- allowedHosts: ReadonlyArray<string>;
183
- allowedCIDRs?: ReadonlyArray<string>;
184
- deniedCIDRs?: ReadonlyArray<string>;
181
+ mode: 'custom';
182
+ allowedHosts: ReadonlyArray<string>;
183
+ allowedCIDRs?: ReadonlyArray<string>;
184
+ deniedCIDRs?: ReadonlyArray<string>;
185
185
  } | {
186
- mode: 'custom';
187
- allowedHosts?: ReadonlyArray<string>;
188
- allowedCIDRs: ReadonlyArray<string>;
189
- deniedCIDRs?: ReadonlyArray<string>;
186
+ mode: 'custom';
187
+ allowedHosts?: ReadonlyArray<string>;
188
+ allowedCIDRs: ReadonlyArray<string>;
189
+ deniedCIDRs?: ReadonlyArray<string>;
190
190
  };
191
191
  type HarnessV1RequestTransformationPathMatcher = {
192
- exact: string;
192
+ exact: string;
193
193
  } | {
194
- startsWith: string;
194
+ startsWith: string;
195
195
  } | {
196
- regex: string;
196
+ regex: string;
197
197
  };
198
198
  type HarnessV1RequestTransformationKeyValuePartMatcher = {
199
- exact: string;
199
+ exact: string;
200
200
  } | {
201
- startsWith: string;
201
+ startsWith: string;
202
202
  } | {
203
- regex: string;
203
+ regex: string;
204
204
  };
205
205
  type HarnessV1RequestTransformationKeyValueMatcher = {
206
- readonly key?: HarnessV1RequestTransformationKeyValuePartMatcher;
207
- readonly value?: HarnessV1RequestTransformationKeyValuePartMatcher;
206
+ readonly key?: HarnessV1RequestTransformationKeyValuePartMatcher;
207
+ readonly value?: HarnessV1RequestTransformationKeyValuePartMatcher;
208
208
  };
209
209
  /**
210
210
  * Outbound HTTPS request transformation applied outside the sandbox security
@@ -218,25 +218,26 @@ type HarnessV1RequestTransformationKeyValueMatcher = {
218
218
  * making transformed values available inside it.
219
219
  */
220
220
  type HarnessV1RequestTransformation = {
221
- readonly match: {
222
- readonly host: string;
223
- readonly path?: HarnessV1RequestTransformationPathMatcher;
224
- readonly method?: ReadonlyArray<string>;
225
- readonly queryString?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;
226
- readonly headers?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;
227
- };
228
- readonly transform: {
229
- readonly headers: Readonly<Record<string, string>>;
230
- };
221
+ readonly match: {
222
+ readonly host: string;
223
+ readonly path?: HarnessV1RequestTransformationPathMatcher;
224
+ readonly method?: ReadonlyArray<string>;
225
+ readonly queryString?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;
226
+ readonly headers?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;
227
+ };
228
+ readonly transform: {
229
+ readonly headers: Readonly<Record<string, string>>;
230
+ };
231
231
  };
232
-
232
+ //#endregion
233
+ //#region src/v1/harness-v1-diagnostic.d.ts
233
234
  /** Severity of a diagnostic, ordered most → least severe. */
234
235
  declare const harnessV1DebugLevelSchema: z.ZodEnum<{
235
- error: "error";
236
- warn: "warn";
237
- info: "info";
238
- debug: "debug";
239
- trace: "trace";
236
+ error: "error";
237
+ warn: "warn";
238
+ info: "info";
239
+ debug: "debug";
240
+ trace: "trace";
240
241
  }>;
241
242
  type HarnessV1DebugLevel = z.infer<typeof harnessV1DebugLevelSchema>;
242
243
  /**
@@ -246,15 +247,15 @@ type HarnessV1DebugLevel = z.infer<typeof harnessV1DebugLevelSchema>;
246
247
  * prefix; console capture is independent of the subsystem filter.
247
248
  */
248
249
  declare const harnessV1DebugConfigSchema: z.ZodObject<{
249
- enabled: z.ZodOptional<z.ZodBoolean>;
250
- level: z.ZodOptional<z.ZodEnum<{
251
- error: "error";
252
- warn: "warn";
253
- info: "info";
254
- debug: "debug";
255
- trace: "trace";
256
- }>>;
257
- subsystems: z.ZodOptional<z.ZodArray<z.ZodString>>;
250
+ enabled: z.ZodOptional<z.ZodBoolean>;
251
+ level: z.ZodOptional<z.ZodEnum<{
252
+ error: "error";
253
+ warn: "warn";
254
+ info: "info";
255
+ debug: "debug";
256
+ trace: "trace";
257
+ }>>;
258
+ subsystems: z.ZodOptional<z.ZodArray<z.ZodString>>;
258
259
  }, z.core.$strip>;
259
260
  type HarnessV1DebugConfig = z.infer<typeof harnessV1DebugConfigSchema>;
260
261
  /**
@@ -263,32 +264,33 @@ type HarnessV1DebugConfig = z.infer<typeof harnessV1DebugConfigSchema>;
263
264
  * emission shape, that is the external consumption shape.
264
265
  */
265
266
  type HarnessV1Diagnostic = {
266
- /** Severity. */
267
- readonly level: HarnessV1DebugLevel;
268
- /** Human-readable line (console capture) or message (structured event). */
269
- readonly message: string;
270
- /** Dotted subsystem (`sandbox.log.<source>` for console capture). */
271
- readonly subsystem: string;
272
- /** `'log'` = captured console line; `'event'` = structured emission. */
273
- readonly kind: 'log' | 'event';
274
- /** Originating source label (console capture). */
275
- readonly source?: string;
276
- /** Which standard stream the line came from (console capture). */
277
- readonly stream?: 'stdout' | 'stderr';
278
- /** Structured attributes (structured events only). */
279
- readonly attrs?: Record<string, unknown>;
280
- /** Error payload (structured events only). */
281
- readonly error?: {
282
- name?: string;
283
- message: string;
284
- stack?: string;
285
- };
286
- /** The harness session this diagnostic originated from. */
287
- readonly sessionId?: string;
288
- /** Emission time (epoch ms). */
289
- readonly timestamp: number;
267
+ /** Severity. */
268
+ readonly level: HarnessV1DebugLevel;
269
+ /** Human-readable line (console capture) or message (structured event). */
270
+ readonly message: string;
271
+ /** Dotted subsystem (`sandbox.log.<source>` for console capture). */
272
+ readonly subsystem: string;
273
+ /** `'log'` = captured console line; `'event'` = structured emission. */
274
+ readonly kind: 'log' | 'event';
275
+ /** Originating source label (console capture). */
276
+ readonly source?: string;
277
+ /** Which standard stream the line came from (console capture). */
278
+ readonly stream?: 'stdout' | 'stderr';
279
+ /** Structured attributes (structured events only). */
280
+ readonly attrs?: Record<string, unknown>;
281
+ /** Error payload (structured events only). */
282
+ readonly error?: {
283
+ name?: string;
284
+ message: string;
285
+ stack?: string;
286
+ };
287
+ /** The harness session this diagnostic originated from. */
288
+ readonly sessionId?: string;
289
+ /** Emission time (epoch ms). */
290
+ readonly timestamp: number;
290
291
  };
291
-
292
+ //#endregion
293
+ //#region src/v1/harness-v1-observability.d.ts
292
294
  /**
293
295
  * Diagnostics wiring the framework hands to an adapter's `doStart`. `report` is
294
296
  * the general emission sink: a bridge adapter normalizes each wire frame into a
@@ -298,12 +300,13 @@ type HarnessV1Diagnostic = {
298
300
  * Absent when the consumer has not enabled diagnostics.
299
301
  */
300
302
  type HarnessV1Observability = {
301
- /** Per-session debug config gating what the adapter captures/emits. */
302
- readonly debug?: HarnessV1DebugConfig;
303
- /** General emission sink — any adapter reports a `HarnessV1Diagnostic` here. */
304
- readonly report?: (diagnostic: HarnessV1Diagnostic) => void;
303
+ /** Per-session debug config gating what the adapter captures/emits. */
304
+ readonly debug?: HarnessV1DebugConfig;
305
+ /** General emission sink — any adapter reports a `HarnessV1Diagnostic` here. */
306
+ readonly report?: (diagnostic: HarnessV1Diagnostic) => void;
305
307
  };
306
-
308
+ //#endregion
309
+ //#region src/v1/harness-v1-permission-mode.d.ts
307
310
  /**
308
311
  * Baseline permission mode for adapter-native built-in tools.
309
312
  *
@@ -312,7 +315,8 @@ type HarnessV1Observability = {
312
315
  * status map.
313
316
  */
314
317
  type HarnessV1PermissionMode = 'allow-reads' | 'allow-edits' | 'allow-all';
315
-
318
+ //#endregion
319
+ //#region src/v1/harness-v1-prompt.d.ts
316
320
  /**
317
321
  * Prompt shape passed to `HarnessV1Session.doPromptTurn`.
318
322
  *
@@ -322,7 +326,8 @@ type HarnessV1PermissionMode = 'allow-reads' | 'allow-edits' | 'allow-all';
322
326
  * `UserModelMessage`.
323
327
  */
324
328
  type HarnessV1Prompt = string | UserModelMessage;
325
-
329
+ //#endregion
330
+ //#region src/v1/harness-v1-prompt-control.d.ts
326
331
  /**
327
332
  * Bidirectional control surface returned by `doPromptTurn`.
328
333
  *
@@ -333,41 +338,41 @@ type HarnessV1Prompt = string | UserModelMessage;
333
338
  * messages require `submitUserMessage`).
334
339
  */
335
340
  type HarnessV1PromptControl = {
336
- /**
337
- * Provide a result for a `tool-call` the adapter emitted. The adapter
338
- * forwards the result to the underlying runtime so the model can continue.
339
- */
340
- submitToolResult(input: {
341
- toolCallId: string;
342
- output: unknown;
343
- isError?: boolean;
344
- toolResult?: ToolResultPart;
345
- }): PromiseLike<void>;
346
- /**
347
- * Respond to a `tool-approval-request` the adapter emitted.
348
- */
349
- submitToolApproval?(input: {
350
- approvalId: string;
351
- approved: boolean;
352
- reason?: string;
353
- }): PromiseLike<void>;
354
- /**
355
- * Inject a fresh user message into a turn that is still in flight.
356
- * Supported only by runtimes that accept interactive input.
357
- */
358
- submitUserMessage?(text: string): PromiseLike<void>;
359
- /**
360
- * Resolves when the adapter has finished the turn (success or failure).
361
- * Rejects with the underlying error when the turn fails.
362
- */
363
- readonly done: PromiseLike<void>;
341
+ /**
342
+ * Provide a result for a `tool-call` the adapter emitted. The adapter
343
+ * forwards the result to the underlying runtime so the model can continue.
344
+ */
345
+ submitToolResult(input: {
346
+ toolCallId: string;
347
+ output: unknown;
348
+ isError?: boolean;
349
+ toolResult?: ToolResultPart;
350
+ }): PromiseLike<void>;
351
+ /**
352
+ * Respond to a `tool-approval-request` the adapter emitted.
353
+ */
354
+ submitToolApproval?(input: {
355
+ approvalId: string;
356
+ approved: boolean;
357
+ reason?: string;
358
+ }): PromiseLike<void>;
359
+ /**
360
+ * Inject a fresh user message into a turn that is still in flight.
361
+ * Supported only by runtimes that accept interactive input.
362
+ */
363
+ submitUserMessage?(text: string): PromiseLike<void>;
364
+ /**
365
+ * Resolves when the adapter has finished the turn (success or failure).
366
+ * Rejects with the underlying error when the turn fails.
367
+ */
368
+ readonly done: PromiseLike<void>;
364
369
  };
365
-
370
+ //#endregion
371
+ //#region src/v1/harness-v1-response-format.d.ts
366
372
  type HarnessV1JSONValue = null | boolean | number | string | HarnessV1JSONArray | HarnessV1JSONObject;
367
- interface HarnessV1JSONArray extends Array<HarnessV1JSONValue> {
368
- }
373
+ interface HarnessV1JSONArray extends Array<HarnessV1JSONValue> {}
369
374
  interface HarnessV1JSONObject {
370
- [key: string]: HarnessV1JSONValue | undefined;
375
+ [key: string]: HarnessV1JSONValue | undefined;
371
376
  }
372
377
  type HarnessV1JSONSchema = HarnessV1JSONObject;
373
378
  /**
@@ -379,46 +384,48 @@ type HarnessV1JSONSchema = HarnessV1JSONObject;
379
384
  * contract can cross process and package boundaries.
380
385
  */
381
386
  type HarnessV1ResponseFormat = {
382
- readonly type: 'text';
387
+ readonly type: 'text';
383
388
  } | {
384
- readonly type: 'json';
385
- readonly schema?: HarnessV1JSONSchema;
386
- readonly name?: string;
387
- readonly description?: string;
389
+ readonly type: 'json';
390
+ readonly schema?: HarnessV1JSONSchema;
391
+ readonly name?: string;
392
+ readonly description?: string;
388
393
  };
389
-
394
+ //#endregion
395
+ //#region src/v1/harness-v1-skill.d.ts
390
396
  /**
391
397
  * A self-contained instruction bundle the underlying runtime can load into
392
398
  * its context. Adapters decide how to surface skills to the runtime.
393
399
  */
394
400
  type HarnessV1Skill = {
395
- /** Stable identifier for the skill (kebab-case slug). */
396
- readonly name: string;
397
- /**
398
- * Short, model-facing description. This is what the runtime sees to
399
- * decide whether the skill is relevant.
400
- */
401
- readonly description: string;
402
- /** Full skill content the model loads when the skill is active. */
403
- readonly content: string;
404
- /**
405
- * Additional files that belong to this skill. Adapters with native skill
406
- * directories materialize these next to `SKILL.md`; adapters without native
407
- * skill files include them with the skill content.
408
- */
409
- readonly files?: ReadonlyArray<HarnessV1SkillFile>;
401
+ /** Stable identifier for the skill (kebab-case slug). */
402
+ readonly name: string;
403
+ /**
404
+ * Short, model-facing description. This is what the runtime sees to
405
+ * decide whether the skill is relevant.
406
+ */
407
+ readonly description: string;
408
+ /** Full skill content the model loads when the skill is active. */
409
+ readonly content: string;
410
+ /**
411
+ * Additional files that belong to this skill. Adapters with native skill
412
+ * directories materialize these next to `SKILL.md`; adapters without native
413
+ * skill files include them with the skill content.
414
+ */
415
+ readonly files?: ReadonlyArray<HarnessV1SkillFile>;
410
416
  };
411
417
  type HarnessV1SkillFile = {
412
- /**
413
- * Skill-relative POSIX path, for example `reference.md` or
414
- * `references/codes.md`. Absolute paths and `..` segments are rejected by
415
- * adapters before writing.
416
- */
417
- readonly path: string;
418
- /** UTF-8 text content for the file. */
419
- readonly content: string;
418
+ /**
419
+ * Skill-relative POSIX path, for example `reference.md` or
420
+ * `references/codes.md`. Absolute paths and `..` segments are rejected by
421
+ * adapters before writing.
422
+ */
423
+ readonly path: string;
424
+ /** UTF-8 text content for the file. */
425
+ readonly content: string;
420
426
  };
421
-
427
+ //#endregion
428
+ //#region src/v1/harness-v1-tool-spec.d.ts
422
429
  /**
423
430
  * Description of a host-defined tool that the harness should make available
424
431
  * to the underlying agent runtime.
@@ -430,43 +437,44 @@ type HarnessV1SkillFile = {
430
437
  * `submitToolResult` from the caller.
431
438
  */
432
439
  type HarnessV1ToolSpec = {
433
- /**
434
- * Tool name the agent runtime sees. Must match the name on incoming
435
- * `tool-call` events.
436
- */
437
- readonly name: string;
438
- /**
439
- * Human-readable description handed to the runtime, used to help the model
440
- * decide when to call the tool.
441
- */
442
- readonly description?: string;
443
- /**
444
- * JSON Schema describing the expected input for the tool. Optional because
445
- * some runtimes accept tools without schemas (free-form arguments).
446
- */
447
- readonly inputSchema?: JSONSchema7;
440
+ /**
441
+ * Tool name the agent runtime sees. Must match the name on incoming
442
+ * `tool-call` events.
443
+ */
444
+ readonly name: string;
445
+ /**
446
+ * Human-readable description handed to the runtime, used to help the model
447
+ * decide when to call the tool.
448
+ */
449
+ readonly description?: string;
450
+ /**
451
+ * JSON Schema describing the expected input for the tool. Optional because
452
+ * some runtimes accept tools without schemas (free-form arguments).
453
+ */
454
+ readonly inputSchema?: JSONSchema7;
448
455
  };
449
-
456
+ //#endregion
457
+ //#region src/v1/harness-v1-lifecycle-state.d.ts
450
458
  type HarnessV1PendingToolApproval = {
451
- readonly approvalId: string;
452
- readonly toolCallId: string;
453
- readonly toolName: string;
454
- readonly input: string;
455
- readonly kind: 'builtin' | 'custom';
456
- readonly providerExecuted?: boolean;
457
- readonly nativeName?: string;
459
+ readonly approvalId: string;
460
+ readonly toolCallId: string;
461
+ readonly toolName: string;
462
+ readonly input: string;
463
+ readonly kind: 'builtin' | 'custom';
464
+ readonly providerExecuted?: boolean;
465
+ readonly nativeName?: string;
458
466
  };
459
467
  type HarnessV1PendingToolResult = {
460
- readonly toolCallId: string;
461
- readonly toolName: string;
462
- readonly input: string;
463
- readonly providerOptions?: ProviderOptions;
464
- /** Executed while suspending; submit on resume without running the tool again. */
465
- readonly completedResult?: {
466
- readonly output: unknown;
467
- readonly isError?: boolean;
468
- readonly toolResult?: ToolResultPart;
469
- };
468
+ readonly toolCallId: string;
469
+ readonly toolName: string;
470
+ readonly input: string;
471
+ readonly providerOptions?: ProviderOptions;
472
+ /** Executed while suspending; submit on resume without running the tool again. */
473
+ readonly completedResult?: {
474
+ readonly output: unknown;
475
+ readonly isError?: boolean;
476
+ readonly toolResult?: ToolResultPart;
477
+ };
470
478
  };
471
479
  /**
472
480
  * Framework-owned settings captured when a turn begins. The same settings are
@@ -474,47 +482,47 @@ type HarnessV1PendingToolResult = {
474
482
  * so a resumed continuation cannot pick up configuration from a later turn.
475
483
  */
476
484
  type HarnessV1TurnSettings = {
477
- /**
478
- * Model identifier selected for this turn. Adapters interpret this value
479
- * according to the underlying harness runtime. Rerun-based continuations
480
- * reuse it when reconstructing the turn.
481
- */
482
- readonly model?: string;
483
- /**
484
- * Skills made available to the underlying runtime for this turn. Adapters
485
- * must replace skills from the preceding completed turn before starting a
486
- * fresh turn. Rerun-based continuations use them to reconstruct the turn.
487
- */
488
- readonly skills: ReadonlyArray<HarnessV1Skill>;
489
- /**
490
- * Free-form instructions for this turn. Adapters should apply them through
491
- * the runtime's native system or developer instruction mechanism when
492
- * supported. Rerun-based continuations use them to reconstruct the turn.
493
- */
494
- readonly instructions?: string;
495
- /**
496
- * Host-defined tools made available to the underlying runtime for this turn.
497
- * The harness emits `tool-call` events when the runtime calls one and waits
498
- * for `submitToolResult`. Rerun-based continuations use them to reconstruct
499
- * the turn.
500
- */
501
- readonly tools: ReadonlyArray<HarnessV1ToolSpec>;
485
+ /**
486
+ * Model identifier selected for this turn. Adapters interpret this value
487
+ * according to the underlying harness runtime. Rerun-based continuations
488
+ * reuse it when reconstructing the turn.
489
+ */
490
+ readonly model?: string;
491
+ /**
492
+ * Skills made available to the underlying runtime for this turn. Adapters
493
+ * must replace skills from the preceding completed turn before starting a
494
+ * fresh turn. Rerun-based continuations use them to reconstruct the turn.
495
+ */
496
+ readonly skills: ReadonlyArray<HarnessV1Skill>;
497
+ /**
498
+ * Free-form instructions for this turn. Adapters should apply them through
499
+ * the runtime's native system or developer instruction mechanism when
500
+ * supported. Rerun-based continuations use them to reconstruct the turn.
501
+ */
502
+ readonly instructions?: string;
503
+ /**
504
+ * Host-defined tools made available to the underlying runtime for this turn.
505
+ * The harness emits `tool-call` events when the runtime calls one and waits
506
+ * for `submitToolResult`. Rerun-based continuations use them to reconstruct
507
+ * the turn.
508
+ */
509
+ readonly tools: ReadonlyArray<HarnessV1ToolSpec>;
502
510
  };
503
511
  type HarnessV1LifecycleStateBase = {
504
- /**
505
- * Identifier of the harness that produced this state. Used by adapters to
506
- * refuse mismatched payloads.
507
- */
508
- readonly harnessId: string;
509
- /**
510
- * Spec version of the harness that produced this state.
511
- */
512
- readonly specificationVersion: 'harness-v1';
513
- /**
514
- * Adapter-defined payload. May be persisted as JSON; the adapter is
515
- * responsible for any necessary encoding.
516
- */
517
- readonly data: JSONValue;
512
+ /**
513
+ * Identifier of the harness that produced this state. Used by adapters to
514
+ * refuse mismatched payloads.
515
+ */
516
+ readonly harnessId: string;
517
+ /**
518
+ * Spec version of the harness that produced this state.
519
+ */
520
+ readonly specificationVersion: 'harness-v1';
521
+ /**
522
+ * Adapter-defined payload. May be persisted as JSON; the adapter is
523
+ * responsible for any necessary encoding.
524
+ */
525
+ readonly data: JSONValue;
518
526
  };
519
527
  /**
520
528
  * Opaque payload returned by between-turn session lifecycle methods and
@@ -522,12 +530,12 @@ type HarnessV1LifecycleStateBase = {
522
530
  * underlying session before starting a new turn.
523
531
  */
524
532
  type HarnessV1ResumeSessionState = HarnessV1LifecycleStateBase & {
525
- readonly type: 'resume-session';
526
- /**
527
- * Optional unfinished-turn state. When present, the session must be resumed
528
- * before the turn is continued.
529
- */
530
- readonly continueFrom?: HarnessV1ContinueTurnState;
533
+ readonly type: 'resume-session';
534
+ /**
535
+ * Optional unfinished-turn state. When present, the session must be resumed
536
+ * before the turn is continued.
537
+ */
538
+ readonly continueFrom?: HarnessV1ContinueTurnState;
531
539
  };
532
540
  /**
533
541
  * Opaque payload returned by `doSuspendTurn` and accepted by a future
@@ -535,27 +543,28 @@ type HarnessV1ResumeSessionState = HarnessV1LifecycleStateBase & {
535
543
  * continuing the suspended turn.
536
544
  */
537
545
  type HarnessV1ContinueTurnState = HarnessV1LifecycleStateBase & {
538
- readonly type: 'continue-turn';
539
- /**
540
- * Framework-owned pending approval records. These are intentionally outside
541
- * adapter-defined `data` so callers can persist the entire lifecycle payload
542
- * without the harness framework owning storage.
543
- */
544
- readonly pendingToolApprovals?: readonly HarnessV1PendingToolApproval[];
545
- /**
546
- * Framework-owned client tool calls that are waiting for a caller-provided
547
- * result before the underlying turn can continue.
548
- */
549
- readonly pendingToolResults?: readonly HarnessV1PendingToolResult[];
550
- /**
551
- * Framework-owned settings captured when the unfinished turn began. They
552
- * are persisted outside adapter data so a resumed continuation cannot pick
553
- * up settings prepared for a later turn.
554
- */
555
- readonly turnSettings?: HarnessV1TurnSettings;
546
+ readonly type: 'continue-turn';
547
+ /**
548
+ * Framework-owned pending approval records. These are intentionally outside
549
+ * adapter-defined `data` so callers can persist the entire lifecycle payload
550
+ * without the harness framework owning storage.
551
+ */
552
+ readonly pendingToolApprovals?: readonly HarnessV1PendingToolApproval[];
553
+ /**
554
+ * Framework-owned client tool calls that are waiting for a caller-provided
555
+ * result before the underlying turn can continue.
556
+ */
557
+ readonly pendingToolResults?: readonly HarnessV1PendingToolResult[];
558
+ /**
559
+ * Framework-owned settings captured when the unfinished turn began. They
560
+ * are persisted outside adapter data so a resumed continuation cannot pick
561
+ * up settings prepared for a later turn.
562
+ */
563
+ readonly turnSettings?: HarnessV1TurnSettings;
556
564
  };
557
565
  type HarnessV1LifecycleState = HarnessV1ResumeSessionState | HarnessV1ContinueTurnState;
558
-
566
+ //#endregion
567
+ //#region src/v1/harness-v1-call-warning.d.ts
559
568
  /**
560
569
  * Warning emitted by a harness adapter during a call.
561
570
  *
@@ -564,18 +573,19 @@ type HarnessV1LifecycleState = HarnessV1ResumeSessionState | HarnessV1ContinueTu
564
573
  * in the harness namespace.
565
574
  */
566
575
  type HarnessV1CallWarning = {
567
- type: 'unsupported-setting';
568
- setting: string;
569
- details?: string;
576
+ type: 'unsupported-setting';
577
+ setting: string;
578
+ details?: string;
570
579
  } | {
571
- type: 'unsupported-tool';
572
- tool: string;
573
- details?: string;
580
+ type: 'unsupported-tool';
581
+ tool: string;
582
+ details?: string;
574
583
  } | {
575
- type: 'other';
576
- message: string;
584
+ type: 'other';
585
+ message: string;
577
586
  };
578
-
587
+ //#endregion
588
+ //#region src/v1/harness-v1-metadata.d.ts
579
589
  /**
580
590
  * Adapter-namespaced opaque data attached to harness events.
581
591
  *
@@ -587,7 +597,8 @@ type HarnessV1CallWarning = {
587
597
  * JSON-serializable data the adapter chooses to surface to callers.
588
598
  */
589
599
  type HarnessV1Metadata = Record<string, Record<string, JSONValue>>;
590
-
600
+ //#endregion
601
+ //#region src/v1/harness-v1-stream-part.d.ts
591
602
  /**
592
603
  * One event emitted by a harness adapter during a prompt turn.
593
604
  *
@@ -603,86 +614,87 @@ type HarnessV1Metadata = Record<string, Record<string, JSONValue>>;
603
614
  * agent rebinds it when forwarding to AI SDK consumers.
604
615
  */
605
616
  type HarnessV1StreamPart = {
606
- type: 'stream-start';
607
- warnings?: ReadonlyArray<HarnessV1CallWarning>;
608
- /**
609
- * The model the runtime actually resolved to for this turn, when the
610
- * adapter learns it at stream start (e.g. Claude Code's `init` message
611
- * reports the resolved/default model). Surfaced into telemetry as
612
- * `gen_ai.request.model`. Omitted when the adapter doesn't know it here.
613
- */
614
- modelId?: string;
617
+ type: 'stream-start';
618
+ warnings?: ReadonlyArray<HarnessV1CallWarning>;
619
+ /**
620
+ * The model the runtime actually resolved to for this turn, when the
621
+ * adapter learns it at stream start (e.g. Claude Code's `init` message
622
+ * reports the resolved/default model). Surfaced into telemetry as
623
+ * `gen_ai.request.model`. Omitted when the adapter doesn't know it here.
624
+ */
625
+ modelId?: string;
615
626
  } | {
616
- type: 'text-start';
617
- id: string;
618
- harnessMetadata?: HarnessV1Metadata;
627
+ type: 'text-start';
628
+ id: string;
629
+ harnessMetadata?: HarnessV1Metadata;
619
630
  } | {
620
- type: 'text-delta';
621
- id: string;
622
- delta: string;
623
- harnessMetadata?: HarnessV1Metadata;
631
+ type: 'text-delta';
632
+ id: string;
633
+ delta: string;
634
+ harnessMetadata?: HarnessV1Metadata;
624
635
  } | {
625
- type: 'text-end';
626
- id: string;
627
- harnessMetadata?: HarnessV1Metadata;
636
+ type: 'text-end';
637
+ id: string;
638
+ harnessMetadata?: HarnessV1Metadata;
628
639
  } | {
629
- type: 'reasoning-start';
630
- id: string;
631
- harnessMetadata?: HarnessV1Metadata;
640
+ type: 'reasoning-start';
641
+ id: string;
642
+ harnessMetadata?: HarnessV1Metadata;
632
643
  } | {
633
- type: 'reasoning-delta';
634
- id: string;
635
- delta: string;
636
- harnessMetadata?: HarnessV1Metadata;
644
+ type: 'reasoning-delta';
645
+ id: string;
646
+ delta: string;
647
+ harnessMetadata?: HarnessV1Metadata;
637
648
  } | {
638
- type: 'reasoning-end';
639
- id: string;
640
- harnessMetadata?: HarnessV1Metadata;
649
+ type: 'reasoning-end';
650
+ id: string;
651
+ harnessMetadata?: HarnessV1Metadata;
641
652
  } | Extract<LanguageModelV4StreamPart, {
642
- type: 'tool-input-start';
653
+ type: 'tool-input-start';
643
654
  }> | Extract<LanguageModelV4StreamPart, {
644
- type: 'tool-input-delta';
655
+ type: 'tool-input-delta';
645
656
  }> | Extract<LanguageModelV4StreamPart, {
646
- type: 'tool-input-end';
657
+ type: 'tool-input-end';
647
658
  }> | (LanguageModelV4ToolCall & {
648
- nativeName?: string;
649
- /**
650
- * Total tool calls in the current model step, when known before tool
651
- * execution begins. Populate this on every tool call in the step.
652
- */
653
- stepToolCallCount?: number;
659
+ nativeName?: string;
660
+ /**
661
+ * Total tool calls in the current model step, when known before tool
662
+ * execution begins. Populate this on every tool call in the step.
663
+ */
664
+ stepToolCallCount?: number;
654
665
  }) | LanguageModelV4ToolApprovalRequest | LanguageModelV4ToolResult | {
655
- type: 'finish-step';
656
- finishReason: LanguageModelV4FinishReason;
657
- usage: LanguageModelV4Usage;
658
- harnessMetadata?: HarnessV1Metadata;
666
+ type: 'finish-step';
667
+ finishReason: LanguageModelV4FinishReason;
668
+ usage: LanguageModelV4Usage;
669
+ harnessMetadata?: HarnessV1Metadata;
659
670
  } | {
660
- type: 'finish';
661
- finishReason: LanguageModelV4FinishReason;
662
- totalUsage: LanguageModelV4Usage;
663
- harnessMetadata?: HarnessV1Metadata;
671
+ type: 'finish';
672
+ finishReason: LanguageModelV4FinishReason;
673
+ totalUsage: LanguageModelV4Usage;
674
+ harnessMetadata?: HarnessV1Metadata;
664
675
  } | {
665
- type: 'file-change';
666
- event: 'create' | 'modify' | 'delete';
667
- path: string;
668
- harnessMetadata?: HarnessV1Metadata;
676
+ type: 'file-change';
677
+ event: 'create' | 'modify' | 'delete';
678
+ path: string;
679
+ harnessMetadata?: HarnessV1Metadata;
669
680
  } | {
670
- type: 'compaction';
671
- trigger: 'manual' | 'auto';
672
- summary: string;
673
- tokensBefore?: number;
674
- tokensAfter?: number;
675
- harnessMetadata?: HarnessV1Metadata;
681
+ type: 'compaction';
682
+ trigger: 'manual' | 'auto';
683
+ summary: string;
684
+ tokensBefore?: number;
685
+ tokensAfter?: number;
686
+ harnessMetadata?: HarnessV1Metadata;
676
687
  } | {
677
- type: 'error';
678
- error: unknown;
688
+ type: 'error';
689
+ error: unknown;
679
690
  } | {
680
- type: 'raw';
681
- rawValue: unknown;
691
+ type: 'raw';
692
+ rawValue: unknown;
682
693
  };
683
-
694
+ //#endregion
695
+ //#region src/v1/harness-v1-message.d.ts
684
696
  type LanguageModelV4ToolResultContentPart = Extract<LanguageModelV4ToolResultOutput, {
685
- type: 'content';
697
+ type: 'content';
686
698
  }>['value'][number];
687
699
  type HarnessV1TextPart = Omit<LanguageModelV4TextPart, 'providerOptions'>;
688
700
  type HarnessV1FilePart = Omit<LanguageModelV4FilePart, 'providerOptions'>;
@@ -690,64 +702,66 @@ type HarnessV1CustomPart = Omit<LanguageModelV4CustomPart, 'providerOptions'>;
690
702
  type HarnessV1ReasoningPart = Omit<LanguageModelV4ReasoningPart, 'providerOptions'>;
691
703
  type HarnessV1ReasoningFilePart = Omit<LanguageModelV4ReasoningFilePart, 'providerOptions'>;
692
704
  type HarnessV1ToolCallPart = Omit<LanguageModelV4ToolCallPart, 'providerOptions'> & {
693
- nativeName?: string;
705
+ nativeName?: string;
694
706
  };
695
707
  type HarnessV1ToolResultOutput = Omit<Extract<LanguageModelV4ToolResultOutput, {
696
- type: 'text';
708
+ type: 'text';
697
709
  }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultOutput, {
698
- type: 'json';
710
+ type: 'json';
699
711
  }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultOutput, {
700
- type: 'execution-denied';
712
+ type: 'execution-denied';
701
713
  }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultOutput, {
702
- type: 'error-text';
714
+ type: 'error-text';
703
715
  }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultOutput, {
704
- type: 'error-json';
716
+ type: 'error-json';
705
717
  }>, 'providerOptions'> | {
706
- type: 'content';
707
- value: Array<Omit<Extract<LanguageModelV4ToolResultContentPart, {
708
- type: 'text';
709
- }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultContentPart, {
710
- type: 'file';
711
- }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultContentPart, {
712
- type: 'custom';
713
- }>, 'providerOptions'>>;
718
+ type: 'content';
719
+ value: Array<Omit<Extract<LanguageModelV4ToolResultContentPart, {
720
+ type: 'text';
721
+ }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultContentPart, {
722
+ type: 'file';
723
+ }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultContentPart, {
724
+ type: 'custom';
725
+ }>, 'providerOptions'>>;
714
726
  };
715
727
  type HarnessV1ToolResultPart = Omit<LanguageModelV4ToolResultPart, 'output' | 'providerOptions'> & {
716
- output: HarnessV1ToolResultOutput;
728
+ output: HarnessV1ToolResultOutput;
717
729
  };
718
730
  type HarnessV1ToolApprovalResponsePart = Omit<LanguageModelV4ToolApprovalResponsePart, 'providerOptions'>;
719
731
  type HarnessV1UserMessage = {
720
- readonly role: 'user';
721
- readonly content: Array<HarnessV1TextPart | HarnessV1FilePart>;
722
- readonly at?: string;
723
- readonly harnessMetadata?: HarnessV1Metadata;
732
+ readonly role: 'user';
733
+ readonly content: Array<HarnessV1TextPart | HarnessV1FilePart>;
734
+ readonly at?: string;
735
+ readonly harnessMetadata?: HarnessV1Metadata;
724
736
  };
725
737
  type HarnessV1AssistantMessage = {
726
- readonly role: 'assistant';
727
- readonly content: Array<HarnessV1TextPart | HarnessV1FilePart | HarnessV1CustomPart | HarnessV1ReasoningPart | HarnessV1ReasoningFilePart | HarnessV1ToolCallPart | HarnessV1ToolResultPart>;
728
- readonly at?: string;
729
- readonly harnessMetadata?: HarnessV1Metadata;
738
+ readonly role: 'assistant';
739
+ readonly content: Array<HarnessV1TextPart | HarnessV1FilePart | HarnessV1CustomPart | HarnessV1ReasoningPart | HarnessV1ReasoningFilePart | HarnessV1ToolCallPart | HarnessV1ToolResultPart>;
740
+ readonly at?: string;
741
+ readonly harnessMetadata?: HarnessV1Metadata;
730
742
  };
731
743
  type HarnessV1ToolMessage = {
732
- readonly role: 'tool';
733
- readonly content: Array<HarnessV1ToolResultPart | HarnessV1ToolApprovalResponsePart>;
734
- readonly at?: string;
735
- readonly harnessMetadata?: HarnessV1Metadata;
744
+ readonly role: 'tool';
745
+ readonly content: Array<HarnessV1ToolResultPart | HarnessV1ToolApprovalResponsePart>;
746
+ readonly at?: string;
747
+ readonly harnessMetadata?: HarnessV1Metadata;
736
748
  };
737
749
  /**
738
750
  * A persisted harness message using V4 prompt content shapes and metadata
739
751
  * scoped to the adapter that produced it.
740
752
  */
741
753
  type HarnessV1Message = HarnessV1UserMessage | HarnessV1AssistantMessage | HarnessV1ToolMessage;
742
-
754
+ //#endregion
755
+ //#region src/v1/harness-v1-tool-filtering.d.ts
743
756
  type HarnessV1BuiltinToolFiltering = {
744
- mode: 'allow';
745
- toolNames: string[];
757
+ mode: 'allow';
758
+ toolNames: string[];
746
759
  } | {
747
- mode: 'deny';
748
- toolNames: string[];
760
+ mode: 'deny';
761
+ toolNames: string[];
749
762
  };
750
-
763
+ //#endregion
764
+ //#region src/v1/harness-v1-session.d.ts
751
765
  /**
752
766
  * Options passed to `HarnessV1.doStart`.
753
767
  *
@@ -756,101 +770,101 @@ type HarnessV1BuiltinToolFiltering = {
756
770
  * calling the adapter, so adapters never need to derive provider-specific paths.
757
771
  */
758
772
  type HarnessV1StartOptions = {
759
- /**
760
- * Additional normalized HTTP headers to send with model requests.
761
- */
762
- readonly headers?: Readonly<Record<string, string>>;
763
- /**
764
- * Stable identifier for this harness session. Used as the underlying
765
- * resource name where the adapter has a notion of a named session
766
- * (sandbox name, native session id, …).
767
- */
768
- readonly sessionId: string;
769
- /**
770
- * Optional resume payload returned by a prior session lifecycle method. When
771
- * provided, the adapter should resume the existing session before accepting a
772
- * new prompt or continuing a nested unfinished turn.
773
- */
774
- readonly resumeFrom?: HarnessV1ResumeSessionState;
775
- /**
776
- * Optional continuation payload returned by `doSuspendTurn`, or nested in
777
- * `resumeFrom`. When provided, the adapter should resume the existing session
778
- * in a shape ready for `doContinueTurn` rather than for a fresh prompt.
779
- */
780
- readonly continueFrom?: HarnessV1ContinueTurnState;
781
- /**
782
- * Approval policy for built-in adapter-native tool use. Custom host-executed
783
- * tools are approved by the framework before results are submitted back to
784
- * the adapter.
785
- */
786
- readonly permissionMode?: HarnessV1PermissionMode;
787
- /**
788
- * Adapter-native built-in tools that should be available for this session.
789
- * Custom host-executed tools are filtered by the framework before they reach
790
- * the adapter.
791
- */
792
- readonly builtinToolFiltering?: HarnessV1BuiltinToolFiltering;
793
- /**
794
- * Signal that aborts startup. The adapter must propagate cancellation to
795
- * any spawned processes or network calls.
796
- */
797
- readonly abortSignal?: AbortSignal;
798
- /**
799
- * Diagnostics wiring. The framework populates this; the adapter only
800
- * forwards `observability.onDiagnostic` into its `SandboxChannel` and
801
- * `observability.debug` into the bridge `start` message. Absent when the
802
- * consumer has not enabled diagnostics.
803
- */
804
- readonly observability?: HarnessV1Observability;
805
- /**
806
- * Sandbox session the adapter operates against. Network sandbox sessions
807
- * expose optional infrastructure capabilities for bridge wiring; caller-
808
- * provided basic sandbox sessions expose only filesystem and process APIs.
809
- * Adapters must not stop or destroy the sandbox themselves.
810
- */
811
- readonly sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
812
- /**
813
- * Absolute path the adapter runs the agent in for this session. Composed
814
- * underneath the sandbox's resolved default working directory and created
815
- * before `doStart`.
816
- */
817
- readonly sessionWorkDir: string;
773
+ /**
774
+ * Additional normalized HTTP headers to send with model requests.
775
+ */
776
+ readonly headers?: Readonly<Record<string, string>>;
777
+ /**
778
+ * Stable identifier for this harness session. Used as the underlying
779
+ * resource name where the adapter has a notion of a named session
780
+ * (sandbox name, native session id, …).
781
+ */
782
+ readonly sessionId: string;
783
+ /**
784
+ * Optional resume payload returned by a prior session lifecycle method. When
785
+ * provided, the adapter should resume the existing session before accepting a
786
+ * new prompt or continuing a nested unfinished turn.
787
+ */
788
+ readonly resumeFrom?: HarnessV1ResumeSessionState;
789
+ /**
790
+ * Optional continuation payload returned by `doSuspendTurn`, or nested in
791
+ * `resumeFrom`. When provided, the adapter should resume the existing session
792
+ * in a shape ready for `doContinueTurn` rather than for a fresh prompt.
793
+ */
794
+ readonly continueFrom?: HarnessV1ContinueTurnState;
795
+ /**
796
+ * Approval policy for built-in adapter-native tool use. Custom host-executed
797
+ * tools are approved by the framework before results are submitted back to
798
+ * the adapter.
799
+ */
800
+ readonly permissionMode?: HarnessV1PermissionMode;
801
+ /**
802
+ * Adapter-native built-in tools that should be available for this session.
803
+ * Custom host-executed tools are filtered by the framework before they reach
804
+ * the adapter.
805
+ */
806
+ readonly builtinToolFiltering?: HarnessV1BuiltinToolFiltering;
807
+ /**
808
+ * Signal that aborts startup. The adapter must propagate cancellation to
809
+ * any spawned processes or network calls.
810
+ */
811
+ readonly abortSignal?: AbortSignal;
812
+ /**
813
+ * Diagnostics wiring. The framework populates this; the adapter only
814
+ * forwards `observability.onDiagnostic` into its `SandboxChannel` and
815
+ * `observability.debug` into the bridge `start` message. Absent when the
816
+ * consumer has not enabled diagnostics.
817
+ */
818
+ readonly observability?: HarnessV1Observability;
819
+ /**
820
+ * Sandbox session the adapter operates against. Network sandbox sessions
821
+ * expose optional infrastructure capabilities for bridge wiring; caller-
822
+ * provided basic sandbox sessions expose only filesystem and process APIs.
823
+ * Adapters must not stop or destroy the sandbox themselves.
824
+ */
825
+ readonly sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
826
+ /**
827
+ * Absolute path the adapter runs the agent in for this session. Composed
828
+ * underneath the sandbox's resolved default working directory and created
829
+ * before `doStart`.
830
+ */
831
+ readonly sessionWorkDir: string;
818
832
  };
819
833
  /**
820
834
  * Result of `HarnessV1Session.doReadHistory`.
821
835
  */
822
836
  type HarnessV1ReadHistoryResult = {
823
- readonly messages: ReadonlyArray<HarnessV1Message>;
824
- /** Opaque position; pass back as `since` to read only what follows. */
825
- readonly cursor: string;
837
+ readonly messages: ReadonlyArray<HarnessV1Message>;
838
+ /** Opaque position; pass back as `since` to read only what follows. */
839
+ readonly cursor: string;
826
840
  };
827
841
  /**
828
842
  * Options passed to `HarnessV1Session.doPromptTurn`.
829
843
  */
830
844
  type HarnessV1PromptTurnOptions = HarnessV1TurnSettings & {
831
- /**
832
- * Fresh input for this turn — either a plain string or a single
833
- * `ModelMessage`. The harness session owns its own conversation history,
834
- * so prior turns are never replayed across the contract.
835
- */
836
- readonly prompt: HarnessV1Prompt;
837
- /**
838
- * Response format requested for this turn. Adapters that cannot honor a
839
- * JSON response format must throw `HarnessCapabilityUnsupportedError`.
840
- */
841
- readonly responseFormat?: HarnessV1ResponseFormat;
842
- /**
843
- * Signal that aborts the in-flight turn. The adapter must cancel any
844
- * underlying work and resolve `done` (with an error if appropriate).
845
- */
846
- readonly abortSignal?: AbortSignal;
847
- /**
848
- * Callback invoked once for each event the adapter produces during the
849
- * turn. The adapter is responsible for the ordering and completeness of
850
- * events. `done` resolves once the adapter has emitted all events for the
851
- * turn (success or failure).
852
- */
853
- readonly emit: (event: HarnessV1StreamPart) => void;
845
+ /**
846
+ * Fresh input for this turn — either a plain string or a single
847
+ * `ModelMessage`. The harness session owns its own conversation history,
848
+ * so prior turns are never replayed across the contract.
849
+ */
850
+ readonly prompt: HarnessV1Prompt;
851
+ /**
852
+ * Response format requested for this turn. Adapters that cannot honor a
853
+ * JSON response format must throw `HarnessCapabilityUnsupportedError`.
854
+ */
855
+ readonly responseFormat?: HarnessV1ResponseFormat;
856
+ /**
857
+ * Signal that aborts the in-flight turn. The adapter must cancel any
858
+ * underlying work and resolve `done` (with an error if appropriate).
859
+ */
860
+ readonly abortSignal?: AbortSignal;
861
+ /**
862
+ * Callback invoked once for each event the adapter produces during the
863
+ * turn. The adapter is responsible for the ordering and completeness of
864
+ * events. `done` resolves once the adapter has emitted all events for the
865
+ * turn (success or failure).
866
+ */
867
+ readonly emit: (event: HarnessV1StreamPart) => void;
854
868
  };
855
869
  /**
856
870
  * Options passed to `HarnessV1Session.doContinueTurn`.
@@ -860,21 +874,21 @@ type HarnessV1PromptTurnOptions = HarnessV1TurnSettings & {
860
874
  * that was previously suspended temporarily, e.g. by the workflow slice loop.
861
875
  */
862
876
  type HarnessV1ContinueTurnOptions = HarnessV1TurnSettings & {
863
- /**
864
- * Response format of the in-flight turn. Rerun-based adapters use this when
865
- * reconstructing the turn; attach-based adapters may ignore it.
866
- */
867
- readonly responseFormat?: HarnessV1ResponseFormat;
868
- /**
869
- * Signal that aborts the continued turn. The adapter must cancel any
870
- * underlying work and resolve `done` (with an error if appropriate).
871
- */
872
- readonly abortSignal?: AbortSignal;
873
- /**
874
- * Callback invoked once for each event the adapter produces while the
875
- * continued turn runs. Same contract as `doPromptTurn`'s `emit`.
876
- */
877
- readonly emit: (event: HarnessV1StreamPart) => void;
877
+ /**
878
+ * Response format of the in-flight turn. Rerun-based adapters use this when
879
+ * reconstructing the turn; attach-based adapters may ignore it.
880
+ */
881
+ readonly responseFormat?: HarnessV1ResponseFormat;
882
+ /**
883
+ * Signal that aborts the continued turn. The adapter must cancel any
884
+ * underlying work and resolve `done` (with an error if appropriate).
885
+ */
886
+ readonly abortSignal?: AbortSignal;
887
+ /**
888
+ * Callback invoked once for each event the adapter produces while the
889
+ * continued turn runs. Same contract as `doPromptTurn`'s `emit`.
890
+ */
891
+ readonly emit: (event: HarnessV1StreamPart) => void;
878
892
  };
879
893
  /**
880
894
  * Active harness session, returned by `HarnessV1.doStart`.
@@ -885,121 +899,122 @@ type HarnessV1ContinueTurnOptions = HarnessV1TurnSettings & {
885
899
  * instance via `doDetach`, `doStop`, or `doDestroy`.
886
900
  */
887
901
  type HarnessV1Session = {
888
- /**
889
- * Stable identifier for this session. Same value the host passed in via
890
- * `HarnessV1StartOptions.sessionId`.
891
- */
892
- readonly sessionId: string;
893
- /**
894
- * Whether this session was created from `resumeFrom` or `continueFrom`. Fresh
895
- * sessions report `false`; resumed sessions report `true`.
896
- */
897
- readonly isResume: boolean;
898
- /**
899
- * Run one prompt turn. Returns a control handle the host uses to feed
900
- * tool results, approvals, and user messages back into the turn while it
901
- * is in flight. The handle's `done` promise resolves when the turn ends.
902
- */
903
- doPromptTurn(options: HarnessV1PromptTurnOptions): PromiseLike<HarnessV1PromptControl>;
904
- /**
905
- * Request that the underlying runtime compact its context. The runtime owns
906
- * the compaction — the harness neither implements nor schedules it; this is
907
- * only the trigger. When compaction completes, the adapter surfaces a
908
- * `compaction` stream part on the next/active turn.
909
- *
910
- * Required, but not every runtime can honour it: adapters whose transport
911
- * exposes no manual compaction (e.g. Codex over `codex exec`, which still
912
- * auto-compacts on its own) throw `HarnessCapabilityUnsupportedError`.
913
- * `customInstructions`, when supported, steer the compaction summary.
914
- */
915
- doCompact(customInstructions?: string): PromiseLike<void>;
916
- /**
917
- * Read the conversation history the runtime itself persisted, normalized
918
- * to `HarnessV1Message`.
919
- *
920
- * The session's history can grow outside the harness contract: the same
921
- * runtime conversation may be continued interactively (`claude --resume`),
922
- * by another process, or before this session attached. Hosts that render a
923
- * continuous record of the conversation — not just the turns they drove —
924
- * need to read that history back, and the runtime's own store is the only
925
- * source that has it. The adapter owns its runtime's persistence format,
926
- * so the read belongs here rather than in every host.
927
- *
928
- * `since` is the `cursor` from a previous read; the result then contains
929
- * only messages recorded after it. The cursor is adapter-owned and opaque
930
- * to the host.
931
- *
932
- * Optional capability: adapters that cannot read their runtime's store
933
- * omit the method entirely, and the agent surfaces that as
934
- * `HarnessCapabilityUnsupportedError`. An adapter that implements it but
935
- * cannot reach the store from the current environment (e.g. it lives
936
- * inside a remote sandbox) throws `HarnessHistoryUnavailableError`. A
937
- * conversation with no recorded messages yet is not an error — it resolves
938
- * to an empty `messages` array.
939
- */
940
- doReadHistory?(options: {
941
- readonly since?: string;
942
- }): PromiseLike<HarnessV1ReadHistoryResult>;
943
- /**
944
- * Continue the in-flight turn **without a new user prompt**, returning the
945
- * same control surface as `doPromptTurn`. Used to keep consuming a turn that
946
- * was suspended at a process boundary (the workflow slice loop), after the
947
- * session itself has been resumed via `doStart({ continueFrom })`:
948
- *
949
- * - When the runtime's turn is still live and reachable (bridge `attach` /
950
- * `replay`), the adapter subscribes to its events and resolves `done` on
951
- * the turn's `finish` — **without** re-driving it. Lossless.
952
- * - When the live turn is gone (bridge respawned `rerun`, or a host-resident
953
- * runtime like Pi whose turn cannot survive its process), the adapter
954
- * re-drives the runtime's own thread from its persisted state. Lossy: work
955
- * in flight at the suspension is recomputed.
956
- *
957
- * Required on every adapter. The behaviour an adapter can guarantee follows
958
- * from its architecture; the contract is uniform.
959
- */
960
- doContinueTurn(options: HarnessV1ContinueTurnOptions): PromiseLike<HarnessV1PromptControl>;
961
- /**
962
- * Gracefully freeze the active turn **at a precise cursor while keeping the
963
- * runtime alive**, returning the continuation payload.
964
- *
965
- * This is the slice-boundary primitive. The adapter stops host-side
966
- * consumption of the in-flight turn without telling the runtime to stop:
967
- * for a bridge adapter it closes the host socket (the bridge keeps the turn
968
- * running and accumulates events for replay) and resolves the active
969
- * `doPromptTurn`/`doContinueTurn` `done` **cleanly** (not as an error) once buffered
970
- * events have drained, so the cursor in the returned state equals the last
971
- * event delivered to the host — guaranteeing the next slice's attach replays
972
- * with no gap and no duplicate. A host-resident adapter (Pi) cannot keep its
973
- * turn alive, so it persists what it can and the in-flight tail is recomputed
974
- * on continue.
975
- *
976
- * Like `doDetach`, the sandbox/runtime is left running. Unlike `doDetach`,
977
- * this is for an active turn at a slice boundary rather than a between-turn
978
- * session handoff. Required on every adapter.
979
- */
980
- doSuspendTurn(): PromiseLike<HarnessV1ContinueTurnState>;
981
- /**
982
- * Detach from the underlying runtime without tearing it down, returning a
983
- * payload the host can later pass to
984
- * `HarnessV1.doStart({ resumeFrom })` to reconnect before a new turn. After
985
- * `doDetach`, no further methods on this session instance may be called.
986
- *
987
- * Required. Adapters that cannot keep a live runtime parked still return the
988
- * best resume session state they can while leaving the sandbox running.
989
- */
990
- doDetach(): PromiseLike<HarnessV1ResumeSessionState>;
991
- /**
992
- * Persist enough state to resume later, then stop the underlying runtime.
993
- * After `doStop`, no further methods on this session instance may be called.
994
- */
995
- doStop(): PromiseLike<HarnessV1ResumeSessionState>;
996
- /**
997
- * Stop the underlying runtime without returning lifecycle state. After
998
- * `doDestroy`, no further methods on this session instance may be called.
999
- */
1000
- doDestroy(): PromiseLike<void>;
902
+ /**
903
+ * Stable identifier for this session. Same value the host passed in via
904
+ * `HarnessV1StartOptions.sessionId`.
905
+ */
906
+ readonly sessionId: string;
907
+ /**
908
+ * Whether this session was created from `resumeFrom` or `continueFrom`. Fresh
909
+ * sessions report `false`; resumed sessions report `true`.
910
+ */
911
+ readonly isResume: boolean;
912
+ /**
913
+ * Run one prompt turn. Returns a control handle the host uses to feed
914
+ * tool results, approvals, and user messages back into the turn while it
915
+ * is in flight. The handle's `done` promise resolves when the turn ends.
916
+ */
917
+ doPromptTurn(options: HarnessV1PromptTurnOptions): PromiseLike<HarnessV1PromptControl>;
918
+ /**
919
+ * Request that the underlying runtime compact its context. The runtime owns
920
+ * the compaction — the harness neither implements nor schedules it; this is
921
+ * only the trigger. When compaction completes, the adapter surfaces a
922
+ * `compaction` stream part on the next/active turn.
923
+ *
924
+ * Required, but not every runtime can honour it: adapters whose transport
925
+ * exposes no manual compaction (e.g. Codex over `codex exec`, which still
926
+ * auto-compacts on its own) throw `HarnessCapabilityUnsupportedError`.
927
+ * `customInstructions`, when supported, steer the compaction summary.
928
+ */
929
+ doCompact(customInstructions?: string): PromiseLike<void>;
930
+ /**
931
+ * Read the conversation history the runtime itself persisted, normalized
932
+ * to `HarnessV1Message`.
933
+ *
934
+ * The session's history can grow outside the harness contract: the same
935
+ * runtime conversation may be continued interactively (`claude --resume`),
936
+ * by another process, or before this session attached. Hosts that render a
937
+ * continuous record of the conversation — not just the turns they drove —
938
+ * need to read that history back, and the runtime's own store is the only
939
+ * source that has it. The adapter owns its runtime's persistence format,
940
+ * so the read belongs here rather than in every host.
941
+ *
942
+ * `since` is the `cursor` from a previous read; the result then contains
943
+ * only messages recorded after it. The cursor is adapter-owned and opaque
944
+ * to the host.
945
+ *
946
+ * Optional capability: adapters that cannot read their runtime's store
947
+ * omit the method entirely, and the agent surfaces that as
948
+ * `HarnessCapabilityUnsupportedError`. An adapter that implements it but
949
+ * cannot reach the store from the current environment (e.g. it lives
950
+ * inside a remote sandbox) throws `HarnessHistoryUnavailableError`. A
951
+ * conversation with no recorded messages yet is not an error — it resolves
952
+ * to an empty `messages` array.
953
+ */
954
+ doReadHistory?(options: {
955
+ readonly since?: string;
956
+ }): PromiseLike<HarnessV1ReadHistoryResult>;
957
+ /**
958
+ * Continue the in-flight turn **without a new user prompt**, returning the
959
+ * same control surface as `doPromptTurn`. Used to keep consuming a turn that
960
+ * was suspended at a process boundary (the workflow slice loop), after the
961
+ * session itself has been resumed via `doStart({ continueFrom })`:
962
+ *
963
+ * - When the runtime's turn is still live and reachable (bridge `attach` /
964
+ * `replay`), the adapter subscribes to its events and resolves `done` on
965
+ * the turn's `finish` — **without** re-driving it. Lossless.
966
+ * - When the live turn is gone (bridge respawned `rerun`, or a host-resident
967
+ * runtime like Pi whose turn cannot survive its process), the adapter
968
+ * re-drives the runtime's own thread from its persisted state. Lossy: work
969
+ * in flight at the suspension is recomputed.
970
+ *
971
+ * Required on every adapter. The behaviour an adapter can guarantee follows
972
+ * from its architecture; the contract is uniform.
973
+ */
974
+ doContinueTurn(options: HarnessV1ContinueTurnOptions): PromiseLike<HarnessV1PromptControl>;
975
+ /**
976
+ * Gracefully freeze the active turn **at a precise cursor while keeping the
977
+ * runtime alive**, returning the continuation payload.
978
+ *
979
+ * This is the slice-boundary primitive. The adapter stops host-side
980
+ * consumption of the in-flight turn without telling the runtime to stop:
981
+ * for a bridge adapter it closes the host socket (the bridge keeps the turn
982
+ * running and accumulates events for replay) and resolves the active
983
+ * `doPromptTurn`/`doContinueTurn` `done` **cleanly** (not as an error) once buffered
984
+ * events have drained, so the cursor in the returned state equals the last
985
+ * event delivered to the host — guaranteeing the next slice's attach replays
986
+ * with no gap and no duplicate. A host-resident adapter (Pi) cannot keep its
987
+ * turn alive, so it persists what it can and the in-flight tail is recomputed
988
+ * on continue.
989
+ *
990
+ * Like `doDetach`, the sandbox/runtime is left running. Unlike `doDetach`,
991
+ * this is for an active turn at a slice boundary rather than a between-turn
992
+ * session handoff. Required on every adapter.
993
+ */
994
+ doSuspendTurn(): PromiseLike<HarnessV1ContinueTurnState>;
995
+ /**
996
+ * Detach from the underlying runtime without tearing it down, returning a
997
+ * payload the host can later pass to
998
+ * `HarnessV1.doStart({ resumeFrom })` to reconnect before a new turn. After
999
+ * `doDetach`, no further methods on this session instance may be called.
1000
+ *
1001
+ * Required. Adapters that cannot keep a live runtime parked still return the
1002
+ * best resume session state they can while leaving the sandbox running.
1003
+ */
1004
+ doDetach(): PromiseLike<HarnessV1ResumeSessionState>;
1005
+ /**
1006
+ * Persist enough state to resume later, then stop the underlying runtime.
1007
+ * After `doStop`, no further methods on this session instance may be called.
1008
+ */
1009
+ doStop(): PromiseLike<HarnessV1ResumeSessionState>;
1010
+ /**
1011
+ * Stop the underlying runtime without returning lifecycle state. After
1012
+ * `doDestroy`, no further methods on this session instance may be called.
1013
+ */
1014
+ doDestroy(): PromiseLike<void>;
1001
1015
  };
1002
-
1016
+ //#endregion
1017
+ //#region src/v1/harness-v1.d.ts
1003
1018
  /**
1004
1019
  * Versioned specification for a harness adapter — the integration point for
1005
1020
  * one third-party coding-agent runtime (Claude Code, Codex, …).
@@ -1014,73 +1029,74 @@ type HarnessV1Session = {
1014
1029
  * capability.
1015
1030
  */
1016
1031
  type HarnessV1<TBuiltinTools extends ToolSet = ToolSet> = {
1017
- /**
1018
- * Spec version this adapter implements. Always the literal `'harness-v1'`.
1019
- */
1020
- readonly specificationVersion: 'harness-v1';
1021
- /**
1022
- * Stable identifier for this harness, used as the key inside
1023
- * `HarnessV1Metadata` objects. Conventionally a kebab-case slug matching
1024
- * the package name (`'claude-code'`, `'codex'`).
1025
- */
1026
- readonly harnessId: string;
1027
- /**
1028
- * Tools the adapter's underlying runtime exposes natively, as a `ToolSet`
1029
- * keyed by what the bridge emits on `tool-call` events
1030
- * (`commonName ?? nativeName`). Each entry is a `HarnessV1BuiltinTool`
1031
- * (a `Tool` plus harness-specific `nativeName` / `commonName` metadata).
1032
- *
1033
- * The agent merges this with consumer-supplied user tools when validating
1034
- * inbound tool calls and when typing the consumer-facing stream.
1035
- */
1036
- readonly builtinTools: TBuiltinTools;
1037
- /**
1038
- * Whether the adapter can emit approval requests for built-in tools when
1039
- * `permissionMode` is not `'allow-all'`.
1040
- *
1041
- * Custom host-executed tool approvals are handled by `HarnessAgent`, so this
1042
- * only describes adapter-native tool approval support.
1043
- */
1044
- readonly supportsBuiltinToolApprovals?: boolean;
1045
- /**
1046
- * Whether the adapter can prevent its underlying runtime from seeing or
1047
- * calling inactive built-in tools for every tool in `builtinTools`.
1048
- *
1049
- * Adapters without native filtering can still support `activeTools` and
1050
- * `inactiveTools` for built-ins when `supportsBuiltinToolApprovals` is
1051
- * `true`: the framework routes inactive built-in tool calls through the
1052
- * approval path and auto-denies them before they execute.
1053
- */
1054
- readonly supportsBuiltinToolFiltering?: boolean;
1055
- /**
1056
- * Optional schema for the adapter-defined `data` payload returned by session
1057
- * lifecycle methods. When present, the adapter promises that exported state
1058
- * validated by this schema can be re-imported in a future
1059
- * `doStart({ resumeFrom })` or `doStart({ continueFrom })` call.
1060
- */
1061
- readonly lifecycleStateSchema?: FlexibleSchema<unknown>;
1062
- /**
1063
- * Optional bootstrap recipe. When defined, the harness session manager
1064
- * computes a stable identity from the recipe, passes it (along with a
1065
- * one-time recipe-application hook) to the sandbox provider, and applies
1066
- * the recipe idempotently after the provider returns the handle.
1067
- *
1068
- * Adapters with no bootstrap needs omit this. Adapters that need to install
1069
- * deps or ship bridge files into the sandbox declare them here so the
1070
- * provider can cache the result across sessions via snapshots when
1071
- * supported.
1072
- */
1073
- readonly getBootstrap?: (options?: {
1074
- abortSignal?: AbortSignal;
1075
- }) => PromiseLike<HarnessV1Bootstrap>;
1076
- /**
1077
- * Start a fresh session, resume a parked session via `resumeFrom`, or resume
1078
- * a suspended turn via `continueFrom`. The host then issues prompts against
1079
- * the returned session, ending with `doDetach`, `doStop`, or `doDestroy`.
1080
- */
1081
- doStart(options: HarnessV1StartOptions): PromiseLike<HarnessV1Session>;
1032
+ /**
1033
+ * Spec version this adapter implements. Always the literal `'harness-v1'`.
1034
+ */
1035
+ readonly specificationVersion: 'harness-v1';
1036
+ /**
1037
+ * Stable identifier for this harness, used as the key inside
1038
+ * `HarnessV1Metadata` objects. Conventionally a kebab-case slug matching
1039
+ * the package name (`'claude-code'`, `'codex'`).
1040
+ */
1041
+ readonly harnessId: string;
1042
+ /**
1043
+ * Tools the adapter's underlying runtime exposes natively, as a `ToolSet`
1044
+ * keyed by what the bridge emits on `tool-call` events
1045
+ * (`commonName ?? nativeName`). Each entry is a `HarnessV1BuiltinTool`
1046
+ * (a `Tool` plus harness-specific `nativeName` / `commonName` metadata).
1047
+ *
1048
+ * The agent merges this with consumer-supplied user tools when validating
1049
+ * inbound tool calls and when typing the consumer-facing stream.
1050
+ */
1051
+ readonly builtinTools: TBuiltinTools;
1052
+ /**
1053
+ * Whether the adapter can emit approval requests for built-in tools when
1054
+ * `permissionMode` is not `'allow-all'`.
1055
+ *
1056
+ * Custom host-executed tool approvals are handled by `HarnessAgent`, so this
1057
+ * only describes adapter-native tool approval support.
1058
+ */
1059
+ readonly supportsBuiltinToolApprovals?: boolean;
1060
+ /**
1061
+ * Whether the adapter can prevent its underlying runtime from seeing or
1062
+ * calling inactive built-in tools for every tool in `builtinTools`.
1063
+ *
1064
+ * Adapters without native filtering can still support `activeTools` and
1065
+ * `inactiveTools` for built-ins when `supportsBuiltinToolApprovals` is
1066
+ * `true`: the framework routes inactive built-in tool calls through the
1067
+ * approval path and auto-denies them before they execute.
1068
+ */
1069
+ readonly supportsBuiltinToolFiltering?: boolean;
1070
+ /**
1071
+ * Optional schema for the adapter-defined `data` payload returned by session
1072
+ * lifecycle methods. When present, the adapter promises that exported state
1073
+ * validated by this schema can be re-imported in a future
1074
+ * `doStart({ resumeFrom })` or `doStart({ continueFrom })` call.
1075
+ */
1076
+ readonly lifecycleStateSchema?: FlexibleSchema<unknown>;
1077
+ /**
1078
+ * Optional bootstrap recipe. When defined, the harness session manager
1079
+ * computes a stable identity from the recipe, passes it (along with a
1080
+ * one-time recipe-application hook) to the sandbox provider, and applies
1081
+ * the recipe idempotently after the provider returns the handle.
1082
+ *
1083
+ * Adapters with no bootstrap needs omit this. Adapters that need to install
1084
+ * deps or ship bridge files into the sandbox declare them here so the
1085
+ * provider can cache the result across sessions via snapshots when
1086
+ * supported.
1087
+ */
1088
+ readonly getBootstrap?: (options?: {
1089
+ abortSignal?: AbortSignal;
1090
+ }) => PromiseLike<HarnessV1Bootstrap>;
1091
+ /**
1092
+ * Start a fresh session, resume a parked session via `resumeFrom`, or resume
1093
+ * a suspended turn via `continueFrom`. The host then issues prompts against
1094
+ * the returned session, ending with `doDetach`, `doStop`, or `doDestroy`.
1095
+ */
1096
+ doStart(options: HarnessV1StartOptions): PromiseLike<HarnessV1Session>;
1082
1097
  };
1083
-
1098
+ //#endregion
1099
+ //#region src/v1/harness-v1-builtin-tool.d.ts
1084
1100
  /**
1085
1101
  * Cross-harness vocabulary of common built-in tool names with their baseline
1086
1102
  * input schemas. Adapters that declare a built-in with one of these
@@ -1091,64 +1107,64 @@ type HarnessV1<TBuiltinTools extends ToolSet = ToolSet> = {
1091
1107
  * a vocabulary source — `HarnessV1BuiltinToolName` is derived from its keys.
1092
1108
  */
1093
1109
  declare const HARNESS_V1_BUILTIN_TOOLS: {
1094
- readonly read: Tool<{
1095
- file_path: string;
1096
- }, unknown, _ai_sdk_provider_utils.Context>;
1097
- readonly write: Tool<{
1098
- file_path: string;
1099
- content: string;
1100
- }, unknown, _ai_sdk_provider_utils.Context>;
1101
- readonly edit: Tool<{
1102
- file_path: string;
1103
- old_string: string;
1104
- new_string: string;
1105
- }, unknown, _ai_sdk_provider_utils.Context>;
1106
- readonly bash: Tool<{
1107
- command: string;
1108
- }, unknown, _ai_sdk_provider_utils.Context>;
1109
- readonly grep: Tool<{
1110
- pattern: string;
1111
- }, unknown, _ai_sdk_provider_utils.Context>;
1112
- readonly glob: Tool<{
1113
- pattern: string;
1114
- }, unknown, _ai_sdk_provider_utils.Context>;
1115
- readonly webSearch: Tool<{
1116
- query: string;
1117
- }, unknown, _ai_sdk_provider_utils.Context>;
1118
- readonly askUserQuestions: _ai_sdk_provider_utils.FunctionTool<{
1119
- allowPartialAnswers: boolean;
1120
- questions: {
1121
- id: string;
1122
- question: string;
1123
- header?: string | undefined;
1124
- options?: {
1125
- id: string;
1126
- label: string;
1127
- description?: string | undefined;
1128
- preview?: string | undefined;
1129
- }[] | undefined;
1130
- allowMultiple?: boolean | undefined;
1131
- allowFreeForm?: boolean | {
1132
- secret: boolean;
1133
- } | undefined;
1134
- }[];
1135
- }, {
1136
- action: "answered";
1137
- answers: Record<string, {
1138
- optionIds: string[];
1139
- freeform?: string | undefined;
1140
- }>;
1141
- } | {
1142
- action: "partially-answered";
1143
- answers: Record<string, {
1144
- optionIds: string[];
1145
- freeform?: string | undefined;
1146
- }>;
1147
- } | {
1148
- action: "declined";
1149
- } | {
1150
- action: "cancelled";
1110
+ readonly read: Tool<{
1111
+ file_path: string;
1112
+ }, unknown, import("@ai-sdk/provider-utils").Context>;
1113
+ readonly write: Tool<{
1114
+ file_path: string;
1115
+ content: string;
1116
+ }, unknown, import("@ai-sdk/provider-utils").Context>;
1117
+ readonly edit: Tool<{
1118
+ file_path: string;
1119
+ old_string: string;
1120
+ new_string: string;
1121
+ }, unknown, import("@ai-sdk/provider-utils").Context>;
1122
+ readonly bash: Tool<{
1123
+ command: string;
1124
+ }, unknown, import("@ai-sdk/provider-utils").Context>;
1125
+ readonly grep: Tool<{
1126
+ pattern: string;
1127
+ }, unknown, import("@ai-sdk/provider-utils").Context>;
1128
+ readonly glob: Tool<{
1129
+ pattern: string;
1130
+ }, unknown, import("@ai-sdk/provider-utils").Context>;
1131
+ readonly webSearch: Tool<{
1132
+ query: string;
1133
+ }, unknown, import("@ai-sdk/provider-utils").Context>;
1134
+ readonly askUserQuestions: import("@ai-sdk/provider-utils").FunctionTool<{
1135
+ allowPartialAnswers: boolean;
1136
+ questions: {
1137
+ id: string;
1138
+ question: string;
1139
+ header?: string | undefined;
1140
+ options?: {
1141
+ id: string;
1142
+ label: string;
1143
+ description?: string | undefined;
1144
+ preview?: string | undefined;
1145
+ }[] | undefined;
1146
+ allowMultiple?: boolean | undefined;
1147
+ allowFreeForm?: boolean | {
1148
+ secret: boolean;
1149
+ } | undefined;
1150
+ }[];
1151
+ }, {
1152
+ action: "answered";
1153
+ answers: Record<string, {
1154
+ optionIds: string[];
1155
+ freeform?: string | undefined;
1151
1156
  }>;
1157
+ } | {
1158
+ action: "partially-answered";
1159
+ answers: Record<string, {
1160
+ optionIds: string[];
1161
+ freeform?: string | undefined;
1162
+ }>;
1163
+ } | {
1164
+ action: "declined";
1165
+ } | {
1166
+ action: "cancelled";
1167
+ }>;
1152
1168
  };
1153
1169
  type HarnessV1BuiltinToolName = keyof typeof HARNESS_V1_BUILTIN_TOOLS;
1154
1170
  type HarnessV1BuiltinToolUseKind = 'readonly' | 'edit' | 'bash';
@@ -1171,11 +1187,12 @@ type HarnessV1BuiltinToolUseKind = 'readonly' | 'edit' | 'bash';
1171
1187
  * (declare the tool with the AI SDK's `tool()` directly).
1172
1188
  */
1173
1189
  type HarnessV1BuiltinTool<INPUT = unknown, OUTPUT = unknown> = Tool<INPUT, OUTPUT, any> & {
1174
- readonly nativeName?: string;
1175
- readonly commonName?: HarnessV1BuiltinToolName;
1176
- readonly toolUseKind?: HarnessV1BuiltinToolUseKind;
1190
+ readonly nativeName?: string;
1191
+ readonly commonName?: HarnessV1BuiltinToolName;
1192
+ readonly toolUseKind?: HarnessV1BuiltinToolUseKind;
1177
1193
  };
1178
-
1194
+ //#endregion
1195
+ //#region src/v1/harness-v1-sandbox-provider.d.ts
1179
1196
  /**
1180
1197
  * Provider that produces network sandbox sessions for harness sessions. Lives at
1181
1198
  * module scope as a stable, synchronous object — analogous to
@@ -1184,72 +1201,74 @@ type HarnessV1BuiltinTool<INPUT = unknown, OUTPUT = unknown> = Tool<INPUT, OUTPU
1184
1201
  */
1185
1202
  /** @deprecated Supply a sandbox session to `HarnessAgent.createSession()` instead. */
1186
1203
  interface HarnessV1SandboxProvider {
1187
- readonly specificationVersion: 'harness-sandbox-v1';
1188
- readonly providerId: string;
1189
- /**
1190
- * Providers should throw `HarnessSandboxAuthenticationError` when sandbox
1191
- * acquisition fails because credentials are missing, invalid, or not
1192
- * authorized. This lets framework integrations distinguish configuration
1193
- * failures from general sandbox infrastructure errors.
1204
+ readonly specificationVersion: 'harness-sandbox-v1';
1205
+ readonly providerId: string;
1206
+ /**
1207
+ * Providers should throw `HarnessSandboxAuthenticationError` when sandbox
1208
+ * acquisition fails because credentials are missing, invalid, or not
1209
+ * authorized. This lets framework integrations distinguish configuration
1210
+ * failures from general sandbox infrastructure errors.
1211
+ */
1212
+ readonly createSession: (options?: {
1213
+ /**
1214
+ * Stable per-session identifier. When supplied, the provider names the
1215
+ * underlying resource deterministically so a future call to `resume`
1216
+ * (potentially from a different process) can find the same sandbox.
1217
+ * Omitted from prewarm and other paths that don't need a resumable
1218
+ * resource — in that case the provider falls back to its native
1219
+ * auto-naming.
1220
+ */
1221
+ sessionId?: string;
1222
+ abortSignal?: AbortSignal;
1223
+ /**
1224
+ * Stable identity for snapshot-based reuse. Providers that support
1225
+ * persistence/snapshots use this as part of the persistent sandbox
1226
+ * name; subsequent calls with the same identity resume from snapshot.
1227
+ *
1228
+ * Ignored when the provider is wrapping a caller-provided sandbox.
1194
1229
  */
1195
- readonly createSession: (options?: {
1196
- /**
1197
- * Stable per-session identifier. When supplied, the provider names the
1198
- * underlying resource deterministically so a future call to `resume`
1199
- * (potentially from a different process) can find the same sandbox.
1200
- * Omitted from prewarm and other paths that don't need a resumable
1201
- * resource — in that case the provider falls back to its native
1202
- * auto-naming.
1203
- */
1204
- sessionId?: string;
1205
- abortSignal?: AbortSignal;
1206
- /**
1207
- * Stable identity for snapshot-based reuse. Providers that support
1208
- * persistence/snapshots use this as part of the persistent sandbox
1209
- * name; subsequent calls with the same identity resume from snapshot.
1210
- *
1211
- * Ignored when the provider is wrapping a caller-provided sandbox.
1212
- */
1213
- identity?: string;
1214
- /**
1215
- * Called exactly once per identity, on fresh creation. Snapshot-capable
1216
- * providers wire this into the platform's one-time-setup hook so the
1217
- * side effects are baked into the snapshot. Providers without snapshot
1218
- * support run it immediately after fresh create.
1219
- *
1220
- * Not called when the provider is wrapping a caller-provided sandbox
1221
- * (the caller owns the sandbox; the framework applies its own
1222
- * idempotent bootstrap post-create instead).
1223
- */
1224
- onFirstCreate?: (session: Experimental_SandboxSession, opts: {
1225
- abortSignal?: AbortSignal;
1226
- }) => Promise<void>;
1227
- }) => PromiseLike<HarnessV1NetworkSandboxSession>;
1230
+ identity?: string;
1228
1231
  /**
1229
- * Reattach to an existing sandbox previously created with the same
1230
- * `sessionId`. Optional — providers that cannot rehydrate by id omit
1231
- * this; the harness throws
1232
- * `HarnessCapabilityUnsupportedError` when resume is attempted against
1233
- * them.
1232
+ * Called exactly once per identity, on fresh creation. Snapshot-capable
1233
+ * providers wire this into the platform's one-time-setup hook so the
1234
+ * side effects are baked into the snapshot. Providers without snapshot
1235
+ * support run it immediately after fresh create.
1234
1236
  *
1235
- * The provider derives the sandbox identifier from `sessionId` using the
1236
- * same deterministic naming scheme it used in `createSession`. Returns a
1237
- * network sandbox session bound to the existing resource.
1237
+ * Not called when the provider is wrapping a caller-provided sandbox
1238
+ * (the caller owns the sandbox; the framework applies its own
1239
+ * idempotent bootstrap post-create instead).
1238
1240
  */
1239
- readonly resumeSession?: (options: {
1240
- sessionId: string;
1241
- abortSignal?: AbortSignal;
1242
- }) => PromiseLike<HarnessV1NetworkSandboxSession>;
1241
+ onFirstCreate?: (session: Experimental_SandboxSession, opts: {
1242
+ abortSignal?: AbortSignal;
1243
+ }) => Promise<void>;
1244
+ }) => PromiseLike<HarnessV1NetworkSandboxSession>;
1245
+ /**
1246
+ * Reattach to an existing sandbox previously created with the same
1247
+ * `sessionId`. Optional — providers that cannot rehydrate by id omit
1248
+ * this; the harness throws
1249
+ * `HarnessCapabilityUnsupportedError` when resume is attempted against
1250
+ * them.
1251
+ *
1252
+ * The provider derives the sandbox identifier from `sessionId` using the
1253
+ * same deterministic naming scheme it used in `createSession`. Returns a
1254
+ * network sandbox session bound to the existing resource.
1255
+ */
1256
+ readonly resumeSession?: (options: {
1257
+ sessionId: string;
1258
+ abortSignal?: AbortSignal;
1259
+ }) => PromiseLike<HarnessV1NetworkSandboxSession>;
1243
1260
  }
1244
-
1261
+ //#endregion
1262
+ //#region src/v1/harness-v1-sandbox-template.d.ts
1245
1263
  type HarnessV1SandboxTemplate = {
1246
- readonly identity: string;
1247
- readonly prepare: (options: {
1248
- readonly session: Experimental_SandboxSession;
1249
- readonly abortSignal?: AbortSignal;
1250
- }) => Promise<void>;
1264
+ readonly identity: string;
1265
+ readonly prepare: (options: {
1266
+ readonly session: Experimental_SandboxSession;
1267
+ readonly abortSignal?: AbortSignal;
1268
+ }) => Promise<void>;
1251
1269
  };
1252
-
1270
+ //#endregion
1271
+ //#region src/agent/observability/types.d.ts
1253
1272
  /** Severity of a diagnostic. */
1254
1273
  type HarnessDebugLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
1255
1274
  /**
@@ -1259,12 +1278,12 @@ type HarnessDebugLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
1259
1278
  * fill any unset field — a convenience default, never the only path.
1260
1279
  */
1261
1280
  type HarnessDebugConfig = {
1262
- /** Master switch. Nothing is captured or forwarded when false/unset. */
1263
- readonly enabled?: boolean;
1264
- /** Threshold; events at or above this severity are emitted. Default `debug`. */
1265
- readonly level?: HarnessDebugLevel;
1266
- /** Dotted-prefix subsystem filter for structured events. */
1267
- readonly subsystems?: ReadonlyArray<string>;
1281
+ /** Master switch. Nothing is captured or forwarded when false/unset. */
1282
+ readonly enabled?: boolean;
1283
+ /** Threshold; events at or above this severity are emitted. Default `debug`. */
1284
+ readonly level?: HarnessDebugLevel;
1285
+ /** Dotted-prefix subsystem filter for structured events. */
1286
+ readonly subsystems?: ReadonlyArray<string>;
1268
1287
  };
1269
1288
  /**
1270
1289
  * A forwarded bridge diagnostic, normalized for host consumers.
@@ -1276,37 +1295,37 @@ type HarnessDebugConfig = {
1276
1295
  * kept first-class and per-line — they are never folded into telemetry spans.
1277
1296
  */
1278
1297
  type HarnessDiagnostic = {
1279
- /**
1280
- * Severity. Structured events carry their own level; captured console lines
1281
- * map `stderr` → `'warn'` and `stdout` → `'info'`.
1282
- */
1283
- readonly level: HarnessDebugLevel;
1284
- /** Human-readable line (console capture) or message (structured event). */
1285
- readonly message: string;
1286
- /**
1287
- * Dotted subsystem. For captured console output this is
1288
- * `sandbox.log.<source>`; for structured events it is the adapter-supplied
1289
- * subsystem (e.g. `bridge.turn`).
1290
- */
1291
- readonly subsystem: string;
1292
- /** `'log'` = captured console line; `'event'` = structured `bridgeLog`. */
1293
- readonly kind: 'log' | 'event';
1294
- /** Originating sandbox source label (console capture). */
1295
- readonly source?: string;
1296
- /** Which standard stream the line came from (console capture). */
1297
- readonly stream?: 'stdout' | 'stderr';
1298
- /** Structured attributes (structured events only). */
1299
- readonly attrs?: Record<string, unknown>;
1300
- /** Error payload (structured events only). */
1301
- readonly error?: {
1302
- name?: string;
1303
- message: string;
1304
- stack?: string;
1305
- };
1306
- /** The harness session this diagnostic originated from. */
1307
- readonly sessionId?: string;
1308
- /** Host receipt time (epoch ms). */
1309
- readonly timestamp: number;
1298
+ /**
1299
+ * Severity. Structured events carry their own level; captured console lines
1300
+ * map `stderr` → `'warn'` and `stdout` → `'info'`.
1301
+ */
1302
+ readonly level: HarnessDebugLevel;
1303
+ /** Human-readable line (console capture) or message (structured event). */
1304
+ readonly message: string;
1305
+ /**
1306
+ * Dotted subsystem. For captured console output this is
1307
+ * `sandbox.log.<source>`; for structured events it is the adapter-supplied
1308
+ * subsystem (e.g. `bridge.turn`).
1309
+ */
1310
+ readonly subsystem: string;
1311
+ /** `'log'` = captured console line; `'event'` = structured `bridgeLog`. */
1312
+ readonly kind: 'log' | 'event';
1313
+ /** Originating sandbox source label (console capture). */
1314
+ readonly source?: string;
1315
+ /** Which standard stream the line came from (console capture). */
1316
+ readonly stream?: 'stdout' | 'stderr';
1317
+ /** Structured attributes (structured events only). */
1318
+ readonly attrs?: Record<string, unknown>;
1319
+ /** Error payload (structured events only). */
1320
+ readonly error?: {
1321
+ name?: string;
1322
+ message: string;
1323
+ stack?: string;
1324
+ };
1325
+ /** The harness session this diagnostic originated from. */
1326
+ readonly sessionId?: string;
1327
+ /** Host receipt time (epoch ms). */
1328
+ readonly timestamp: number;
1310
1329
  };
1311
1330
  /**
1312
1331
  * A telemetry integration that also wants the per-line diagnostics stream. The
@@ -1316,9 +1335,10 @@ type HarnessDiagnostic = {
1316
1335
  * `telemetry.integrations` receives both spans and logs.
1317
1336
  */
1318
1337
  interface HarnessDiagnosticConsumer {
1319
- ingestDiagnostic?(diagnostic: HarnessDiagnostic): void;
1338
+ ingestDiagnostic?(diagnostic: HarnessDiagnostic): void;
1320
1339
  }
1321
-
1340
+ //#endregion
1341
+ //#region src/agent/harness-agent-types.d.ts
1322
1342
  type HarnessAgentAdapter<TBuiltinTools extends ToolSet = ToolSet> = HarnessV1<TBuiltinTools>;
1323
1343
  type HarnessSandboxTemplate = HarnessV1SandboxTemplate;
1324
1344
  type HarnessAgentBuiltinTool<INPUT = unknown, OUTPUT = unknown> = HarnessV1BuiltinTool<INPUT, OUTPUT>;
@@ -1340,7 +1360,8 @@ type HarnessAgentPendingToolApproval = HarnessV1PendingToolApproval;
1340
1360
  type HarnessAgentPendingToolResult = HarnessV1PendingToolResult;
1341
1361
  type HarnessAgentSkill = HarnessV1Skill;
1342
1362
  type HarnessAgentPermissionMode = HarnessV1PermissionMode;
1343
-
1363
+ //#endregion
1364
+ //#region src/agent/harness-agent-tool-types.d.ts
1344
1365
  /** Extract the builtin tool set type from a harness adapter parameter. */
1345
1366
  type HarnessBuiltinToolsOf<H> = H extends HarnessAgentAdapter<infer T> ? T : never;
1346
1367
  /**
@@ -1348,46 +1369,47 @@ type HarnessBuiltinToolsOf<H> = H extends HarnessAgentAdapter<infer T> ? T : nev
1348
1369
  * User tools override builtins on key collision.
1349
1370
  */
1350
1371
  type HarnessAllTools<THarness extends HarnessAgentAdapter<any>, TUserTools extends ToolSet> = Omit<HarnessBuiltinToolsOf<THarness>, keyof TUserTools> & TUserTools;
1351
-
1372
+ //#endregion
1373
+ //#region src/agent/harness-agent-settings.d.ts
1352
1374
  type HarnessAgentToolApprovalConfiguration = Readonly<Record<string, ToolApprovalStatus>>;
1353
1375
  type HarnessAgentSandboxConfig = {
1354
- /**
1355
- * Optional fixed working directory for all sessions, relative to the
1356
- * sandbox's default working directory. Use `'.'` to use the default
1357
- * working directory itself. When omitted, sessions keep the existing
1358
- * `<harnessId>-<sessionId>` work directory.
1359
- */
1360
- readonly workDir?: string;
1361
- /**
1362
- * Caller-controlled identity for `onBootstrap`. Change this whenever the
1363
- * bootstrap side effects should invalidate the reusable sandbox snapshot.
1364
- */
1365
- readonly bootstrapHash?: string;
1366
- /**
1367
- * Called during sandbox template creation after the harness adapter's own
1368
- * bootstrap has run and before snapshot-capable providers publish a snapshot.
1369
- *
1370
- * `bootstrapHash` must be provided with this callback.
1371
- */
1372
- readonly onBootstrap?: (opts: {
1373
- readonly session: Experimental_SandboxSession;
1374
- readonly workDir: string;
1375
- readonly abortSignal?: AbortSignal;
1376
- }) => Promise<void>;
1377
- /**
1378
- * Called after each sandbox session is acquired and the session work
1379
- * directory exists, before the harness adapter starts. Runs for fresh and
1380
- * resumed sessions.
1381
- *
1382
- * Use this to write per-session config, install lightweight tools, activate
1383
- * licenses, or prepare files in `sessionWorkDir`. Keep it idempotent if the
1384
- * agent may resume sessions.
1385
- */
1386
- readonly onSession?: (opts: {
1387
- readonly session: Experimental_SandboxSession;
1388
- readonly sessionWorkDir: string;
1389
- readonly abortSignal?: AbortSignal;
1390
- }) => Promise<void>;
1376
+ /**
1377
+ * Optional fixed working directory for all sessions, relative to the
1378
+ * sandbox's default working directory. Use `'.'` to use the default
1379
+ * working directory itself. When omitted, sessions keep the existing
1380
+ * `<harnessId>-<sessionId>` work directory.
1381
+ */
1382
+ readonly workDir?: string;
1383
+ /**
1384
+ * Caller-controlled identity for `onBootstrap`. Change this whenever the
1385
+ * bootstrap side effects should invalidate the reusable sandbox snapshot.
1386
+ */
1387
+ readonly bootstrapHash?: string;
1388
+ /**
1389
+ * Called during sandbox template creation after the harness adapter's own
1390
+ * bootstrap has run and before snapshot-capable providers publish a snapshot.
1391
+ *
1392
+ * `bootstrapHash` must be provided with this callback.
1393
+ */
1394
+ readonly onBootstrap?: (opts: {
1395
+ readonly session: Experimental_SandboxSession;
1396
+ readonly workDir: string;
1397
+ readonly abortSignal?: AbortSignal;
1398
+ }) => Promise<void>;
1399
+ /**
1400
+ * Called after each sandbox session is acquired and the session work
1401
+ * directory exists, before the harness adapter starts. Runs for fresh and
1402
+ * resumed sessions.
1403
+ *
1404
+ * Use this to write per-session config, install lightweight tools, activate
1405
+ * licenses, or prepare files in `sessionWorkDir`. Keep it idempotent if the
1406
+ * agent may resume sessions.
1407
+ */
1408
+ readonly onSession?: (opts: {
1409
+ readonly session: Experimental_SandboxSession;
1410
+ readonly sessionWorkDir: string;
1411
+ readonly abortSignal?: AbortSignal;
1412
+ }) => Promise<void>;
1391
1413
  };
1392
1414
  type HarnessTools<TOOLS extends ToolSet> = ActiveTools<NoInfer<TOOLS>>;
1393
1415
  /**
@@ -1401,215 +1423,217 @@ type HarnessTools<TOOLS extends ToolSet> = ActiveTools<NoInfer<TOOLS>>;
1401
1423
  * from custom call options.
1402
1424
  */
1403
1425
  type HarnessAgentToolFilteringSettings<TOOLS extends ToolSet> = {
1404
- /**
1405
- * Limits the tools that are available for the harness to call without
1406
- * changing the tool call and result types in the result.
1407
- */
1408
- readonly activeTools?: HarnessTools<TOOLS>;
1409
- readonly inactiveTools?: never;
1426
+ /**
1427
+ * Limits the tools that are available for the harness to call without
1428
+ * changing the tool call and result types in the result.
1429
+ */
1430
+ readonly activeTools?: HarnessTools<TOOLS>;
1431
+ readonly inactiveTools?: never;
1410
1432
  } | {
1411
- readonly activeTools?: never;
1412
- /**
1413
- * Excludes tools from the set that is available for the harness to call
1414
- * without changing the tool call and result types in the result.
1415
- */
1416
- readonly inactiveTools?: HarnessTools<TOOLS>;
1433
+ readonly activeTools?: never;
1434
+ /**
1435
+ * Excludes tools from the set that is available for the harness to call
1436
+ * without changing the tool call and result types in the result.
1437
+ */
1438
+ readonly inactiveTools?: HarnessTools<TOOLS>;
1417
1439
  };
1418
1440
  type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never, CALL_OPTIONS = never> = {
1419
- /**
1420
- * The harness adapter driving the underlying agent runtime. Its
1421
- * `builtinTools` are merged with the user-defined `tools` and exposed to
1422
- * AI SDK consumers in the typed `tool-call` stream.
1423
- */
1424
- readonly harness: THarness;
1425
- /**
1426
- * Stable identifier for this agent instance. Exposed via `agent.id`.
1427
- * If omitted, `agent.id` is `undefined`.
1428
- */
1429
- readonly id?: string;
1430
- /**
1431
- * Model identifier used by the harness adapter. Supported values are
1432
- * defined by the selected harness. `prepareCall` can replace it between
1433
- * completed turns.
1434
- */
1435
- readonly model?: string;
1436
- /**
1437
- * Tools available to the underlying runtime in addition to the harness's
1438
- * own builtins. The agent forwards each tool to the harness as a
1439
- * `HarnessAgentToolSpec`; when the runtime calls one, the agent executes
1440
- * `tool.execute()` on the host and submits the result back to the harness.
1441
- *
1442
- * User tools take precedence over harness builtins on key collision —
1443
- * declare a tool with the same name as a builtin to override.
1444
- */
1445
- readonly tools?: TUserTools;
1446
- /**
1447
- * Per-tool context passed to host-executed tools. Each entry is validated
1448
- * against the matching tool's `contextSchema` before execution.
1449
- * `prepareCall` can replace it for each new turn.
1450
- */
1451
- readonly toolsContext?: InferToolSetContext<TUserTools>;
1452
- /**
1453
- * Runtime context passed to lifecycle callbacks and telemetry.
1454
- * `prepareCall` can replace it for each new turn.
1455
- */
1456
- readonly runtimeContext?: RUNTIME_CONTEXT;
1457
- /**
1458
- * Skills made available to the underlying runtime. Each adapter decides how
1459
- * to surface skills. `prepareCall` can replace them between completed turns.
1460
- */
1461
- readonly skills?: ReadonlyArray<HarnessAgentSkill>;
1462
- /**
1463
- * Instructions for the underlying agent runtime. Adapters append these to a
1464
- * native system or developer prompt when supported. Otherwise, they prepend
1465
- * them to the user message. `prepareCall` can replace them between completed
1466
- * turns. When a `SystemModelMessage` is provided, only its `content` is
1467
- * forwarded to the harness adapter.
1468
- */
1469
- readonly instructions?: string | SystemModelMessage;
1470
- /**
1471
- * Additional HTTP headers to be sent with every model request.
1472
- *
1473
- * `authorization`, `x-api-key`, `user-agent`, and `x-client-app` are
1474
- * managed by the harness and are not allowed.
1475
- */
1476
- readonly headers?: Record<string, string | undefined>;
1477
- /**
1478
- * Schema for validating the custom options passed to each agent call.
1479
- */
1480
- readonly callOptionsSchema?: FlexibleSchema<CALL_OPTIONS>;
1481
- /**
1482
- * Prepares the prompt and the settings that may vary between completed
1483
- * turns. The prepared values are frozen for the lifetime of the turn,
1484
- * including any suspended-turn continuations.
1485
- *
1486
- * Preserve the remaining arguments with the rest-spread pattern when a
1487
- * field should be removable by returning `undefined`:
1488
- *
1489
- * ```ts
1490
- * prepareCall: ({ options, ...rest }) => ({
1491
- * ...rest,
1492
- * instructions: options.instructions,
1493
- * })
1494
- * ```
1495
- */
1496
- readonly prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT>, 'abortSignal' | 'timeout' | 'onStart' | 'experimental_onStart' | 'onStepStart' | 'experimental_onStepStart' | 'onToolExecutionStart' | 'experimental_onToolCallStart' | 'onToolExecutionEnd' | 'experimental_onToolCallFinish' | 'onStepEnd' | 'onStepFinish' | 'onEnd' | 'onFinish' | 'experimental_sandbox'> & Pick<HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, NoInfer<OUTPUT>, CALL_OPTIONS>, 'model' | 'skills' | 'instructions' | 'tools' | 'runtimeContext'> & {
1497
- toolsContext: InferToolSetContext<TUserTools>;
1498
- }) => MaybePromiseLike<Pick<HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, NoInfer<OUTPUT>, CALL_OPTIONS>, 'model' | 'skills' | 'instructions' | 'tools' | 'runtimeContext'> & {
1499
- toolsContext: InferToolSetContext<TUserTools>;
1500
- } & Omit<Prompt, 'system' | 'instructions' | 'allowSystemInMessages'>>;
1501
- /**
1502
- * Optional specification for generating typed output. The same output
1503
- * requirement is active for every turn run by this agent.
1504
- */
1505
- readonly output?: OUTPUT;
1506
- /**
1507
- * Conditions that stop the current result after a completed harness tool
1508
- * step that can continue into another model step. The underlying turn remains
1509
- * unfinished and can be suspended and continued.
1510
- *
1511
- * A terminal text-only step finishes naturally and is not stopped early.
1512
- *
1513
- * When omitted, the harness runs until the turn naturally finishes or pauses.
1514
- */
1515
- readonly stopWhen?: Arrayable<StopCondition<NoInfer<HarnessAllTools<THarness, TUserTools>>, RUNTIME_CONTEXT>>;
1516
- /**
1517
- * Called when an agent call begins, before any model steps.
1518
- */
1519
- readonly onStart?: GenerateTextOnStartCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, RUNTIME_CONTEXT, NoInfer<OUTPUT>>;
1520
- /**
1521
- * Called when a model step begins.
1522
- */
1523
- readonly onStepStart?: GenerateTextOnStepStartCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, NoInfer<RUNTIME_CONTEXT>, NoInfer<OUTPUT>>;
1524
- /**
1525
- * Called immediately before the harness begins emitting a model response.
1526
- */
1527
- readonly onLanguageModelCallStart?: OnLanguageModelCallStartCallback;
1528
- /**
1529
- * Called after a model response is complete and before its tool execution
1530
- * lifecycle callbacks are delivered.
1531
- */
1532
- readonly onLanguageModelCallEnd?: OnLanguageModelCallEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>>;
1533
- /**
1534
- * Called before each harness or host tool execution is reported.
1535
- */
1536
- readonly onToolExecutionStart?: OnToolExecutionStartCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>>;
1537
- /**
1538
- * Called after each harness or host tool execution is reported.
1539
- */
1540
- readonly onToolExecutionEnd?: OnToolExecutionEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>>;
1541
- /**
1542
- * Called after each completed model step.
1543
- */
1544
- readonly onStepEnd?: GenerateTextOnStepEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, NoInfer<RUNTIME_CONTEXT>>;
1545
- /**
1546
- * Called when an agent call completes successfully.
1547
- */
1548
- readonly onEnd?: GenerateTextOnEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, NoInfer<RUNTIME_CONTEXT>>;
1549
- /**
1550
- * Built-in tool permission mode. Defaults to `'allow-all'`, preserving the
1551
- * existing bypass-permissions behavior unless users opt in.
1552
- */
1553
- readonly permissionMode?: HarnessAgentPermissionMode;
1554
- /**
1555
- * Per custom-tool approval statuses. This mirrors AI SDK `toolApproval`
1556
- * object configuration for host-executed tools, without callback support.
1557
- *
1558
- * `not-applicable` and `approved` run the tool, `user-approval` pauses the
1559
- * turn for a user decision, and `denied` immediately submits an
1560
- * `execution-denied` result.
1561
- */
1562
- readonly toolApproval?: HarnessAgentToolApprovalConfiguration;
1563
- /**
1564
- * Optional sandbox provider used to create or resume network sandbox
1565
- * sessions. When omitted, every `createSession()` call must provide an
1566
- * existing network sandbox session.
1567
- */
1568
- /** @deprecated Supply `sandboxSession` to `HarnessAgent.createSession()` instead. */
1569
- readonly sandbox?: HarnessV1SandboxProvider;
1570
- /**
1571
- * Sandbox working-directory and lifecycle hook configuration.
1572
- */
1573
- readonly sandboxConfig?: HarnessAgentSandboxConfig;
1574
- /** @deprecated Use `sandboxConfig.onSession` instead. */
1575
- readonly onSandboxSession?: HarnessAgentSandboxConfig['onSession'];
1576
- /**
1577
- * Telemetry configuration. The harness drives AI SDK's pluggable
1578
- * `Telemetry` integration contract from the turn lifecycle, so a harness turn
1579
- * appears in a consumer's traces with the same span shape as `streamText`.
1580
- * Register an integration here (e.g. `@ai-sdk/otel`) or globally via
1581
- * `registerTelemetry`. The harness itself stays OpenTelemetry-agnostic.
1582
- */
1583
- readonly telemetry?: TelemetryOptions;
1584
- /**
1585
- * Diagnostics configuration. Enables bridge log forwarding (sandbox
1586
- * console + structured `debug-event`s) and the `HARNESS_DEBUG` stderr default.
1587
- * Set `{ enabled: true }` to turn it on in code; env vars fill unset fields.
1588
- */
1589
- readonly debug?: HarnessDebugConfig;
1590
- /**
1591
- * Programmatic sink for forwarded bridge diagnostics. Receives every
1592
- * captured console line and structured event, normalized. Independent of the
1593
- * stderr default — wire this to capture diagnostics in code.
1594
- */
1595
- readonly onLog?: (event: HarnessDiagnostic) => void;
1441
+ /**
1442
+ * The harness adapter driving the underlying agent runtime. Its
1443
+ * `builtinTools` are merged with the user-defined `tools` and exposed to
1444
+ * AI SDK consumers in the typed `tool-call` stream.
1445
+ */
1446
+ readonly harness: THarness;
1447
+ /**
1448
+ * Stable identifier for this agent instance. Exposed via `agent.id`.
1449
+ * If omitted, `agent.id` is `undefined`.
1450
+ */
1451
+ readonly id?: string;
1452
+ /**
1453
+ * Model identifier used by the harness adapter. Supported values are
1454
+ * defined by the selected harness. `prepareCall` can replace it between
1455
+ * completed turns.
1456
+ */
1457
+ readonly model?: string;
1458
+ /**
1459
+ * Tools available to the underlying runtime in addition to the harness's
1460
+ * own builtins. The agent forwards each tool to the harness as a
1461
+ * `HarnessAgentToolSpec`; when the runtime calls one, the agent executes
1462
+ * `tool.execute()` on the host and submits the result back to the harness.
1463
+ *
1464
+ * User tools take precedence over harness builtins on key collision —
1465
+ * declare a tool with the same name as a builtin to override.
1466
+ */
1467
+ readonly tools?: TUserTools;
1468
+ /**
1469
+ * Per-tool context passed to host-executed tools. Each entry is validated
1470
+ * against the matching tool's `contextSchema` before execution.
1471
+ * `prepareCall` can replace it for each new turn.
1472
+ */
1473
+ readonly toolsContext?: InferToolSetContext<TUserTools>;
1474
+ /**
1475
+ * Runtime context passed to lifecycle callbacks and telemetry.
1476
+ * `prepareCall` can replace it for each new turn.
1477
+ */
1478
+ readonly runtimeContext?: RUNTIME_CONTEXT;
1479
+ /**
1480
+ * Skills made available to the underlying runtime. Each adapter decides how
1481
+ * to surface skills. `prepareCall` can replace them between completed turns.
1482
+ */
1483
+ readonly skills?: ReadonlyArray<HarnessAgentSkill>;
1484
+ /**
1485
+ * Instructions for the underlying agent runtime. Adapters append these to a
1486
+ * native system or developer prompt when supported. Otherwise, they prepend
1487
+ * them to the user message. `prepareCall` can replace them between completed
1488
+ * turns. When a `SystemModelMessage` is provided, only its `content` is
1489
+ * forwarded to the harness adapter.
1490
+ */
1491
+ readonly instructions?: string | SystemModelMessage;
1492
+ /**
1493
+ * Additional HTTP headers to be sent with every model request.
1494
+ *
1495
+ * `authorization`, `x-api-key`, `user-agent`, and `x-client-app` are
1496
+ * managed by the harness and are not allowed.
1497
+ */
1498
+ readonly headers?: Record<string, string | undefined>;
1499
+ /**
1500
+ * Schema for validating the custom options passed to each agent call.
1501
+ */
1502
+ readonly callOptionsSchema?: FlexibleSchema<CALL_OPTIONS>;
1503
+ /**
1504
+ * Prepares the prompt and the settings that may vary between completed
1505
+ * turns. The prepared values are frozen for the lifetime of the turn,
1506
+ * including any suspended-turn continuations.
1507
+ *
1508
+ * Preserve the remaining arguments with the rest-spread pattern when a
1509
+ * field should be removable by returning `undefined`:
1510
+ *
1511
+ * ```ts
1512
+ * prepareCall: ({ options, ...rest }) => ({
1513
+ * ...rest,
1514
+ * instructions: options.instructions,
1515
+ * })
1516
+ * ```
1517
+ */
1518
+ readonly prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT>, 'abortSignal' | 'timeout' | 'onStart' | 'experimental_onStart' | 'onStepStart' | 'experimental_onStepStart' | 'onToolExecutionStart' | 'experimental_onToolCallStart' | 'onToolExecutionEnd' | 'experimental_onToolCallFinish' | 'onStepEnd' | 'onStepFinish' | 'onEnd' | 'onFinish' | 'experimental_sandbox'> & Pick<HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, NoInfer<OUTPUT>, CALL_OPTIONS>, 'model' | 'skills' | 'instructions' | 'tools' | 'runtimeContext'> & {
1519
+ toolsContext: InferToolSetContext<TUserTools>;
1520
+ }) => MaybePromiseLike<Pick<HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, NoInfer<OUTPUT>, CALL_OPTIONS>, 'model' | 'skills' | 'instructions' | 'tools' | 'runtimeContext'> & {
1521
+ toolsContext: InferToolSetContext<TUserTools>;
1522
+ } & Omit<Prompt, 'system' | 'instructions' | 'allowSystemInMessages'>>;
1523
+ /**
1524
+ * Optional specification for generating typed output. The same output
1525
+ * requirement is active for every turn run by this agent.
1526
+ */
1527
+ readonly output?: OUTPUT;
1528
+ /**
1529
+ * Conditions that stop the current result after a completed harness tool
1530
+ * step that can continue into another model step. The underlying turn remains
1531
+ * unfinished and can be suspended and continued.
1532
+ *
1533
+ * A terminal text-only step finishes naturally and is not stopped early.
1534
+ *
1535
+ * When omitted, the harness runs until the turn naturally finishes or pauses.
1536
+ */
1537
+ readonly stopWhen?: Arrayable<StopCondition<NoInfer<HarnessAllTools<THarness, TUserTools>>, RUNTIME_CONTEXT>>;
1538
+ /**
1539
+ * Called when an agent call begins, before any model steps.
1540
+ */
1541
+ readonly onStart?: GenerateTextOnStartCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, RUNTIME_CONTEXT, NoInfer<OUTPUT>>;
1542
+ /**
1543
+ * Called when a model step begins.
1544
+ */
1545
+ readonly onStepStart?: GenerateTextOnStepStartCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, NoInfer<RUNTIME_CONTEXT>, NoInfer<OUTPUT>>;
1546
+ /**
1547
+ * Called immediately before the harness begins emitting a model response.
1548
+ */
1549
+ readonly onLanguageModelCallStart?: OnLanguageModelCallStartCallback;
1550
+ /**
1551
+ * Called after a model response is complete and before its tool execution
1552
+ * lifecycle callbacks are delivered.
1553
+ */
1554
+ readonly onLanguageModelCallEnd?: OnLanguageModelCallEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>>;
1555
+ /**
1556
+ * Called before each harness or host tool execution is reported.
1557
+ */
1558
+ readonly onToolExecutionStart?: OnToolExecutionStartCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>>;
1559
+ /**
1560
+ * Called after each harness or host tool execution is reported.
1561
+ */
1562
+ readonly onToolExecutionEnd?: OnToolExecutionEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>>;
1563
+ /**
1564
+ * Called after each completed model step.
1565
+ */
1566
+ readonly onStepEnd?: GenerateTextOnStepEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, NoInfer<RUNTIME_CONTEXT>>;
1567
+ /**
1568
+ * Called when an agent call completes successfully.
1569
+ */
1570
+ readonly onEnd?: GenerateTextOnEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, NoInfer<RUNTIME_CONTEXT>>;
1571
+ /**
1572
+ * Built-in tool permission mode. Defaults to `'allow-all'`, preserving the
1573
+ * existing bypass-permissions behavior unless users opt in.
1574
+ */
1575
+ readonly permissionMode?: HarnessAgentPermissionMode;
1576
+ /**
1577
+ * Per custom-tool approval statuses. This mirrors AI SDK `toolApproval`
1578
+ * object configuration for host-executed tools, without callback support.
1579
+ *
1580
+ * `not-applicable` and `approved` run the tool, `user-approval` pauses the
1581
+ * turn for a user decision, and `denied` immediately submits an
1582
+ * `execution-denied` result.
1583
+ */
1584
+ readonly toolApproval?: HarnessAgentToolApprovalConfiguration;
1585
+ /**
1586
+ * Optional sandbox provider used to create or resume network sandbox
1587
+ * sessions. When omitted, every `createSession()` call must provide an
1588
+ * existing network sandbox session.
1589
+ */
1590
+ /** @deprecated Supply `sandboxSession` to `HarnessAgent.createSession()` instead. */
1591
+ readonly sandbox?: HarnessV1SandboxProvider;
1592
+ /**
1593
+ * Sandbox working-directory and lifecycle hook configuration.
1594
+ */
1595
+ readonly sandboxConfig?: HarnessAgentSandboxConfig;
1596
+ /** @deprecated Use `sandboxConfig.onSession` instead. */
1597
+ readonly onSandboxSession?: HarnessAgentSandboxConfig['onSession'];
1598
+ /**
1599
+ * Telemetry configuration. The harness drives AI SDK's pluggable
1600
+ * `Telemetry` integration contract from the turn lifecycle, so a harness turn
1601
+ * appears in a consumer's traces with the same span shape as `streamText`.
1602
+ * Register an integration here (e.g. `@ai-sdk/otel`) or globally via
1603
+ * `registerTelemetry`. The harness itself stays OpenTelemetry-agnostic.
1604
+ */
1605
+ readonly telemetry?: TelemetryOptions;
1606
+ /**
1607
+ * Diagnostics configuration. Enables bridge log forwarding (sandbox
1608
+ * console + structured `debug-event`s) and the `HARNESS_DEBUG` stderr default.
1609
+ * Set `{ enabled: true }` to turn it on in code; env vars fill unset fields.
1610
+ */
1611
+ readonly debug?: HarnessDebugConfig;
1612
+ /**
1613
+ * Programmatic sink for forwarded bridge diagnostics. Receives every
1614
+ * captured console line and structured event, normalized. Independent of the
1615
+ * stderr default — wire this to capture diagnostics in code.
1616
+ */
1617
+ readonly onLog?: (event: HarnessDiagnostic) => void;
1596
1618
  } & ToolsContextSettings<TUserTools> & HarnessAgentToolFilteringSettings<HarnessAllTools<THarness, TUserTools>>;
1597
-
1619
+ //#endregion
1620
+ //#region src/agent/internal/turn-telemetry.d.ts
1598
1621
  type HarnessAgentLifecycleCallbacks<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface> = {
1599
- onStart?: GenerateTextOnStartCallback<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1600
- onStepStart?: GenerateTextOnStepStartCallback<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1601
- onLanguageModelCallStart?: OnLanguageModelCallStartCallback;
1602
- onLanguageModelCallEnd?: OnLanguageModelCallEndCallback<TOOLS>;
1603
- onToolExecutionStart?: OnToolExecutionStartCallback<TOOLS>;
1604
- onToolExecutionEnd?: OnToolExecutionEndCallback<TOOLS>;
1605
- onStepEnd?: GenerateTextOnStepEndCallback<TOOLS, RUNTIME_CONTEXT>;
1606
- onEnd?: GenerateTextOnEndCallback<TOOLS, RUNTIME_CONTEXT>;
1622
+ onStart?: GenerateTextOnStartCallback<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1623
+ onStepStart?: GenerateTextOnStepStartCallback<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1624
+ onLanguageModelCallStart?: OnLanguageModelCallStartCallback;
1625
+ onLanguageModelCallEnd?: OnLanguageModelCallEndCallback<TOOLS>;
1626
+ onToolExecutionStart?: OnToolExecutionStartCallback<TOOLS>;
1627
+ onToolExecutionEnd?: OnToolExecutionEndCallback<TOOLS>;
1628
+ onStepEnd?: GenerateTextOnStepEndCallback<TOOLS, RUNTIME_CONTEXT>;
1629
+ onEnd?: GenerateTextOnEndCallback<TOOLS, RUNTIME_CONTEXT>;
1607
1630
  };
1608
-
1631
+ //#endregion
1632
+ //#region src/agent/harness-agent-session.d.ts
1609
1633
  type HarnessAgentTurnResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface> = {
1610
- result: StreamTextResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1611
- done: Promise<void>;
1612
- ready: Promise<void>;
1634
+ result: StreamTextResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1635
+ done: Promise<void>;
1636
+ ready: Promise<void>;
1613
1637
  };
1614
1638
  type HarnessAgentTurnState = 'idle' | 'running' | 'awaiting-approval' | 'awaiting-tool-result' | 'suspended';
1615
1639
  /**
@@ -1624,180 +1648,181 @@ type HarnessAgentTurnState = 'idle' | 'running' | 'awaiting-approval' | 'awaitin
1624
1648
  * After any lifecycle method has resolved, the session is unusable — any
1625
1649
  * subsequent `generate`/`stream` call against it throws.
1626
1650
  */
1627
- declare class HarnessAgentSession {
1628
- /**
1629
- * Stable identifier the harness adapter saw in `doStart`. The same
1630
- * string callers persist when they intend to resume the session in a
1631
- * future process.
1632
- */
1633
- readonly sessionId: string;
1634
- private readonly harness;
1635
- private readonly sessionWorkDir;
1636
- private readonly ownsSandboxLifecycle;
1637
- private underlyingSession;
1638
- private sandboxSession;
1639
- private readonly toolApproval;
1640
- private readonly pendingToolApprovals;
1641
- private readonly pendingToolResults;
1642
- private sessionState;
1643
- private turnState;
1644
- private turnSequence;
1645
- private activeTurnSequence;
1646
- private activePromptDone;
1647
- private activePromptControl;
1648
- private suspendedTurnState;
1649
- private activeTurnSettings;
1650
- private persistedTurnSettings;
1651
- private readonly resumedToolsContext;
1652
- private readonly resumedRuntimeContext;
1653
- /**
1654
- * Whether this session was created from `resumeFrom` or `continueFrom`.
1655
- * Captured at construction so it survives lifecycle cleanup.
1656
- */
1657
- readonly isResume: boolean;
1658
- constructor(options: {
1659
- sessionId: string;
1660
- harness: HarnessAgentAdapter;
1661
- underlyingSession: HarnessAgentAdapterSession;
1662
- sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
1663
- ownsSandboxLifecycle?: boolean;
1664
- sessionWorkDir: string;
1665
- toolApproval: HarnessAgentToolApprovalConfiguration | undefined;
1666
- pendingToolApprovals?: readonly HarnessAgentPendingToolApproval[];
1667
- pendingToolResults?: readonly HarnessAgentPendingToolResult[];
1668
- turnSettings?: HarnessV1TurnSettings;
1669
- resumedToolsContext?: Record<string, Context | undefined>;
1670
- resumedRuntimeContext?: Context;
1671
- turnState?: HarnessAgentTurnState;
1672
- });
1673
- hasUnfinishedTurn(): boolean;
1674
- promptTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
1675
- prompt: HarnessAgentPrompt;
1676
- model: string | undefined;
1677
- skills: ReadonlyArray<HarnessV1Skill>;
1678
- instructions: string | undefined;
1679
- tools: TOOLS;
1680
- toolsContext: InferToolSetContext<TOOLS>;
1681
- activeTools: ToolSet;
1682
- toolSpecs: HarnessAgentToolSpec[];
1683
- builtinToolFiltering: HarnessV1BuiltinToolFiltering | undefined;
1684
- runtimeContext: RUNTIME_CONTEXT;
1685
- abortSignal: AbortSignal | undefined;
1686
- responseFormat: HarnessV1ResponseFormat | undefined;
1687
- output: OUTPUT | undefined;
1688
- telemetry: TelemetryOptions | undefined;
1689
- callbacks: HarnessAgentLifecycleCallbacks<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1690
- stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
1691
- }): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1692
- continueTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
1693
- model: string | undefined;
1694
- skills: ReadonlyArray<HarnessV1Skill>;
1695
- instructions: string | undefined;
1696
- tools: TOOLS;
1697
- toolsContext: InferToolSetContext<TOOLS>;
1698
- activeTools: ToolSet;
1699
- toolSpecs: HarnessAgentToolSpec[];
1700
- builtinToolFiltering: HarnessV1BuiltinToolFiltering | undefined;
1701
- runtimeContext: RUNTIME_CONTEXT;
1702
- abortSignal: AbortSignal | undefined;
1703
- responseFormat: HarnessV1ResponseFormat | undefined;
1704
- output: OUTPUT | undefined;
1705
- telemetry: TelemetryOptions | undefined;
1706
- callbacks: HarnessAgentLifecycleCallbacks<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1707
- stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
1708
- toolApprovalContinuations?: readonly ToolApprovalResponse[] | undefined;
1709
- toolResultContinuations?: readonly ToolResultPart[] | undefined;
1710
- }): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1711
- /**
1712
- * Ask the underlying runtime to compact its context. The runtime performs
1713
- * the compaction itself; when it completes, a `compaction` part appears on
1714
- * the active (or next) turn's stream. Safe to call between turns for
1715
- * runtimes whose compaction is session-scoped (e.g. Pi).
1716
- *
1717
- * Throws `HarnessCapabilityUnsupportedError` for harnesses that cannot
1718
- * trigger compaction manually (e.g. Codex, which still auto-compacts under
1719
- * the hood). Throws if the session has ended.
1720
- */
1721
- compact(customInstructions?: string): Promise<void>;
1722
- /**
1723
- * Submit another user message to the active turn.
1724
- *
1725
- * The runtime accepts the message for its next safe input boundary. Output
1726
- * caused by the message remains part of the active turn's result stream.
1727
- */
1728
- experimental_steerTurn(text: string): Promise<void>;
1729
- /**
1730
- * Park the session, returning a payload the caller can persist and later
1731
- * pass to `agent.createSession({ sessionId, resumeFrom })` to reconnect.
1732
- * The runtime and sandbox keep running; this local session handle becomes
1733
- * unusable.
1734
- */
1735
- detach(): Promise<HarnessAgentResumeSessionState>;
1736
- /**
1737
- * Read the conversation history the runtime itself persisted, normalized
1738
- * by the adapter. Includes exchanges that happened outside this process —
1739
- * the same conversation continued interactively in the agent's own CLI,
1740
- * for instance — which the live event stream never saw.
1741
- *
1742
- * Pass a previous result's `cursor` as `since` to read only the delta. A
1743
- * conversation with no recorded messages yet resolves to an empty
1744
- * `messages` array.
1745
- *
1746
- * Throws `HarnessCapabilityUnsupportedError` when the adapter does not
1747
- * implement history reads, and
1748
- * `HarnessHistoryUnavailableError` when the adapter supports them but
1749
- * cannot reach the runtime's store from this environment.
1750
- */
1751
- readHistory(options?: {
1752
- since?: string;
1753
- }): Promise<HarnessV1ReadHistoryResult>;
1754
- /**
1755
- * Persist enough state to resume later, then stop the runtime and any
1756
- * harness-owned sandbox.
1757
- * Returns the resume state for a future
1758
- * `agent.createSession({ sessionId, resumeFrom })` call.
1759
- */
1760
- stop(): Promise<HarnessAgentResumeSessionState>;
1761
- /**
1762
- * Stop the runtime and discard resumability. A harness-owned network
1763
- * sandbox is stopped and destroyed through its `destroy()` method.
1764
- */
1765
- destroy(): Promise<void>;
1766
- /**
1767
- * Gracefully freeze the active turn at the slice boundary and return the
1768
- * continuation payload, **leaving the sandbox/runtime running** so the next
1769
- * process can continue. Resolves once the in-flight `stream()` /
1770
- * `continueStream()` has cleanly wound down at a precise cursor (see
1771
- * `doSuspendTurn`).
1772
- *
1773
- * After this call the session is detached. This in-process handle no
1774
- * longer drives turns; a future slice creates a fresh session from the
1775
- * returned state. The sandbox is **not** stopped because bridge-backed
1776
- * adapters may still have a live bridge.
1777
- */
1778
- suspendTurn(): Promise<HarnessAgentContinueTurnState>;
1779
- private getPendingToolApprovals;
1780
- private getPendingToolResults;
1781
- private addPendingToolState;
1782
- private suspendCurrentTurn;
1783
- private finalizeCurrentTurnSuspension;
1784
- private captureStopConditionBoundary;
1785
- private toResumeStateWithContinuation;
1786
- private requirePromptableTurn;
1787
- private requireContinuableTurn;
1788
- private markAwaitingApprovalIfActive;
1789
- private markAwaitingToolResultIfActive;
1790
- private startTrackedTurn;
1791
- private setPromptControl;
1792
- private waitForPromptControl;
1793
- private settleActivePromptControl;
1794
- private clearActivePromptControl;
1795
- private finishTrackedTurn;
1796
- private resolveActiveTurnSettings;
1797
- private endLocalHandle;
1798
- private requireReusableSession;
1651
+ export declare class HarnessAgentSession {
1652
+ /**
1653
+ * Stable identifier the harness adapter saw in `doStart`. The same
1654
+ * string callers persist when they intend to resume the session in a
1655
+ * future process.
1656
+ */
1657
+ readonly sessionId: string;
1658
+ private readonly harness;
1659
+ private readonly sessionWorkDir;
1660
+ private readonly ownsSandboxLifecycle;
1661
+ private underlyingSession;
1662
+ private sandboxSession;
1663
+ private readonly toolApproval;
1664
+ private readonly pendingToolApprovals;
1665
+ private readonly pendingToolResults;
1666
+ private sessionState;
1667
+ private turnState;
1668
+ private turnSequence;
1669
+ private activeTurnSequence;
1670
+ private activePromptDone;
1671
+ private activePromptControl;
1672
+ private suspendedTurnState;
1673
+ private activeTurnSettings;
1674
+ private persistedTurnSettings;
1675
+ private readonly resumedToolsContext;
1676
+ private readonly resumedRuntimeContext;
1677
+ /**
1678
+ * Whether this session was created from `resumeFrom` or `continueFrom`.
1679
+ * Captured at construction so it survives lifecycle cleanup.
1680
+ */
1681
+ readonly isResume: boolean;
1682
+ constructor(options: {
1683
+ sessionId: string;
1684
+ harness: HarnessAgentAdapter;
1685
+ underlyingSession: HarnessAgentAdapterSession;
1686
+ sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
1687
+ ownsSandboxLifecycle?: boolean;
1688
+ sessionWorkDir: string;
1689
+ toolApproval: HarnessAgentToolApprovalConfiguration | undefined;
1690
+ pendingToolApprovals?: readonly HarnessAgentPendingToolApproval[];
1691
+ pendingToolResults?: readonly HarnessAgentPendingToolResult[];
1692
+ turnSettings?: HarnessV1TurnSettings;
1693
+ resumedToolsContext?: Record<string, Context | undefined>;
1694
+ resumedRuntimeContext?: Context;
1695
+ turnState?: HarnessAgentTurnState;
1696
+ });
1697
+ hasUnfinishedTurn(): boolean;
1698
+ promptTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
1699
+ prompt: HarnessAgentPrompt;
1700
+ model: string | undefined;
1701
+ skills: ReadonlyArray<HarnessV1Skill>;
1702
+ instructions: string | undefined;
1703
+ tools: TOOLS;
1704
+ toolsContext: InferToolSetContext<TOOLS>;
1705
+ activeTools: ToolSet;
1706
+ toolSpecs: HarnessAgentToolSpec[];
1707
+ builtinToolFiltering: HarnessV1BuiltinToolFiltering | undefined;
1708
+ runtimeContext: RUNTIME_CONTEXT;
1709
+ abortSignal: AbortSignal | undefined;
1710
+ responseFormat: HarnessV1ResponseFormat | undefined;
1711
+ output: OUTPUT | undefined;
1712
+ telemetry: TelemetryOptions | undefined;
1713
+ callbacks: HarnessAgentLifecycleCallbacks<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1714
+ stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
1715
+ }): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1716
+ continueTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
1717
+ model: string | undefined;
1718
+ skills: ReadonlyArray<HarnessV1Skill>;
1719
+ instructions: string | undefined;
1720
+ tools: TOOLS;
1721
+ toolsContext: InferToolSetContext<TOOLS>;
1722
+ activeTools: ToolSet;
1723
+ toolSpecs: HarnessAgentToolSpec[];
1724
+ builtinToolFiltering: HarnessV1BuiltinToolFiltering | undefined;
1725
+ runtimeContext: RUNTIME_CONTEXT;
1726
+ abortSignal: AbortSignal | undefined;
1727
+ responseFormat: HarnessV1ResponseFormat | undefined;
1728
+ output: OUTPUT | undefined;
1729
+ telemetry: TelemetryOptions | undefined;
1730
+ callbacks: HarnessAgentLifecycleCallbacks<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1731
+ stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
1732
+ toolApprovalContinuations?: readonly ToolApprovalResponse[] | undefined;
1733
+ toolResultContinuations?: readonly ToolResultPart[] | undefined;
1734
+ }): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1735
+ /**
1736
+ * Ask the underlying runtime to compact its context. The runtime performs
1737
+ * the compaction itself; when it completes, a `compaction` part appears on
1738
+ * the active (or next) turn's stream. Safe to call between turns for
1739
+ * runtimes whose compaction is session-scoped (e.g. Pi).
1740
+ *
1741
+ * Throws `HarnessCapabilityUnsupportedError` for harnesses that cannot
1742
+ * trigger compaction manually (e.g. Codex, which still auto-compacts under
1743
+ * the hood). Throws if the session has ended.
1744
+ */
1745
+ compact(customInstructions?: string): Promise<void>;
1746
+ /**
1747
+ * Submit another user message to the active turn.
1748
+ *
1749
+ * The runtime accepts the message for its next safe input boundary. Output
1750
+ * caused by the message remains part of the active turn's result stream.
1751
+ */
1752
+ experimental_steerTurn(text: string): Promise<void>;
1753
+ /**
1754
+ * Park the session, returning a payload the caller can persist and later
1755
+ * pass to `agent.createSession({ sessionId, resumeFrom })` to reconnect.
1756
+ * The runtime and sandbox keep running; this local session handle becomes
1757
+ * unusable.
1758
+ */
1759
+ detach(): Promise<HarnessAgentResumeSessionState>;
1760
+ /**
1761
+ * Read the conversation history the runtime itself persisted, normalized
1762
+ * by the adapter. Includes exchanges that happened outside this process —
1763
+ * the same conversation continued interactively in the agent's own CLI,
1764
+ * for instance — which the live event stream never saw.
1765
+ *
1766
+ * Pass a previous result's `cursor` as `since` to read only the delta. A
1767
+ * conversation with no recorded messages yet resolves to an empty
1768
+ * `messages` array.
1769
+ *
1770
+ * Throws `HarnessCapabilityUnsupportedError` when the adapter does not
1771
+ * implement history reads, and
1772
+ * `HarnessHistoryUnavailableError` when the adapter supports them but
1773
+ * cannot reach the runtime's store from this environment.
1774
+ */
1775
+ readHistory(options?: {
1776
+ since?: string;
1777
+ }): Promise<HarnessV1ReadHistoryResult>;
1778
+ /**
1779
+ * Persist enough state to resume later, then stop the runtime and any
1780
+ * harness-owned sandbox.
1781
+ * Returns the resume state for a future
1782
+ * `agent.createSession({ sessionId, resumeFrom })` call.
1783
+ */
1784
+ stop(): Promise<HarnessAgentResumeSessionState>;
1785
+ /**
1786
+ * Stop the runtime and discard resumability. A harness-owned network
1787
+ * sandbox is stopped and destroyed through its `destroy()` method.
1788
+ */
1789
+ destroy(): Promise<void>;
1790
+ /**
1791
+ * Gracefully freeze the active turn at the slice boundary and return the
1792
+ * continuation payload, **leaving the sandbox/runtime running** so the next
1793
+ * process can continue. Resolves once the in-flight `stream()` /
1794
+ * `continueStream()` has cleanly wound down at a precise cursor (see
1795
+ * `doSuspendTurn`).
1796
+ *
1797
+ * After this call the session is detached. This in-process handle no
1798
+ * longer drives turns; a future slice creates a fresh session from the
1799
+ * returned state. The sandbox is **not** stopped because bridge-backed
1800
+ * adapters may still have a live bridge.
1801
+ */
1802
+ suspendTurn(): Promise<HarnessAgentContinueTurnState>;
1803
+ private getPendingToolApprovals;
1804
+ private getPendingToolResults;
1805
+ private addPendingToolState;
1806
+ private suspendCurrentTurn;
1807
+ private finalizeCurrentTurnSuspension;
1808
+ private captureStopConditionBoundary;
1809
+ private toResumeStateWithContinuation;
1810
+ private requirePromptableTurn;
1811
+ private requireContinuableTurn;
1812
+ private markAwaitingApprovalIfActive;
1813
+ private markAwaitingToolResultIfActive;
1814
+ private startTrackedTurn;
1815
+ private setPromptControl;
1816
+ private waitForPromptControl;
1817
+ private settleActivePromptControl;
1818
+ private clearActivePromptControl;
1819
+ private finishTrackedTurn;
1820
+ private resolveActiveTurnSettings;
1821
+ private endLocalHandle;
1822
+ private requireReusableSession;
1799
1823
  }
1800
-
1824
+ //#endregion
1825
+ //#region src/agent/harness-agent.d.ts
1801
1826
  /**
1802
1827
  * Required `session` extension on every `HarnessAgent.generate` /
1803
1828
  * `HarnessAgent.stream` call. The agent operates exclusively on the
@@ -1805,11 +1830,11 @@ declare class HarnessAgentSession {
1805
1830
  * state of its own.
1806
1831
  */
1807
1832
  interface HarnessAgentCallExtensions {
1808
- /**
1809
- * Active session returned by `agent.createSession(...)`. Drives the
1810
- * underlying harness adapter for this turn.
1811
- */
1812
- session: HarnessAgentSession;
1833
+ /**
1834
+ * Active session returned by `agent.createSession(...)`. Drives the
1835
+ * underlying harness adapter for this turn.
1836
+ */
1837
+ session: HarnessAgentSession;
1813
1838
  }
1814
1839
  /**
1815
1840
  * AI SDK `Agent` implementation that drives a third-party agent runtime
@@ -1846,133 +1871,135 @@ interface HarnessAgentCallExtensions {
1846
1871
  * remain owned by the caller and are not stopped or destroyed by the
1847
1872
  * harness layer.
1848
1873
  */
1849
- declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never, CALL_OPTIONS = never> implements Agent<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT> {
1850
- readonly version: "agent-v1";
1851
- readonly id: string | undefined;
1852
- /**
1853
- * Merged tool set exposed to AI SDK consumers: harness builtins +
1854
- * user-defined tools, with user tools overriding builtins on key
1855
- * collision. Built once at construction time so the typed surface is
1856
- * stable across calls.
1857
- */
1858
- readonly tools: HarnessAllTools<THarness, TUserTools>;
1859
- private readonly settings;
1860
- private readonly stopConditions;
1861
- private readonly sandboxConfig;
1862
- private readonly builtinToolFiltering;
1863
- private readonly permissionMode;
1864
- private readonly headers;
1865
- constructor(settings: HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, OUTPUT, CALL_OPTIONS>);
1866
- /** Identifier of the harness backing this agent. */
1867
- get harnessId(): string;
1868
- /** Whether this agent parses completed turns with its configured output. */
1869
- get hasOutput(): boolean;
1870
- getSandboxTemplate(): Promise<HarnessSandboxTemplate | undefined>;
1871
- /**
1872
- * Start a fresh session, or resume from state previously returned by
1873
- * `session.detach()` or `session.stop()`. The returned
1874
- * `HarnessAgentSession` must be passed to subsequent `generate` / `stream`
1875
- * calls; end it with `session.detach()`, `session.stop()`, or
1876
- * `session.destroy()`.
1877
- */
1878
- createSession(options?: {
1879
- /**
1880
- * Optional stable identifier for the underlying sandbox/session.
1881
- * When omitted the agent generates one. Supply the original
1882
- * `session.sessionId` together with `resumeFrom` to reattach a
1883
- * previously ended session across processes.
1884
- */
1885
- sessionId?: string;
1886
- /**
1887
- * Resume payload returned by a prior `session.detach()` or
1888
- * `session.stop()`. Must be accompanied by the original `sessionId`; the
1889
- * framework validates it against `harness.lifecycleStateSchema` before
1890
- * handing it to the adapter.
1891
- */
1892
- resumeFrom?: HarnessAgentResumeSessionState;
1893
- /**
1894
- * Continuation payload returned by a prior `session.suspendTurn()`. Must be
1895
- * accompanied by the original `sessionId`; the framework validates it before
1896
- * handing it to the adapter.
1897
- */
1898
- continueFrom?: HarnessAgentContinueTurnState;
1899
- /**
1900
- * Rebinds host-only tool context for an unfinished turn resumed with
1901
- * `continueFrom` (directly or through `resumeFrom`). Tool context is not
1902
- * serialized into lifecycle state because it may contain credentials or
1903
- * non-serializable host objects.
1904
- */
1905
- toolsContext?: ToolsContextSettings<TUserTools>['toolsContext'];
1906
- /**
1907
- * Rebinds host-only runtime context for an unfinished turn resumed with
1908
- * `continueFrom` (directly or through `resumeFrom`). Runtime context is
1909
- * not serialized into lifecycle state.
1910
- */
1911
- runtimeContext?: RUNTIME_CONTEXT;
1912
- /**
1913
- * Existing sandbox session to run the harness in. When provided, the
1914
- * caller retains ownership of the sandbox lifecycle.
1915
- */
1916
- sandboxSession?: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
1917
- abortSignal?: AbortSignal;
1918
- }): Promise<HarnessAgentSession>;
1919
- generate(options: AgentCallParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1920
- stream(options: AgentStreamParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1921
- /**
1922
- * Continue the in-flight turn **without a new prompt**, draining it like
1923
- * {@link generate}. Used after `createSession({ continueFrom })` to finish
1924
- * consuming a turn that crossed a process boundary.
1925
- */
1926
- continueGenerate(options: {
1927
- session: HarnessAgentSession;
1928
- toolApprovalContinuations?: readonly ToolApprovalResponse[];
1929
- toolResultContinuations?: readonly ToolResultPart[];
1930
- abortSignal?: AbortSignal;
1931
- }): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1932
- /**
1933
- * Continue the in-flight turn **without a new prompt**, streaming its events
1934
- * like {@link stream}. Used to keep consuming a turn that is still running
1935
- * (or finished) in the runtime after a process boundary — the workflow slice
1936
- * loop calls this on every slice after the first. Routes through the adapter's
1937
- * `doContinueTurn`; what it can guarantee (lossless attach vs. lossy rerun)
1938
- * follows from how the adapter resumed the session.
1939
- */
1940
- continueStream(options: {
1941
- session: HarnessAgentSession;
1942
- toolApprovalContinuations?: readonly ToolApprovalResponse[];
1943
- toolResultContinuations?: readonly ToolResultPart[];
1944
- abortSignal?: AbortSignal;
1945
- }): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1946
- /**
1947
- * Submit another user message to a currently running session turn.
1948
- *
1949
- * The returned promise resolves after the runtime has accepted the message
1950
- * for its next safe input boundary. Output caused by the message remains in
1951
- * the current turn's stream.
1952
- */
1953
- experimental_steer(options: {
1954
- session: HarnessAgentSession;
1955
- text: string;
1956
- }): Promise<void>;
1957
- private _startPromptTurn;
1958
- private _startContinueTurn;
1959
- private _buildTurnOptions;
1960
- private _resolveLifecycleCallbacks;
1961
- private _resolveContinueTurnInput;
1962
- private _resolvePromptTurnInput;
1963
- private _preparePromptTurnInput;
1964
- private _prepareContinueTurnInput;
1965
- private _prepareTurnSettings;
1966
- private _toToolSpecs;
1967
- private _toGenerateResult;
1968
- private _resolveResponseFormat;
1874
+ export declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never, CALL_OPTIONS = never> implements Agent<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT> {
1875
+ readonly version: "agent-v1";
1876
+ readonly id: string | undefined;
1877
+ /**
1878
+ * Merged tool set exposed to AI SDK consumers: harness builtins +
1879
+ * user-defined tools, with user tools overriding builtins on key
1880
+ * collision. Built once at construction time so the typed surface is
1881
+ * stable across calls.
1882
+ */
1883
+ readonly tools: HarnessAllTools<THarness, TUserTools>;
1884
+ private readonly settings;
1885
+ private readonly stopConditions;
1886
+ private readonly sandboxConfig;
1887
+ private readonly builtinToolFiltering;
1888
+ private readonly permissionMode;
1889
+ private readonly headers;
1890
+ constructor(settings: HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, OUTPUT, CALL_OPTIONS>);
1891
+ /** Identifier of the harness backing this agent. */
1892
+ get harnessId(): string;
1893
+ /** Whether this agent parses completed turns with its configured output. */
1894
+ get hasOutput(): boolean;
1895
+ getSandboxTemplate(): Promise<HarnessSandboxTemplate | undefined>;
1896
+ /**
1897
+ * Start a fresh session, or resume from state previously returned by
1898
+ * `session.detach()` or `session.stop()`. The returned
1899
+ * `HarnessAgentSession` must be passed to subsequent `generate` / `stream`
1900
+ * calls; end it with `session.detach()`, `session.stop()`, or
1901
+ * `session.destroy()`.
1902
+ */
1903
+ createSession(options?: {
1904
+ /**
1905
+ * Optional stable identifier for the underlying sandbox/session.
1906
+ * When omitted the agent generates one. Supply the original
1907
+ * `session.sessionId` together with `resumeFrom` to reattach a
1908
+ * previously ended session across processes.
1909
+ */
1910
+ sessionId?: string;
1911
+ /**
1912
+ * Resume payload returned by a prior `session.detach()` or
1913
+ * `session.stop()`. Must be accompanied by the original `sessionId`; the
1914
+ * framework validates it against `harness.lifecycleStateSchema` before
1915
+ * handing it to the adapter.
1916
+ */
1917
+ resumeFrom?: HarnessAgentResumeSessionState;
1918
+ /**
1919
+ * Continuation payload returned by a prior `session.suspendTurn()`. Must be
1920
+ * accompanied by the original `sessionId`; the framework validates it before
1921
+ * handing it to the adapter.
1922
+ */
1923
+ continueFrom?: HarnessAgentContinueTurnState;
1924
+ /**
1925
+ * Rebinds host-only tool context for an unfinished turn resumed with
1926
+ * `continueFrom` (directly or through `resumeFrom`). Tool context is not
1927
+ * serialized into lifecycle state because it may contain credentials or
1928
+ * non-serializable host objects.
1929
+ */
1930
+ toolsContext?: ToolsContextSettings<TUserTools>['toolsContext'];
1931
+ /**
1932
+ * Rebinds host-only runtime context for an unfinished turn resumed with
1933
+ * `continueFrom` (directly or through `resumeFrom`). Runtime context is
1934
+ * not serialized into lifecycle state.
1935
+ */
1936
+ runtimeContext?: RUNTIME_CONTEXT;
1937
+ /**
1938
+ * Existing sandbox session to run the harness in. When provided, the
1939
+ * caller retains ownership of the sandbox lifecycle.
1940
+ */
1941
+ sandboxSession?: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
1942
+ abortSignal?: AbortSignal;
1943
+ }): Promise<HarnessAgentSession>;
1944
+ generate(options: AgentCallParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1945
+ stream(options: AgentStreamParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1946
+ /**
1947
+ * Continue the in-flight turn **without a new prompt**, draining it like
1948
+ * {@link generate}. Used after `createSession({ continueFrom })` to finish
1949
+ * consuming a turn that crossed a process boundary.
1950
+ */
1951
+ continueGenerate(options: {
1952
+ session: HarnessAgentSession;
1953
+ toolApprovalContinuations?: readonly ToolApprovalResponse[];
1954
+ toolResultContinuations?: readonly ToolResultPart[];
1955
+ abortSignal?: AbortSignal;
1956
+ }): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1957
+ /**
1958
+ * Continue the in-flight turn **without a new prompt**, streaming its events
1959
+ * like {@link stream}. Used to keep consuming a turn that is still running
1960
+ * (or finished) in the runtime after a process boundary — the workflow slice
1961
+ * loop calls this on every slice after the first. Routes through the adapter's
1962
+ * `doContinueTurn`; what it can guarantee (lossless attach vs. lossy rerun)
1963
+ * follows from how the adapter resumed the session.
1964
+ */
1965
+ continueStream(options: {
1966
+ session: HarnessAgentSession;
1967
+ toolApprovalContinuations?: readonly ToolApprovalResponse[];
1968
+ toolResultContinuations?: readonly ToolResultPart[];
1969
+ abortSignal?: AbortSignal;
1970
+ }): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1971
+ /**
1972
+ * Submit another user message to a currently running session turn.
1973
+ *
1974
+ * The returned promise resolves after the runtime has accepted the message
1975
+ * for its next safe input boundary. Output caused by the message remains in
1976
+ * the current turn's stream.
1977
+ */
1978
+ experimental_steer(options: {
1979
+ session: HarnessAgentSession;
1980
+ text: string;
1981
+ }): Promise<void>;
1982
+ private _startPromptTurn;
1983
+ private _startContinueTurn;
1984
+ private _buildTurnOptions;
1985
+ private _resolveLifecycleCallbacks;
1986
+ private _resolveContinueTurnInput;
1987
+ private _resolvePromptTurnInput;
1988
+ private _preparePromptTurnInput;
1989
+ private _prepareContinueTurnInput;
1990
+ private _prepareTurnSettings;
1991
+ private _toToolSpecs;
1992
+ private _toGenerateResult;
1993
+ private _resolveResponseFormat;
1969
1994
  }
1970
-
1971
- declare function createHarnessSandboxTemplate(options: {
1972
- readonly harnesses: ReadonlyArray<HarnessAgentAdapter>;
1973
- readonly sandboxConfig?: Omit<HarnessAgentSandboxConfig, 'onSession'>;
1995
+ //#endregion
1996
+ //#region src/agent/create-harness-sandbox-template.d.ts
1997
+ export declare function createHarnessSandboxTemplate(options: {
1998
+ readonly harnesses: ReadonlyArray<HarnessAgentAdapter>;
1999
+ readonly sandboxConfig?: Omit<HarnessAgentSandboxConfig, 'onSession'>;
1974
2000
  }): Promise<HarnessSandboxTemplate | undefined>;
1975
-
2001
+ //#endregion
2002
+ //#region src/agent/harness-agent-tool-approval-continuation.d.ts
1976
2003
  /**
1977
2004
  * Extract approval decisions that should continue a suspended harness turn.
1978
2005
  *
@@ -1983,17 +2010,19 @@ declare function createHarnessSandboxTemplate(options: {
1983
2010
  * Responses that already have a tool result are ignored, because those
1984
2011
  * approvals were already consumed by a prior continuation.
1985
2012
  */
1986
- declare function collectHarnessAgentToolApprovalContinuations(input: {
1987
- messages: readonly ModelMessage[];
2013
+ export declare function collectHarnessAgentToolApprovalContinuations(input: {
2014
+ messages: readonly ModelMessage[];
1988
2015
  }): readonly ToolApprovalResponse[];
1989
-
2016
+ //#endregion
2017
+ //#region src/agent/harness-agent-tool-result-continuation.d.ts
1990
2018
  /**
1991
2019
  * Extract client-provided tool results from the trailing tool message.
1992
2020
  */
1993
- declare function collectHarnessAgentToolResultContinuations(input: {
1994
- messages: readonly ModelMessage[];
2021
+ export declare function collectHarnessAgentToolResultContinuations(input: {
2022
+ messages: readonly ModelMessage[];
1995
2023
  }): readonly ToolResultPart[];
1996
-
2024
+ //#endregion
2025
+ //#region src/agent/prepare-harness-sandbox-template.d.ts
1997
2026
  type SandboxBootstrapSettings = Omit<HarnessAgentSandboxConfig, 'onSession'>;
1998
2027
  /**
1999
2028
  * Prepare a harness's sandbox template without running an agent. Idempotent: if
@@ -2009,20 +2038,21 @@ type SandboxBootstrapSettings = Omit<HarnessAgentSandboxConfig, 'onSession'>;
2009
2038
  * provider's native storage.
2010
2039
  * @deprecated Use `createHarnessSandboxTemplate` and pass its template to a sandbox session creator instead.
2011
2040
  */
2012
- declare function prepareHarnessSandboxTemplate(options: {
2013
- readonly harness: HarnessAgentAdapter;
2014
- readonly sandboxProvider: HarnessV1SandboxProvider;
2015
- readonly sandboxConfig?: SandboxBootstrapSettings;
2016
- readonly abortSignal?: AbortSignal;
2041
+ export declare function prepareHarnessSandboxTemplate(options: {
2042
+ readonly harness: HarnessAgentAdapter;
2043
+ readonly sandboxProvider: HarnessV1SandboxProvider;
2044
+ readonly sandboxConfig?: SandboxBootstrapSettings;
2045
+ readonly abortSignal?: AbortSignal;
2017
2046
  }): Promise<void>;
2018
2047
  /** @deprecated Use `prepareHarnessSandboxTemplate` instead. */
2019
- declare const prewarmHarness: typeof prepareHarnessSandboxTemplate;
2020
-
2048
+ export declare const prewarmHarness: typeof prepareHarnessSandboxTemplate;
2049
+ //#endregion
2050
+ //#region src/agent/prepare-sandbox-for-harness.d.ts
2021
2051
  /** @deprecated Use `createHarnessSandboxTemplate` and `template.prepare` instead. */
2022
2052
  type PrepareSandboxForHarnessResult = {
2023
- readonly identity?: string;
2024
- readonly recipeIdentities: Record<string, string>;
2025
- readonly skippedHarnessIds: ReadonlyArray<string>;
2053
+ readonly identity?: string;
2054
+ readonly recipeIdentities: Record<string, string>;
2055
+ readonly skippedHarnessIds: ReadonlyArray<string>;
2026
2056
  };
2027
2057
  /**
2028
2058
  * Apply one or more harness bootstrap recipes to an existing sandbox session.
@@ -2045,28 +2075,30 @@ type PrepareSandboxForHarnessResult = {
2045
2075
  * ID, the last adapter in `harnesses` is used.
2046
2076
  * @deprecated Use `createHarnessSandboxTemplate` and `template.prepare` instead.
2047
2077
  */
2048
- declare function prepareSandboxForHarness(options: {
2049
- readonly session: Experimental_SandboxSession;
2050
- readonly harnesses: ReadonlyArray<HarnessAgentAdapter>;
2051
- readonly sandboxConfig?: HarnessAgentSandboxConfig;
2052
- readonly abortSignal?: AbortSignal;
2078
+ export declare function prepareSandboxForHarness(options: {
2079
+ readonly session: Experimental_SandboxSession;
2080
+ readonly harnesses: ReadonlyArray<HarnessAgentAdapter>;
2081
+ readonly sandboxConfig?: HarnessAgentSandboxConfig;
2082
+ readonly abortSignal?: AbortSignal;
2053
2083
  }): Promise<PrepareSandboxForHarnessResult>;
2054
-
2084
+ //#endregion
2085
+ //#region src/errors/harness-error.d.ts
2055
2086
  declare const symbol$2: unique symbol;
2056
2087
  /**
2057
2088
  * Base error type for failures originating in or signalled by a harness
2058
2089
  * adapter. Specific failure modes (e.g. unsupported capability) extend this
2059
2090
  * class.
2060
2091
  */
2061
- declare class HarnessError extends AISDKError {
2062
- private readonly [symbol$2];
2063
- constructor({ message, cause }: {
2064
- message: string;
2065
- cause?: unknown;
2066
- });
2067
- static isInstance(error: unknown): error is HarnessError;
2092
+ export declare class HarnessError extends AISDKError {
2093
+ private readonly [symbol$2];
2094
+ constructor({ message, cause }: {
2095
+ message: string;
2096
+ cause?: unknown;
2097
+ });
2098
+ static isInstance(error: unknown): error is HarnessError;
2068
2099
  }
2069
-
2100
+ //#endregion
2101
+ //#region src/errors/harness-capability-unsupported-error.d.ts
2070
2102
  declare const symbol$1: unique symbol;
2071
2103
  /**
2072
2104
  * Thrown when a caller asks the harness to do something the adapter (or the
@@ -2077,17 +2109,18 @@ declare const symbol$1: unique symbol;
2077
2109
  * The caller supplies the full human-readable message. Optional `harnessId`
2078
2110
  * is recorded as structured context for tooling.
2079
2111
  */
2080
- declare class HarnessCapabilityUnsupportedError extends HarnessError {
2081
- private readonly [symbol$1];
2082
- readonly harnessId?: string;
2083
- constructor({ message, harnessId, cause, }: {
2084
- message: string;
2085
- harnessId?: string;
2086
- cause?: unknown;
2087
- });
2088
- static isInstance(error: unknown): error is HarnessCapabilityUnsupportedError;
2112
+ export declare class HarnessCapabilityUnsupportedError extends HarnessError {
2113
+ private readonly [symbol$1];
2114
+ readonly harnessId?: string;
2115
+ constructor({ message, harnessId, cause }: {
2116
+ message: string;
2117
+ harnessId?: string;
2118
+ cause?: unknown;
2119
+ });
2120
+ static isInstance(error: unknown): error is HarnessCapabilityUnsupportedError;
2089
2121
  }
2090
-
2122
+ //#endregion
2123
+ //#region src/errors/harness-sandbox-authentication-error.d.ts
2091
2124
  declare const symbol: unique symbol;
2092
2125
  /**
2093
2126
  * Thrown when a sandbox provider cannot authenticate or authorize the
@@ -2095,25 +2128,27 @@ declare const symbol: unique symbol;
2095
2128
  * preserve the underlying SDK failure as `cause` and supply a message that
2096
2129
  * explains how the consumer can configure credentials.
2097
2130
  */
2098
- declare class HarnessSandboxAuthenticationError extends HarnessError {
2099
- private readonly [symbol];
2100
- readonly sandboxProviderId: string;
2101
- constructor({ message, sandboxProviderId, cause, }: {
2102
- message: string;
2103
- sandboxProviderId: string;
2104
- cause?: unknown;
2105
- });
2106
- static isInstance(error: unknown): error is HarnessSandboxAuthenticationError;
2131
+ export declare class HarnessSandboxAuthenticationError extends HarnessError {
2132
+ private readonly [symbol];
2133
+ readonly sandboxProviderId: string;
2134
+ constructor({ message, sandboxProviderId, cause }: {
2135
+ message: string;
2136
+ sandboxProviderId: string;
2137
+ cause?: unknown;
2138
+ });
2139
+ static isInstance(error: unknown): error is HarnessSandboxAuthenticationError;
2107
2140
  }
2108
-
2141
+ //#endregion
2142
+ //#region src/agent/get-harness-error-message.d.ts
2109
2143
  /**
2110
2144
  * Returns a client-safe message for errors produced by the harness runtime.
2111
2145
  * Messages from explicitly reviewed harness error types are preserved. All
2112
2146
  * other errors are masked so provider, sandbox, and server details are not
2113
2147
  * exposed to clients by default.
2114
2148
  */
2115
- declare function getHarnessErrorMessage(error: unknown): string;
2116
-
2149
+ export declare function getHarnessErrorMessage(error: unknown): string;
2150
+ //#endregion
2151
+ //#region src/agent/observability/file-reporter.d.ts
2117
2152
  /**
2118
2153
  * A harness observability reporter that writes a unified, non-lossy
2119
2154
  * `events.jsonl` containing **both** the telemetry span lifecycle (turn / step
@@ -2126,20 +2161,21 @@ declare function getHarnessErrorMessage(error: unknown): string;
2126
2161
  * replacement for the original SDK's host-side artifact files.
2127
2162
  */
2128
2163
  interface FileReporterOptions {
2129
- /** Directory for `events.jsonl` (created if absent). */
2130
- dir: string;
2131
- /**
2132
- * Buffer a turn's records in memory and write them only if the turn produced
2133
- * an error (an `error`-level diagnostic, a failed tool, or an error finish).
2134
- * Default false (write everything).
2135
- */
2136
- failOnly?: boolean;
2137
- /** File name within `dir`. Default `events.jsonl`. */
2138
- fileName?: string;
2164
+ /** Directory for `events.jsonl` (created if absent). */
2165
+ dir: string;
2166
+ /**
2167
+ * Buffer a turn's records in memory and write them only if the turn produced
2168
+ * an error (an `error`-level diagnostic, a failed tool, or an error finish).
2169
+ * Default false (write everything).
2170
+ */
2171
+ failOnly?: boolean;
2172
+ /** File name within `dir`. Default `events.jsonl`. */
2173
+ fileName?: string;
2139
2174
  }
2140
2175
  type FileReporter = Telemetry & HarnessDiagnosticConsumer;
2141
- declare function createFileReporter(options: FileReporterOptions): FileReporter;
2142
-
2176
+ export declare function createFileReporter(options: FileReporterOptions): FileReporter;
2177
+ //#endregion
2178
+ //#region src/agent/observability/trace-tree-reporter.d.ts
2143
2179
  /**
2144
2180
  * A harness observability reporter that renders an ASCII trace tree of a
2145
2181
  * turn's span lifecycle (turn → steps → tools) to a stream at turn end. It is a
@@ -2148,9 +2184,10 @@ declare function createFileReporter(options: FileReporterOptions): FileReporter;
2148
2184
  * backend (via `@ai-sdk/otel`) is a strict superset.
2149
2185
  */
2150
2186
  interface TraceTreeReporterOptions {
2151
- /** Where to write the rendered tree. Default `process.stderr.write`. */
2152
- write?: (chunk: string) => void;
2187
+ /** Where to write the rendered tree. Default `process.stderr.write`. */
2188
+ write?: (chunk: string) => void;
2153
2189
  }
2154
- declare function createTraceTreeReporter(options?: TraceTreeReporterOptions): Telemetry;
2155
-
2156
- export { type FileReporter, type FileReporterOptions, HarnessAgent, type HarnessAgentAdapter, type HarnessAgentAdapterSession, type HarnessAgentBuiltinTool, type HarnessAgentBuiltinToolName, type HarnessAgentBuiltinToolUseKind, type HarnessAgentBuiltinTools, type HarnessAgentContinueTurnOptions, type HarnessAgentContinueTurnState, type HarnessAgentLifecycleState, type HarnessAgentPendingToolApproval, type HarnessAgentPendingToolResult, type HarnessAgentPermissionMode, type HarnessAgentPrompt, type HarnessAgentPromptControl, type HarnessAgentPromptTurnOptions, type HarnessAgentResumeSessionState, type HarnessAgentSandboxConfig, HarnessAgentSession, type HarnessAgentSettings, type HarnessAgentSkill, type HarnessAgentStartOptions, type HarnessAgentStreamPart, type HarnessAgentToolApprovalConfiguration, type HarnessAgentToolSpec, type HarnessAllTools, HarnessCapabilityUnsupportedError, type HarnessDebugConfig, type HarnessDebugLevel, type HarnessDiagnostic, type HarnessDiagnosticConsumer, HarnessError, HarnessSandboxAuthenticationError, type HarnessSandboxTemplate, type PrepareSandboxForHarnessResult, type TraceTreeReporterOptions, collectHarnessAgentToolApprovalContinuations, collectHarnessAgentToolResultContinuations, createFileReporter, createHarnessSandboxTemplate, createTraceTreeReporter, getHarnessErrorMessage, prepareHarnessSandboxTemplate, prepareSandboxForHarness, prewarmHarness };
2190
+ export declare function createTraceTreeReporter(options?: TraceTreeReporterOptions): Telemetry;
2191
+ //#endregion
2192
+ export type { FileReporter, FileReporterOptions, HarnessAgentAdapter, HarnessAgentAdapterSession, HarnessAgentBuiltinTool, HarnessAgentBuiltinToolName, HarnessAgentBuiltinToolUseKind, HarnessAgentBuiltinTools, HarnessAgentContinueTurnOptions, HarnessAgentContinueTurnState, HarnessAgentLifecycleState, HarnessAgentPendingToolApproval, HarnessAgentPendingToolResult, HarnessAgentPermissionMode, HarnessAgentPrompt, HarnessAgentPromptControl, HarnessAgentPromptTurnOptions, HarnessAgentResumeSessionState, HarnessAgentSandboxConfig, HarnessAgentSettings, HarnessAgentSkill, HarnessAgentStartOptions, HarnessAgentStreamPart, HarnessAgentToolApprovalConfiguration, HarnessAgentToolSpec, HarnessAllTools, HarnessDebugConfig, HarnessDebugLevel, HarnessDiagnostic, HarnessDiagnosticConsumer, HarnessSandboxTemplate, PrepareSandboxForHarnessResult, TraceTreeReporterOptions };
2193
+ //# sourceMappingURL=index.d.ts.map