@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/README.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# @liy/agent-runner
|
|
2
|
+
|
|
3
|
+
Sprite-local Task Agent Runner for Mote remote task execution.
|
|
4
|
+
|
|
5
|
+
`agent-runner` is a production-mode executable. It expects the same contract used
|
|
6
|
+
inside a Sprite Scratchpad:
|
|
7
|
+
|
|
8
|
+
- a task spec JSON file
|
|
9
|
+
- a reachable Mote Task Control Channel WebSocket
|
|
10
|
+
- a configured harness executable such as Pi or Codex
|
|
11
|
+
- terminal completion written to `state/completion.json`
|
|
12
|
+
|
|
13
|
+
The runner uses the `rpcUrl` from `task-spec.json` exactly as supplied.
|
|
14
|
+
|
|
15
|
+
It does not provide a fake control channel or a separate dev mode.
|
|
16
|
+
|
|
17
|
+
## Build
|
|
18
|
+
|
|
19
|
+
From the repository root:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm --dir ./agent-runner build
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This builds `dist/` and marks `dist/bin/agent-runner.js` executable.
|
|
26
|
+
|
|
27
|
+
To build as part of the full workspace:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Run
|
|
34
|
+
|
|
35
|
+
From the repository root:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm agent-runner -- --task-spec /absolute/path/to/state/task-spec.json
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
From this package:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pnpm --dir ./agent-runner start -- --task-spec /absolute/path/to/state/task-spec.json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Directly from the built executable:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
./agent-runner/dist/bin/agent-runner.js --task-spec /absolute/path/to/state/task-spec.json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For a globally linked local binary:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pnpm dev:link-agent-runner
|
|
57
|
+
agent-runner --task-spec /absolute/path/to/state/task-spec.json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## CLI Options
|
|
61
|
+
|
|
62
|
+
```text
|
|
63
|
+
agent-runner --task-spec <path> [--config <path>]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
- `--task-spec <path>`: path to the host-authored task spec JSON file. Relative paths are resolved from the current working directory.
|
|
67
|
+
- `--config <path>`: optional local-debug override for the runner config path. The Sprite default is `/home/sprite/.config/mote/agent-runner.json`.
|
|
68
|
+
- `--help`, `-h`: print command help.
|
|
69
|
+
|
|
70
|
+
## Runner Config
|
|
71
|
+
|
|
72
|
+
The runner fails fast when its config file is missing or invalid. The Sprite
|
|
73
|
+
baseline setup script writes the default config to:
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
/home/sprite/.config/mote/agent-runner.json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Default Pi POC config:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"defaultHarness": "pi",
|
|
84
|
+
"harnesses": {
|
|
85
|
+
"pi": {
|
|
86
|
+
"driver": "pi-rpc",
|
|
87
|
+
"command": "pi",
|
|
88
|
+
"provider": "deepseek",
|
|
89
|
+
"defaultModel": "deepseek-v4-flash",
|
|
90
|
+
"thinking": "high",
|
|
91
|
+
"secretEnv": ["DEEPSEEK_API_KEY"]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Task Spec
|
|
98
|
+
|
|
99
|
+
The task spec is written by `mote-node` in production at:
|
|
100
|
+
|
|
101
|
+
```text
|
|
102
|
+
<workspace>/state/task-spec.json
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
An editable Pi RPC example lives at:
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
agent-runner/examples/task-spec.pi-rpc.json
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Minimal shape:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"taskId": "aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaaaa",
|
|
116
|
+
"workspaceDir": "/absolute/workspace",
|
|
117
|
+
"rpcUrl": "ws://127.0.0.1:3900/execute-task/tasks/aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaaaa/rpc",
|
|
118
|
+
"userQuery": {
|
|
119
|
+
"queryText": "Why did yield change?"
|
|
120
|
+
},
|
|
121
|
+
"intent": {
|
|
122
|
+
"kind": "diagnosis"
|
|
123
|
+
},
|
|
124
|
+
"task": {
|
|
125
|
+
"title": "Investigate yield drivers",
|
|
126
|
+
"context": "Use approved tools only."
|
|
127
|
+
},
|
|
128
|
+
"toolProvisioning": {
|
|
129
|
+
"tools": []
|
|
130
|
+
},
|
|
131
|
+
"agentRunner": {
|
|
132
|
+
"harness": "pi",
|
|
133
|
+
"model": "deepseek-v4-flash"
|
|
134
|
+
},
|
|
135
|
+
"endpoints": {
|
|
136
|
+
"llmBaseUrl": "https://api.deepseek.com"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The runner validates:
|
|
142
|
+
|
|
143
|
+
- `workspaceDir` is absolute
|
|
144
|
+
- `rpcUrl` is present
|
|
145
|
+
- optional `agentRunner.harness` and `agentRunner.model` are strings
|
|
146
|
+
- configured runner endpoints are HTTP(S) URLs
|
|
147
|
+
- secret-like keys do not appear in the spec
|
|
148
|
+
|
|
149
|
+
The current Fly Sprite Pi POC does not require or provision MCP. Future task
|
|
150
|
+
specs may include `endpoints.mcpBaseUrl` again when MCP integration returns.
|
|
151
|
+
|
|
152
|
+
## Harness Options
|
|
153
|
+
|
|
154
|
+
Harness options live in the runner config. The task spec may only select
|
|
155
|
+
`agentRunner.harness` and `agentRunner.model`; when either value is absent the
|
|
156
|
+
runner uses `defaultHarness` and the selected harness `defaultModel`.
|
|
157
|
+
|
|
158
|
+
### `pi-rpc`
|
|
159
|
+
|
|
160
|
+
Pi RPC driver for Pi-backed task execution.
|
|
161
|
+
|
|
162
|
+
Required fields:
|
|
163
|
+
|
|
164
|
+
- `driver`: `"pi-rpc"`
|
|
165
|
+
- `command`: executable name or absolute path, usually `"pi"`
|
|
166
|
+
- `provider`: provider passed to Pi, for example `"deepseek"`
|
|
167
|
+
- `model`: model passed to Pi, for example `"deepseek-v4-flash"`
|
|
168
|
+
|
|
169
|
+
Optional fields:
|
|
170
|
+
|
|
171
|
+
- `thinking`: `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, or `"xhigh"`. Defaults to `"high"` inside the Pi RPC driver when absent.
|
|
172
|
+
- `args`: extra vetted Pi flags appended after driver-owned flags.
|
|
173
|
+
- `secretEnv`: required provider secret env vars passed through to Pi after the host explicitly forwards them to the runner process.
|
|
174
|
+
|
|
175
|
+
The Pi RPC driver owns these flags and rejects duplicates in `args`:
|
|
176
|
+
|
|
177
|
+
```text
|
|
178
|
+
--mode
|
|
179
|
+
--provider
|
|
180
|
+
--model
|
|
181
|
+
--thinking
|
|
182
|
+
--no-extensions
|
|
183
|
+
--no-prompt-templates
|
|
184
|
+
--no-themes
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
It currently spawns Pi like:
|
|
188
|
+
|
|
189
|
+
```text
|
|
190
|
+
pi --mode rpc --provider deepseek --model deepseek-v4-flash --thinking high --no-extensions --no-prompt-templates --no-themes
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The driver writes one Pi RPC `prompt` command to stdin, parses Pi stdout as
|
|
194
|
+
byte-buffered JSONL, forwards Pi events as `task.progress`, and cancels with
|
|
195
|
+
Pi `abort`, then `SIGTERM`, then `SIGKILL` after five seconds.
|
|
196
|
+
|
|
197
|
+
Direct DeepSeek token example:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
export DEEPSEEK_API_KEY=...
|
|
201
|
+
agent-runner --task-spec /absolute/path/to/state/task-spec.json --config /absolute/path/to/agent-runner.json
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Direct provider-token passthrough is a temporary risk-bearing path. The harness
|
|
205
|
+
must never print, log, persist, or include that token in task artifacts. Mote
|
|
206
|
+
still needs a gateway that protects LLM access tokens before this runtime is
|
|
207
|
+
treated as production-safe.
|
|
208
|
+
|
|
209
|
+
### `codex-jsonl`
|
|
210
|
+
|
|
211
|
+
Codex JSONL driver preserving the existing line-oriented Codex behavior.
|
|
212
|
+
|
|
213
|
+
Required fields:
|
|
214
|
+
|
|
215
|
+
- `driver`: `"codex-jsonl"`
|
|
216
|
+
- `command`: executable name or absolute path, usually `"codex"`
|
|
217
|
+
|
|
218
|
+
Optional fields:
|
|
219
|
+
|
|
220
|
+
- `args`: command arguments, for example `["exec", "--json", "--ephemeral"]`
|
|
221
|
+
- `defaultModel`: model name exposed to the harness as `MOTE_TASK_MODEL` unless the task spec overrides it
|
|
222
|
+
|
|
223
|
+
Example:
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"driver": "codex-jsonl",
|
|
228
|
+
"command": "codex",
|
|
229
|
+
"args": ["exec", "--json", "--ephemeral"],
|
|
230
|
+
"defaultModel": "gpt-5"
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Runtime Contract
|
|
235
|
+
|
|
236
|
+
The harness must write terminal completion to:
|
|
237
|
+
|
|
238
|
+
```text
|
|
239
|
+
<workspace>/state/completion.json
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Completion shape:
|
|
243
|
+
|
|
244
|
+
```json
|
|
245
|
+
{
|
|
246
|
+
"status": "completed",
|
|
247
|
+
"summary": "Short result summary",
|
|
248
|
+
"artifactIds": []
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
`status` must be one of:
|
|
253
|
+
|
|
254
|
+
- `completed`
|
|
255
|
+
- `partial`
|
|
256
|
+
- `failed`
|
|
257
|
+
- `cancelled`
|
|
258
|
+
|
|
259
|
+
Artifacts referenced by `artifactIds` must live under:
|
|
260
|
+
|
|
261
|
+
```text
|
|
262
|
+
<workspace>/artifacts/<artifactId>/artifact.json
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Dataset artifacts must also include:
|
|
266
|
+
|
|
267
|
+
```text
|
|
268
|
+
<workspace>/artifacts/<artifactId>/data.csv
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
`state/completion.json` is authoritative. Harness stdout/stderr and RPC events
|
|
272
|
+
are progress telemetry only.
|
|
273
|
+
|
|
274
|
+
## Local Production Smoke Checklist
|
|
275
|
+
|
|
276
|
+
To run locally without Sprite leasing, you still need production-equivalent
|
|
277
|
+
inputs:
|
|
278
|
+
|
|
279
|
+
1. Start or provide a Mote API server with execute-task RPC routes.
|
|
280
|
+
2. Create a task in the execute-task store.
|
|
281
|
+
3. Create a workspace with `state/` and `artifacts/`.
|
|
282
|
+
4. Write `state/task-spec.json` with a reachable `rpcUrl`.
|
|
283
|
+
5. Ensure the harness command is on `PATH`.
|
|
284
|
+
6. Run `agent-runner --task-spec ...`.
|
|
285
|
+
|
|
286
|
+
For most local checks, use the test suite:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
pnpm --dir ./agent-runner test
|
|
290
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Parse CLI args, run the task agent, and set the process exit code.
|
|
4
|
+
*
|
|
5
|
+
* @param argv - CLI argv after the executable name.
|
|
6
|
+
*/
|
|
7
|
+
export declare function main(argv?: string[]): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Read the `--task-spec` command-line argument.
|
|
10
|
+
*
|
|
11
|
+
* @param argv - CLI argv after the executable name.
|
|
12
|
+
* @returns Resolved task spec path.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readTaskSpecArg(argv: string[]): string;
|
|
15
|
+
/**
|
|
16
|
+
* Read the optional `--config` command-line argument.
|
|
17
|
+
*
|
|
18
|
+
* @param argv - CLI argv after the executable name.
|
|
19
|
+
* @returns Resolved config path when provided.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readConfigPathArg(argv: string[]): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Decide whether this invocation should print command help.
|
|
24
|
+
*
|
|
25
|
+
* @param argv - CLI argv after the executable name.
|
|
26
|
+
* @returns Whether help was requested or no arguments were provided.
|
|
27
|
+
*/
|
|
28
|
+
export declare function shouldPrintHelp(argv: string[]): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Format production-mode CLI help.
|
|
31
|
+
*
|
|
32
|
+
* @returns Help text.
|
|
33
|
+
*/
|
|
34
|
+
export declare function formatHelp(): string;
|