toolroll 0.9.105 → 0.9.107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/operate.js CHANGED
@@ -100,7 +100,7 @@ import { releaseStalledUpdate, waitingUpdate } from "./toolroll-update.js";
100
100
  import { dur } from "./design/kit.js";
101
101
  import { requeueEligibility, checkoutIdle, setCheckoutIdle, leadQuickAnswersOn, setLeadQuickAnswers, openStore, openStoreNoMigrate, initLocalMode, localModeCandidate, consoleServingNow, consoleComponent, consoleRowForPort, openConsoleRows, enrollOwnerPassword, installationCreatedBy, laptopPortOf, recordLaptopPort, localModeOf, localOwnerBinding, archiveTaskFamily, restoreTaskFamily, shipChecksForTask, elapsedSeconds, CONCURRENT_WRITER_WAIT_MS, isDatabaseBusy, databasePath, BUILT_IN, parseCapabilityKey, verifiedAuthor, isDigestTime, predecessorWatches, RESULT_SCREENSHOTS, lifecycleOf, reportLifecycle, beatLifecycle, } from "./store.js";
102
102
  import { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
103
- import { claimInstance, clearInstance, openInstanceSocket, proveLiveConsole } from "./console-instance.js";
103
+ import { claimInstance, clearInstance, instanceRunDir, openInstanceSocket, prepareRunDir, proveLiveConsole } from "./console-instance.js";
104
104
  import { backgroundOff, backgroundOn, backgroundShow, laptopStatus, laptopStop, restartOwnBuilder } from "./laptop-background.js";
105
105
  import { authorizePlanUnderMode } from "./plan-auto.js";
106
106
  import { ghDispatchAdapter, mirrorTaskId, syncPass } from "./sync.js";
@@ -120,6 +120,7 @@ import { LOCAL_POLICY } from "./surface.js";
120
120
  import { asLocalOwner, currentLocalOwner, LOCAL_MODE_CONFINES, localModeOn, localOwnerRefusal, localOwnerRequested } from "./local-owner.js";
121
121
  import { CHECK_ACCESS_WARNINGS, checkAccessRunsAs, checkAccessWords, isCheckAccess, signInHostsMissing, signInsUnavailableWords, widerThan } from "./check-access.js";
122
122
  import { CLI_PASSWORD_SOURCE, withPasswordSource } from "./sign-in-guard.js";
123
+ import { ledgerSpent, NO_SAFE_OPENER, openSignInLink, platformOpener } from "./sign-in-page.js";
123
124
  import { admissionRecorded, admitProject, commandLineActor } from "./project-admission.js";
124
125
  import { leadClaim, leadSay, noteLeadWork } from "./lead-voice.js";
125
126
  import { createConnection as createNetConnection, createServer as createNetServer } from "node:net";
@@ -166,7 +167,7 @@ function planContractLines(store, evidenceRoot, taskId) {
166
167
  import { verdictWords as proofVerdictWords, matrixWords, plainReasonWords, semanticCoverage, coverageWords } from "./proof.js";
167
168
  import { probeRepo } from "./probe.js";
168
169
  import { agentlessFirstRun, diagnoseTaskDispatch, diagnosisIsDispatchable, NO_AGENT_TITLE, scopeApprovedForDispatch, } from "./dispatch.js";
169
- import { createDecisionServer } from "./serve.js";
170
+ import { createDecisionServer, SIGN_IN_LINK_MS } from "./serve.js";
170
171
  import { readTailnetNames } from "./tailnet.js";
171
172
  import { daemonLaunchCommand, daemonStatus, installReplacingLegacy, installedLegacyDaemon, planDaemon, uninstallDaemon, awaitFreshHeartbeat, } from "./daemon.js";
172
173
  import { bridgePass, clearBotToken, createTransport, followBridge, hashPairingCode, loadBotToken, mintPairingCode, networkFence, networkFenceLine, redactToken, saveBotToken, PAIRING_TTL_MS, TOKEN_ENV, telegramHookSecret, telegramPushUrl, } from "./telegram.js";
@@ -198,6 +199,7 @@ import { mintCoordinator, revokeCoordinator, listCoordinators } from "./coordina
198
199
  import { serveMcp } from "./mcp.js";
199
200
  import { createInterface } from "node:readline";
200
201
  import { hashPassword } from "./scope.js";
202
+ import { noticeDueOnce, CONTAINMENT_NOTICE_FACT } from "./store.js";
201
203
  import { propose, approve, addApprover, authenticateAccount, authenticateApprover as passwordApprover, describeScope, approvalOf, hashToken as hashApproverToken, modeFilingCoverage, acceptanceLinesToInput, parseAcceptanceCriteria, splitAcceptanceRubric, rubricIsPlaceholder, isCommitSha, credentialProof, rememberedLogin, personApprovalOf } from "./scope.js";
202
204
  import { CHAT_APPROVE_ALL, presetTerms, modeTermsJson, modeDigestOf, modeTermsFromJson, modeWords, MODE_MAX_DAYS } from "./modes.js";
203
205
  import { WorktreePool } from "./worktree.js";
@@ -6514,6 +6516,7 @@ async function upCommand(flags, context) {
6514
6516
  }
6515
6517
  }, RUNNER_HEARTBEAT_MS);
