@discovery-tree/runner 0.1.15 → 0.1.16

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.
Files changed (3) hide show
  1. package/README.md +89 -14
  2. package/dist/cli.js +2494 -1015
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -44,13 +44,13 @@ answer yes. If you answer no, nothing is saved; remove the runner in Discovery T
44
44
  terminal to ask (stdin is not a TTY) the token is saved and the account is printed in a
45
45
  banner. Check it.
46
46
 
47
- | Command | What it does |
48
- | ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
49
- | `dt-runner login [--server <url>] [--name <name>] [--yes]` | Pair with Discovery Tree (device code), then confirm the account. |
50
- | `dt-runner start [--max-sessions N] [--repos-dir <dir>] [--json] [--verbose]` | Run the daemon (one per configuration; a second `start` refuses to run). |
51
- | `dt-runner status` | Show the configuration and check the server (see below). |
52
- | `dt-runner doctor` | Check Node.js, git, Claude Code and its sign-in; warn about `ANTHROPIC_API_KEY`. |
53
- | `dt-runner logout` | Delete the saved config (and token). Remove the runner in Discovery Tree to revoke it. |
47
+ | Command | What it does |
48
+ | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
49
+ | `dt-runner login [--server <url>] [--name <name>] [--yes]` | Pair with Discovery Tree (device code), then confirm the account. |
50
+ | `dt-runner start [--max-sessions N] [--repos-dir <dir>] [--json] [--verbose]` | Run the daemon (one per configuration; a second `start` refuses to run). |
51
+ | `dt-runner status` | Show the configuration and check the server (see below). |
52
+ | `dt-runner doctor` | Check Node.js, git, Claude Code (and Codex and Cursor, if installed) and sign-in; warn about API keys. |
53
+ | `dt-runner logout` | Delete the saved config (and token). Remove the runner in Discovery Tree to revoke it. |
54
54
 
55
55
  The runner only makes outbound HTTPS requests to the Discovery Tree server: a heartbeat every
56
56
  15 seconds, a long poll for commands, and posts of session events. Nothing listens on a port.
@@ -149,13 +149,20 @@ never offered to you. What it may do without asking:
149
149
  agent is told to use another port. A server started this way ends with the Claude Code
150
150
  process (at most `idleTimeoutMinutes` after the last turn, or when the runner stops): Claude
151
151
  Code runs in a process group of its own, and the runner ends what is left in it however
