@nylorun/harness 0.12.0-beta → 0.15.0-beta
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 +71 -0
- package/HOST_CONTRACT.md +27 -0
- package/README.md +86 -5
- package/dist/compatibility.d.ts +3 -0
- package/dist/compatibility.js +3 -0
- package/dist/definition/agent-definition.d.ts +19 -0
- package/dist/definition/agent-definition.js +20 -0
- package/dist/definition/compatibility.d.ts +11 -0
- package/dist/definition/compatibility.js +30 -0
- package/dist/definition/registry.d.ts +10 -0
- package/dist/definition/registry.js +49 -0
- package/dist/index.d.ts +4 -15
- package/dist/index.js +1 -6
- package/dist/loop/dispatch.d.ts +2 -0
- package/dist/loop/dispatch.js +327 -0
- package/dist/loop/host-suspension.d.ts +6 -0
- package/dist/loop/host-suspension.js +10 -0
- package/dist/loop/initial-state.d.ts +13 -0
- package/dist/loop/initial-state.js +30 -0
- package/dist/loop/invocation.d.ts +24 -0
- package/dist/loop/invocation.js +37 -0
- package/dist/{model → loop/model}/adapters.d.ts +4 -2
- package/dist/{model → loop/model}/adapters.js +3 -2
- package/dist/{model → loop/model}/normalize.d.ts +2 -2
- package/dist/{model → loop/model}/normalize.js +2 -2
- package/dist/{model → loop/model}/prepared.d.ts +3 -3
- package/dist/{step → loop/model}/project.d.ts +1 -1
- package/dist/{step → loop/model}/project.js +2 -10
- package/dist/loop/observe.d.ts +17 -0
- package/dist/loop/observe.js +53 -0
- package/dist/loop/options.d.ts +11 -0
- package/dist/loop/options.js +69 -0
- package/dist/loop/resume.d.ts +4 -0
- package/dist/loop/resume.js +52 -0
- package/dist/loop/run.d.ts +5 -0
- package/dist/loop/run.js +264 -0
- package/dist/loop/state.d.ts +8 -0
- package/dist/loop/state.js +218 -0
- package/dist/{step → loop/step}/canonicalize.d.ts +2 -2
- package/dist/{step → loop/step}/canonicalize.js +2 -2
- package/dist/{step → loop/step}/compose.d.ts +3 -2
- package/dist/{step → loop/step}/compose.js +8 -5
- package/dist/loop/step/context-draft.d.ts +8 -0
- package/dist/{step → loop/step}/context-draft.js +5 -22
- package/dist/loop/step/describe.d.ts +9 -0
- package/dist/loop/step/describe.js +22 -0
- package/dist/loop/step/dynamics.d.ts +29 -0
- package/dist/loop/step/dynamics.js +147 -0
- package/dist/{step → loop/step}/model-configuration.d.ts +4 -3
- package/dist/{step → loop/step}/model-configuration.js +3 -3
- package/dist/loop/step/resolve.d.ts +11 -0
- package/dist/{step → loop/step}/resolve.js +5 -3
- package/dist/loop/step/run.d.ts +30 -0
- package/dist/{step → loop/step}/run.js +104 -53
- package/dist/loop/step/runtime.d.ts +40 -0
- package/dist/{step → loop/step}/seal.d.ts +13 -8
- package/dist/{step → loop/step}/seal.js +8 -6
- package/dist/{step → loop/step}/slot-assembly.d.ts +4 -4
- package/dist/{step → loop/step}/slot-assembly.js +4 -4
- package/dist/{step → loop/step}/step-context.d.ts +11 -12
- package/dist/{step → loop/step}/step-context.js +5 -27
- package/dist/loop/tool-result.d.ts +4 -0
- package/dist/loop/tool-result.js +30 -0
- package/dist/loop/transcript.d.ts +2 -0
- package/dist/{session/seed.js → loop/transcript.js} +11 -41
- package/dist/loop/waits.d.ts +50 -0
- package/dist/loop/waits.js +11 -0
- package/dist/run/durable.d.ts +71 -0
- package/dist/run/durable.js +164 -0
- package/dist/run/index.d.ts +33 -0
- package/dist/run/index.js +38 -0
- package/dist/types/client.d.ts +88 -0
- package/dist/types/execution.d.ts +114 -0
- package/dist/utils/ids.d.ts +1 -0
- package/dist/utils/ids.js +11 -1
- package/package.json +18 -6
- package/dist/build/agent.d.ts +0 -17
- package/dist/build/agent.js +0 -32
- package/dist/build/assemble.d.ts +0 -7
- package/dist/build/assemble.js +0 -41
- package/dist/build/bind-tool.d.ts +0 -3
- package/dist/build/bind-tool.js +0 -18
- package/dist/build/builder.d.ts +0 -38
- package/dist/build/builder.js +0 -136
- package/dist/build/helpers.d.ts +0 -6
- package/dist/build/helpers.js +0 -4
- package/dist/build/manifest.d.ts +0 -7
- package/dist/build/manifest.js +0 -20
- package/dist/build/schema.d.ts +0 -14
- package/dist/build/schema.js +0 -205
- package/dist/errors.d.ts +0 -17
- package/dist/errors.js +0 -17
- package/dist/session/capability-state.d.ts +0 -14
- package/dist/session/capability-state.js +0 -67
- package/dist/session/event-log.d.ts +0 -12
- package/dist/session/event-log.js +0 -63
- package/dist/session/input-queue.d.ts +0 -41
- package/dist/session/input-queue.js +0 -94
- package/dist/session/output-contract.d.ts +0 -6
- package/dist/session/output-contract.js +0 -12
- package/dist/session/record.d.ts +0 -11
- package/dist/session/record.js +0 -26
- package/dist/session/scheduler.d.ts +0 -62
- package/dist/session/scheduler.js +0 -475
- package/dist/session/seed.d.ts +0 -10
- package/dist/session/session.d.ts +0 -17
- package/dist/session/session.js +0 -101
- package/dist/session/state.d.ts +0 -15
- package/dist/session/state.js +0 -48
- package/dist/session/submission-stream.d.ts +0 -16
- package/dist/session/submission-stream.js +0 -46
- package/dist/step/context-draft.d.ts +0 -10
- package/dist/step/resolve.d.ts +0 -10
- package/dist/step/run.d.ts +0 -33
- package/dist/turn/plan-runner.d.ts +0 -72
- package/dist/turn/plan-runner.js +0 -389
- package/dist/turn/runner.d.ts +0 -69
- package/dist/turn/runner.js +0 -159
- package/dist/types/manifest.d.ts +0 -19
- package/dist/types/middleware.d.ts +0 -95
- package/dist/types/model.d.ts +0 -184
- package/dist/types/session.d.ts +0 -230
- package/dist/types/session.js +0 -1
- package/dist/types/shared.d.ts +0 -249
- package/dist/types/shared.js +0 -1
- package/dist/types/tool.d.ts +0 -139
- package/dist/types/tool.js +0 -1
- package/dist/utils/immutable.d.ts +0 -5
- package/dist/utils/immutable.js +0 -68
- package/dist/utils/maps.d.ts +0 -1
- package/dist/utils/maps.js +0 -37
- package/dist/utils/observe.d.ts +0 -3
- package/dist/utils/observe.js +0 -13
- /package/dist/{model → loop/model}/prepared.js +0 -0
- /package/dist/{types/manifest.js → loop/step/runtime.js} +0 -0
- /package/dist/types/{middleware.js → client.js} +0 -0
- /package/dist/types/{model.js → execution.js} +0 -0
package/dist/types/shared.d.ts
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import type { ContextSnapshot, ModelCandidate, ModelCall, ModelConfigurationSnapshot } from "./model.js";
|
|
2
|
-
import type { InputEvent, TranscriptEntry } from "./session.js";
|
|
3
|
-
import type { RequiredInteraction, ToolResult } from "./tool.js";
|
|
4
|
-
export type JsonPrimitive = string | number | boolean | null;
|
|
5
|
-
export type JsonValue = JsonPrimitive | JsonObject | readonly JsonValue[];
|
|
6
|
-
export type JsonObject = {
|
|
7
|
-
readonly [key: string]: JsonValue;
|
|
8
|
-
};
|
|
9
|
-
export interface DeferredOutcome {
|
|
10
|
-
readonly kind: "deferred";
|
|
11
|
-
readonly token?: JsonValue;
|
|
12
|
-
}
|
|
13
|
-
export interface BuildDiagnostic {
|
|
14
|
-
readonly code: string;
|
|
15
|
-
readonly message: string;
|
|
16
|
-
readonly toolName?: string;
|
|
17
|
-
readonly details?: Readonly<Record<string, string | number | boolean>>;
|
|
18
|
-
readonly cause?: unknown;
|
|
19
|
-
}
|
|
20
|
-
export interface ContextItem {
|
|
21
|
-
readonly type?: string;
|
|
22
|
-
readonly value: JsonValue;
|
|
23
|
-
}
|
|
24
|
-
export interface Tripwire {
|
|
25
|
-
readonly code: string;
|
|
26
|
-
readonly message: string;
|
|
27
|
-
readonly scope?: "step" | "session";
|
|
28
|
-
}
|
|
29
|
-
export interface ObserveToolSnapshot {
|
|
30
|
-
readonly name: string;
|
|
31
|
-
readonly description?: string;
|
|
32
|
-
readonly owner: {
|
|
33
|
-
readonly middlewareId: string;
|
|
34
|
-
readonly slot: string;
|
|
35
|
-
};
|
|
36
|
-
readonly inputSchema: {
|
|
37
|
-
readonly jsonSchema: JsonObject;
|
|
38
|
-
};
|
|
39
|
-
readonly outputSchema?: {
|
|
40
|
-
readonly jsonSchema: JsonObject;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/** JSON-only model-configuration view suitable for an observation stream. */
|
|
44
|
-
export interface ObserveModelConfigurationSnapshot extends Omit<ModelConfigurationSnapshot, "tools"> {
|
|
45
|
-
readonly tools: readonly ObserveToolSnapshot[];
|
|
46
|
-
}
|
|
47
|
-
export interface ObserveSealedCall {
|
|
48
|
-
readonly callId: string;
|
|
49
|
-
readonly toolName: string;
|
|
50
|
-
readonly args: JsonValue;
|
|
51
|
-
readonly invocationId: string;
|
|
52
|
-
readonly owner: {
|
|
53
|
-
readonly middlewareId: string;
|
|
54
|
-
readonly slot: string;
|
|
55
|
-
};
|
|
56
|
-
readonly interaction?: RequiredInteraction;
|
|
57
|
-
}
|
|
58
|
-
export interface ObserveModelRequested {
|
|
59
|
-
/** The exact immutable logical input supplied to the ModelAdapter. */
|
|
60
|
-
readonly call: ModelCall;
|
|
61
|
-
/** Canonical configuration facts and attribution. */
|
|
62
|
-
readonly configuration: ObserveModelConfigurationSnapshot;
|
|
63
|
-
/** Current-step runtime context and attribution. */
|
|
64
|
-
readonly context: ContextSnapshot;
|
|
65
|
-
}
|
|
66
|
-
export type ObserveEvent = {
|
|
67
|
-
readonly type: "session.stopped";
|
|
68
|
-
readonly reason: string;
|
|
69
|
-
} | {
|
|
70
|
-
readonly type: "capability.state.dispose.failed";
|
|
71
|
-
readonly capabilityId: string;
|
|
72
|
-
readonly attributes: {
|
|
73
|
-
readonly message: string;
|
|
74
|
-
};
|
|
75
|
-
} | {
|
|
76
|
-
readonly type: "session.seeded";
|
|
77
|
-
readonly revision: number;
|
|
78
|
-
readonly transcriptEntries: number;
|
|
79
|
-
} | {
|
|
80
|
-
readonly type: "session.continued";
|
|
81
|
-
readonly inputId?: string;
|
|
82
|
-
} | {
|
|
83
|
-
readonly type: "session.record.failed";
|
|
84
|
-
readonly code: string;
|
|
85
|
-
readonly attributes: {
|
|
86
|
-
readonly message: string;
|
|
87
|
-
};
|
|
88
|
-
} | {
|
|
89
|
-
readonly type: "input.received";
|
|
90
|
-
readonly inputId: string;
|
|
91
|
-
readonly kind: string;
|
|
92
|
-
} | {
|
|
93
|
-
readonly type: "input.queued";
|
|
94
|
-
readonly inputId: string;
|
|
95
|
-
} | {
|
|
96
|
-
readonly type: "input.rejected";
|
|
97
|
-
readonly inputId: string;
|
|
98
|
-
readonly reason: string;
|
|
99
|
-
} | {
|
|
100
|
-
readonly type: "input.cancelled";
|
|
101
|
-
readonly inputId: string;
|
|
102
|
-
readonly reason: string;
|
|
103
|
-
} | {
|
|
104
|
-
readonly type: "model.requested";
|
|
105
|
-
readonly turnId: string;
|
|
106
|
-
readonly stepId: string;
|
|
107
|
-
readonly inputId?: string;
|
|
108
|
-
readonly requestedModelId?: string;
|
|
109
|
-
readonly attributes: ObserveModelRequested;
|
|
110
|
-
} | {
|
|
111
|
-
readonly type: "model.prepared";
|
|
112
|
-
readonly turnId: string;
|
|
113
|
-
readonly stepId: string;
|
|
114
|
-
readonly inputId?: string;
|
|
115
|
-
readonly requestedModelId?: string;
|
|
116
|
-
readonly attributes: {
|
|
117
|
-
readonly adapter: string;
|
|
118
|
-
readonly call: JsonValue;
|
|
119
|
-
};
|
|
120
|
-
} | {
|
|
121
|
-
readonly type: "model.completed";
|
|
122
|
-
readonly turnId: string;
|
|
123
|
-
readonly stepId: string;
|
|
124
|
-
readonly inputId?: string;
|
|
125
|
-
readonly requestedModelId?: string;
|
|
126
|
-
readonly attributes: ModelCandidate;
|
|
127
|
-
} | {
|
|
128
|
-
readonly type: "model.deferred";
|
|
129
|
-
readonly turnId: string;
|
|
130
|
-
readonly stepId: string;
|
|
131
|
-
readonly inputId?: string;
|
|
132
|
-
readonly invocationId: string;
|
|
133
|
-
readonly attributes: {
|
|
134
|
-
readonly token?: JsonValue;
|
|
135
|
-
};
|
|
136
|
-
} | {
|
|
137
|
-
readonly type: "step.started";
|
|
138
|
-
readonly turnId: string;
|
|
139
|
-
readonly stepId: string;
|
|
140
|
-
readonly inputId?: string;
|
|
141
|
-
readonly turnNumber: number;
|
|
142
|
-
readonly stepNumber: number;
|
|
143
|
-
readonly attributes: {
|
|
144
|
-
readonly session?: {
|
|
145
|
-
readonly userId?: string;
|
|
146
|
-
readonly context?: JsonObject;
|
|
147
|
-
};
|
|
148
|
-
readonly arrivals: readonly InputEvent[];
|
|
149
|
-
readonly toolResults: readonly ToolResult[];
|
|
150
|
-
readonly transcript: readonly TranscriptEntry[];
|
|
151
|
-
};
|
|
152
|
-
} | {
|
|
153
|
-
readonly type: "middleware.entered" | "middleware.completed";
|
|
154
|
-
readonly turnId: string;
|
|
155
|
-
readonly stepId: string;
|
|
156
|
-
readonly inputId?: string;
|
|
157
|
-
readonly middlewareId: string;
|
|
158
|
-
} | {
|
|
159
|
-
readonly type: "middleware.lease-violation";
|
|
160
|
-
readonly turnId: string;
|
|
161
|
-
readonly stepId: string;
|
|
162
|
-
readonly inputId?: string;
|
|
163
|
-
readonly middlewareId: string;
|
|
164
|
-
readonly reason: string;
|
|
165
|
-
} | {
|
|
166
|
-
readonly type: "tool.sealed";
|
|
167
|
-
readonly turnId: string;
|
|
168
|
-
readonly stepId: string;
|
|
169
|
-
readonly inputId?: string;
|
|
170
|
-
readonly attributes: {
|
|
171
|
-
readonly executable: readonly ObserveSealedCall[];
|
|
172
|
-
readonly immediate: readonly ToolResult[];
|
|
173
|
-
};
|
|
174
|
-
} | {
|
|
175
|
-
readonly type: "tool.started";
|
|
176
|
-
readonly sessionId: string;
|
|
177
|
-
readonly turnId: string;
|
|
178
|
-
readonly stepId: string;
|
|
179
|
-
readonly inputId?: string;
|
|
180
|
-
readonly toolName: string;
|
|
181
|
-
readonly callId: string;
|
|
182
|
-
readonly invocationId: string;
|
|
183
|
-
readonly middlewareId: string;
|
|
184
|
-
readonly slot: string;
|
|
185
|
-
readonly attributes: {
|
|
186
|
-
readonly args: JsonValue;
|
|
187
|
-
};
|
|
188
|
-
} | {
|
|
189
|
-
readonly type: "tool.completed";
|
|
190
|
-
readonly sessionId: string;
|
|
191
|
-
readonly turnId: string;
|
|
192
|
-
readonly stepId: string;
|
|
193
|
-
readonly inputId?: string;
|
|
194
|
-
readonly toolName: string;
|
|
195
|
-
readonly callId: string;
|
|
196
|
-
readonly invocationId: string;
|
|
197
|
-
readonly middlewareId: string;
|
|
198
|
-
readonly slot: string;
|
|
199
|
-
readonly outcome: string;
|
|
200
|
-
readonly code?: string;
|
|
201
|
-
readonly attributes?: ToolResult;
|
|
202
|
-
} | {
|
|
203
|
-
readonly type: "tool.deferred";
|
|
204
|
-
readonly sessionId: string;
|
|
205
|
-
readonly turnId: string;
|
|
206
|
-
readonly stepId: string;
|
|
207
|
-
readonly inputId?: string;
|
|
208
|
-
readonly toolName: string;
|
|
209
|
-
readonly callId: string;
|
|
210
|
-
readonly invocationId: string;
|
|
211
|
-
readonly middlewareId: string;
|
|
212
|
-
readonly slot: string;
|
|
213
|
-
readonly attributes: {
|
|
214
|
-
readonly token?: JsonValue;
|
|
215
|
-
};
|
|
216
|
-
} | {
|
|
217
|
-
readonly type: "turn.completed";
|
|
218
|
-
readonly turnId: string;
|
|
219
|
-
readonly stepId: string;
|
|
220
|
-
readonly inputId?: string;
|
|
221
|
-
readonly attributes: {
|
|
222
|
-
readonly output: JsonValue;
|
|
223
|
-
};
|
|
224
|
-
} | {
|
|
225
|
-
readonly type: "interaction.required";
|
|
226
|
-
readonly turnId: string;
|
|
227
|
-
readonly stepId: string;
|
|
228
|
-
readonly inputId?: string;
|
|
229
|
-
readonly interactionId: string;
|
|
230
|
-
readonly kind: string;
|
|
231
|
-
readonly callId?: string;
|
|
232
|
-
readonly toolName?: string;
|
|
233
|
-
readonly phase?: "interaction" | "execute";
|
|
234
|
-
readonly attributes: {
|
|
235
|
-
readonly prompt: string;
|
|
236
|
-
readonly metadata?: JsonObject;
|
|
237
|
-
};
|
|
238
|
-
} | {
|
|
239
|
-
readonly type: "tripwire";
|
|
240
|
-
readonly turnId: string;
|
|
241
|
-
readonly stepId?: string;
|
|
242
|
-
readonly inputId?: string;
|
|
243
|
-
readonly code: string;
|
|
244
|
-
readonly scope: string;
|
|
245
|
-
readonly attributes: {
|
|
246
|
-
readonly message: string;
|
|
247
|
-
};
|
|
248
|
-
};
|
|
249
|
-
export type Observer = (event: ObserveEvent) => void | Promise<void>;
|
package/dist/types/shared.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/tool.d.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import type { ZodType } from "zod";
|
|
2
|
-
import type { DeferredOutcome, JsonObject, JsonValue } from "./shared.js";
|
|
3
|
-
import type { ModelAdapter } from "./model.js";
|
|
4
|
-
export interface SchemaIssue {
|
|
5
|
-
readonly path: readonly (string | number)[];
|
|
6
|
-
readonly code: string;
|
|
7
|
-
readonly message: string;
|
|
8
|
-
}
|
|
9
|
-
export type SchemaValidation<T> = {
|
|
10
|
-
readonly ok: true;
|
|
11
|
-
readonly value: T;
|
|
12
|
-
} | {
|
|
13
|
-
readonly ok: false;
|
|
14
|
-
readonly issues: readonly SchemaIssue[];
|
|
15
|
-
};
|
|
16
|
-
/** The portable, locally-enforced schema contract accepted by a Harness tool. */
|
|
17
|
-
export interface ToolSchema<T> {
|
|
18
|
-
readonly jsonSchema: JsonObject;
|
|
19
|
-
validate(value: unknown): SchemaValidation<T>;
|
|
20
|
-
}
|
|
21
|
-
/** The synchronous Standard Schema subset required to project and validate a tool contract. */
|
|
22
|
-
export interface StandardToolSchema<Input = unknown, Output = unknown> {
|
|
23
|
-
readonly "~standard": {
|
|
24
|
-
readonly validate: (value: Input) => {
|
|
25
|
-
readonly value: Output;
|
|
26
|
-
readonly issues?: undefined;
|
|
27
|
-
} | {
|
|
28
|
-
readonly issues: readonly StandardSchemaIssue[];
|
|
29
|
-
readonly value?: undefined;
|
|
30
|
-
} | Promise<unknown>;
|
|
31
|
-
readonly jsonSchema: {
|
|
32
|
-
readonly input: () => unknown;
|
|
33
|
-
readonly output: () => unknown;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
export interface StandardSchemaIssue {
|
|
38
|
-
readonly message?: string;
|
|
39
|
-
readonly path?: readonly (string | number | symbol)[];
|
|
40
|
-
readonly code?: string;
|
|
41
|
-
}
|
|
42
|
-
export type ToolSchemaSource<T = unknown> = ZodType<T> | StandardToolSchema<any, T> | ToolSchema<T>;
|
|
43
|
-
export type SchemaOutput<Schema> = Schema extends ZodType<infer Value> ? Value : Schema extends StandardToolSchema<any, infer Value> ? Value : Schema extends ToolSchema<infer Value> ? Value : never;
|
|
44
|
-
export type ToolInputSchema = ToolSchemaSource;
|
|
45
|
-
export type ToolOutputSchema = ToolSchemaSource;
|
|
46
|
-
export interface BoundToolSchema<T> extends ToolSchema<T> {
|
|
47
|
-
}
|
|
48
|
-
type OutputFor<Schema> = Schema extends ToolSchemaSource ? SchemaOutput<Schema> : ToolContent;
|
|
49
|
-
export interface ToolDefinition<InputSchema extends ToolInputSchema = ToolInputSchema, State = never, OutputSchema extends ToolOutputSchema | undefined = undefined> {
|
|
50
|
-
readonly name: string;
|
|
51
|
-
readonly description?: string;
|
|
52
|
-
readonly inputSchema: InputSchema;
|
|
53
|
-
readonly outputSchema?: OutputSchema;
|
|
54
|
-
execute(args: SchemaOutput<InputSchema>, context: ToolExecutionContext<State>): Promise<ToolOutcome<OutputFor<OutputSchema>>>;
|
|
55
|
-
}
|
|
56
|
-
export interface BoundToolDefinition<State = never> extends Omit<ToolDefinition<ToolInputSchema, State, ToolOutputSchema | undefined>, "inputSchema" | "outputSchema" | "execute"> {
|
|
57
|
-
readonly inputSchema: BoundToolSchema<unknown>;
|
|
58
|
-
readonly outputSchema?: BoundToolSchema<unknown>;
|
|
59
|
-
readonly execute: (args: unknown, context: ToolExecutionContext<State>) => Promise<ToolOutcome>;
|
|
60
|
-
readonly owner: ToolOwner;
|
|
61
|
-
}
|
|
62
|
-
export interface ToolOwner {
|
|
63
|
-
readonly middlewareId: string;
|
|
64
|
-
readonly slot: string;
|
|
65
|
-
}
|
|
66
|
-
export interface Interaction {
|
|
67
|
-
readonly id?: string;
|
|
68
|
-
readonly kind: "approval" | "response";
|
|
69
|
-
readonly prompt: string;
|
|
70
|
-
readonly metadata?: JsonObject;
|
|
71
|
-
}
|
|
72
|
-
export interface RequiredInteraction extends Interaction {
|
|
73
|
-
readonly id: string;
|
|
74
|
-
}
|
|
75
|
-
export interface ToolExecutionResume {
|
|
76
|
-
readonly interactionId: string;
|
|
77
|
-
readonly kind: "approval" | "response";
|
|
78
|
-
readonly approved?: boolean;
|
|
79
|
-
readonly value?: JsonValue;
|
|
80
|
-
readonly token?: JsonValue;
|
|
81
|
-
}
|
|
82
|
-
export interface SealedToolCall {
|
|
83
|
-
readonly callId: string;
|
|
84
|
-
readonly toolName: string;
|
|
85
|
-
readonly args: JsonValue;
|
|
86
|
-
}
|
|
87
|
-
interface ToolExecutionContextBase {
|
|
88
|
-
readonly sessionId: string;
|
|
89
|
-
readonly turnId: string;
|
|
90
|
-
readonly stepId: string;
|
|
91
|
-
readonly callId: string;
|
|
92
|
-
readonly invocationId: string;
|
|
93
|
-
readonly signal: AbortSignal;
|
|
94
|
-
/** The session's model callable, for tools that explicitly run a child agent. */
|
|
95
|
-
readonly onModelCall?: ModelAdapter;
|
|
96
|
-
readonly resume?: ToolExecutionResume;
|
|
97
|
-
}
|
|
98
|
-
export type ToolExecutionContext<State = never> = ToolExecutionContextBase & ([State] extends [never] ? object : {
|
|
99
|
-
readonly state: Promise<State>;
|
|
100
|
-
});
|
|
101
|
-
export type ToolContent = JsonValue;
|
|
102
|
-
export type ToolOutcome<Output = ToolContent> = {
|
|
103
|
-
readonly kind: "completed";
|
|
104
|
-
readonly output: Output;
|
|
105
|
-
} | {
|
|
106
|
-
readonly kind: "denied";
|
|
107
|
-
readonly reason: string;
|
|
108
|
-
} | {
|
|
109
|
-
readonly kind: "failed";
|
|
110
|
-
readonly code: string;
|
|
111
|
-
readonly message: string;
|
|
112
|
-
} | {
|
|
113
|
-
readonly kind: "interaction-required";
|
|
114
|
-
readonly interaction: Interaction;
|
|
115
|
-
readonly token?: JsonValue;
|
|
116
|
-
} | DeferredOutcome;
|
|
117
|
-
export interface ToolValidationFailureDetails {
|
|
118
|
-
readonly phase: "input" | "output";
|
|
119
|
-
readonly issues: readonly SchemaIssue[];
|
|
120
|
-
}
|
|
121
|
-
export type ToolResult = {
|
|
122
|
-
readonly callId: string;
|
|
123
|
-
readonly toolName: string;
|
|
124
|
-
readonly kind: "completed";
|
|
125
|
-
readonly output: ToolContent;
|
|
126
|
-
} | {
|
|
127
|
-
readonly callId: string;
|
|
128
|
-
readonly toolName: string;
|
|
129
|
-
readonly kind: "denied";
|
|
130
|
-
readonly reason: string;
|
|
131
|
-
} | {
|
|
132
|
-
readonly callId: string;
|
|
133
|
-
readonly toolName: string;
|
|
134
|
-
readonly kind: "failed";
|
|
135
|
-
readonly code: string;
|
|
136
|
-
readonly message: string;
|
|
137
|
-
readonly details?: ToolValidationFailureDetails;
|
|
138
|
-
};
|
|
139
|
-
export {};
|
package/dist/types/tool.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { JsonObject, JsonValue } from "../types/shared.js";
|
|
2
|
-
export declare function assertJson(value: unknown, path?: string): asserts value is JsonValue;
|
|
3
|
-
export declare function copyJson<T>(value: T): T;
|
|
4
|
-
export declare function copyJsonObject(value: unknown, path: string): JsonObject;
|
|
5
|
-
export declare function deepFreeze<T>(value: T): T;
|
package/dist/utils/immutable.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { HarnessError } from "../errors.js";
|
|
2
|
-
export function assertJson(value, path = "value") {
|
|
3
|
-
assertJsonValue(value, path, new WeakSet());
|
|
4
|
-
}
|
|
5
|
-
function assertJsonValue(value, path, ancestors) {
|
|
6
|
-
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
7
|
-
return;
|
|
8
|
-
if (typeof value === "number" && Number.isFinite(value))
|
|
9
|
-
return;
|
|
10
|
-
if (Array.isArray(value)) {
|
|
11
|
-
enterJsonContainer(value, path, ancestors);
|
|
12
|
-
value.forEach((item, index) => assertJsonValue(item, `${path}[${index}]`, ancestors));
|
|
13
|
-
ancestors.delete(value);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (typeof value === "object") {
|
|
17
|
-
const prototype = Object.getPrototypeOf(value);
|
|
18
|
-
if (prototype !== Object.prototype && prototype !== null)
|
|
19
|
-
throw new HarnessError("json.invalid-data", `${path} must be plain JSON data`, {
|
|
20
|
-
details: { path },
|
|
21
|
-
});
|
|
22
|
-
enterJsonContainer(value, path, ancestors);
|
|
23
|
-
for (const [key, item] of Object.entries(value)) {
|
|
24
|
-
if (item === undefined)
|
|
25
|
-
throw new HarnessError("json.invalid-data", `${path}.${key} cannot be undefined`, {
|
|
26
|
-
details: { path: `${path}.${key}` },
|
|
27
|
-
});
|
|
28
|
-
assertJsonValue(item, `${path}.${key}`, ancestors);
|
|
29
|
-
}
|
|
30
|
-
ancestors.delete(value);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
throw new HarnessError("json.invalid-data", `${path} must be JSON-serializable`, {
|
|
34
|
-
details: { path },
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function enterJsonContainer(value, path, ancestors) {
|
|
38
|
-
if (ancestors.has(value))
|
|
39
|
-
throw new HarnessError("json.invalid-data", `${path} cannot contain a cycle`, {
|
|
40
|
-
details: { path },
|
|
41
|
-
});
|
|
42
|
-
ancestors.add(value);
|
|
43
|
-
}
|
|
44
|
-
export function copyJson(value) {
|
|
45
|
-
assertJson(value);
|
|
46
|
-
if (Array.isArray(value))
|
|
47
|
-
return Object.freeze(value.map((item) => copyJson(item)));
|
|
48
|
-
if (value !== null && typeof value === "object") {
|
|
49
|
-
return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, copyJson(item)])));
|
|
50
|
-
}
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
export function copyJsonObject(value, path) {
|
|
54
|
-
assertJson(value, path);
|
|
55
|
-
if (value === null || Array.isArray(value) || typeof value !== "object")
|
|
56
|
-
throw new HarnessError("json.invalid-object", `${path} must be a JSON object`, {
|
|
57
|
-
details: { path },
|
|
58
|
-
});
|
|
59
|
-
return copyJson(value);
|
|
60
|
-
}
|
|
61
|
-
export function deepFreeze(value) {
|
|
62
|
-
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
63
|
-
Object.freeze(value);
|
|
64
|
-
for (const item of Object.values(value))
|
|
65
|
-
deepFreeze(item);
|
|
66
|
-
}
|
|
67
|
-
return value;
|
|
68
|
-
}
|
package/dist/utils/maps.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function createFixedMap<K, V>(values: Iterable<readonly [K, V]>): ReadonlyMap<K, V>;
|
package/dist/utils/maps.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
class FixedReadonlyMap {
|
|
2
|
-
#values;
|
|
3
|
-
constructor(values) {
|
|
4
|
-
this.#values = new Map(values);
|
|
5
|
-
Object.freeze(this);
|
|
6
|
-
}
|
|
7
|
-
get size() {
|
|
8
|
-
return this.#values.size;
|
|
9
|
-
}
|
|
10
|
-
get(key) {
|
|
11
|
-
return this.#values.get(key);
|
|
12
|
-
}
|
|
13
|
-
has(key) {
|
|
14
|
-
return this.#values.has(key);
|
|
15
|
-
}
|
|
16
|
-
entries() {
|
|
17
|
-
return this.#values.entries();
|
|
18
|
-
}
|
|
19
|
-
keys() {
|
|
20
|
-
return this.#values.keys();
|
|
21
|
-
}
|
|
22
|
-
values() {
|
|
23
|
-
return this.#values.values();
|
|
24
|
-
}
|
|
25
|
-
forEach(callbackfn, thisArg) {
|
|
26
|
-
this.#values.forEach((value, key) => callbackfn.call(thisArg, value, key, this));
|
|
27
|
-
}
|
|
28
|
-
[Symbol.iterator]() {
|
|
29
|
-
return this.#values[Symbol.iterator]();
|
|
30
|
-
}
|
|
31
|
-
get [Symbol.toStringTag]() {
|
|
32
|
-
return "FixedReadonlyMap";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export function createFixedMap(values) {
|
|
36
|
-
return new FixedReadonlyMap(values);
|
|
37
|
-
}
|
package/dist/utils/observe.d.ts
DELETED
package/dist/utils/observe.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function emitObserve(listener, event) {
|
|
2
|
-
if (!listener)
|
|
3
|
-
return;
|
|
4
|
-
const snapshot = Object.freeze({ ...(typeof event === "function" ? event() : event) });
|
|
5
|
-
try {
|
|
6
|
-
const result = listener(snapshot);
|
|
7
|
-
if (result && typeof result.then === "function")
|
|
8
|
-
void Promise.resolve(result).catch(() => undefined);
|
|
9
|
-
}
|
|
10
|
-
catch {
|
|
11
|
-
// Observation is deliberately fail-open.
|
|
12
|
-
}
|
|
13
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|