6516
6518
  runnerHeartbeat.unref?.();
6519
+ let removeSignInPageNow = () => { };
6517
6520
  const approverPlan2 = approver;
6518
6521
  const terminal = !agentRunning && (context.upSeams?.terminal ?? process.stdout.isTTY === true);
6519
6522
  const upHandoff = buildHandoff({
@@ -6546,7 +6549,11 @@ async function upCommand(flags, context) {
6546
6549
  const account = approverPlan2.approver;
6547
6550
  const localStart = approverPlan2.startAuthority === "local";
6548
6551
  const request = upLinkRequest(approverPlan2.startAuthority, account);
6549
- const link = request === null || flags.has("no-open") ? null : await new Promise(resolveLink => {
6552
+ const pageParent = instanceRunDir(context.databaseFile);
6553
+ const hasOpener = platformOpener(context.upSeams?.signInPlatform) !== null;
6554
+ const canOpen = hasOpener && prepareRunDir(pageParent) === null;
6555
+ const linkExpiresAt = Date.now() + SIGN_IN_LINK_MS;
6556
+ const link = request === null || flags.has("no-open") || !canOpen ? null : await new Promise(resolveLink => {
6550
6557
  const id = ++linkRequests;
6551
6558
  const timer = setTimeout(() => { pendingLinks.delete(id); resolveLink(null); }, 10_000);
6552
6559
  pendingLinks.set(id, value => { clearTimeout(timer); resolveLink(value); });
@@ -6557,28 +6564,40 @@ async function upCommand(flags, context) {
6557
6564
  const signInWords = account === null
6558
6565
  ? `sign in as one of ${approverPlan2.approvers.join(", ")}`
6559
6566
  : showCommand === null ? `sign in as ${account} with your password` : `sign in as ${account}`;
6567
+ const opened = link === null ? false : await (async () => {
6568
+ const outcome = localStart ? "local link" : "one-time link";
6569
+ const page = await openSignInLink(new URL(link, url).toString(), {
6570
+ parent: pageParent, spent: ledgerSpent(store, outcome, localStart ? null : account), expiresAt: linkExpiresAt,
6571
+ ...(context.upSeams?.signInOpener === undefined ? {} : { opener: context.upSeams.signInOpener }),
6572
+ ...(context.upSeams?.signInPlatform === undefined ? {} : { platform: context.upSeams.signInPlatform }),
6573
+ });
6574
+ removeSignInPageNow = page.stop;
6575
+ return page.opened;
6576
+ })();
6560
6577
  write("");
6561
6578
  write(`Toolroll is on ${url}`);
6562
6579
  if (localStart) {
6563
- if (link !== null) {
6580
+ if (opened) {
6564
6581
  write("Opening it in your browser now, already signed in.");
6565
6582
  write("If it doesn't open, stop it with Ctrl-C and run the same command again.");
6566
- (context.upSeams?.openBrowser ?? openBrowser)(new URL(link, url).toString());
6567
6583
  }
6568
- else
6584
+ else if (flags.has("no-open"))
6569
6585
  write("To sign in from this computer's browser, run the same command again without --no-open.");
6586
+ else if (!hasOpener)
6587
+ write(`${NO_SAFE_OPENER.charAt(0).toUpperCase()}${NO_SAFE_OPENER.slice(1)}.`);
6588
+ else
6589
+ write("Your browser didn't open. Stop it with Ctrl-C and run the same command again.");
6570
6590
  }
6571
- else if (link !== null) {
6591
+ else if (opened) {
6572
6592
  write("Opening it in your browser now, already signed in.");
6573
6593
  write(`If it doesn't open, go to that address and ${signInWords}.`);
6574
- (context.upSeams?.openBrowser ?? openBrowser)(new URL(link, url).toString());
6575
6594
  }
6576
6595
  else {
6577
6596
  write(`${signInWords.charAt(0).toUpperCase()}${signInWords.slice(1)}.`);
6578
6597
  }
6579
6598
  if (showCommand !== null)
6580
6599
  write(`Your password: run \`${showCommand}\``);
6581
- if (link === null)
6600
+ if (!opened)
6582
6601
  write("Ctrl-C stops it.");
6583
6602
  }
6584
6603
  }
@@ -6587,6 +6606,7 @@ async function upCommand(flags, context) {
6587
6606
  runTimer.unref?.();
6588
6607
  }
6589
6608
  await stopped;
6609
+ removeSignInPageNow();
6590
6610
  if (workerRole !== null)
6591
6611
  await Promise.race([workerRole.done, forced]);
6592
6612
  clearInterval(runnerHeartbeat);
@@ -10748,9 +10768,15 @@ async function runUpWorkerRole(context, config, port, build) {
10748
10768
  const prefix = (repo) => (activeRepos.size > 1 ? `[${projectName(repo)}] ` : "");
10749
10769
  const containmentDetail = config.verbose || !config.terminal;
10750
10770
  let containmentSaid = false;
10771
+ const firstContainmentNotice = () => { try {
10772
+ return noticeDueOnce(context.store, CONTAINMENT_NOTICE_FACT, clock());
10773
+ }
10774
+ catch {
10775
+ return true;
10776
+ } };
10751
10777
  const containmentLines = (effective) => {
10752
10778
  const notice = containmentNotice(effective);
10753
- if (notice !== null && !containmentSaid)
10779
+ if (notice !== null && !containmentSaid && (containmentDetail || firstContainmentNotice()))
10754
10780
  progress(notice);
10755
10781
  containmentSaid = true;
10756
10782
  return containmentDetail || effective.refusal !== null ? [`watch: ${describeContainment(effective)}`] : [];
@@ -1,7 +1,7 @@
1
1
  import { spawnSync } from "node:child_process";
2
- import { existsSync, mkdirSync, readFileSync } from "node:fs";
2
+ import { accessSync, constants as fsConstants, existsSync, mkdirSync, readFileSync, statSync } from "node:fs";
3
3
  import { createRequire } from "node:module";
4
- import { dirname, join } from "node:path";
4
+ import { delimiter, dirname, join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { wrapCommandWithSandboxMacOS } from "@anthropic-ai/sandbox-runtime/dist/sandbox/macos-sandbox-utils.js";
7
7
  import { checkLinuxDependencies, getLinuxDependencyStatus } from "@anthropic-ai/sandbox-runtime/dist/sandbox/linux-sandbox-utils.js";
@@ -27,6 +27,9 @@ export function sandboxRuntimeProblem(platform = process.platform) {
27
27
  return probe.status === 0 ? null : "sandbox-exec can't start a sandbox here (is this already inside one?)";
28
28
  }
29
29
  if (platform === "linux") {
30
+ const missing = missingLinuxSandboxTools();
31
+ if (missing.length > 0)
32
+ return `${toolWords(missing)} ${missing.length === 1 ? "is" : "are"} not installed (${linuxSandboxInstallLine(missing)})`;
30
33
  const checked = checkLinuxDependencies();
31
34
  if (checked.errors.length > 0)
32
35
  return checked.errors.join("; ");
@@ -39,6 +42,37 @@ export function sandboxRuntimeProblem(platform = process.platform) {
39
42
  }
40
43
  return `the sandbox runtime has no sandbox for ${platform}`;
41
44
  }
45
+ export const LINUX_SANDBOX_TOOLS = [
46
+ { command: "bwrap", package: "bubblewrap" },
47
+ { command: "socat", package: "socat" },
48
+ { command: "rg", package: "ripgrep" },
49
+ ];
50
+ function toolWords(packages) {
51
+ return packages.length <= 1 ? packages.join("") : `${packages.slice(0, -1).join(", ")} and ${packages.at(-1)}`;
52
+ }
53
+ export function missingLinuxSandboxTools(path = process.env["PATH"] ?? "") {
54
+ const folders = path.split(delimiter).filter(folder => folder !== "");
55
+ const found = (command) => folders.some(folder => {
56
+ try {
57
+ accessSync(join(folder, command), fsConstants.X_OK);
58
+ return statSync(join(folder, command)).isFile();
59
+ }
60
+ catch {
61
+ return false;
62
+ }
63
+ });
64
+ return LINUX_SANDBOX_TOOLS.filter(tool => !found(tool.command)).map(tool => tool.package);
65
+ }
66
+ export function linuxSandboxInstallLine(packages = LINUX_SANDBOX_TOOLS.map(tool => tool.package)) {
67
+ return `sudo apt update && sudo apt install ${packages.join(" ")} (Fedora: sudo dnf install ${packages.join(" ")})`;
68
+ }
69
+ export const linuxSandboxToolsWords = () => toolWords(LINUX_SANDBOX_TOOLS.map(tool => tool.package));
70
+ export function missingSandboxToolsWords(missing) {
71
+ return [
72
+ `Toolroll needs ${toolWords(missing)} to run agents in a sandbox on this computer.`,
73
+ `Install ${missing.length === 1 ? "it" : "them"}, then run toolroll again: ${linuxSandboxInstallLine(missing)}`,
74
+ ];
75
+ }
42
76
  export function shellQuote(words) {
43
77
  return words.map(word => /^[A-Za-z0-9_@%+=:,./-]+$/.test(word) ? word : `'${word.replace(/'/g, `'\\''`)}'`).join(" ");
44
78
  }
@@ -0,0 +1,197 @@
1
+ import { spawn as spawnChild } from "node:child_process";
2
+ import { chmodSync, lstatSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
3
+ import { basename, dirname, join } from "node:path";
4
+ import { SIGN_IN_LINK_MS } from "./server/session.js";
5
+ export const NO_SAFE_OPENER = "this computer can't open a browser for Toolroll safely. To use the browser, run `toolroll password set` and sign in with that password";
6
+ export function platformOpener(platform = process.platform) {
7
+ return platform === "darwin" ? "open" : platform === "linux" ? "xdg-open" : null;
8
+ }
9
+ const PAGE_FOLDER = /^sign-in-[A-Za-z0-9]{6}$/;
10
+ const PAGE_FILE = "open.html";
11
+ export function writeSignInPage(parent, link, now = Date.now()) {
12
+ sweepSignInPages(parent, now);
13
+ const dir = mkdtempSync(join(parent, "sign-in-"));
14
+ const file = join(dir, PAGE_FILE);
15
+ try {
16
+ chmodSync(dir, 0o700);
17
+ const attribute = link.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
18
+ writeFileSync(file, `<!doctype html><meta charset="utf-8"><meta name="referrer" content="no-referrer">`
19
+ + `<meta http-equiv="refresh" content="0;url=${attribute}"><title>Toolroll</title>`
20
+ + `<script>location.replace(${JSON.stringify(link).replace(/</g, "\\u003c")})</script><p>Opening Toolroll…</p>\n`, { mode: 0o600 });
21
+ chmodSync(file, 0o600);
22
+ }
23
+ catch (error) {
24
+ rmSync(dir, { recursive: true, force: true });
25
+ throw error;
26
+ }
27
+ return file;
28
+ }
29
+ export function removeSignInPage(file) {
30
+ const dir = dirname(file);
31
+ if (basename(file) !== PAGE_FILE || !PAGE_FOLDER.test(basename(dir)))
32
+ throw Error(`${file} isn't a sign-in page`);
33
+ let info;
34
+ try {
35
+ info = lstatSync(dir);
36
+ }
37
+ catch (error) {
38
+ if (error.code === "ENOENT")
39
+ return;
40
+ throw error;
41
+ }
42
+ if (!info.isDirectory())
43
+ throw Error(`${dir} isn't a sign-in page's folder`);
44
+ rmSync(dir, { recursive: true, force: true });
45
+ }
46
+ function sweepSignInPages(parent, now) {
47
+ let names;
48
+ try {
49
+ names = readdirSync(parent);
50
+ }
51
+ catch {
52
+ return;
53
+ }
54
+ const uid = process.getuid?.() ?? -1;
55
+ for (const name of names) {
56
+ if (!PAGE_FOLDER.test(name))
57
+ continue;
58
+ try {
59
+ const info = lstatSync(join(parent, name));
60
+ if (!info.isDirectory() || (uid >= 0 && info.uid !== uid) || now - info.mtimeMs < SIGN_IN_LINK_MS)
61
+ continue;
62
+ removeSignInPage(join(parent, name, PAGE_FILE));
63
+ }
64
+ catch { }
65
+ }
66
+ }
67
+ export function openSignInPage(file, spawn = spawnChild, platform = process.platform, settleMs = 3_000) {
68
+ const command = platformOpener(platform);
69
+ if (command === null)
70
+ return Promise.resolve(false);
71
+ return new Promise(resolve => {
72
+ let settled = false;
73
+ let timer;
74
+ const end = (opened) => {
75
+ if (settled)
76
+ return;
77
+ settled = true;
78
+ if (timer !== undefined)
79
+ clearTimeout(timer);
80
+ resolve(opened);
81
+ };
82
+ let child;
83
+ try {
84
+ child = spawn(command, [file], { detached: true, stdio: "ignore" });
85
+ }
86
+ catch {
87
+ end(false);
88
+ return;
89
+ }
90
+ child.on("error", () => end(false));
91
+ child.once("exit", code => end(code === 0));
92
+ timer = setTimeout(() => end(true), settleMs);
93
+ child.unref();
94
+ });
95
+ }
96
+ export function ledgerSpent(store, outcome, account) {
97
+ const sinceRow = store.handle.prepare("SELECT coalesce(max(id), 0) AS id FROM action_ledger").get();
98
+ const since = Number(sinceRow?.["id"] ?? 0);
99
+ const spent = store.handle.prepare("SELECT actor FROM action_ledger WHERE id > ? AND source = 'sign-in' AND action = 'signed in' AND outcome = ?");
100
+ return () => spent.all(since, outcome).some(row => account === null || row["actor"] === account);
101
+ }
102
+ const held = new Set();
103
+ let exitHooked = false;
104
+ function holdUntilExit(finish) {
105
+ held.add(finish);
106
+ if (exitHooked)
107
+ return;
108
+ exitHooked = true;
109
+ process.once("exit", () => { for (const one of [...held])
110
+ one(); });
111
+ }
112
+ const REMOVE_RETRIES = 3;
113
+ const REMOVE_RETRY_MS = 250;
114
+ export function removeSignInPageWhenSpent(file, spent, options = {}) {
115
+ let done = false;
116
+ let resolveGone = () => { };
117
+ const gone = new Promise(resolve => { resolveGone = resolve; });
118
+ const removeOnce = options.remove ?? removeSignInPage;
119
+ const remove = (left) => {
120
+ try {
121
+ removeOnce(file);
122
+ }
123
+ catch {
124
+ if (left > 0) {
125
+ const again = setTimeout(() => remove(left - 1), REMOVE_RETRY_MS);
126
+ again.unref?.();
127
+ }
128
+ }
129
+ };
130
+ const finish = () => {
131
+ if (done)
132
+ return;
133
+ done = true;
134
+ held.delete(finish);
135
+ clearInterval(timer);
136
+ clearTimeout(expiry);
137
+ try {
138
+ remove(REMOVE_RETRIES);
139
+ }
140
+ finally {
141
+ try {
142
+ options.onEnd?.();
143
+ }
144
+ catch { }
145
+ resolveGone();
146
+ }
147
+ };
148
+ const timer = setInterval(() => { try {
149
+ if (spent())
150
+ finish();
151
+ }
152
+ catch {
153
+ finish();
154
+ } }, options.everyMs ?? 500);
155
+ const expiry = setTimeout(finish, Math.max(0, (options.expiresAt ?? Date.now() + SIGN_IN_LINK_MS) - Date.now()));
156
+ timer.unref?.();
157
+ expiry.unref?.();
158
+ holdUntilExit(finish);
159
+ return { stop: finish, gone };
160
+ }
161
+ export async function openSignInLink(link, options) {
162
+ const platform = options.platform ?? process.platform;
163
+ const nothing = { opened: false, stop: () => { }, wait: async () => { } };
164
+ const end = () => { try {
165
+ options.onEnd?.();
166
+ }
167
+ catch { } };
168
+ if (platformOpener(platform) === null) {
169
+ end();
170
+ return nothing;
171
+ }
172
+ let file;
173
+ try {
174
+ file = writeSignInPage(options.parent, link);
175
+ }
176
+ catch {
177
+ end();
178
+ return nothing;
179
+ }
180
+ const watch = removeSignInPageWhenSpent(file, options.spent, {
181
+ expiresAt: options.expiresAt,
182
+ ...(options.everyMs === undefined ? {} : { everyMs: options.everyMs }),
183
+ ...(options.onEnd === undefined ? {} : { onEnd: options.onEnd }),
184
+ });
185
+ if (!await openSignInPage(file, options.opener ?? spawnChild, platform)) {
186
+ watch.stop();
187
+ return nothing;
188
+ }
189
+ const wait = async (ms) => {
190
+ let bound;
191
+ await Promise.race([watch.gone, new Promise(resolve => { bound = setTimeout(resolve, ms); })]);
192
+ if (bound !== undefined)
193
+ clearTimeout(bound);
194
+ watch.stop();
195
+ };
196
+ return { opened: true, stop: watch.stop, wait };
197
+ }
package/dist/store.js CHANGED
@@ -18656,3 +18656,7 @@ function viewPreferenceShapeProblem(db) {
18656
18656
  const want = canonicalDdl(V160_SCHEMA.trim().replace(/;$/, "")).trim();
18657
18657
  return canonicalDdl(String(row["sql"])).trim() === want ? null : "the view_preference table has an unknown shape";
18658
18658
  }
18659
+ export const CONTAINMENT_NOTICE_FACT = "containment-notice-shown";
18660
+ export function noticeDueOnce(store, key, now) {
18661
+ return Number(store.handle.prepare("INSERT OR IGNORE INTO installation_fact (key, value, created_at) VALUES (?, 'yes', ?)").run(key, now.toISOString()).changes) === 1;
18662
+ }
@@ -17,7 +17,14 @@ toolroll update --yes update: verify, let running work finish, back up
17
17
  --at HH:MM wait until then (e.g. --at 03:00)
18
18
  --allow-downgrade with --version, go back to an older release
19
19
  toolroll update --rollback [--yes] return to the previous version and its database backup
20
- toolroll update --status | --resume | --cancel`;
20
+ toolroll update --status | --resume | --cancel
21
+ Releases 0.9.105 and earlier don't start on a Node whose SQLite is 3.54 or newer (Node 22.23, 24.22, 26.13 and later).`;
22
+ export function oldReleaseProblem(target, sqlite) {
23
+ const [major = 0, minor = 0] = (sqlite ?? "").split(".").map(part => Number.parseInt(part, 10) || 0);
24
+ if ((major < 3 || (major === 3 && minor < 54)) || isNewer(target, "0.9.105"))
25
+ return null;
26
+ return `Toolroll ${target} can't start on this Node: its SQLite (${sqlite}) refuses that release's Tasks list ("VIEWs and/or subqueries nested too deep"). Releases 0.9.105 and earlier need a Node whose SQLite is older than 3.54, such as Node 22.22.0.`;
27
+ }
21
28
  export async function runUpdateCommand(args, write, deps = {}) {
22
29
  const has = (name) => args.includes(`--${name}`);
23
30
  const value = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
@@ -91,6 +98,11 @@ export async function runUpdateCommand(args, write, deps = {}) {
91
98
  write("There is no completed update to roll back.");
92
99
  return 1;
93
100
  }
101
+ const old = oldReleaseProblem(last.from.version, deps.sqlite ?? process.versions.sqlite);
102
+ if (old !== null) {
103
+ write(old);
104
+ return 1;
105
+ }
94
106
  if (!has("yes")) {
95
107
  write(`Roll back ${last.to.version} → ${last.from.version}, with the database as it was before the update (${last.finishedAt?.slice(0, 16).replace("T", " ") ?? "unknown"} UTC).`);
96
108
  const since = recordsSince(databaseFile, last.finishedAt ?? last.updatedAt);
@@ -122,6 +134,11 @@ export async function runUpdateCommand(args, write, deps = {}) {
122
134
  write(`Toolroll ${version} is older than ${current.version}. Add --allow-downgrade to go back to it.`);
123
135
  return 1;
124
136
  }
137
+ const old = downgrade ? oldReleaseProblem(version, deps.sqlite ?? process.versions.sqlite) : null;
138
+ if (old !== null) {
139
+ write(old);
140
+ return 1;
141
+ }
125
142
  if (!has("yes")) {
126
143
  write(`Update Toolroll ${current.version} → ${version}.`);
127
144
  write(`${when === "now" ? "Refuses if any work is running" : when === "at" ? `Waits until ${at}, then pauses new work and lets running work finish` : "Pauses new work and lets running work finish"}; verifies the package came from ap9000/toolroll's publish workflow; backs up and rehearses the database; keeps ${current.version} for toolroll update --rollback.`);