152
- Claude Code exited. On Windows, which has no process groups, the runner instead looks up
153
- every process descended from the exited Claude Code (by parent process id) and ends it with
154
- `taskkill /T /F`. An interrupted turn leaves it running (unless Claude Code does not
155
- answer the interrupt and the SIGINT the runner then sends ends it). It can be left running
156
- only if it moves itself out of that group (`setsid`, a daemon; on Windows, a process whose
157
- parent exited before Claude Code did), or if the runner itself is killed with SIGKILL or
158
- from Task Manager (or the computer loses power).
152
+ Claude Code exited. On Windows, which has no process groups, the runner puts each Claude
153
+ Code in a Job Object of its own (held by one small PowerShell helper it starts), so
154
+ everything Claude Code starts stays in that job however its parents exit (an MCP server
155
+ whose `cmd.exe` wrapper was killed, a server started with `&` from a Git Bash shell that
156
+ exited at once), and ends the job when Claude Code has exited. It also ends any process
157
+ still descending from Claude Code by parent process id, or seen descending from it earlier
158
+ (it looks every 30 seconds, and once more just before it stops Claude Code), with
159
+ `taskkill /T /F`. Without PowerShell it falls back to those alone. An interrupted turn
160
+ leaves it running (unless Claude Code does not answer the interrupt and the SIGINT the
161
+ runner then sends ends it). It can be left running only if it moves itself out of that
162
+ group (`setsid`, a daemon; on Windows, a process started in the first moments of Claude
163
+ Code, before it is in its job, whose parent then exited unseen), or if the runner itself is
164
+ killed with SIGKILL (or the computer loses power). On Windows the jobs end with the runner
165
+ even when it is killed from Task Manager.
159
166
  Left off on purpose: `WebFetch` and `WebSearch` (the easiest way for a manipulated agent to
160
167
  send data out), `curl`, `kill`, `docker` and `sudo` (to start a database: run it
161
168
  yourself beforehand, or add `"Bash(docker compose *)"` to `extraAllowedTools`; Docker access
@@ -227,6 +234,74 @@ The runner only clones from `https://github.com/<owner>/<repo>`: Discovery Tree
227
234
  at another host. It passes Claude Code only a model name that looks like one (`sonnet`,
228
235
  `opus[1m]`, `claude-opus-5-5`, …) and refuses the session otherwise.
229
236
 
237
+ ## Running Codex
238
+
239
+ The runner can also run a session with the official [Codex CLI](https://github.com/openai/codex)
240
+ signed in on your computer, with your ChatGPT plan or your own OpenAI API key. Discovery Tree
241
+ starts a Codex session only when you choose Codex for a run; everything else (worktree, commits,
242
+ push, pull request, screenshots) is the same as for Claude Code.
243
+
244
+ 1. Install it: `npm i -g @openai/codex` (or a release binary on your `PATH`; set
245
+ `DT_RUNNER_CODEX_BIN` to use a particular one).
246
+ 2. Sign in: `codex login`. `codex login status` should say you are logged in.
247
+ 3. Check: `dt-runner doctor` shows the Codex version and sign-in. Codex is optional: without it
248
+ the check is a note, not a failure, and the runner reports Codex as not ready to Discovery
249
+ Tree, which then refuses Codex runs on this computer with the reason.
250
+
251
+ Each turn is one `codex exec --json` process in the session's worktree; the next message
252
+ continues the conversation with `codex exec resume <thread_id>`. The runner never reads Codex's
253
+ credential files: "signed in" is whatever `codex login status` says.
254
+
255
+ **`OPENAI_API_KEY` or `CODEX_API_KEY` in the runner's environment bills that key**, not your
256
+ ChatGPT plan. `dt-runner doctor` and `dt-runner start` warn when either is set.
257
+
258
+ `codex exec` asks no questions: there are no permission prompts to approve in Discovery Tree,
259
+ and the tool rules above (`allowedTools`, saved and inherited rules) do not apply to Codex.
260
+ Codex's own sandbox is what keeps a run in its worktree:
261
+
262
+ | Key | Default | Meaning |
263
+ | -------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
264
+ | `codexSandbox` | `workspace-write` | `codex exec --sandbox`. `workspace-write`: commands may write in the worktree only. `danger-full-access`: no sandbox at all (warned at start). |
265
+ | `codexNetworkAccess` | `false` | With `workspace-write`, let commands reach the network (`npm install`, `gh pr view`): `-c sandbox_workspace_write.network_access=true`. |
266
+
267
+ Interrupting a Codex turn stops its process (and what it started); the next message resumes the
268
+ conversation. Planning requests are still answered by Claude Code.
269
+
270
+ ## Running Cursor
271
+
272
+ The runner can also run a session with the [Cursor Agent CLI](https://cursor.com/cli) signed in
273
+ on your computer, when you choose "Cursor (your computer)" for a run. This is not Cursor Cloud
274
+ (Cursor's background agents, which Discovery Tree runs with a workspace key): the work happens
275
+ in a worktree on your computer, committed, pushed and turned into a pull request as for Claude
276
+ Code and Codex.
277
+
278
+ 1. Install it: `curl https://cursor.com/install -fsS | bash` (it installs `cursor-agent`; newer
279
+ builds also as `agent`). Set `DT_RUNNER_CURSOR_BIN` to use a particular binary.
280
+ 2. Sign in: `cursor-agent login`. `cursor-agent status` should say you are logged in.
281
+ 3. Check: `dt-runner doctor` shows the Cursor Agent CLI version and sign-in. Cursor is optional:
282
+ without it the check is a note, not a failure, and Discovery Tree refuses Cursor runs on this
283
+ computer with the reason.
284
+
285
+ Each turn is one `cursor-agent -p --output-format stream-json` process in the session's
286
+ worktree; the next message continues the chat with `--resume <session_id>`. The runner never
287
+ reads Cursor's credential files: "signed in" is whatever `cursor-agent status` says.
288
+
289
+ **`CURSOR_API_KEY` in the runner's environment makes the CLI sign in with that key** instead of
290
+ your `cursor-agent login`. `dt-runner doctor` and `dt-runner start` warn when it is set.
291
+
292
+ Headless, the Cursor CLI asks no questions: there are no permission prompts to approve in
293
+ Discovery Tree, and the tool rules above (`allowedTools`, saved and inherited rules) do not apply
294
+ to Cursor. Its own permission rules (`~/.cursor/cli-config.json`, and the repository's
295
+ `.cursor/cli.json`) decide which commands and file writes it may make; what they do not allow is
296
+ not done, which can leave a run unable to finish its task. To let it do anything:
297
+
298
+ | Key | Default | Meaning |
299
+ | ------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------- |
300
+ | `cursorForce` | `false` | Pass `--force`: Cursor runs commands and writes files without asking, past its permission rules. `dt-runner start` warns when on. |
301
+
302
+ Interrupting a Cursor turn stops its process (and what it started); the next message resumes the
303
+ chat. Planning requests are still answered by Claude Code.
304
+
230
305
  ## Planning on your own Claude Code
231
306
 
232
307
  Turn on **Plan on my own Claude Code** under Account settings → Local runners, and your