@ai-sdk/harness 1.0.132 → 1.0.134

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, 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,92 +614,154 @@ 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;
693
+ };
694
+ //#endregion
695
+ //#region src/v1/harness-v1-message.d.ts
696
+ type LanguageModelV4ToolResultContentPart = Extract<LanguageModelV4ToolResultOutput, {
697
+ type: 'content';
698
+ }>['value'][number];
699
+ type HarnessV1TextPart = Omit<LanguageModelV4TextPart, 'providerOptions'>;
700
+ type HarnessV1FilePart = Omit<LanguageModelV4FilePart, 'providerOptions'>;
701
+ type HarnessV1CustomPart = Omit<LanguageModelV4CustomPart, 'providerOptions'>;
702
+ type HarnessV1ReasoningPart = Omit<LanguageModelV4ReasoningPart, 'providerOptions'>;
703
+ type HarnessV1ReasoningFilePart = Omit<LanguageModelV4ReasoningFilePart, 'providerOptions'>;
704
+ type HarnessV1ToolCallPart = Omit<LanguageModelV4ToolCallPart, 'providerOptions'> & {
705
+ nativeName?: string;
706
+ };
707
+ type HarnessV1ToolResultOutput = Omit<Extract<LanguageModelV4ToolResultOutput, {
708
+ type: 'text';
709
+ }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultOutput, {
710
+ type: 'json';
711
+ }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultOutput, {
712
+ type: 'execution-denied';
713
+ }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultOutput, {
714
+ type: 'error-text';
715
+ }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultOutput, {
716
+ type: 'error-json';
717
+ }>, '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'>>;
726
+ };
727
+ type HarnessV1ToolResultPart = Omit<LanguageModelV4ToolResultPart, 'output' | 'providerOptions'> & {
728
+ output: HarnessV1ToolResultOutput;
729
+ };
730
+ type HarnessV1ToolApprovalResponsePart = Omit<LanguageModelV4ToolApprovalResponsePart, 'providerOptions'>;
731
+ type HarnessV1UserMessage = {
732
+ readonly role: 'user';
733
+ readonly content: Array<HarnessV1TextPart | HarnessV1FilePart>;
734
+ readonly at?: string;
735
+ readonly harnessMetadata?: HarnessV1Metadata;
682
736
  };
683
-
737
+ type HarnessV1AssistantMessage = {
738
+ readonly role: 'assistant';
739
+ readonly content: Array<HarnessV1TextPart | HarnessV1FilePart | HarnessV1CustomPart | HarnessV1ReasoningPart | HarnessV1ReasoningFilePart | HarnessV1ToolCallPart | HarnessV1ToolResultPart>;
740
+ readonly at?: string;
741
+ readonly harnessMetadata?: HarnessV1Metadata;
742
+ };
743
+ type HarnessV1ToolMessage = {
744
+ readonly role: 'tool';
745
+ readonly content: Array<HarnessV1ToolResultPart | HarnessV1ToolApprovalResponsePart>;
746
+ readonly at?: string;
747
+ readonly harnessMetadata?: HarnessV1Metadata;
748
+ };
749
+ /**
750
+ * A persisted harness message using V4 prompt content shapes and metadata
751
+ * scoped to the adapter that produced it.
752
+ */
753
+ type HarnessV1Message = HarnessV1UserMessage | HarnessV1AssistantMessage | HarnessV1ToolMessage;
754
+ //#endregion
755
+ //#region src/v1/harness-v1-tool-filtering.d.ts
684
756
  type HarnessV1BuiltinToolFiltering = {
685
- mode: 'allow';
686
- toolNames: string[];
757
+ mode: 'allow';
758
+ toolNames: string[];
687
759
  } | {
688
- mode: 'deny';
689
- toolNames: string[];
760
+ mode: 'deny';
761
+ toolNames: string[];
690
762
  };
691
-
763
+ //#endregion
764
+ //#region src/v1/harness-v1-session.d.ts
692
765
  /**
693
766
  * Options passed to `HarnessV1.doStart`.
694
767
  *
@@ -697,93 +770,101 @@ type HarnessV1BuiltinToolFiltering = {
697
770
  * calling the adapter, so adapters never need to derive provider-specific paths.
698
771
  */
699
772
  type HarnessV1StartOptions = {
700
- /**
701
- * Additional normalized HTTP headers to send with model requests.
702
- */
703
- readonly headers?: Readonly<Record<string, string>>;
704
- /**
705
- * Stable identifier for this harness session. Used as the underlying
706
- * resource name where the adapter has a notion of a named session
707
- * (sandbox name, native session id, …).
708
- */
709
- readonly sessionId: string;
710
- /**
711
- * Optional resume payload returned by a prior session lifecycle method. When
712
- * provided, the adapter should resume the existing session before accepting a
713
- * new prompt or continuing a nested unfinished turn.
714
- */
715
- readonly resumeFrom?: HarnessV1ResumeSessionState;
716
- /**
717
- * Optional continuation payload returned by `doSuspendTurn`, or nested in
718
- * `resumeFrom`. When provided, the adapter should resume the existing session
719
- * in a shape ready for `doContinueTurn` rather than for a fresh prompt.
720
- */
721
- readonly continueFrom?: HarnessV1ContinueTurnState;
722
- /**
723
- * Approval policy for built-in adapter-native tool use. Custom host-executed
724
- * tools are approved by the framework before results are submitted back to
725
- * the adapter.
726
- */
727
- readonly permissionMode?: HarnessV1PermissionMode;
728
- /**
729
- * Adapter-native built-in tools that should be available for this session.
730
- * Custom host-executed tools are filtered by the framework before they reach
731
- * the adapter.
732
- */
733
- readonly builtinToolFiltering?: HarnessV1BuiltinToolFiltering;
734
- /**
735
- * Signal that aborts startup. The adapter must propagate cancellation to
736
- * any spawned processes or network calls.
737
- */
738
- readonly abortSignal?: AbortSignal;
739
- /**
740
- * Diagnostics wiring. The framework populates this; the adapter only
741
- * forwards `observability.onDiagnostic` into its `SandboxChannel` and
742
- * `observability.debug` into the bridge `start` message. Absent when the
743
- * consumer has not enabled diagnostics.
744
- */
745
- readonly observability?: HarnessV1Observability;
746
- /**
747
- * Sandbox session the adapter operates against. Network sandbox sessions
748
- * expose optional infrastructure capabilities for bridge wiring; caller-
749
- * provided basic sandbox sessions expose only filesystem and process APIs.
750
- * Adapters must not stop or destroy the sandbox themselves.
751
- */
752
- readonly sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
753
- /**
754
- * Absolute path the adapter runs the agent in for this session. Composed
755
- * underneath the sandbox's resolved default working directory and created
756
- * before `doStart`.
757
- */
758
- 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;
832
+ };
833
+ /**
834
+ * Result of `HarnessV1Session.doReadHistory`.
835
+ */
836
+ type HarnessV1ReadHistoryResult = {
837
+ readonly messages: ReadonlyArray<HarnessV1Message>;
838
+ /** Opaque position; pass back as `since` to read only what follows. */
839
+ readonly cursor: string;
759
840
  };
760
841
  /**
761
842
  * Options passed to `HarnessV1Session.doPromptTurn`.
762
843
  */
763
844
  type HarnessV1PromptTurnOptions = HarnessV1TurnSettings & {
764
- /**
765
- * Fresh input for this turn — either a plain string or a single
766
- * `ModelMessage`. The harness session owns its own conversation history,
767
- * so prior turns are never replayed across the contract.
768
- */
769
- readonly prompt: HarnessV1Prompt;
770
- /**
771
- * Response format requested for this turn. Adapters that cannot honor a
772
- * JSON response format must throw `HarnessCapabilityUnsupportedError`.
773
- */
774
- readonly responseFormat?: HarnessV1ResponseFormat;
775
- /**
776
- * Signal that aborts the in-flight turn. The adapter must cancel any
777
- * underlying work and resolve `done` (with an error if appropriate).
778
- */
779
- readonly abortSignal?: AbortSignal;
780
- /**
781
- * Callback invoked once for each event the adapter produces during the
782
- * turn. The adapter is responsible for the ordering and completeness of
783
- * events. `done` resolves once the adapter has emitted all events for the
784
- * turn (success or failure).
785
- */
786
- 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;
787
868
  };
788
869
  /**
789
870
  * Options passed to `HarnessV1Session.doContinueTurn`.
@@ -793,21 +874,21 @@ type HarnessV1PromptTurnOptions = HarnessV1TurnSettings & {
793
874
  * that was previously suspended temporarily, e.g. by the workflow slice loop.
794
875
  */
