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,46 @@
1
+ import { existsSync } from "node:fs";
2
+ const PROGRAMS = [
3
+ ["apt", ["/usr/bin/apt-get"]],
4
+ ["dnf", ["/usr/bin/dnf", "/usr/bin/dnf5"]],
5
+ ["zypper", ["/usr/bin/zypper"]],
6
+ ["pacman", ["/usr/bin/pacman"]],
7
+ ["apk", ["/sbin/apk", "/usr/sbin/apk", "/usr/bin/apk"]],
8
+ ];
9
+ const NAMES = { apt: "Debian, Ubuntu", dnf: "Fedora", zypper: "openSUSE", pacman: "Arch", apk: "Alpine" };
10
+ const RENAMED = { which: { apt: "debianutils" } };
11
+ export function packageSystem(exists = existsSync, euid = process.geteuid?.() ?? -1) {
12
+ const manager = PROGRAMS.find(([, paths]) => paths.some(path => exists(path)))?.[0] ?? null;
13
+ return { manager, root: euid === 0 };
14
+ }
15
+ export function managerLine(manager, packages, root) {
16
+ const sudo = root ? "" : "sudo ";
17
+ const named = [...new Set(packages.map(one => RENAMED[one]?.[manager] ?? one))].join(" ");
18
+ switch (manager) {
19
+ case "apt": return `${sudo}apt update && ${sudo}apt install ${named}`;
20
+ case "dnf": return `${sudo}dnf install ${named}`;
21
+ case "zypper": return `${sudo}zypper install ${named}`;
22
+ case "pacman": return `${sudo}pacman -S --needed ${named}`;
23
+ case "apk": return `${sudo}apk add ${named}`;
24
+ }
25
+ }
26
+ export function installLine(packages, system = packageSystem()) {
27
+ if (system.manager !== null)
28
+ return managerLine(system.manager, packages, system.root);
29
+ return PROGRAMS.map(([manager]) => `${managerLine(manager, packages, system.root)} (${NAMES[manager]})`).join("; ");
30
+ }
31
+ export function managerReinstall(manager, packages, root) {
32
+ const sudo = root ? "" : "sudo ";
33
+ const named = [...new Set(packages.map(one => RENAMED[one]?.[manager] ?? one))].join(" ");
34
+ switch (manager) {
35
+ case "apt": return `${sudo}apt update && ${sudo}apt install --reinstall ${named}`;
36
+ case "dnf": return `${sudo}dnf reinstall ${named}`;
37
+ case "zypper": return `${sudo}zypper install -f ${named}`;
38
+ case "pacman": return `${sudo}pacman -S ${named}`;
39
+ case "apk": return `${sudo}apk fix ${named}`;
40
+ }
41
+ }
42
+ export function reinstallLine(packages, system = packageSystem()) {
43
+ if (system.manager !== null)
44
+ return managerReinstall(system.manager, packages, system.root);
45
+ return PROGRAMS.map(([manager]) => `${managerReinstall(manager, packages, system.root)} (${NAMES[manager]})`).join("; ");
46
+ }
@@ -10,7 +10,7 @@ import { recordActionWhole } from "./action-ledger.js";
10
10
  import { reproveApprover, verifyApproverStanding } from "./principal.js";
11
11
  import { localActNow, LOCAL_OWNER_LAPSED } from "./local-owner.js";
12
12
  import { publishingOf } from "./pull-request-flow.js";
13
- import { wholeChangeBaseOf } from "./task-base.js";
13
+ import { readGit, wholeChangeBaseOf } from "./task-base.js";
14
14
  export const LAND_DESTINATION = "land destination";
15
15
  export const LAND_INTENT = "land intent";
16
16
  export const LAND_SETTLED = "land settled";
