@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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { JSONValue } from '@ai-sdk/provider';
|
|
2
|
+
import type { HarnessV1Skill } from './harness-v1-skill';
|
|
3
|
+
import type { HarnessV1ToolSpec } from './harness-v1-tool-spec';
|
|
2
4
|
|
|
3
5
|
export type HarnessV1PendingToolApproval = {
|
|
4
6
|
readonly approvalId: string;
|
|
@@ -16,6 +18,35 @@ export type HarnessV1PendingToolResult = {
|
|
|
16
18
|
readonly input: string;
|
|
17
19
|
};
|
|
18
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Framework-owned settings captured when a turn begins. The same settings are
|
|
23
|
+
* passed to fresh and continued turns and persisted with unfinished-turn state
|
|
24
|
+
* so a resumed continuation cannot pick up configuration from a later turn.
|
|
25
|
+
*/
|
|
26
|
+
export type HarnessV1TurnSettings = {
|
|
27
|
+
/**
|
|
28
|
+
* Skills made available to the underlying runtime for this turn. Adapters
|
|
29
|
+
* must replace skills from the preceding completed turn before starting a
|
|
30
|
+
* fresh turn. Rerun-based continuations use them to reconstruct the turn.
|
|
31
|
+
*/
|
|
32
|
+
readonly skills: ReadonlyArray<HarnessV1Skill>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Free-form instructions for this turn. Adapters should apply them through
|
|
36
|
+
* the runtime's native system or developer instruction mechanism when
|
|
37
|
+
* supported. Rerun-based continuations use them to reconstruct the turn.
|
|
38
|
+
*/
|
|
39
|
+
readonly instructions?: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Host-defined tools made available to the underlying runtime for this turn.
|
|
43
|
+
* The harness emits `tool-call` events when the runtime calls one and waits
|
|
44
|
+
* for `submitToolResult`. Rerun-based continuations use them to reconstruct
|
|
45
|
+
* the turn.
|
|
46
|
+
*/
|
|
47
|
+
readonly tools: ReadonlyArray<HarnessV1ToolSpec>;
|
|
48
|
+
};
|
|
49
|
+
|
|
19
50
|
type HarnessV1LifecycleStateBase = {
|
|
20
51
|
/**
|
|
21
52
|
* Identifier of the harness that produced this state. Used by adapters to
|
|
@@ -70,6 +101,13 @@ export type HarnessV1ContinueTurnState = HarnessV1LifecycleStateBase & {
|
|
|
70
101
|
* result before the underlying turn can continue.
|
|
71
102
|
*/
|
|
72
103
|
readonly pendingToolResults?: readonly HarnessV1PendingToolResult[];
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Framework-owned settings captured when the unfinished turn began. They
|
|
107
|
+
* are persisted outside adapter data so a resumed continuation cannot pick
|
|
108
|
+
* up settings prepared for a later turn.
|
|
109
|
+
*/
|
|
110
|
+
readonly turnSettings?: HarnessV1TurnSettings;
|
|
73
111
|
};
|
|
74
112
|
|
|
75
113
|
export type HarnessV1LifecycleState =
|
|
@@ -8,10 +8,9 @@ import type { HarnessV1ResponseFormat } from './harness-v1-response-format';
|
|
|
8
8
|
import type {
|
|
9
9
|
HarnessV1ContinueTurnState,
|
|
10
10
|
HarnessV1ResumeSessionState,
|
|
11
|
+
HarnessV1TurnSettings,
|
|
11
12
|
} from './harness-v1-lifecycle-state';
|
|
12
|
-
import type { HarnessV1Skill } from './harness-v1-skill';
|
|
13
13
|
import type { HarnessV1StreamPart } from './harness-v1-stream-part';
|
|
14
|
-
import type { HarnessV1ToolSpec } from './harness-v1-tool-spec';
|
|
15
14
|
import type { HarnessV1BuiltinToolFiltering } from './harness-v1-tool-filtering';
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -22,6 +21,12 @@ import type { HarnessV1BuiltinToolFiltering } from './harness-v1-tool-filtering'
|
|
|
22
21
|
* calling the adapter, so adapters never need to derive provider-specific paths.
|
|
23
22
|
*/
|
|
24
23
|
export type HarnessV1StartOptions = {
|
|
24
|
+
/**
|
|
25
|
+
* Model identifier selected by the consumer. Adapters interpret this value
|
|
26
|
+
* according to the underlying harness runtime.
|
|
27
|
+
*/
|
|
28
|
+
readonly model?: string;
|
|
29
|
+
|
|
25
30
|
/**
|
|
26
31
|
* Stable identifier for this harness session. Used as the underlying
|
|
27
32
|
* resource name where the adapter has a notion of a named session
|
|
@@ -29,12 +34,6 @@ export type HarnessV1StartOptions = {
|
|
|
29
34
|
*/
|
|
30
35
|
readonly sessionId: string;
|
|
31
36
|
|
|
32
|
-
/**
|
|
33
|
-
* Skills made available to the underlying runtime for the lifetime of
|
|
34
|
-
* the session. Adapters decide how to surface them.
|
|
35
|
-
*/
|
|
36
|
-
readonly skills?: ReadonlyArray<HarnessV1Skill>;
|
|
37
|
-
|
|
38
37
|
/**
|
|
39
38
|
* Optional resume payload returned by a prior session lifecycle method. When
|
|
40
39
|
* provided, the adapter should resume the existing session before accepting a
|
|
@@ -95,7 +94,7 @@ export type HarnessV1StartOptions = {
|
|
|
95
94
|
/**
|
|
96
95
|
* Options passed to `HarnessV1Session.doPromptTurn`.
|
|
97
96
|
*/
|
|
98
|
-
export type HarnessV1PromptTurnOptions = {
|
|
97
|
+
export type HarnessV1PromptTurnOptions = HarnessV1TurnSettings & {
|
|
99
98
|
/**
|
|
100
99
|
* Fresh input for this turn — either a plain string or a single
|
|
101
100
|
* `ModelMessage`. The harness session owns its own conversation history,
|
|
@@ -109,22 +108,6 @@ export type HarnessV1PromptTurnOptions = {
|
|
|
109
108
|
*/
|
|
110
109
|
readonly responseFormat?: HarnessV1ResponseFormat;
|
|
111
110
|
|
|
112
|
-
/**
|
|
113
|
-
* Host-defined tools to make available to the underlying runtime for this
|
|
114
|
-
* turn. The harness emits `tool-call` events when the runtime calls one
|
|
115
|
-
* and waits for `submitToolResult`.
|
|
116
|
-
*/
|
|
117
|
-
readonly tools?: ReadonlyArray<HarnessV1ToolSpec>;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Free-form instructions for the session. The framework supplies the same
|
|
121
|
-
* value on every turn. Adapters should append it to the runtime's native
|
|
122
|
-
* system or developer prompt when supported. Otherwise, they should prepend
|
|
123
|
-
* it to the first user message of a fresh session and rely on the runtime's
|
|
124
|
-
* persisted history when resuming.
|
|
125
|
-
*/
|
|
126
|
-
readonly instructions?: string;
|
|
127
|
-
|
|
128
111
|
/**
|
|
129
112
|
* Signal that aborts the in-flight turn. The adapter must cancel any
|
|
130
113
|
* underlying work and resolve `done` (with an error if appropriate).
|
|
@@ -147,27 +130,13 @@ export type HarnessV1PromptTurnOptions = {
|
|
|
147
130
|
* in-flight turn rather than starting a new one. It is used to continue a turn
|
|
148
131
|
* that was previously suspended temporarily, e.g. by the workflow slice loop.
|
|
149
132
|
*/
|
|
150
|
-
export type HarnessV1ContinueTurnOptions = {
|
|
133
|
+
export type HarnessV1ContinueTurnOptions = HarnessV1TurnSettings & {
|
|
151
134
|
/**
|
|
152
135
|
* Response format of the in-flight turn. Rerun-based adapters use this when
|
|
153
136
|
* reconstructing the turn; attach-based adapters may ignore it.
|
|
154
137
|
*/
|
|
155
138
|
readonly responseFormat?: HarnessV1ResponseFormat;
|
|
156
139
|
|
|
157
|
-
/**
|
|
158
|
-
* Host-defined tools to make available for the continued turn. Same shape
|
|
159
|
-
* as `doPromptTurn`'s `tools`. An adapter that purely attaches to a live turn
|
|
160
|
-
* may ignore them; an adapter that re-drives the turn (rerun) needs them.
|
|
161
|
-
*/
|
|
162
|
-
readonly tools?: ReadonlyArray<HarnessV1ToolSpec>;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Free-form session instructions. An adapter that re-drives the runtime may
|
|
166
|
-
* need these to reconstruct its native system or developer prompt. An
|
|
167
|
-
* adapter that attaches to a live turn may ignore them.
|
|
168
|
-
*/
|
|
169
|
-
readonly instructions?: string;
|
|
170
|
-
|
|
171
140
|
/**
|
|
172
141
|
* Signal that aborts the continued turn. The adapter must cancel any
|
|
173
142
|
* underlying work and resolve `done` (with an error if appropriate).
|
package/src/v1/index.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export type { HarnessV1 } from './harness-v1';
|
|
2
|
+
export type {
|
|
3
|
+
HarnessV1Authentication,
|
|
4
|
+
HarnessV1AuthenticationEnvironment,
|
|
5
|
+
} from './harness-authentication';
|
|
2
6
|
export type { HarnessV1CredentialForwarding } from './harness-v1-credential-forwarding';
|
|
3
7
|
export type {
|
|
4
8
|
HarnessV1Bootstrap,
|
|
@@ -40,6 +44,7 @@ export type {
|
|
|
40
44
|
HarnessV1PendingToolApproval,
|
|
41
45
|
HarnessV1PendingToolResult,
|
|
42
46
|
HarnessV1ResumeSessionState,
|
|
47
|
+
HarnessV1TurnSettings,
|
|
43
48
|
} from './harness-v1-lifecycle-state';
|
|
44
49
|
export type {
|
|
45
50
|
HarnessV1NetworkPolicy,
|