795
876
  type HarnessV1ContinueTurnOptions = HarnessV1TurnSettings & {
796
- /**
797
- * Response format of the in-flight turn. Rerun-based adapters use this when
798
- * reconstructing the turn; attach-based adapters may ignore it.
799
- */
800
- readonly responseFormat?: HarnessV1ResponseFormat;
801
- /**
802
- * Signal that aborts the continued turn. The adapter must cancel any
803
- * underlying work and resolve `done` (with an error if appropriate).
804
- */
805
- readonly abortSignal?: AbortSignal;
806
- /**
807
- * Callback invoked once for each event the adapter produces while the
808
- * continued turn runs. Same contract as `doPromptTurn`'s `emit`.
809
- */
810
- 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;
811
892
  };
812
893
  /**
813
894
  * Active harness session, returned by `HarnessV1.doStart`.
@@ -818,94 +899,122 @@ type HarnessV1ContinueTurnOptions = HarnessV1TurnSettings & {
818
899
  * instance via `doDetach`, `doStop`, or `doDestroy`.
819
900
  */
820
901
  type HarnessV1Session = {
821
- /**
822
- * Stable identifier for this session. Same value the host passed in via
823
- * `HarnessV1StartOptions.sessionId`.
824
- */
825
- readonly sessionId: string;
826
- /**
827
- * Whether this session was created from `resumeFrom` or `continueFrom`. Fresh
828
- * sessions report `false`; resumed sessions report `true`.
829
- */
830
- readonly isResume: boolean;
831
- /**
832
- * Run one prompt turn. Returns a control handle the host uses to feed
833
- * tool results, approvals, and user messages back into the turn while it
834
- * is in flight. The handle's `done` promise resolves when the turn ends.
835
- */
836
- doPromptTurn(options: HarnessV1PromptTurnOptions): PromiseLike<HarnessV1PromptControl>;
837
- /**
838
- * Request that the underlying runtime compact its context. The runtime owns
839
- * the compaction — the harness neither implements nor schedules it; this is
840
- * only the trigger. When compaction completes, the adapter surfaces a
841
- * `compaction` stream part on the next/active turn.
842
- *
843
- * Required, but not every runtime can honour it: adapters whose transport
844
- * exposes no manual compaction (e.g. Codex over `codex exec`, which still
845
- * auto-compacts on its own) throw `HarnessCapabilityUnsupportedError`.
846
- * `customInstructions`, when supported, steer the compaction summary.
847
- */
848
- doCompact(customInstructions?: string): PromiseLike<void>;
849
- /**
850
- * Continue the in-flight turn **without a new user prompt**, returning the
851
- * same control surface as `doPromptTurn`. Used to keep consuming a turn that
852
- * was suspended at a process boundary (the workflow slice loop), after the
853
- * session itself has been resumed via `doStart({ continueFrom })`:
854
- *
855
- * - When the runtime's turn is still live and reachable (bridge `attach` /
856
- * `replay`), the adapter subscribes to its events and resolves `done` on
857
- * the turn's `finish` — **without** re-driving it. Lossless.
858
- * - When the live turn is gone (bridge respawned `rerun`, or a host-resident
859
- * runtime like Pi whose turn cannot survive its process), the adapter
860
- * re-drives the runtime's own thread from its persisted state. Lossy: work
861
- * in flight at the suspension is recomputed.
862
- *
863
- * Required on every adapter. The behaviour an adapter can guarantee follows
864
- * from its architecture; the contract is uniform.
865
- */
866
- doContinueTurn(options: HarnessV1ContinueTurnOptions): PromiseLike<HarnessV1PromptControl>;
867
- /**
868
- * Gracefully freeze the active turn **at a precise cursor while keeping the
869
- * runtime alive**, returning the continuation payload.
870
- *
871
- * This is the slice-boundary primitive. The adapter stops host-side
872
- * consumption of the in-flight turn without telling the runtime to stop:
873
- * for a bridge adapter it closes the host socket (the bridge keeps the turn
874
- * running and accumulates events for replay) and resolves the active
875
- * `doPromptTurn`/`doContinueTurn` `done` **cleanly** (not as an error) once buffered
876
- * events have drained, so the cursor in the returned state equals the last
877
- * event delivered to the host — guaranteeing the next slice's attach replays
878
- * with no gap and no duplicate. A host-resident adapter (Pi) cannot keep its
879
- * turn alive, so it persists what it can and the in-flight tail is recomputed
880
- * on continue.
881
- *
882
- * Like `doDetach`, the sandbox/runtime is left running. Unlike `doDetach`,
883
- * this is for an active turn at a slice boundary rather than a between-turn
884
- * session handoff. Required on every adapter.
885
- */
886
- doSuspendTurn(): PromiseLike<HarnessV1ContinueTurnState>;
887
- /**
888
- * Detach from the underlying runtime without tearing it down, returning a
889
- * payload the host can later pass to
890
- * `HarnessV1.doStart({ resumeFrom })` to reconnect before a new turn. After
891
- * `doDetach`, no further methods on this session instance may be called.
892
- *
893
- * Required. Adapters that cannot keep a live runtime parked still return the
894
- * best resume session state they can while leaving the sandbox running.
895
- */
896
- doDetach(): PromiseLike<HarnessV1ResumeSessionState>;
897
- /**
898
- * Persist enough state to resume later, then stop the underlying runtime.
899
- * After `doStop`, no further methods on this session instance may be called.
900
- */
901
- doStop(): PromiseLike<HarnessV1ResumeSessionState>;
902
- /**
903
- * Stop the underlying runtime without returning lifecycle state. After
904
- * `doDestroy`, no further methods on this session instance may be called.
905
- */
906
- 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>;
907
1015
  };
908
-
1016
+ //#endregion
1017
+ //#region src/v1/harness-v1.d.ts
909
1018
  /**
910
1019
  * Versioned specification for a harness adapter — the integration point for
911
1020
  * one third-party coding-agent runtime (Claude Code, Codex, …).
@@ -920,73 +1029,74 @@ type HarnessV1Session = {
920
1029
  * capability.
921
1030
  */
922
1031
  type HarnessV1<TBuiltinTools extends ToolSet = ToolSet> = {
923
- /**
924
- * Spec version this adapter implements. Always the literal `'harness-v1'`.
925
- */
926
- readonly specificationVersion: 'harness-v1';
927
- /**
928
- * Stable identifier for this harness, used as the key inside
929
- * `HarnessV1Metadata` objects. Conventionally a kebab-case slug matching
930
- * the package name (`'claude-code'`, `'codex'`).
931
- */
932
- readonly harnessId: string;
933
- /**
934
- * Tools the adapter's underlying runtime exposes natively, as a `ToolSet`
935
- * keyed by what the bridge emits on `tool-call` events
936
- * (`commonName ?? nativeName`). Each entry is a `HarnessV1BuiltinTool`
937
- * (a `Tool` plus harness-specific `nativeName` / `commonName` metadata).
938
- *
939
- * The agent merges this with consumer-supplied user tools when validating
940
- * inbound tool calls and when typing the consumer-facing stream.
941
- */
942
- readonly builtinTools: TBuiltinTools;
943
- /**
944
- * Whether the adapter can emit approval requests for built-in tools when
945
- * `permissionMode` is not `'allow-all'`.
946
- *
947
- * Custom host-executed tool approvals are handled by `HarnessAgent`, so this
948
- * only describes adapter-native tool approval support.
949
- */
950
- readonly supportsBuiltinToolApprovals?: boolean;
951
- /**
952
- * Whether the adapter can prevent its underlying runtime from seeing or
953
- * calling inactive built-in tools for every tool in `builtinTools`.
954
- *
955
- * Adapters without native filtering can still support `activeTools` and
956
- * `inactiveTools` for built-ins when `supportsBuiltinToolApprovals` is
957
- * `true`: the framework routes inactive built-in tool calls through the
958
- * approval path and auto-denies them before they execute.
959
- */
960
- readonly supportsBuiltinToolFiltering?: boolean;
961
- /**
962
- * Optional schema for the adapter-defined `data` payload returned by session
963
- * lifecycle methods. When present, the adapter promises that exported state
964
- * validated by this schema can be re-imported in a future
965
- * `doStart({ resumeFrom })` or `doStart({ continueFrom })` call.
966
- */
967
- readonly lifecycleStateSchema?: FlexibleSchema<unknown>;
968
- /**
969
- * Optional bootstrap recipe. When defined, the harness session manager
970
- * computes a stable identity from the recipe, passes it (along with a
971
- * one-time recipe-application hook) to the sandbox provider, and applies
972
- * the recipe idempotently after the provider returns the handle.
973
- *
974
- * Adapters with no bootstrap needs omit this. Adapters that need to install
975
- * deps or ship bridge files into the sandbox declare them here so the
976
- * provider can cache the result across sessions via snapshots when
977
- * supported.
978
- */
979
- readonly getBootstrap?: (options?: {
980
- abortSignal?: AbortSignal;
981
- }) => PromiseLike<HarnessV1Bootstrap>;
982
- /**
983
- * Start a fresh session, resume a parked session via `resumeFrom`, or resume
984
- * a suspended turn via `continueFrom`. The host then issues prompts against
985
- * the returned session, ending with `doDetach`, `doStop`, or `doDestroy`.
986
- */
987
- 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>;
988
1097
  };
