@discovery-tree/runner 0.1.22 → 0.1.24
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 +29 -18
- package/dist/cli.js +290 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,23 +86,24 @@ readable only by you (mode 0600) because it holds the runner token. `login` writ
|
|
|
86
86
|
}
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
| Option | Default | Meaning
|
|
90
|
-
| ------------------------------ | ------------------------------------------------ |
|
|
91
|
-
| `maxSessions` | `2` | Sessions with a running Claude Code at once (1 to 64). Further starts are refused as busy and retried by the server. `--max-sessions` overrides it.
|
|
92
|
-
| `maxJobs` | `2` | [Jobs](#jobs) run at once (1 to 16), apart from sessions. `--max-jobs` overrides it.
|
|
93
|
-
| `jobLogRetentionDays` | `30` | Days an ended job's log files are kept (0: for good). `--job-log-retention-days` overrides it. See [Jobs](#jobs).
|
|
94
|
-
| `jobDataRetentionDays` | `0` (kept for good) | Days an ended job's data folder is kept (0: for good). `--job-data-retention-days` overrides it.
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
89
|
+
| Option | Default | Meaning |
|
|
90
|
+
| ------------------------------ | ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
91
|
+
| `maxSessions` | `2` | Sessions with a running Claude Code at once (1 to 64). Further starts are refused as busy and retried by the server. `--max-sessions` overrides it. |
|
|
92
|
+
| `maxJobs` | `2` | [Jobs](#jobs) run at once (1 to 16), apart from sessions. `--max-jobs` overrides it. |
|
|
93
|
+
| `jobLogRetentionDays` | `30` | Days an ended job's log files are kept (0: for good). `--job-log-retention-days` overrides it. See [Jobs](#jobs). |
|
|
94
|
+
| `jobDataRetentionDays` | `0` (kept for good) | Days an ended job's data folder is kept (0: for good). `--job-data-retention-days` overrides it. |
|
|
95
|
+
| `jobShell` | `powershell` | Windows only: the shell jobs run in: `powershell` (5.1, no `&&`), `pwsh` (PowerShell 7) or `cmd`. Not on the PATH: jobs are refused. `--job-shell` overrides it. |
|
|
96
|
+
| `reposDir` | `$XDG_DATA_HOME/discovery-tree/runner/repos` | Clone cache. `--repos-dir` overrides it. |
|
|
97
|
+
| `worktreesDir` | `$XDG_DATA_HOME/discovery-tree/runner/worktrees` | One worktree per session. |
|
|
98
|
+
| `permissionMode` | `auto` | Claude Code `--permission-mode`. See below. |
|
|
99
|
+
| `allowedTools` | a development allow-list | Replaces the default `--allowedTools` list. |
|
|
100
|
+
| `extraAllowedTools` | `[]` | Added to the allow-list. |
|
|
101
|
+
| `disallowedTools` | credential locations (see below) | Replaces the default `--disallowedTools` deny list. Deny rules win over the allow-list. |
|
|
102
|
+
| `extraDisallowedTools` | `[]` | Added to the deny list. |
|
|
103
|
+
| `loadProjectSettings` | `false` | `true` lets Claude Code load the repository's own `.claude/settings.json` / `settings.local.json` (hooks, permissions). See below. |
|
|
104
|
+
| `inheritClaudeCodePermissions` | `true` | Start each run with the permission rules you approved in your own Claude Code for that repository (see below). `false` turns it off. |
|
|
105
|
+
| `gitProtocol` | `https` | `ssh` clones `git@github.com:owner/repo.git` instead. The cached clone's `origin` URL is rewritten to match on every session start (see below). |
|
|
106
|
+
| `idleTimeoutMinutes` | `15` | An idle Claude Code process is ended after this long; the next message resumes it. |
|
|
106
107
|
|
|
107
108
|
Environment variables: `DT_SERVER_URL` (server), `DT_RUNNER_TOKEN` (token; overrides the file),
|
|
108
109
|
`DT_RUNNER_CLAUDE_BIN` (the `claude` binary to run).
|
|
@@ -270,6 +271,12 @@ Codex's own sandbox is what keeps a run in its worktree:
|
|
|
270
271
|
Interrupting a Codex turn stops its process (and what it started); the next message resumes the
|
|
271
272
|
conversation. Planning requests are still answered by Claude Code.
|
|
272
273
|
|
|
274
|
+
Which model a Codex run uses is chosen in Discovery Tree's model picker. The runner lists the
|
|
275
|
+
models your Codex offers (`codex debug models`) with each heartbeat, so the picker shows them
|
|
276
|
+
under "Codex (your computer)"; `dt-runner doctor` prints the same list. A Codex too old to list
|
|
277
|
+
models still runs on its own default. The models appear within a few minutes of starting the
|
|
278
|
+
runner (its agent probe is cached for five minutes).
|
|
279
|
+
|
|
273
280
|
## Running Cursor
|
|
274
281
|
|
|
275
282
|
The runner can also run a session with the [Cursor Agent CLI](https://cursor.com/cli) signed in
|
|
@@ -329,6 +336,10 @@ sandbox.
|
|
|
329
336
|
Interrupting a Cursor turn stops its process (and what it started); the next message resumes the
|
|
330
337
|
chat. Planning requests are still answered by Claude Code.
|
|
331
338
|
|
|
339
|
+
The Cursor models come from `cursor-agent --list-models`,
|
|
340
|
+
reported the same way and shown under "Cursor (your computer)" in the picker; `dt-runner doctor`
|
|
341
|
+
prints them too. Without a list, Cursor runs the model its CLI is set to.
|
|
342
|
+
|
|
332
343
|
## Planning on your own Claude Code
|
|
333
344
|
|
|
334
345
|
Turn on **Plan on my own Claude Code** under Account settings → Local runners, and your
|
|
@@ -356,7 +367,7 @@ it leaves it running (the session's worktree stays until the job ends, then goes
|
|
|
356
367
|
- **Where it runs.** In the directory you approved, with the tree's environment over the
|
|
357
368
|
runner's own (secrets in memory only, redacted from what is posted; never the runner's
|
|
358
369
|
token). On macOS and Linux the command runs in `/bin/sh`, in a process group of its own; on
|
|
359
|
-
Windows in Windows PowerShell (`powershell.exe`).
|
|
370
|
+
Windows in Windows PowerShell (`powershell.exe`) unless you set `jobShell` (below).
|
|
360
371
|
- **Its data folder.** Each job gets `<state>/jobs/<job id>/data/` (owner-only), its path in
|
|
361
372
|
`DT_JOB_DATA_DIR`, for what it produces (a recording, a report). It is outside every
|
|
362
373
|
session's checkout, so it stays when the checkout is removed (7 days after the job ends),
|
package/dist/cli.js
CHANGED
|
@@ -22,6 +22,7 @@ var WORKSPACE_KEY_PROVIDER_TYPES = [
|
|
|
22
22
|
var AI_CATEGORY_MODEL_MAX_LENGTH = 200;
|
|
23
23
|
|
|
24
24
|
// ../contracts/src/agent-work.ts
|
|
25
|
+
var OWN_CLAUDE_PROVIDER = "own_claude";
|
|
25
26
|
var AGENT_WORK_IDLE_AFTER_MS = 24 * 60 * 60 * 1e3;
|
|
26
27
|
|
|
27
28
|
// ../contracts/src/default-task-model.ts
|
|
@@ -89,6 +90,15 @@ var AGENT_RUN_MAX_WALL_MS = 6 * 60 * 60 * 1e3;
|
|
|
89
90
|
var AGENT_RUN_ABANDONED_GRACE_MS = 30 * 60 * 1e3;
|
|
90
91
|
var AGENT_RUN_AUTO_RECOVER_MAX_MS = 5 * 6e4;
|
|
91
92
|
|
|
93
|
+
// ../contracts/src/active-run-summary.ts
|
|
94
|
+
var ACTIVE_RUN_AGENT_SHORT = {
|
|
95
|
+
[OWN_CLAUDE_PROVIDER]: "Claude",
|
|
96
|
+
local_claude_code: "Claude",
|
|
97
|
+
local_codex: "Codex",
|
|
98
|
+
local_cursor: "Cursor",
|
|
99
|
+
cursor_cloud: "Cursor"
|
|
100
|
+
};
|
|
101
|
+
|
|
92
102
|
// ../contracts/src/discovered-work.ts
|
|
93
103
|
var MAX_DISCOVERED_TASKS_PER_TURN = 5;
|
|
94
104
|
var EXAMPLE_TITLE = "Return 404 instead of 500 when an invoice id is unknown";
|
|
@@ -583,6 +593,7 @@ var ENV_SETUP_SCRIPT_MAX_LENGTH = 16 * 1024;
|
|
|
583
593
|
|
|
584
594
|
// ../contracts/src/tree-autonomy.ts
|
|
585
595
|
var MAX_AUTO_RETRY_DELAY_MINUTES = 24 * 60;
|
|
596
|
+
var MAX_AUTO_DECIDE_GRACE_MINUTES = 7 * 24 * 60;
|
|
586
597
|
|
|
587
598
|
// ../contracts/src/shared-artifacts.ts
|
|
588
599
|
var SHARED_ARTIFACT_TEXT_MAX_BYTES = 1024 * 1024;
|
|
@@ -678,7 +689,7 @@ function toolGrantRepositoryKey(url) {
|
|
|
678
689
|
var RUN_STUCK_TOOL_CALL_AFTER_MS = 15 * 6e4;
|
|
679
690
|
|
|
680
691
|
// src/version.ts
|
|
681
|
-
var RUNNER_VERSION = true ? "0.1.
|
|
692
|
+
var RUNNER_VERSION = true ? "0.1.24" : "0.0.0-dev";
|
|
682
693
|
var RUNNER_PLATFORM = `${process.platform}-${process.arch}`;
|
|
683
694
|
|
|
684
695
|
// src/api.ts
|
|
@@ -3239,6 +3250,56 @@ function startupHint(stderr) {
|
|
|
3239
3250
|
return "";
|
|
3240
3251
|
}
|
|
3241
3252
|
|
|
3253
|
+
// src/drivers/model-list.ts
|
|
3254
|
+
var MAX_LISTED_MODELS = 200;
|
|
3255
|
+
var MODEL_ID = /^[A-Za-z0-9][\w.:@/-]{0,199}$/;
|
|
3256
|
+
var ANSI = /\u001b\[[0-9;?]*[ -/]*[@-~]/g;
|
|
3257
|
+
function tidy(ids) {
|
|
3258
|
+
const out = [];
|
|
3259
|
+
for (const raw of ids) {
|
|
3260
|
+
const id = raw.trim();
|
|
3261
|
+
if (MODEL_ID.test(id) && !out.includes(id)) out.push(id);
|
|
3262
|
+
if (out.length >= MAX_LISTED_MODELS) break;
|
|
3263
|
+
}
|
|
3264
|
+
return out.length ? out : void 0;
|
|
3265
|
+
}
|
|
3266
|
+
function parseCodexModels(stdout) {
|
|
3267
|
+
const text = stdout.trim();
|
|
3268
|
+
if (!text) return void 0;
|
|
3269
|
+
let parsed;
|
|
3270
|
+
try {
|
|
3271
|
+
parsed = JSON.parse(text);
|
|
3272
|
+
} catch {
|
|
3273
|
+
return void 0;
|
|
3274
|
+
}
|
|
3275
|
+
const list = Array.isArray(parsed) ? parsed : parsed && typeof parsed === "object" ? parsed.models : void 0;
|
|
3276
|
+
if (!Array.isArray(list)) return void 0;
|
|
3277
|
+
const ids = [];
|
|
3278
|
+
for (const item of list) {
|
|
3279
|
+
if (typeof item === "string") {
|
|
3280
|
+
ids.push(item);
|
|
3281
|
+
} else if (item && typeof item === "object") {
|
|
3282
|
+
const m = item;
|
|
3283
|
+
if (typeof m.visibility === "string" && m.visibility !== "list") continue;
|
|
3284
|
+
const id = [m.slug, m.id, m.model, m.name].find((v) => typeof v === "string");
|
|
3285
|
+
if (typeof id === "string") ids.push(id);
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
return tidy(ids);
|
|
3289
|
+
}
|
|
3290
|
+
function parseCursorModels(stdout) {
|
|
3291
|
+
const ids = [];
|
|
3292
|
+
for (const raw of stdout.replace(ANSI, "").split(/\r?\n/)) {
|
|
3293
|
+
const line = raw.replace(/^[\s*•✓-]+(?=[A-Za-z0-9])/, "").trim();
|
|
3294
|
+
if (!line) continue;
|
|
3295
|
+
const m = /^(\S+)(?:\s+-\s+.*)?$/.exec(line);
|
|
3296
|
+
if (m && !m[1].endsWith(":") && (line !== m[1] || /[-.\d]/.test(m[1]) || m[1] === "auto")) {
|
|
3297
|
+
ids.push(m[1]);
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
return tidy(ids);
|
|
3301
|
+
}
|
|
3302
|
+
|
|
3242
3303
|
// src/drivers/codex/codex.ts
|
|
3243
3304
|
var CODEX_NPM_SCRIPT = ["node_modules", "@openai", "codex", "bin", "codex.js"];
|
|
3244
3305
|
async function findCodex(env = process.env) {
|
|
@@ -3260,6 +3321,14 @@ async function codexVersion(bin, env = process.env) {
|
|
|
3260
3321
|
return null;
|
|
3261
3322
|
}
|
|
3262
3323
|
}
|
|
3324
|
+
async function codexModels(bin, env = process.env) {
|
|
3325
|
+
try {
|
|
3326
|
+
const res = await runCodex(bin, ["debug", "models"], 2e4, env);
|
|
3327
|
+
return res.code === 0 ? parseCodexModels(res.stdout) : void 0;
|
|
3328
|
+
} catch {
|
|
3329
|
+
return void 0;
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3263
3332
|
async function codexAuthStatus(bin, env = process.env) {
|
|
3264
3333
|
try {
|
|
3265
3334
|
const res = await runCodex(bin, ["login", "status"], 2e4, env);
|
|
@@ -3286,7 +3355,7 @@ function codexKeyVariable(env = process.env) {
|
|
|
3286
3355
|
if (env.OPENAI_API_KEY) return "OPENAI_API_KEY";
|
|
3287
3356
|
return null;
|
|
3288
3357
|
}
|
|
3289
|
-
async function probeCodex(env = process.env) {
|
|
3358
|
+
async function probeCodex(env = process.env, opts = {}) {
|
|
3290
3359
|
const bin = await findCodex(env);
|
|
3291
3360
|
if (!bin) {
|
|
3292
3361
|
return {
|
|
@@ -3311,7 +3380,13 @@ async function probeCodex(env = process.env) {
|
|
|
3311
3380
|
codexProblem: "Codex is not signed in. Run `codex login` on this computer."
|
|
3312
3381
|
};
|
|
3313
3382
|
}
|
|
3314
|
-
|
|
3383
|
+
const models = auth.loggedIn === true && opts.models !== false ? await codexModels(bin, env) : void 0;
|
|
3384
|
+
return {
|
|
3385
|
+
codexVersion: version,
|
|
3386
|
+
codexReady: auth.loggedIn,
|
|
3387
|
+
codexProblem: null,
|
|
3388
|
+
...models ? { codexModels: models } : {}
|
|
3389
|
+
};
|
|
3315
3390
|
}
|
|
3316
3391
|
var SIGN_IN_FAILURE2 = /not logged in|please (run|use) `?codex login|401 unauthorized|status 401|invalid[_ ]api[_ ]key|incorrect api key|refresh token|token (has )?expired|token_expired|could not be refreshed/i;
|
|
3317
3392
|
function looksLikeCodexSignInFailure(text) {
|
|
@@ -3540,10 +3615,10 @@ var codexDriver = {
|
|
|
3540
3615
|
resolveBinary: (env) => findCodex(env),
|
|
3541
3616
|
notInstalledMessage: () => "Codex is not installed on the runner\u2019s computer (no `codex` on PATH). Install it with `npm i -g @openai/codex` and run `codex login`.",
|
|
3542
3617
|
readFeatures: async () => ({}),
|
|
3543
|
-
probe: async (env) => ({
|
|
3618
|
+
probe: async (env, opts) => ({
|
|
3544
3619
|
claudeVersion: null,
|
|
3545
3620
|
claudeReady: null,
|
|
3546
|
-
...await probeCodex(env),
|
|
3621
|
+
...await probeCodex(env, opts),
|
|
3547
3622
|
runsCodex: true
|
|
3548
3623
|
}),
|
|
3549
3624
|
doctor: doctor2,
|
|
@@ -3623,6 +3698,14 @@ async function doctor2(env = process.env) {
|
|
|
3623
3698
|
detail: "could not tell (`codex login status` failed)"
|
|
3624
3699
|
}
|
|
3625
3700
|
);
|
|
3701
|
+
if (auth.loggedIn === true) {
|
|
3702
|
+
const models = await codexModels(bin, env);
|
|
3703
|
+
checks.push({
|
|
3704
|
+
name: "Codex models",
|
|
3705
|
+
level: models ? "ok" : "warn",
|
|
3706
|
+
detail: models ? `${models.length} available: ${models.slice(0, 6).join(", ")}${models.length > 6 ? ", \u2026" : ""}` : "could not list them (`codex debug models`): runs can only use Codex\u2019s own default model"
|
|
3707
|
+
});
|
|
3708
|
+
}
|
|
3626
3709
|
const key = codexKeyVariable(env);
|
|
3627
3710
|
if (key) {
|
|
3628
3711
|
checks.push({
|
|
@@ -3653,6 +3736,14 @@ async function cursorVersion(bin, env = process.env) {
|
|
|
3653
3736
|
return null;
|
|
3654
3737
|
}
|
|
3655
3738
|
}
|
|
3739
|
+
async function cursorModels(bin, env = process.env) {
|
|
3740
|
+
try {
|
|
3741
|
+
const res = await runCursor(bin, ["--list-models"], 2e4, env);
|
|
3742
|
+
return res.code === 0 ? parseCursorModels(res.stdout) : void 0;
|
|
3743
|
+
} catch {
|
|
3744
|
+
return void 0;
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3656
3747
|
async function cursorAuthStatus(bin, env = process.env) {
|
|
3657
3748
|
try {
|
|
3658
3749
|
const res = await runCursor(bin, ["status"], 2e4, env);
|
|
@@ -3677,7 +3768,7 @@ function cursorSignInFix(env = process.env) {
|
|
|
3677
3768
|
}
|
|
3678
3769
|
return "On the runner\u2019s computer, run `cursor-agent login` and sign in, and check that `cursor-agent status` says you are logged in.";
|
|
3679
3770
|
}
|
|
3680
|
-
async function probeCursor(env = process.env) {
|
|
3771
|
+
async function probeCursor(env = process.env, opts = {}) {
|
|
3681
3772
|
const bin = await findCursor(env);
|
|
3682
3773
|
if (!bin) {
|
|
3683
3774
|
return {
|
|
@@ -3702,7 +3793,13 @@ async function probeCursor(env = process.env) {
|
|
|
3702
3793
|
cursorProblem: "The Cursor Agent CLI is not signed in. Run `cursor-agent login` on this computer."
|
|
3703
3794
|
};
|
|
3704
3795
|
}
|
|
3705
|
-
|
|
3796
|
+
const models = opts.models === false ? void 0 : await cursorModels(bin, env);
|
|
3797
|
+
return {
|
|
3798
|
+
cursorVersion: version,
|
|
3799
|
+
cursorReady: auth.loggedIn,
|
|
3800
|
+
cursorProblem: null,
|
|
3801
|
+
...models ? { cursorModels: models } : {}
|
|
3802
|
+
};
|
|
3706
3803
|
}
|
|
3707
3804
|
var SIGN_IN_FAILURE3 = /authentication required|not (logged|signed) in|please run `?(cursor-)?agent login|invalid api key|401 unauthorized|status 401|unauthenticated|session (has )?expired/i;
|
|
3708
3805
|
function looksLikeCursorSignInFailure(text) {
|
|
@@ -3931,6 +4028,7 @@ function applyCursorPermissions(cwd, rules) {
|
|
|
3931
4028
|
if (read === "unreadable") return;
|
|
3932
4029
|
const hadPermissions = read !== null && isObject2(read.permissions);
|
|
3933
4030
|
const hadAllow = hadPermissions && Array.isArray(read.permissions.allow);
|
|
4031
|
+
const hadDeny = hadPermissions && Array.isArray(read.permissions.deny);
|
|
3934
4032
|
const config = read ?? {};
|
|
3935
4033
|
const permissions = permissionsOf(config);
|
|
3936
4034
|
const previous = new Set(marker?.added ?? []);
|
|
@@ -3942,10 +4040,19 @@ function applyCursorPermissions(cwd, rules) {
|
|
|
3942
4040
|
}
|
|
3943
4041
|
if (!keepOutOfCommits(cwd)) return;
|
|
3944
4042
|
permissions.allow = [...own, ...added];
|
|
4043
|
+
if (permissions.deny === void 0) permissions.deny = [];
|
|
3945
4044
|
config.permissions = permissions;
|
|
3946
4045
|
const written = `${JSON.stringify(config, null, 2)}
|
|
3947
4046
|
`;
|
|
3948
|
-
const next = marker ? { ...marker, added, written } : {
|
|
4047
|
+
const next = marker ? { ...marker, added, written } : {
|
|
4048
|
+
added,
|
|
4049
|
+
created: read === null,
|
|
4050
|
+
original: text,
|
|
4051
|
+
written,
|
|
4052
|
+
hadPermissions,
|
|
4053
|
+
hadAllow,
|
|
4054
|
+
hadDeny
|
|
4055
|
+
};
|
|
3949
4056
|
mkdirSync(dirname4(file), { recursive: true });
|
|
3950
4057
|
writeFileSync(join6(cwd, MARKER), `${JSON.stringify(next)}
|
|
3951
4058
|
`);
|
|
@@ -3972,6 +4079,8 @@ function removeCursorPermissions(cwd) {
|
|
|
3972
4079
|
const allow = allowOf(permissions).filter((r) => !added.has(r));
|
|
3973
4080
|
if (allow.length || marker.hadAllow) permissions.allow = allow;
|
|
3974
4081
|
else delete permissions.allow;
|
|
4082
|
+
const deny = permissions.deny;
|
|
4083
|
+
if (!marker.hadDeny && Array.isArray(deny) && deny.length === 0) delete permissions.deny;
|
|
3975
4084
|
if (Object.keys(permissions).length || marker.hadPermissions)
|
|
3976
4085
|
read.permissions = permissions;
|
|
3977
4086
|
else delete read.permissions;
|
|
@@ -4007,18 +4116,31 @@ function readMarker(cwd) {
|
|
|
4007
4116
|
try {
|
|
4008
4117
|
const m = JSON.parse(readFileSync(join6(cwd, MARKER), "utf8"));
|
|
4009
4118
|
if (!Array.isArray(m.added) || typeof m.written !== "string") return null;
|
|
4119
|
+
const original = typeof m.original === "string" ? m.original : null;
|
|
4010
4120
|
return {
|
|
4011
4121
|
added: m.added.filter((r) => typeof r === "string"),
|
|
4012
4122
|
created: m.created === true,
|
|
4013
|
-
original
|
|
4123
|
+
original,
|
|
4014
4124
|
written: m.written,
|
|
4015
4125
|
hadPermissions: m.hadPermissions === true,
|
|
4016
|
-
hadAllow: m.hadAllow === true
|
|
4126
|
+
hadAllow: m.hadAllow === true,
|
|
4127
|
+
// A marker from before the runner wrote `deny` (0.1.21) says nothing of it: the file as
|
|
4128
|
+
// it was before the runner first wrote it does.
|
|
4129
|
+
hadDeny: typeof m.hadDeny === "boolean" ? m.hadDeny : originalHadDeny(original)
|
|
4017
4130
|
};
|
|
4018
4131
|
} catch {
|
|
4019
4132
|
return null;
|
|
4020
4133
|
}
|
|
4021
4134
|
}
|
|
4135
|
+
function originalHadDeny(original) {
|
|
4136
|
+
if (original === null) return false;
|
|
4137
|
+
try {
|
|
4138
|
+
const parsed = JSON.parse(original);
|
|
4139
|
+
return Array.isArray(parsed?.permissions?.deny);
|
|
4140
|
+
} catch {
|
|
4141
|
+
return false;
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4022
4144
|
var isObject2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
4023
4145
|
function readConfig(file) {
|
|
4024
4146
|
if (!existsSync(file)) return null;
|
|
@@ -4076,10 +4198,10 @@ var cursorDriver = {
|
|
|
4076
4198
|
resolveBinary: (env) => findCursor(env),
|
|
4077
4199
|
notInstalledMessage: () => "The Cursor Agent CLI is not installed on the runner\u2019s computer (no `cursor-agent` on PATH). Install it from https://cursor.com/cli and run `cursor-agent login`.",
|
|
4078
4200
|
readFeatures: async () => ({}),
|
|
4079
|
-
probe: async (env) => ({
|
|
4201
|
+
probe: async (env, opts) => ({
|
|
4080
4202
|
claudeVersion: null,
|
|
4081
4203
|
claudeReady: null,
|
|
4082
|
-
...await probeCursor(env),
|
|
4204
|
+
...await probeCursor(env, opts),
|
|
4083
4205
|
runsCursor: true
|
|
4084
4206
|
}),
|
|
4085
4207
|
doctor: doctor3,
|
|
@@ -4113,6 +4235,9 @@ var cursorDriver = {
|
|
|
4113
4235
|
if (cursorResumeNotFound(stderr)) {
|
|
4114
4236
|
return " The Cursor chat to resume was not found on this computer.";
|
|
4115
4237
|
}
|
|
4238
|
+
if (cursorConfigInvalid(stderr)) {
|
|
4239
|
+
return " The Cursor Agent CLI rejected a config file: check the worktree\u2019s `.cursor/cli.json` and `~/.cursor/cli-config.json` on the runner\u2019s computer (each `permissions` needs both `allow` and `deny` lists).";
|
|
4240
|
+
}
|
|
4116
4241
|
return "";
|
|
4117
4242
|
},
|
|
4118
4243
|
resumeNotFound: (stderr) => cursorResumeNotFound(stderr)
|
|
@@ -4122,6 +4247,9 @@ function cursorResumeNotFound(text) {
|
|
|
4122
4247
|
text
|
|
4123
4248
|
);
|
|
4124
4249
|
}
|
|
4250
|
+
function cursorConfigInvalid(text) {
|
|
4251
|
+
return /Invalid input: expected \w+, received \w+/.test(text);
|
|
4252
|
+
}
|
|
4125
4253
|
function turnErrorMessage3(turn) {
|
|
4126
4254
|
if (turn.isError && looksLikeCursorSignInFailure(turn.text)) {
|
|
4127
4255
|
return `The Cursor Agent CLI could not sign in (${turn.text.slice(0, 200)}). ${cursorSignInFix()} Then send a message here to try again.`;
|
|
@@ -4158,6 +4286,14 @@ async function doctor3(env = process.env) {
|
|
|
4158
4286
|
detail: "could not tell (`cursor-agent status` said nothing the runner reads)"
|
|
4159
4287
|
}
|
|
4160
4288
|
);
|
|
4289
|
+
if (auth.loggedIn !== false) {
|
|
4290
|
+
const models = await cursorModels(bin, env);
|
|
4291
|
+
checks.push({
|
|
4292
|
+
name: "Cursor models",
|
|
4293
|
+
level: models ? "ok" : "warn",
|
|
4294
|
+
detail: models ? `${models.length} available: ${models.slice(0, 6).join(", ")}${models.length > 6 ? ", \u2026" : ""}` : "could not list them (`cursor-agent --list-models`): runs can only use the model the CLI is set to"
|
|
4295
|
+
});
|
|
4296
|
+
}
|
|
4161
4297
|
if (cursorKeyVariable(env)) {
|
|
4162
4298
|
checks.push({
|
|
4163
4299
|
name: "CURSOR_API_KEY",
|
|
@@ -4417,6 +4553,8 @@ function configDirRules(configFile, platform = process.platform) {
|
|
|
4417
4553
|
var DEFAULT_SERVER_URL = "https://discovery-tree-backend.onrender.com";
|
|
4418
4554
|
var DEFAULT_MAX_SESSIONS = 2;
|
|
4419
4555
|
var DEFAULT_IDLE_TIMEOUT_MINUTES = 15;
|
|
4556
|
+
var JOB_SHELLS = ["powershell", "pwsh", "cmd"];
|
|
4557
|
+
var DEFAULT_JOB_SHELL = "powershell";
|
|
4420
4558
|
var DEFAULT_JOB_LOG_RETENTION_DAYS = 30;
|
|
4421
4559
|
var JOB_RETENTION_DAYS_LIMIT = 3650;
|
|
4422
4560
|
async function readConfigFile(file) {
|
|
@@ -4481,6 +4619,7 @@ function resolveConfig(file, overrides = {}, env = process.env, paths = runnerPa
|
|
|
4481
4619
|
"jobDataRetentionDays",
|
|
4482
4620
|
overrides.jobDataRetentionDays ?? file?.jobDataRetentionDays ?? 0
|
|
4483
4621
|
);
|
|
4622
|
+
const jobShell = jobShellOf(overrides.jobShell ?? file?.jobShell);
|
|
4484
4623
|
const inherit = file?.inheritClaudeCodePermissions;
|
|
4485
4624
|
if (inherit !== void 0 && typeof inherit !== "boolean") {
|
|
4486
4625
|
throw new Error(
|
|
@@ -4531,6 +4670,7 @@ function resolveConfig(file, overrides = {}, env = process.env, paths = runnerPa
|
|
|
4531
4670
|
maxJobs,
|
|
4532
4671
|
jobLogRetentionDays,
|
|
4533
4672
|
jobDataRetentionDays,
|
|
4673
|
+
jobShell,
|
|
4534
4674
|
reposDir: overrides.reposDir ?? file?.reposDir ?? join7(paths.dataDir, "repos"),
|
|
4535
4675
|
worktreesDir: file?.worktreesDir ?? join7(paths.dataDir, "worktrees"),
|
|
4536
4676
|
permissionMode: mode,
|
|
@@ -4550,6 +4690,17 @@ function resolveConfig(file, overrides = {}, env = process.env, paths = runnerPa
|
|
|
4550
4690
|
configFile: paths.configFile
|
|
4551
4691
|
};
|
|
4552
4692
|
}
|
|
4693
|
+
function jobShellOf(value) {
|
|
4694
|
+
if (value === void 0) return DEFAULT_JOB_SHELL;
|
|
4695
|
+
const name = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
4696
|
+
const shell = JOB_SHELLS.find((s) => s === name);
|
|
4697
|
+
if (!shell) {
|
|
4698
|
+
throw new Error(
|
|
4699
|
+
`jobShell must be one of ${JOB_SHELLS.join(", ")} (got ${typeof value === "string" ? `"${value}"` : JSON.stringify(value)}).`
|
|
4700
|
+
);
|
|
4701
|
+
}
|
|
4702
|
+
return shell;
|
|
4703
|
+
}
|
|
4553
4704
|
function retentionDays(key, days) {
|
|
4554
4705
|
if (!Number.isInteger(days) || days < 0 || days > JOB_RETENTION_DAYS_LIMIT) {
|
|
4555
4706
|
throw new Error(
|
|
@@ -5424,9 +5575,9 @@ var JobOutbox = class _JobOutbox {
|
|
|
5424
5575
|
|
|
5425
5576
|
// src/jobs/job-process.ts
|
|
5426
5577
|
import { execFile, spawn as spawn4 } from "node:child_process";
|
|
5427
|
-
import { closeSync, openSync, readFileSync as readFileSync2, readdirSync } from "node:fs";
|
|
5578
|
+
import { closeSync, existsSync as existsSync2, openSync, readFileSync as readFileSync2, readdirSync } from "node:fs";
|
|
5428
5579
|
import { readFile as readFile7, writeFile as writeFile4 } from "node:fs/promises";
|
|
5429
|
-
import { dirname as dirname7, join as join10 } from "node:path";
|
|
5580
|
+
import { dirname as dirname7, join as join10, win32 } from "node:path";
|
|
5430
5581
|
|
|
5431
5582
|
// src/lock.ts
|
|
5432
5583
|
import { mkdir as mkdir5, open as open2, readFile as readFile6, rm as rm5 } from "node:fs/promises";
|
|
@@ -5489,6 +5640,31 @@ async function acquireDaemonLock(stateDir, pid = process.pid) {
|
|
|
5489
5640
|
|
|
5490
5641
|
// src/jobs/job-process.ts
|
|
5491
5642
|
var JOB_IS_WINDOWS = process.platform === "win32";
|
|
5643
|
+
function jobShellProgram(shell) {
|
|
5644
|
+
return shell === "cmd" ? "cmd.exe" : shell === "pwsh" ? "pwsh.exe" : "powershell.exe";
|
|
5645
|
+
}
|
|
5646
|
+
function findJobShell(shell, env = process.env) {
|
|
5647
|
+
const program = jobShellProgram(shell);
|
|
5648
|
+
const pathKey = Object.keys(env).find((k) => k.toLowerCase() === "path");
|
|
5649
|
+
const dirs = (pathKey ? env[pathKey] ?? "" : "").split(";").map((d) => d.trim().replace(/^"|"$/g, ""));
|
|
5650
|
+
const root = env.SystemRoot ?? env.SYSTEMROOT ?? env.windir;
|
|
5651
|
+
if (root) {
|
|
5652
|
+
const system32 = win32.join(root, "System32");
|
|
5653
|
+
if (shell === "cmd") dirs.push(system32);
|
|
5654
|
+
if (shell === "powershell") dirs.push(win32.join(system32, "WindowsPowerShell", "v1.0"));
|
|
5655
|
+
}
|
|
5656
|
+
for (const dir of dirs) {
|
|
5657
|
+
if (!dir) continue;
|
|
5658
|
+
const candidate = win32.join(dir, program);
|
|
5659
|
+
if (existsSync2(candidate)) return candidate;
|
|
5660
|
+
}
|
|
5661
|
+
return null;
|
|
5662
|
+
}
|
|
5663
|
+
function jobShellProblem(shell, env = process.env) {
|
|
5664
|
+
if (!JOB_IS_WINDOWS || findJobShell(shell, env)) return null;
|
|
5665
|
+
const others = ["powershell", "pwsh", "cmd"].filter((s) => s !== shell);
|
|
5666
|
+
return `The job shell "${shell}" (${jobShellProgram(shell)}) is not on this computer's PATH, so jobs are refused. Install it, or set jobShell to ${others.map((s) => `"${s}"`).join(" or ")} in the runner's config (or start with --job-shell).`;
|
|
5667
|
+
}
|
|
5492
5668
|
var POWERSHELL_FLAGS = [
|
|
5493
5669
|
"-NoLogo",
|
|
5494
5670
|
"-NoProfile",
|
|
@@ -5530,29 +5706,58 @@ function powershellCommandScript(command) {
|
|
|
5530
5706
|
"if ($dtRunnerOk) { exit 0 } elseif ($dtRunnerLast) { exit $dtRunnerLast } else { exit 1 }"
|
|
5531
5707
|
].join("\n");
|
|
5532
5708
|
}
|
|
5533
|
-
function powershellJobScript(commandFile, exitFile) {
|
|
5709
|
+
function powershellJobScript(commandFile, exitFile, host = "powershell.exe") {
|
|
5534
5710
|
return [
|
|
5535
5711
|
"$ErrorActionPreference = 'Continue'",
|
|
5536
5712
|
"$ProgressPreference = 'SilentlyContinue'",
|
|
5537
5713
|
"try { [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding $false } catch {}",
|
|
5538
|
-
`&
|
|
5714
|
+
`& ${psQuote(host)} ${POWERSHELL_FLAGS.join(" ")} -File ${psQuote(commandFile)}`,
|
|
5539
5715
|
"$dtRunnerCode = $LASTEXITCODE",
|
|
5540
5716
|
"if ($null -eq $dtRunnerCode) { $dtRunnerCode = 1 }",
|
|
5541
5717
|
`try { [IO.File]::WriteAllText(${psQuote(exitFile)}, [string]$dtRunnerCode) } catch {}`,
|
|
5542
5718
|
"exit $dtRunnerCode"
|
|
5543
5719
|
].join("\n");
|
|
5544
5720
|
}
|
|
5721
|
+
function batchPath(path) {
|
|
5722
|
+
return path.replace(/%/g, "%%");
|
|
5723
|
+
}
|
|
5724
|
+
function cmdCommandScript(command) {
|
|
5725
|
+
return [
|
|
5726
|
+
"@echo off",
|
|
5727
|
+
"@chcp 65001 >nul",
|
|
5728
|
+
command.replace(/\r?\n/g, "\r\n"),
|
|
5729
|
+
"exit /b %ERRORLEVEL%",
|
|
5730
|
+
""
|
|
5731
|
+
].join("\r\n");
|
|
5732
|
+
}
|
|
5733
|
+
function cmdJobScript(commandFile, exitFile, cmdPath = "cmd.exe") {
|
|
5734
|
+
const tmp = `${exitFile}.tmp`;
|
|
5735
|
+
return [
|
|
5736
|
+
"@echo off",
|
|
5737
|
+
// Before any path: `cmd` reads this file in the OEM code page until then, and the state
|
|
5738
|
+
// folder may be under a user name with an accented letter.
|
|
5739
|
+
"@chcp 65001 >nul",
|
|
5740
|
+
`"${batchPath(cmdPath)}" /d /s /c ""${batchPath(commandFile)}""`,
|
|
5741
|
+
'set "DT_RUNNER_CODE=%ERRORLEVEL%"',
|
|
5742
|
+
// The code is written next to the file and renamed, so a half-written one is never read.
|
|
5743
|
+
`>"${batchPath(tmp)}" echo %DT_RUNNER_CODE%`,
|
|
5744
|
+
`move /y "${batchPath(tmp)}" "${batchPath(exitFile)}" >nul`,
|
|
5745
|
+
"exit /b %DT_RUNNER_CODE%",
|
|
5746
|
+
""
|
|
5747
|
+
].join("\r\n");
|
|
5748
|
+
}
|
|
5545
5749
|
function psLiteralPath(path) {
|
|
5546
5750
|
return `([WildcardPattern]::Escape(${psQuote(path)}))`;
|
|
5547
5751
|
}
|
|
5548
5752
|
function windowsLauncherScript(input) {
|
|
5549
|
-
const
|
|
5753
|
+
const shell = input.shell ?? DEFAULT_JOB_SHELL;
|
|
5754
|
+
const args = shell === "cmd" ? ["/d", "/s", "/c", `""${input.scriptFile}""`].join(" ") : [...POWERSHELL_FLAGS, "-File", `"${input.scriptFile}"`].join(" ");
|
|
5550
5755
|
return [
|
|
5551
5756
|
"$ErrorActionPreference = 'Stop'",
|
|
5552
5757
|
"$ProgressPreference = 'SilentlyContinue'",
|
|
5553
5758
|
// Started here: Start-Process takes the current location as the job's directory.
|
|
5554
5759
|
`Set-Location -LiteralPath ${psQuote(input.cwd)}`,
|
|
5555
|
-
`$p = Start-Process -FilePath
|
|
5760
|
+
`$p = Start-Process -FilePath ${psQuote(input.shellPath ?? jobShellProgram(shell))} -ArgumentList ${psQuote(args)} -NoNewWindow -PassThru -RedirectStandardOutput ${psLiteralPath(input.stdoutFile)} -RedirectStandardError ${psLiteralPath(input.stderrFile)}`,
|
|
5556
5761
|
// A command that is over already has no start time to read: now is close enough.
|
|
5557
5762
|
"$dtRunnerAt = $null",
|
|
5558
5763
|
"try { $dtRunnerAt = ([DateTimeOffset]$p.StartTime).ToUnixTimeMilliseconds() } catch { $dtRunnerAt = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() }",
|
|
@@ -5588,21 +5793,32 @@ async function spawnJob(input) {
|
|
|
5588
5793
|
return { pid: child.pid, startedAt: Date.now() - 500, child, exited };
|
|
5589
5794
|
}
|
|
5590
5795
|
async function spawnWindowsJob(input) {
|
|
5796
|
+
const shell = input.shell ?? DEFAULT_JOB_SHELL;
|
|
5797
|
+
const shellPath = findJobShell(shell, process.env);
|
|
5798
|
+
if (!shellPath) throw new Error(jobShellProblem(shell, process.env) ?? `${shell} was not found.`);
|
|
5591
5799
|
const dir = dirname7(input.exitFile);
|
|
5592
|
-
const
|
|
5593
|
-
const
|
|
5594
|
-
const
|
|
5595
|
-
|
|
5800
|
+
const cmd = shell === "cmd";
|
|
5801
|
+
const scriptFile = join10(dir, cmd ? "job.cmd" : "job.ps1");
|
|
5802
|
+
const commandFile = join10(dir, cmd ? "command.cmd" : "command.ps1");
|
|
5803
|
+
if (cmd) {
|
|
5804
|
+
await writeFile4(commandFile, cmdCommandScript(input.command), { mode: 384 });
|
|
5805
|
+
} else {
|
|
5806
|
+
await writeFile4(commandFile, "\uFEFF" + powershellCommandScript(input.command), {
|
|
5807
|
+
mode: 384
|
|
5808
|
+
});
|
|
5809
|
+
}
|
|
5596
5810
|
for (const f of [input.stdoutFile, input.stderrFile]) await writeFile4(f, "", { flag: "a" });
|
|
5597
|
-
await writeFile4(
|
|
5598
|
-
|
|
5599
|
-
|
|
5811
|
+
await writeFile4(
|
|
5812
|
+
scriptFile,
|
|
5813
|
+
cmd ? cmdJobScript(commandFile, input.exitFile, shellPath) : "\uFEFF" + powershellJobScript(commandFile, input.exitFile, shellPath),
|
|
5814
|
+
{ mode: 384 }
|
|
5815
|
+
);
|
|
5600
5816
|
const launcher = spawn4(
|
|
5601
5817
|
"powershell.exe",
|
|
5602
5818
|
[
|
|
5603
5819
|
...POWERSHELL_FLAGS,
|
|
5604
5820
|
"-EncodedCommand",
|
|
5605
|
-
encoded(windowsLauncherScript({ ...input, scriptFile }))
|
|
5821
|
+
encoded(windowsLauncherScript({ ...input, scriptFile, shell, shellPath }))
|
|
5606
5822
|
],
|
|
5607
5823
|
// Piped (nothing inherited), so Node gives it a console without a window.
|
|
5608
5824
|
{ cwd: input.cwd, env: input.env, stdio: ["ignore", "pipe", "pipe"], windowsHide: true }
|
|
@@ -5815,6 +6031,8 @@ var JobManager = class {
|
|
|
5815
6031
|
constructor(opts) {
|
|
5816
6032
|
this.opts = opts;
|
|
5817
6033
|
this.root = join11(opts.stateDir, "jobs");
|
|
6034
|
+
const problem = this.shellProblem();
|
|
6035
|
+
if (problem) opts.logger.error(problem);
|
|
5818
6036
|
}
|
|
5819
6037
|
jobs = /* @__PURE__ */ new Map();
|
|
5820
6038
|
/** Folders being removed now, with how many removals hold each (see `holdForRemoval`). */
|
|
@@ -5835,6 +6053,13 @@ var JobManager = class {
|
|
|
5835
6053
|
/** Resolves when the runner begins to stop: an end waiting for secrets waits no more. */
|
|
5836
6054
|
stopped = secretWait();
|
|
5837
6055
|
root;
|
|
6056
|
+
/** Why jobs cannot run in the job shell (not on the PATH), when they cannot. */
|
|
6057
|
+
shellProblem() {
|
|
6058
|
+
return (this.opts.checkJobShell ?? ((s) => jobShellProblem(s)))(this.shell);
|
|
6059
|
+
}
|
|
6060
|
+
get shell() {
|
|
6061
|
+
return this.opts.jobShell ?? DEFAULT_JOB_SHELL;
|
|
6062
|
+
}
|
|
5838
6063
|
/** The folder a job's record, log and outbox live in. */
|
|
5839
6064
|
jobDir(jobId) {
|
|
5840
6065
|
return join11(this.root, jobId);
|
|
@@ -6216,6 +6441,8 @@ var JobManager = class {
|
|
|
6216
6441
|
if (this.shuttingDown) {
|
|
6217
6442
|
return { ok: false, retryable: true, error: "The runner is shutting down." };
|
|
6218
6443
|
}
|
|
6444
|
+
const shellProblem = this.shellProblem();
|
|
6445
|
+
if (shellProblem) return { ok: false, error: shellProblem };
|
|
6219
6446
|
const command = typeof cmd.command === "string" ? cmd.command : "";
|
|
6220
6447
|
if (!command.trim() || command.includes("\0")) {
|
|
6221
6448
|
return { ok: false, error: "The job has no command to run." };
|
|
@@ -6308,7 +6535,8 @@ var JobManager = class {
|
|
|
6308
6535
|
env,
|
|
6309
6536
|
stdoutFile: join11(dir, "stdout.log"),
|
|
6310
6537
|
stderrFile: join11(dir, "stderr.log"),
|
|
6311
|
-
exitFile: join11(dir, "exit-code")
|
|
6538
|
+
exitFile: join11(dir, "exit-code"),
|
|
6539
|
+
shell: this.shell
|
|
6312
6540
|
});
|
|
6313
6541
|
} catch (err) {
|
|
6314
6542
|
const error = safeError(err, redactor);
|
|
@@ -6861,7 +7089,7 @@ function safeError(err, redactor) {
|
|
|
6861
7089
|
}
|
|
6862
7090
|
|
|
6863
7091
|
// src/session-manager.ts
|
|
6864
|
-
import { existsSync as
|
|
7092
|
+
import { existsSync as existsSync3, lstatSync } from "node:fs";
|
|
6865
7093
|
import { mkdir as mkdir9, rm as rm8, writeFile as writeFile6 } from "node:fs/promises";
|
|
6866
7094
|
import { basename as basename3, dirname as dirname11, join as join15, resolve as resolve3 } from "node:path";
|
|
6867
7095
|
|
|
@@ -9171,9 +9399,9 @@ var SessionManager = class {
|
|
|
9171
9399
|
dir: fromEntry.dir,
|
|
9172
9400
|
repoDir: fromEntry.repoDir
|
|
9173
9401
|
} : void 0);
|
|
9174
|
-
const keptReference = candidate &&
|
|
9402
|
+
const keptReference = candidate && existsSync3(candidate.dir) ? candidate : void 0;
|
|
9175
9403
|
const referenceHold = !reference?.url ? null : this.opts.jobs ? this.opts.jobs.holdForRemoval(referenceDir) : () => void 0;
|
|
9176
|
-
if (reference?.url && keepWorkspace && (keptReference ||
|
|
9404
|
+
if (reference?.url && keepWorkspace && (keptReference || existsSync3(referenceDir))) {
|
|
9177
9405
|
if (keptReference) record.referenceRepository = keptReference;
|
|
9178
9406
|
referenceHold?.();
|
|
9179
9407
|
this.opts.logger.info(
|
|
@@ -9757,6 +9985,7 @@ var RunnerDaemon = class {
|
|
|
9757
9985
|
this.jobs = new JobManager({
|
|
9758
9986
|
stateDir: opts.config.stateDir,
|
|
9759
9987
|
maxJobs: opts.config.maxJobs,
|
|
9988
|
+
jobShell: opts.config.jobShell,
|
|
9760
9989
|
logRetentionDays: opts.config.jobLogRetentionDays,
|
|
9761
9990
|
dataRetentionDays: opts.config.jobDataRetentionDays,
|
|
9762
9991
|
poster: this.api,
|
|
@@ -9931,8 +10160,14 @@ var RunnerDaemon = class {
|
|
|
9931
10160
|
async agentProblem(driver) {
|
|
9932
10161
|
const agent = this.optional.find((a) => a.driver.kind === driver.kind);
|
|
9933
10162
|
if (!agent) return null;
|
|
9934
|
-
const fresh = readAgentFields(await agent.driver.probe(), agent);
|
|
9935
|
-
if (this.agentInfo)
|
|
10163
|
+
const fresh = readAgentFields(await agent.driver.probe(void 0, { models: false }), agent);
|
|
10164
|
+
if (this.agentInfo) {
|
|
10165
|
+
const kept = readAgentFields(this.agentInfo.info, agent).models;
|
|
10166
|
+
this.agentInfo.info = withAgentFields(this.agentInfo.info, agent, {
|
|
10167
|
+
...fresh,
|
|
10168
|
+
models: fresh.models ?? kept
|
|
10169
|
+
});
|
|
10170
|
+
}
|
|
9936
10171
|
if (fresh.ready === true) this.signInFailed.delete(agent.driver.kind);
|
|
9937
10172
|
if (fresh.ready !== false) return null;
|
|
9938
10173
|
return fresh.problem || `${agent.driver.displayName} is not ready. ${agent.driver.signInFix()}`;
|
|
@@ -10284,6 +10519,7 @@ var OPTIONAL_AGENTS = [
|
|
|
10284
10519
|
version: "codexVersion",
|
|
10285
10520
|
ready: "codexReady",
|
|
10286
10521
|
problem: "codexProblem",
|
|
10522
|
+
models: "codexModels",
|
|
10287
10523
|
runs: "runsCodex"
|
|
10288
10524
|
},
|
|
10289
10525
|
{
|
|
@@ -10291,6 +10527,7 @@ var OPTIONAL_AGENTS = [
|
|
|
10291
10527
|
version: "cursorVersion",
|
|
10292
10528
|
ready: "cursorReady",
|
|
10293
10529
|
problem: "cursorProblem",
|
|
10530
|
+
models: "cursorModels",
|
|
10294
10531
|
runs: "runsCursor"
|
|
10295
10532
|
}
|
|
10296
10533
|
];
|
|
@@ -10298,7 +10535,8 @@ function readAgentFields(info, agent) {
|
|
|
10298
10535
|
return {
|
|
10299
10536
|
version: info[agent.version] ?? null,
|
|
10300
10537
|
ready: info[agent.ready] ?? null,
|
|
10301
|
-
problem: info[agent.problem] ?? null
|
|
10538
|
+
problem: info[agent.problem] ?? null,
|
|
10539
|
+
models: info[agent.models]
|
|
10302
10540
|
};
|
|
10303
10541
|
}
|
|
10304
10542
|
function withAgentFields(info, agent, fields) {
|
|
@@ -10306,7 +10544,9 @@ function withAgentFields(info, agent, fields) {
|
|
|
10306
10544
|
...info,
|
|
10307
10545
|
[agent.version]: fields.version,
|
|
10308
10546
|
[agent.ready]: fields.ready,
|
|
10309
|
-
[agent.problem]: fields.problem
|
|
10547
|
+
[agent.problem]: fields.problem,
|
|
10548
|
+
// A fresh probe that listed none clears what an earlier one listed.
|
|
10549
|
+
[agent.models]: fields.models
|
|
10310
10550
|
};
|
|
10311
10551
|
}
|
|
10312
10552
|
|
|
@@ -10440,12 +10680,14 @@ Usage:
|
|
|
10440
10680
|
Pair this computer with your Discovery Tree account.
|
|
10441
10681
|
--yes skips the "is this your account?" question.
|
|
10442
10682
|
dt-runner start [--max-sessions <n>] [--max-jobs <n>] [--job-log-retention-days <n>]
|
|
10443
|
-
[--job-data-retention-days <n>] [--
|
|
10683
|
+
[--job-data-retention-days <n>] [--job-shell powershell|pwsh|cmd]
|
|
10684
|
+
[--repos-dir <dir>] [--json] [--verbose]
|
|
10444
10685
|
Run: wait for agent sessions and run them with Claude Code,
|
|
10445
10686
|
and run the jobs you approve (up to --max-jobs at once).
|
|
10446
10687
|
Ended jobs' logs are removed after --job-log-retention-days
|
|
10447
10688
|
(default 30; 0 keeps them), their data folders after
|
|
10448
10689
|
--job-data-retention-days (default 0: kept).
|
|
10690
|
+
On Windows, jobs run in --job-shell (default powershell).
|
|
10449
10691
|
dt-runner status Show the configuration and check the connection.
|
|
10450
10692
|
dt-runner doctor Check Node.js, git and Claude Code on this computer.
|
|
10451
10693
|
dt-runner logout Forget this runner's token (deletes the config file).
|
|
@@ -10478,6 +10720,7 @@ async function main(argv) {
|
|
|
10478
10720
|
"max-jobs": { type: "string" },
|
|
10479
10721
|
"job-log-retention-days": { type: "string" },
|
|
10480
10722
|
"job-data-retention-days": { type: "string" },
|
|
10723
|
+
"job-shell": { type: "string" },
|
|
10481
10724
|
"repos-dir": { type: "string" },
|
|
10482
10725
|
json: { type: "boolean" },
|
|
10483
10726
|
verbose: { type: "boolean" },
|
|
@@ -10503,6 +10746,7 @@ async function main(argv) {
|
|
|
10503
10746
|
maxJobs: numberFlag(values["max-jobs"]),
|
|
10504
10747
|
jobLogRetentionDays: numberFlag(values["job-log-retention-days"]),
|
|
10505
10748
|
jobDataRetentionDays: numberFlag(values["job-data-retention-days"]),
|
|
10749
|
+
jobShell: values["job-shell"],
|
|
10506
10750
|
reposDir: values["repos-dir"],
|
|
10507
10751
|
json: values.json,
|
|
10508
10752
|
verbose: values.verbose
|
|
@@ -10585,13 +10829,20 @@ async function login(server, name, openBrowser, yes) {
|
|
|
10585
10829
|
async function start(opts) {
|
|
10586
10830
|
const logger = createLogger({ json: opts.json, verbose: opts.verbose });
|
|
10587
10831
|
const paths = runnerPaths();
|
|
10588
|
-
const
|
|
10832
|
+
const file = await readConfigFile(paths.configFile);
|
|
10833
|
+
const config = resolveConfig(file, {
|
|
10589
10834
|
maxSessions: opts.maxSessions,
|
|
10590
10835
|
maxJobs: opts.maxJobs,
|
|
10591
10836
|
jobLogRetentionDays: opts.jobLogRetentionDays,
|
|
10592
10837
|
jobDataRetentionDays: opts.jobDataRetentionDays,
|
|
10838
|
+
jobShell: opts.jobShell,
|
|
10593
10839
|
reposDir: opts.reposDir
|
|
10594
10840
|
});
|
|
10841
|
+
if (process.platform !== "win32" && (opts.jobShell !== void 0 || file?.jobShell !== void 0)) {
|
|
10842
|
+
logger.warn(
|
|
10843
|
+
`jobShell "${config.jobShell}" is ignored: jobs run in /bin/sh here. It only chooses the shell on Windows.`
|
|
10844
|
+
);
|
|
10845
|
+
}
|
|
10595
10846
|
if (!config.token) {
|
|
10596
10847
|
logger.error(`This computer is not paired yet. Run \`${runnerCommand("login")}\` first.`);
|
|
10597
10848
|
return 1;
|
|
@@ -10692,6 +10943,9 @@ async function status() {
|
|
|
10692
10943
|
console.log(`Jobs: up to ${config.maxJobs} at once`);
|
|
10693
10944
|
console.log(`Job logs: ${keptFor(config.jobLogRetentionDays)} after a job ends`);
|
|
10694
10945
|
console.log(`Job data: ${keptFor(config.jobDataRetentionDays)} after a job ends`);
|
|
10946
|
+
console.log(
|
|
10947
|
+
`Job shell: ${process.platform === "win32" ? config.jobShell : `/bin/sh (jobShell "${config.jobShell}" only applies on Windows)`}`
|
|
10948
|
+
);
|
|
10695
10949
|
console.log(`Repos: ${config.reposDir}`);
|
|
10696
10950
|
console.log(`Worktrees: ${config.worktreesDir}`);
|
|
10697
10951
|
console.log(`State: ${config.stateDir}`);
|
package/package.json
CHANGED