@speculoai/baton 0.0.0-stage → 0.4.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 +459 -2
- package/README.zh-CN.md +460 -0
- package/dist/adapters/agy.js +62 -0
- package/dist/adapters/claude.js +79 -0
- package/dist/adapters/codex.js +105 -0
- package/dist/adapters/common.js +25 -0
- package/dist/adapters/cursor.js +96 -0
- package/dist/adapters/index.js +6 -0
- package/dist/cli.js +162 -0
- package/dist/contract.js +42 -0
- package/dist/git.js +201 -0
- package/dist/install.js +231 -0
- package/dist/mcp.js +90 -0
- package/dist/process.js +23 -0
- package/dist/redact.js +9 -0
- package/dist/scope.js +108 -0
- package/dist/store.js +105 -0
- package/dist/supervisor.js +293 -0
- package/dist/tail.js +64 -0
- package/dist/tasks.js +305 -0
- package/dist/types.js +1 -0
- package/dist/worktree.js +260 -0
- package/package.json +34 -4
package/README.md
CHANGED
|
@@ -1,3 +1,460 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Baton
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**English** | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
> A local compute bridge for AI agents: **Any Agent as Host, Any Agent as Worker**.
|
|
6
|
+
> The CLI/IDE you are using is the Host. It hands bounded coding tasks to other agent CLIs installed on the same machine (Workers), spending their subscriptions. Each task runs in its own process with its state on disk, can run as long as it needs, and can be watched at any time.
|
|
7
|
+
|
|
8
|
+
Delegation targets: `claude` (Claude Code), `codex` (Codex CLI), `cursor` (Cursor Agent CLI), `agy` (Antigravity).
|
|
9
|
+
|
|
10
|
+
> **0.4.0 is a breaking release.** See [Upgrading from 0.3.x](#upgrading-from-03x). 0.3.0 notes are in [Upgrading from 0.2.x](#upgrading-from-02x).
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [How It Works](#how-it-works)
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Verify Installation](#verify-installation)
|
|
19
|
+
- [Usage](#usage)
|
|
20
|
+
- [Skills in the host](#skills-in-the-host)
|
|
21
|
+
- [Command line](#command-line)
|
|
22
|
+
- [Statuses and liveness](#statuses-and-liveness)
|
|
23
|
+
- [Questions and follow-up turns (needs_input / reply)](#questions-and-follow-up-turns-needs_input--reply)
|
|
24
|
+
- [MCP tools](#mcp-tools)
|
|
25
|
+
- [Task directory ~/.baton](#task-directory-baton)
|
|
26
|
+
- [Underlying Calling Conventions](#underlying-calling-conventions)
|
|
27
|
+
- [Safety](#safety)
|
|
28
|
+
- [Manual Smoke Testing](#manual-smoke-testing)
|
|
29
|
+
- [Development & Testing](#development--testing)
|
|
30
|
+
- [Upgrading from 0.3.x](#upgrading-from-03x)
|
|
31
|
+
- [Upgrading from 0.2.x](#upgrading-from-02x)
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## How It Works
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
Host CLI ──shell──> baton start ──spawns a detached supervisor──> baton _supervise <id>
|
|
39
|
+
│ │ (returns task_id at once) │ owns the worker's process group
|
|
40
|
+
│ ▼ │ parses streamed output → events
|
|
41
|
+
│ ~/.baton/tasks/<id>/ <──────── single writer ──────┘
|
|
42
|
+
│ ▲
|
|
43
|
+
└──shell/MCP──> baton status / wait / tail / reply / cancel / ls
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- **Tasks outlive the host**: the supervisor runs on its own. Closing the host session, restarting MCP, or closing the terminal does not stop the task, and its result can still be read afterwards.
|
|
47
|
+
- **No total time cap**: by default only an idle timeout applies (stop after 600 seconds with no output at all), so slow models can run for hours.
|
|
48
|
+
- **Visible progress**: each CLI's streamed output becomes uniform events (messages, tool calls, tool results, errors). Watch them live with `baton tail -f`; `status` says whether the worker is busy, quietly thinking, or whether its supervisor died.
|
|
49
|
+
- **Turn-based interaction**: when the worker stops to ask a question, a human or the host agent continues the same conversation with `baton reply`. Every turn and its author are recorded.
|
|
50
|
+
- **No extra API keys**: reuses each CLI's existing login and subscription.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx @speculoai/baton install
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This installs the `baton` command globally and the plugin into the agent CLIs you select. `--only <agent>` is repeatable (`claude`, `codex`, `cursor`, `agy`, `gemini`), `--force` reinstalls, and `--dry-run` prints the commands. Update everything later with:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx @speculoai/baton@latest update
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The per-host commands below are the same steps, run by hand.
|
|
67
|
+
|
|
68
|
+
### Prerequisites
|
|
69
|
+
|
|
70
|
+
1. **Node.js** >= 20.17.
|
|
71
|
+
2. At least one supported Agent CLI installed and logged in locally (`codex`, `claude`, `agy`, or `cursor`).
|
|
72
|
+
3. A marketplace install does not put `baton` on PATH. Run `/baton:setup`, or `npm install -g @speculoai/baton`.
|
|
73
|
+
4. (Optional) Local checkout:
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/SpeculoAI/baton.git
|
|
76
|
+
cd baton
|
|
77
|
+
npm install
|
|
78
|
+
npm run build
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### Claude Code
|
|
84
|
+
|
|
85
|
+
Claude Code supports plugins via its plugin marketplace.
|
|
86
|
+
|
|
87
|
+
#### Remote One-Click Install (Recommended)
|
|
88
|
+
|
|
89
|
+
Run directly in your system terminal:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
claude plugin marketplace add https://github.com/SpeculoAI/baton
|
|
93
|
+
claude plugin install baton@speculoai
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Or inside an active `claude` session using Slash commands:
|
|
97
|
+
|
|
98
|
+
```text
|
|
99
|
+
/plugin marketplace add https://github.com/SpeculoAI/baton
|
|
100
|
+
/plugin install baton@speculoai
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Local Checkout Install
|
|
104
|
+
|
|
105
|
+
From inside your local `baton` directory:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
claude plugin marketplace add .
|
|
109
|
+
claude plugin install baton@speculoai
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### Antigravity (agy)
|
|
115
|
+
|
|
116
|
+
Antigravity natively discovers plugins and auto-loads their skills.
|
|
117
|
+
|
|
118
|
+
#### Remote One-Click Install (Recommended)
|
|
119
|
+
|
|
120
|
+
Run in your terminal:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
agy plugin install https://github.com/SpeculoAI/baton
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### Local Checkout Install
|
|
127
|
+
|
|
128
|
+
From inside your local `baton` directory:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
agy plugin install .
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
> **Update**: Re-running the same install command updates the plugin to the latest version.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### Codex CLI
|
|
139
|
+
|
|
140
|
+
Codex CLI supports adding plugin marketplaces and registering MCP tools.
|
|
141
|
+
|
|
142
|
+
#### Terminal Command Install
|
|
143
|
+
|
|
144
|
+
Run in your system terminal:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
codex plugin marketplace add https://github.com/SpeculoAI/baton
|
|
148
|
+
codex plugin add baton@speculoai
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### Interactive TUI Install
|
|
152
|
+
|
|
153
|
+
Inside an interactive `codex` session:
|
|
154
|
+
|
|
155
|
+
```text
|
|
156
|
+
/plugins
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Search for `baton` and select `Install Plugin`.
|
|
160
|
+
|
|
161
|
+
#### Local Checkout Install
|
|
162
|
+
|
|
163
|
+
From inside your local `baton` directory:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
codex plugin marketplace add .
|
|
167
|
+
codex plugin add baton@speculoai
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
### Codex App
|
|
173
|
+
|
|
174
|
+
For the Codex desktop application:
|
|
175
|
+
|
|
176
|
+
1. Open Codex App and navigate to **Plugins** in the sidebar.
|
|
177
|
+
2. Search for `Baton` (or add custom marketplace source: `https://github.com/SpeculoAI/baton`).
|
|
178
|
+
3. Click **Install**.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### Cursor (Agent CLI & IDE)
|
|
183
|
+
|
|
184
|
+
#### Cursor Agent CLI Install
|
|
185
|
+
|
|
186
|
+
Cursor's official Agent CLI accepts Git repositories:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
agent plugin marketplace add https://github.com/SpeculoAI/baton
|
|
190
|
+
agent plugin install baton@speculoai
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Or in the Cursor Agent chat window:
|
|
194
|
+
|
|
195
|
+
```text
|
|
196
|
+
/add-plugin baton
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### Cursor IDE (MCP Mode)
|
|
200
|
+
|
|
201
|
+
If using the Cursor editor interface, configure it directly as an MCP server.
|
|
202
|
+
|
|
203
|
+
In your project's `.cursor/mcp.json` (or global Cursor MCP Settings):
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"mcpServers": {
|
|
208
|
+
"baton": {
|
|
209
|
+
"command": "baton",
|
|
210
|
+
"args": ["mcp"]
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
### Gemini CLI
|
|
219
|
+
|
|
220
|
+
Gemini CLI uses an extension system. This installs baton into Gemini CLI as the host; delegating tasks to gemini is not supported.
|
|
221
|
+
|
|
222
|
+
#### Remote Install
|
|
223
|
+
|
|
224
|
+
Run in your terminal:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
gemini extensions install https://github.com/SpeculoAI/baton --consent
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
#### Local Link Mode (For development)
|
|
231
|
+
|
|
232
|
+
From inside your local `baton` directory:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
gemini extensions link .
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
#### Update Extension
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
gemini extensions update baton
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
### Generic MCP Clients (Claude Desktop / Windsurf / etc.)
|
|
247
|
+
|
|
248
|
+
Baton exposes a standard Stdio MCP server compatible with any MCP client (including Claude Desktop, Windsurf, Zed, Cline, Roo Code).
|
|
249
|
+
|
|
250
|
+
Add the following to your client's MCP configuration JSON:
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
{
|
|
254
|
+
"mcpServers": {
|
|
255
|
+
"baton": {
|
|
256
|
+
"command": "baton",
|
|
257
|
+
"args": ["mcp"]
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Apps launched from the Dock often miss an nvm or volta PATH. If `baton` works in a terminal but MCP cannot start it, set `command` to the absolute path from `command -v baton`.
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Verify Installation
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
baton agents
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Example output:
|
|
274
|
+
|
|
275
|
+
```json
|
|
276
|
+
{"agents":[{"id":"codex","installed":true,"bin":"/opt/homebrew/bin/codex","version":"codex-cli 0.167.0"},{"id":"claude","installed":true,"bin":"/Users/user/.local/bin/claude","version":"2.1.323 (Claude Code)"},{"id":"cursor","installed":true,"bin":"/Users/user/.local/bin/cursor-agent","version":"2026.11.11-043ef28"},{"id":"agy","installed":true,"bin":"/Users/user/.local/bin/agy","version":"1.5.6"}]}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Only agents with `installed: true` can be delegation targets.
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Usage
|
|
284
|
+
|
|
285
|
+
### Skills in the host
|
|
286
|
+
|
|
287
|
+
After installation the host loads three skills:
|
|
288
|
+
|
|
289
|
+
- [skills/setup/SKILL.md](skills/setup/SKILL.md): `/baton:setup`, makes sure the `baton` command is on PATH
|
|
290
|
+
- [skills/baton-rescue/SKILL.md](skills/baton-rescue/SKILL.md): one hop, bounded waiting, relays or answers the worker's questions
|
|
291
|
+
- [skills/baton-orchestrate/SKILL.md](skills/baton-orchestrate/SKILL.md): several jobs with a dependency graph, per-job review, rework, fail-over, and a summary (does not require Speckit / OpenSpec / agent-skills)
|
|
292
|
+
|
|
293
|
+
Say something like "rescue this refactor to Codex" and the host runs `baton start` through its shell, then repeats `baton wait --for 50` until the job stops. The skills rely only on shell commands; they do not need the host to have background sub-agents.
|
|
294
|
+
|
|
295
|
+
**Routing**: use the target the user names. Otherwise implementation and debugging go to `codex`, or to `claude` when the current session is already Codex. Never delegate to yourself.
|
|
296
|
+
|
|
297
|
+
### Command line
|
|
298
|
+
|
|
299
|
+
Every command prints exactly one JSON object (except `tail`) and exits non-zero on error. `baton` is the global command from `@speculoai/baton`.
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
baton agents
|
|
303
|
+
baton start --target <codex|claude|cursor|agy> [--prompt <text> | stdin] [--file <p>...] [--effort low|medium|high|ultra]
|
|
304
|
+
[--model <id>] [--idle-timeout <s>] [--max-duration <s>] [--cwd <dir>]
|
|
305
|
+
[--scope <glob> ...] [--scope-on-violation warn|fail]
|
|
306
|
+
[--mode readonly|write] [--allow-weak]
|
|
307
|
+
baton status <id>
|
|
308
|
+
baton wait <id>... [--for <s> | --until-done] # default --for 50; --until-done blocks until a job leaves running
|
|
309
|
+
baton tail <id> [-f] [--raw] # readable events; -f follows until the job stops; --raw prints events.jsonl lines
|
|
310
|
+
baton reply <id> [--prompt <text> | stdin] [--as host|human] # also after scope_violation / readonly_violation
|
|
311
|
+
baton cancel <id>
|
|
312
|
+
baton ls [--all] # jobs for the current directory by default, newest first
|
|
313
|
+
baton prune --older <days> # delete non-running task dirs older than N days (does not remove worktrees)
|
|
314
|
+
baton worktree add [--name <id>] [--branch <name>] [--base <ref>]
|
|
315
|
+
baton worktree ls
|
|
316
|
+
baton worktree rm <name-or-path> # refuses dirty/unmerged trees; remove + delete local branch when clean
|
|
317
|
+
baton mcp # start the MCP server (stdio)
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
- `--effort` maps to each CLI's native flag: Codex `-c model_reasoning_effort=...`; Claude/Agy `--effort` (`ultra` becomes `max`); Cursor alone → `--model auto[effort=...]`.
|
|
321
|
+
- `--model <id>` (Cursor only for now): sets the requested model, stored on the task and kept across `reply`. Cursor rules: model only → `--model <id>`; model+effort → `--model '<id>[effort=...]'`; if the id already embeds a tier (e.g. `grok-4.7-xhigh`) or brackets, combining `--effort` errors. Never emits two `--model` flags. `status` shows `model` (requested) and `model_argv` (passed to the CLI). That is not a provider-confirmed “actual model”.
|
|
322
|
+
- `--idle-timeout` defaults to 600: the job stops only after that many seconds without a single output byte. `--max-duration` is unlimited by default. Both apply per turn and restart on `reply`.
|
|
323
|
+
- **`--mode readonly|write` (default `write`):** maps to each CLI's read-only path (Codex `--sandbox read-only`, Claude `--permission-mode plan`, Cursor `--mode ask`, Agy `--mode plan`). Stored on the task and kept across `reply`. After each turn, dirty net changes upgrade a clean `success` to `readonly_violation`. Targets with no mapping fail unless `--allow-weak` is set. **Breaking note:** new terminal status `readonly_violation`.
|
|
324
|
+
- **Worktrees are separate from tasks:** `baton worktree add`, then `baton start --cwd <path>`. Default root is `.worktrees/` (appended to `.gitignore` if needed). Optional `.baton.json` configures `copy` / `symlink` / `post_create`. Symlinking `node_modules` can cross-contaminate when branches diverge — prefer `post_create` installs when unsure.
|
|
325
|
+
- **`--scope` (optional):** repeatable globs relative to the task `cwd`. After each turn, Baton checks **task-baseline net changes** (commits since start HEAD ∪ working-tree digest diff) against those globs. `--scope-on-violation warn` (default) keeps the transport status and sets `scope_violations` + `warning`; `fail` upgrades a clean `success` to `scope_violation`. This is a **mistake fence**, not a sandbox: ignored paths, non-git writes, and concurrent edits on a shared cwd are blind spots — prefer combining with worktree. Requires a git repo when `--scope` is set. **Breaking note for clients:** new terminal status `scope_violation` (and optional `scope_*` meta fields).
|
|
326
|
+
|
|
327
|
+
### Statuses and liveness
|
|
328
|
+
|
|
329
|
+
| `status` | Meaning |
|
|
330
|
+
|---|---|
|
|
331
|
+
| `running` | Still working; includes `liveness` and `quiet_for_s` |
|
|
332
|
+
| `needs_input` | The worker asked a question; `decision` holds `question` and `options` |
|
|
333
|
+
| `success` | Turn finished; includes `summary` and this turn's `git_changes` (still check `scope_violations` under warn) |
|
|
334
|
+
| `scope_violation` | Out-of-scope edits under `--scope-on-violation fail`; `reply` allowed |
|
|
335
|
+
| `readonly_violation` | `--mode readonly` but the tree changed; `reply` allowed |
|
|
336
|
+
| `failed` / `timed_out` / `cancelled` | Terminal; cannot be replied to |
|
|
337
|
+
| `not_authenticated` / `quota_exceeded` | The target CLI is not logged in / out of quota |
|
|
338
|
+
| `not_installed` | Returned by `start`; the target is not on `PATH` |
|
|
339
|
+
|
|
340
|
+
`liveness` while `running`:
|
|
341
|
+
|
|
342
|
+
| `liveness` | Condition |
|
|
343
|
+
|---|---|
|
|
344
|
+
| `active` | Output within the last 60 seconds |
|
|
345
|
+
| `quiet` | Supervisor alive but silent for more than 60 seconds (usually thinking) |
|
|
346
|
+
| `orphaned` | Supervisor gone or heartbeat older than 30 seconds; the next read kills leftover processes and records `failed` |
|
|
347
|
+
|
|
348
|
+
### Questions and follow-up turns (needs_input / reply)
|
|
349
|
+
|
|
350
|
+
Baton appends an output contract to every prompt: ask with a `BATON_DECISION` block when a choice is needed, finish with a `BATON_RESULT` block. When the worker asks, the task moves to `needs_input` and the worker process exits normally.
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
baton reply <id> --as human --prompt "A"
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
- Starts the next turn in the same conversation. `--as human` marks the words as the user's; the default `--as host` is for answers the host gives from the user's earlier instructions.
|
|
357
|
+
- `reply` also works after `success` for a follow-up. While the job is `running`, `reply` returns `busy`.
|
|
358
|
+
- Each turn's author, input, and result are stored in `turns/<n>.json`.
|
|
359
|
+
|
|
360
|
+
### MCP tools
|
|
361
|
+
|
|
362
|
+
MCP is a thin shell over the same logic. It keeps no task state, so restarting MCP does not affect running jobs:
|
|
363
|
+
|
|
364
|
+
| Tool | Command |
|
|
365
|
+
|---|---|
|
|
366
|
+
| `list_agents` | `agents` |
|
|
367
|
+
| `delegate_task` | `start` (`target_agent`, `prompt`, `files`, `reasoning_effort`, `idle_timeout_seconds`, `max_duration_seconds`, `cwd`) |
|
|
368
|
+
| `task_status` | `status` |
|
|
369
|
+
| `task_wait` | `wait` (`task_ids`, `wait_seconds` default 50, max 55; sends a progress notification every 15 seconds) |
|
|
370
|
+
| `task_reply` | `reply` (`task_id`, `prompt`, `as`) |
|
|
371
|
+
| `task_cancel` | `cancel` |
|
|
372
|
+
| `task_list` | `ls` (`all`, `cwd`) |
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## Task directory ~/.baton
|
|
377
|
+
|
|
378
|
+
The root is `~/.baton` by default; set `BATON_HOME` to move it. Directories are `0700` and files `0600` (they contain prompts).
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
~/.baton/tasks/<task_id>/
|
|
382
|
+
meta.json current state (atomic writes)
|
|
383
|
+
events.jsonl uniform event stream
|
|
384
|
+
turns/<n>.json turn n: author, input, final status, summary, git_changes
|
|
385
|
+
raw/<n>.stdout.log raw worker output for turn n, not truncated
|
|
386
|
+
raw/<n>.stderr.log
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Task directories are never deleted automatically; use `baton prune --older <days>`.
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Underlying Calling Conventions
|
|
394
|
+
|
|
395
|
+
| Agent | First call | Resume | Notes |
|
|
396
|
+
| :--- | :--- | :--- | :--- |
|
|
397
|
+
| **Codex** | `codex exec --json --color never --approve-for-me --skip-git-repo-check --cd <cwd> -` | `codex exec resume --json <thread_id> -` | write uses `--approve-for-me` (conflicts with `--sandbox`); readonly first turn uses `--sandbox read-only`; `exec resume` has no sandbox flag and rejects `--cd` / `--color` |
|
|
398
|
+
| **Claude Code** | `claude -p --output-format stream-json --verbose --permission-mode acceptEdits --permission-prompts none` | add `--resume <session_id>` | readonly → `--permission-mode plan`; `stream-json` with `-p` requires `--verbose`; hook events stay out of the event stream |
|
|
399
|
+
| **Cursor** | `cursor-agent --print --force --trust --output-format stream-json --workspace <cwd>` | add `--resume <session_id>` | readonly → `--mode ask` (drops `--force`, keeps `--trust`); prefers `cursor-agent`, then `agent`; never the IDE's `cursor` |
|
|
400
|
+
| **Antigravity (agy)** | `agy --print <prompt> --mode accept-edits --output-format stream-json` | add `--conversation <id>` | readonly → `--mode plan`; replies stream as deltas; the full text comes from the final `result` |
|
|
401
|
+
|
|
402
|
+
Any output line a parser does not recognize is kept as a `raw` event, never dropped. Real output samples for each CLI live in `test/fixtures/`.
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## Safety
|
|
407
|
+
|
|
408
|
+
1. **No recursion (`BATON_DELEGATION=1`)**: set in the worker's environment; a downstream call into baton is refused.
|
|
409
|
+
2. **Process groups**: each worker runs in its own process group; timeouts and `cancel` kill the whole group, grandchildren included.
|
|
410
|
+
3. **Credential redaction**: text written to events and summaries is redacted before truncation; full raw logs stay under `raw/`, protected by `0600`.
|
|
411
|
+
4. **Id validation**: every task id is checked to be a UUID before it is used in a path.
|
|
412
|
+
5. **`--scope` is not a security boundary**: it only post-checks git-visible net changes. `.gitignore`d files, writes outside the repo, concurrent shared-cwd edits, and orphaned supervisors (check skipped) are known blind spots.
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Manual Smoke Testing
|
|
417
|
+
|
|
418
|
+
Use a separate throwaway Git repository:
|
|
419
|
+
|
|
420
|
+
1. `baton agents`; confirm the target shows `installed: true`.
|
|
421
|
+
2. Start a task that stops to ask:
|
|
422
|
+
```bash
|
|
423
|
+
baton start --target codex --effort low --prompt "Do not edit files. Stop and ask me: A or B, using the BATON_DECISION format, options: A | B."
|
|
424
|
+
```
|
|
425
|
+
3. In another terminal, `baton tail -f <id>` shows events live.
|
|
426
|
+
4. Repeat `baton wait <id> --for 50` until it returns `needs_input` with A/B in `decision`.
|
|
427
|
+
5. `baton reply <id> --as human --prompt "A. Reply with the letter, then finish with BATON_RESULT."`, wait until `success`, and check that `session_id` matches turn 1.
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
## Development & Testing
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
npm test # tsc --noEmit + node --test, no real model quota used
|
|
435
|
+
npm run typecheck
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
Integration tests use fake CLIs in `test/fake-cli/` and a temporary `BATON_HOME`. They cover: a task finishing after its parent is killed, idle and total timeouts, cancel killing the whole group, orphan detection after the supervisor dies, needs_input → reply on the same session, bounded wait, tail, ls/prune, and reading tasks after an MCP restart. Adapter tests use real output samples from each CLI.
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## Upgrading from 0.3.x
|
|
443
|
+
|
|
444
|
+
- Install and update with `npx @speculoai/baton install` and `npx @speculoai/baton@latest update`. The marketplace id is `baton@speculoai`.
|
|
445
|
+
- MCP runs `baton` with args `["mcp"]`. `/baton:setup` installs the global package instead of running npm inside the plugin directory.
|
|
446
|
+
- Node requirement is >= 20.17. The published package is built with `tsc`; a marketplace install no longer needs the TypeScript source.
|
|
447
|
+
|
|
448
|
+
## Upgrading from 0.2.x
|
|
449
|
+
|
|
450
|
+
- **Node 20.17 or newer.** The source is TypeScript. Published installs use the `baton` command.
|
|
451
|
+
- Hand-written MCP config uses `command: "baton"` and `args: ["mcp"]`.
|
|
452
|
+
- The CLI drops `delegate` in favor of `start` + `wait` + `reply`; `wait` takes ids as positional arguments.
|
|
453
|
+
- MCP drops `delegate_task(session_id)` continuation and `task_wait_any`: continue with `task_reply`, wait on several jobs with `task_wait(task_ids)`.
|
|
454
|
+
- `needs_decision` is now `needs_input`. `timeout_seconds` (capped at 1800) is replaced by `idle_timeout_seconds` + `max_duration_seconds`, with no total cap by default.
|
|
455
|
+
- Task state moved from the system temp directory to `~/.baton`.
|
|
456
|
+
- **gemini is not a delegation target for now** (it could not be verified because of a local auth problem). Installing baton as an extension inside Gemini CLI as the host still works.
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
Formerly named **Agent-Plugin-Agent (APA)**. Older install strings are no longer valid; use `baton@speculoai`.
|