989
-
1098
+ //#endregion
1099
+ //#region src/v1/harness-v1-builtin-tool.d.ts
990
1100
  /**
991
1101
  * Cross-harness vocabulary of common built-in tool names with their baseline
992
1102
  * input schemas. Adapters that declare a built-in with one of these
@@ -997,64 +1107,64 @@ type HarnessV1<TBuiltinTools extends ToolSet = ToolSet> = {
997
1107
  * a vocabulary source — `HarnessV1BuiltinToolName` is derived from its keys.
998
1108
  */
999
1109
  declare const HARNESS_V1_BUILTIN_TOOLS: {
1000
- readonly read: Tool<{
1001
- file_path: string;
1002
- }, unknown, _ai_sdk_provider_utils.Context>;
1003
- readonly write: Tool<{
1004
- file_path: string;
1005
- content: string;
1006
- }, unknown, _ai_sdk_provider_utils.Context>;
1007
- readonly edit: Tool<{
1008
- file_path: string;
1009
- old_string: string;
1010
- new_string: string;
1011
- }, unknown, _ai_sdk_provider_utils.Context>;
1012
- readonly bash: Tool<{
1013
- command: string;
1014
- }, unknown, _ai_sdk_provider_utils.Context>;
1015
- readonly grep: Tool<{
1016
- pattern: string;
1017
- }, unknown, _ai_sdk_provider_utils.Context>;
1018
- readonly glob: Tool<{
1019
- pattern: string;
1020
- }, unknown, _ai_sdk_provider_utils.Context>;
1021
- readonly webSearch: Tool<{
1022
- query: string;
1023
- }, unknown, _ai_sdk_provider_utils.Context>;
1024
- readonly askUserQuestions: _ai_sdk_provider_utils.FunctionTool<{
1025
- allowPartialAnswers: boolean;
1026
- questions: {
1027
- id: string;
1028
- question: string;
1029
- header?: string | undefined;
1030
- options?: {
1031
- id: string;
1032
- label: string;
1033
- description?: string | undefined;
1034
- preview?: string | undefined;
1035
- }[] | undefined;
1036
- allowMultiple?: boolean | undefined;
1037
- allowFreeForm?: boolean | {
1038
- secret: boolean;
1039
- } | undefined;
1040
- }[];
1041
- }, {
1042
- action: "answered";
1043
- answers: Record<string, {
1044
- optionIds: string[];
1045
- freeform?: string | undefined;
1046
- }>;
1047
- } | {
1048
- action: "partially-answered";
1049
- answers: Record<string, {
1050
- optionIds: string[];
1051
- freeform?: string | undefined;
1052
- }>;
1053
- } | {
1054
- action: "declined";
1055
- } | {
1056
- 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;
1156
+ }>;
1157
+ } | {
1158
+ action: "partially-answered";
1159
+ answers: Record<string, {
1160
+ optionIds: string[];
1161
+ freeform?: string | undefined;
1057
1162
  }>;
1163
+ } | {
1164
+ action: "declined";
1165
+ } | {
1166
+ action: "cancelled";
1167
+ }>;
1058
1168
  };
1059
1169
  type HarnessV1BuiltinToolName = keyof typeof HARNESS_V1_BUILTIN_TOOLS;
1060
1170
  type HarnessV1BuiltinToolUseKind = 'readonly' | 'edit' | 'bash';
