toolroll 0.9.118 → 0.9.119

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 (63) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +14 -14
  3. package/dist/assignment.js +40 -29
  4. package/dist/browser/workspace.css +1 -1
  5. package/dist/browser/workspace.js +32 -31
  6. package/dist/builder.js +286 -236
  7. package/dist/central-recovery-stage.js +3 -3
  8. package/dist/check-failure.js +2 -2
  9. package/dist/check-levels.js +3 -0
  10. package/dist/check-report.js +58 -7
  11. package/dist/contracts/console-api.js +4 -1
  12. package/dist/contracts/engine-api.js +1 -0
  13. package/dist/contracts/release-check.js +7 -4
  14. package/dist/contracts/release-terms.js +11 -2
  15. package/dist/contracts/verification-receipt.js +1 -1
  16. package/dist/deploy-gate.js +7 -1
  17. package/dist/direct-chat.js +3 -3
  18. package/dist/easy-start.js +8 -6
  19. package/dist/engine-reads.js +72 -0
  20. package/dist/flexible-conversation-schema.js +24 -0
  21. package/dist/flexible-conversation.js +162 -0
  22. package/dist/flexible-custody.js +3 -0
  23. package/dist/flexible-import.js +51 -0
  24. package/dist/flexible-session.js +84 -11
  25. package/dist/install-mode.js +1 -1
  26. package/dist/local-landing.js +500 -0
  27. package/dist/local-owner.js +1 -0
  28. package/dist/operate.js +143 -22
  29. package/dist/passwordless.js +1 -1
  30. package/dist/project-delete.js +1 -0
  31. package/dist/rehearsal.js +27 -0
  32. package/dist/release-adapters.js +170 -2
  33. package/dist/release-approval.js +11 -8
  34. package/dist/release-card.js +7 -2
  35. package/dist/release-carry.js +1 -1
  36. package/dist/release-cli.js +115 -14
  37. package/dist/release-main-proof.js +49 -0
  38. package/dist/release-main.js +110 -0
  39. package/dist/release-recheck.js +10 -3
  40. package/dist/release.js +221 -33
  41. package/dist/reply-shape.js +6 -1
  42. package/dist/result-actions.js +7 -1
  43. package/dist/result-follow-ups.js +8 -4
  44. package/dist/serve.js +31 -14
  45. package/dist/server/direct-chat.js +88 -3
  46. package/dist/server/engine-api.js +43 -5
  47. package/dist/server/render-results.js +3 -1
  48. package/dist/server/render-tasks.js +10 -1
  49. package/dist/server/route-table.js +9 -0
  50. package/dist/server/settings.js +31 -7
  51. package/dist/server/task-views.js +15 -0
  52. package/dist/server/tasks.js +63 -3
  53. package/dist/settings-groups-ui.js +2 -2
  54. package/dist/store.js +29 -4
  55. package/dist/surface.js +9 -1
  56. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  57. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  58. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  59. package/dist/tui/linux-x64/toolroll-tui +0 -0
  60. package/dist/verification-evidence.js +17 -6
  61. package/dist/workspace-ui.js +1 -1
  62. package/package.json +2 -1
  63. package/scripts/release-proof.mjs +240 -0
package/dist/operate.js CHANGED
@@ -126,6 +126,7 @@ import { isWritesMode, writesWords } from "./writes-mode.js";
126
126
  import { linuxFenceAvailable, macosFenceAvailable } from "./agent-fence.js";
127
127
  import { parseMachLookup, parseReadDeny, readDenyWords } from "./project-sandbox.js";
128
128
  import { LOCAL_POLICY } from "./surface.js";
129
+ import { land, landingWords, publishesThroughPullRequests, PULL_REQUESTS_INSTEAD, readLanding } from "./local-landing.js";
129
130
  import { asLocalOwner, currentLocalOwner, localActNow, LOCAL_MODE_CONFINES, localModeOn, localOwnerRefusal, localOwnerRequested } from "./local-owner.js";
130
131
  import { CHECK_ACCESS_WARNINGS, checkAccessRunsAs, checkAccessWords, isCheckAccess, signInHostsMissing, signInsUnavailableWords, widerThan } from "./check-access.js";
131
132
  import { CLI_PASSWORD_SOURCE, withPasswordSource } from "./sign-in-guard.js";
@@ -720,7 +721,7 @@ export const TASK_ACTIONS = [
720
721
  "add", "new", "keep", "list", "show", "wait", "state", "block", "unblock", "next", "steer", "pause", "continue", "assign",
721
722
  "reopen", "scope", "approve", "hold", "unhold", "require", "requeue", "regate", "plan",
722
723
  "review", "accept", "repair", "route", "stop", "resume", "complete", "revise", "merge", "ask",
723
- "checks", "add-tests", "archive", "restore", "tidy", "ship", "ready", "handover", "before-after", "failing-first",
724
+ "checks", "add-tests", "archive", "restore", "tidy", "ship", "ready", "handover", "before-after", "failing-first", "land",
724
725
  ];
725
726
  export const PUBLISH_ACTIONS = ["setup", "grant", "revoke", "status", "unblock", "rearm", "merge", "refire"];
726
727
  export const CONFIG_ACTIONS = ["show", "set", "clear"];
