@ai-sdk/harness 1.0.91 → 1.0.93
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 +22 -0
- package/README.md +5 -1
- package/dist/agent/index.d.ts +155 -110
- package/dist/agent/index.js +292 -99
- package/dist/agent/index.js.map +1 -1
- package/dist/bridge/index.d.ts +20 -1
- package/dist/bridge/index.js +29 -5
- package/dist/bridge/index.js.map +1 -1
- package/dist/index.d.ts +115 -94
- package/dist/utils/index.d.ts +18 -2
- package/dist/utils/index.js +327 -33
- package/dist/utils/index.js.map +1 -1
- package/package.json +4 -4
- package/src/agent/harness-agent-session.ts +107 -7
- package/src/agent/harness-agent-settings.ts +86 -7
- package/src/agent/harness-agent.ts +322 -112
- package/src/agent/internal/lifecycle-state-validation.ts +3 -0
- package/src/agent/internal/run-prompt.ts +16 -6
- package/src/bridge/index.ts +73 -6
- package/src/utils/authentication-environment.ts +20 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/write-skills.ts +419 -32
- package/src/v1/harness-authentication.ts +24 -0
- package/src/v1/harness-v1-lifecycle-state.ts +38 -0
- package/src/v1/harness-v1-session.ts +9 -40
- package/src/v1/index.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @ai-sdk/harness
|
|
2
2
|
|
|
3
|
+
## 1.0.93
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cc9f6ce: fix(harness): stop diagnosing caller-initiated aborts as bridge errors, and serialize bridge turns so a start racing an aborted turn's teardown no longer overlaps it (bounded by a teardown grace period, after which the start proceeds as before)
|
|
8
|
+
- 7608210: feat(harness): add `model` parameter to `HarnessAgent` instead of having each harness adapter support it on their own constructor functions
|
|
9
|
+
- 6f8a2d7: fix (harness): ensure the harness bootstrap recipe on resumed sessions too. The marker is keyed by recipe identity, so a resume whose bootstrap is already current costs one file read, while a resume into a sandbox bootstrapped by an older adapter build — a snapshot that outlived the harness version that made it — is re-bootstrapped instead of running a stale bridge against a newer host.
|
|
10
|
+
- 14d4fc0: feat(harness): allow changing harness settings between turns via `prepareCall()` support on `HarnessAgent`
|
|
11
|
+
- Updated dependencies [6669d69]
|
|
12
|
+
- Updated dependencies [a6463ca]
|
|
13
|
+
- Updated dependencies [e604532]
|
|
14
|
+
- Updated dependencies [90192f1]
|
|
15
|
+
- ai@7.0.84
|
|
16
|
+
- @ai-sdk/provider-utils@5.0.33
|
|
17
|
+
|
|
18
|
+
## 1.0.92
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- e0d7cfb: feat(harness): allow harness sessions to optionally authenticate from an isolated environment supplied through the `auth` option, and remove support for the formerly deprecated legacy auth options types
|
|
23
|
+
- ai@7.0.83
|
|
24
|
+
|
|
3
25
|
## 1.0.91
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ import { z } from 'zod/v4';
|
|
|
22
22
|
const agent = new HarnessAgent({
|
|
23
23
|
harness: claudeCode,
|
|
24
24
|
id: 'auth-agent',
|
|
25
|
+
model: 'claude-sonnet-4-5',
|
|
25
26
|
instructions:
|
|
26
27
|
'You are a careful refactoring assistant. Prefer minimal diffs.',
|
|
27
28
|
sandbox: createVercelSandbox({
|
|
@@ -100,6 +101,9 @@ const agent = new HarnessAgent({
|
|
|
100
101
|
|
|
101
102
|
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 network sandbox session 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.
|
|
102
103
|
|
|
104
|
+
Set `model` on `HarnessAgent` to select the model used when the harness session
|
|
105
|
+
starts. Model identifiers are harness-specific, so `model` accepts any string.
|
|
106
|
+
|
|
103
107
|
`sandbox` is an optional `HarnessV1SandboxProvider`. When omitted, pass a `HarnessV1NetworkSandboxSession` to every `agent.createSession({ sandboxSession })` call. Use `sandboxConfig` for agent specific sandbox configuration that works independently from the sandbox provider that is used:
|
|
104
108
|
|
|
105
109
|
- Use `sandboxConfig.onSession` to prepare the acquired sandbox before the harness adapter starts. The hook runs for fresh and resumed sessions, so keep it idempotent.
|
|
@@ -126,7 +130,7 @@ See the [harness adapters documentation](https://ai-sdk.dev/v7/docs/ai-sdk-harne
|
|
|
126
130
|
|
|
127
131
|
## Implementing a harness
|
|
128
132
|
|
|
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 selected network sandbox session. The harness layer stops or destroys sessions it acquires from the provider, while a session passed to `agent.createSession({ sandboxSession })` remains caller-owned. Call `sandboxSession.restricted()` for the tool-safe file-IO/exec/spawn surface.
|
|
133
|
+
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.model` for the consumer-selected model and `startOpts.sandboxSession` for the selected network sandbox session. The harness layer stops or destroys sessions it acquires from the provider, while a session passed to `agent.createSession({ sandboxSession })` remains caller-owned. Call `sandboxSession.restricted()` for the tool-safe file-IO/exec/spawn surface.
|
|
130
134
|
|
|
131
135
|
Each prompt and continuation receives an optional `responseFormat`. JSON
|
|
132
136
|
formats carry a caller-provided JSON Schema plus optional name and description;
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
2
|
-
import { Experimental_SandboxSession, UserModelMessage, ToolSet, FlexibleSchema, Tool, Context, Arrayable, ToolApprovalResponse, ModelMessage } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { OutputInterface, StopCondition, ToolApprovalStatus, TelemetryOptions, ActiveTools, StreamTextResult, Agent,
|
|
2
|
+
import { Experimental_SandboxSession, UserModelMessage, ToolSet, FlexibleSchema, Tool, Context, MaybePromiseLike, Arrayable, ToolApprovalResponse, ModelMessage } from '@ai-sdk/provider-utils';
|
|
3
|
+
import { OutputInterface, AgentCallParameters, Prompt, StopCondition, ToolApprovalStatus, TelemetryOptions, ActiveTools, StreamTextResult, Agent, GenerateTextResult, AgentStreamParameters, Telemetry } from 'ai';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
|
-
import { JSONValue, LanguageModelV4ToolCall, LanguageModelV4ToolApprovalRequest, LanguageModelV4ToolResult, LanguageModelV4FinishReason, LanguageModelV4Usage,
|
|
5
|
+
import { JSONSchema7, JSONValue, LanguageModelV4ToolCall, LanguageModelV4ToolApprovalRequest, LanguageModelV4ToolResult, LanguageModelV4FinishReason, LanguageModelV4Usage, AISDKError } from '@ai-sdk/provider';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* One file to write into the sandbox as part of an adapter's bootstrap recipe.
|
|
@@ -392,6 +392,66 @@ type HarnessV1ResponseFormat = {
|
|
|
392
392
|
readonly description?: string;
|
|
393
393
|
};
|
|
394
394
|
|
|
395
|
+
/**
|
|
396
|
+
* A self-contained instruction bundle the underlying runtime can load into
|
|
397
|
+
* its context. Adapters decide how to surface skills to the runtime.
|
|
398
|
+
*/
|
|
399
|
+
type HarnessV1Skill = {
|
|
400
|
+
/** Stable identifier for the skill (kebab-case slug). */
|
|
401
|
+
readonly name: string;
|
|
402
|
+
/**
|
|
403
|
+
* Short, model-facing description. This is what the runtime sees to
|
|
404
|
+
* decide whether the skill is relevant.
|
|
405
|
+
*/
|
|
406
|
+
readonly description: string;
|
|
407
|
+
/** Full skill content the model loads when the skill is active. */
|
|
408
|
+
readonly content: string;
|
|
409
|
+
/**
|
|
410
|
+
* Additional files that belong to this skill. Adapters with native skill
|
|
411
|
+
* directories materialize these next to `SKILL.md`; adapters without native
|
|
412
|
+
* skill files include them with the skill content.
|
|
413
|
+
*/
|
|
414
|
+
readonly files?: ReadonlyArray<HarnessV1SkillFile>;
|
|
415
|
+
};
|
|
416
|
+
type HarnessV1SkillFile = {
|
|
417
|
+
/**
|
|
418
|
+
* Skill-relative POSIX path, for example `reference.md` or
|
|
419
|
+
* `references/codes.md`. Absolute paths and `..` segments are rejected by
|
|
420
|
+
* adapters before writing.
|
|
421
|
+
*/
|
|
422
|
+
readonly path: string;
|
|
423
|
+
/** UTF-8 text content for the file. */
|
|
424
|
+
readonly content: string;
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Description of a host-defined tool that the harness should make available
|
|
429
|
+
* to the underlying agent runtime.
|
|
430
|
+
*
|
|
431
|
+
* Adapters translate this into whatever shape their runtime expects (e.g.
|
|
432
|
+
* Claude Code's tool definitions, Codex CLI's tool config, an MCP server
|
|
433
|
+
* exposed to the runtime, …). The adapter does not execute the tool; when
|
|
434
|
+
* the runtime calls it, the adapter emits a `tool-call` event and waits for
|
|
435
|
+
* `submitToolResult` from the caller.
|
|
436
|
+
*/
|
|
437
|
+
type HarnessV1ToolSpec = {
|
|
438
|
+
/**
|
|
439
|
+
* Tool name the agent runtime sees. Must match the name on incoming
|
|
440
|
+
* `tool-call` events.
|
|
441
|
+
*/
|
|
442
|
+
readonly name: string;
|
|
443
|
+
/**
|
|
444
|
+
* Human-readable description handed to the runtime, used to help the model
|
|
445
|
+
* decide when to call the tool.
|
|
446
|
+
*/
|
|
447
|
+
readonly description?: string;
|
|
448
|
+
/**
|
|
449
|
+
* JSON Schema describing the expected input for the tool. Optional because
|
|
450
|
+
* some runtimes accept tools without schemas (free-form arguments).
|
|
451
|
+
*/
|
|
452
|
+
readonly inputSchema?: JSONSchema7;
|
|
453
|
+
};
|
|
454
|
+
|
|
395
455
|
type HarnessV1PendingToolApproval = {
|
|
396
456
|
readonly approvalId: string;
|
|
397
457
|
readonly toolCallId: string;
|
|
@@ -406,6 +466,32 @@ type HarnessV1PendingToolResult = {
|
|
|
406
466
|
readonly toolName: string;
|
|
407
467
|
readonly input: string;
|
|
408
468
|
};
|
|
469
|
+
/**
|
|
470
|
+
* Framework-owned settings captured when a turn begins. The same settings are
|
|
471
|
+
* passed to fresh and continued turns and persisted with unfinished-turn state
|
|
472
|
+
* so a resumed continuation cannot pick up configuration from a later turn.
|
|
473
|
+
*/
|
|
474
|
+
type HarnessV1TurnSettings = {
|
|
475
|
+
/**
|
|
476
|
+
* Skills made available to the underlying runtime for this turn. Adapters
|
|
477
|
+
* must replace skills from the preceding completed turn before starting a
|
|
478
|
+
* fresh turn. Rerun-based continuations use them to reconstruct the turn.
|
|
479
|
+
*/
|
|
480
|
+
readonly skills: ReadonlyArray<HarnessV1Skill>;
|
|
481
|
+
/**
|
|
482
|
+
* Free-form instructions for this turn. Adapters should apply them through
|
|
483
|
+
* the runtime's native system or developer instruction mechanism when
|
|
484
|
+
* supported. Rerun-based continuations use them to reconstruct the turn.
|
|
485
|
+
*/
|
|
486
|
+
readonly instructions?: string;
|
|
487
|
+
/**
|
|
488
|
+
* Host-defined tools made available to the underlying runtime for this turn.
|
|
489
|
+
* The harness emits `tool-call` events when the runtime calls one and waits
|
|
490
|
+
* for `submitToolResult`. Rerun-based continuations use them to reconstruct
|
|
491
|
+
* the turn.
|
|
492
|
+
*/
|
|
493
|
+
readonly tools: ReadonlyArray<HarnessV1ToolSpec>;
|
|
494
|
+
};
|
|
409
495
|
type HarnessV1LifecycleStateBase = {
|
|
410
496
|
/**
|
|
411
497
|
* Identifier of the harness that produced this state. Used by adapters to
|
|
@@ -453,40 +539,14 @@ type HarnessV1ContinueTurnState = HarnessV1LifecycleStateBase & {
|
|
|
453
539
|
* result before the underlying turn can continue.
|
|
454
540
|
*/
|
|
455
541
|
readonly pendingToolResults?: readonly HarnessV1PendingToolResult[];
|
|
456
|
-
};
|
|
457
|
-
type HarnessV1LifecycleState = HarnessV1ResumeSessionState | HarnessV1ContinueTurnState;
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* A self-contained instruction bundle the underlying runtime can load into
|
|
461
|
-
* its context. Adapters decide how to surface skills to the runtime.
|
|
462
|
-
*/
|
|
463
|
-
type HarnessV1Skill = {
|
|
464
|
-
/** Stable identifier for the skill (kebab-case slug). */
|
|
465
|
-
readonly name: string;
|
|
466
|
-
/**
|
|
467
|
-
* Short, model-facing description. This is what the runtime sees to
|
|
468
|
-
* decide whether the skill is relevant.
|
|
469
|
-
*/
|
|
470
|
-
readonly description: string;
|
|
471
|
-
/** Full skill content the model loads when the skill is active. */
|
|
472
|
-
readonly content: string;
|
|
473
|
-
/**
|
|
474
|
-
* Additional files that belong to this skill. Adapters with native skill
|
|
475
|
-
* directories materialize these next to `SKILL.md`; adapters without native
|
|
476
|
-
* skill files include them with the skill content.
|
|
477
|
-
*/
|
|
478
|
-
readonly files?: ReadonlyArray<HarnessV1SkillFile>;
|
|
479
|
-
};
|
|
480
|
-
type HarnessV1SkillFile = {
|
|
481
542
|
/**
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
543
|
+
* Framework-owned settings captured when the unfinished turn began. They
|
|
544
|
+
* are persisted outside adapter data so a resumed continuation cannot pick
|
|
545
|
+
* up settings prepared for a later turn.
|
|
485
546
|
*/
|
|
486
|
-
readonly
|
|
487
|
-
/** UTF-8 text content for the file. */
|
|
488
|
-
readonly content: string;
|
|
547
|
+
readonly turnSettings?: HarnessV1TurnSettings;
|
|
489
548
|
};
|
|
549
|
+
type HarnessV1LifecycleState = HarnessV1ResumeSessionState | HarnessV1ContinueTurnState;
|
|
490
550
|
|
|
491
551
|
/**
|
|
492
552
|
* Warning emitted by a harness adapter during a call.
|
|
@@ -607,34 +667,6 @@ type HarnessV1StreamPart = {
|
|
|
607
667
|
rawValue: unknown;
|
|
608
668
|
};
|
|
609
669
|
|
|
610
|
-
/**
|
|
611
|
-
* Description of a host-defined tool that the harness should make available
|
|
612
|
-
* to the underlying agent runtime.
|
|
613
|
-
*
|
|
614
|
-
* Adapters translate this into whatever shape their runtime expects (e.g.
|
|
615
|
-
* Claude Code's tool definitions, Codex CLI's tool config, an MCP server
|
|
616
|
-
* exposed to the runtime, …). The adapter does not execute the tool; when
|
|
617
|
-
* the runtime calls it, the adapter emits a `tool-call` event and waits for
|
|
618
|
-
* `submitToolResult` from the caller.
|
|
619
|
-
*/
|
|
620
|
-
type HarnessV1ToolSpec = {
|
|
621
|
-
/**
|
|
622
|
-
* Tool name the agent runtime sees. Must match the name on incoming
|
|
623
|
-
* `tool-call` events.
|
|
624
|
-
*/
|
|
625
|
-
readonly name: string;
|
|
626
|
-
/**
|
|
627
|
-
* Human-readable description handed to the runtime, used to help the model
|
|
628
|
-
* decide when to call the tool.
|
|
629
|
-
*/
|
|
630
|
-
readonly description?: string;
|
|
631
|
-
/**
|
|
632
|
-
* JSON Schema describing the expected input for the tool. Optional because
|
|
633
|
-
* some runtimes accept tools without schemas (free-form arguments).
|
|
634
|
-
*/
|
|
635
|
-
readonly inputSchema?: JSONSchema7;
|
|
636
|
-
};
|
|
637
|
-
|
|
638
670
|
type HarnessV1BuiltinToolFiltering = {
|
|
639
671
|
mode: 'allow';
|
|
640
672
|
toolNames: string[];
|
|
@@ -651,17 +683,17 @@ type HarnessV1BuiltinToolFiltering = {
|
|
|
651
683
|
* calling the adapter, so adapters never need to derive provider-specific paths.
|
|
652
684
|
*/
|
|
653
685
|
type HarnessV1StartOptions = {
|
|
686
|
+
/**
|
|
687
|
+
* Model identifier selected by the consumer. Adapters interpret this value
|
|
688
|
+
* according to the underlying harness runtime.
|
|
689
|
+
*/
|
|
690
|
+
readonly model?: string;
|
|
654
691
|
/**
|
|
655
692
|
* Stable identifier for this harness session. Used as the underlying
|
|
656
693
|
* resource name where the adapter has a notion of a named session
|
|
657
694
|
* (sandbox name, native session id, …).
|
|
658
695
|
*/
|
|
659
696
|
readonly sessionId: string;
|
|
660
|
-
/**
|
|
661
|
-
* Skills made available to the underlying runtime for the lifetime of
|
|
662
|
-
* the session. Adapters decide how to surface them.
|
|
663
|
-
*/
|
|
664
|
-
readonly skills?: ReadonlyArray<HarnessV1Skill>;
|
|
665
697
|
/**
|
|
666
698
|
* Optional resume payload returned by a prior session lifecycle method. When
|
|
667
699
|
* provided, the adapter should resume the existing session before accepting a
|
|
@@ -715,7 +747,7 @@ type HarnessV1StartOptions = {
|
|
|
715
747
|
/**
|
|
716
748
|
* Options passed to `HarnessV1Session.doPromptTurn`.
|
|
717
749
|
*/
|
|
718
|
-
type HarnessV1PromptTurnOptions = {
|
|
750
|
+
type HarnessV1PromptTurnOptions = HarnessV1TurnSettings & {
|
|
719
751
|
/**
|
|
720
752
|
* Fresh input for this turn — either a plain string or a single
|
|
721
753
|
* `ModelMessage`. The harness session owns its own conversation history,
|
|
@@ -727,20 +759,6 @@ type HarnessV1PromptTurnOptions = {
|
|
|
727
759
|
* JSON response format must throw `HarnessCapabilityUnsupportedError`.
|
|
728
760
|
*/
|
|
729
761
|
readonly responseFormat?: HarnessV1ResponseFormat;
|
|
730
|
-
/**
|
|
731
|
-
* Host-defined tools to make available to the underlying runtime for this
|
|
732
|
-
* turn. The harness emits `tool-call` events when the runtime calls one
|
|
733
|
-
* and waits for `submitToolResult`.
|
|
734
|
-
*/
|
|
735
|
-
readonly tools?: ReadonlyArray<HarnessV1ToolSpec>;
|
|
736
|
-
/**
|
|
737
|
-
* Free-form instructions for the session. The framework supplies the same
|
|
738
|
-
* value on every turn. Adapters should append it to the runtime's native
|
|
739
|
-
* system or developer prompt when supported. Otherwise, they should prepend
|
|
740
|
-
* it to the first user message of a fresh session and rely on the runtime's
|
|
741
|
-
* persisted history when resuming.
|
|
742
|
-
*/
|
|
743
|
-
readonly instructions?: string;
|
|
744
762
|
/**
|
|
745
763
|
* Signal that aborts the in-flight turn. The adapter must cancel any
|
|
746
764
|
* underlying work and resolve `done` (with an error if appropriate).
|
|
@@ -761,24 +779,12 @@ type HarnessV1PromptTurnOptions = {
|
|
|
761
779
|
* in-flight turn rather than starting a new one. It is used to continue a turn
|
|
762
780
|
* that was previously suspended temporarily, e.g. by the workflow slice loop.
|
|
763
781
|
*/
|
|
764
|
-
type HarnessV1ContinueTurnOptions = {
|
|
782
|
+
type HarnessV1ContinueTurnOptions = HarnessV1TurnSettings & {
|
|
765
783
|
/**
|
|
766
784
|
* Response format of the in-flight turn. Rerun-based adapters use this when
|
|
767
785
|
* reconstructing the turn; attach-based adapters may ignore it.
|
|
768
786
|
*/
|
|
769
787
|
readonly responseFormat?: HarnessV1ResponseFormat;
|
|
770
|
-
/**
|
|
771
|
-
* Host-defined tools to make available for the continued turn. Same shape
|
|
772
|
-
* as `doPromptTurn`'s `tools`. An adapter that purely attaches to a live turn
|
|
773
|
-
* may ignore them; an adapter that re-drives the turn (rerun) needs them.
|
|
774
|
-
*/
|
|
775
|
-
readonly tools?: ReadonlyArray<HarnessV1ToolSpec>;
|
|
776
|
-
/**
|
|
777
|
-
* Free-form session instructions. An adapter that re-drives the runtime may
|
|
778
|
-
* need these to reconstruct its native system or developer prompt. An
|
|
779
|
-
* adapter that attaches to a live turn may ignore them.
|
|
780
|
-
*/
|
|
781
|
-
readonly instructions?: string;
|
|
782
788
|
/**
|
|
783
789
|
* Signal that aborts the continued turn. The adapter must cancel any
|
|
784
790
|
* underlying work and resolve `done` (with an error if appropriate).
|
|
@@ -1242,9 +1248,10 @@ type HarnessTools<TOOLS extends ToolSet> = ActiveTools<NoInfer<TOOLS>>;
|
|
|
1242
1248
|
/**
|
|
1243
1249
|
* Construction-time settings for a `HarnessAgent`.
|
|
1244
1250
|
*
|
|
1245
|
-
*
|
|
1251
|
+
* Prompt, abortSignal, callbacks, and custom call options belong on the
|
|
1246
1252
|
* `AgentCallParameters` / `AgentStreamParameters` passed to `generate` /
|
|
1247
|
-
* `stream`
|
|
1253
|
+
* `stream`. `prepareCall` can derive turn-scoped skills, instructions, and
|
|
1254
|
+
* tools from those custom call options.
|
|
1248
1255
|
*/
|
|
1249
1256
|
type HarnessAgentToolFilteringSettings<TOOLS extends ToolSet> = {
|
|
1250
1257
|
/**
|
|
@@ -1261,7 +1268,7 @@ type HarnessAgentToolFilteringSettings<TOOLS extends ToolSet> = {
|
|
|
1261
1268
|
*/
|
|
1262
1269
|
readonly inactiveTools?: HarnessTools<TOOLS>;
|
|
1263
1270
|
};
|
|
1264
|
-
type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never> = {
|
|
1271
|
+
type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never, CALL_OPTIONS = never> = {
|
|
1265
1272
|
/**
|
|
1266
1273
|
* The harness adapter driving the underlying agent runtime. Its
|
|
1267
1274
|
* `builtinTools` are merged with the user-defined `tools` and exposed to
|
|
@@ -1273,6 +1280,11 @@ type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAge
|
|
|
1273
1280
|
* If omitted, `agent.id` is `undefined`.
|
|
1274
1281
|
*/
|
|
1275
1282
|
readonly id?: string;
|
|
1283
|
+
/**
|
|
1284
|
+
* Model identifier passed to the harness adapter when a session starts.
|
|
1285
|
+
* Supported values are defined by the selected harness.
|
|
1286
|
+
*/
|
|
1287
|
+
readonly model?: string;
|
|
1276
1288
|
/**
|
|
1277
1289
|
* Tools available to the underlying runtime in addition to the harness's
|
|
1278
1290
|
* own builtins. The agent forwards each tool to the harness as a
|
|
@@ -1284,17 +1296,37 @@ type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAge
|
|
|
1284
1296
|
*/
|
|
1285
1297
|
readonly tools?: TUserTools;
|
|
1286
1298
|
/**
|
|
1287
|
-
* Skills made available to the underlying runtime
|
|
1288
|
-
*
|
|
1289
|
-
* working tree, prompt prefix, …).
|
|
1299
|
+
* Skills made available to the underlying runtime. Each adapter decides how
|
|
1300
|
+
* to surface skills. `prepareCall` can replace them between completed turns.
|
|
1290
1301
|
*/
|
|
1291
1302
|
readonly skills?: ReadonlyArray<HarnessAgentSkill>;
|
|
1292
1303
|
/**
|
|
1293
|
-
* Instructions for the underlying agent runtime. Adapters append
|
|
1304
|
+
* Instructions for the underlying agent runtime. Adapters append these to a
|
|
1294
1305
|
* native system or developer prompt when supported. Otherwise, they prepend
|
|
1295
|
-
*
|
|
1306
|
+
* them to the user message. `prepareCall` can replace them between completed
|
|
1307
|
+
* turns.
|
|
1296
1308
|
*/
|
|
1297
1309
|
readonly instructions?: string;
|
|
1310
|
+
/**
|
|
1311
|
+
* Schema for validating the custom options passed to each agent call.
|
|
1312
|
+
*/
|
|
1313
|
+
readonly callOptionsSchema?: FlexibleSchema<CALL_OPTIONS>;
|
|
1314
|
+
/**
|
|
1315
|
+
* Prepares the prompt and the settings that may vary between completed
|
|
1316
|
+
* turns. The prepared values are frozen for the lifetime of the turn,
|
|
1317
|
+
* including any suspended-turn continuations.
|
|
1318
|
+
*
|
|
1319
|
+
* Preserve the remaining arguments with the rest-spread pattern when a
|
|
1320
|
+
* field should be removable by returning `undefined`:
|
|
1321
|
+
*
|
|
1322
|
+
* ```ts
|
|
1323
|
+
* prepareCall: ({ options, ...rest }) => ({
|
|
1324
|
+
* ...rest,
|
|
1325
|
+
* instructions: options.instructions,
|
|
1326
|
+
* })
|
|
1327
|
+
* ```
|
|
1328
|
+
*/
|
|
1329
|
+
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>, 'skills' | 'instructions' | 'tools'>) => MaybePromiseLike<Pick<HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, NoInfer<OUTPUT>, CALL_OPTIONS>, 'skills' | 'instructions' | 'tools'> & Omit<Prompt, 'system' | 'instructions' | 'allowSystemInMessages'>>;
|
|
1298
1330
|
/**
|
|
1299
1331
|
* Optional specification for generating typed output. The same output
|
|
1300
1332
|
* requirement is active for every turn run by this agent.
|
|
@@ -1399,6 +1431,7 @@ declare function collectHarnessAgentToolResultContinuations(input: {
|
|
|
1399
1431
|
type HarnessAgentTurnResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface> = {
|
|
1400
1432
|
result: StreamTextResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
|
|
1401
1433
|
done: Promise<void>;
|
|
1434
|
+
ready: Promise<void>;
|
|
1402
1435
|
};
|
|
1403
1436
|
type HarnessAgentTurnState = 'idle' | 'running' | 'awaiting-approval' | 'awaiting-tool-result' | 'suspended';
|
|
1404
1437
|
/**
|
|
@@ -1434,6 +1467,8 @@ declare class HarnessAgentSession {
|
|
|
1434
1467
|
private activeTurnSequence;
|
|
1435
1468
|
private activePromptControl;
|
|
1436
1469
|
private suspendedTurnState;
|
|
1470
|
+
private activeTurnSettings;
|
|
1471
|
+
private persistedTurnSettings;
|
|
1437
1472
|
/**
|
|
1438
1473
|
* Whether this session was created from `resumeFrom` or `continueFrom`.
|
|
1439
1474
|
* Captured at construction so it survives lifecycle cleanup.
|
|
@@ -1449,11 +1484,13 @@ declare class HarnessAgentSession {
|
|
|
1449
1484
|
toolApproval: HarnessAgentToolApprovalConfiguration | undefined;
|
|
1450
1485
|
pendingToolApprovals?: readonly HarnessAgentPendingToolApproval[];
|
|
1451
1486
|
pendingToolResults?: readonly HarnessAgentPendingToolResult[];
|
|
1487
|
+
turnSettings?: HarnessV1TurnSettings;
|
|
1452
1488
|
turnState?: HarnessAgentTurnState;
|
|
1453
1489
|
});
|
|
1454
1490
|
hasUnfinishedTurn(): boolean;
|
|
1455
1491
|
promptTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
|
|
1456
1492
|
prompt: HarnessAgentPrompt;
|
|
1493
|
+
skills: ReadonlyArray<HarnessV1Skill>;
|
|
1457
1494
|
instructions: string | undefined;
|
|
1458
1495
|
tools: TOOLS;
|
|
1459
1496
|
activeTools: ToolSet;
|
|
@@ -1467,6 +1504,7 @@ declare class HarnessAgentSession {
|
|
|
1467
1504
|
stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
|
|
1468
1505
|
}): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
|
|
1469
1506
|
continueTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
|
|
1507
|
+
skills: ReadonlyArray<HarnessV1Skill>;
|
|
1470
1508
|
instructions: string | undefined;
|
|
1471
1509
|
tools: TOOLS;
|
|
1472
1510
|
activeTools: ToolSet;
|
|
@@ -1543,9 +1581,11 @@ declare class HarnessAgentSession {
|
|
|
1543
1581
|
private markAwaitingToolResultIfActive;
|
|
1544
1582
|
private startTrackedTurn;
|
|
1545
1583
|
private setPromptControl;
|
|
1584
|
+
private waitForPromptControl;
|
|
1546
1585
|
private settleActivePromptControl;
|
|
1547
1586
|
private clearActivePromptControl;
|
|
1548
1587
|
private finishTrackedTurn;
|
|
1588
|
+
private resolveActiveTurnSettings;
|
|
1549
1589
|
private endLocalHandle;
|
|
1550
1590
|
private requireReusableSession;
|
|
1551
1591
|
}
|
|
@@ -1598,7 +1638,7 @@ interface HarnessAgentCallExtensions {
|
|
|
1598
1638
|
* remain owned by the caller and are not stopped or destroyed by the
|
|
1599
1639
|
* harness layer.
|
|
1600
1640
|
*/
|
|
1601
|
-
declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = never> implements Agent<
|
|
1641
|
+
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> {
|
|
1602
1642
|
readonly version: "agent-v1";
|
|
1603
1643
|
readonly id: string | undefined;
|
|
1604
1644
|
/**
|
|
@@ -1611,10 +1651,9 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
|
|
|
1611
1651
|
private readonly settings;
|
|
1612
1652
|
private readonly stopConditions;
|
|
1613
1653
|
private readonly sandboxConfig;
|
|
1614
|
-
private readonly activeUserTools;
|
|
1615
1654
|
private readonly builtinToolFiltering;
|
|
1616
1655
|
private readonly permissionMode;
|
|
1617
|
-
constructor(settings: HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, OUTPUT>);
|
|
1656
|
+
constructor(settings: HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, OUTPUT, CALL_OPTIONS>);
|
|
1618
1657
|
/** Identifier of the harness backing this agent. */
|
|
1619
1658
|
get harnessId(): string;
|
|
1620
1659
|
/**
|
|
@@ -1652,8 +1691,8 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
|
|
|
1652
1691
|
sandboxSession?: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
|
|
1653
1692
|
abortSignal?: AbortSignal;
|
|
1654
1693
|
}): Promise<HarnessAgentSession>;
|
|
1655
|
-
generate(options: AgentCallParameters<
|
|
1656
|
-
stream(options: AgentStreamParameters<
|
|
1694
|
+
generate(options: AgentCallParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
|
|
1695
|
+
stream(options: AgentStreamParameters<CALL_OPTIONS, HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT> & HarnessAgentCallExtensions): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, OUTPUT>>;
|
|
1657
1696
|
/**
|
|
1658
1697
|
* Continue the in-flight turn **without a new prompt**, draining it like
|
|
1659
1698
|
* {@link generate}. Used after `createSession({ continueFrom })` to finish
|
|
@@ -1690,8 +1729,14 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
|
|
|
1690
1729
|
session: HarnessAgentSession;
|
|
1691
1730
|
text: string;
|
|
1692
1731
|
}): Promise<void>;
|
|
1693
|
-
private
|
|
1694
|
-
private
|
|
1732
|
+
private _startPromptTurn;
|
|
1733
|
+
private _startContinueTurn;
|
|
1734
|
+
private _buildTurnOptions;
|
|
1735
|
+
private _resolveContinueTurnInput;
|
|
1736
|
+
private _resolvePromptTurnInput;
|
|
1737
|
+
private _preparePromptTurnInput;
|
|
1738
|
+
private _prepareContinueTurnInput;
|
|
1739
|
+
private _prepareTurnSettings;
|
|
1695
1740
|
private _toToolSpecs;
|
|
1696
1741
|
private _toGenerateResult;
|
|
1697
1742
|
private _resolveResponseFormat;
|