@@ -1077,11 +1187,12 @@ type HarnessV1BuiltinToolUseKind = 'readonly' | 'edit' | 'bash';
1077
1187
  * (declare the tool with the AI SDK's `tool()` directly).
1078
1188
  */
1079
1189
  type HarnessV1BuiltinTool<INPUT = unknown, OUTPUT = unknown> = Tool<INPUT, OUTPUT, any> & {
1080
- readonly nativeName?: string;
1081
- readonly commonName?: HarnessV1BuiltinToolName;
1082
- readonly toolUseKind?: HarnessV1BuiltinToolUseKind;
1190
+ readonly nativeName?: string;
1191
+ readonly commonName?: HarnessV1BuiltinToolName;
1192
+ readonly toolUseKind?: HarnessV1BuiltinToolUseKind;
1083
1193
  };
1084
-
1194
+ //#endregion
1195
+ //#region src/v1/harness-v1-sandbox-provider.d.ts
1085
1196
  /**
1086
1197
  * Provider that produces network sandbox sessions for harness sessions. Lives at
1087
1198
  * module scope as a stable, synchronous object — analogous to
@@ -1090,72 +1201,74 @@ type HarnessV1BuiltinTool<INPUT = unknown, OUTPUT = unknown> = Tool<INPUT, OUTPU
1090
1201
  */
1091
1202
  /** @deprecated Supply a sandbox session to `HarnessAgent.createSession()` instead. */
1092
1203
  interface HarnessV1SandboxProvider {
1093
- readonly specificationVersion: 'harness-sandbox-v1';
1094
- readonly providerId: string;
1095
- /**
1096
- * Providers should throw `HarnessSandboxAuthenticationError` when sandbox
1097
- * acquisition fails because credentials are missing, invalid, or not
1098
- * authorized. This lets framework integrations distinguish configuration
1099
- * 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.
1100
1229
  */
1101
- readonly createSession: (options?: {
1102
- /**
1103
- * Stable per-session identifier. When supplied, the provider names the
1104
- * underlying resource deterministically so a future call to `resume`
1105
- * (potentially from a different process) can find the same sandbox.
1106
- * Omitted from prewarm and other paths that don't need a resumable
1107
- * resource — in that case the provider falls back to its native
1108
- * auto-naming.
1109
- */
1110
- sessionId?: string;
1111
- abortSignal?: AbortSignal;
1112
- /**
1113
- * Stable identity for snapshot-based reuse. Providers that support
1114
- * persistence/snapshots use this as part of the persistent sandbox
1115
- * name; subsequent calls with the same identity resume from snapshot.
1116
- *
1117
- * Ignored when the provider is wrapping a caller-provided sandbox.
1118
- */
1119
- identity?: string;
1120
- /**
1121
- * Called exactly once per identity, on fresh creation. Snapshot-capable
1122
- * providers wire this into the platform's one-time-setup hook so the
1123
- * side effects are baked into the snapshot. Providers without snapshot
1124
- * support run it immediately after fresh create.
1125
- *
1126
- * Not called when the provider is wrapping a caller-provided sandbox
1127
- * (the caller owns the sandbox; the framework applies its own
1128
- * idempotent bootstrap post-create instead).
1129
- */
1130
- onFirstCreate?: (session: Experimental_SandboxSession, opts: {
1131
- abortSignal?: AbortSignal;
1132
- }) => Promise<void>;
1133
- }) => PromiseLike<HarnessV1NetworkSandboxSession>;
1230
+ identity?: string;
1134
1231
  /**
1135
- * Reattach to an existing sandbox previously created with the same
1136
- * `sessionId`. Optional — providers that cannot rehydrate by id omit
1137
- * this; the harness throws
1138
- * `HarnessCapabilityUnsupportedError` when resume is attempted against
1139
- * 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.
1140
1236
  *
1141
- * The provider derives the sandbox identifier from `sessionId` using the
1142
- * same deterministic naming scheme it used in `createSession`. Returns a
1143
- * 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).
1144
1240
  */
1145
- readonly resumeSession?: (options: {
1146
- sessionId: string;
1147
- abortSignal?: AbortSignal;
1148
- }) => 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>;
1149
1260
  }
1150
-
1261
+ //#endregion
1262
+ //#region src/v1/harness-v1-sandbox-template.d.ts
1151
1263
  type HarnessV1SandboxTemplate = {
1152
- readonly identity: string;
1153
- readonly prepare: (options: {
1154
- readonly session: Experimental_SandboxSession;
1155
- readonly abortSignal?: AbortSignal;
1156
- }) => Promise<void>;
1264
+ readonly identity: string;
1265
+ readonly prepare: (options: {
1266
+ readonly session: Experimental_SandboxSession;
1267
+ readonly abortSignal?: AbortSignal;
1268
+ }) => Promise<void>;
1157
1269
  };
1158
-
1270
+ //#endregion
1271
+ //#region src/agent/observability/types.d.ts
1159
1272
  /** Severity of a diagnostic. */
1160
1273
  type HarnessDebugLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
1161
1274
  /**
@@ -1165,12 +1278,12 @@ type HarnessDebugLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
1165
1278
  * fill any unset field — a convenience default, never the only path.
1166
1279
  */
1167
1280
  type HarnessDebugConfig = {
1168
- /** Master switch. Nothing is captured or forwarded when false/unset. */
1169
- readonly enabled?: boolean;
1170
- /** Threshold; events at or above this severity are emitted. Default `debug`. */
1171
- readonly level?: HarnessDebugLevel;
1172
- /** Dotted-prefix subsystem filter for structured events. */
1173
- 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>;
1174
1287
  };
1175
1288
  /**
1176
1289
  * A forwarded bridge diagnostic, normalized for host consumers.
@@ -1182,37 +1295,37 @@ type HarnessDebugConfig = {
1182
1295
  * kept first-class and per-line — they are never folded into telemetry spans.
1183
1296
  */
1184
1297
  type HarnessDiagnostic = {
1185
- /**
1186
- * Severity. Structured events carry their own level; captured console lines
1187
- * map `stderr` → `'warn'` and `stdout` → `'info'`.
1188
- */
1189
- readonly level: HarnessDebugLevel;
1190
- /** Human-readable line (console capture) or message (structured event). */
1191
- readonly message: string;
1192
- /**
1193
- * Dotted subsystem. For captured console output this is
1194
- * `sandbox.log.<source>`; for structured events it is the adapter-supplied
1195
- * subsystem (e.g. `bridge.turn`).
1196
- */
1197
- readonly subsystem: string;
1198
- /** `'log'` = captured console line; `'event'` = structured `bridgeLog`. */
1199
- readonly kind: 'log' | 'event';
1200
- /** Originating sandbox source label (console capture). */
1201
- readonly source?: string;
1202
- /** Which standard stream the line came from (console capture). */
1203
- readonly stream?: 'stdout' | 'stderr';
1204
- /** Structured attributes (structured events only). */
1205
- readonly attrs?: Record<string, unknown>;
1206
- /** Error payload (structured events only). */
1207
- readonly error?: {
1208
- name?: string;
1209
- message: string;
1210
- stack?: string;
1211
- };
1212
- /** The harness session this diagnostic originated from. */
1213
- readonly sessionId?: string;
1214
- /** Host receipt time (epoch ms). */
1215
- 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;
1216
1329
  };
1217
1330
  /**
1218
1331
  * A telemetry integration that also wants the per-line diagnostics stream. The
@@ -1222,9 +1335,10 @@ type HarnessDiagnostic = {
1222
1335
  * `telemetry.integrations` receives both spans and logs.
1223
1336
  */
1224
1337
  interface HarnessDiagnosticConsumer {
1225
- ingestDiagnostic?(diagnostic: HarnessDiagnostic): void;
1338
+ ingestDiagnostic?(diagnostic: HarnessDiagnostic): void;
1226
1339
  }
1227
-
1340
+ //#endregion
1341
+ //#region src/agent/harness-agent-types.d.ts
1228
1342
  type HarnessAgentAdapter<TBuiltinTools extends ToolSet = ToolSet> = HarnessV1<TBuiltinTools>;
1229
1343
  type HarnessSandboxTemplate = HarnessV1SandboxTemplate;
1230
1344
  type HarnessAgentBuiltinTool<INPUT = unknown, OUTPUT = unknown> = HarnessV1BuiltinTool<INPUT, OUTPUT>;
@@ -1246,7 +1360,8 @@ type HarnessAgentPendingToolApproval = HarnessV1PendingToolApproval;
1246
1360
  type HarnessAgentPendingToolResult = HarnessV1PendingToolResult;
1247
1361
  type HarnessAgentSkill = HarnessV1Skill;
1248
1362
  type HarnessAgentPermissionMode = HarnessV1PermissionMode;
1249
-
1363
+ //#endregion
1364
+ //#region src/agent/harness-agent-tool-types.d.ts
1250
1365
  /** Extract the builtin tool set type from a harness adapter parameter. */
1251
1366
  type HarnessBuiltinToolsOf<H> = H extends HarnessAgentAdapter<infer T> ? T : never;
1252
1367
  /**
@@ -1254,46 +1369,47 @@ type HarnessBuiltinToolsOf<H> = H extends HarnessAgentAdapter<infer T> ? T : nev
1254
1369
  * User tools override builtins on key collision.
1255
1370
  */
1256
1371
  type HarnessAllTools<THarness extends HarnessAgentAdapter<any>, TUserTools extends ToolSet> = Omit<HarnessBuiltinToolsOf<THarness>, keyof TUserTools> & TUserTools;
1257
-
1372
+ //#endregion
1373
+ //#region src/agent/harness-agent-settings.d.ts
1258
1374
  type HarnessAgentToolApprovalConfiguration = Readonly<Record<string, ToolApprovalStatus>>;
1259
1375
  type HarnessAgentSandboxConfig = {
1260
- /**
1261
- * Optional fixed working directory for all sessions, relative to the
1262
- * sandbox's default working directory. Use `'.'` to use the default
1263
- * working directory itself. When omitted, sessions keep the existing
1264
- * `<harnessId>-<sessionId>` work directory.
1265
- */
1266
- readonly workDir?: string;
1267
- /**
1268
- * Caller-controlled identity for `onBootstrap`. Change this whenever the
1269
- * bootstrap side effects should invalidate the reusable sandbox snapshot.
1270
- */
1271
- readonly bootstrapHash?: string;
1272
- /**
1273
- * Called during sandbox template creation after the harness adapter's own
1274
- * bootstrap has run and before snapshot-capable providers publish a snapshot.
1275
- *
1276
- * `bootstrapHash` must be provided with this callback.
1277
- */
1278
- readonly onBootstrap?: (opts: {
1279
- readonly session: Experimental_SandboxSession;
1280
- readonly workDir: string;
1281
- readonly abortSignal?: AbortSignal;
1282
- }) => Promise<void>;
1283
- /**
1284
- * Called after each sandbox session is acquired and the session work
1285
- * directory exists, before the harness adapter starts. Runs for fresh and
1286
- * resumed sessions.
1287
- *
1288
- * Use this to write per-session config, install lightweight tools, activate
1289
- * licenses, or prepare files in `sessionWorkDir`. Keep it idempotent if the
1290
- * agent may resume sessions.
1291
- */
1292
- readonly onSession?: (opts: {
1293
- readonly session: Experimental_SandboxSession;
1294
- readonly sessionWorkDir: string;
1295
- readonly abortSignal?: AbortSignal;
1296
- }) => 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>;
1297
1413
  };
1298
1414
  type HarnessTools<TOOLS extends ToolSet> = ActiveTools<NoInfer<TOOLS>>;
1299
1415
  /**
@@ -1307,215 +1423,217 @@ type HarnessTools<TOOLS extends ToolSet> = ActiveTools<NoInfer<TOOLS>>;
1307
1423
  * from custom call options.
1308
1424
  */
1309
1425
  type HarnessAgentToolFilteringSettings<TOOLS extends ToolSet> = {
1310
- /**
1311
- * Limits the tools that are available for the harness to call without
1312
- * changing the tool call and result types in the result.
1313
- */
1314
- readonly activeTools?: HarnessTools<TOOLS>;
1315
- 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;
1316
1432
  } | {
1317
- readonly activeTools?: never;
1318
- /**
1319
- * Excludes tools from the set that is available for the harness to call
1320
- * without changing the tool call and result types in the result.
1321
- */
1322
- 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>;
1323
1439
  };
1324
1440
  type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never, CALL_OPTIONS = never> = {
1325
- /**
1326
- * The harness adapter driving the underlying agent runtime. Its
1327
- * `builtinTools` are merged with the user-defined `tools` and exposed to
1328
- * AI SDK consumers in the typed `tool-call` stream.
1329
- */
1330
- readonly harness: THarness;
1331
- /**
1332
- * Stable identifier for this agent instance. Exposed via `agent.id`.
1333
- * If omitted, `agent.id` is `undefined`.
1334
- */
1335
- readonly id?: string;
1336
- /**
1337
- * Model identifier used by the harness adapter. Supported values are
1338
- * defined by the selected harness. `prepareCall` can replace it between
1339
- * completed turns.
1340
- */
1341
- readonly model?: string;
1342
- /**
1343
- * Tools available to the underlying runtime in addition to the harness's
1344
- * own builtins. The agent forwards each tool to the harness as a
1345
- * `HarnessAgentToolSpec`; when the runtime calls one, the agent executes
1346
- * `tool.execute()` on the host and submits the result back to the harness.
1347
- *
1348
- * User tools take precedence over harness builtins on key collision —
1349
- * declare a tool with the same name as a builtin to override.
1350
- */
1351
- readonly tools?: TUserTools;
1352
- /**
1353
- * Per-tool context passed to host-executed tools. Each entry is validated
1354
- * against the matching tool's `contextSchema` before execution.
1355
- * `prepareCall` can replace it for each new turn.
1356
- */
1357
- readonly toolsContext?: InferToolSetContext<TUserTools>;
1358
- /**
1359
- * Runtime context passed to lifecycle callbacks and telemetry.
1360
- * `prepareCall` can replace it for each new turn.
1361
- */
1362
- readonly runtimeContext?: RUNTIME_CONTEXT;
1363
- /**
1364
- * Skills made available to the underlying runtime. Each adapter decides how
1365
- * to surface skills. `prepareCall` can replace them between completed turns.
1366
- */
1367
- readonly skills?: ReadonlyArray<HarnessAgentSkill>;
1368
- /**
1369
- * Instructions for the underlying agent runtime. Adapters append these to a
1370
- * native system or developer prompt when supported. Otherwise, they prepend
1371
- * them to the user message. `prepareCall` can replace them between completed
1372
- * turns. When a `SystemModelMessage` is provided, only its `content` is
1373
- * forwarded to the harness adapter.
1374
- */
1375
- readonly instructions?: string | SystemModelMessage;
1376
- /**
1377
- * Additional HTTP headers to be sent with every model request.
1378
- *
1379
- * `authorization`, `x-api-key`, `user-agent`, and `x-client-app` are
1380
- * managed by the harness and are not allowed.
1381
- */
1382
- readonly headers?: Record<string, string | undefined>;
1383
- /**
1384
- * Schema for validating the custom options passed to each agent call.
1385
- */
1386
- readonly callOptionsSchema?: FlexibleSchema<CALL_OPTIONS>;
1387
- /**
1388
- * Prepares the prompt and the settings that may vary between completed
1389
- * turns. The prepared values are frozen for the lifetime of the turn,
1390
- * including any suspended-turn continuations.
1391
- *
1392
- * Preserve the remaining arguments with the rest-spread pattern when a
1393
- * field should be removable by returning `undefined`:
1394
- *
1395
- * ```ts
1396
- * prepareCall: ({ options, ...rest }) => ({
1397
- * ...rest,
1398
- * instructions: options.instructions,
1399
- * })
1400
- * ```
1401
- */
1402
- 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'> & {
1403
- toolsContext: InferToolSetContext<TUserTools>;
1404
- }) => MaybePromiseLike<Pick<HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, NoInfer<OUTPUT>, CALL_OPTIONS>, 'model' | 'skills' | 'instructions' | 'tools' | 'runtimeContext'> & {
1405
- toolsContext: InferToolSetContext<TUserTools>;
1406
- } & Omit<Prompt, 'system' | 'instructions' | 'allowSystemInMessages'>>;
1407
- /**
1408
- * Optional specification for generating typed output. The same output
1409
- * requirement is active for every turn run by this agent.
1410
- */
1411
- readonly output?: OUTPUT;
1412
- /**
1413
- * Conditions that stop the current result after a completed harness tool
1414
- * step that can continue into another model step. The underlying turn remains
1415
- * unfinished and can be suspended and continued.
1416
- *
1417
- * A terminal text-only step finishes naturally and is not stopped early.
1418
- *
1419
- * When omitted, the harness runs until the turn naturally finishes or pauses.
1420
- */
1421
- readonly stopWhen?: Arrayable<StopCondition<NoInfer<HarnessAllTools<THarness, TUserTools>>, RUNTIME_CONTEXT>>;
1422
- /**
1423
- * Called when an agent call begins, before any model steps.
1424
- */
1425
- readonly onStart?: GenerateTextOnStartCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, RUNTIME_CONTEXT, NoInfer<OUTPUT>>;
1426
- /**
1427
- * Called when a model step begins.
1428
- */
1429
- readonly onStepStart?: GenerateTextOnStepStartCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, NoInfer<RUNTIME_CONTEXT>, NoInfer<OUTPUT>>;
1430
- /**
1431
- * Called immediately before the harness begins emitting a model response.
1432
- */
1433
- readonly onLanguageModelCallStart?: OnLanguageModelCallStartCallback;
1434
- /**
1435
- * Called after a model response is complete and before its tool execution
1436
- * lifecycle callbacks are delivered.
1437
- */
1438
- readonly onLanguageModelCallEnd?: OnLanguageModelCallEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>>;
1439
- /**
1440
- * Called before each harness or host tool execution is reported.
1441
- */
1442
- readonly onToolExecutionStart?: OnToolExecutionStartCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>>;
1443
- /**
1444
- * Called after each harness or host tool execution is reported.
1445
- */
1446
- readonly onToolExecutionEnd?: OnToolExecutionEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>>;
1447
- /**
1448
- * Called after each completed model step.
1449
- */
1450
- readonly onStepEnd?: GenerateTextOnStepEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, NoInfer<RUNTIME_CONTEXT>>;
1451
- /**
1452
- * Called when an agent call completes successfully.
1453
- */
1454
- readonly onEnd?: GenerateTextOnEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, NoInfer<RUNTIME_CONTEXT>>;
1455
- /**
1456
- * Built-in tool permission mode. Defaults to `'allow-all'`, preserving the
1457
- * existing bypass-permissions behavior unless users opt in.
1458
- */
1459
- readonly permissionMode?: HarnessAgentPermissionMode;
1460
- /**
1461
- * Per custom-tool approval statuses. This mirrors AI SDK `toolApproval`
1462
- * object configuration for host-executed tools, without callback support.
1463
- *
1464
- * `not-applicable` and `approved` run the tool, `user-approval` pauses the
1465
- * turn for a user decision, and `denied` immediately submits an
1466
- * `execution-denied` result.
1467
- */
1468
- readonly toolApproval?: HarnessAgentToolApprovalConfiguration;
1469
- /**
1470
- * Optional sandbox provider used to create or resume network sandbox
1471
- * sessions. When omitted, every `createSession()` call must provide an
1472
- * existing network sandbox session.
1473
- */
1474
- /** @deprecated Supply `sandboxSession` to `HarnessAgent.createSession()` instead. */
1475
- readonly sandbox?: HarnessV1SandboxProvider;
1476
- /**
1477
- * Sandbox working-directory and lifecycle hook configuration.
1478
- */
1479
- readonly sandboxConfig?: HarnessAgentSandboxConfig;
1480
- /** @deprecated Use `sandboxConfig.onSession` instead. */
1481
- readonly onSandboxSession?: HarnessAgentSandboxConfig['onSession'];
1482
- /**
1483
- * Telemetry configuration. The harness drives AI SDK's pluggable
1484
- * `Telemetry` integration contract from the turn lifecycle, so a harness turn
1485
- * appears in a consumer's traces with the same span shape as `streamText`.
1486
- * Register an integration here (e.g. `@ai-sdk/otel`) or globally via
1487
- * `registerTelemetry`. The harness itself stays OpenTelemetry-agnostic.
1488
- */
1489
- readonly telemetry?: TelemetryOptions;
1490
- /**
1491
- * Diagnostics configuration. Enables bridge log forwarding (sandbox
1492
- * console + structured `debug-event`s) and the `HARNESS_DEBUG` stderr default.
1493
- * Set `{ enabled: true }` to turn it on in code; env vars fill unset fields.
1494
- */
1495
- readonly debug?: HarnessDebugConfig;
1496
- /**
1497
- * Programmatic sink for forwarded bridge diagnostics. Receives every
1498
- * captured console line and structured event, normalized. Independent of the
1499
- * stderr default — wire this to capture diagnostics in code.
1500
- */
1501
- 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;
1502
1618
  } & ToolsContextSettings<TUserTools> & HarnessAgentToolFilteringSettings<HarnessAllTools<THarness, TUserTools>>;
