@ai-sdk/harness 1.0.71 → 1.0.73
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 +18 -0
- package/README.md +23 -0
- package/dist/agent/index.d.ts +148 -23
- package/dist/agent/index.js +185 -37
- package/dist/agent/index.js.map +1 -1
- package/dist/bridge/index.js +14 -20
- package/dist/bridge/index.js.map +1 -1
- package/dist/index.d.ts +124 -10
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +59 -7
- package/dist/utils/index.js +47 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/src/agent/harness-agent-session.ts +27 -7
- package/src/agent/harness-agent-settings.ts +8 -0
- package/src/agent/harness-agent.ts +74 -23
- package/src/agent/internal/harness-stream-text-result.ts +251 -59
- package/src/agent/internal/run-prompt.ts +10 -2
- package/src/agent/prepare-sandbox-for-harness.ts +8 -18
- package/src/bridge/index.ts +41 -37
- package/src/errors/harness-capability-unsupported-error.ts +2 -2
- package/src/utils/index.ts +5 -0
- package/src/utils/sandbox-credential-brokering.ts +41 -0
- package/src/v1/harness-v1-bridge-protocol.ts +13 -0
- package/src/v1/harness-v1-network-sandbox-session.ts +87 -5
- package/src/v1/harness-v1-response-format.ts +32 -0
- package/src/v1/harness-v1-session.ts +17 -2
- package/src/v1/index.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ai-sdk/harness
|
|
2
2
|
|
|
3
|
+
## 1.0.73
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 62a9c2a: feat(harness): add support for structured output to `HarnessAgent` via `output` property
|
|
8
|
+
- d25cae2: fix(harness): claim the bridge event stream on start/resume instead of on connect
|
|
9
|
+
|
|
10
|
+
## 1.0.72
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 69bb613: feat(harness): support request transformations in network sandbox abstraction and use it to apply credential brokering when available
|
|
15
|
+
- 52bc889: feat(harness): add `getPortEndpoint()` as more comprehensive replacement to `getPortUrl()` (now deprecated) in `HarnessV1NetworkSandboxSession`
|
|
16
|
+
- 4cd4989: chore(harness): decouple bridge based harness bootstrap recipe logic from dynamic params and enforce unique harnesses in `prepareSandboxForHarness()` helper
|
|
17
|
+
- Updated dependencies [0782259]
|
|
18
|
+
- Updated dependencies [2fd1214]
|
|
19
|
+
- ai@7.0.66
|
|
20
|
+
|
|
3
21
|
## 1.0.71
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -81,6 +81,23 @@ try {
|
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
Set `output` on `HarnessAgent` to require the same typed, schema-backed output
|
|
85
|
+
on every turn. `generate()` exposes the validated value as `result.output`, and
|
|
86
|
+
`stream()` additionally exposes `partialOutputStream`; the JSON also remains on
|
|
87
|
+
the normal text and stream surfaces.
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { Output } from 'ai';
|
|
91
|
+
|
|
92
|
+
const agent = new HarnessAgent({
|
|
93
|
+
harness: claudeCode,
|
|
94
|
+
sandbox,
|
|
95
|
+
output: Output.object({
|
|
96
|
+
schema: z.object({ answer: z.string() }),
|
|
97
|
+
}),
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
84
101
|
Use `session.detach()` to park a bridge-backed session for later attach, `session.stop()` to save state and stop the sandbox, or `session.destroy()` to clean up without keeping resume state. Bridge-backed adapters such as Claude Code, Codex, OpenCode, and DeepAgents require a sandbox provider that exposes ports — `@ai-sdk/sandbox-vercel` is the supported choice today. `@ai-sdk/sandbox-just-bash` is suitable only for host-runtime or otherwise non-bridge flows, such as Pi.
|
|
85
102
|
|
|
86
103
|
`sandbox` is a required `HarnessV1SandboxProvider` — the agent calls `provider.createSession()` when a session starts. Use `sandboxConfig` for agent specific sandbox configuration that works independently from the sandbox provider that is used:
|
|
@@ -111,6 +128,12 @@ See the [harness adapters documentation](https://ai-sdk.dev/v7/docs/ai-sdk-harne
|
|
|
111
128
|
|
|
112
129
|
Implement the `HarnessV1` factory and a `HarnessV1Session` whose `doPromptTurn` emits events; the agent surface, streaming, tool execution, and multi-turn state are handled for you. Read `startOpts.sandboxSession` for the network sandbox session the agent created and will stop on cleanup. Call `sandboxSession.restricted()` for the tool-safe file-IO/exec/spawn surface.
|
|
113
130
|
|
|
131
|
+
Each prompt and continuation receives an optional `responseFormat`. JSON
|
|
132
|
+
formats carry a caller-provided JSON Schema plus optional name and description;
|
|
133
|
+
the adapter must enforce the schema and emit the resulting JSON through normal
|
|
134
|
+
text parts. If the runtime cannot honor the format, throw
|
|
135
|
+
`HarnessCapabilityUnsupportedError` before starting the turn.
|
|
136
|
+
|
|
114
137
|
Bootstrap recipe paths may be absolute or relative. Relative `bootstrapDir` and
|
|
115
138
|
file paths are resolved against `sandboxSession.defaultWorkingDirectory`.
|
|
116
139
|
The framework creates `bootstrapDir` before writing files, and bootstrap
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
2
2
|
import { Experimental_SandboxSession, UserModelMessage, ToolSet, FlexibleSchema, Tool, Context, Arrayable, ToolApprovalResponse, ModelMessage } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { StopCondition, ToolApprovalStatus, TelemetryOptions, ActiveTools, StreamTextResult, Agent, AgentCallParameters, GenerateTextResult, AgentStreamParameters, Telemetry } from 'ai';
|
|
3
|
+
import { OutputInterface, StopCondition, ToolApprovalStatus, TelemetryOptions, ActiveTools, StreamTextResult, Agent, AgentCallParameters, GenerateTextResult, AgentStreamParameters, Telemetry } from 'ai';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
import { JSONValue, LanguageModelV4ToolCall, LanguageModelV4ToolApprovalRequest, LanguageModelV4ToolResult, LanguageModelV4FinishReason, LanguageModelV4Usage, JSONSchema7, AISDKError } from '@ai-sdk/provider';
|
|
6
6
|
|
|
@@ -117,6 +117,14 @@ interface HarnessV1Bootstrap {
|
|
|
117
117
|
readonly commands: ReadonlyArray<HarnessV1BootstrapCommand>;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Connection details for a sandbox-exposed port. Headers are scoped to the
|
|
122
|
+
* returned URL and must be included when opening the connection.
|
|
123
|
+
*/
|
|
124
|
+
type HarnessV1PortEndpoint = {
|
|
125
|
+
readonly url: string;
|
|
126
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
127
|
+
};
|
|
120
128
|
/**
|
|
121
129
|
* Network sandbox session returned by `HarnessV1SandboxProvider.createSession()`. The
|
|
122
130
|
* harness keeps this for the lifetime of a session. It is itself a
|
|
@@ -125,8 +133,8 @@ interface HarnessV1Bootstrap {
|
|
|
125
133
|
*
|
|
126
134
|
* Code that should only touch the filesystem and spawn processes receives the
|
|
127
135
|
* reduced view from {@link HarnessV1NetworkSandboxSession.restricted}, never the
|
|
128
|
-
* network sandbox session itself — so it cannot stop the sandbox
|
|
129
|
-
* network
|
|
136
|
+
* network sandbox session itself — so it cannot stop the sandbox, change
|
|
137
|
+
* network access, or transform requests.
|
|
130
138
|
*/
|
|
131
139
|
interface HarnessV1NetworkSandboxSession extends Experimental_SandboxSession {
|
|
132
140
|
/**
|
|
@@ -151,12 +159,21 @@ interface HarnessV1NetworkSandboxSession extends Experimental_SandboxSession {
|
|
|
151
159
|
* not bake a provider-specific base into their own paths.
|
|
152
160
|
*/
|
|
153
161
|
readonly defaultWorkingDirectory: string;
|
|
154
|
-
/** Ports the sandbox exposes; resolvable
|
|
162
|
+
/** Ports the sandbox exposes; resolvable via `getPortEndpoint`. */
|
|
155
163
|
readonly ports: ReadonlyArray<number>;
|
|
156
164
|
/**
|
|
157
|
-
* Resolve
|
|
165
|
+
* Resolve the connection details for a sandbox-exposed port. Bridge-backed
|
|
158
166
|
* adapters call this to open their WebSocket to the in-sandbox bridge.
|
|
159
167
|
*/
|
|
168
|
+
readonly getPortEndpoint: (options: {
|
|
169
|
+
port: number;
|
|
170
|
+
protocol?: 'http' | 'https' | 'ws';
|
|
171
|
+
}) => PromiseLike<HarnessV1PortEndpoint>;
|
|
172
|
+
/**
|
|
173
|
+
* Resolve a publicly-reachable URL for a sandbox-exposed port.
|
|
174
|
+
*
|
|
175
|
+
* @deprecated Use `getPortEndpoint` instead.
|
|
176
|
+
*/
|
|
160
177
|
readonly getPortUrl: (options: {
|
|
161
178
|
port: number;
|
|
162
179
|
protocol?: 'http' | 'https' | 'ws';
|
|
@@ -176,6 +193,23 @@ interface HarnessV1NetworkSandboxSession extends Experimental_SandboxSession {
|
|
|
176
193
|
* missing implementation is a no-op.
|
|
177
194
|
*/
|
|
178
195
|
readonly setNetworkPolicy?: (policy: HarnessV1NetworkPolicy) => PromiseLike<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Replace the sandbox's outbound request-transformation rules. Optional —
|
|
198
|
+
* implementations expose this only when credentials can be injected outside
|
|
199
|
+
* the sandbox security boundary. Calling this method assumes authority over
|
|
200
|
+
* the complete transformation set; harness adapters should normally use
|
|
201
|
+
* `addRequestTransformations` instead. Adapters may preserve legacy
|
|
202
|
+
* credential-forwarding behavior when additive request transformations are
|
|
203
|
+
* unavailable.
|
|
204
|
+
*/
|
|
205
|
+
readonly setRequestTransformations?: (transformations: ReadonlyArray<HarnessV1RequestTransformation>) => PromiseLike<void>;
|
|
206
|
+
/**
|
|
207
|
+
* Add outbound request-transformation rules without replacing rules already
|
|
208
|
+
* managed by the sandbox session. Optional for the same reason as
|
|
209
|
+
* `setRequestTransformations`. Harness adapters should use this additive
|
|
210
|
+
* capability unless they explicitly own the complete transformation set.
|
|
211
|
+
*/
|
|
212
|
+
readonly addRequestTransformations?: (transformations: ReadonlyArray<HarnessV1RequestTransformation>) => PromiseLike<void>;
|
|
179
213
|
/**
|
|
180
214
|
* Replace the set of ports exposed by the sandbox. Full-replacement
|
|
181
215
|
* semantics: ports omitted from the array are deregistered. Optional —
|
|
@@ -192,7 +226,8 @@ interface HarnessV1NetworkSandboxSession extends Experimental_SandboxSession {
|
|
|
192
226
|
*
|
|
193
227
|
* The returned object points at exactly the same underlying sandbox
|
|
194
228
|
* resource as the network sandbox session it was produced from; it is only a
|
|
195
|
-
* narrower surface over the same resource, not a separate sandbox.
|
|
229
|
+
* narrower surface over the same resource, not a separate sandbox. In
|
|
230
|
+
* particular, it cannot mutate network access or request transformations.
|
|
196
231
|
*/
|
|
197
232
|
readonly restricted: () => Experimental_SandboxSession;
|
|
198
233
|
}
|
|
@@ -226,6 +261,47 @@ type HarnessV1NetworkPolicy = {
|
|
|
226
261
|
allowedCIDRs: ReadonlyArray<string>;
|
|
227
262
|
deniedCIDRs?: ReadonlyArray<string>;
|
|
228
263
|
};
|
|
264
|
+
type HarnessV1RequestTransformationPathMatcher = {
|
|
265
|
+
exact: string;
|
|
266
|
+
} | {
|
|
267
|
+
startsWith: string;
|
|
268
|
+
} | {
|
|
269
|
+
regex: string;
|
|
270
|
+
};
|
|
271
|
+
type HarnessV1RequestTransformationKeyValuePartMatcher = {
|
|
272
|
+
exact: string;
|
|
273
|
+
} | {
|
|
274
|
+
startsWith: string;
|
|
275
|
+
} | {
|
|
276
|
+
regex: string;
|
|
277
|
+
};
|
|
278
|
+
type HarnessV1RequestTransformationKeyValueMatcher = {
|
|
279
|
+
readonly key?: HarnessV1RequestTransformationKeyValuePartMatcher;
|
|
280
|
+
readonly value?: HarnessV1RequestTransformationKeyValuePartMatcher;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Outbound HTTPS request transformation applied outside the sandbox security
|
|
284
|
+
* boundary. The host is part of the match so each rule is self-contained and
|
|
285
|
+
* several rules, including several for the same host, can be installed at
|
|
286
|
+
* once.
|
|
287
|
+
*
|
|
288
|
+
* Credential values belong in `transform.headers`, while the sandbox process
|
|
289
|
+
* receives only a non-secret placeholder. Implementations must overwrite
|
|
290
|
+
* matching request headers after the request leaves the sandbox rather than
|
|
291
|
+
* making transformed values available inside it.
|
|
292
|
+
*/
|
|
293
|
+
type HarnessV1RequestTransformation = {
|
|
294
|
+
readonly match: {
|
|
295
|
+
readonly host: string;
|
|
296
|
+
readonly path?: HarnessV1RequestTransformationPathMatcher;
|
|
297
|
+
readonly method?: ReadonlyArray<string>;
|
|
298
|
+
readonly queryString?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;
|
|
299
|
+
readonly headers?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;
|
|
300
|
+
};
|
|
301
|
+
readonly transform: {
|
|
302
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
303
|
+
};
|
|
304
|
+
};
|
|
229
305
|
|
|
230
306
|
/** Severity of a diagnostic, ordered most → least severe. */
|
|
231
307
|
declare const harnessV1DebugLevelSchema: z.ZodEnum<{
|
|
@@ -359,6 +435,30 @@ type HarnessV1PromptControl = {
|
|
|
359
435
|
readonly done: PromiseLike<void>;
|
|
360
436
|
};
|
|
361
437
|
|
|
438
|
+
type HarnessV1JSONValue = null | boolean | number | string | HarnessV1JSONArray | HarnessV1JSONObject;
|
|
439
|
+
interface HarnessV1JSONArray extends Array<HarnessV1JSONValue> {
|
|
440
|
+
}
|
|
441
|
+
interface HarnessV1JSONObject {
|
|
442
|
+
[key: string]: HarnessV1JSONValue | undefined;
|
|
443
|
+
}
|
|
444
|
+
type HarnessV1JSONSchema = HarnessV1JSONObject;
|
|
445
|
+
/**
|
|
446
|
+
* Requested response format for one harness turn.
|
|
447
|
+
*
|
|
448
|
+
* This intentionally mirrors the AI SDK provider response-format shape
|
|
449
|
+
* without depending on `@ai-sdk/provider`. Harness implementations receive
|
|
450
|
+
* JSON Schema rather than the caller's original Zod or Standard Schema so the
|
|
451
|
+
* contract can cross process and package boundaries.
|
|
452
|
+
*/
|
|
453
|
+
type HarnessV1ResponseFormat = {
|
|
454
|
+
readonly type: 'text';
|
|
455
|
+
} | {
|
|
456
|
+
readonly type: 'json';
|
|
457
|
+
readonly schema?: HarnessV1JSONSchema;
|
|
458
|
+
readonly name?: string;
|
|
459
|
+
readonly description?: string;
|
|
460
|
+
};
|
|
461
|
+
|
|
362
462
|
type HarnessV1PendingToolApproval = {
|
|
363
463
|
readonly approvalId: string;
|
|
364
464
|
readonly toolCallId: string;
|
|
@@ -664,8 +764,10 @@ type HarnessV1StartOptions = {
|
|
|
664
764
|
* Network sandbox session the adapter operates against. It is owned and
|
|
665
765
|
* lifecycled by `HarnessAgent`. Adapters call `restricted()` for the
|
|
666
766
|
* tool-safe filesystem/exec/spawn surface, and use the infra methods
|
|
667
|
-
* (`
|
|
668
|
-
*
|
|
767
|
+
* (`getPortEndpoint`, `ports`, `setNetworkPolicy`,
|
|
768
|
+
* `setRequestTransformations`, `addRequestTransformations`) for bridge
|
|
769
|
+
* wiring. Adapters must not call `stop()` themselves; the agent does that
|
|
770
|
+
* during cleanup.
|
|
669
771
|
*/
|
|
670
772
|
readonly sandboxSession: HarnessV1NetworkSandboxSession;
|
|
671
773
|
/**
|
|
@@ -686,6 +788,11 @@ type HarnessV1PromptTurnOptions = {
|
|
|
686
788
|
* so prior turns are never replayed across the contract.
|
|
687
789
|
*/
|
|
688
790
|
readonly prompt: HarnessV1Prompt;
|
|
791
|
+
/**
|
|
792
|
+
* Response format requested for this turn. Adapters that cannot honor a
|
|
793
|
+
* JSON response format must throw `HarnessCapabilityUnsupportedError`.
|
|
794
|
+
*/
|
|
795
|
+
readonly responseFormat?: HarnessV1ResponseFormat;
|
|
689
796
|
/**
|
|
690
797
|
* Host-defined tools to make available to the underlying runtime for this
|
|
691
798
|
* turn. The harness emits `tool-call` events when the runtime calls one
|
|
@@ -721,6 +828,11 @@ type HarnessV1PromptTurnOptions = {
|
|
|
721
828
|
* that was previously suspended temporarily, e.g. by the workflow slice loop.
|
|
722
829
|
*/
|
|
723
830
|
type HarnessV1ContinueTurnOptions = {
|
|
831
|
+
/**
|
|
832
|
+
* Response format of the in-flight turn. Rerun-based adapters use this when
|
|
833
|
+
* reconstructing the turn; attach-based adapters may ignore it.
|
|
834
|
+
*/
|
|
835
|
+
readonly responseFormat?: HarnessV1ResponseFormat;
|
|
724
836
|
/**
|
|
725
837
|
* Host-defined tools to make available for the continued turn. Same shape
|
|
726
838
|
* as `doPromptTurn`'s `tools`. An adapter that purely attaches to a live turn
|
|
@@ -1157,7 +1269,7 @@ type HarnessAgentToolFilteringSettings<TOOLS extends ToolSet> = {
|
|
|
1157
1269
|
*/
|
|
1158
1270
|
readonly inactiveTools?: HarnessTools<TOOLS>;
|
|
1159
1271
|
};
|
|
1160
|
-
type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context> = {
|
|
1272
|
+
type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never> = {
|
|
1161
1273
|
/**
|
|
1162
1274
|
* The harness adapter driving the underlying agent runtime. Its
|
|
1163
1275
|
* `builtinTools` are merged with the user-defined `tools` and exposed to
|
|
@@ -1191,6 +1303,11 @@ type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAge
|
|
|
1191
1303
|
* it to the first user message of a fresh session.
|
|
1192
1304
|
*/
|
|
1193
1305
|
readonly instructions?: string;
|
|
1306
|
+
/**
|
|
1307
|
+
* Optional specification for generating typed output. The same output
|
|
1308
|
+
* requirement is active for every turn run by this agent.
|
|
1309
|
+
*/
|
|
1310
|
+
readonly output?: OUTPUT;
|
|
1194
1311
|
/**
|
|
1195
1312
|
* Conditions that stop the current result after a completed harness tool
|
|
1196
1313
|
* step that can continue into another model step. The underlying turn remains
|
|
@@ -1288,8 +1405,8 @@ declare function collectHarnessAgentToolResultContinuations(input: {
|
|
|
1288
1405
|
messages: readonly ModelMessage[];
|
|
1289
1406
|
}): readonly HarnessAgentToolResultContinuation[];
|
|
1290
1407
|
|
|
1291
|
-
type HarnessAgentTurnResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context> = {
|
|
1292
|
-
result: StreamTextResult<TOOLS, RUNTIME_CONTEXT,
|
|
1408
|
+
type HarnessAgentTurnResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface> = {
|
|
1409
|
+
result: StreamTextResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
|
|
1293
1410
|
done: Promise<void>;
|
|
1294
1411
|
};
|
|
1295
1412
|
type HarnessAgentTurnState = 'idle' | 'running' | 'awaiting-approval' | 'awaiting-tool-result' | 'suspended';
|
|
@@ -1347,7 +1464,7 @@ declare class HarnessAgentSession {
|
|
|
1347
1464
|
turnState?: HarnessAgentTurnState;
|
|
1348
1465
|
});
|
|
1349
1466
|
hasUnfinishedTurn(): boolean;
|
|
1350
|
-
promptTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context>(options: {
|
|
1467
|
+
promptTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
|
|
1351
1468
|
prompt: HarnessAgentPrompt;
|
|
1352
1469
|
instructions: string | undefined;
|
|
1353
1470
|
tools: TOOLS;
|
|
@@ -1356,10 +1473,12 @@ declare class HarnessAgentSession {
|
|
|
1356
1473
|
builtinToolFiltering: HarnessV1BuiltinToolFiltering | undefined;
|
|
1357
1474
|
runtimeContext: RUNTIME_CONTEXT;
|
|
1358
1475
|
abortSignal: AbortSignal | undefined;
|
|
1476
|
+
responseFormat: HarnessV1ResponseFormat | undefined;
|
|
1477
|
+
output: OUTPUT | undefined;
|
|
1359
1478
|
telemetry: TelemetryOptions | undefined;
|
|
1360
1479
|
stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
|
|
1361
|
-
}): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT>;
|
|
1362
|
-
continueTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context>(options: {
|
|
1480
|
+
}): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
|
|
1481
|
+
continueTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
|
|
1363
1482
|
instructions: string | undefined;
|
|
1364
1483
|
tools: TOOLS;
|
|
1365
1484
|
activeTools: ToolSet;
|
|
@@ -1367,11 +1486,13 @@ declare class HarnessAgentSession {
|
|
|
1367
1486
|
builtinToolFiltering: HarnessV1BuiltinToolFiltering | undefined;
|
|
1368
1487
|
runtimeContext: RUNTIME_CONTEXT;
|
|
1369
1488
|
abortSignal: AbortSignal | undefined;
|
|
1489
|
+
responseFormat: HarnessV1ResponseFormat | undefined;
|
|
1490
|
+
output: OUTPUT | undefined;
|
|
1370
1491
|
telemetry: TelemetryOptions | undefined;
|
|
1371
1492
|
stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
|
|
1372
1493
|
toolApprovalContinuations?: readonly HarnessAgentToolApprovalContinuation[] | undefined;
|
|
1373
1494
|
toolResultContinuations?: readonly HarnessAgentToolResultContinuation[] | undefined;
|
|
1374
|
-
}): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT>;
|
|
1495
|
+
}): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
|
|
1375
1496
|
/**
|
|
1376
1497
|
* Ask the underlying runtime to compact its context. The runtime performs
|
|
1377
1498
|
* the compaction itself; when it completes, a `compaction` part appears on
|
|
@@ -1478,7 +1599,7 @@ interface HarnessAgentCallExtensions {
|
|
|
1478
1599
|
* `Experimental_SandboxSession`) is handed to user-tool `execute()` calls
|
|
1479
1600
|
* via `experimental_sandbox`.
|
|
1480
1601
|
*/
|
|
1481
|
-
declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context> implements Agent<never, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT,
|
|
1602
|
+
declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never> implements Agent<never, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT> {
|
|
1482
1603
|
readonly version: "agent-v1";
|
|
1483
1604
|
readonly id: string | undefined;
|
|
1484
1605
|
/**
|
|
@@ -1494,7 +1615,7 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
|
|
|
1494
1615
|
private readonly activeUserTools;
|
|
1495
1616
|
private readonly builtinToolFiltering;
|
|
1496
1617
|
private readonly permissionMode;
|
|
1497
|
-
constructor(settings: HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT>);
|
|
1618
|
+
constructor(settings: HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, OUTPUT>);
|
|
1498
1619
|
/** Identifier of the harness backing this agent. */
|
|
1499
1620
|
get harnessId(): string;
|
|
1500
1621
|
/**
|
|
@@ -1527,8 +1648,8 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
|
|
|
1527
1648
|
continueFrom?: HarnessAgentContinueTurnState;
|
|
1528
1649
|
abortSignal?: AbortSignal;
|
|
1529
1650
|
}): Promise<HarnessAgentSession>;
|
|
1530
|
-
generate(options: AgentCallParameters<never, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT,
|
|
1531
|
-
stream(options: AgentStreamParameters<never, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT,
|
|
1651
|
+
generate(options: AgentCallParameters<never, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
|
|
1652
|
+
stream(options: AgentStreamParameters<never, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
|
|
1532
1653
|
/**
|
|
1533
1654
|
* Continue the in-flight turn **without a new prompt**, draining it like
|
|
1534
1655
|
* {@link generate}. Used after `createSession({ continueFrom })` to finish
|
|
@@ -1539,7 +1660,7 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
|
|
|
1539
1660
|
toolApprovalContinuations?: readonly HarnessAgentToolApprovalContinuation[];
|
|
1540
1661
|
toolResultContinuations?: readonly HarnessAgentToolResultContinuation[];
|
|
1541
1662
|
abortSignal?: AbortSignal;
|
|
1542
|
-
}): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT,
|
|
1663
|
+
}): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
|
|
1543
1664
|
/**
|
|
1544
1665
|
* Continue the in-flight turn **without a new prompt**, streaming its events
|
|
1545
1666
|
* like {@link stream}. Used to keep consuming a turn that is still running
|
|
@@ -1553,12 +1674,13 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
|
|
|
1553
1674
|
toolApprovalContinuations?: readonly HarnessAgentToolApprovalContinuation[];
|
|
1554
1675
|
toolResultContinuations?: readonly HarnessAgentToolResultContinuation[];
|
|
1555
1676
|
abortSignal?: AbortSignal;
|
|
1556
|
-
}): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT,
|
|
1677
|
+
}): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
|
|
1557
1678
|
private _startTurn;
|
|
1558
1679
|
private _acquireSandbox;
|
|
1559
1680
|
private _resolveTurnInput;
|
|
1560
1681
|
private _toToolSpecs;
|
|
1561
1682
|
private _toGenerateResult;
|
|
1683
|
+
private _resolveResponseFormat;
|
|
1562
1684
|
}
|
|
1563
1685
|
|
|
1564
1686
|
type SandboxBootstrapSettings = Omit<HarnessAgentSandboxConfig, 'onSession'>;
|
|
@@ -1606,6 +1728,9 @@ type PrepareSandboxForHarnessResult = {
|
|
|
1606
1728
|
* When a later `HarnessAgent` session uses a sandbox created from the persisted
|
|
1607
1729
|
* artifact, the adapter recomputes the same recipe identity and the existing
|
|
1608
1730
|
* bootstrap marker makes the bootstrap logic a no-op.
|
|
1731
|
+
*
|
|
1732
|
+
* Repeated harness IDs are prepared once. When multiple adapters use the same
|
|
1733
|
+
* ID, the last adapter in `harnesses` is used.
|
|
1609
1734
|
*/
|
|
1610
1735
|
declare function prepareSandboxForHarness(options: {
|
|
1611
1736
|
readonly session: Experimental_SandboxSession;
|
|
@@ -1633,8 +1758,8 @@ declare const symbol$1: unique symbol;
|
|
|
1633
1758
|
/**
|
|
1634
1759
|
* Thrown when a caller asks the harness to do something the adapter (or the
|
|
1635
1760
|
* supplied sandbox) does not support, e.g. requesting manual compaction from
|
|
1636
|
-
* an adapter that only auto-compacts, or invoking `
|
|
1637
|
-
* that does not expose one.
|
|
1761
|
+
* an adapter that only auto-compacts, or invoking `getPortEndpoint` on a
|
|
1762
|
+
* sandbox that does not expose one.
|
|
1638
1763
|
*
|
|
1639
1764
|
* The caller supplies the full human-readable message. Optional `harnessId`
|
|
1640
1765
|
* is recorded as structured context for tooling.
|