@nylorun/harness 0.8.0-beta.1 → 0.11.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 +64 -0
- package/README.md +5 -38
- package/dist/build/assemble.js +1 -0
- package/dist/build/bind-tool.js +4 -3
- package/dist/build/builder.js +26 -0
- package/dist/build/helpers.d.ts +2 -2
- package/dist/build/manifest.js +12 -1
- package/dist/build/schema.d.ts +11 -16
- package/dist/build/schema.js +141 -22
- package/dist/errors.d.ts +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.js +2 -0
- package/dist/model/adapters.d.ts +160 -0
- package/dist/model/adapters.js +545 -0
- package/dist/{model-normalize.d.ts → model/normalize.d.ts} +2 -2
- package/dist/{model-normalize.js → model/normalize.js} +35 -4
- package/dist/model/prepared.d.ts +16 -0
- package/dist/model/prepared.js +11 -0
- package/dist/session/event-log.d.ts +4 -3
- package/dist/session/input-queue.d.ts +7 -4
- package/dist/session/input-queue.js +12 -0
- package/dist/session/output-contract.d.ts +6 -0
- package/dist/session/output-contract.js +12 -0
- package/dist/session/scheduler.js +1 -1
- package/dist/session/seed.js +79 -5
- package/dist/session/session.d.ts +8 -5
- package/dist/session/session.js +38 -2
- package/dist/session/state.d.ts +1 -1
- package/dist/session/submission-stream.d.ts +5 -4
- package/dist/step/context-draft.js +1 -7
- package/dist/step/model-configuration.js +6 -20
- package/dist/step/project.js +25 -3
- package/dist/step/resolve.d.ts +1 -0
- package/dist/step/resolve.js +1 -0
- package/dist/step/run.d.ts +1 -0
- package/dist/step/run.js +25 -4
- package/dist/step/seal.d.ts +4 -2
- package/dist/step/seal.js +64 -13
- package/dist/step/step-context.js +1 -1
- package/dist/turn/plan-runner.js +38 -3
- package/dist/turn/runner.d.ts +6 -4
- package/dist/turn/runner.js +6 -4
- package/dist/types/manifest.d.ts +5 -4
- package/dist/types/middleware.d.ts +10 -1
- package/dist/types/model.d.ts +21 -13
- package/dist/types/session.d.ts +34 -13
- package/dist/types/shared.d.ts +16 -3
- package/dist/types/tool.d.ts +54 -17
- package/package.json +15 -12
- package/dist/utils/digest.d.ts +0 -1
- package/dist/utils/digest.js +0 -14
package/dist/types/tool.d.ts
CHANGED
|
@@ -1,29 +1,61 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ZodType } from "zod";
|
|
2
2
|
import type { DeferredOutcome, JsonObject, JsonValue } from "./shared.js";
|
|
3
|
-
|
|
3
|
+
export interface SchemaIssue {
|
|
4
|
+
readonly path: readonly (string | number)[];
|
|
5
|
+
readonly code: string;
|
|
6
|
+
readonly message: string;
|
|
7
|
+
}
|
|
8
|
+
export type SchemaValidation<T> = {
|
|
4
9
|
readonly ok: true;
|
|
5
10
|
readonly value: T;
|
|
6
|
-
}
|
|
7
|
-
type SchemaValidationFailure = {
|
|
11
|
+
} | {
|
|
8
12
|
readonly ok: false;
|
|
9
|
-
readonly issues: readonly
|
|
13
|
+
readonly issues: readonly SchemaIssue[];
|
|
10
14
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export type ToolObjectSchema = ZodObject;
|
|
14
|
-
export interface BoundToolSchema<T> {
|
|
15
|
+
/** The portable, locally-enforced schema contract accepted by a Harness tool. */
|
|
16
|
+
export interface ToolSchema<T> {
|
|
15
17
|
readonly jsonSchema: JsonObject;
|
|
16
18
|
validate(value: unknown): SchemaValidation<T>;
|
|
17
19
|
}
|
|
18
|
-
|
|
20
|
+
/** The synchronous Standard Schema subset required to project and validate a tool contract. */
|
|
21
|
+
export interface StandardToolSchema<Input = unknown, Output = unknown> {
|
|
22
|
+
readonly "~standard": {
|
|
23
|
+
readonly validate: (value: Input) => {
|
|
24
|
+
readonly value: Output;
|
|
25
|
+
readonly issues?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
readonly issues: readonly StandardSchemaIssue[];
|
|
28
|
+
readonly value?: undefined;
|
|
29
|
+
} | Promise<unknown>;
|
|
30
|
+
readonly jsonSchema: {
|
|
31
|
+
readonly input: () => unknown;
|
|
32
|
+
readonly output: () => unknown;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface StandardSchemaIssue {
|
|
37
|
+
readonly message?: string;
|
|
38
|
+
readonly path?: readonly (string | number | symbol)[];
|
|
39
|
+
readonly code?: string;
|
|
40
|
+
}
|
|
41
|
+
export type ToolSchemaSource<T = unknown> = ZodType<T> | StandardToolSchema<any, T> | ToolSchema<T>;
|
|
42
|
+
export type SchemaOutput<Schema> = Schema extends ZodType<infer Value> ? Value : Schema extends StandardToolSchema<any, infer Value> ? Value : Schema extends ToolSchema<infer Value> ? Value : never;
|
|
43
|
+
export type ToolInputSchema = ToolSchemaSource;
|
|
44
|
+
export type ToolOutputSchema = ToolSchemaSource;
|
|
45
|
+
export interface BoundToolSchema<T> extends ToolSchema<T> {
|
|
46
|
+
}
|
|
47
|
+
type OutputFor<Schema> = Schema extends ToolSchemaSource ? SchemaOutput<Schema> : ToolContent;
|
|
48
|
+
export interface ToolDefinition<InputSchema extends ToolInputSchema = ToolInputSchema, State = never, OutputSchema extends ToolOutputSchema | undefined = undefined> {
|
|
19
49
|
readonly name: string;
|
|
20
50
|
readonly description?: string;
|
|
21
|
-
readonly
|
|
22
|
-
|
|
51
|
+
readonly inputSchema: InputSchema;
|
|
52
|
+
readonly outputSchema?: OutputSchema;
|
|
53
|
+
execute(args: SchemaOutput<InputSchema>, context: ToolExecutionContext<State>): Promise<ToolOutcome<OutputFor<OutputSchema>>>;
|
|
23
54
|
}
|
|
24
|
-
export interface BoundToolDefinition<
|
|
25
|
-
readonly
|
|
26
|
-
readonly
|
|
55
|
+
export interface BoundToolDefinition<State = never> extends Omit<ToolDefinition<ToolInputSchema, State, ToolOutputSchema | undefined>, "inputSchema" | "outputSchema" | "execute"> {
|
|
56
|
+
readonly inputSchema: BoundToolSchema<unknown>;
|
|
57
|
+
readonly outputSchema?: BoundToolSchema<unknown>;
|
|
58
|
+
readonly execute: (args: unknown, context: ToolExecutionContext<State>) => Promise<ToolOutcome>;
|
|
27
59
|
readonly owner: ToolOwner;
|
|
28
60
|
}
|
|
29
61
|
export interface ToolOwner {
|
|
@@ -64,9 +96,9 @@ export type ToolExecutionContext<State = never> = ToolExecutionContextBase & ([S
|
|
|
64
96
|
readonly state: Promise<State>;
|
|
65
97
|
});
|
|
66
98
|
export type ToolContent = JsonValue;
|
|
67
|
-
export type ToolOutcome = {
|
|
99
|
+
export type ToolOutcome<Output = ToolContent> = {
|
|
68
100
|
readonly kind: "completed";
|
|
69
|
-
readonly output:
|
|
101
|
+
readonly output: Output;
|
|
70
102
|
} | {
|
|
71
103
|
readonly kind: "denied";
|
|
72
104
|
readonly reason: string;
|
|
@@ -79,6 +111,10 @@ export type ToolOutcome = {
|
|
|
79
111
|
readonly interaction: Interaction;
|
|
80
112
|
readonly token?: JsonValue;
|
|
81
113
|
} | DeferredOutcome;
|
|
114
|
+
export interface ToolValidationFailureDetails {
|
|
115
|
+
readonly phase: "input" | "output";
|
|
116
|
+
readonly issues: readonly SchemaIssue[];
|
|
117
|
+
}
|
|
82
118
|
export type ToolResult = {
|
|
83
119
|
readonly callId: string;
|
|
84
120
|
readonly toolName: string;
|
|
@@ -95,5 +131,6 @@ export type ToolResult = {
|
|
|
95
131
|
readonly kind: "failed";
|
|
96
132
|
readonly code: string;
|
|
97
133
|
readonly message: string;
|
|
134
|
+
readonly details?: ToolValidationFailureDetails;
|
|
98
135
|
};
|
|
99
136
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nylorun/harness",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.11.0-beta",
|
|
4
|
+
"description": "Nylorun's TypeScript agent runtime. See github.com/nylorun/harness.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/nylorun/harness.git",
|
|
10
10
|
"directory": "harness"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://github.com/nylorun/harness
|
|
12
|
+
"homepage": "https://github.com/nylorun/harness",
|
|
13
13
|
"bugs": "https://github.com/nylorun/harness/issues",
|
|
14
14
|
"author": "Nylo",
|
|
15
15
|
"keywords": [
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
".": {
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"import": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./model/adapters": {
|
|
32
|
+
"types": "./dist/model/adapters.d.ts",
|
|
33
|
+
"import": "./dist/model/adapters.js"
|
|
30
34
|
}
|
|
31
35
|
},
|
|
32
36
|
"files": [
|
|
@@ -44,26 +48,25 @@
|
|
|
44
48
|
"node": "^22.14.0 || ^24.0.0 || >=26.0.0"
|
|
45
49
|
},
|
|
46
50
|
"scripts": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
51
|
+
"build": "npm run clean && node ../scripts/check-typescript-version.mjs && tsc -p tsconfig.json",
|
|
52
|
+
"check": "npm run format:check && npm run build && npm run test:types && npm test && node scripts/check-package.mjs",
|
|
53
|
+
"typecheck": "node ../scripts/check-typescript-version.mjs && tsc -p tsconfig.json --noEmit",
|
|
49
54
|
"test": "vitest run",
|
|
55
|
+
"test:types": "tsc -p test/types/tsconfig.json",
|
|
50
56
|
"format": "prettier --write .",
|
|
51
57
|
"format:check": "prettier --check .",
|
|
52
|
-
"
|
|
53
|
-
"check": "npm run format:check && npm run build && npm run test:types && npm test && node scripts/check-package.mjs",
|
|
58
|
+
"clean": "node -e \"import('node:fs').then(({rmSync})=>rmSync('dist',{recursive:true,force:true}))\"",
|
|
54
59
|
"prepack": "npm run build"
|
|
55
60
|
},
|
|
56
61
|
"devDependencies": {
|
|
57
62
|
"@types/node": "^22.18.0",
|
|
63
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
58
64
|
"prettier": "^3.9.6",
|
|
59
|
-
"typescript": "
|
|
60
|
-
"vitest": "^
|
|
65
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
66
|
+
"vitest": "^4.1.11",
|
|
61
67
|
"zod": "^4.1.12"
|
|
62
68
|
},
|
|
63
69
|
"peerDependencies": {
|
|
64
70
|
"zod": "^4.1.12"
|
|
65
|
-
},
|
|
66
|
-
"dependencies": {
|
|
67
|
-
"@noble/hashes": "^2.3.0"
|
|
68
71
|
}
|
|
69
72
|
}
|
package/dist/utils/digest.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const digest: (value: unknown) => string;
|
package/dist/utils/digest.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { sha256 } from "@noble/hashes/sha2.js";
|
|
2
|
-
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
3
|
-
function canonical(value) {
|
|
4
|
-
if (Array.isArray(value))
|
|
5
|
-
return `[${value.map(canonical).join(",")}]`;
|
|
6
|
-
if (value && typeof value === "object") {
|
|
7
|
-
return `{${Object.entries(value)
|
|
8
|
-
.sort(([a], [b]) => a.localeCompare(b))
|
|
9
|
-
.map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`)
|
|
10
|
-
.join(",")}}`;
|
|
11
|
-
}
|
|
12
|
-
return JSON.stringify(value);
|
|
13
|
-
}
|
|
14
|
-
export const digest = (value) => bytesToHex(sha256(utf8ToBytes(canonical(value))));
|