@@ -210,8 +210,10 @@ export async function readLanding(store, taskId, access, now, options) {
210
210
  if (candidate === null || !OID.test(candidate) || receipt.completionKind === "research-report")
211
211
  return refuse("nothing", "This result has no commit to land.");
212
212
  const landed = landingOf(store, assignment.rootId);
213
- if (landed !== null && !landed.undone && landed.intent.candidate === candidate)
214
- return { ok: true, landed: { at: landed.at, ref: landed.intent.ref, commit: landed.intent.commit, mode: landed.intent.mode } };
213
+ if (landed !== null && !landed.undone && landed.intent.candidate === candidate) {
214
+ const reverted = landedStanding(store, assignment.rootId, readGit)?.reverted === true;
215
+ return { ok: true, landed: { at: landed.at, ref: landed.intent.ref, commit: landed.intent.commit, mode: landed.intent.mode, ...(reverted ? { reverted } : {}) } };
216
+ }
215
217
  const checks = receipt.checks.status === "passed" ? "passed" : !projectCheckSet(store, project.repo) && receipt.checks.status === "not-run" ? "none" : null;
216
218
  if (checks === null) {
217
219
  if (receipt.checks.status === "failed")
@@ -225,10 +227,19 @@ export async function readLanding(store, taskId, access, now, options) {
225
227
  return destination;
226
228
  const run = store.getRun(receipt.runId);
227
229
  const base = run === null || run.branch === null ? null : wholeChangeBaseOf(store, run.taskRef, run.branch) ?? run.baseRevision;
228
- return planFor(git, project, destination, { kind: "land", taskId: receipt.taskId, rootId: assignment.rootId, runId: receipt.runId, receipt: receipt.digest, completion: assignment.completion.digest, candidate, checks,
230
+ const read = await planFor(git, project, destination, { kind: "land", taskId: receipt.taskId, rootId: assignment.rootId, runId: receipt.runId, receipt: receipt.digest, completion: assignment.completion.digest, candidate, checks,
229
231
  bindings: checkBindingsOf(store, project.repo) }, { base, message: squashMessage(store.getTask(receipt.taskId)?.title ?? null, receipt.taskId),
230
232
  time: Math.max(0, Math.floor(Date.parse(assignment.completion.at) / 1000) || 0),
231
233
  handedOff: handoffsOf(store, project.repo, assignment.rootId).filter(one => one.candidate === candidate).map(one => one.commit) });
234
+ if (!read.ok && read.reason === "nothing") {
235
+ const seen = recognisedOnBranch(store, project.repo, assignment.rootId, candidate, readGit);
236
+ if (seen !== null && seen.reverted)
237
+ return refuse("nothing", `${seen.words}.`);
238
+ }
239
+ return read;
240
+ }
241
+ export function landedLine(landed) {
242
+ return `Landed on ${landed.ref.replace(/^refs\/heads\//, "")} (${short(landed.commit)})${landed.reverted === true ? " · a later commit reverted it" : ""}.`;
232
243
  }
233
244
  async function destinationOf(store, project, git, into) {
234
245
  const recorded = recordedDestination(store, project.repo);
@@ -485,7 +496,7 @@ export async function land(store, taskId, input, authority, access, now, options
485
496
  if (!read.ok)
486
497
  return read;
487
498
  if (!("plan" in read))
488
- return refuse("nothing", ALREADY_MSG(read.landed.ref, read.landed.commit));
499
+ return refuse("nothing", read.landed.reverted === true ? landedLine(read.landed) : ALREADY_MSG(read.landed.ref, read.landed.commit));
489
500
  const plan = read.plan;
490
501
  if (plan.key !== input.key)
491
502
  return refuse("stale", "Something changed since you looked (the branch, the checks or the result). Look again, then land it.");
@@ -801,6 +812,16 @@ export function recognisedOnBranch(store, repo, rootId, candidate, read) {
801
812
  const where = `Landed on ${ref.slice("refs/heads/".length)} (${short(found.commit)})`;
802
813
  return { words: reverted ? `${where} · a later commit reverted it` : where, reverted };
803
814
  }
815
+ export function landingHistoryOf(store, repo, rootId, candidate, read) {
816
+ const record = landingOf(store, rootId);
817
+ if (record === null || record.undone) {
818
+ const onBranch = recognisedOnBranch(store, repo, rootId, candidate, read);
819
+ if (onBranch !== null)
820
+ return { ...onBranch, landed: true, recorded: false };
821
+ }
822
+ const standing = landedStanding(store, rootId, read);
823
+ return standing === null ? null : { ...standing, landed: record !== null && !record.undone && candidate !== null && record.intent.candidate === candidate, recorded: true };
824
+ }
804
825
  export function broughtInOnBranch(store, repo, rootId, read) {
805
826
  const landed = landedCommits(store, rootId);
806
827
  return handoffsOf(store, repo, rootId).some(one => !landed.has(one.commit) && read(repo, ["merge-base", "--is-ancestor", one.commit, one.ref]) !== null);
@@ -7,6 +7,16 @@ import { shipChecksForTask } from "./store.js";
7
7
  import { approvedCheckStateOf, requirementWordOf } from "./task-status.js";
8
8
  import { projectCheckSet } from "./check-levels.js";
9
9
  import { projectName } from "./project.js";
10
+ import { landingHistoryOf, publishesThroughPullRequests } from "./local-landing.js";
11
+ import { recentGitReads } from "./task-base.js";
12
+ const landingReads = recentGitReads();
13
+ export function landedNowOf(store, assignment, read = landingReads) {
14
+ const head = assignment.state === "complete" ? assignment.receipt?.head ?? null : null;
15
+ if (head === null || assignment.repo === null || publishesThroughPullRequests(store, assignment.repo))
16
+ return null;
17
+ const history = landingHistoryOf(store, assignment.repo, assignment.rootId, head, read);
18
+ return history !== null && history.landed ? { words: history.words, reverted: history.reverted } : null;
19
+ }
10
20
  export const CHECKLIST_KEYS = ["plan", "build", "checks", "requirements", "pull-request", "pr-ci", "up-to-date", "conflicts", "comments", "release"];
11
21
  export const CHECKLIST_LABELS = {
12
22
  plan: "Plan approved",
@@ -29,10 +39,12 @@ export function mergeChecklistOf(store, taskId, now, access, root) {
29
39
  const assignment = assignmentOf(store, taskId, now, access, root);
30
40
  if (assignment === null)
31
41
  return null;
32
- return checklistFromAssignment(store, taskId, assignment);
42
+ return checklistFromAssignment(store, taskId, assignment, landedNowOf(store, assignment)?.words ?? null);
33
43
  }
34
- export function checklistFromAssignment(store, taskId, assignment) {
44
+ export function checklistFromAssignment(store, taskId, assignment, landed = null, base, read = landingReads) {
35
45
  const active = assignment.activeTaskId;
46
+ if (landed !== null)
47
+ return { taskId, activeTaskId: active, run: assignment.receipt?.runId ?? null, head: assignment.receipt?.head ?? null, answer: "landed", sentence: landed, rows: [] };
36
48
  const scope = store.getScope(active);
37
49
  const task = store.getTask(active);
38
50
  const receipt = assignment.receipt;
@@ -69,7 +81,7 @@ export function checklistFromAssignment(store, taskId, assignment) {
69
81
  row("checks", "no", noCheckSetWords(assignment.repo));
70
82
  }
71
83
  else
72
- row("checks", "no", check === "unreadable" ? "The check result couldn't be read." : "No check ran on this commit.", { kind: "run-checks", run: receipt.runId });
84
+ row("checks", "no", check === "unreadable" ? "The check result couldn't be read." : check === "stale" ? "The check command changed since they ran on this commit." : "No check ran on this commit.", { kind: "run-checks", run: receipt.runId });
73
85
  const criteria = assignment.readiness?.blockers.filter(one => one.key === "criteria" || one.key === "high") ?? [];
74
86
  if (receipt === null)
75
87
  row("requirements", "waiting", "Waits for a build.");
@@ -132,7 +144,15 @@ export function checklistFromAssignment(store, taskId, assignment) {
132
144
  row("pr-ci", view.state === "failed" || view.state === "closed" ? "skip" : "waiting", view.state === "failed" || view.state === "closed" ? "No open pull request." : "No CI has reported yet.");
133
145
  }
134
146
  const notRecorded = publishing.on ? NOT_RECORDED : NOT_RECORDED_LOCAL;
135
- row("up-to-date", merged ? "yes" : "unknown", merged ? "Merged." : notRecorded);
147
+ const standing = merged || publishing.on || receipt === null || assignment.repo === null ? null : resultBehindMain(assignment.repo, head, base === undefined ? undefined : base?.main ?? null, read);
148
+ if (merged)
149
+ row("up-to-date", "yes", "Merged.");
150
+ else if (standing == null || standing.main === null || standing.behind === null)
151
+ row("up-to-date", "unknown", notRecorded);
152
+ else if (standing.behind === 0)
153
+ row("up-to-date", "yes", `Up to date with ${standing.main}.`);
154
+ else
155
+ row("up-to-date", "no", `${standing.main} has ${standing.behind === 1 ? "1 commit" : `${standing.behind} commits`} this work doesn't. Send it back to build on the current ${standing.main}.`, { kind: "fix", run: receipt.runId, note: `${standing.main} moved on since this work started. Build it again on the current ${standing.main}.` });
136
156
  if (merged)
137
157
  row("conflicts", "yes", "Merged.");
138
158
  else if (receipt?.checks.batch?.state === "conflict")
@@ -167,7 +187,16 @@ export function checklistFromAssignment(store, taskId, assignment) {
167
187
  : `Yes, as far as Toolroll records.${unknown.length === 0 ? "" : ` Check ${unknown.join(" and ")} ${publishing.on ? "on GitHub" : "in your repository"}.`}`;
168
188
  return { taskId, activeTaskId: active, run, head, answer, sentence, rows };
169
189
  }
190
+ function resultBehindMain(repo, head, main, read) {
191
+ const branch = main === undefined ? read(repo, ["symbolic-ref", "--short", "-q", "HEAD"]) || null : main;
192
+ if (branch === null || head === null || !/^[0-9a-f]{40}$/.test(head))
193
+ return { main: branch, behind: null };
194
+ const counted = read(repo, ["rev-list", "--count", `${head}..refs/heads/${branch}`]);
195
+ return { main: branch, behind: counted !== null && /^\d+$/.test(counted) ? Number(counted) : null };
196
+ }
170
197
  export function checklistLines(list) {
198
+ if (list.answer === "landed")
199
+ return [list.sentence];
171
200
  const MARK = { yes: "✓", no: "✗", waiting: "…", unknown: "?", skip: "–" };
172
201
  return [`Can I merge ${list.activeTaskId}? ${list.sentence}`,
173
202
  ...list.rows.filter(one => one.mark !== "skip").map(one => ` ${MARK[one.mark]} ${one.label}: ${one.say}${one.act === null ? "" : ` Next: ${CHECKLIST_ACT_LABELS[one.act.kind]}, on the task's page.`}`)];
package/dist/operate.js CHANGED
@@ -101,7 +101,7 @@ import { applyProjectProfile, runProjectCommand } from "./project-cli.js";
101
101
  import { passwordFreeOwner, passwordFreeShell, passwordFreeShellWords, proveTaskBuildsStopped, pullRequestLines, runLocalCompletion, runLocalRevision, runTaskMergeCommand, runTaskOutcomeCommand } from "./task-outcome-cli.js";
102
102
  import { applyPendingAgentChanges, planAgainAsLocalOwner, requestPlanAsLocalOwner, retryAsLocalOwner } from "./local-owner-acts.js";
103
103
  import { withTaskAlias } from "./task-aliases.js";
104
- import { checklistLines, mergeChecklistOf } from "./merge-checklist.js";
104
+ import { checklistLines, landedNowOf, mergeChecklistOf } from "./merge-checklist.js";
105
105
  import { taskReviewBrief, renderReviewBrief } from "./task-review-brief.js";
106
106
  import { homedir, hostname } from "node:os";
107
107
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
@@ -127,7 +127,7 @@ import { isWritesMode, writesWords } from "./writes-mode.js";
127
127
  import { linuxFenceAvailable, macosFenceAvailable } from "./agent-fence.js";
128
128
  import { parseMachLookup, parseReadDeny, readDenyWords } from "./project-sandbox.js";
129
129
  import { LOCAL_POLICY } from "./surface.js";
130
- import { handoffWords, land, landingWords, publishesThroughPullRequests, PULL_REQUESTS_INSTEAD, readLanding } from "./local-landing.js";
130
+ import { handoffWords, land, landedLine, landingWords, publishesThroughPullRequests, PULL_REQUESTS_INSTEAD, readLanding } from "./local-landing.js";
131
131
  import { asLocalOwner, currentLocalOwner, localActNow, LOCAL_MODE_CONFINES, localModeOn, localOwnerRefusal, localOwnerRequested } from "./local-owner.js";
132
132
  import { CHECK_ACCESS_WARNINGS, checkAccessRunsAs, checkAccessWords, isCheckAccess, signInHostsMissing, signInsUnavailableWords, widerThan } from "./check-access.js";
133
133
  import { CLI_PASSWORD_SOURCE, withPasswordSource } from "./sign-in-guard.js";
@@ -135,7 +135,6 @@ import { ledgerSpent, NO_SAFE_OPENER, openSignInLink, platformOpener } from "./s
135
135
  import { admissionRecorded, admitProject, commandLineActor } from "./project-admission.js";
136
136
  import { leadClaim, leadSay, noteLeadWork } from "./lead-voice.js";
137
137
  import { createConnection as createNetConnection, createServer as createNetServer } from "node:net";
138
- import { spawn as spawnChild } from "node:child_process";
139
138
  import { fileURLToPath } from "node:url";
140
139
  import { superviseController } from "./controller-supervisor.js";
141
140
  import { buildIdentity, memoryChannel, RoleGenerations, roleMessage } from "./up-processes.js";
@@ -204,6 +203,8 @@ import { disposeBuildOutcome, holdStaleApproval, regateTask } from "./dispose.js
204
203
  import { proposeGrant, describeGrant, describeWithheld, permits, MUTATION_CLASSES, DEFAULT_MUTATIONS, } from "./grant.js";
205
204
  import { builtIn, guarded } from "./backend.js";
206
205
  import { register, authenticate, heartbeat as heartbeatRunner, isAlive, recoverDead, recoveredAnything, acquireWatchLeaseAuthed, heartbeatWatchLeaseAuthed, addRunnerReposAuthed, removeRunnerRepoAuthed, registerRunnerIfIdle, retireRunnerIfCurrent, drainRunnerIfCurrent, RUNNER_HEARTBEAT_MS, MAX_WATCH_LEASE_MS, normalizeRunnerName, validRunnerName, canonicalRepos, RUNNER_NAME_MAX, RUNNER_CAPACITY_MAX, parseRunnerCapacity, hashToken as hashRunnerToken, } from "./runner.js";
206
+ import { processIdentityProblem } from "./process-identity.js";
207
+ import { openAddress } from "./browser-open.js";
207
208
  import { credentialDigest, recordedHolderProvedGone, processGone, processStart, readRunnerProcessRecord, runnerProcessFile, sealRunnerProcessRecord, writeRunnerProcessRecord } from "./runner-process.js";
208
209
  import { stopProcessTree } from "./process-tree.js";
209
210
  import { mintCoordinator, revokeCoordinator, listCoordinators } from "./coordinator.js";
@@ -6143,17 +6144,7 @@ async function resolveUpApprover(context, flags, canPrompt) {
6143
6144
  return { approver: selected, approvers: names, verified, passwordFile, mintedPassword: null, notes, startAuthority: verified ? "full" : "none" };
6144
6145
  }
6145
6146
  export function openBrowser(url) {
6146
- const chosen = envValue(process.env, "BROWSER_COMMAND");
6147
- const command = chosen !== undefined && chosen !== "" ? [chosen, url]
6148
- : process.platform === "darwin" ? ["open", url]
6149
- : process.platform === "win32" ? ["cmd", "/c", "start", "", url]
6150
- : ["xdg-open", url];
6151
- try {
6152
- const child = spawnChild(command[0], command.slice(1), { detached: true, stdio: "ignore" });
6153
- child.unref();
6154
- }
6155
- catch {
6156
- }
6147
+ return openAddress(url);
6157
6148
  }
6158
6149
  function recordUpConsoleUrl(dir, url, now) {
6159
6150
  try {
@@ -6461,7 +6452,8 @@ async function upCommand(flags, context) {
6461
6452
  progress(`recovered ${answer.recoveredRuns} interrupted attempt(s) left by the previous ${name}`);
6462
6453
  if (!recordRunnerProcess(context.databaseFile, { runner: answer.runner, credentialHash: hashRunnerToken(answer.token) }, "up", process.pid)) {
6463
6454
  retireRunnerIfCurrent(store, runnerName, runnerToken, clock());
6464
- return fail(write, json, "up", "runner-alive", "The worker process record could not be saved; nothing started", EXIT.refused);
6455
+ const identity = processIdentityProblem();
6456
+ return fail(write, json, "up", "runner-alive", `The worker process record could not be saved${identity === null ? "" : ` (${identity})`}; nothing started`, EXIT.refused);
6465
6457
  }
6466
6458
  recordBuilderWish(store, "running", "up", packageVersion(), clock());
6467
6459
  doorAnswer = answer;
@@ -8138,6 +8130,7 @@ function showTask(positional, context) {
8138
8130
  const primaryAction = listed === null ? work?.primaryAction ?? null : listed.primaryAction;
8139
8131
  const steeringLive = store.steeringLiveBuild(ref.id, now) !== null;
8140
8132
  const base = taskBaseOf(store, id);
8133
+ const landedNow = current === null ? null : landedNowOf(store, current)?.words ?? null;
8141
8134
  const detail = {
8142
8135
  task,
8143
8136
  work: work === null || listed === null ? work : { ...work, status: { ...work.status, label: listed.status.label, detail: listed.status.detail, tone: listed.status.tone }, primaryAction },
@@ -8154,6 +8147,7 @@ function showTask(positional, context) {
8154
8147
  personApproval: personApprovalOf(store, id),
8155
8148
  route: taskRouteView(routed, readiness),
8156
8149
  base,
8150
+ landing: landedNow,
8157
8151
  runs: runs.map(one => ({ ...one, route: store.runRoute(one.id) })),
8158
8152
  deliverable: ref.deliverable,
8159
8153
  report: readVerifiedReport(store, context.evidenceRoot, ref.id),
@@ -8201,7 +8195,8 @@ function showTask(positional, context) {
8201
8195
  ]
8202
8196
  : [` report: ${detail.report.problem} (build #${detail.report.run})`]),
8203
8197
  ...pullRequestLines(detail.pullRequest),
8204
- ...(base === null ? [] : [` base: ${baseStandingWords(base)}`]),
8198
+ ...(landedNow === null ? [] : [` landing: ${landedNow}`]),
8199
+ ...(base === null ? [] : [` base: ${baseStandingWords(base, landedNow !== null)}`]),
8205
8200
  ...(detail.blockedBy.length > 0 ? [` waits for ${detail.blockedBy.join(", ")}`] : []),
8206
8201
  ...(detail.position === null
8207
8202
  ? []
@@ -12076,8 +12071,10 @@ async function newTaskCommand(positional, flags, context) {
12076
12071
  return importTaskCommand(fromLink, flags, context, name);
12077
12072
  const words = positional.join(" ").trim();
12078
12073
  const repo = text(flags, "repo");
12079
- if (words === "" || repo === undefined)
12080
- return fail(write, json, command, "usage", "`toolroll task new \"<what should change>\" --repo <project>`", EXIT.usage);
12074
+ if (words === "")
12075
+ return fail(write, json, command, "usage", `Say what should change: \`toolroll task new "<what should change>" --repo ${repo ?? "<project>"}\``, EXIT.usage);
12076
+ if (repo === undefined)
12077
+ return fail(write, json, command, "usage", "Name the project it's for with --repo (its folder, or `--repo .` for the one you're in): `toolroll task new \"<what should change>\" --repo <project>`", EXIT.usage);
12081
12078
  const placed = canonicalProject(repo) ?? resolve(repo);
12082
12079
  if (local === null && (flags.has("token") || (!facts.passwordless && !passwordFreeOwner(store)))) {
12083
12080
  let given = flags.has("token") ? token : undefined;
@@ -13443,7 +13440,7 @@ async function landTaskCommand(positional, flags, context) {
13443
13440
  if (!read.ok)
13444
13441
  return fail(write, json, command, read.reason, read.message, EXIT.refused);
13445
13442
  if (!("plan" in read))
13446
- return succeed(write, json, command, { landed: read.landed }, () => [`${id} · Landed on ${read.landed.ref.replace(/^refs\/heads\//, "")} (${read.landed.commit.slice(0, 7)}).`]);
13443
+ return succeed(write, json, command, { landed: read.landed }, () => [`${id} · ${landedLine(read.landed)}`]);
13447
13444
  const plan = read.plan;
13448
13445
  if (local === null && passwordFreeOwner(store))
13449
13446
  return succeed(write, json, command, { plan }, () => [...landingWords(plan), LAND_NEEDS_PASSWORD]);
@@ -0,0 +1,14 @@
1
+ import { noBrowserReason } from "./browser-open.js";
2
+ import { installedGitFloorProblem } from "./git-floor.js";
3
+ import { processIdentityProblem } from "./process-identity.js";
4
+ export function startPrerequisites(deps = {}) {
5
+ const blockers = [];
6
+ const git = (deps.gitFloorProblem ?? installedGitFloorProblem)();
7
+ if (git !== null)
8
+ blockers.push([git]);
9
+ const identity = (deps.processIdentityProblem ?? processIdentityProblem)();
10
+ if (identity !== null)
11
+ blockers.push([`${identity}.`]);
12
+ const browser = (deps.noBrowser ?? (() => noBrowserReason()))();
13
+ return { blockers, advisories: browser === null ? [] : [`No browser opens here (${browser}): the terminal workbench doesn't need one, and Toolroll prints its address.`] };
14
+ }
@@ -0,0 +1,155 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { readdirSync, readFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ const LSTART = /^(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})$/;
5
+ const ISO = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
6
+ const PROC_ID = /^proc:[0-9a-f-]{36}:\d{1,20}$/;
7
+ const BOOT_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
8
+ export function lstartToIso(raw) {
9
+ const match = LSTART.exec(raw.trim().replace(/ +/g, " "));
10
+ if (match === null)
11
+ return null;
12
+ const utc = `${match[1]}, ${match[3].padStart(2, "0")} ${match[2]} ${match[5]} ${match[4]} GMT`;
13
+ const at = Date.parse(utc);
14
+ if (!Number.isFinite(at) || new Date(at).toUTCString() !== utc)
15
+ return null;
16
+ return new Date(at).toISOString();
17
+ }
18
+ export function identityProvider(recorded) {
19
+ if (PROC_ID.test(recorded))
20
+ return "proc";
21
+ if (ISO.test(recorded) || lstartToIso(recorded) !== null)
22
+ return "ps";
23
+ return null;
24
+ }
25
+ export function procStatFields(stat) {
26
+ const close = stat.lastIndexOf(")");
27
+ if (close < 0 || stat.indexOf("(") < 0 || stat.indexOf("(") > close)
28
+ return null;
29
+ const fields = stat.slice(close + 1).trim().split(/\s+/);
30
+ return fields.length >= 20 && /^[A-Za-z]$/.test(fields[0]) ? fields : null;
31
+ }
32
+ const defaultRead = (file) => readFileSync(file, "utf8");
33
+ const defaultPs = (pid, field) => {
34
+ try {
35
+ return execFileSync("/bin/ps", ["-p", String(pid), "-o", `${field}=`], {
36
+ encoding: "utf8", env: { PATH: "/usr/bin:/bin", LC_ALL: "C", TZ: "UTC" }, stdio: ["ignore", "pipe", "ignore"],
37
+ maxBuffer: 4096, timeout: 2_000, killSignal: "SIGKILL",
38
+ });
39
+ }
40
+ catch {
41
+ return null;
42
+ }
43
+ };
44
+ function procFields(pid, io) {
45
+ if ((io.platform ?? process.platform) !== "linux")
46
+ return null;
47
+ try {
48
+ return procStatFields((io.read ?? defaultRead)(join(io.procRoot ?? "/proc", String(pid), "stat")));
49
+ }
50
+ catch {
51
+ return null;
52
+ }
53
+ }
54
+ export function processIdentity(pid, provider, io = {}) {
55
+ const platform = io.platform ?? process.platform;
56
+ if (!Number.isSafeInteger(pid) || pid <= 1 || platform === "win32")
57
+ return null;
58
+ if (provider !== "ps" && platform === "linux") {
59
+ const fields = procFields(pid, io);
60
+ let boot = null;
61
+ try {
62
+ boot = (io.read ?? defaultRead)(join(io.procRoot ?? "/proc", "sys", "kernel", "random", "boot_id")).trim();
63
+ }
64
+ catch {
65
+ boot = null;
66
+ }
67
+ const ticks = fields?.[19];
68
+ if (fields !== null && boot !== null && BOOT_ID.test(boot) && ticks !== undefined && /^\d{1,20}$/.test(ticks))
69
+ return `proc:${boot}:${ticks}`;
70
+ if (provider === "proc")
71
+ return null;
72
+ }
73
+ const raw = (io.ps ?? defaultPs)(pid, "lstart");
74
+ return raw === null ? null : lstartToIso(raw);
75
+ }
76
+ export function sameProcess(pid, recorded, io = {}) {
77
+ const provider = identityProvider(recorded);
78
+ if (provider === null)
79
+ return "unknown";
80
+ const now = processIdentity(pid, provider, io);
81
+ if (now === null)
82
+ return "unknown";
83
+ const was = provider === "ps" && !ISO.test(recorded) ? lstartToIso(recorded) : recorded;
84
+ return now === was ? "same" : "other";
85
+ }
86
+ export function processParentId(pid, io = {}) {
87
+ if (!Number.isSafeInteger(pid) || pid <= 1 || (io.platform ?? process.platform) === "win32")
88
+ return null;
89
+ const fields = procFields(pid, io);
90
+ const raw = fields !== null ? fields[1] : (io.ps ?? defaultPs)(pid, "ppid")?.trim() ?? "";
91
+ const parent = Number(raw);
92
+ return /^\d+$/.test(raw) && Number.isSafeInteger(parent) && parent > 0 ? parent : null;
93
+ }
94
+ export function processGroupId(pid, io = {}) {
95
+ if (!Number.isSafeInteger(pid) || pid <= 1 || (io.platform ?? process.platform) === "win32")
96
+ return null;
97
+ const fields = procFields(pid, io);
98
+ const raw = fields !== null ? fields[2] : (io.ps ?? defaultPs)(pid, "pgid")?.trim() ?? "";
99
+ const group = Number(raw);
100
+ return /^\d+$/.test(raw) && Number.isSafeInteger(group) && group > 1 ? group : null;
101
+ }
102
+ export function processGroupRss(pgid, io = {}) {
103
+ if ((io.platform ?? process.platform) === "linux") {
104
+ const root = io.procRoot ?? "/proc";
105
+ const read = io.read ?? defaultRead;
106
+ let names;
107
+ try {
108
+ names = (io.list ?? readdirSync)(root).filter(name => /^\d+$/.test(name));
109
+ }
110
+ catch {
111
+ names = null;
112
+ }
113
+ if (names !== null && names.length > 0) {
114
+ let kilobytes = 0;
115
+ for (const name of names) {
116
+ try {
117
+ const fields = procStatFields(read(join(root, name, "stat")));
118
+ if (fields === null || Number(fields[2]) !== pgid)
119
+ continue;
120
+ const rss = /^VmRSS:\s+(\d+) kB$/m.exec(read(join(root, name, "status")));
121
+ if (rss !== null)
122
+ kilobytes += Number(rss[1]);
123
+ }
124
+ catch { }
125
+ }
126
+ return kilobytes * 1024;
127
+ }
128
+ }
129
+ let out;
130
+ try {
131
+ out = execFileSync("/bin/ps", ["-A", "-o", "pgid=,rss="], { encoding: "utf8", env: { PATH: "/usr/bin:/bin", LC_ALL: "C" }, stdio: ["ignore", "pipe", "ignore"], maxBuffer: 4 * 1024 * 1024, timeout: 2_000, killSignal: "SIGKILL" });
132
+ }
133
+ catch {
134
+ out = null;
135
+ }
136
+ if (out === null)
137
+ return null;
138
+ let kilobytes = 0;
139
+ for (const line of out.split("\n")) {
140
+ const [group, rss] = line.trim().split(/\s+/);
141
+ if (Number(group) === pgid)
142
+ kilobytes += Number(rss) || 0;
143
+ }
144
+ return kilobytes * 1024;
145
+ }
146
+ export function processIdentityProblem(io = {}) {
147
+ const platform = io.platform ?? process.platform;
148
+ if (platform === "win32")
149
+ return "Toolroll can't read when a process started on Windows, so it can't start its worker here";
150
+ if (processIdentity(process.pid, undefined, io) !== null)
151
+ return null;
152
+ return platform === "linux"
153
+ ? "Toolroll can't read when a process started here: /proc can't be read and this `ps` has no `-o lstart` (busybox). Install procps (Debian, Ubuntu, Alpine: procps; Fedora: procps-ng), or make /proc readable"
154
+ : "Toolroll can't read when a process started here: `ps -o lstart` doesn't work";
155
+ }
@@ -91,8 +91,13 @@ export async function runQuickStart(argv, write, seams) {
91
91
  write(`Toolroll can't attach: ${proof.message}.`);
92
92
  return EXIT.refused;
93
93
  }
94
- if (!proof.ok)
94
+ if (!proof.ok) {
95
+ if (seams.setUp !== undefined && !(await seams.setUp())) {
96
+ write(`Toolroll isn't set up on this computer yet. Run \`toolroll\` in a terminal to set it up without a password, or \`toolroll up\` to start it with one.`);
97
+ return EXIT.refused;
98
+ }
95
99
  return seams.startUp();
100
+ }
96
101
  if (!enrolled) {
97
102
  const admitted = await seams.admit(repo);
98
103
  if (admitted !== 0)
package/dist/release.js CHANGED
@@ -37,6 +37,14 @@ export const ADVISORY_PR_CHECKS = {
37
37
  "upgrade path": ".github/workflows/upgrade-path.yml",
38
38
  "install smoke · ubuntu-24.04": ".github/workflows/install-smoke.yml",
39
39
  "install smoke · macos-latest": ".github/workflows/install-smoke.yml",
40
+ "install smoke · ubuntu umask 0002": ".github/workflows/install-smoke.yml",
41
+ "install smoke · ubuntu umask 0002 · arm64": ".github/workflows/install-smoke.yml",
42
+ "install smoke · no user namespaces": ".github/workflows/install-smoke.yml",
43
+ "install smoke · alpine": ".github/workflows/install-smoke.yml",
44
+ "install smoke · fedora": ".github/workflows/install-smoke.yml",
45
+ "install smoke · debian 12": ".github/workflows/install-smoke.yml",
46
+ "install smoke · debian 13": ".github/workflows/install-smoke.yml",
47
+ "install smoke · node 26": ".github/workflows/install-smoke.yml",
40
48
  "wire budgets": ".github/workflows/wire-budgets.yml",
41
49
  "rust · ubuntu-latest": ".github/workflows/rust.yml",
42
50
  "rust · macos-latest": ".github/workflows/rust.yml",
@@ -1,6 +1,6 @@
1
1
  import { sameMachineHost } from "./machine-identity.js";
2
2
  import { createHash, createHmac, randomUUID, timingSafeEqual } from "node:crypto";
3
- import { execFileSync } from "node:child_process";
3
+ import { identityProvider, lstartToIso, processIdentity } from "./process-identity.js";
4
4
  import { closeSync, fstatSync, lstatSync, mkdirSync, openSync, readSync, realpathSync, renameSync, rmSync, writeFileSync, fsyncSync, constants } from "node:fs";
5
5
  import { dirname, join, resolve } from "node:path";
6
6
  export const RUNNER_PROCESS_DIR = "runner-processes";
@@ -38,30 +38,11 @@ export function runnerProcessFile(databaseFile, runner) {
38
38
  export function credentialDigest(credentialHash) {
39
39
  return createHash("sha256").update(`runner-process:${credentialHash}`, "utf8").digest("hex").slice(0, 32);
40
40
  }
41
- const LSTART = /^(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})$/;
42
41
  export function parseProcessStart(raw) {
43
- const match = LSTART.exec(raw.trim().replace(/ +/g, " "));
44
- if (match === null)
45
- return null;
46
- const utc = `${match[1]}, ${match[3].padStart(2, "0")} ${match[2]} ${match[5]} ${match[4]} GMT`;
47
- const at = Date.parse(utc);
48
- if (!Number.isFinite(at) || new Date(at).toUTCString() !== utc)
49
- return null;
50
- return new Date(at).toISOString();
42
+ return lstartToIso(raw);
51
43
  }
52
- export function processStart(pid) {
53
- if (!Number.isSafeInteger(pid) || pid <= 1 || process.platform === "win32")
54
- return null;
55
- try {
56
- const raw = execFileSync("/bin/ps", ["-p", String(pid), "-o", "lstart="], {
57
- encoding: "utf8", env: { PATH: "/usr/bin:/bin", LC_ALL: "C", TZ: "UTC" }, stdio: ["ignore", "pipe", "ignore"],
58
- maxBuffer: 1024, timeout: 2_000, killSignal: "SIGKILL",
59
- });
60
- return parseProcessStart(raw);
61
- }
62
- catch {
63
- return null;
64
- }
44
+ export function processStart(pid, provider) {
45
+ return processIdentity(pid, provider);
65
46
  }
66
47
  export const realProcessProbe = {
67
48
  exists: pid => {
@@ -82,7 +63,10 @@ export function processGone(entry, probe = realProcessProbe) {
82
63
  return true;
83
64
  if (exists === "unknown")
84
65
  return false;
85
- const started = probe.start(entry.pid);
66
+ const provider = identityProvider(entry.started);
67
+ if (provider === null)
68
+ return false;
69
+ const started = probe.start(entry.pid, provider);
86
70
  if (started === null)
87
71
  return probe.exists(entry.pid) === "absent";
88
72
  return started !== entry.started;
@@ -137,7 +121,7 @@ function parseRecord(value) {
137
121
  if (typeof one !== "object" || one === null)
138
122
  return null;
139
123
  const p = one;
140
- if (!Number.isSafeInteger(p["pid"]) || p["pid"] <= 1 || !ROLES.has(p["role"]) || !text(p["started"], 32) || !ISO.test(p["started"]))
124
+ if (!Number.isSafeInteger(p["pid"]) || p["pid"] <= 1 || !ROLES.has(p["role"]) || !text(p["started"], 80) || identityProvider(p["started"]) === null || !(ISO.test(p["started"]) || p["started"].startsWith("proc:")))
141
125
  return null;
142
126
  processes.push({ pid: p["pid"], role: p["role"], started: p["started"] });
143
127
  }
@@ -1,3 +1,4 @@
1
+ import { shownText } from "./shown-text.js";
1
2
  import { spawn } from "node:child_process";
2
3
  import { checkLinuxDependencies, cleanupBwrapMountPoints, getLinuxDependencyStatus, initializeLinuxNetworkBridge, wrapCommandWithSandboxLinux } from "@anthropic-ai/sandbox-runtime/dist/sandbox/linux-sandbox-utils.js";
3
4
  import { SANDBOX_LAUNCH_SPEC, shellQuote, withRuntimeTemp } from "./sandbox-runtime.js";
@@ -31,7 +32,7 @@ async function main() {
31
32
  const spec = JSON.parse(raw);
32
33
  const problem = toolsProblem(spec);
33
34
  if (problem !== null) {
34
- process.stderr.write(`toolroll sandbox: nothing was started: ${problem}\n`);
35
+ process.stderr.write(`toolroll sandbox: nothing was started: ${shownText(problem)}\n`);
35
36
  return REFUSED;
36
37
  }
37
38
  const tools = spec.tools;
@@ -135,7 +136,7 @@ async function main() {
135
136
  }
136
137
  catch (error) {
137
138
  if (child === null) {
138
- process.stderr.write(`toolroll sandbox: nothing was started: ${error instanceof Error ? error.message : String(error)}\n`);
139
+ process.stderr.write(`toolroll sandbox: nothing was started: ${shownText(error instanceof Error ? error.message : String(error))}\n`);
139
140
  return REFUSED;
140
141
  }
141
142
  return 1;