toolroll 0.9.123 → 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 (72) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +1 -1
  3. package/dist/advanced-view.js +0 -1
  4. package/dist/agent-detect.js +23 -3
  5. package/dist/bounded-spawn.js +5 -36
  6. package/dist/browser/workspace.css +1 -1
  7. package/dist/browser/workspace.js +29 -29
  8. package/dist/browser-open.js +49 -0
  9. package/dist/chat-acceptance.js +1 -1
  10. package/dist/chat-actions.js +1 -1
  11. package/dist/check-only.js +1 -1
  12. package/dist/cli.js +2 -2
  13. package/dist/connect-cli.js +2 -8
  14. package/dist/contracts/engine-api.js +5 -0
  15. package/dist/direct-chat-git.js +20 -0
  16. package/dist/direct-chat-ship.js +5 -5
  17. package/dist/direct-chat.js +29 -20
  18. package/dist/doctor.js +30 -3
  19. package/dist/easy-start.js +43 -17
  20. package/dist/engine-reads.js +14 -0
  21. package/dist/evals.js +17 -19
  22. package/dist/first-run.js +5 -1
  23. package/dist/flexible-import.js +3 -2
  24. package/dist/flexible-save.js +2 -0
  25. package/dist/flexible-session.js +1 -1
  26. package/dist/flexible-thread.js +14 -2
  27. package/dist/flow-code.js +2 -2
  28. package/dist/git-identity.js +65 -0
  29. package/dist/invoke.js +4 -4
  30. package/dist/laptop-background.js +2 -11
  31. package/dist/linux-packages.js +46 -0
  32. package/dist/local-landing.js +35 -5
  33. package/dist/merge-checklist.js +33 -4
  34. package/dist/operate.js +19 -20
  35. package/dist/passwordless.js +10 -2
  36. package/dist/preflight.js +14 -0
  37. package/dist/process-identity.js +155 -0
  38. package/dist/project-skills.js +2 -2
  39. package/dist/quick-start.js +6 -1
  40. package/dist/release.js +8 -0
  41. package/dist/runner-process.js +9 -25
  42. package/dist/sandbox-launch.js +3 -2
  43. package/dist/sandbox-runtime.js +115 -15
  44. package/dist/sandbox-tools.js +91 -6
  45. package/dist/server/direct-chat.js +33 -6
  46. package/dist/server/merge-ready-view.js +4 -2
  47. package/dist/server/pages.js +1 -1
  48. package/dist/server/render-pages.js +1 -0
  49. package/dist/server/render-results.js +6 -6
  50. package/dist/server/render-tasks.js +7 -2
  51. package/dist/server/route-table.js +3 -0
  52. package/dist/server/settings-sections.js +1 -1
  53. package/dist/server/settings.js +55 -33
  54. package/dist/server/task-views.js +14 -8
  55. package/dist/server/tasks.js +14 -3
  56. package/dist/settings-groups-ui.js +6 -6
  57. package/dist/shown-text.js +14 -0
  58. package/dist/skill-library.js +22 -5
  59. package/dist/skills-ui.js +24 -11
  60. package/dist/status-probe.js +32 -0
  61. package/dist/task-base.js +2 -2
  62. package/dist/task-status.js +7 -4
  63. package/dist/telegram-status.js +1 -1
  64. package/dist/toolroll-update.js +4 -0
  65. package/dist/trust-repair.js +187 -0
  66. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  67. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  68. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  69. package/dist/tui/linux-x64/toolroll-tui +0 -0
  70. package/dist/work-index.js +51 -3
  71. package/dist/workspace-ui.js +4 -2
  72. package/package.json +1 -1
@@ -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);
@@ -15,6 +15,7 @@ import { processMayBeAlive } from "./process-liveness.js";
15
15
  import { startIdentityOf } from "./flexible-custody.js";
