@liy/agent-runner 0.1.0
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/README.md +290 -0
- package/dist/bin/agent-runner.d.ts +34 -0
- package/dist/bin/agent-runner.js +16076 -0
- package/dist/bin/agent-runner.js.map +7 -0
- package/dist/config.d.ts +121 -0
- package/dist/harness-drivers/codex-jsonl.d.ts +10 -0
- package/dist/harness-drivers/pi-rpc.d.ts +20 -0
- package/dist/harness-drivers/shared.d.ts +98 -0
- package/dist/harness-drivers/types.d.ts +144 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +16135 -0
- package/dist/index.js.map +7 -0
- package/dist/runner.d.ts +76 -0
- package/dist/runtime.d.ts +134 -0
- package/package.json +62 -0
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type ExecuteTaskCompletionPayload, type ExecuteTaskRunnerSpec } from "@liy/mote-core";
|
|
2
|
+
import { type AgentRunnerConfig, type ResolvedAgentRunnerHarnessConfig } from "./config.js";
|
|
3
|
+
/**
|
|
4
|
+
* Optional runtime inputs for one agent-runner invocation.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface RunTaskAgentRunnerOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Already-loaded runner config, primarily used by tests.
|
|
11
|
+
*/
|
|
12
|
+
config?: AgentRunnerConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Config path used when `config` is not supplied.
|
|
15
|
+
*/
|
|
16
|
+
configPath?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Process environment inherited by the runner.
|
|
19
|
+
*/
|
|
20
|
+
env?: NodeJS.ProcessEnv;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Run the Sprite Task Agent harness described by one task spec.
|
|
24
|
+
*
|
|
25
|
+
* @param spec - Host-authored task spec from `state/task-spec.json`.
|
|
26
|
+
* @returns Validated terminal completion payload.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare function runTaskAgentRunner(spec: ExecuteTaskRunnerSpec, options?: RunTaskAgentRunnerOptions): Promise<ExecuteTaskCompletionPayload>;
|
|
31
|
+
/**
|
|
32
|
+
* Create the child process environment for Codex/Pi harness commands.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* The harness receives configured model/tool endpoints and task workspace
|
|
36
|
+
* paths. Host credentials, DB credentials, Sprite tokens, and object storage
|
|
37
|
+
* credentials are deliberately omitted. A selected harness may declare the
|
|
38
|
+
* specific secret env vars it requires; those values must never be logged,
|
|
39
|
+
* persisted, or written to artifacts.
|
|
40
|
+
*
|
|
41
|
+
* @param input - Spec and inherited runner environment.
|
|
42
|
+
* @returns Sanitized harness process environment.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export declare function createHarnessEnvironment(input: {
|
|
47
|
+
spec: ExecuteTaskRunnerSpec;
|
|
48
|
+
harness: ResolvedAgentRunnerHarnessConfig;
|
|
49
|
+
env?: NodeJS.ProcessEnv;
|
|
50
|
+
}): Record<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* Build the instruction prompt passed to the selected JSONL harness.
|
|
53
|
+
*
|
|
54
|
+
* @param spec - Task spec for one task.
|
|
55
|
+
* @returns Prompt text sent to harness stdin.
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildHarnessPrompt(spec: ExecuteTaskRunnerSpec): string;
|
|
60
|
+
/**
|
|
61
|
+
* Read a runner spec JSON file from disk.
|
|
62
|
+
*
|
|
63
|
+
* @param path - Absolute path to `state/task-spec.json`.
|
|
64
|
+
* @returns Parsed task spec.
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare function readTaskRunnerSpec(path: string): Promise<ExecuteTaskRunnerSpec>;
|
|
69
|
+
/**
|
|
70
|
+
* Validate that one runner endpoint is an HTTP(S) URL.
|
|
71
|
+
*
|
|
72
|
+
* @param value - Candidate endpoint URL.
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
export declare function validateRunnerEndpoint(value: string): void;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { type ExecuteTaskCompletionPayload, type Dataset, type JsonValue } from "@liy/mote-core";
|
|
2
|
+
/**
|
|
3
|
+
* Directory layout used by one Sprite task workspace.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface TaskAgentWorkspacePaths {
|
|
8
|
+
workspaceDir: string;
|
|
9
|
+
stateDir: string;
|
|
10
|
+
artifactsDir: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Allocate a UUID for one task artifact.
|
|
14
|
+
*
|
|
15
|
+
* @returns RFC 4122 artifact id.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare function allocateTaskArtifactId(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Create the canonical directory paths for a task workspace.
|
|
22
|
+
*
|
|
23
|
+
* @param workspaceDir - Absolute Sprite workspace directory for one run.
|
|
24
|
+
* @returns Workspace, state, and artifact directory paths.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare function createTaskAgentWorkspacePaths(workspaceDir: string): TaskAgentWorkspacePaths;
|
|
29
|
+
/**
|
|
30
|
+
* Ensure the runtime workspace directories exist.
|
|
31
|
+
*
|
|
32
|
+
* @param paths - Canonical task workspace paths.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare function ensureTaskAgentWorkspace(paths: TaskAgentWorkspacePaths): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Write one Markdown artifact to its canonical artifact directory.
|
|
39
|
+
*
|
|
40
|
+
* @param input - Artifact directory plus Markdown payload.
|
|
41
|
+
* @returns The artifact id that was written.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export declare function writeMarkdownTaskArtifact(input: {
|
|
46
|
+
paths: TaskAgentWorkspacePaths;
|
|
47
|
+
artifactId?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
markdown: string;
|
|
50
|
+
metadata?: Record<string, JsonValue>;
|
|
51
|
+
}): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Write one JSON artifact to its canonical artifact directory.
|
|
54
|
+
*
|
|
55
|
+
* @param input - Artifact directory plus JSON payload.
|
|
56
|
+
* @returns The artifact id that was written.
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare function writeJsonTaskArtifact(input: {
|
|
61
|
+
paths: TaskAgentWorkspacePaths;
|
|
62
|
+
artifactId?: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
payload: JsonValue;
|
|
65
|
+
metadata?: Record<string, JsonValue>;
|
|
66
|
+
}): Promise<string>;
|
|
67
|
+
/**
|
|
68
|
+
* Write one dataset artifact with a required CSV sidecar.
|
|
69
|
+
*
|
|
70
|
+
* @param input - Artifact directory, preview dataset, and full CSV contents.
|
|
71
|
+
* @returns The artifact id that was written.
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
export declare function writeDatasetTaskArtifact(input: {
|
|
76
|
+
paths: TaskAgentWorkspacePaths;
|
|
77
|
+
artifactId?: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
dataset: Dataset;
|
|
80
|
+
csv: string | Buffer;
|
|
81
|
+
metadata?: Record<string, JsonValue>;
|
|
82
|
+
}): Promise<string>;
|
|
83
|
+
/**
|
|
84
|
+
* Parse CSV text into a preview dataset.
|
|
85
|
+
*
|
|
86
|
+
* @param input - CSV source, dataset id, and optional row preview limit.
|
|
87
|
+
* @returns Dataset using the first row as headers.
|
|
88
|
+
*
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
export declare function datasetFromCsv(input: {
|
|
92
|
+
id: string;
|
|
93
|
+
csv: string;
|
|
94
|
+
previewRows?: number;
|
|
95
|
+
}): Dataset;
|
|
96
|
+
/**
|
|
97
|
+
* Write terminal completion to `state/completion.json`.
|
|
98
|
+
*
|
|
99
|
+
* @param input - Workspace paths plus terminal completion payload.
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
export declare function writeTaskCompletion(input: {
|
|
104
|
+
paths: TaskAgentWorkspacePaths;
|
|
105
|
+
completion: ExecuteTaskCompletionPayload;
|
|
106
|
+
}): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Read and validate terminal completion from `state/completion.json`.
|
|
109
|
+
*
|
|
110
|
+
* @param paths - Canonical task workspace paths.
|
|
111
|
+
* @returns Validated terminal completion payload.
|
|
112
|
+
*
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
export declare function readTaskCompletion(paths: TaskAgentWorkspacePaths): Promise<ExecuteTaskCompletionPayload>;
|
|
116
|
+
/**
|
|
117
|
+
* Validate every artifact file referenced by terminal completion.
|
|
118
|
+
*
|
|
119
|
+
* @param input - Workspace paths plus terminal completion payload.
|
|
120
|
+
*
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
export declare function validateTaskArtifactFiles(input: {
|
|
124
|
+
paths: TaskAgentWorkspacePaths;
|
|
125
|
+
completion: ExecuteTaskCompletionPayload;
|
|
126
|
+
}): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Validate that a candidate artifact id is safe for path construction.
|
|
129
|
+
*
|
|
130
|
+
* @param artifactId - Candidate artifact id.
|
|
131
|
+
*
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
export declare function assertTaskArtifactId(artifactId: string): void;
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@liy/agent-runner",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Sprite-local Task Agent runner for Mote remote task execution.",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"agent-runner": "dist/bin/agent-runner.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/liy/mote-app.git",
|
|
30
|
+
"directory": "agent-runner"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/liy/mote-app.git",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/liy/mote-app/issues"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"mote",
|
|
38
|
+
"agent",
|
|
39
|
+
"runner",
|
|
40
|
+
"sprites"
|
|
41
|
+
],
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=24.0.0"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^24.5.2",
|
|
48
|
+
"typescript": "^5.9.3",
|
|
49
|
+
"vitest": "^3.2.4",
|
|
50
|
+
"@liy/mote-core": "0.1.2"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"agent-runner": "node ./dist/bin/agent-runner.js",
|
|
54
|
+
"start": "node ./dist/bin/agent-runner.js",
|
|
55
|
+
"build:local": "rm -rf dist && tsc -p tsconfig.json && pnpm exec esbuild src/index.ts src/bin/agent-runner.ts --bundle --platform=node --format=esm --target=node24 --sourcemap --outdir=dist --outbase=src && find dist -type f \\( -name '*.js' -o -name '*.js.map' \\) ! -path 'dist/index.js' ! -path 'dist/index.js.map' ! -path 'dist/bin/agent-runner.js' ! -path 'dist/bin/agent-runner.js.map' -delete && chmod +x dist/bin/agent-runner.js",
|
|
56
|
+
"build": "pnpm --dir ../mote-core build && pnpm build:local",
|
|
57
|
+
"test:local": "vitest run --passWithNoTests",
|
|
58
|
+
"test": "pnpm --dir ../mote-core build && pnpm test:local",
|
|
59
|
+
"typecheck:local": "tsc --noEmit -p tsconfig.json",
|
|
60
|
+
"typecheck": "pnpm --dir ../mote-core build && pnpm typecheck:local"
|
|
61
|
+
}
|
|
62
|
+
}
|