toolroll 0.9.125 → 0.9.126

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 (58) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +1 -1
  3. package/dist/agent-detect.js +23 -3
  4. package/dist/bounded-spawn.js +5 -36
  5. package/dist/browser/workspace.css +1 -1
  6. package/dist/browser/workspace.js +29 -29
  7. package/dist/browser-open.js +49 -0
  8. package/dist/chat-acceptance.js +1 -1
  9. package/dist/check-only.js +1 -1
  10. package/dist/cli.js +2 -2
  11. package/dist/connect-cli.js +2 -8
  12. package/dist/contracts/engine-api.js +5 -0
  13. package/dist/direct-chat.js +26 -18
  14. package/dist/doctor.js +30 -3
  15. package/dist/easy-start.js +43 -17
  16. package/dist/engine-reads.js +14 -0
  17. package/dist/evals.js +17 -19
  18. package/dist/first-run.js +5 -1
  19. package/dist/flexible-import.js +3 -2
  20. package/dist/flexible-save.js +2 -0
  21. package/dist/flexible-session.js +1 -1
  22. package/dist/flow-code.js +2 -2
  23. package/dist/invoke.js +4 -4
  24. package/dist/laptop-background.js +2 -11
  25. package/dist/linux-packages.js +46 -0
  26. package/dist/local-landing.js +26 -5
  27. package/dist/merge-checklist.js +33 -4
  28. package/dist/operate.js +16 -19
  29. package/dist/preflight.js +14 -0
  30. package/dist/process-identity.js +155 -0
  31. package/dist/quick-start.js +6 -1
  32. package/dist/release.js +8 -0
  33. package/dist/runner-process.js +9 -25
  34. package/dist/sandbox-launch.js +3 -2
  35. package/dist/sandbox-runtime.js +115 -15
  36. package/dist/sandbox-tools.js +91 -6
  37. package/dist/server/direct-chat.js +4 -3
  38. package/dist/server/merge-ready-view.js +4 -2
  39. package/dist/server/pages.js +1 -1
  40. package/dist/server/render-pages.js +1 -0
  41. package/dist/server/render-results.js +6 -6
  42. package/dist/server/render-tasks.js +2 -2
  43. package/dist/server/task-views.js +12 -8
  44. package/dist/server/tasks.js +2 -2
  45. package/dist/shown-text.js +14 -0
  46. package/dist/status-probe.js +32 -0
  47. package/dist/task-base.js +2 -2
  48. package/dist/task-status.js +7 -4
  49. package/dist/telegram-status.js +1 -1
  50. package/dist/toolroll-update.js +4 -0
  51. package/dist/trust-repair.js +187 -0
  52. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  53. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  54. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  55. package/dist/tui/linux-x64/toolroll-tui +0 -0
  56. package/dist/work-index.js +51 -3
  57. package/dist/workspace-ui.js +4 -2
  58. package/package.json +1 -1
@@ -0,0 +1,49 @@
1
+ import { spawn } from "node:child_process";
2
+ const set = (env, name) => (env[name] ?? "") !== "";
3
+ export function noBrowserReason(env = process.env, platform = process.platform) {
4
+ if (chosenCommand(env) !== null || (platform !== "darwin" && platform !== "win32" && browserEntry(env) !== null))
5
+ return null;
6
+ const display = set(env, "DISPLAY") || set(env, "WAYLAND_DISPLAY");
7
+ if ((set(env, "SSH_CONNECTION") || set(env, "SSH_TTY")) && !display)
8
+ return "this is an SSH session";
9
+ if (platform !== "darwin" && platform !== "win32" && !display)
10
+ return "there is no display here";
11
+ return null;
12
+ }
13
+ function chosenCommand(env) {
14
+ for (const name of ["TOOLROLL_BROWSER_COMMAND", "STANDING_ORDERS_BROWSER_COMMAND"])
15
+ if (set(env, name))
16
+ return env[name];
17
+ return null;
18
+ }
19
+ function browserEntry(env) {
20
+ const first = (env["BROWSER"] ?? "").split(":")[0].trim();
21
+ return first !== "" && /^[A-Za-z0-9._/+-]+$/.test(first) ? first : null;
22
+ }
23
+ export function browserCommand(url, env = process.env, platform = process.platform) {
24
+ const chosen = chosenCommand(env);
25
+ if (chosen !== null)
26
+ return [chosen, url];
27
+ if (platform === "darwin")
28
+ return ["open", url];
29
+ if (platform === "win32")
30
+ return ["cmd", "/c", "start", "", url];
31
+ return [browserEntry(env) ?? "xdg-open", url];
32
+ }
33
+ export function openAddress(url, options = {}) {
34
+ const [command, ...args] = browserCommand(url, options.env ?? process.env, options.platform ?? process.platform);
35
+ return startOpener(command, args, options);
36
+ }
37
+ export function startOpener(command, args, options = {}) {
38
+ if (noBrowserReason(options.env, options.platform) !== null)
39
+ return false;
40
+ try {
41
+ const child = (options.spawn ?? spawn)(command, [...args], { detached: true, stdio: "ignore" });
42
+ child.on("error", () => { });
43
+ child.unref();
44
+ return true;
45
+ }
46
+ catch {
47
+ return false;
48
+ }
49
+ }
@@ -10,7 +10,7 @@ export function acceptanceStatus(proof, accepted, check) {
10
10
  if (manualReviewOnly(proof))
11
11
  return "You check the remaining requirements";
12
12
  if (proof?.verdict === "verified" && check !== "passed") {
13
- return check === undefined ? "Open the result to see its checks" : check === "failed" ? "Checks failed" : check === "running" ? "Checks running" : "The check result couldn't be read";
13
+ return check === undefined ? "Open the result to see its checks" : check === "failed" ? "Checks failed" : check === "running" ? "Checks running" : check === "stale" ? "The check command changed since they ran" : "The check result couldn't be read";
14
14
  }
15
15
  return proof === null ? "No checks recorded" : ({ verified: "Checks passed", attested: "Checks reported by the agent", short: "Some required material is missing", refuted: "Saved result doesn't match the approved plan" }[proof.verdict] ?? "Some required material is missing");
16
16
  }
