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