@nylorun/harness 0.13.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 +48 -0
- package/HOST_CONTRACT.md +27 -0
- package/README.md +62 -100
- package/dist/compatibility.d.ts +3 -0
- package/dist/compatibility.js +3 -0
- package/dist/definition/agent-definition.d.ts +11 -3
- package/dist/definition/agent-definition.js +18 -10
- package/dist/definition/compatibility.d.ts +11 -0
- package/dist/definition/compatibility.js +30 -0
- package/dist/definition/registry.d.ts +2 -2
- package/dist/definition/registry.js +7 -6
- package/dist/index.d.ts +4 -18
- package/dist/index.js +1 -6
- 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/{execution → loop}/invocation.d.ts +5 -2
- package/dist/{execution → loop}/invocation.js +8 -3
- package/dist/{execution → loop}/model/adapters.d.ts +4 -2
- package/dist/{execution → loop}/model/adapters.js +3 -2
- package/dist/{execution → loop}/model/normalize.d.ts +2 -2
- package/dist/{execution → loop}/model/normalize.js +2 -2
- package/dist/{execution → loop}/model/prepared.d.ts +2 -2
- package/dist/{execution → loop}/model/project.d.ts +1 -1
- package/dist/{execution → loop}/model/project.js +1 -1
- package/dist/{execution → loop}/observe.d.ts +2 -2
- package/dist/{execution → loop}/observe.js +1 -1
- package/dist/{execution → loop}/options.d.ts +2 -1
- package/dist/{execution → loop}/options.js +28 -8
- package/dist/{execution → loop}/resume.d.ts +1 -1
- package/dist/{execution → loop}/resume.js +2 -2
- package/dist/{execution → loop}/run.d.ts +1 -1
- package/dist/{execution → loop}/run.js +9 -1
- package/dist/{execution → loop}/state.d.ts +2 -2
- package/dist/{execution → loop}/state.js +13 -3
- package/dist/{execution → loop}/step/canonicalize.d.ts +2 -2
- package/dist/{execution → loop}/step/canonicalize.js +1 -1
- package/dist/{execution → loop}/step/compose.d.ts +2 -2
- package/dist/{execution → loop}/step/compose.js +4 -1
- package/dist/{execution → loop}/step/context-draft.d.ts +2 -2
- package/dist/{execution → loop}/step/context-draft.js +2 -2
- package/dist/{execution → loop}/step/describe.d.ts +3 -3
- package/dist/{execution → loop}/step/describe.js +1 -1
- package/dist/loop/step/dynamics.d.ts +29 -0
- package/dist/loop/step/dynamics.js +147 -0
- package/dist/{execution → loop}/step/model-configuration.d.ts +2 -2
- package/dist/{execution → loop}/step/model-configuration.js +3 -3
- package/dist/{execution → loop}/step/resolve.d.ts +4 -4
- package/dist/{execution → loop}/step/run.d.ts +5 -4
- package/dist/{execution → loop}/step/run.js +87 -2
- package/dist/{execution → loop}/step/runtime.d.ts +12 -4
- package/dist/{execution → loop}/step/seal.d.ts +5 -5
- package/dist/{execution → loop}/step/seal.js +2 -2
- package/dist/{execution → loop}/step/slot-assembly.d.ts +1 -1
- package/dist/{execution → loop}/step/slot-assembly.js +1 -1
- package/dist/{execution → loop}/step/step-context.d.ts +5 -5
- package/dist/{execution → loop}/step/step-context.js +2 -2
- package/dist/{execution → loop}/tool-result.d.ts +2 -2
- package/dist/{execution → loop}/tool-result.js +2 -2
- package/dist/{execution → loop}/transcript.d.ts +1 -1
- package/dist/{execution → loop}/transcript.js +2 -2
- 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 +22 -5
- package/dist/utils/ids.d.ts +1 -0
- package/dist/utils/ids.js +11 -1
- package/package.json +18 -6
- package/dist/definition/assemble.d.ts +0 -22
- package/dist/definition/assemble.js +0 -43
- package/dist/definition/bind-agent.d.ts +0 -9
- package/dist/definition/bind-agent.js +0 -21
- package/dist/definition/bind-tool.d.ts +0 -4
- package/dist/definition/bind-tool.js +0 -19
- package/dist/definition/bound.d.ts +0 -16
- package/dist/definition/builder.d.ts +0 -30
- package/dist/definition/builder.js +0 -94
- package/dist/definition/declaration.d.ts +0 -3
- package/dist/definition/declaration.js +0 -53
- package/dist/definition/helpers.d.ts +0 -6
- package/dist/definition/helpers.js +0 -4
- package/dist/definition/manifest.d.ts +0 -9
- package/dist/definition/manifest.js +0 -45
- package/dist/definition/output-contract.d.ts +0 -6
- package/dist/definition/output-contract.js +0 -12
- package/dist/definition/schema.d.ts +0 -14
- package/dist/definition/schema.js +0 -205
- package/dist/errors.d.ts +0 -17
- package/dist/errors.js +0 -17
- package/dist/execution/dispatch.js +0 -164
- package/dist/execution/initial-state.d.ts +0 -3
- package/dist/execution/initial-state.js +0 -14
- package/dist/types/agent.d.ts +0 -9
- package/dist/types/agent.js +0 -1
- package/dist/types/manifest.d.ts +0 -22
- package/dist/types/manifest.js +0 -1
- package/dist/types/middleware.d.ts +0 -66
- package/dist/types/middleware.js +0 -1
- package/dist/types/model.d.ts +0 -184
- package/dist/types/model.js +0 -1
- package/dist/types/observe.d.ts +0 -165
- package/dist/types/observe.js +0 -1
- package/dist/types/shared.d.ts +0 -25
- package/dist/types/shared.js +0 -1
- package/dist/types/tool.d.ts +0 -138
- package/dist/types/tool.js +0 -1
- package/dist/types/transcript.d.ts +0 -65
- package/dist/types/transcript.js +0 -1
- package/dist/utils/canonical.d.ts +0 -1
- package/dist/utils/canonical.js +0 -10
- package/dist/utils/immutable.d.ts +0 -6
- package/dist/utils/immutable.js +0 -76
- /package/dist/{execution → loop}/dispatch.d.ts +0 -0
- /package/dist/{execution → loop}/model/prepared.js +0 -0
- /package/dist/{execution → loop}/step/resolve.js +0 -0
- /package/dist/{execution → loop}/step/runtime.js +0 -0
- /package/dist/{definition/bound.js → types/client.js} +0 -0
package/dist/types/tool.d.ts
DELETED
|
@@ -1,138 +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
|
-
type OutputFor<Schema> = Schema extends ToolSchemaSource ? SchemaOutput<Schema> : ToolContent;
|
|
47
|
-
export interface ToolDefinition<InputSchema extends ToolInputSchema = ToolInputSchema, Info = unknown, OutputSchema extends ToolOutputSchema | undefined = undefined> {
|
|
48
|
-
readonly name: string;
|
|
49
|
-
readonly description?: string;
|
|
50
|
-
readonly inputSchema: InputSchema;
|
|
51
|
-
readonly outputSchema?: OutputSchema;
|
|
52
|
-
execute(args: SchemaOutput<InputSchema>, context: ToolExecutionContext<Info>): Promise<ToolOutcome<OutputFor<OutputSchema>>>;
|
|
53
|
-
}
|
|
54
|
-
export interface ToolOwner {
|
|
55
|
-
readonly middlewareId: string;
|
|
56
|
-
readonly slot: string;
|
|
57
|
-
}
|
|
58
|
-
export interface Interaction {
|
|
59
|
-
readonly id?: string;
|
|
60
|
-
readonly kind: "approval" | "response";
|
|
61
|
-
readonly prompt: string;
|
|
62
|
-
readonly metadata?: JsonObject;
|
|
63
|
-
}
|
|
64
|
-
export interface RequiredInteraction extends Interaction {
|
|
65
|
-
readonly id: string;
|
|
66
|
-
}
|
|
67
|
-
export interface ToolExecutionResume {
|
|
68
|
-
readonly interactionId: string;
|
|
69
|
-
readonly kind: "approval" | "response";
|
|
70
|
-
readonly approved?: boolean;
|
|
71
|
-
readonly value?: JsonValue;
|
|
72
|
-
readonly token?: JsonValue;
|
|
73
|
-
}
|
|
74
|
-
interface ToolExecutionContextBase {
|
|
75
|
-
readonly executionId: string;
|
|
76
|
-
readonly turnId: string;
|
|
77
|
-
readonly stepId: string;
|
|
78
|
-
readonly callId: string;
|
|
79
|
-
readonly invocationId: string;
|
|
80
|
-
readonly signal: AbortSignal;
|
|
81
|
-
/** The invocation's model callable, for tools that explicitly run a child agent. */
|
|
82
|
-
readonly onModelCall?: ModelAdapter;
|
|
83
|
-
readonly resume?: ToolExecutionResume;
|
|
84
|
-
}
|
|
85
|
-
export type ToolExecutionContext<Info = unknown> = ToolExecutionContextBase & {
|
|
86
|
-
readonly info?: Info;
|
|
87
|
-
};
|
|
88
|
-
export type ToolContent = JsonValue;
|
|
89
|
-
export type ToolOutcome<Output = ToolContent> = {
|
|
90
|
-
readonly kind: "completed";
|
|
91
|
-
readonly output: Output;
|
|
92
|
-
} | {
|
|
93
|
-
readonly kind: "denied";
|
|
94
|
-
readonly reason: string;
|
|
95
|
-
} | {
|
|
96
|
-
readonly kind: "failed";
|
|
97
|
-
readonly code: string;
|
|
98
|
-
readonly message: string;
|
|
99
|
-
} | {
|
|
100
|
-
readonly kind: "interaction-required";
|
|
101
|
-
readonly interaction: Interaction;
|
|
102
|
-
readonly token?: JsonValue;
|
|
103
|
-
} | DeferredOutcome;
|
|
104
|
-
export interface ToolValidationFailureDetails {
|
|
105
|
-
readonly phase: "input" | "output";
|
|
106
|
-
readonly issues: readonly SchemaIssue[];
|
|
107
|
-
}
|
|
108
|
-
export type ToolResult = {
|
|
109
|
-
readonly callId: string;
|
|
110
|
-
readonly toolName: string;
|
|
111
|
-
readonly kind: "completed";
|
|
112
|
-
readonly output: ToolContent;
|
|
113
|
-
} | {
|
|
114
|
-
readonly callId: string;
|
|
115
|
-
readonly toolName: string;
|
|
116
|
-
readonly kind: "denied";
|
|
117
|
-
readonly reason: string;
|
|
118
|
-
} | {
|
|
119
|
-
readonly callId: string;
|
|
120
|
-
readonly toolName: string;
|
|
121
|
-
readonly kind: "failed";
|
|
122
|
-
readonly code: string;
|
|
123
|
-
readonly message: string;
|
|
124
|
-
readonly details?: ToolValidationFailureDetails;
|
|
125
|
-
};
|
|
126
|
-
/** Immutable tool metadata supplied to model adapters and observers. */
|
|
127
|
-
export interface ToolDescriptor {
|
|
128
|
-
readonly name: string;
|
|
129
|
-
readonly description?: string;
|
|
130
|
-
readonly owner: ToolOwner;
|
|
131
|
-
readonly inputSchema: {
|
|
132
|
-
readonly jsonSchema: JsonObject;
|
|
133
|
-
};
|
|
134
|
-
readonly outputSchema?: {
|
|
135
|
-
readonly jsonSchema: JsonObject;
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
export {};
|
package/dist/types/tool.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { ModelCandidate } from "./model.js";
|
|
2
|
-
import type { JsonObject, JsonValue } from "./shared.js";
|
|
3
|
-
import type { ToolResult } from "./tool.js";
|
|
4
|
-
export type InputEvent = {
|
|
5
|
-
readonly kind: "user-message" | "interrupt";
|
|
6
|
-
readonly text: string;
|
|
7
|
-
readonly metadata?: JsonObject;
|
|
8
|
-
} | {
|
|
9
|
-
readonly kind: "user-message" | "interrupt";
|
|
10
|
-
readonly content: readonly UserContentPart[];
|
|
11
|
-
/** Undefined for content-bearing events; retained for text-event narrowing compatibility. */
|
|
12
|
-
readonly text?: undefined;
|
|
13
|
-
readonly metadata?: JsonObject;
|
|
14
|
-
} | {
|
|
15
|
-
readonly kind: "approve";
|
|
16
|
-
readonly interactionId: string;
|
|
17
|
-
readonly approved: boolean;
|
|
18
|
-
} | {
|
|
19
|
-
readonly kind: "respond";
|
|
20
|
-
readonly interactionId: string;
|
|
21
|
-
readonly value: JsonValue;
|
|
22
|
-
};
|
|
23
|
-
/** Ordered, model-visible user content. Media references stay host-owned JSON values. */
|
|
24
|
-
export type UserContentPart = {
|
|
25
|
-
readonly type: "text";
|
|
26
|
-
readonly text: string;
|
|
27
|
-
} | {
|
|
28
|
-
readonly type: "media";
|
|
29
|
-
readonly mediaType: string;
|
|
30
|
-
readonly reference: JsonValue;
|
|
31
|
-
};
|
|
32
|
-
export type MessageInput = string | {
|
|
33
|
-
readonly text: string;
|
|
34
|
-
readonly metadata?: JsonObject;
|
|
35
|
-
} | {
|
|
36
|
-
readonly content: readonly UserContentPart[];
|
|
37
|
-
readonly metadata?: JsonObject;
|
|
38
|
-
};
|
|
39
|
-
export type InteractionReply = Extract<InputEvent, {
|
|
40
|
-
kind: "approve" | "respond";
|
|
41
|
-
}>;
|
|
42
|
-
export interface TranscriptInputEntry {
|
|
43
|
-
readonly kind: "input";
|
|
44
|
-
readonly turnId: string;
|
|
45
|
-
readonly event: InputEvent;
|
|
46
|
-
}
|
|
47
|
-
export interface TranscriptCandidateEntry {
|
|
48
|
-
readonly kind: "candidate";
|
|
49
|
-
readonly turnId: string;
|
|
50
|
-
readonly stepId: string;
|
|
51
|
-
readonly candidate: ModelCandidate;
|
|
52
|
-
}
|
|
53
|
-
export interface TranscriptToolsEntry {
|
|
54
|
-
readonly kind: "tool-results";
|
|
55
|
-
readonly turnId: string;
|
|
56
|
-
readonly stepId: string;
|
|
57
|
-
readonly results: readonly ToolResult[];
|
|
58
|
-
}
|
|
59
|
-
export interface TranscriptFinalEntry {
|
|
60
|
-
readonly kind: "final";
|
|
61
|
-
readonly turnId: string;
|
|
62
|
-
readonly stepId: string;
|
|
63
|
-
readonly output: JsonValue;
|
|
64
|
-
}
|
|
65
|
-
export type TranscriptEntry = TranscriptInputEntry | TranscriptCandidateEntry | TranscriptToolsEntry | TranscriptFinalEntry;
|
package/dist/types/transcript.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function canonical(value: unknown): string;
|
package/dist/utils/canonical.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export function canonical(value) {
|
|
2
|
-
if (Array.isArray(value))
|
|
3
|
-
return `[${value.map(canonical).join(",")}]`;
|
|
4
|
-
if (value && typeof value === "object")
|
|
5
|
-
return `{${Object.entries(value)
|
|
6
|
-
.sort(([a], [b]) => a.localeCompare(b))
|
|
7
|
-
.map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`)
|
|
8
|
-
.join(",")}}`;
|
|
9
|
-
return JSON.stringify(value);
|
|
10
|
-
}
|
|
@@ -1,6 +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;
|
|
6
|
-
export declare function freezeGraph<T>(value: T, seen?: WeakSet<object>): T;
|
package/dist/utils/immutable.js
DELETED
|
@@ -1,76 +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
|
-
}
|
|
69
|
-
export function freezeGraph(value, seen = new WeakSet()) {
|
|
70
|
-
if (!value || typeof value !== "object" || seen.has(value))
|
|
71
|
-
return value;
|
|
72
|
-
seen.add(value);
|
|
73
|
-
for (const item of Object.values(value))
|
|
74
|
-
freezeGraph(item, seen);
|
|
75
|
-
return Object.freeze(value);
|
|
76
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|