1503
-
1619
+ //#endregion
1620
+ //#region src/agent/internal/turn-telemetry.d.ts
1504
1621
  type HarnessAgentLifecycleCallbacks<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface> = {
1505
- onStart?: GenerateTextOnStartCallback<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1506
- onStepStart?: GenerateTextOnStepStartCallback<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1507
- onLanguageModelCallStart?: OnLanguageModelCallStartCallback;
1508
- onLanguageModelCallEnd?: OnLanguageModelCallEndCallback<TOOLS>;
1509
- onToolExecutionStart?: OnToolExecutionStartCallback<TOOLS>;
1510
- onToolExecutionEnd?: OnToolExecutionEndCallback<TOOLS>;
1511
- onStepEnd?: GenerateTextOnStepEndCallback<TOOLS, RUNTIME_CONTEXT>;
1512
- 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>;
1513
1630
  };
1514
-
1631
+ //#endregion
1632
+ //#region src/agent/harness-agent-session.d.ts
1515
1633
  type HarnessAgentTurnResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface> = {
1516
- result: StreamTextResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1517
- done: Promise<void>;
1518
- ready: Promise<void>;
1634
+ result: StreamTextResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1635
+ done: Promise<void>;
1636
+ ready: Promise<void>;
1519
1637
  };