16
16
  import { defaultCustodyIO, holdLaunch, recordGateShut, recordLive, reserveLaunchOpen, recordNeverStarted, recordSpawning, settleLaunch, unsettledLaunch } from "./flexible-launch.js";
17
17
  import { readProjectRefs, saveRefSnapshot } from "./flexible-refs.js";
18
+ import { identityEnv, projectGitIdentity, THREAD_IDENTITY } from "./git-identity.js";
18
19
  import { projectRowKnown } from "./store.js";
19
20
  import { readProjectRegistryNow } from "./repos.js";
20
21
  import { poolRootOf } from "./worktree.js";
@@ -440,12 +441,13 @@ export function flexibleThreadFence(store, input) {
440
441
  ...(unread === undefined ? {} : { pool: unread }) };
441
442
  return { ok: true, launch: { ...made, fenceGrants: grants }, paths, thread };
442
443
  }
443
- export function flexibleThreadEnv(paths, proxy, base = process.env) {
444
+ export function flexibleThreadEnv(paths, proxy, base = process.env, identity = THREAD_IDENTITY) {
444
445
  return {
445
446
  ...plainAgentEnv(base),
446
447
  HOME: real(homedir()), TMPDIR: paths.tmp, ...buildCacheEnv(paths.cache),
447
448
  GIT_TERMINAL_PROMPT: "0", GIT_CONFIG_NOSYSTEM: "1",
448
449
  ...proxy,
450
+ ...identityEnv(identity),
449
451
  };
450
452
  }
451
453
  function outerEnv(env, platform) {
@@ -552,7 +554,17 @@ async function spawnLocked(store, input, file, args, platform, seams) {
552
554
  const terms = termsProblem(launch);
553
555
  if (terms !== null)
554
556
  return refuse("containment", terms);
555
- const base = flexibleThreadEnv(paths, input.proxyEnv);
557
+ let project;
558
+ try {
559
+ project = realpathSync(fenced.thread.repo);
560
+ }
561
+ catch {
562
+ return refuse("repository-unusable");
563
+ }
564
+ const identity = await projectGitIdentity(project, THREAD_IDENTITY);
565
+ if (!identity.ok)
566
+ return refuse("repository-unusable", identity.why);
567
+ const base = flexibleThreadEnv(paths, input.proxyEnv, process.env, identity.identity);
556
568
  const env = { ...Object.fromEntries(Object.entries(input.agentEnv ?? {}).filter(([name]) => !(name in base))), ...base };
557
569
  const probed = await probeContainment(launch, paths, env, platform);
558
570
  if (probed !== null)
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 {
@@ -0,0 +1,65 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { isAbsolute, join } from "node:path";
5
+ import { run } from "./exec.js";
6
+ import { hardenedGit, refusal } from "./teardown-git.js";
7
+ import { unsafeInCommand } from "./local-landing.js";
8
+ export const THREAD_IDENTITY = Object.freeze({ name: "Toolroll thread", email: "thread@toolroll.local" });
9
+ export const DIRECT_CHAT_IDENTITY = Object.freeze({ name: "Toolroll Direct Chat", email: "direct-chat@toolroll.local" });
10
+ const plain = (value) => {
11
+ if (value === undefined || unsafeInCommand(value) || /[<>]/.test(value))
12
+ return null;
13
+ const trimmed = value.trim();
14
+ return trimmed !== "" && trimmed.length <= 200 ? trimmed : null;
15
+ };
16
+ export function identityValues(listing) {
17
+ let name, email;
18
+ for (const entry of listing.split("\0")) {
19
+ const newline = entry.indexOf("\n");
20
+ if (newline < 0)
21
+ continue;
22
+ const key = entry.slice(0, newline).toLowerCase();
23
+ if (key === "user.name")
24
+ name = entry.slice(newline + 1);
25
+ else if (key === "user.email")
26
+ email = entry.slice(newline + 1);
27
+ }
28
+ return { name: plain(name), email: plain(email) };
29
+ }
30
+ function globalValues(home, env) {
31
+ const xdg = env["XDG_CONFIG_HOME"];
32
+ const files = [join(xdg !== undefined && isAbsolute(xdg) ? xdg : join(home, ".config"), "git", "config"), join(home, ".gitconfig")];
33
+ const found = { name: null, email: null };
34
+ for (const file of files) {
35
+ if (!existsSync(file))
36
+ continue;
37
+ const ran = spawnSync("git", ["config", "--file", file, "--no-includes", "--list", "-z"], {
38
+ cwd: "/", encoding: "utf8", timeout: 5_000, killSignal: "SIGKILL", stdio: ["ignore", "pipe", "ignore"], maxBuffer: 1_048_576,
39
+ env: { PATH: process.env["PATH"] ?? "/usr/bin:/bin", HOME: "/nonexistent", GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", LANG: "C" },
40
+ });
41
+ if (ran.status !== 0)
42
+ continue;
43
+ const values = identityValues(ran.stdout);
44
+ found.name = values.name ?? found.name;
45
+ found.email = values.email ?? found.email;
46
+ }
47
+ return found;
48
+ }
49
+ export function identityFrom(localListing, neutral, home = homedir(), env = process.env) {
50
+ const local = identityValues(localListing);
51
+ const global = local.name !== null && local.email !== null ? { name: null, email: null } : globalValues(home, env);
52
+ return { name: local.name ?? global.name ?? neutral.name, email: local.email ?? global.email ?? neutral.email };
53
+ }
54
+ export async function projectGitIdentity(repo, neutral, inner = run) {
55
+ const ran = await hardenedGit(inner, "read", { repo })("git", ["config", "--local", "--list", "-z"], { cwd: repo, timeoutMs: 60_000 });
56
+ const refused = refusal(ran);
57
+ if (refused !== null)
58
+ return { ok: false, why: refused };
59
+ if (ran.code !== 0)
60
+ return { ok: false, why: "its git config couldn't be read" };
61
+ return { ok: true, identity: identityFrom(ran.stdout, neutral) };
62
+ }
63
+ export function identityEnv(identity) {
64
+ return { GIT_AUTHOR_NAME: identity.name, GIT_AUTHOR_EMAIL: identity.email, GIT_COMMITTER_NAME: identity.name, GIT_COMMITTER_EMAIL: identity.email };
65
+ }
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 => {
@@ -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.");
@@ -670,6 +681,15 @@ function handoffRows(store, repo, taskId) {
670
681
  export function handoffsOf(store, repo, taskId) {
671
682
  return handoffRows(store, repo, taskId).filter(one => one.settled);
672
683
  }
684
+ export function keptHandoffOf(store, repo, rootId, candidate) {
685
+ if (candidate === null || !OID.test(candidate))
686
+ return null;
687
+ const one = handoffsOf(store, repo, rootId).find(row => row.candidate === candidate);
688
+ if (one === undefined)
689
+ return null;
690
+ const command = handoffCommand(one.folder, one.commit);
691
+ return { commit: one.commit, branch: one.ref.replace(/^refs\/heads\//, ""), command, words: handoffWords({ command }, one.commit) };
692
+ }
673
693
  class Refused extends Error {
674
694
  result;
675
695
  constructor(result) {
@@ -792,6 +812,16 @@ export function recognisedOnBranch(store, repo, rootId, candidate, read) {
792
812
  const where = `Landed on ${ref.slice("refs/heads/".length)} (${short(found.commit)})`;
793
813
  return { words: reverted ? `${where} · a later commit reverted it` : where, reverted };
794
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
+ }
795
825
  export function broughtInOnBranch(store, repo, rootId, read) {
796
826
  const landed = landedCommits(store, rootId);
797
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;
@@ -12827,7 +12824,9 @@ async function projectFlexibleCommand(positional, flags, context) {
12827
12824
  return refused("Only a person changes a project's thread terms, never the lead, a token or a chat app.");
12828
12825
  const acting = await askCredentials(flags, context);
12829
12826
  if (acting === null)
12830
- return refused(`${action === "enable" ? "Turning on interactive agent threads needs your password" : "This needs your sign-in"}: pass --as and --token.`);
12827
+ return refused(action === "enable"
12828
+ ? "Turning on interactive agent threads needs your Toolroll password: run it again with `--as <your name>` and type the password when asked (`--token` is that password, only for scripts: it stays in shell history). Or turn them on in the browser, on the project's page in Settings."
12829
+ : "This needs your sign-in: run it again with `--as <your name>` and type your Toolroll password when asked.");
12831
12830
  if (action === "enable") {
12832
12831
  if (!flexibleAvailable(store))
12833
12832
  return fail(write, json, command, "not-available", FLEXIBLE_UNAVAILABLE, EXIT.refused);
@@ -13441,7 +13440,7 @@ async function landTaskCommand(positional, flags, context) {
13441
13440
  if (!read.ok)
13442
13441
  return fail(write, json, command, read.reason, read.message, EXIT.refused);
13443
13442
  if (!("plan" in read))
13444
- 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)}`]);
13445
13444
  const plan = read.plan;
13446
13445
  if (local === null && passwordFreeOwner(store))
13447
13446
  return succeed(write, json, command, { plan }, () => [...landingWords(plan), LAND_NEEDS_PASSWORD]);
@@ -17,8 +17,16 @@ export function setPasswordless(store, on, by, now) {
17
17
  if (setting.on === on && (on || setting.at !== null))
18
18
  return { changed: false };
19
19
  store.recordAction({ at: now.toISOString(), actor: by, repo: null, taskId: null, runId: null, action: PASSWORDLESS_ACTION, outcome: on ? "on" : "off", source: "policy",
20
- detail: on ? "Passwordless on: approvals need no password" : "Passwordless off: step-ups ask for the password again" });
20
+ detail: on ? "Passwordless on: most browser approvals need no password" : "Passwordless off: step-ups ask for the password again" });
21
21
  store.bumpWake();
22
22
  return { changed: true };
23
23
  }
24
- export const PASSWORDLESS_TRADE = "Anyone holding a signed-in browser — an unlocked laptop, a phone, a stolen session — can then do everything you can without a second check. Signing in, session limits (12 hours idle, 7 days), signing out and ending sessions remain your protection. Creating or widening a way in (passwords, sign-in methods, API tokens, connected apps, people, workers, chat pairing, webhook secrets), or widening what a project's builds and checks reach (its network, where builds write, its home folder and its check access), still asks for your password.";
24
+ export const PASSWORDLESS_TRADE = "Anyone holding a signed-in browser — an unlocked laptop, a phone, a stolen session — can then do everything you can without a second check, except what still asks below. Signing in, session limits (12 hours idle, 7 days), signing out and ending sessions remain your protection.";
25
+ export const PASSWORDLESS_STILL_ASKS = Object.freeze([
26
+ "Signing in, and anything that adds or widens a way in: passwords, sign-in methods, API tokens, connected apps, people, workers, chat pairing and webhook secrets.",
27
+ "Widening what a project’s builds and checks reach: its network, where builds write, its home folder and its check commands.",
28
+ "Turning on interactive agent threads and saving the Claude sign-in they use.",
29
+ "Saving or shipping a Direct Chat’s work, and shipping a thread’s, except in Local mode on a laptop install, where this computer’s own browser and workbench don’t ask.",
30
+ "A toolroll command run in a shell without this computer’s remembered login.",
31
+ ]);
32
+ export const PASSWORDLESS_OTHERS = "Solo stands in the same way while you are the only person on this install. Local mode lets this computer’s browser file tasks, approve plans and add projects with no password at all. Without either, a password you just typed skips standard approvals on this computer for 15 minutes.";
@@ -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
+ }