@@ -737,6 +738,7 @@ export const OPERATE_VALUE_FLAGS = new Set([
737
738
  "for", "tick-every", "bridge-every", "reconcile-every", "incarnation",
738
739
  "say", "ceiling-usd", "cap-usd",
739
740
  "incident",
741
+ "into",
740
742
  "case", "k", "world", "deny", "abandon",
741
743
  "token-file", "bin", "poll", "github", "remote", "head-prefix", "password",
742
744
  "not-requester", "protect", "protect-paths",
@@ -769,6 +771,8 @@ export const OPERATE_BOOLEAN_FLAGS = new Set([
769
771
  "preview",
770
772
  "diagnostic", "keep",
771
773
  "no-carry",
774
+ "from-main", "full-check",
775
+ "rehearsal",
772
776
  "json", "yes", "all", "brief", "local", "history", "latest-watch", "dry-run", "file",
773
777
  "clear", "follow", "ready", "all-tasks", "inbound-only", "help", "undo", "anyone", "allow-dispatch", "allow-merge", "merge-delete-branch",
774
778
  "no-open", "single-process", "laptop", "web", "remove", "no-verify", "no-follow", "end", "report", "off", "tmux",
@@ -3438,14 +3442,17 @@ async function decideCommand(positional, flags, context) {
3438
3442
  "The task returns to the ready set; the next tick resumes it with your answer in hand.",
3439
3443
  ]);
3440
3444
  }
3441
- async function startConsole(options) {
3445
+ export async function startConsole(options) {
3442
3446
  const { context } = options;
3443
- noticeGitIncidents(context.store, context.clock);
3447
+ const rehearsal = options.rehearsal === true;
3448
+ if (!rehearsal)
3449
+ noticeGitIncidents(context.store, context.clock);
3444
3450
  const identities = projectIdentities(context.folderLook);
3445
3451
  const server = createDecisionServer({
3446
3452
  identities,
3447
3453
  store: context.store,
3448
- backgroundChecks: true,
3454
+ backgroundChecks: !rehearsal,
3455
+ ...(rehearsal ? { rehearsal: true } : {}),
3449
3456
  ...(context.desktopIdentity === undefined ? {} : { desktopIdentity: context.desktopIdentity }),
3450
3457
  ...(context.additionalProjectRepos === undefined || options.currentRepos === undefined ? {} : { additionalProjectRepos: options.currentRepos }),
3451
3458
  evidenceRoot: context.evidenceRoot,
@@ -3455,7 +3462,7 @@ async function startConsole(options) {
3455
3462
  ...(options.localRunner === undefined ? {} : { localRunner: options.localRunner }),
3456
3463
  poolRoot: options.poolRoot,
3457
3464
  ...(options.allowedHosts === undefined ? {} : { allowedHosts: options.allowedHosts }),
3458
- tailnetNames: context.tailnetNames ?? (() => readTailnetNames()),
3465
+ tailnetNames: rehearsal ? (async () => []) : context.tailnetNames ?? (() => readTailnetNames()),
3459
3466
  leadByDefault: true,
3460
3467
  ...(options.setupCode === undefined ? {} : { setupCode: options.setupCode }),
3461
3468
  ...(options.repos === undefined ? {} : { repos: options.repos }),
@@ -3477,6 +3484,11 @@ async function startConsole(options) {
3477
3484
  }).catch(error => {
3478
3485
  throw new Error(`could not listen on ${options.host}:${options.port} — ${describe(error)}`);
3479
3486
  });
3487
+ const bound = server.address();
3488
+ const port = typeof bound === "object" && bound !== null ? bound.port : options.port;
3489
+ const shown = options.host === "0.0.0.0" || options.host === "::" ? "localhost" : options.host;
3490
+ if (rehearsal)
3491
+ return { server, port, url: `http://${shown}:${port}/` };
3480
3492
  consoleIdentitiesInBackground(identities, [...options.repos ?? [], ...options.projectRoots ?? [], ...context.store.listProjects().map(one => one.path), ...context.store.knownRepos()]);
3481
3493
  const stopMonitoring = startMonitoring({
3482
3494
  store: context.store, settings: () => readMonitoring(dirname(context.databaseFile)),
@@ -3494,18 +3506,19 @@ async function startConsole(options) {
3494
3506
  ];
3495
3507
  server.on("close", () => { for (const stop of besideConsole)
3496
3508
  stop(); });
3497
- const bound = server.address();
3498
- const port = typeof bound === "object" && bound !== null ? bound.port : options.port;
3499
- const shown = options.host === "0.0.0.0" || options.host === "::" ? "localhost" : options.host;
3500
3509
  return { server, port, url: `http://${shown}:${port}/` };
3501
3510
  }
3502
3511
  async function serveCommand(flags, context) {
3503
3512
  const { store, write, json } = context;
3504
3513
  const portGiven = text(flags, "port");
3505
3514
  const port = Number(portGiven ?? 4180);
3506
- if (portGiven !== undefined && (!Number.isInteger(port) || port < 1 || port >= 65536))
3515
+ const rehearsal = flags.get("rehearsal") === true;
3516
+ if (portGiven !== undefined && (!Number.isInteger(port) || port < (rehearsal ? 0 : 1) || port >= 65536))
3507
3517
  return fail(write, json, "serve", "usage", "--port is a whole number under 65536", EXIT.usage);
3508
3518
  const host = text(flags, "host") ?? "127.0.0.1";
3519
+ if (rehearsal && (host !== "127.0.0.1" || ["allow-host", "public-url", "runner", "editor", "repo", "project-root"].some(one => flags.has(one)))) {
3520
+ return fail(write, json, "serve", "usage", "--rehearsal serves 127.0.0.1 only, with no --allow-host, --public-url, --runner, --editor, --repo or --project-root", EXIT.usage);
3521
+ }
3509
3522
  const allow = text(flags, "allow-host");
3510
3523
  const repoFlag = text(flags, "repo");
3511
3524
  const rootFlag = text(flags, "project-root");
@@ -3522,6 +3535,7 @@ async function serveCommand(flags, context) {
3522
3535
  context,
3523
3536
  host,
3524
3537
  port,
3538
+ ...(rehearsal ? { rehearsal: true } : {}),
3525
3539
  ...(setupCode === undefined ? {} : { setupCode }),
3526
3540
  ...(localRunner === undefined ? {} : { localRunner }),
3527
3541
  ...(publicUrl === undefined ? {} : { publicUrl }),
@@ -4651,10 +4665,17 @@ async function verifyCommand(positional, flags, context) {
4651
4665
  const { store, write, json } = context;
4652
4666
  const clock = context.clock ?? (() => new Date());
4653
4667
  const action = positional[0] ?? "show";
4654
- const repo = text(flags, "repo");
4668
+ const raw = text(flags, "repo");
4669
+ if (raw !== undefined && activeRemote() !== null && !isAbsolute(raw))
4670
+ return fail(write, json, `verify ${action}`, "usage", "name the project's full path: --repo <path>", EXIT.usage);
4671
+ const repo = raw === undefined ? undefined : verifyRepoOf(store, raw);
4672
+ const legacy = raw !== undefined && raw !== repo && !isAbsolute(raw) && store.liveVerifyCommand(raw) !== null ? raw : null;
4673
+ const legacyNote = legacy === null ? [] : [`An older check command saved under the name "${legacy}" applies to no project. Set the command for ${repo} again; \`toolroll verify clear --repo ${legacy}\` removes the old one.`];
4655
4674
  if (action === "show") {
4656
4675
  if (repo === undefined)
4657
4676
  return fail(write, json, "verify show", "usage", "which repo? --repo <path>", EXIT.usage);
4677
+ for (const line of json ? [] : legacyNote)
4678
+ write(line);
4658
4679
  const live = store.liveVerifyCommand(repo);
4659
4680
  const quick = liveQuickCommand(store, repo);
4660
4681
  const level = projectCheckLevel(store, repo);
@@ -4705,7 +4726,9 @@ async function verifyCommand(positional, flags, context) {
4705
4726
  if (acting === null || !verified?.ok)
4706
4727
  return refuseApprover(context, `verify ${action}`, verified, "an approved verification command runs unattended after every future build — changing it takes `--as <you> --token <t>`", repo);
4707
4728
  if (action === "clear") {
4708
- const cleared = store.clearVerifyCommand(grantKey, acting.name, clock());
4729
+ if (legacy !== null && !quickClear)
4730
+ store.clearVerifyCommand(legacy, acting.name, clock());
4731
+ const cleared = store.clearVerifyCommand(grantKey, acting.name, clock()) || (legacy !== null && !quickClear);
4709
4732
  if (quickClear)
4710
4733
  return succeed(write, json, "verify clear", { repo, cleared, level: "quick" }, () => [
4711
4734
  cleared ? `Cleared the quick command — Quick builds of ${repo} run the full check now.` : `No quick command was set for ${repo}.`,
@@ -7694,6 +7717,8 @@ function taskAction(action, rest, flags, context) {
7694
7717
  return reviewTaskCommand(rest, flags, context);
7695
7718
  case "accept":
7696
7719
  return acceptTaskProof(rest, flags, context);
7720
+ case "land":
7721
+ return landTaskCommand(rest, flags, context);
7697
7722
  case "repair":
7698
7723
  return repairTaskCommand(rest, flags, context);
7699
7724
  case "route":
@@ -8081,7 +8106,7 @@ function listTasks(flags, context) {
8081
8106
  }
8082
8107
  function showTask(positional, context) {
8083
8108
  const { store, write, json, now } = context;
8084
- const id = positional[0];
8109
+ const id = positional[0] === undefined ? undefined : resolveTaskId(store, positional[0]);
8085
8110
  if (id === undefined)
8086
8111
  return fail(write, json, "task show", "usage", "which task?", EXIT.usage);
8087
8112
  const task = store.getTask(id);
@@ -8753,6 +8778,11 @@ async function scopeTask(positional, flags, context) {
8753
8778
  let releaseTerms;
8754
8779
  let releaseCheck;
8755
8780
  let releaseNote = null;
8781
+ const fromMain = flags.get("from-main") === true;
8782
+ if ((fromMain || flags.get("full-check") === true) && releaseGiven === undefined)
8783
+ return fail(write, json, "task scope", "usage", "--from-main and --full-check go with --release <version>:<pull request>:<branch>", EXIT.usage);
8784
+ if (flags.get("full-check") === true && !fromMain)
8785
+ return fail(write, json, "task scope", "usage", "--full-check goes with --from-main", EXIT.usage);
8756
8786
  if (releaseGiven !== undefined) {
8757
8787
  const spec = /^(\d+\.\d+\.\d+):([1-9][0-9]*):([A-Za-z0-9._/-]+)$/.exec(releaseGiven);
8758
8788
  if (spec === null || candidateGiven === undefined)
@@ -8760,6 +8790,16 @@ async function scopeTask(positional, flags, context) {
8760
8790
  const repo = store.lookupRef(id)?.repo ?? null;
8761
8791
  if (repo === null)
8762
8792
  return fail(write, json, "task scope", "usage", "a release scope's task has to be placed in its project first", EXIT.usage);
8793
+ if (fromMain) {
8794
+ const purpose = releaseCheckPurposeFor(store, { repo, version: spec[1], pr: Number(spec[2]), branch: spec[3], candidate: candidateGiven, main: { check: flags.get("full-check") === true ? "full" : "deploy" } });
8795
+ if (!purpose.ok)
8796
+ return fail(write, json, "task scope", "refused", `This release from main can't be filed: ${purpose.why}.`, EXIT.refused);
8797
+ releaseCheck = purpose.purpose;
8798
+ }
8799
+ }
8800
+ if (releaseGiven !== undefined && candidateGiven !== undefined && !fromMain) {
8801
+ const spec = /^(\d+\.\d+\.\d+):([1-9][0-9]*):([A-Za-z0-9._/-]+)$/.exec(releaseGiven);
8802
+ const repo = store.lookupRef(id).repo;
8763
8803
  const made = releaseTermsFor(store, { repo, version: spec[1], pr: Number(spec[2]), branch: spec[3], candidate: candidateGiven, now, noCarry: flags.get("no-carry") === true });
8764
8804
  if (made.ok)
8765
8805
  releaseTerms = made.terms;
@@ -9238,6 +9278,8 @@ async function askCredentials(flags, context) {
9238
9278
  const local = currentLocalOwner();
9239
9279
  if (local !== null)
9240
9280
  return { name: local.account, token: "" };
9281
+ if (name === undefined && token !== undefined && activeRemote() === null)
9282
+ name = soloOperatorOf(context.store) ?? undefined;
9241
9283
  if ((name === undefined || token === undefined) && interactive() && !context.json) {
9242
9284
  const usual = name === undefined ? soloOperatorOf(context.store) : null;
9243
9285
  if (name === undefined) {
@@ -11863,7 +11905,7 @@ async function releaseApproveCommand(positional, flags, context) {
11863
11905
  const repo = repoFlag === undefined ? null : resolve(repoFlag);
11864
11906
  const stateDir = dirname(context.databaseFile);
11865
11907
  const { journals, unreadable } = waitingJournals(stateDir, name => journalFile(stateDir, name));
11866
- const named = branch === undefined ? journals : journals.filter(one => one.branch === branch);
11908
+ const named = branch === undefined ? journals : journals.filter(one => one.branch === branch || (/^\d+\.\d+\.\d+$/.test(branch) && one.version === branch && one.file.endsWith(`/from-main/${branch}.json`)));
11867
11909
  if (branch !== undefined && named.length === 0 && unreadable.includes(basename(journalFile(stateDir, branch)))) {
11868
11910
  return fail(write, json, command, "unreadable", `${branch}'s release journal can't be read as one; nothing was approved. Run \`toolroll release ${branch}\` again.`, EXIT.refused);
11869
11911
  }
@@ -12742,11 +12784,11 @@ async function projectFlexibleCommand(positional, flags, context) {
12742
12784
  if (standing.state === "secure")
12743
12785
  return { data: { state: "secure" }, lines: [`${repo}: Secure. Work is planned and approved before it starts.`] };
12744
12786
  if (standing.state === "unreadable")
12745
- return { data: { state: "unreadable" }, lines: [`${repo}: its Flexible terms can't be read, so they allow nothing. Turn Flexible off, then on again.`] };
12787
+ return { data: { state: "unreadable" }, lines: [`${repo}: its thread terms can't be read, so they allow nothing. Turn interactive agent threads off for it, then on again.`] };
12746
12788
  const data = { state: standing.state, digest: standing.digest, terms: standing.terms, signedBy: standing.signedBy, signedAt: standing.signedAt, ...(standing.state === "lapsed" ? { lapse: standing.reason } : {}) };
12747
12789
  if (standing.state === "lapsed")
12748
12790
  return { data, lines: [`${repo}: Flexible terms no longer count. ${FLEXIBLE_LAPSE_WORDS[standing.reason]} Turn it on again to sign new terms.`] };
12749
- return { data, lines: [`${repo}: Flexible, turned on by ${standing.signedBy}.`, ...termsLines(standing.terms, standing.digest)] };
12791
+ return { data, lines: [`${repo}: interactive agent threads are on, turned on by ${standing.signedBy}.`, ...termsLines(standing.terms, standing.digest)] };
12750
12792
  };
12751
12793
  if (action === "show") {
12752
12794
  const now = shown(flexibleStanding(store, repo));
@@ -12754,16 +12796,16 @@ async function projectFlexibleCommand(positional, flags, context) {
12754
12796
  }
12755
12797
  const refused = (message) => fail(write, json, command, "person-only", message, EXIT.refused);
12756
12798
  if (machineActing() || process.env["TOOLROLL_LEAD_TOKEN"] !== undefined || process.env["TOOLROLL_REMOTE_TOKEN"] !== undefined)
12757
- return refused("Only a person changes a project's Flexible terms, never the lead, a token or a chat app.");
12799
+ return refused("Only a person changes a project's thread terms, never the lead, a token or a chat app.");
12758
12800
  const acting = await askCredentials(flags, context);
12759
12801
  if (acting === null)
12760
- return refused(`${action === "enable" ? "Turning on Flexible needs your password" : "This needs your sign-in"}: pass --as and --token.`);
12802
+ return refused(`${action === "enable" ? "Turning on interactive agent threads needs your password" : "This needs your sign-in"}: pass --as and --token.`);
12761
12803
  if (action === "enable") {
12762
12804
  if (!flexibleAvailable(store))
12763
12805
  return fail(write, json, command, "not-available", FLEXIBLE_UNAVAILABLE, EXIT.refused);
12764
12806
  const proved = credentialApprover(store, acting.name, acting.token, repo);
12765
12807
  if (!proved.ok)
12766
- return refused("Only an approver of this project, with their password typed now, turns on Flexible.");
12808
+ return refused("Only an approver of this project, with their password typed now, turns on interactive agent threads.");
12767
12809
  const choice = { ...(max === undefined ? {} : { max }), ...(chosenDefault === undefined ? {} : { default: chosenDefault }) };
12768
12810
  const proposed = proposedFlexibleTerms(store, repo, acting.name, choice);
12769
12811
  if (!proposed.ok)
@@ -12773,18 +12815,18 @@ async function projectFlexibleCommand(positional, flags, context) {
12773
12815
  if (!interactive() || json)
12774
12816
  return fail(write, json, command, "review-terms", [...termsLines(proposed.terms, proposed.digest), `Read these terms, then run again with --digest ${proposed.digest} to agree to them. Nothing changed.`].join("\n"), EXIT.refused, { digest: proposed.digest, terms: proposed.terms });
12775
12817
  write(termsLines(proposed.terms, proposed.digest).join("\n"));
12776
- if (!(await confirm("Turn on Flexible with these terms? [y/N] ")))
12818
+ if (!(await confirm("Turn on interactive agent threads in this project with these terms?")))
12777
12819
  return fail(write, json, command, "declined", "Nothing changed.", EXIT.refused);
12778
12820
  digest = proposed.digest;
12779
12821
  }
12780
12822
  const done = enableFlexible(store, { repo, by: acting.name, proof: proved.method, choice, shownDigest: digest, now: context.clock() });
12781
12823
  if (!done.ok)
12782
12824
  return fail(write, json, command, done.reason, done.message, EXIT.refused);
12783
- return succeed(write, json, command, { repo, flexible: shown(flexibleStanding(store, repo)).data, replaced: done.replaced }, () => [`${repo} is Flexible.`, ...termsLines(done.terms, done.digest)]);
12825
+ return succeed(write, json, command, { repo, flexible: shown(flexibleStanding(store, repo)).data, replaced: done.replaced }, () => [`Interactive agent threads are on in ${repo} (terms ${done.digest}). Start one with T in the terminal workbench.`]);
12784
12826
  }
12785
12827
  const proved = authenticateApprover(store, acting.name, acting.token, repo);
12786
12828
  if (!proved.ok || !personProof(proved.method))
12787
- return refused("Only an approver of this project, signed in as a person, changes its Flexible terms.");
12829
+ return refused("Only an approver of this project, signed in as a person, changes its thread terms.");
12788
12830
  if (action === "lower") {
12789
12831
  if (max === undefined)
12790
12832
  return fail(write, json, command, "usage", "Name the highest level with --max supervised, auto or full.", EXIT.usage);
@@ -12796,7 +12838,7 @@ async function projectFlexibleCommand(positional, flags, context) {
12796
12838
  const done = turnFlexibleOff(store, { repo, by: acting.name, now: context.clock() });
12797
12839
  if (!done.ok)
12798
12840
  return fail(write, json, command, done.reason, done.message, EXIT.refused);
12799
- return succeed(write, json, command, { repo, changed: done.changed, flexible: { state: "secure" } }, () => [done.changed ? `${repo} is Secure again. No new Flexible threads start.` : `${repo} is already Secure.`]);
12841
+ return succeed(write, json, command, { repo, changed: done.changed, flexible: { state: "secure" } }, () => [done.changed ? `Interactive agent threads are off in ${repo}. No new ones start.` : `Interactive agent threads are already off in ${repo}.`]);
12800
12842
  }
12801
12843
  async function taskSizingConfig(action, value, repoGiven, flags, context) {
12802
12844
  const { store, write, json, clock } = context;
@@ -13336,3 +13378,82 @@ async function requestCommand(positional, flags, context) {
13336
13378
  }
13337
13379
  return fail(context.write, context.json, "request", "usage", "Use `toolroll request [list [--all]|show <id>|wait <id>|decline <id>|clear]`.", EXIT.usage);
13338
13380
  }
13381
+ async function landTaskCommand(positional, flags, context) {
13382
+ const { store, write, json, now } = context;
13383
+ const command = "task land";
13384
+ const allowed = new Set(["json", "db", "into", "undo", "yes", "key", "as", "token", "token-file", "token-env"]);
13385
+ for (const key of flags.keys())
13386
+ if (!allowed.has(key))
13387
+ return fail(write, json, command, "usage", `--${key} is not a ${command} option.`, EXIT.usage);
13388
+ const id = positional[0] === undefined ? undefined : resolveTaskId(store, positional[0]);
13389
+ if (id === undefined || positional.length !== 1)
13390
+ return fail(write, json, command, "usage", "Use `toolroll task land <id>` to see what landing does, then `--yes --key <key>` to land it.", EXIT.usage);
13391
+ const into = text(flags, "into"), undo = flags.get("undo") === true, yes = flags.get("yes") === true, key = text(flags, "key");
13392
+ if (flags.has("into") && into === undefined)
13393
+ return fail(write, json, command, "usage", "--into needs a branch name.", EXIT.usage);
13394
+ if (undo && into !== undefined)
13395
+ return fail(write, json, command, "usage", "--undo lands on the branch the work landed on; it takes no --into.", EXIT.usage);
13396
+ const landRepo = store.lookupRef(id)?.repo ?? null;
13397
+ if (landRepo !== null && publishesThroughPullRequests(store, landRepo))
13398
+ return fail(write, json, command, "pull-requests", PULL_REQUESTS_INSTEAD, EXIT.refused);
13399
+ const local = currentLocalOwner();
13400
+ const localRepos = local === null ? null : store.knownRepos().filter(repo => store.accountCanAccess(local.account, repo));
13401
+ const options = { root: context.evidenceRoot, ...(into === undefined ? {} : { into }), ...(undo ? { undo: true } : {}) };
13402
+ if (!yes) {
13403
+ if (key !== undefined)
13404
+ return fail(write, json, command, "usage", "--key goes with --yes.", EXIT.usage);
13405
+ const read = await readLanding(store, id, { repos: localRepos }, now, options);
13406
+ if (!read.ok)
13407
+ return fail(write, json, command, read.reason, read.message, EXIT.refused);
13408
+ if (!("plan" in read))
13409
+ return succeed(write, json, command, { landed: read.landed }, () => [`${id} · Landed on ${read.landed.ref.replace(/^refs\/heads\//, "")} (${read.landed.commit.slice(0, 7)}).`]);
13410
+ const plan = read.plan;
13411
+ return succeed(write, json, command, { plan }, () => [...landingWords(plan),
13412
+ `To ${undo ? "undo it" : "land it"}: toolroll task land ${id}${into === undefined ? "" : ` --into ${into}`}${undo ? " --undo" : ""} --yes --key ${plan.key}`]);
13413
+ }
13414
+ if (key === undefined || !/^[0-9a-f]{16}$/.test(key))
13415
+ return fail(write, json, command, "usage", "--yes needs the --key `toolroll task land` showed you, so what lands is what you read.", EXIT.usage);
13416
+ let authority;
13417
+ if (local !== null)
13418
+ authority = { kind: "local" };
13419
+ else {
13420
+ const acting = await askCredentials(flags, context);
13421
+ const ref = store.lookupRef(id);
13422
+ const repos = store.knownRepos().filter(repo => acting !== null && store.accountCanAccess(acting.name, repo));
13423
+ const proved = acting === null || ref === null ? null : verifyApproverByPassword(store, acting.name, acting.token, repos);
13424
+ if (proved === null || !proved.ok)
13425
+ return fail(write, json, command, "unauthenticated", "Landing work is a person's act: it takes `--as <you>` and your password.", EXIT.refused);
13426
+ authority = { kind: "person", who: proved.who };
13427
+ }
13428
+ const access = { repos: authority.kind === "person" ? authority.who.repos : localRepos };
13429
+ const result = await land(store, id, { key, ...(into === undefined ? {} : { into }), ...(undo ? { undo: true } : {}) }, authority, access, now, { root: context.evidenceRoot });
13430
+ if (!result.ok)
13431
+ return fail(write, json, command, result.reason, result.message, EXIT.refused);
13432
+ return succeed(write, json, command, { landing: result }, () => [
13433
+ `${id} · ${result.replayed ? "Already " : ""}${result.kind === "undo" ? "Undone" : "Landed"} on ${result.branch} (${result.commit.slice(0, 7)})${result.mode === "ref" ? "; no folder had it open" : ""}.`,
13434
+ ...(result.warning === null ? [] : [result.warning])
13435
+ ]);
13436
+ }
13437
+ function resolveTaskId(store, typed) {
13438
+ if (store.getTask(typed) !== null || typed.startsWith("task-"))
13439
+ return typed;
13440
+ return store.getTask(`task-${typed}`) !== null ? `task-${typed}` : typed;
13441
+ }
13442
+ function verifyRepoOf(store, raw) {
13443
+ const absolute = isAbsolute(raw) ? raw : resolve(process.cwd(), raw);
13444
+ let real;
13445
+ try {
13446
+ real = realpathSync(absolute);
13447
+ }
13448
+ catch {
13449
+ return absolute;
13450
+ }
13451
+ for (const known of new Set([...store.listProjects().map(one => one.path), ...store.knownRepos()])) {
13452
+ try {
13453
+ if (known === absolute || realpathSync(known) === real)
13454
+ return known;
13455
+ }
13456
+ catch { }
13457
+ }
13458
+ return absolute;
13459
+ }
@@ -17,7 +17,7 @@ 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: signing in is the only password" : "Passwordless off: step-ups ask for the password again" });
20
+ detail: on ? "Passwordless on: approvals need no password" : "Passwordless off: step-ups ask for the password again" });
21
21
  store.bumpWake();
22
22
  return { changed: true };
23
23
  }
@@ -311,6 +311,7 @@ function deleteRows(store, repo, d, now) {
311
311
  del("thread_relay_pending", flexibleThreads, repo);
312
312
  del("flexible_relay_grant", flexibleThreads, repo);
313
313
  del("thread_turn", flexibleThreads, repo);
314
+ del("flexible_turn_said", flexibleThreads, repo);
314
315
  del("flexible_thread_launch", flexibleThreads, repo);
315
316
  del("flexible_thread_level", flexibleThreads, repo);
316
317
  del("flexible_thread", "repo = ? AND state IN ('removed', 'failed')", repo);
@@ -0,0 +1,27 @@
1
+ let depth = 0;
2
+ let realKill = null;
3
+ export function inRehearsal() { return depth > 0; }
4
+ export const REHEARSAL_SIGNAL_REFUSED = "a rehearsal never signals a process: every pid in its database copy belongs to the real computer";
5
+ export function enterRehearsal() {
6
+ if (depth === 0) {
7
+ realKill = process.kill.bind(process);
8
+ const real = realKill;
9
+ process.kill = ((pid, signal) => {
10
+ if ((signal === 0 || signal === "0") || pid === process.pid)
11
+ return real(pid, signal);
12
+ throw Object.assign(new Error(`${REHEARSAL_SIGNAL_REFUSED} (pid ${pid}, ${String(signal ?? "SIGTERM")})`), { code: "EPERM" });
13
+ });
14
+ }
15
+ depth += 1;
16
+ let left = false;
17
+ return () => {
18
+ if (left)
19
+ return;
20
+ left = true;
21
+ depth -= 1;
22
+ if (depth === 0 && realKill !== null) {
23
+ process.kill = realKill;
24
+ realKill = null;
25
+ }
26
+ };
27
+ }
@@ -9,7 +9,9 @@ import { parse as parseYaml } from "yaml";
9
9
  import { sleep } from "./sleep.js";
10
10
  import { callLabel, readOnlyCall, retryCall, retryingExec, writeWithRecheck } from "./release-net.js";
11
11
  const sqlite = () => createRequire(import.meta.url)("node:sqlite");
12
- import { PROTECTION_MINIMUM_CHECKS, PROTECTION_REPORT_ONLY_CHECKS } from "./release.js";
12
+ import { PROTECTION_MINIMUM_CHECKS, PROTECTION_REPORT_ONLY_CHECKS, REQUIRED_PR_CHECKS_WORKFLOW } from "./release.js";
13
+ import { bumpVersion, changelogHas, changelogWith, firstParentAfter, releaseBranchFor } from "./release-main.js";
14
+ import { recordMainReleaseProof, recordMainReleaseProofFailure } from "./release-main-proof.js";
13
15
  import { activeUpdateWork } from "./desktop-update-gate.js";
14
16
  import { BEFORE_SWAP, deployActionOf, stoppedWhereNothingChanged } from "./deploy-phase.js";
15
17
  import { gateOwner } from "./release-gate.js";
@@ -135,6 +137,7 @@ export function gateStateOf(answer, accounts = []) {
135
137
  result: resultRun === null || textOr(result["digest"]) === null ? null : {
136
138
  run: resultRun, head: textOr(result["head"]), receipt: String(result["digest"]), worktree: textOr(worktree),
137
139
  level: textOr(checks["level"]),
140
+ ...(textOr(checks["coverage"]) === null ? {} : { coverage: textOr(checks["coverage"]) }),
138
141
  check: textOr(checks["running"]) !== null ? "running"
139
142
  : checks["status"] === "passed" && checks["level"] !== "full" ? "not-full" : String(checks["status"] ?? "not-run"),
140
143
  },
@@ -458,7 +461,8 @@ export function releaseAdapters(options) {
458
461
  const added = await toolroll("task", "add", input.title, "--id", input.taskId, "--repo", input.checkout, "--checks", "full");
459
462
  if (added["ok"] !== true)
460
463
  throw new Error(`task add: ${refused(added)}`);
461
- const scoped = await toolroll("task", "scope", input.taskId, "--candidate", input.candidate, "--goal", input.goal, "--acceptance", input.acceptance, ...(input.release === undefined ? [] : ["--release", `${input.release.version}:${input.release.pr}:${input.release.branch}`, ...(input.release.noCarry ? ["--no-carry"] : [])]));
464
+ const scoped = await toolroll("task", "scope", input.taskId, "--candidate", input.candidate, "--goal", input.goal, "--acceptance", input.acceptance, ...(input.release === undefined ? [] : ["--release", `${input.release.version}:${input.release.pr}:${input.release.branch}`, ...(input.release.noCarry ? ["--no-carry"] : []),
465
+ ...(input.release.main === undefined ? [] : ["--from-main", ...(input.release.main.full ? ["--full-check"] : [])])]));
462
466
  if (scoped["ok"] !== true)
463
467
  throw new Error(`task scope: ${refused(scoped)}`);
464
468
  const digest = gateStateOf(await toolroll("task", "show", input.taskId)).scopeDigest;
@@ -620,6 +624,7 @@ export function releaseAdapters(options) {
620
624
  });
621
625
  },
622
626
  async release(repo, tag) { return (await gh("release", "view", tag, "--repo", repo, "--json", "tagName")).code === 0; },
627
+ main: mainReads(reads, ciGh),
623
628
  },
624
629
  registry: {
625
630
  async published(name, version) {
@@ -865,6 +870,8 @@ export function storeReleaseAdapter(open, done, now, runner, auto, nightlyReads)
865
870
  async stopped(input) { withStore(store => { noteReleaseStopped(store, { ...input, now: now() }); }); },
866
871
  async verified(input) { withStore(store => { recordVerifiedRelease(store, { ...input, now: now() }); }); },
867
872
  },
873
+ async proved(input) { withStore(store => { recordMainReleaseProof(store, { ...input, now: now() }); }); },
874
+ async proofFailed(input) { withStore(store => { recordMainReleaseProofFailure(store, { ...input, now: now() }); }); },
868
875
  ...(auto === undefined ? {} : {
869
876
  async recheck(taskId) {
870
877
  return withStore(store => {
@@ -1414,3 +1421,164 @@ async function macosCasesOf(run, gh, slug, sha) {
1414
1421
  rmSync(folder, { recursive: true, force: true });
1415
1422
  }
1416
1423
  }
1424
+ export function githubJson(run, gh) {
1425
+ return async (path) => {
1426
+ if (!/^repos\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_./?&=%:+-]+$/.test(path) || path.includes(".."))
1427
+ throw new Error(`not a GitHub read this makes: ${path.slice(0, 120)}`);
1428
+ const out = await run(gh, ["api", "--hostname", "github.com", "--method", "GET", path], { cwd: "/", env: ciEnv() });
1429
+ if (out.code !== 0)
1430
+ throw new Error(`GitHub answered ${(out.stderr || out.stdout).trim().split("\n").slice(-1)[0]?.slice(0, 200) || `gh exited ${out.code}`} for ${path.replace(/\?.*/, "")}`);
1431
+ try {
1432
+ return JSON.parse(out.stdout);
1433
+ }
1434
+ catch {
1435
+ throw new Error(`GitHub's answer for ${path.replace(/\?.*/, "")} couldn't be read`);
1436
+ }
1437
+ };
1438
+ }
1439
+ const proofModule = () => import(new URL("../scripts/release-proof.mjs", import.meta.url).href);
1440
+ export const FIRST_PARENT_PAGES = 5;
1441
+ export function mainReads(run, gh, proof = proofModule) {
1442
+ const api = githubJson(run, gh);
1443
+ const repoOk = (repo) => /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo);
1444
+ return {
1445
+ async pull(repo, version) {
1446
+ if (!repoOk(repo) || !/^\d+\.\d+\.\d+$/.test(version))
1447
+ return { kind: "none" };
1448
+ const branch = releaseBranchFor(version), owner = repo.split("/")[0];
1449
+ const rows = await api(`repos/${repo}/pulls?state=all&head=${encodeURIComponent(`${owner}:${branch}`)}&per_page=100`);
1450
+ if (!Array.isArray(rows))
1451
+ throw new Error("GitHub's pull requests couldn't be read");
1452
+ const own = rows.map(object).filter(pr => object(pr["base"])["ref"] === "main" && object(object(pr["base"])["repo"])["full_name"] === repo
1453
+ && object(pr["head"])["ref"] === branch && object(object(pr["head"])["repo"])["full_name"] === repo && Number.isSafeInteger(pr["number"]));
1454
+ const merged = own.filter(pr => typeof pr["merged_at"] === "string" && typeof pr["merge_commit_sha"] === "string" && /^[0-9a-f]{40}$/.test(pr["merge_commit_sha"]))
1455
+ .sort((a, b) => Date.parse(String(b["merged_at"])) - Date.parse(String(a["merged_at"])));
1456
+ if (merged[0] !== undefined)
1457
+ return { kind: "merged", pr: Number(merged[0]["number"]), sha: String(merged[0]["merge_commit_sha"]) };
1458
+ const open = own.find(pr => pr["state"] === "open");
1459
+ return open === undefined ? { kind: "none" } : { kind: "open", pr: Number(open["number"]), head: String(object(open["head"])["sha"]) };
1460
+ },
1461
+ async prove(repo, sha) {
1462
+ const proven = await (await proof()).proveRelease({ repo, sha, required: { ...REQUIRED_PR_CHECKS_WORKFLOW } }, api);
1463
+ return proven.ok ? { ok: true, sha, tree: proven.tree, pr: proven.pr, head: proven.head, branch: proven.branch } : proven;
1464
+ },
1465
+ async firstParent(repo, sha) {
1466
+ if (!repoOk(repo) || !/^[0-9a-f]{40}$/.test(sha))
1467
+ return { ok: false, why: "not a commit GitHub can be asked about" };
1468
+ const head = await readMainHead(run, gh, repo);
1469
+ const parents = new Map();
1470
+ for (let page = 1; page <= FIRST_PARENT_PAGES; page++) {
1471
+ const rows = await api(`repos/${repo}/commits?sha=${head}&per_page=100&page=${page}`);
1472
+ if (!Array.isArray(rows))
1473
+ throw new Error("GitHub's commit list couldn't be read");
1474
+ for (const row of rows.map(object)) {
1475
+ const id = row["sha"], listed = Array.isArray(row["parents"]) ? row["parents"].map(one => object(one)["sha"]) : null;
1476
+ if (typeof id !== "string" || listed === null || listed.some(one => typeof one !== "string"))
1477
+ throw new Error("GitHub's commit list couldn't be read");
1478
+ parents.set(id, listed);
1479
+ }
1480
+ const after = firstParentAfter(head, sha, parents);
1481
+ if (after !== null)
1482
+ return { ok: true, after };
1483
+ if (rows.length < 100)
1484
+ break;
1485
+ }
1486
+ return { ok: false, why: `${sha.slice(0, 7)} isn't on main's first-parent history from ${head.slice(0, 7)}` };
1487
+ },
1488
+ async changedSince(repo, tag, sha) {
1489
+ if (!repoOk(repo) || !/^v\d+\.\d+\.\d+$/.test(tag) || !/^[0-9a-f]{40}$/.test(sha))
1490
+ return null;
1491
+ try {
1492
+ const compared = object(await api(`repos/${repo}/compare/${tag}...${sha}?per_page=100`));
1493
+ const files = Array.isArray(compared["files"]) ? compared["files"].map(one => object(one)["filename"]) : null;
1494
+ if (files === null || files.some(one => typeof one !== "string") || files.length >= 300)
1495
+ return null;
1496
+ return files;
1497
+ }
1498
+ catch {
1499
+ return null;
1500
+ }
1501
+ },
1502
+ };
1503
+ }
1504
+ export async function prepareRelease(run, gh, input) {
1505
+ const { repo, version } = input;
1506
+ if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo) || !/^\d+\.\d+\.\d+$/.test(version))
1507
+ return { ok: false, why: "not a repository and version this prepares" };
1508
+ const api = githubJson(run, gh);
1509
+ const branch = releaseBranchFor(version);
1510
+ const exists = await run(gh, ["api", "--hostname", "github.com", "--method", "GET", `repos/${repo}/git/ref/heads/${branch}`], { cwd: "/", env: ciEnv() });
1511
+ if (exists.code === 0)
1512
+ return { ok: false, why: `${branch} already exists on GitHub; open its pull request or delete the branch first` };
1513
+ const head = await readMainHead(run, gh, repo);
1514
+ const commit = object(await api(`repos/${repo}/git/commits/${head}`));
1515
+ const baseTree = object(commit["tree"])["sha"];
1516
+ if (typeof baseTree !== "string" || !/^[0-9a-f]{40}$/.test(baseTree))
1517
+ return { ok: false, why: "GitHub didn't describe main's head" };
1518
+ const fileAt = async (path) => {
1519
+ const listed = await run(gh, ["api", "--hostname", "github.com", "--method", "GET", `repos/${repo}/contents/${path}?ref=${head}`, "--jq", ".sha"], { cwd: "/", env: ciEnv() });
1520
+ if (listed.code !== 0)
1521
+ return null;
1522
+ const blob = object(await api(`repos/${repo}/git/blobs/${listed.stdout.trim()}`));
1523
+ return blob["encoding"] === "base64" && typeof blob["content"] === "string" ? Buffer.from(blob["content"].replace(/\s/g, ""), "base64").toString("utf8") : null;
1524
+ };
1525
+ const manifest = await fileAt("package.json"), lock = await fileAt("package-lock.json"), changelog = await fileAt("CHANGELOG.md") ?? "# Changelog\n";
1526
+ if (manifest === null || lock === null)
1527
+ return { ok: false, why: "main's package.json or package-lock.json can't be read" };
1528
+ let from;
1529
+ try {
1530
+ from = String(object(JSON.parse(manifest))["version"]);
1531
+ }
1532
+ catch {
1533
+ return { ok: false, why: "main's package.json can't be read" };
1534
+ }
1535
+ if (versionAfter(from, version) || from === version)
1536
+ return { ok: false, why: `main is already at ${from}; ${version} must be later` };
1537
+ const nextManifest = bumpVersion("package.json", manifest, from, version), nextLock = bumpVersion("package-lock.json", lock, from, version);
1538
+ if (nextManifest === null || nextLock === null)
1539
+ return { ok: false, why: `main's ${nextManifest === null ? "package.json" : "package-lock.json"} doesn't have the shape whose version alone can be changed` };
1540
+ let nextChangelog = changelog;
1541
+ if (!changelogHas(changelog, version)) {
1542
+ if (input.notes === null || input.notes.trim() === "")
1543
+ return { ok: false, why: `CHANGELOG.md has no "## ${version}" entry: write it in a file and pass --notes <file>` };
1544
+ nextChangelog = changelogWith(changelog, version, input.notes, input.date);
1545
+ }
1546
+ const post = async (path, body) => {
1547
+ const out = await run(gh, ["api", "--hostname", "github.com", "--method", "POST", `repos/${repo}/${path}`, "--input", "-"], { cwd: "/", env: ciEnv(), input: JSON.stringify(body) });
1548
+ if (out.code !== 0)
1549
+ throw new Error(`GitHub refused ${path}: ${(out.stderr || out.stdout).trim().split("\n").slice(-1)[0]?.slice(0, 200)}`);
1550
+ return object(JSON.parse(out.stdout));
1551
+ };
1552
+ try {
1553
+ const blobs = await Promise.all([["package.json", nextManifest], ["package-lock.json", nextLock], ["CHANGELOG.md", nextChangelog]].map(async ([path, content]) => ({ path: path, mode: "100644", type: "blob", sha: String((await post("git/blobs", { content, encoding: "utf-8" }))["sha"]) })));
1554
+ const tree = String((await post("git/trees", { base_tree: baseTree, tree: blobs }))["sha"]);
1555
+ const made = String((await post("git/commits", { message: `Release ${version}`, tree, parents: [head] }))["sha"]);
1556
+ if (!/^[0-9a-f]{40}$/.test(made))
1557
+ return { ok: false, why: "GitHub made no commit" };
1558
+ await post("git/refs", { ref: `refs/heads/${branch}`, sha: made });
1559
+ const opened = await run(gh, ["pr", "create", "--repo", repo, "--head", branch, "--base", "main", "--title", `Release ${version}`,
1560
+ "--body", `The version and changelog for ${version}. Once its checks pass, merge it like any pull request, then run \`toolroll release ${version}\`.`], { cwd: "/", env: ciEnv() });
1561
+ if (opened.code !== 0)
1562
+ return { ok: false, why: `${branch} was pushed, but its pull request wasn't opened: ${(opened.stderr || opened.stdout).trim().split("\n").slice(-1)[0]}` };
1563
+ const pr = Number(/\/pull\/(\d+)/.exec(opened.stdout)?.[1]);
1564
+ return Number.isSafeInteger(pr) && pr > 0 ? { ok: true, pr, branch, commit: made } : { ok: false, why: "GitHub didn't name the pull request it opened" };
1565
+ }
1566
+ catch (error) {
1567
+ return { ok: false, why: String(error?.message ?? error) };
1568
+ }
1569
+ }
1570
+ export async function readMainVersion(run, gh, repo) {
1571
+ if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo))
1572
+ return null;
1573
+ const head = await readMainHead(run, gh, repo);
1574
+ const out = await run(gh, ["api", "--hostname", "github.com", "--method", "GET", `repos/${repo}/contents/package.json?ref=${head}`, "--jq", ".content"], { cwd: "/", env: ciEnv() });
1575
+ if (out.code !== 0)
1576
+ return null;
1577
+ try {
1578
+ const version = object(JSON.parse(Buffer.from(out.stdout.replace(/\\n|\s/g, ""), "base64").toString("utf8")))["version"];
1579
+ return typeof version === "string" && /^\d+\.\d+\.\d+$/.test(version) ? version : null;
1580
+ }
1581
+ catch {
1582
+ return null;
1583
+ }
1584
+ }