1520
1638
  type HarnessAgentTurnState = 'idle' | 'running' | 'awaiting-approval' | 'awaiting-tool-result' | 'suspended';
1521
1639
  /**
@@ -1530,162 +1648,181 @@ type HarnessAgentTurnState = 'idle' | 'running' | 'awaiting-approval' | 'awaitin
1530
1648
  * After any lifecycle method has resolved, the session is unusable — any
1531
1649
  * subsequent `generate`/`stream` call against it throws.
1532
1650
  */
1533
- declare class HarnessAgentSession {
1534
- /**
1535
- * Stable identifier the harness adapter saw in `doStart`. The same
1536
- * string callers persist when they intend to resume the session in a
1537
- * future process.
1538
- */
1539
- readonly sessionId: string;
1540
- private readonly harness;
1541
- private readonly sessionWorkDir;
1542
- private readonly ownsSandboxLifecycle;
1543
- private underlyingSession;
1544
- private sandboxSession;
1545
- private readonly toolApproval;
1546
- private readonly pendingToolApprovals;
1547
- private readonly pendingToolResults;
1548
- private sessionState;
1549
- private turnState;
1550
- private turnSequence;
1551
- private activeTurnSequence;
1552
- private activePromptDone;
1553
- private activePromptControl;
1554
- private suspendedTurnState;
1555
- private activeTurnSettings;
1556
- private persistedTurnSettings;
1557
- private readonly resumedToolsContext;
1558
- private readonly resumedRuntimeContext;
1559
- /**
1560
- * Whether this session was created from `resumeFrom` or `continueFrom`.
1561
- * Captured at construction so it survives lifecycle cleanup.
1562
- */
1563
- readonly isResume: boolean;
1564
- constructor(options: {
1565
- sessionId: string;
1566
- harness: HarnessAgentAdapter;
1567
- underlyingSession: HarnessAgentAdapterSession;
1568
- sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
1569
- ownsSandboxLifecycle?: boolean;
1570
- sessionWorkDir: string;
1571
- toolApproval: HarnessAgentToolApprovalConfiguration | undefined;
1572
- pendingToolApprovals?: readonly HarnessAgentPendingToolApproval[];
1573
- pendingToolResults?: readonly HarnessAgentPendingToolResult[];
1574
- turnSettings?: HarnessV1TurnSettings;
1575
- resumedToolsContext?: Record<string, Context | undefined>;
1576
- resumedRuntimeContext?: Context;
1577
- turnState?: HarnessAgentTurnState;
1578
- });
1579
- hasUnfinishedTurn(): boolean;
1580
- promptTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
1581
- prompt: HarnessAgentPrompt;
1582
- model: string | undefined;
1583
- skills: ReadonlyArray<HarnessV1Skill>;
1584
- instructions: string | undefined;
1585
- tools: TOOLS;
1586
- toolsContext: InferToolSetContext<TOOLS>;
1587
- activeTools: ToolSet;
1588
- toolSpecs: HarnessAgentToolSpec[];
1589
- builtinToolFiltering: HarnessV1BuiltinToolFiltering | undefined;
1590
- runtimeContext: RUNTIME_CONTEXT;
1591
- abortSignal: AbortSignal | undefined;
1592
- responseFormat: HarnessV1ResponseFormat | undefined;
1593
- output: OUTPUT | undefined;
1594
- telemetry: TelemetryOptions | undefined;
1595
- callbacks: HarnessAgentLifecycleCallbacks<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1596
- stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
1597
- }): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1598
- continueTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
1599
- model: string | undefined;
1600
- skills: ReadonlyArray<HarnessV1Skill>;
1601
- instructions: string | undefined;
1602
- tools: TOOLS;
1603
- toolsContext: InferToolSetContext<TOOLS>;
1604
- activeTools: ToolSet;
1605
- toolSpecs: HarnessAgentToolSpec[];
1606
- builtinToolFiltering: HarnessV1BuiltinToolFiltering | undefined;
1607
- runtimeContext: RUNTIME_CONTEXT;
1608
- abortSignal: AbortSignal | undefined;
1609
- responseFormat: HarnessV1ResponseFormat | undefined;
1610
- output: OUTPUT | undefined;
1611
- telemetry: TelemetryOptions | undefined;
1612
- callbacks: HarnessAgentLifecycleCallbacks<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1613
- stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
1614
- toolApprovalContinuations?: readonly ToolApprovalResponse[] | undefined;
1615
- toolResultContinuations?: readonly ToolResultPart[] | undefined;
1616
- }): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1617
- /**
1618
- * Ask the underlying runtime to compact its context. The runtime performs
1619
- * the compaction itself; when it completes, a `compaction` part appears on
1620
- * the active (or next) turn's stream. Safe to call between turns for
1621
- * runtimes whose compaction is session-scoped (e.g. Pi).
1622
- *
1623
- * Throws `HarnessCapabilityUnsupportedError` for harnesses that cannot
1624
- * trigger compaction manually (e.g. Codex, which still auto-compacts under
1625
- * the hood). Throws if the session has ended.
1626
- */
1627
- compact(customInstructions?: string): Promise<void>;
1628
- /**
1629
- * Submit another user message to the active turn.
1630
- *
1631
- * The runtime accepts the message for its next safe input boundary. Output
1632
- * caused by the message remains part of the active turn's result stream.
1633
- */
1634
- experimental_steerTurn(text: string): Promise<void>;
1635
- /**
1636
- * Park the session, returning a payload the caller can persist and later
1637
- * pass to `agent.createSession({ sessionId, resumeFrom })` to reconnect.
1638
- * The runtime and sandbox keep running; this local session handle becomes
1639
- * unusable.
1640
- */
1641
- detach(): Promise<HarnessAgentResumeSessionState>;
1642
- /**
1643
- * Persist enough state to resume later, then stop the runtime and any
1644
- * harness-owned sandbox.
1645
- * Returns the resume state for a future
1646
- * `agent.createSession({ sessionId, resumeFrom })` call.
1647
- */
1648
- stop(): Promise<HarnessAgentResumeSessionState>;
1649
- /**
1650
- * Stop the runtime and discard resumability. A harness-owned network
1651
- * sandbox is stopped and destroyed through its `destroy()` method.
1652
- */
1653
- destroy(): Promise<void>;
1654
- /**
1655
- * Gracefully freeze the active turn at the slice boundary and return the
1656
- * continuation payload, **leaving the sandbox/runtime running** so the next
1657
- * process can continue. Resolves once the in-flight `stream()` /
1658
- * `continueStream()` has cleanly wound down at a precise cursor (see
1659
- * `doSuspendTurn`).
1660
- *
1661
- * After this call the session is detached. This in-process handle no
1662
- * longer drives turns; a future slice creates a fresh session from the
1663
- * returned state. The sandbox is **not** stopped because bridge-backed
1664
- * adapters may still have a live bridge.
1665
- */
1666
- suspendTurn(): Promise<HarnessAgentContinueTurnState>;
1667
- private getPendingToolApprovals;
1668
- private getPendingToolResults;
1669
- private addPendingToolState;
1670
- private suspendCurrentTurn;
1671
- private finalizeCurrentTurnSuspension;
1672
- private captureStopConditionBoundary;
1673
- private toResumeStateWithContinuation;
1674
- private requirePromptableTurn;
1675
- private requireContinuableTurn;
1676
- private markAwaitingApprovalIfActive;
1677
- private markAwaitingToolResultIfActive;
1678
- private startTrackedTurn;
1679
- private setPromptControl;
1680
- private waitForPromptControl;
1681
- private settleActivePromptControl;
1682
- private clearActivePromptControl;
1683
- private finishTrackedTurn;
1684
- private resolveActiveTurnSettings;
1685
- private endLocalHandle;
1686
- 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;
1687
1823
  }