@@ -77,7 +77,7 @@ export function requestMissingRechecks(store, root, now) {
77
77
  if (run === null || run.finishedAt === null)
78
78
  return 0;
79
79
  const state = approvedCheckStateOf(assignmentChecksForRun(store, root, auth.run, now));
80
- if (state === "not-run" || state === "unreadable")
80
+ if (state === "not-run" || state === "unreadable" || state === "stale")
81
81
  return claimRecheck(store, auth.id, now) === null ? 0 : 1;
82
82
  if (state !== "running" && checkOnlyRecoveryProblem(store, auth.run) === null) {
83
83
  store.handle.prepare("UPDATE check_authorization SET closed_at = ? WHERE id = ? AND used_at IS NULL AND closed_at IS NULL").run(now.toISOString(), auth.id);
package/dist/cli.js CHANGED
@@ -383,6 +383,7 @@ async function dispatch(argv, write, mainOptions) {
383
383
  enrolled: async (repo) => { const loaded = await loadRepos(registryBeside(databaseFile)); return !("error" in loaded) && loaded.repos.includes(repo); },
384
384
  admit: repo => runReposCommand(["add", repo], write, mainOptions.onboard),
385
385
  startUp: () => runOperate("up", [], write, mainOptions.operate ?? {}),
386
+ setUp: async () => { const mode = (await import("./easy-start.js")).localModeRead(databaseFile); return mode === "on" || mode === "off"; },
386
387
  openBrowser: async (url) => { (await import("./operate.js")).openBrowser(url); },
387
388
  ...mainOptions.quickStart,
388
389
  });
@@ -1454,8 +1455,7 @@ async function runRemoteTuiCommand(argv, write, connectOptions) {
1454
1455
  const origin = profile.origin;
1455
1456
  const openUrl = async (path) => {
1456
1457
  const target = new URL(path, origin).href;
1457
- (await import("./operate.js")).openBrowser(target);
1458
- return `Opened ${target} in your browser.`;
1458
+ return (await import("./operate.js")).openBrowser(target) ? `Opened ${target} in your browser.` : `Open ${target} in a browser.`;
1459
1459
  };
1460
1460
  const ended = await runTuiBinary({
1461
1461
  binary: chosen.binary,
@@ -1,4 +1,4 @@
1
- import { spawn } from 'node:child_process';
1
+ import { openAddress } from './browser-open.js';
2
2
  import { constants, closeSync, existsSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
3
3
  import { request as httpRequest } from 'node:http';
4
4
  import { request as httpsRequest } from 'node:https';
@@ -347,13 +347,7 @@ function pairPostJson(origin, path, body) {
347
347
  });
348
348
  }
349
349
  function launchBrowserUrl(url) {
350
- const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
351
- const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];
352
- try {
353
- const child = spawn(cmd, args, { stdio: 'ignore', detached: true });
354
- child.unref();
355
- }
356
- catch { }
350
+ openAddress(url);
357
351
  }
358
352
  async function pairViaBrowser(origin, stderr, options) {
359
353
  const started = await pairPostJson(origin, '/api/connect/pair/start');
@@ -110,6 +110,7 @@ const workRowSchema = z.object({
110
110
  chip: z.string().nullable(),
111
111
  group: z.enum(WORK_ROW_GROUPS),
112
112
  rank: z.number().int(),
113
+ check: z.enum(["failed", "stale", "unreadable"]).optional(),
113
114
  detail: z.string().nullable(),
114
115
  problem: z.string().nullable(),
115
116
  need: needRowSchema.nullable(),
@@ -183,6 +184,9 @@ export const stepCardsSchema = z.object({
183
184
  agentChoices: z.object({ plan: z.array(z.object({ provider: z.string(), model: z.string() })), build: z.array(z.object({ provider: z.string(), model: z.string() })) }).nullable(),
184
185
  pendingAgentChange: z.object({ phase: z.enum(["plan", "build"]), provider: z.string(), model: z.string(), when: z.enum(["next-run", "restart"]), by: z.string(), at: z.string(),
185
186
  problem: z.string().nullable() }).nullable(),
187
+ landing: z.object({ words: z.string(), reverted: z.boolean() }).nullable(),
188
+ check: z.enum(["failed", "stale", "unreadable"]).optional(),
189
+ runChecks: z.object({ run: z.number().int(), level: z.enum(["quick", "full"]) }).optional(),
186
190
  room: z.string(),
187
191
  });
188
192
  export const approvalCardSchema = z.object({
@@ -485,6 +489,7 @@ export const directChatDetailSchema = z.object({
485
489
  changedFiles: z.array(z.string()),
486
490
  diffText: z.string(),
487
491
  dirty: z.boolean(),
492
+ unread: z.literal(true).optional(),
488
493
  }),
489
494
  });
490
495
  export const directChatShipPreviewSchema = z.object({
@@ -599,12 +599,29 @@ async function defaultPrepareCloneAsync(input) {
599
599
  mainDirtyFiles: cloned.mainDirtyFiles.map(sanitizeLine),
600
600
  };
601
601
  }
602
+ const UNREAD_DIFF = Object.freeze({ changedFiles: [], diffText: "", dirty: false, unread: true });
603
+ function diffCacheOf(raw) {
604
+ if (typeof raw !== "string" || raw === "")
605
+ return { changedFiles: [], diffText: "", dirty: false };
606
+ try {
607
+ const parsed = JSON.parse(raw);
608
+ return {
609
+ changedFiles: Array.isArray(parsed.changedFiles) ? parsed.changedFiles.filter((x) => typeof x === "string") : [],
610
+ diffText: typeof parsed.diffText === "string" ? parsed.diffText : "",
611
+ dirty: parsed.dirty === true,
612
+ ...(parsed.unread === true ? { unread: true } : {}),
613
+ };
614
+ }
615
+ catch {
616
+ return { changedFiles: [], diffText: "", dirty: false };
617
+ }
618
+ }
602
619
  function defaultReadDiff(input) {
603
620
  if (!existsSync(input.binding.clonePath))
604
- return { changedFiles: [], diffText: "", dirty: false };
621
+ return { ...UNREAD_DIFF };
605
622
  const verified = assertTrustedCloneGit(input.binding);
606
623
  if (!verified.ok)
607
- return { changedFiles: [], diffText: "", dirty: false };
624
+ return { ...UNREAD_DIFF };
608
625
  try {
609
626
  const statusLines = runTrustedCloneGit(input.binding, ["status", "--porcelain"])
610
627
  .split("\n")
@@ -633,7 +650,7 @@ function defaultReadDiff(input) {
633
650
  };
634
651
  }
635
652
  catch {
636
- return { changedFiles: [], diffText: "", dirty: false };
653
+ return { ...UNREAD_DIFF };
637
654
  }
638
655
  }
639
656
  function snapshotCloneTree(binding) {
@@ -882,7 +899,11 @@ export class DirectChatHost {
882
899
  }
883
900
  refreshDiffCache(thread) {
884
901
  const binding = this.bindingOf(thread);
885
- const diff = binding === null ? { ...EMPTY_DIFF } : this.readDiffFn({ binding, baseSha: thread.baseSha });
902
+ const read = binding === null ? thread.isLegacy ? null : { ...UNREAD_DIFF } : this.readDiffFn({ binding, baseSha: thread.baseSha });
903
+ const saved = diffCacheOf(this.store.handle.prepare(`SELECT diff_cache_json FROM direct_chat_thread WHERE id = ?`).get(thread.id)?.["diff_cache_json"]);
904
+ if (read === null)
905
+ return saved;
906
+ const diff = read.unread === true ? { ...saved, unread: true } : { changedFiles: read.changedFiles, diffText: read.diffText, dirty: read.dirty };
886
907
  this.store.handle
887
908
  .prepare(`UPDATE direct_chat_thread SET diff_cache_json = ? WHERE id = ?`)
888
909
  .run(JSON.stringify(diff), thread.id);
@@ -2039,20 +2060,7 @@ export class DirectChatHost {
2039
2060
  mainDirtyFiles = [];
2040
2061
  }
2041
2062
  }
2042
- let diffCache = { changedFiles: [], diffText: "", dirty: false };
2043
- if (typeof raw["diff_cache_json"] === "string" && raw["diff_cache_json"] !== "") {
2044
- try {
2045
- const parsed = JSON.parse(raw["diff_cache_json"]);
2046
- diffCache = {
2047
- changedFiles: Array.isArray(parsed.changedFiles) ? parsed.changedFiles.filter((x) => typeof x === "string") : [],
2048
- diffText: typeof parsed.diffText === "string" ? parsed.diffText : "",
2049
- dirty: parsed.dirty === true,
2050
- };
2051
- }
2052
- catch {
2053
- diffCache = { changedFiles: [], diffText: "", dirty: false };
2054
- }
2055
- }
2063
+ const diffCache = diffCacheOf(raw["diff_cache_json"]);
2056
2064
  return {
2057
2065
  id: String(raw["id"]),
2058
2066
  owner: String(raw["owner"]),
package/dist/doctor.js CHANGED
@@ -7,8 +7,23 @@ import { envelopeJson } from "./envelope.js";
7
7
  import { GIT_FLOOR_WORDS, installedGitFloorProblem } from "./git-floor.js";
8
8
  import { run as runCommand } from "./exec.js";
9
9
  import { OWN_KEY_ENV } from "./keys.js";
10
+ import { processIdentityProblem } from "./process-identity.js";
10
11
  import { ALL_CREDENTIAL_ENV } from "./provider.js";
11
- import { SANDBOX_RUNTIME, sandboxRuntimeProblem, sandboxRuntimeWords } from "./sandbox-runtime.js";
12
+ import { SANDBOX_RUNTIME, sandboxAdviceLines, sandboxRuntimeDiagnosis, sandboxRuntimeWords, UNCONFINED_OPT_IN } from "./sandbox-runtime.js";
13
+ async function agentTrustProblems(env, uid) {
14
+ const { excludedFolders, statusBinaryDiagnosis } = await import("./status-probe.js");
15
+ const { agentTrustWords } = await import("./agent-detect.js");
16
+ const { platformAcl } = await import("./trusted-path.js");
17
+ const untrusted = await excludedFolders({}) ?? [];
18
+ const path = (env["PATH"] ?? "").split(":").filter(one => one.startsWith("/")).join(":");
19
+ const found = [];
20
+ for (const [binary, name] of [["claude", "Claude Code"], ["codex", "Codex"]]) {
21
+ const words = agentTrustWords(statusBinaryDiagnosis(binary, { path, uid, untrusted, acl: platformAcl() }));
22
+ if (words !== null)
23
+ found.push({ name, problem: words });
24
+ }
25
+ return found;
26
+ }
12
27
  const CREDENTIAL_NAME = /(?:^|_)(?:API_?KEY|ACCESS_?KEY|PRIVATE_?KEY|SECRET|SECRET_?KEY|TOKEN|AUTH_?TOKEN|PASSWORD|PASSWD|CREDENTIALS?|PAT)(?:_|$)/i;
13
28
  const POINTER_NAME = /(?:_FILE|_PATH|_DIR|_SOCK|_URL|_HOST)$/i;
14
29
  const CREDENTIAL_FLAG = /^--?(?:token|api-?key|key|secret|password|auth-token)$/i;
@@ -343,6 +358,8 @@ export function doctorLines(report) {
343
358
  const lines = [];
344
359
  if (report.git?.problem != null)
345
360
  lines.push(`Git: ${report.git.problem}`, "");
361
+ if (report.processIdentity?.problem != null)
362
+ lines.push(`Processes: ${report.processIdentity.problem}. Toolroll's worker won't start until it can.`, "");
346
363
  if (report.findings.length === 0 && report.unreadable.length === 0)
347
364
  lines.push("No secrets found in Toolroll's service. A build can't read a key from it.");
348
365
  else if (report.findings.length > 0)
@@ -359,8 +376,13 @@ export function doctorLines(report) {
359
376
  }
360
377
  for (const note of report.notes)
361
378
  lines.push("", `Note: ${note}`);
379
+ const optIn = report.sandbox?.repair?.includes(UNCONFINED_OPT_IN) === true;
362
380
  if (report.sandbox !== undefined)
363
- lines.push("", `Sandbox: ${sandboxRuntimeWords()}${report.sandbox.problem === null ? ", working here." : `, not available here: ${report.sandbox.problem}. Builds don't start unless an instance operator allows unconfined agents.`}`);
381
+ lines.push("", `Sandbox: ${sandboxRuntimeWords()}${report.sandbox.problem === null ? ", working here." : `, not available here: ${report.sandbox.problem}. Builds don't start ${optIn ? "here." : "unless an instance operator allows unconfined agents."}`}`);
382
+ if (report.sandbox?.repair !== undefined && report.sandbox.repair.length > 0)
383
+ lines.push(...report.sandbox.repair, ...report.sandbox.kind === "trust" ? ["Then run `toolroll doctor` again."] : []);
384
+ for (const agent of report.agents ?? [])
385
+ lines.push("", `${agent.name}: ${agent.problem}`);
364
386
  if (report.checked.length > 0)
365
387
  lines.push("", "Checked:", ...report.checked.map(one => ` ${one}`));
366
388
  return lines;
@@ -378,10 +400,15 @@ export async function runDoctorCommand(argv, write, deps = {}) {
378
400
  return 2;
379
401
  }
380
402
  const report = await auditServiceEnvironment(deps);
381
- report.sandbox = { engine: SANDBOX_RUNTIME.name, version: SANDBOX_RUNTIME.version, problem: sandboxRuntimeProblem() };
403
+ const diagnosis = sandboxRuntimeDiagnosis();
404
+ report.sandbox = { engine: SANDBOX_RUNTIME.name, version: SANDBOX_RUNTIME.version, problem: diagnosis.ok ? null : diagnosis.why, ...(diagnosis.ok ? {} : { kind: diagnosis.kind, repair: sandboxAdviceLines(diagnosis) }) };
405
+ report.agents = await (deps.agentProblems ?? (() => agentTrustProblems(deps.env ?? process.env, deps.uid ?? process.getuid?.() ?? -1)))();
382
406
  report.git = { floor: GIT_FLOOR_WORDS, problem: deps.gitFloorProblem === undefined ? installedGitFloorProblem() : deps.gitFloorProblem };
383
407
  if (report.git.problem !== null)
384
408
  report.ok = false;
409
+ report.processIdentity = { problem: deps.processIdentityProblem === undefined ? processIdentityProblem() : deps.processIdentityProblem };
410
+ if (report.processIdentity.problem !== null)
411
+ report.ok = false;
385
412
  if (json)
386
413
  write(envelopeJson({ command: "doctor", ...report }));
387
414
  else
@@ -60,9 +60,33 @@ export async function runEasyStart(mode, args, seams) {
60
60
  if (refusedTooDeep())
61
61
  return EXIT.refused;
62
62
  const sandbox = await seams.sandbox();
63
+ const others = await (seams.prerequisites?.() ?? Promise.resolve({ blockers: [], advisories: [] }));
64
+ const blockers = [];
65
+ let passwordInstead = false;
63
66
  if (sandbox.missing.length > 0) {
64
67
  const { missingSandboxToolsWords } = await import("./sandbox-runtime.js");
65
- for (const line of missingSandboxToolsWords(sandbox.missing))
68
+ blockers.push(missingSandboxToolsWords(sandbox.missing));
69
+ }
70
+ else if (sandbox.problem !== null) {
71
+ const { UNCONFINED_OPT_IN } = await import("./sandbox-runtime.js");
72
+ blockers.push([`Agents can't run in a sandbox here: ${sandbox.problem}.`, ...(sandbox.repair ?? []).filter(line => line !== UNCONFINED_OPT_IN)]);
73
+ passwordInstead = others.blockers.length === 0;
74
+ }
75
+ blockers.push(...others.blockers);
76
+ if (blockers.length > 0) {
77
+ if (blockers.length === 1) {
78
+ for (const line of blockers[0])
79
+ write(line);
80
+ if (sandbox.missing.length === 0 && sandbox.problem !== null)
81
+ write("Then run toolroll again.");
82
+ }
83
+ else {
84
+ write("Toolroll can't start on this computer yet. Fix these, then run toolroll again:");
85
+ blockers.forEach((lines, index) => lines.forEach((line, at) => write(at === 0 ? `${index + 1}. ${line}` : ` ${line}`)));
86
+ }
87
+ if (passwordInstead)
88
+ write("To start now with a password instead, run `toolroll up`. Agents then run only once the sandbox works, or if an instance operator lets them run without OS confinement (`toolroll config unconfined-agents allow`).");
89
+ for (const line of others.advisories)
66
90
  write(line);
67
91
  return EXIT.refused;
68
92
  }
@@ -147,9 +171,12 @@ export async function runEasyStart(mode, args, seams) {
147
171
  return EXIT.ok;
148
172
  };
149
173
  if (seams.localMode() !== "on") {
150
- const problem = (await seams.sandbox()).problem;
174
+ const { problem, repair } = await seams.sandbox();
151
175
  if (problem !== null)
152
176
  write(`Toolroll can't start without a password here: ${problem}.`);
177
+ if (problem !== null)
178
+ for (const line of repair ?? [])
179
+ write(line);
153
180
  const saved = seams.savedLogin();
154
181
  write(saved === null ? `Toolroll is on ${url}. Sign in with your password.` : `Toolroll is on ${url}. Your password: run \`cat -- '${saved.replaceAll("'", "'\\''")}'\``);
155
182
  await seams.openBrowser(url);
@@ -193,17 +220,14 @@ export async function runEasyStart(mode, args, seams) {
193
220
  const target = new URL(setup ? "/password/set" : `${page}#agents`, url);
194
221
  if (setup)
195
222
  target.searchParams.set("next", page);
196
- await seams.openBrowser(target.href);
197
- return "In the browser, open Agents → Change agents and save the new builder.";
223
+ const opened = await seams.openBrowser(target.href);
224
+ return opened === false ? `Open ${target.href} in a browser, then Agents → Change agents and save the new builder.` : "In the browser, open Agents → Change agents and save the new builder.";
198
225
  },
199
226
  openBrowser: async (page) => {
200
- if (page === "projects") {
201
- await seams.openBrowser(new URL("/projects", url).href);
202
- return "Opened Projects in your browser.";
203
- }
204
- if (page === "lead-providers") {
205
- await seams.openBrowser(new URL("/settings/lead#lead-config", url).href);
206
- return "Opened Lead settings in your browser.";
227
+ if (page === "projects" || page === "lead-providers") {
228
+ const href = new URL(page === "projects" ? "/projects" : "/settings/lead#lead-config", url).href;
229
+ const opened = await seams.openBrowser(href);
230
+ return opened === false ? `Open ${href} in a browser.` : `Opened ${page === "projects" ? "Projects" : "Lead settings"} in your browser.`;
207
231
  }
208
232
  const opened = await seams.openSignedIn(page);
209
233
  return opened.ok ? "Opened in your browser." : `The browser couldn't be opened: ${opened.message}.`;
@@ -287,12 +311,14 @@ export function defaultEasyStartSeams(options) {
287
311
  remote: (await import("./local-owner.js")).localOwnerRequested(),
288
312
  }),
289
313
  sandbox: async () => {
290
- const { missingLinuxSandboxTools, sandboxRuntimeProblem } = await import("./sandbox-runtime.js");
291
- if (process.platform !== "linux")
292
- return { missing: [], problem: sandboxRuntimeProblem() };
293
- const missing = missingLinuxSandboxTools();
294
- return { missing, problem: missing.length > 0 ? null : sandboxRuntimeProblem() };
314
+ const { missingLinuxSandboxTools, sandboxAdviceLines, sandboxRuntimeDiagnosis } = await import("./sandbox-runtime.js");
315
+ const missing = process.platform === "linux" ? missingLinuxSandboxTools() : [];
316
+ if (missing.length > 0)
317
+ return { missing, problem: null };
318
+ const diagnosis = sandboxRuntimeDiagnosis();
319
+ return diagnosis.ok ? { missing, problem: null } : { missing, problem: diagnosis.why, repair: sandboxAdviceLines(diagnosis) };
295
320
  },
321
+ prerequisites: async () => (await import("./preflight.js")).startPrerequisites(),
296
322
  passwordByLaptopStart: () => {
297
323
  const store = openStoreReadOnly(file);
298
324
  if (store === null)
@@ -323,7 +349,7 @@ export function defaultEasyStartSeams(options) {
323
349
  },
324
350
  spawnUp: args => spawnOwnedUp(args, { cwd, databaseFile: file }),
325
351
  runUpForeground: async (args) => (await import("./operate.js")).runOperate("up", [...args, "--db", file], options.write, options.operate ?? {}),
326
- openBrowser: async (url) => { (await import("./operate.js")).openBrowser(url); },
352
+ openBrowser: async (url) => (await import("./operate.js")).openBrowser(url),
327
353
  openSignedIn: page => openLocalSignIn(file, options.build, page === undefined ? {} : { then: page }),
328
354
  openTui: async (session) => {
329
355
  const { chooseTuiBinary, runTuiBinary } = await import("./tui-launch.js");
@@ -3,6 +3,8 @@ import { codexOfflineDependencySuggestion, failedAttemptSentence, latestFinished
3
3
  import { pendingAgentChangeOf, planSourceOf, retryPinsOf } from "./local-owner-acts.js";
4
4
  import { assignmentOf, owedAcceptance, personCompletionRefusal } from "./assignment.js";
5
5
  import { assignmentCardOf } from "./assignment-ui.js";
6
+ import { landedNowOf } from "./merge-checklist.js";
7
+ import { liveQuickCommand } from "./check-levels.js";
6
8
  import { assignmentStageOf, stageOfCode } from "./task-status.js";
7
9
  import { taskRoad } from "./first-run.js";
8
10
  import { stepRowsOf } from "./workspace-ui.js";
@@ -121,9 +123,21 @@ export function stepCardsOf({ store, family, now, access, evidenceRoot, viewer =
121
123
  scopeDigest: scope?.digest ?? null,
122
124
  agentChoices: scope === null || !withChoices ? null : agentChoicesOf(store, current.id, ref, now),
123
125
  pendingAgentChange: ref === null ? null : pendingAgentChangeOf(store, ref.id),
126
+ landing: assignment === null ? null : landedNowOf(store, assignment),
127
+ ...(card?.status.check === "failed" || card?.status.check === "stale" || card?.status.check === "unreadable" ? { check: card.status.check } : {}),
128
+ ...(() => { const offer = runChecksOfferOf(store, assignment, card?.status.check ?? null); return offer === null ? {} : { runChecks: offer }; })(),
124
129
  room: `task:${encodeURIComponent(root.id)}`,
125
130
  };
126
131
  }
132
+ function runChecksOfferOf(store, assignment, check) {
133
+ if (check !== "failed" && check !== "stale" && check !== "unreadable" && check !== "not-run")
134
+ return null;
135
+ const receipt = assignment?.receipt ?? null;
136
+ if (receipt === null || receipt.head === null || receipt.completionKind === "research-report" || assignment.repo === null || store.isDemo())
137
+ return null;
138
+ const level = store.liveVerifyCommand(assignment.repo) !== null ? "full" : liveQuickCommand(store, assignment.repo) !== null ? "quick" : null;
139
+ return level === null ? null : { run: receipt.runId, level };
140
+ }
127
141
  export const SHELL_NO_RESULT = "This build has no saved result yet. Wait for it to finish (or stop it), then open the build shell.";
128
142
  export const SHELL_NO_COMMIT = "This build has no saved commit to open a terminal on.";
129
143
  function shellOf(store, family, runId) {
package/dist/evals.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { identityProvider, lstartToIso, processIdentity } from "./process-identity.js";
1
2
  import { execFileSync, spawn } from "node:child_process";
2
3
  import { createHash, randomBytes } from "node:crypto";
3
4
  import { closeSync, constants, lstatSync, mkdirSync, mkdtempSync, openSync, readdirSync, realpathSync, rmSync, writeSync } from "node:fs";
@@ -785,33 +786,30 @@ export function recoverEvalCampaigns(store, now, options = {}) {
785
786
  return out;
786
787
  }
787
788
  export function processStartOf(pid) {
788
- if (process.platform === "win32" || !Number.isSafeInteger(pid) || pid <= 0)
789
+ if (!Number.isSafeInteger(pid) || pid <= 0)
789
790
  return null;
790
- try {
791
- const raw = execFileSync("/bin/ps", ["-p", String(pid), "-o", "lstart="], {
792
- encoding: "utf8", env: { PATH: "/usr/bin:/bin", LC_ALL: "C", TZ: "UTC" }, stdio: ["ignore", "pipe", "ignore"], maxBuffer: 1024, timeout: 2_000, killSignal: "SIGKILL",
793
- }).trim().replace(/ +/g, " ");
794
- return /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{1,2} \d{2}:\d{2}:\d{2} \d{4}$/.test(raw) ? raw : null;
795
- }
796
- catch {
797
- return null;
798
- }
791
+ return processIdentity(pid);
799
792
  }
800
793
  export function runnerMayBeAlive(pid, started) {
801
794
  if (!processMayBeAlive(pid, false))
802
795
  return false;
803
- const was = started === null ? null : startMs(started);
804
- const now = processStartOf(pid);
805
- const is = now === null ? null : startMs(now);
796
+ if (started === null)
797
+ return true;
798
+ const provider = identityProvider(started);
799
+ if (provider === null)
800
+ return true;
801
+ const now = processIdentity(pid, provider);
802
+ if (now === null)
803
+ return true;
804
+ if (provider === "proc")
805
+ return now === started;
806
+ const was = startMs(started), is = startMs(now);
806
807
  return was === null || is === null || Math.abs(is - was) <= 2_000;
807
808
  }
808
809
  function startMs(raw) {
809
- const match = /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{1,2}) (\d{2}:\d{2}:\d{2}) (\d{4})$/.exec(raw);
810
- if (match === null)
811
- return null;
812
- const utc = `${match[1]}, ${match[3].padStart(2, "0")} ${match[2]} ${match[5]} ${match[4]} GMT`;
813
- const ms = Date.parse(utc);
814
- return Number.isFinite(ms) && new Date(ms).toUTCString() === utc ? ms : null;
810
+ const iso = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(raw) ? raw : lstartToIso(raw);
811
+ const ms = iso === null ? NaN : Date.parse(iso);
812
+ return Number.isFinite(ms) ? ms : null;
815
813
  }
816
814
  export function abandonEvalCampaign(store, input) {
817
815
  return store.transact(() => {
package/dist/first-run.js CHANGED
@@ -2,6 +2,7 @@ import { run } from "./exec.js";
2
2
  import { hardenedGit } from "./teardown-git.js";
3
3
  import { githubIssues } from "./issues.js";
4
4
  import { START_BUILDER_HREF } from "./needs-you.js";
5
+ import { CHECKS_OUT_OF_DATE } from "./task-status.js";
5
6
  import { firstRunAgentLines, firstTaskOf, withNext } from "./agent-detect.js";
6
7
  export const SIGN_IN_COMMAND = "claude auth login";
7
8
  export const SANDBOX_COMMAND = "npx toolroll demo";
@@ -144,6 +145,7 @@ export function taskRoad(read, approved, built, facts) {
144
145
  case "running": return { ...step, state: "current", say: "Checks running" };
145
146
  case "failed": return { ...step, say: "Checks failed" };
146
147
  case "unreadable": return { ...step, say: "Checks unreadable" };
148
+ case "stale": return { ...step, say: CHECKS_OUT_OF_DATE };
147
149
  default: return step;
148
150
  }
149
151
  }
@@ -152,7 +154,8 @@ export function taskRoad(read, approved, built, facts) {
152
154
  if (step.state === "current")
153
155
  return facts.checks === "failed" ? { ...step, state: "stuck", say: "Checks failed" }
154
156
  : facts.checks === "unreadable" ? { ...step, state: "stuck", say: "Checks unreadable" }
155
- : facts.checks === "running" ? { ...step, say: "Checks running" } : step;
157
+ : facts.checks === "stale" ? { ...step, state: "stuck", say: CHECKS_OUT_OF_DATE }
158
+ : facts.checks === "running" ? { ...step, say: "Checks running" } : step;
156
159
  switch (facts.checks ?? null) {
157
160
  case "passed": return step;
158
161
  case "running": return { ...step, state: "current", say: "Checks running" };
@@ -160,6 +163,7 @@ export function taskRoad(read, approved, built, facts) {
160
163
  case "not-run": return { ...step, state: "skipped", say: "Checks not run" };
161
164
  case "off": return { ...step, state: "skipped", say: "Checks at release" };
162
165
  case "unreadable": return { ...step, state: "stuck", say: "Checks unreadable", ...(complete ? {} : { needsYou: true }) };
166
+ case "stale": return { ...step, state: "stuck", say: CHECKS_OUT_OF_DATE, ...(complete ? {} : { needsYou: true }) };
163
167
  default: return { ...step, state: "skipped" };
164
168
  }
165
169
  });
@@ -820,9 +820,10 @@ export async function projectMergeHint(store, input) {
820
820
  const head = await read(project, ["symbolic-ref", "-q", "HEAD"]);
821
821
  const ref = head.code === 0 ? head.stdout.trim() : "";
822
822
  if (!ref.startsWith("refs/heads/"))
823
- return { repo: project, branch: null, fastForward: false };
823
+ return { repo: project, branch: null, fastForward: false, contained: false };
824
824
  const ancestor = await read(project, ["merge-base", "--is-ancestor", "--end-of-options", ref, input.candidate]);
825
- return { repo: project, branch: ref.slice("refs/heads/".length), fastForward: ancestor.code === 0 };
825
+ const contained = await read(project, ["merge-base", "--is-ancestor", "--end-of-options", input.candidate, ref]);
826
+ return { repo: project, branch: ref.slice("refs/heads/".length), fastForward: ancestor.code === 0, contained: contained.code === 0 };
826
827
  }
827
828
  export async function settleInterruptedImport(store, input) {
828
829
  const thread = flexibleThread(store, input.thread);
@@ -37,6 +37,8 @@ async function nextWords(store, thread, candidate, branch, runner) {
37
37
  const ff = gitCommand(hint.repo, ["merge", "--ff-only", branch]), merge = gitCommand(hint.repo, ["merge", branch]);
38
38
  if (hint.branch === null)
39
39
  return { next: `To use it: check out the branch you want it on, then ${ff === null ? UNSAFE_FOLDER(`git merge --ff-only ${branch}`) : `run \`${ff}\`.`}`, command: ff };
40
+ if (hint.contained)
41
+ return { next: `It's already in ${hint.branch}: nothing to merge.`, command: null };
40
42
  if (hint.fastForward)
41
43
  return { next: ff === null ? `To put it on ${hint.branch}: ${UNSAFE_FOLDER(`git merge --ff-only ${branch}`)}` : `To put it on ${hint.branch}: \`${ff}\`.`, command: ff };
42
44
  return { next: `${hint.branch} moved since the thread started, so it won't fast-forward. ${merge === null ? UNSAFE_FOLDER(`git merge ${branch}`) : `To merge it: \`${merge}\`.`}`, command: merge };
@@ -1363,7 +1363,7 @@ export async function flexibleThreadChanges(store, input) {
1363
1363
  return { tip: read.tip, changes: { ok: true, patch: read.patch, truncated: read.truncated } };
1364
1364
  }
1365
1365
  function saveInsteadWords(thread) {
1366
- return `To use its work now, save it as a branch in your repository instead (S on the thread in \`toolroll\`, or \`toolroll thread save ${thread.slice(0, 8)}\`).`;
1366
+ return `To use its work now, save it as a branch in your repository instead (S on the thread, or \`toolroll thread save ${thread.slice(0, 8)}\`).`;
1367
1367
  }
1368
1368
  export function flexibleThreadEdited(sessions, input) {
1369
1369
  const session = sessions.threads.get(input.thread);
package/dist/flow-code.js CHANGED
@@ -6,7 +6,7 @@ import { dirname, join } from "node:path";
6
6
  import { buildCacheEnv, buildCacheFolder, checkLaunchRoot, fenceFor, linuxFenceAvailable, macosFenceAvailable, runFolders, taskBoundary, trustedWorktreeBinding, writeAllowlist } from "./agent-fence.js";
7
7
  import { readDenyPath } from "./project-sandbox.js";
8
8
  import { poolRootOf } from "./worktree.js";
9
- import { linuxSandboxToolsWords } from "./sandbox-runtime.js";
9
+ import { noConfinementWords } from "./sandbox-runtime.js";
10
10
  import { SETUP_ENV_ALLOWLIST, SETUP_ENV_DENYLIST } from "./builder.js";
11
11
  import { redactSecretLines, scanForSecrets } from "./evidence.js";
12
12
  import { scrubSecrets } from "./flow-secrets.js";
@@ -130,7 +130,7 @@ export async function flowLaunch(store, options) {
130
130
  const available = options.available ?? (() => macosFenceAvailable() || linuxFenceAvailable());
131
131
  const fenced = available();
132
132
  if (!fenced && !store.unfencedAgentsAllowed()) {
133
- return { problem: "This machine can't confine the flow's script (no macOS sandbox, no working bubblewrap), so it didn't run. Install " + linuxSandboxToolsWords() + " (Linux), or an instance operator allows unconfined agents with `toolroll config unconfined-agents allow`." };
133
+ return { problem: noConfinementWords("the flow's script", "it didn't run") };
134
134
  }
135
135
  let own;
136
136
  try {
package/dist/invoke.js CHANGED
@@ -28,7 +28,7 @@ import { localModeOn } from "./local-owner.js";
28
28
  import { CHECK_STAMP_VERSION, EVERYWHERE, unfencedStamp } from "./check-stamp.js";
29
29
  import { CHECK_ACCESS_DEFAULT, checkAccessHere, localModeCap, narrowestAccess, narrowestNetwork, signInsAvailable } from "./check-access.js";
30
30
  import { readDenyPath } from "./project-sandbox.js";
31
- import { linuxSandboxToolsWords, sandboxRuntimeWords } from "./sandbox-runtime.js";
31
+ import { noConfinementWords, sandboxRuntimeWords } from "./sandbox-runtime.js";
32
32
  import { canonicalJson } from "./canonical-json.js";
33
33
  import { deliveredFile } from "./code-map-admission.js";
34
34
  import { skillsGrant } from "./skills-manifest.js";
@@ -337,7 +337,7 @@ export async function invokeAgent(store, runId, spec, invocation, options) {
337
337
  codexHome?.cleanup();
338
338
  removeAgentDatabase(isolatedDb.dir);
339
339
  return { kind: "refused", reason: "containment", providerVersion: attested?.version ?? null,
340
- diagnostic: "This machine can't confine an agent (no macOS sandbox, no working bubblewrap), so nothing was started. Install " + linuxSandboxToolsWords() + " (Linux), or an instance operator allows unconfined agents with `toolroll config unconfined-agents allow`." };
340
+ diagnostic: noConfinementWords("an agent", "nothing was started") };
341
341
  }
342
342
  let egress = null;
343
343
  let runTemp = null;
@@ -791,7 +791,7 @@ export function fencedCommands(store, runId, writes, inner, available = () => ma
791
791
  stampLaunch(store, [runId], unfencedStamp());
792
792
  return inner(file, args, options);
793
793
  }
794
- return { code: 1, stdout: "", stderr: "This machine can't confine the build's commands (no macOS sandbox, no working bubblewrap), so they didn't run. Install " + linuxSandboxToolsWords() + " (Linux), or an instance operator allows unconfined agents with `toolroll config unconfined-agents allow`.\n", timedOut: false, notFound: false };
794
+ return { code: 1, stdout: "", stderr: `${noConfinementWords("the build's commands", "they didn't run")}\n`, timedOut: false, notFound: false };
795
795
  }
796
796
  const own = realpathSync(mkdtempSync(join(checkLaunchRoot(), "so-cmd-")));
797
797
  try {
@@ -847,7 +847,7 @@ export function fencedCheckoutCommands(store, repo, checkout, inner, available =
847
847
  stampLaunch(store, stampRuns, unfencedStamp());
848
848
  return inner(file, args, options);
849
849
  }
850
- return { code: 1, stdout: "", stderr: "This machine can't confine the project's checks (no macOS sandbox, no working bubblewrap), so they didn't run. Install " + linuxSandboxToolsWords() + " (Linux), or an instance operator allows unconfined agents with `toolroll config unconfined-agents allow`.\n", timedOut: false, notFound: false };
850
+ return { code: 1, stdout: "", stderr: `${noConfinementWords("the project's checks", "they didn't run")}\n`, timedOut: false, notFound: false };
851
851
  }
852
852
  const databaseFile = store.databaseFile();
853
853
  if (databaseFile === null) {
@@ -1,4 +1,4 @@
1
- import { execFileSync } from "node:child_process";
1
+ import { processParentId } from "./process-identity.js";
2
2
  import { existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
3
3
  import { createServer } from "node:net";
4
4
  import { homedir, hostname } from "node:os";
@@ -52,16 +52,7 @@ function installedBuild(entry) {
52
52
  }
53
53
  }
54
54
  function parentPid(pid) {
55
- if (!Number.isSafeInteger(pid) || pid <= 1 || process.platform === "win32")
56
- return null;
57
- try {
58
- const raw = execFileSync("/bin/ps", ["-p", String(pid), "-o", "ppid="], { encoding: "utf8", env: { PATH: "/usr/bin:/bin", LC_ALL: "C" }, stdio: ["ignore", "pipe", "ignore"], timeout: 2_000 });
59
- const parent = Number(raw.trim());
60
- return Number.isSafeInteger(parent) && parent > 0 ? parent : null;
61
- }
62
- catch {
63
- return null;
64
- }
55
+ return processParentId(pid);
65
56
  }
66
57
  function portIsFree(port) {
67
58
  return new Promise(resolve => {