1688
-
1824
+ //#endregion
1825
+ //#region src/agent/harness-agent.d.ts
1689
1826
  /**
1690
1827
  * Required `session` extension on every `HarnessAgent.generate` /
1691
1828
  * `HarnessAgent.stream` call. The agent operates exclusively on the
@@ -1693,11 +1830,11 @@ declare class HarnessAgentSession {
1693
1830
  * state of its own.
1694
1831
  */
1695
1832
  interface HarnessAgentCallExtensions {
1696
- /**
1697
- * Active session returned by `agent.createSession(...)`. Drives the
1698
- * underlying harness adapter for this turn.
1699
- */
1700
- session: HarnessAgentSession;
1833
+ /**
1834
+ * Active session returned by `agent.createSession(...)`. Drives the
1835
+ * underlying harness adapter for this turn.
1836
+ */
1837
+ session: HarnessAgentSession;
1701
1838
  }
1702
1839
  /**
1703
1840
  * AI SDK `Agent` implementation that drives a third-party agent runtime
@@ -1734,133 +1871,135 @@ interface HarnessAgentCallExtensions {
1734
1871
  * remain owned by the caller and are not stopped or destroyed by the
1735
1872
  * harness layer.
1736
1873
  */
1737
- 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> {
1738
- readonly version: "agent-v1";
1739
- readonly id: string | undefined;
1740
- /**
1741
- * Merged tool set exposed to AI SDK consumers: harness builtins +
1742
- * user-defined tools, with user tools overriding builtins on key
1743
- * collision. Built once at construction time so the typed surface is
1744
- * stable across calls.
1745
- */
1746
- readonly tools: HarnessAllTools<THarness, TUserTools>;
1747
- private readonly settings;
1748
- private readonly stopConditions;
1749
- private readonly sandboxConfig;
1750
- private readonly builtinToolFiltering;
1751
- private readonly permissionMode;
1752
- private readonly headers;
1753
- constructor(settings: HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, OUTPUT, CALL_OPTIONS>);
1754
- /** Identifier of the harness backing this agent. */
1755
- get harnessId(): string;
1756
- /** Whether this agent parses completed turns with its configured output. */
1757
- get hasOutput(): boolean;
1758
- getSandboxTemplate(): Promise<HarnessSandboxTemplate | undefined>;
1759
- /**
1760
- * Start a fresh session, or resume from state previously returned by
1761
- * `session.detach()` or `session.stop()`. The returned
1762
- * `HarnessAgentSession` must be passed to subsequent `generate` / `stream`
1763
- * calls; end it with `session.detach()`, `session.stop()`, or
1764
- * `session.destroy()`.
1765
- */
1766
- createSession(options?: {
1767
- /**
1768
- * Optional stable identifier for the underlying sandbox/session.
1769
- * When omitted the agent generates one. Supply the original
1770
- * `session.sessionId` together with `resumeFrom` to reattach a
1771
- * previously ended session across processes.
1772
- */
1773
- sessionId?: string;
1774
- /**
1775
- * Resume payload returned by a prior `session.detach()` or
1776
- * `session.stop()`. Must be accompanied by the original `sessionId`; the
1777
- * framework validates it against `harness.lifecycleStateSchema` before
1778
- * handing it to the adapter.
1779
- */
1780
- resumeFrom?: HarnessAgentResumeSessionState;
1781
- /**
1782
- * Continuation payload returned by a prior `session.suspendTurn()`. Must be
1783
- * accompanied by the original `sessionId`; the framework validates it before
1784
- * handing it to the adapter.
1785
- */
1786
- continueFrom?: HarnessAgentContinueTurnState;
1787
- /**
1788
- * Rebinds host-only tool context for an unfinished turn resumed with
1789
- * `continueFrom` (directly or through `resumeFrom`). Tool context is not
1790
- * serialized into lifecycle state because it may contain credentials or
1791
- * non-serializable host objects.
1792
- */
1793
- toolsContext?: ToolsContextSettings<TUserTools>['toolsContext'];
1794
- /**
1795
- * Rebinds host-only runtime context for an unfinished turn resumed with
1796
- * `continueFrom` (directly or through `resumeFrom`). Runtime context is
1797
- * not serialized into lifecycle state.
1798
- */
1799
- runtimeContext?: RUNTIME_CONTEXT;
1800
- /**
1801
- * Existing sandbox session to run the harness in. When provided, the
1802
- * caller retains ownership of the sandbox lifecycle.
1803
- */
1804
- sandboxSession?: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
1805
- abortSignal?: AbortSignal;
1806
- }): Promise<HarnessAgentSession>;
1807
- generate(options: AgentCallParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1808
- stream(options: AgentStreamParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1809
- /**
1810
- * Continue the in-flight turn **without a new prompt**, draining it like
1811
- * {@link generate}. Used after `createSession({ continueFrom })` to finish
1812
- * consuming a turn that crossed a process boundary.
1813
- */
1814
- continueGenerate(options: {
1815
- session: HarnessAgentSession;
1816
- toolApprovalContinuations?: readonly ToolApprovalResponse[];
1817
- toolResultContinuations?: readonly ToolResultPart[];
1818
- abortSignal?: AbortSignal;
1819
- }): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1820
- /**
1821
- * Continue the in-flight turn **without a new prompt**, streaming its events
1822
- * like {@link stream}. Used to keep consuming a turn that is still running
1823
- * (or finished) in the runtime after a process boundary — the workflow slice
1824
- * loop calls this on every slice after the first. Routes through the adapter's
1825
- * `doContinueTurn`; what it can guarantee (lossless attach vs. lossy rerun)
1826
- * follows from how the adapter resumed the session.
1827
- */
1828
- continueStream(options: {
1829
- session: HarnessAgentSession;
1830
- toolApprovalContinuations?: readonly ToolApprovalResponse[];
1831
- toolResultContinuations?: readonly ToolResultPart[];
1832
- abortSignal?: AbortSignal;
1833
- }): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
1834
- /**
1835
- * Submit another user message to a currently running session turn.
1836
- *
1837
- * The returned promise resolves after the runtime has accepted the message
1838
- * for its next safe input boundary. Output caused by the message remains in
1839
- * the current turn's stream.
1840
- */
1841
- experimental_steer(options: {
1842
- session: HarnessAgentSession;
1843
- text: string;
1844
- }): Promise<void>;
1845
- private _startPromptTurn;
1846
- private _startContinueTurn;
1847
- private _buildTurnOptions;
1848
- private _resolveLifecycleCallbacks;
1849
- private _resolveContinueTurnInput;
1850
- private _resolvePromptTurnInput;
1851
- private _preparePromptTurnInput;
1852
- private _prepareContinueTurnInput;
1853
- private _prepareTurnSettings;
1854
- private _toToolSpecs;
1855
- private _toGenerateResult;
1856
- 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;
1857
1994
  }
1858
-
1859
- declare function createHarnessSandboxTemplate(options: {
1860
- readonly harnesses: ReadonlyArray<HarnessAgentAdapter>;
1861
- 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'>;
1862
2000
  }): Promise<HarnessSandboxTemplate | undefined>;
1863
-
2001
+ //#endregion
2002
+ //#region src/agent/harness-agent-tool-approval-continuation.d.ts
1864
2003
  /**
1865
2004
  * Extract approval decisions that should continue a suspended harness turn.
1866
2005
  *
@@ -1871,17 +2010,19 @@ declare function createHarnessSandboxTemplate(options: {
1871
2010
  * Responses that already have a tool result are ignored, because those
1872
2011
  * approvals were already consumed by a prior continuation.
1873
2012
  */
1874
- declare function collectHarnessAgentToolApprovalContinuations(input: {
1875
- messages: readonly ModelMessage[];
2013
+ export declare function collectHarnessAgentToolApprovalContinuations(input: {
2014
+ messages: readonly ModelMessage[];
1876
2015
  }): readonly ToolApprovalResponse[];
1877
-
2016
+ //#endregion
2017
+ //#region src/agent/harness-agent-tool-result-continuation.d.ts
1878
2018
  /**
1879
2019
  * Extract client-provided tool results from the trailing tool message.
1880
2020
  */
1881
- declare function collectHarnessAgentToolResultContinuations(input: {
1882
- messages: readonly ModelMessage[];
2021
+ export declare function collectHarnessAgentToolResultContinuations(input: {
2022
+ messages: readonly ModelMessage[];
1883
2023
  }): readonly ToolResultPart[];
1884
-
2024
+ //#endregion
2025
+ //#region src/agent/prepare-harness-sandbox-template.d.ts
1885
2026
  type SandboxBootstrapSettings = Omit<HarnessAgentSandboxConfig, 'onSession'>;
1886
2027
  /**
1887
2028
  * Prepare a harness's sandbox template without running an agent. Idempotent: if
@@ -1897,20 +2038,21 @@ type SandboxBootstrapSettings = Omit<HarnessAgentSandboxConfig, 'onSession'>;
1897
2038
  * provider's native storage.
1898
2039
  * @deprecated Use `createHarnessSandboxTemplate` and pass its template to a sandbox session creator instead.
1899
2040
  */
1900
- declare function prepareHarnessSandboxTemplate(options: {
1901
- readonly harness: HarnessAgentAdapter;
1902
- readonly sandboxProvider: HarnessV1SandboxProvider;
1903
- readonly sandboxConfig?: SandboxBootstrapSettings;
1904
- 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;
1905
2046
  }): Promise<void>;
1906
2047
  /** @deprecated Use `prepareHarnessSandboxTemplate` instead. */
1907
- declare const prewarmHarness: typeof prepareHarnessSandboxTemplate;
1908
-
2048
+ export declare const prewarmHarness: typeof prepareHarnessSandboxTemplate;
2049
+ //#endregion
2050
+ //#region src/agent/prepare-sandbox-for-harness.d.ts
1909
2051
  /** @deprecated Use `createHarnessSandboxTemplate` and `template.prepare` instead. */
1910
2052
  type PrepareSandboxForHarnessResult = {
1911
- readonly identity?: string;
1912
- readonly recipeIdentities: Record<string, string>;
1913
- readonly skippedHarnessIds: ReadonlyArray<string>;
2053
+ readonly identity?: string;
2054
+ readonly recipeIdentities: Record<string, string>;
2055
+ readonly skippedHarnessIds: ReadonlyArray<string>;
1914
2056
  };
1915
2057
  /**
1916
2058
  * Apply one or more harness bootstrap recipes to an existing sandbox session.
@@ -1933,28 +2075,30 @@ type PrepareSandboxForHarnessResult = {
1933
2075
  * ID, the last adapter in `harnesses` is used.
1934
2076
  * @deprecated Use `createHarnessSandboxTemplate` and `template.prepare` instead.
1935
2077
  */
1936
- declare function prepareSandboxForHarness(options: {
1937
- readonly session: Experimental_SandboxSession;
1938
- readonly harnesses: ReadonlyArray<HarnessAgentAdapter>;
1939
- readonly sandboxConfig?: HarnessAgentSandboxConfig;
1940
- 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;
1941
2083
  }): Promise<PrepareSandboxForHarnessResult>;
1942
-
2084
+ //#endregion
2085
+ //#region src/errors/harness-error.d.ts
1943
2086
  declare const symbol$2: unique symbol;
1944
2087
  /**
1945
2088
  * Base error type for failures originating in or signalled by a harness
1946
2089
  * adapter. Specific failure modes (e.g. unsupported capability) extend this
1947
2090
  * class.
1948
2091
  */
1949
- declare class HarnessError extends AISDKError {
1950
- private readonly [symbol$2];
1951
- constructor({ message, cause }: {
1952
- message: string;
1953
- cause?: unknown;
1954
- });
1955
- 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;
1956
2099
  }
1957
-
2100
+ //#endregion
2101
+ //#region src/errors/harness-capability-unsupported-error.d.ts
1958
2102
  declare const symbol$1: unique symbol;
1959
2103
  /**
1960
2104
  * Thrown when a caller asks the harness to do something the adapter (or the
@@ -1965,17 +2109,18 @@ declare const symbol$1: unique symbol;
1965
2109
  * The caller supplies the full human-readable message. Optional `harnessId`
1966
2110
  * is recorded as structured context for tooling.
1967
2111
  */
1968
- declare class HarnessCapabilityUnsupportedError extends HarnessError {
1969
- private readonly [symbol$1];
1970
- readonly harnessId?: string;
1971
- constructor({ message, harnessId, cause, }: {
1972
- message: string;
1973
- harnessId?: string;
1974
- cause?: unknown;
1975
- });
1976
- 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;
1977
2121
  }
1978
-
2122
+ //#endregion
2123
+ //#region src/errors/harness-sandbox-authentication-error.d.ts
1979
2124
  declare const symbol: unique symbol;
1980
2125
  /**
1981
2126
  * Thrown when a sandbox provider cannot authenticate or authorize the
@@ -1983,25 +2128,27 @@ declare const symbol: unique symbol;
1983
2128
  * preserve the underlying SDK failure as `cause` and supply a message that
1984
2129
  * explains how the consumer can configure credentials.
1985
2130
  */
1986
- declare class HarnessSandboxAuthenticationError extends HarnessError {
1987
- private readonly [symbol];
1988
- readonly sandboxProviderId: string;
1989
- constructor({ message, sandboxProviderId, cause, }: {
1990
- message: string;
1991
- sandboxProviderId: string;
1992
- cause?: unknown;
1993
- });
1994
- 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;
1995
2140
  }
1996
-
2141
+ //#endregion
2142
+ //#region src/agent/get-harness-error-message.d.ts
1997
2143
  /**
1998
2144
  * Returns a client-safe message for errors produced by the harness runtime.
1999
2145
  * Messages from explicitly reviewed harness error types are preserved. All
2000
2146
  * other errors are masked so provider, sandbox, and server details are not
2001
2147
  * exposed to clients by default.
2002
2148
  */
2003
- declare function getHarnessErrorMessage(error: unknown): string;
2004
-
2149
+ export declare function getHarnessErrorMessage(error: unknown): string;
2150
+ //#endregion
2151
+ //#region src/agent/observability/file-reporter.d.ts
2005
2152
  /**
2006
2153
  * A harness observability reporter that writes a unified, non-lossy
2007
2154
  * `events.jsonl` containing **both** the telemetry span lifecycle (turn / step
@@ -2014,20 +2161,21 @@ declare function getHarnessErrorMessage(error: unknown): string;
2014
2161
  * replacement for the original SDK's host-side artifact files.
2015
2162
  */
2016
2163
  interface FileReporterOptions {
2017
- /** Directory for `events.jsonl` (created if absent). */
2018
- dir: string;
2019
- /**
2020
- * Buffer a turn's records in memory and write them only if the turn produced
2021
- * an error (an `error`-level diagnostic, a failed tool, or an error finish).
2022
- * Default false (write everything).
2023
- */
2024
- failOnly?: boolean;
2025
- /** File name within `dir`. Default `events.jsonl`. */
2026
- 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;
2027
2174
  }
2028
2175
  type FileReporter = Telemetry & HarnessDiagnosticConsumer;
2029
- declare function createFileReporter(options: FileReporterOptions): FileReporter;
2030
-
2176
+ export declare function createFileReporter(options: FileReporterOptions): FileReporter;
2177
+ //#endregion
2178
+ //#region src/agent/observability/trace-tree-reporter.d.ts
2031
2179
  /**
2032
2180
  * A harness observability reporter that renders an ASCII trace tree of a
2033
2181
  * turn's span lifecycle (turn → steps → tools) to a stream at turn end. It is a
@@ -2036,9 +2184,10 @@ declare function createFileReporter(options: FileReporterOptions): FileReporter;
2036
2184
  * backend (via `@ai-sdk/otel`) is a strict superset.
2037
2185
  */
2038
2186
  interface TraceTreeReporterOptions {
2039
- /** Where to write the rendered tree. Default `process.stderr.write`. */
2040
- write?: (chunk: string) => void;
2187
+ /** Where to write the rendered tree. Default `process.stderr.write`. */
2188
+ write?: (chunk: string) => void;
2041
2189
  }
2042
- declare function createTraceTreeReporter(options?: TraceTreeReporterOptions): Telemetry;
2043
-
2044
- 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