toolroll 0.9.128 → 0.9.130
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/CHANGELOG.md +41 -0
- package/dist/accent-colors.js +3 -1
- package/dist/agent-fence.js +0 -2
- package/dist/agents-board.js +0 -3
- package/dist/approval-authority.js +2 -1
- package/dist/assignment.js +56 -2
- package/dist/backup-ui.js +6 -3
- package/dist/backup.js +6 -0
- package/dist/bounded-spawn.js +0 -1
- package/dist/browser/manifest.json +57 -0
- package/dist/browser/terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js.br +0 -0
- package/dist/browser/terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js.gz +0 -0
- package/dist/browser/{terminal.css → terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css} +1 -1
- package/dist/browser/terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css.br +0 -0
- package/dist/browser/terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css.gz +0 -0
- package/dist/browser/{workspace.js → workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js} +25 -25
- package/dist/browser/workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js.br +0 -0
- package/dist/browser/workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js.gz +0 -0
- package/dist/browser/{workspace.css → workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css} +1 -1
- package/dist/browser/workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css.br +0 -0
- package/dist/browser/workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css.gz +0 -0
- package/dist/browser-shell.js +271 -25
- package/dist/canvas-freshness.js +122 -0
- package/dist/canvas-fs.js +273 -0
- package/dist/canvas-reads.js +747 -0
- package/dist/canvas-state-key.js +45 -0
- package/dist/canvas-state-worker.js +12 -0
- package/dist/central-recovery-stage.js +3 -3
- package/dist/chat-actions.js +26 -0
- package/dist/chat-channel.js +4 -3
- package/dist/chat-task-actions.js +1 -1
- package/dist/chat-warmth.js +0 -1
- package/dist/check-report.js +0 -6
- package/dist/commit-extract.js +79 -40
- package/dist/companion/access.js +162 -0
- package/dist/companion/actions.js +622 -0
- package/dist/companion/bonjour.js +45 -0
- package/dist/companion/canvas.js +141 -0
- package/dist/companion/chat-origin.js +92 -0
- package/dist/companion/chat.js +571 -0
- package/dist/companion/daemon.js +1387 -0
- package/dist/companion/direct-server.js +177 -0
- package/dist/companion/finish.js +51 -0
- package/dist/companion/framing.js +498 -0
- package/dist/companion/noise.js +461 -0
- package/dist/companion/passkey-gate.js +287 -0
- package/dist/companion/paths.js +90 -0
- package/dist/companion/reads.js +283 -0
- package/dist/companion/relay-auth.js +265 -0
- package/dist/companion/relay-server.js +870 -0
- package/dist/companion/schema.js +289 -0
- package/dist/companion/service.js +581 -0
- package/dist/companion/store.js +325 -0
- package/dist/companion/webauthn.js +407 -0
- package/dist/console-instance.js +0 -4
- package/dist/contracts/console-api.js +18 -0
- package/dist/converse.js +0 -1
- package/dist/coordinator.js +1 -1
- package/dist/design/kit.css +30 -0
- package/dist/desktop-config.js +156 -0
- package/dist/desktop-host.js +6 -152
- package/dist/desktop-update.js +1 -1
- package/dist/finished-task-sql.js +14 -0
- package/dist/flexible-answers.js +0 -1
- package/dist/github-read.js +41 -0
- package/dist/guides.js +4 -3
- package/dist/lead-doors.js +50 -3
- package/dist/lead-queue-runtime.js +11 -2
- package/dist/lead-queue.js +25 -0
- package/dist/live-backup-change.js +93 -0
- package/dist/live-backup.js +75 -31
- package/dist/live-bus.js +3 -2
- package/dist/live-records.js +0 -1
- package/dist/local-landing.js +47 -0
- package/dist/local-owner.js +0 -1
- package/dist/model-choices.js +0 -11
- package/dist/nightly-check.js +0 -3
- package/dist/nightly-github.js +1 -2
- package/dist/notification-retention.js +119 -0
- package/dist/observations.js +0 -1
- package/dist/operate.js +17 -4
- package/dist/person-proof.js +5 -1
- package/dist/pull-request-flow.js +116 -2
- package/dist/qr.js +360 -0
- package/dist/release-adapters.js +14 -43
- package/dist/release-auto.js +17 -13
- package/dist/release-card.js +0 -4
- package/dist/release-cli.js +37 -2
- package/dist/release.js +13 -2
- package/dist/restore-retirement.js +6 -1
- package/dist/result-review.js +0 -3
- package/dist/retention-ui.js +1 -1
- package/dist/retention.js +14 -21
- package/dist/review-context.js +0 -5
- package/dist/route-rules.js +1 -5
- package/dist/sandbox-runtime.js +0 -1
- package/dist/scope.js +68 -17
- package/dist/scout.js +0 -6
- package/dist/serve.js +60 -9
- package/dist/server/kit.js +1 -0
- package/dist/server/live.js +9 -2
- package/dist/server/pages.js +12 -4
- package/dist/server/phone-engine-api.js +79 -0
- package/dist/server/render-pages.js +1 -11
- package/dist/server/render-results.js +0 -1
- package/dist/server/render-tasks.js +0 -68
- package/dist/server/route-table.js +12 -1
- package/dist/server/settings-phone.js +515 -0
- package/dist/server/settings-scripts.js +2 -0
- package/dist/server/settings-section-table.js +0 -3
- package/dist/server/settings-sections.js +10 -4
- package/dist/server/settings.js +20 -5
- package/dist/server/terminals.js +2 -1
- package/dist/settings-groups-ui.js +2 -1
- package/dist/settings-proofs.js +6 -0
- package/dist/store.js +52 -4
- package/dist/structured-output.js +0 -1
- package/dist/style-asset.js +20 -7
- package/dist/tailnet.js +39 -0
- package/dist/task-control.js +5 -0
- package/dist/task-sizing.js +0 -1
- package/dist/toolroll-update-cli.js +19 -3
- package/dist/toolroll-update-ui.js +2 -2
- package/dist/toolroll-update.js +98 -16
- package/dist/youiyoux-intake.js +8 -0
- package/package.json +7 -2
- package/dist/contracts/contract-test.js +0 -55
- package/dist/unfenced-test-support.js +0 -6
- /package/dist/browser/{terminal.js → terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js} +0 -0
package/dist/server/settings.js
CHANGED
|
@@ -65,7 +65,7 @@ import { passwordFreeOwner } from "../task-outcome-cli.js";
|
|
|
65
65
|
import { realpathSync } from "node:fs";
|
|
66
66
|
import { enableFlexible, FLEXIBLE_LEVEL_WORDS, FLEXIBLE_UNAVAILABLE, flexibleSettingsView, isFlexibleLevel, lowerFlexible, turnFlexibleOff } from "../flexible.js";
|
|
67
67
|
import { backupHtml } from "../backup-ui.js";
|
|
68
|
-
import { BACKUP_EVERY_HOURS, backupFolderOf, backupNow, checkBackupFolder, defaultBackupFolder, MAX_KEEP } from "../backup.js";
|
|
68
|
+
import { BACKUP_EVERY_HOURS, backupFolderOf, backupNow, checkBackupFolder, databaseTag, defaultBackupFolder, MAX_KEEP } from "../backup.js";
|
|
69
69
|
import { projectBatchChecks, setProjectBatchChecks } from '../batch-policy.js';
|
|
70
70
|
import { fastStartOn, setFastStart } from '../fast-start.js';
|
|
71
71
|
import { ALL_PROJECTS as CHAT_APPROVAL_ALL, chatApprovalWords, setChatApproval } from "../chat-approval.js";
|
|
@@ -161,14 +161,14 @@ import { bytesWords, parseCleanup, parseIdle } from "../storage.js";
|
|
|
161
161
|
import { setTaskSizing, taskSizingSetting } from "../task-sizing.js";
|
|
162
162
|
import { localActNow } from "../local-owner.js";
|
|
163
163
|
import { checkoutIdle, isDigestTime, leadQuickAnswersOn, liveBackupState, setCheckoutIdle, localModeOf, RESULT_SCREENSHOTS, setLeadQuickAnswers, setLiveBackupSettings, setLocalModeOff } from "../store.js";
|
|
164
|
-
import { defaultLiveFolder, liveFolderOf, liveFolderProblem } from "../live-backup.js";
|
|
164
|
+
import { defaultLiveFolder, liveCopies, liveFolderOf, liveFolderProblem } from "../live-backup.js";
|
|
165
165
|
import { LIVE_EVERY } from "../backup-ui.js";
|
|
166
166
|
import { checkTeamsCredentials, clearTeamsCredentials, loadTeamsCredentials, saveTeamsCredentials, TeamsError } from "../teams-api.js";
|
|
167
167
|
import { teamsSettingsHtml } from "../teams-settings.js";
|
|
168
168
|
import { telegramSettingsHtml } from "../telegram-settings.js";
|
|
169
169
|
import { hashPairingCode, loadBotToken, mintPairingCode, PAIRING_TTL_MS, redactToken, saveBotToken, TOKEN_ENV } from "../telegram.js";
|
|
170
170
|
import { newerThan, updatesHtml, updatesScript, updateStepsHtml } from "../toolroll-update-ui.js";
|
|
171
|
-
import { abandonRuntimeUpdate, currentRuntime, launchRuntimeUpdate, markWhatsNewSeen, prepareRuntimeUpdate, requestRuntimeUpdateCancel, runningWorkWords, runtimeUpdateStatus, runtimeUpdateTerminal } from "../toolroll-update.js";
|
|
171
|
+
import { abandonRuntimeUpdate, commandRuntime, consoleDriftWords, currentRuntime, launchRuntimeUpdate, markWhatsNewSeen, prepareRuntimeUpdate, requestRuntimeUpdateCancel, runningWorkWords, runtimeUpdateStatus, runtimeUpdateTerminal } from "../toolroll-update.js";
|
|
172
172
|
import { TOOLS_PROJECT_SCRIPT, toolsHtml, toolsProjectPicker } from "../tools-ui.js";
|
|
173
173
|
import { effectivePrimary, isMessagingChannel, savePrimary } from "../webhooks.js";
|
|
174
174
|
import { personChip, ROLE_TITLES } from "./chrome.js";
|
|
@@ -469,7 +469,9 @@ ${connectionHtml(asked, connection, task)}${command === null ? "" : html `<p>On
|
|
|
469
469
|
const current = options.updates?.current ?? PACKAGE_VERSION;
|
|
470
470
|
const checksOff = updateChecksOff(process.env, options.configDir ?? dirname(databaseFile)).off;
|
|
471
471
|
const known = lastChecks.known("release")?.value ?? null;
|
|
472
|
-
const
|
|
472
|
+
const method = options.updates?.method ?? installMethod();
|
|
473
|
+
const view = { current, latest: active ? { version: current } : known ?? (checksOff ? { off: true } : { pending: true }), method, journal: status.journal, running: status.running, whatsNew: status.whatsNew, rollbackTo: status.lastUpdate?.to === current ? status.lastUpdate.from : null, csrf: who.session.csrf,
|
|
474
|
+
drift: runtimeDriftHere(current, method) };
|
|
473
475
|
return sendScreen(response, 200, screen("Updates", settingsSubPage("system", "Updates", html `${(updatesHtml(view, { said: url.searchParams.get("said"), problem: url.searchParams.get("problem") }))}`), { chrome: chromeFor(project, "settings"), ...(active ? { functional: { script: updatesScript(), fetches: true } } : {}) }));
|
|
474
476
|
}
|
|
475
477
|
async function retentionPage(ctx) {
|
|
@@ -529,7 +531,8 @@ ${connectionHtml(asked, connection, task)}${command === null ? "" : html `<p>On
|
|
|
529
531
|
const settings = store.backupSettings();
|
|
530
532
|
const live = liveBackupState(store);
|
|
531
533
|
const view = { settings, folder: backupFolderOf(settings, databaseFile), defaultFolder: defaultBackupFolder(databaseFile), runs: store.backupRuns(20), csrf: who.session.csrf, now,
|
|
532
|
-
live: { state: live, folder: liveFolderOf(live.settings, databaseFile), defaultFolder: defaultLiveFolder(databaseFile)
|
|
534
|
+
live: { state: live, folder: liveFolderOf(live.settings, databaseFile), defaultFolder: defaultLiveFolder(databaseFile),
|
|
535
|
+
newest: liveCopies(liveFolderOf(live.settings, databaseFile), databaseTag(databaseFile))[0] ?? null } };
|
|
533
536
|
return sendScreen(response, 200, screen("Backups", settingsSubPage("system", "Backups", html `${(backupHtml(view, { said: url.searchParams.get("said"), problem: url.searchParams.get("problem") }))}`), { chrome: chromeFor(project, "settings") }));
|
|
534
537
|
}
|
|
535
538
|
async function dataPage(ctx) {
|
|
@@ -3251,6 +3254,7 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
3251
3254
|
}
|
|
3252
3255
|
const generalImpls = generalSections({
|
|
3253
3256
|
updatesVersion: name => settingsUpdates(name, "")?.current ?? null,
|
|
3257
|
+
runtimeDrift: runtimeDriftNow,
|
|
3254
3258
|
packageVersion: PACKAGE_VERSION,
|
|
3255
3259
|
firstResult: now => { const at = store.firstSuccessAt(now), since = store.installationStartedAt(); return at === null || since === null ? null : firstResultWords(since, at); },
|
|
3256
3260
|
passwordless: () => sessionStandsIn(store),
|
|
@@ -3634,6 +3638,17 @@ ${postForm("/settings/chat-approval/save", html `\
|
|
|
3634
3638
|
const title = chosen ? `Skills for ${projectName(chosen)}` : "Skills";
|
|
3635
3639
|
return sendScreen(response, status, screen('Skills', settingsSubPage("agents", title, html `${url.searchParams.get('saved') === '1' ? html `<p role="status">Saved.</p>` : ''}${selector}${globalContent}${content}`), { chrome: chromeFor(chosen || project, 'settings'), functional: { script: skillsScript() } }));
|
|
3636
3640
|
}
|
|
3641
|
+
function runtimeDriftNow() { return runtimeDriftHere(options.updates?.current ?? PACKAGE_VERSION, options.updates?.method ?? installMethod()); }
|
|
3642
|
+
function runtimeDriftHere(current, method) {
|
|
3643
|
+
if (["npx", "source", "desktop"].includes(method.kind))
|
|
3644
|
+
return null;
|
|
3645
|
+
try {
|
|
3646
|
+
return consoleDriftWords({ version: current, dist: options.updates?.dist ?? currentRuntime(current).dist }, (options.updates?.command ?? commandRuntime)());
|
|
3647
|
+
}
|
|
3648
|
+
catch {
|
|
3649
|
+
return null;
|
|
3650
|
+
}
|
|
3651
|
+
}
|
|
3637
3652
|
return { registrations, modelsView };
|
|
3638
3653
|
}
|
|
3639
3654
|
function savedLoginOf(store) {
|
package/dist/server/terminals.js
CHANGED
|
@@ -4,6 +4,7 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { KEY_PROTOCOL, TERMINAL_EPOCH } from "./mutation-key.js";
|
|
5
5
|
import { WebSocketServer } from "ws";
|
|
6
6
|
import { readForm, CONSOLE_FORMS } from "../contracts/console-api.js";
|
|
7
|
+
import { browserAssetPath } from "../browser-shell.js";
|
|
7
8
|
import { html, htmlString } from "../html.js";
|
|
8
9
|
import { openTerminalLedger } from "../terminal-catalog.js";
|
|
9
10
|
import { loadPtySpawn, MAX_FRAME_BYTES, TerminalHost, MAX_VIEWERS, parseTerminalFrame, TERMINAL_PROGRAMS, TerminalError } from "../live-terminal.js";
|
|
@@ -99,7 +100,7 @@ export function createTerminalHandlers(runtime, deps) {
|
|
|
99
100
|
const id = TERMINAL_ID.exec(url.pathname)?.[1] ?? "";
|
|
100
101
|
const nonce = randomBytes(16).toString("base64");
|
|
101
102
|
const host = request.headers.host ?? "";
|
|
102
|
-
const document = html `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content"><meta name="theme-color" content="#0C0E12"><meta name="apple-mobile-web-app-capable" content="yes"><title>Terminals — Toolroll</title><link rel="icon" href="/icon.svg"><link rel="manifest" href="/manifest.webmanifest"><link rel="stylesheet" href="
|
|
103
|
+
const document = html `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content"><meta name="theme-color" content="#0C0E12"><meta name="apple-mobile-web-app-capable" content="yes"><title>Terminals — Toolroll</title><link rel="icon" href="/icon.svg"><link rel="manifest" href="/manifest.webmanifest"><link rel="stylesheet" href="${browserAssetPath("terminal.css")}"></head><body><div id="so-term"></div><div id="so-term-boot" hidden data-csrf="${who.session.csrf}" data-session="${id}" data-passwordless="${sessionStandsIn(store) || who.authority === "local-owner" ? "1" : ""}"></div><script type="module" src="${browserAssetPath("terminal.js")}" nonce="${nonce}"></script></body></html>`;
|
|
103
104
|
response.writeHead(200, {
|
|
104
105
|
"Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", "X-Content-Type-Options": "nosniff", "Referrer-Policy": "no-referrer",
|
|
105
106
|
"Content-Security-Policy": `default-src 'none'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self'; manifest-src 'self'; script-src 'nonce-${nonce}'; connect-src 'self' ws://${host} wss://${host}; form-action 'self'; base-uri 'none'; frame-ancestors 'none'`,
|
|
@@ -277,7 +277,7 @@ function telegramTokenSection(facts) {
|
|
|
277
277
|
]) });
|
|
278
278
|
}
|
|
279
279
|
function phoneSection(phone) {
|
|
280
|
-
return settingsSection({ id: "phone", title: "
|
|
280
|
+
return settingsSection({ id: "phone", title: "Toolroll in your phone's browser", lead: html `Open Toolroll itself in your phone's browser, over your own private network. Or use the <a class="k-link" href="/settings/phone">Toolroll iPhone app</a>.`,
|
|
281
281
|
body: html `<p class="k-note" data-phone-tailnet>${phone.tailnet === null ? html `Install <a class="k-link" href="https://tailscale.com/download">Tailscale</a> on this computer and your phone, then reload this page for the address.`
|
|
282
282
|
: phone.tailnet.restart === null ? html `On your phone, open <code class="k-mono">${phone.tailnet.address}</code> and sign in.`
|
|
283
283
|
: html `Start Toolroll with <code class="k-mono">${phone.tailnet.restart}</code>, then on your phone open <code class="k-mono">${phone.tailnet.address}</code> and sign in.`}</p>` });
|
|
@@ -361,6 +361,7 @@ export function accessGroup(facts, flags) {
|
|
|
361
361
|
const links = [
|
|
362
362
|
settingsLink({ href: "/people", title: "People", status: people === null ? "Your own access" : [accessWords({ ...facts, passwordless: null }), people.invites === 0 ? "no open invites" : plural(people.invites, "open invite", "open invites")].join(" · ") }),
|
|
363
363
|
settingsLink({ href: "/settings/sessions", title: "Sessions and tokens", status: `${plural(facts.access.sessions, "session", "sessions")} signed in · ${plural(facts.access.tokens, "API token", "API tokens")}` }),
|
|
364
|
+
...(facts.approver ? [settingsLink({ href: "/settings/phone", title: "Phone", status: "The Toolroll iPhone app: pair, rename and remove phones" })] : []),
|
|
364
365
|
...(facts.operator && (advancedOn(facts) || facts.sso !== null) ? [
|
|
365
366
|
settingsLink({ href: "/settings/sign-in", title: "Sign-in with a provider", status: facts.sso === null ? "Not set up: everyone uses a password" : `People sign in with ${facts.sso}` })
|
|
366
367
|
] : []),
|
package/dist/settings-proofs.js
CHANGED
|
@@ -80,6 +80,12 @@ export const PROOF_INVENTORY = [
|
|
|
80
80
|
{ id: "people-invite", action: "Invite someone", routes: ["/people/invite"], form: "peopleInvite", field: "token", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver", secrets: [], terms: [], reveal: "once" },
|
|
81
81
|
{ id: "runner-register", action: "Register a computer that builds", routes: ["/fleet/runner/register"], form: "runnerRegister", field: "token", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver, from a browser", secrets: [], terms: ["nonce"], reveal: "once", note: "`token` is the person's own password; `nonce` is the register document's one-use form token (spent before the password is checked: after a refusal, register again from the document); the worker's new token is shown once on the answer and only its hash is kept" },
|
|
82
82
|
{ id: "people-projects", action: "Change a person's projects", routes: ["/people/projects"], form: "peopleProjects", field: "token", proof: "credential", ...CREDENTIAL, role: "operator", secrets: [], terms: ["name"] },
|
|
83
|
+
{ id: "phone-access", action: "Turn phone access on or off", routes: ["/settings/phone/access"], form: "phoneAccess", field: "password", proof: "typed-password", ...TYPED, role: "operator", secrets: [], terms: ["act"] },
|
|
84
|
+
{ id: "phone-remove", action: "Remove a paired phone", routes: ["/settings/phone/remove"], form: "phoneRemove", field: "password", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: ["device"] },
|
|
85
|
+
{ id: "phone-pair", action: "Pair an iPhone with Toolroll", routes: ["/settings/phone/pair"], form: "phonePair", field: "password", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: [] },
|
|
86
|
+
{ id: "phone-passkey-enable", action: "Enable passkey approvals on iPhone", routes: ["/settings/phone/passkey/enable"], form: "phonePasskeyEnable", field: "password", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: [] },
|
|
87
|
+
{ id: "phone-passkey-revoke", action: "Revoke a phone passkey", routes: ["/settings/phone/passkey/revoke"], form: "phonePasskeyRevoke", field: "password", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: ["credential"] },
|
|
88
|
+
{ id: "phone-passkey-window", action: "Change the passkey prompt for phone approvals", routes: ["/settings/phone/passkey/window"], form: "phonePasskeyWindow", field: "password", proof: "typed-password", ...TYPED, role: "operator", secrets: [], terms: ["window"] },
|
|
83
89
|
{ id: "telegram-pair", action: "Pair your phone with Telegram", routes: ["/settings/telegram/pair"], form: "telegramPair", field: "password", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: [] },
|
|
84
90
|
{ id: "chat-approval-save", action: "Turn on approving from chat", routes: ["/settings/chat-approval/save"], form: "chatApproval", field: "token", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: ["nonce", "digest", "scope", "full-access", "cap-usd"] },
|
|
85
91
|
{ id: "push-subscribe", action: "Get alerts on this device", routes: ["/push/subscribe"], form: "pushSubscribe", field: "token", proof: "typed-password", ...TYPED, role: "any", handlerRole: "an approver", secrets: [], terms: ["endpoint", "p256dh", "auth"] },
|
package/dist/store.js
CHANGED
|
@@ -41,6 +41,7 @@ import { V177_STEPS, V177_SCHEMA, V177_OBJECTS, WORKSPACE_ID_PATTERN, RECOVERY_G
|
|
|
41
41
|
import { V174_OBJECTS, V174_SCHEMA, V174_STEPS } from "./flexible-everyday-schema.js";
|
|
42
42
|
import { V185_OBJECTS, V185_SCHEMA, V185_STEPS } from "./flexible-conversation-schema.js";
|
|
43
43
|
import { V186_OBJECTS, V186_SCHEMA, V186_STEPS } from "./skill-library-schema.js";
|
|
44
|
+
import { adoptCompanionChatOrigin, adoptLegacyCompanion, companionChatShapeProblem, companionPasskeyShapeProblem, companionShapeProblem, V187_STEPS, V188_SCHEMA, V188_STEPS, V189_STEPS } from "./companion/schema.js";
|
|
44
45
|
import { endThreadAuthorityFor } from "./flexible-authority-end.js";
|
|
45
46
|
import { relayCancel } from "./flexible-relay-cancel.js";
|
|
46
47
|
import { endLapsedFlexible } from "./flexible.js";
|
|
@@ -847,7 +848,7 @@ export function checkSuitesOf(value) {
|
|
|
847
848
|
}
|
|
848
849
|
}
|
|
849
850
|
const REGISTERED_AT_FILING = "again, as it was filed";
|
|
850
|
-
export const SCHEMA_VERSION =
|
|
851
|
+
export const SCHEMA_VERSION = 189;
|
|
851
852
|
export const V179_STEPS = Object.freeze(["antigravity-provider"]);
|
|
852
853
|
export const V118_MERGED_TABLES = Object.freeze({ api_token: "person", coordinator_credential: "coordinator", lead_credential: "lead" });
|
|
853
854
|
const V118_REFERENCES = /REFERENCES (?:coordinator_credential\(cid\)|api_token\(id\))/g;
|
|
@@ -913,7 +914,7 @@ export const V115_DROPPED_TABLES = Object.freeze([
|
|
|
913
914
|
"fallback_config", "fallback_cycle", "fallback_transition",
|
|
914
915
|
]);
|
|
915
916
|
const V115_DROPPED_REFERENCES = /\s+REFERENCES (?:contestant|contest|tournament_terms|session_turn|attended_authorization|held_session|fallback_cycle|fallback_config|fallback_transition|routine|routine_fire)\(id\)(?: ON DELETE CASCADE)?/g;
|
|
916
|
-
export const UPDATE_SAFE_MIGRATIONS = Object.freeze([108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186]);
|
|
917
|
+
export const UPDATE_SAFE_MIGRATIONS = Object.freeze([108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189]);
|
|
917
918
|
export const V119_ADDED_COLUMNS = Object.freeze({
|
|
918
919
|
task_ref: { planning_generation: { definition: "INTEGER NOT NULL DEFAULT 0", saved: "0" } },
|
|
919
920
|
run: { planning_generation: { definition: "INTEGER NOT NULL DEFAULT 0", saved: "0" } },
|
|
@@ -1456,7 +1457,7 @@ export { V156_STEPS };
|
|
|
1456
1457
|
export { V157_STEPS };
|
|
1457
1458
|
export { V158_STEPS };
|
|
1458
1459
|
export { V159_STEPS };
|
|
1459
|
-
export { V160_STEPS, V161_STEPS, V162_STEPS, V163_STEPS, V164_STEPS, V165_STEPS, V166_STEPS, V167_STEPS, V168_STEPS, V169_STEPS, V170_STEPS, V171_STEPS, V172_STEPS, V173_STEPS, V174_STEPS, V175_STEPS, V176_STEPS, V177_STEPS, V178_STEPS, V180_STEPS, V181_STEPS, V182_STEPS, V183_STEPS, V184_STEPS, V185_STEPS, V186_STEPS };
|
|
1460
|
+
export { V160_STEPS, V161_STEPS, V162_STEPS, V163_STEPS, V164_STEPS, V165_STEPS, V166_STEPS, V167_STEPS, V168_STEPS, V169_STEPS, V170_STEPS, V171_STEPS, V172_STEPS, V173_STEPS, V174_STEPS, V175_STEPS, V176_STEPS, V177_STEPS, V178_STEPS, V180_STEPS, V181_STEPS, V182_STEPS, V183_STEPS, V184_STEPS, V185_STEPS, V186_STEPS, V187_STEPS, V188_STEPS, V189_STEPS };
|
|
1460
1461
|
export const RELEASE_ONCE_SCHEMA = `
|
|
1461
1462
|
CREATE TABLE IF NOT EXISTS release_authority (
|
|
1462
1463
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -4245,7 +4246,7 @@ function initializeStore(db, file, options = {}) {
|
|
|
4245
4246
|
throw new Error(`${file}: ${problem}; refusing to move chat history it cannot name`);
|
|
4246
4247
|
}
|
|
4247
4248
|
if (preflight === SCHEMA_VERSION && !findingSourcesStale(db)) {
|
|
4248
|
-
const missing = codeMapShapeProblem(db) ?? viewPreferenceShapeProblem(db) ?? flexibleTermsShapeProblem(db) ?? flexibleThreadShapeProblem(db) ?? typedByPersonShapeProblem(db) ?? flexibleTurnsShapeProblem(db) ?? flexibleLaunchShapeProblem(db) ?? flexibleRelayShapeProblem(db) ?? flexibleAnswersShapeProblem(db) ?? flexibleShipShapeProblem(db) ?? taskSizingShapeProblem(db) ?? agentSaidShapeProblem(db) ?? flexibleSettingShapeProblem(db) ?? flexibleSignInShapeProblem(db) ?? planProblemsShapeProblem(db) ?? flexibleEverydayShapeProblem(db) ?? flexibleInteractiveShapeProblem(db) ?? subagentBackupShapeProblem(db) ?? workspaceIdentityShapeProblem(db) ?? pendingAgentChangeShapeProblem(db) ?? directChatShapeProblem(db) ?? directChatPhase1bShapeProblem(db) ?? directChatHardeningShapeProblem(db) ?? flexibleConversationShapeProblem(db) ?? skillLibraryShapeProblem(db);
|
|
4249
|
+
const missing = codeMapShapeProblem(db) ?? viewPreferenceShapeProblem(db) ?? flexibleTermsShapeProblem(db) ?? flexibleThreadShapeProblem(db) ?? typedByPersonShapeProblem(db) ?? flexibleTurnsShapeProblem(db) ?? flexibleLaunchShapeProblem(db) ?? flexibleRelayShapeProblem(db) ?? flexibleAnswersShapeProblem(db) ?? flexibleShipShapeProblem(db) ?? taskSizingShapeProblem(db) ?? agentSaidShapeProblem(db) ?? flexibleSettingShapeProblem(db) ?? flexibleSignInShapeProblem(db) ?? planProblemsShapeProblem(db) ?? flexibleEverydayShapeProblem(db) ?? flexibleInteractiveShapeProblem(db) ?? subagentBackupShapeProblem(db) ?? workspaceIdentityShapeProblem(db) ?? pendingAgentChangeShapeProblem(db) ?? directChatShapeProblem(db) ?? directChatPhase1bShapeProblem(db) ?? directChatHardeningShapeProblem(db) ?? flexibleConversationShapeProblem(db) ?? skillLibraryShapeProblem(db) ?? companionShapeProblem(db) ?? companionPasskeyShapeProblem(db) ?? companionChatShapeProblem(db);
|
|
4249
4250
|
if (missing !== null)
|
|
4250
4251
|
throw new Error(`${file}: refusing to open — ${missing}, though the schema says v${SCHEMA_VERSION}`);
|
|
4251
4252
|
db.exec("PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON;");
|
|
@@ -4740,6 +4741,51 @@ CREATE INDEX IF NOT EXISTS run_checkpoint_by_task ON run_checkpoint (task_ref, i
|
|
|
4740
4741
|
if (skillLibraryDamaged !== null)
|
|
4741
4742
|
throw new Error(`${file}: refusing to open — ${skillLibraryDamaged}`);
|
|
4742
4743
|
step("skill-library");
|
|
4744
|
+
db.exec("BEGIN IMMEDIATE");
|
|
4745
|
+
try {
|
|
4746
|
+
adoptLegacyCompanion(db, new Date());
|
|
4747
|
+
const companionDamaged = companionShapeProblem(db);
|
|
4748
|
+
if (companionDamaged !== null)
|
|
4749
|
+
throw new Error(`${file}: refusing to open — ${companionDamaged}`);
|
|
4750
|
+
step("companion");
|
|
4751
|
+
db.exec("COMMIT");
|
|
4752
|
+
}
|
|
4753
|
+
catch (error) {
|
|
4754
|
+
db.exec("ROLLBACK");
|
|
4755
|
+
if (error instanceof Error && !error.message.startsWith(`${file}:`) && /unknown shape/.test(error.message))
|
|
4756
|
+
throw new Error(`${file}: refusing to open — ${error.message}`);
|
|
4757
|
+
throw error;
|
|
4758
|
+
}
|
|
4759
|
+
db.exec("BEGIN IMMEDIATE");
|
|
4760
|
+
try {
|
|
4761
|
+
db.exec(V188_SCHEMA);
|
|
4762
|
+
const passkeyDamaged = companionPasskeyShapeProblem(db);
|
|
4763
|
+
if (passkeyDamaged !== null)
|
|
4764
|
+
throw new Error(`${file}: refusing to open — ${passkeyDamaged}`);
|
|
4765
|
+
step("companion-passkey");
|
|
4766
|
+
db.exec("COMMIT");
|
|
4767
|
+
}
|
|
4768
|
+
catch (error) {
|
|
4769
|
+
db.exec("ROLLBACK");
|
|
4770
|
+
if (error instanceof Error && !error.message.startsWith(`${file}:`) && /unknown shape/.test(error.message))
|
|
4771
|
+
throw new Error(`${file}: refusing to open — ${error.message}`);
|
|
4772
|
+
throw error;
|
|
4773
|
+
}
|
|
4774
|
+
db.exec("BEGIN IMMEDIATE");
|
|
4775
|
+
try {
|
|
4776
|
+
adoptCompanionChatOrigin(db);
|
|
4777
|
+
const chatDamaged = companionChatShapeProblem(db);
|
|
4778
|
+
if (chatDamaged !== null)
|
|
4779
|
+
throw new Error(`${file}: refusing to open — ${chatDamaged}`);
|
|
4780
|
+
step("companion-chat-origin");
|
|
4781
|
+
db.exec("COMMIT");
|
|
4782
|
+
}
|
|
4783
|
+
catch (error) {
|
|
4784
|
+
db.exec("ROLLBACK");
|
|
4785
|
+
if (error instanceof Error && !error.message.startsWith(`${file}:`) && /unknown shape|missing/.test(error.message))
|
|
4786
|
+
throw new Error(`${file}: refusing to open — ${error.message}`);
|
|
4787
|
+
throw error;
|
|
4788
|
+
}
|
|
4743
4789
|
if (!fresh)
|
|
4744
4790
|
reclaimDatabase(db, "migration");
|
|
4745
4791
|
const expectedMarker = preflight < 0 ? preflight : -preflight;
|
|
@@ -7273,6 +7319,8 @@ export class Store {
|
|
|
7273
7319
|
chat.revokeBinding({ id: Number(row["id"]) }, now, by);
|
|
7274
7320
|
chat.prepare("UPDATE chat_pair SET consumed = ? WHERE provider = :provider AND approver = ? AND consumed IS NULL").run(stamp, approver);
|
|
7275
7321
|
}
|
|
7322
|
+
this.db.prepare("UPDATE companion_paired_device SET revoked_at = ?, revoked_reason = ? WHERE account_name = ? AND revoked_at IS NULL")
|
|
7323
|
+
.run(stamp, by === "credential-rotation" ? "password_changed" : "access_changed", approver);
|
|
7276
7324
|
const subscriptions = this.db
|
|
7277
7325
|
.prepare("SELECT id FROM push_subscription WHERE approver = ? AND retired_at IS NULL")
|
|
7278
7326
|
.all(approver)
|
|
@@ -4,7 +4,6 @@ export const STRUCTURED_REPAIR_ATTEMPTS = 2;
|
|
|
4
4
|
export const STRUCTURED_REPAIR_MAX_TURNS = 4;
|
|
5
5
|
export const STRUCTURED_REPAIR_TIMEOUT_MS = 5 * 60_000;
|
|
6
6
|
export const REVIEW_OUTPUT_LIMITS = { comments: 40, criteria: 12, note: TEXT_LIMITS.reviewNote, path: TEXT_LIMITS.reviewPath };
|
|
7
|
-
export const REVIEW_NOTE_CODE_POINTS = Math.floor(REVIEW_OUTPUT_LIMITS.note / 2);
|
|
8
7
|
export function normalizeStructuredJson(raw) {
|
|
9
8
|
let text = raw;
|
|
10
9
|
const changes = [];
|
package/dist/style-asset.js
CHANGED
|
@@ -8,13 +8,7 @@ export function styleAsset(css) {
|
|
|
8
8
|
return {
|
|
9
9
|
path,
|
|
10
10
|
serve(request, response) {
|
|
11
|
-
const
|
|
12
|
-
const [name, ...params] = value.trim().toLowerCase().split(";");
|
|
13
|
-
const quality = params.find(p => p.trim().startsWith("q="));
|
|
14
|
-
return { name, q: quality === undefined ? 1 : Number(quality.trim().slice(2)) };
|
|
15
|
-
});
|
|
16
|
-
const gzip = encodings.find(e => e.name === "gzip") ?? encodings.find(e => e.name === "*");
|
|
17
|
-
const compressed = gzip !== undefined && gzip.q > 0 && gzip.q <= 1;
|
|
11
|
+
const compressed = acceptedEncodings(request.headers["accept-encoding"], ["gzip"]).length > 0;
|
|
18
12
|
const bytes = compressed ? zipped : body;
|
|
19
13
|
const etag = `"${digest}${compressed ? "-gzip" : ""}"`;
|
|
20
14
|
const headers = {
|
|
@@ -37,3 +31,22 @@ export function styleAsset(css) {
|
|
|
37
31
|
},
|
|
38
32
|
};
|
|
39
33
|
}
|
|
34
|
+
function codingsOf(header) {
|
|
35
|
+
return (header ?? "").split(",").map(value => {
|
|
36
|
+
const [name, ...params] = value.trim().toLowerCase().split(";");
|
|
37
|
+
const quality = params.find(p => p.trim().startsWith("q="));
|
|
38
|
+
return { name: (name ?? "").trim(), q: quality === undefined ? 1 : Number(quality.trim().slice(2)) };
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export function acceptedEncodings(header, offered) {
|
|
42
|
+
const encodings = codingsOf(header);
|
|
43
|
+
return offered.filter(coding => {
|
|
44
|
+
const named = encodings.find(e => e.name === coding) ?? encodings.find(e => e.name === "*");
|
|
45
|
+
return named !== undefined && named.q > 0 && named.q <= 1;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export function identityAccepted(header) {
|
|
49
|
+
const encodings = codingsOf(header);
|
|
50
|
+
const named = encodings.find(e => e.name === "identity") ?? encodings.find(e => e.name === "*");
|
|
51
|
+
return named === undefined || (named.q > 0 && named.q <= 1);
|
|
52
|
+
}
|
package/dist/tailnet.js
CHANGED
|
@@ -36,3 +36,42 @@ export async function readTailnetNames(runner = run, platform = process.platform
|
|
|
36
36
|
}
|
|
37
37
|
return [];
|
|
38
38
|
}
|
|
39
|
+
export function tailnetIpv4Of(statusJson) {
|
|
40
|
+
let status;
|
|
41
|
+
try {
|
|
42
|
+
status = JSON.parse(statusJson);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
if (typeof status !== "object" || status === null)
|
|
48
|
+
return null;
|
|
49
|
+
const body = status;
|
|
50
|
+
if (body.BackendState !== "Running" || !Array.isArray(body.Self?.TailscaleIPs))
|
|
51
|
+
return null;
|
|
52
|
+
for (const ip of body.Self.TailscaleIPs) {
|
|
53
|
+
if (typeof ip !== "string")
|
|
54
|
+
continue;
|
|
55
|
+
const m = /^100\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(ip);
|
|
56
|
+
if (m !== null && Number(m[1]) >= 64 && Number(m[1]) <= 127 && Number(m[2]) <= 255 && Number(m[3]) <= 255)
|
|
57
|
+
return ip;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
export async function readTailnetStatus(runner = run, platform = process.platform) {
|
|
62
|
+
const candidates = ["tailscale", ...(platform === "darwin" && existsSync(MAC_APP_CLI) ? [MAC_APP_CLI] : [])];
|
|
63
|
+
let found = false;
|
|
64
|
+
for (const file of candidates) {
|
|
65
|
+
try {
|
|
66
|
+
const answer = await runner(file, ["status", "--json"], { timeoutMs: 3_000 });
|
|
67
|
+
if (answer.notFound === true)
|
|
68
|
+
continue;
|
|
69
|
+
found = true;
|
|
70
|
+
if (answer.code === 0)
|
|
71
|
+
return { found, ipv4: tailnetIpv4Of(answer.stdout) };
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return { found, ipv4: null };
|
|
77
|
+
}
|
package/dist/task-control.js
CHANGED
|
@@ -60,6 +60,8 @@ export function requestTaskStop(store, request, now) {
|
|
|
60
60
|
if (ref === null || store.getTask(request.taskId) === null) {
|
|
61
61
|
return { ok: false, reason: "no-task", detail: `no task \`${request.taskId}\`` };
|
|
62
62
|
}
|
|
63
|
+
if (request.via === "phone")
|
|
64
|
+
return { ok: false, reason: "not-live", detail: PHONE_STOP_LATER };
|
|
63
65
|
const asked = store.requestRunStop({ runId: request.runId, taskRef: ref.id, by: request.by, via: request.via }, now);
|
|
64
66
|
if (!asked.ok)
|
|
65
67
|
return asked;
|
|
@@ -78,6 +80,8 @@ export function resumeTaskStop(store, request, now) {
|
|
|
78
80
|
if (ref === null || store.getTask(request.taskId) === null) {
|
|
79
81
|
return { ok: false, reason: "no-task", detail: `no task \`${request.taskId}\`` };
|
|
80
82
|
}
|
|
83
|
+
if (request.via === "phone")
|
|
84
|
+
return { ok: false, reason: "review", detail: PHONE_STOP_LATER };
|
|
81
85
|
const run = store.getRun(request.runId);
|
|
82
86
|
if (run !== null && run.worktree !== null && request.occupied !== undefined) {
|
|
83
87
|
const held = request.occupied(run.worktree);
|
|
@@ -136,3 +140,4 @@ export function taskControlOf(store, taskRef, now) {
|
|
|
136
140
|
}
|
|
137
141
|
return { kind: "none" };
|
|
138
142
|
}
|
|
143
|
+
export const PHONE_STOP_LATER = "Stop or resume this task on your Mac. It can't be done from the iPhone app yet.";
|
package/dist/task-sizing.js
CHANGED
|
@@ -129,7 +129,6 @@ export function ownerSizer(fetcher = fetch, keyOf = () => readProviderKey("openr
|
|
|
129
129
|
export function availableSizer(keyOf = () => readProviderKey("openrouter")) {
|
|
130
130
|
return keyOf() === null ? "claude" : "jev";
|
|
131
131
|
}
|
|
132
|
-
export const SIZER_WORDS = { claude: "Claude Haiku, on your plan", jev: "Jev via OpenRouter, your credit" };
|
|
133
132
|
export async function classifyTask(input, sizer, budgetMs = SIZING_BUDGET_MS) {
|
|
134
133
|
if (sizer === null)
|
|
135
134
|
return heuristicSizing(input);
|
|
@@ -6,7 +6,7 @@ import { isNewer, latestVersionNow } from "./releases.js";
|
|
|
6
6
|
import { databasePath } from "./store.js";
|
|
7
7
|
import { neverAnswered, unreachableWhy } from "./unreachable.js";
|
|
8
8
|
import { PACKAGE_VERSION } from "./version.js";
|
|
9
|
-
import { currentRuntime, lastCompletedUpdate, machineSystem, readRuntimeUpdate, requestRuntimeUpdateCancel, resumeRuntimeUpdate, retireUpdateJob, startRuntimeRollback, startRuntimeUpdate, } from "./toolroll-update.js";
|
|
9
|
+
import { currentRuntime, driftFact, lastCompletedUpdate, machineSystem, serviceDrift, readRuntimeUpdate, requestRuntimeUpdateCancel, resumeRuntimeUpdate, retireUpdateJob, startRuntimeRollback, startRuntimeUpdate, } from "./toolroll-update.js";
|
|
10
10
|
function sqlite() {
|
|
11
11
|
return createRequire(import.meta.url)("node:sqlite");
|
|
12
12
|
}
|
|
@@ -54,7 +54,7 @@ export async function runUpdateCommand(args, write, deps = {}) {
|
|
|
54
54
|
const stateDir = dirname(databaseFile);
|
|
55
55
|
const actor = value("by") ?? userInfo().username;
|
|
56
56
|
const current = deps.current ?? currentRuntime(PACKAGE_VERSION);
|
|
57
|
-
const system = () => deps.system ?? machineSystem();
|
|
57
|
+
const system = () => deps.system ?? machineSystem(deps.home);
|
|
58
58
|
if (has("status")) {
|
|
59
59
|
const j = readRuntimeUpdate(stateDir);
|
|
60
60
|
write(j ? `${j.kind === "update" ? "Update" : "Rollback"} ${j.from.version} → ${j.to.version}: ${j.phase}. ${j.detail}` : "No update has run here.");
|
|
@@ -126,10 +126,24 @@ export async function runUpdateCommand(args, write, deps = {}) {
|
|
|
126
126
|
return 1;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
const drift = serviceDrift(system().serviceUnit(current, databaseFile), current);
|
|
130
|
+
const driftLine = drift === null ? null : driftFact(drift.service, current);
|
|
131
|
+
if (version === current.version && drift === null) {
|
|
130
132
|
write(`Toolroll ${version} is current.`);
|
|
131
133
|
return 0;
|
|
132
134
|
}
|
|
135
|
+
if (version === current.version) {
|
|
136
|
+
if (!has("yes")) {
|
|
137
|
+
write(driftLine);
|
|
138
|
+
write(`Add --yes to bring them together: Toolroll ${version} is downloaded again and verified as an update is, ${when === "now" ? "refusing if any work is running" : "running work finishes first"}, the database is backed up and rehearsed, and the service and the toolroll command are pointed at it.`);
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
if (when === "at")
|
|
142
|
+
write(`Waiting until ${at}. Keep this running.`);
|
|
143
|
+
const outcome = await startRuntimeUpdate({ stateDir, databaseFile, current, actor, version, when, at: at ?? null, realign: true }, system());
|
|
144
|
+
write(outcome.message);
|
|
145
|
+
return outcome.ok ? 0 : 1;
|
|
146
|
+
}
|
|
133
147
|
const downgrade = !isNewer(version, current.version);
|
|
134
148
|
if (downgrade && !has("allow-downgrade")) {
|
|
135
149
|
write(`Toolroll ${version} is older than ${current.version}. Add --allow-downgrade to go back to it.`);
|
|
@@ -142,6 +156,8 @@ export async function runUpdateCommand(args, write, deps = {}) {
|
|
|
142
156
|
}
|
|
143
157
|
if (!has("yes")) {
|
|
144
158
|
write(`Update Toolroll ${current.version} → ${version}.`);
|
|
159
|
+
if (driftLine !== null)
|
|
160
|
+
write(`${driftLine} This update moves both to ${version}.`);
|
|
145
161
|
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.`);
|
|
146
162
|
write("Add --yes to update.");
|
|
147
163
|
return 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { html, joinHtml, postForm } from "./html.js";
|
|
2
2
|
import { STEP_WORDS, UPDATE_STEPS, runtimeUpdateTerminal } from "./toolroll-update.js";
|
|
3
|
-
import { btn, chip, codeLine, disclose, formRow, infoLine, note, notice, radios, settingsRecord, settingsSection } from "./server/kit.js";
|
|
3
|
+
import { btn, chip, codeLine, codeWords, disclose, formRow, infoLine, note, notice, radios, settingsRecord, settingsSection } from "./server/kit.js";
|
|
4
4
|
import { kitSectionForm } from "./settings-kit.js";
|
|
5
5
|
const clock = (iso) => { const d = new Date(iso); return `${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`; };
|
|
6
6
|
export const UPDATES_CSS = "";
|
|
@@ -70,7 +70,7 @@ export function updatesHtml(view, said) {
|
|
|
70
70
|
: "";
|
|
71
71
|
const rollback = view.rollbackTo !== null ? joinHtml([note(`To go back to ${view.rollbackTo}:`), codeLine("toolroll update --rollback")]) : "";
|
|
72
72
|
const version = settingsSection({ id: "update", title: state[0], ...(state[2] === "" ? {} : { right: state[2] }),
|
|
73
|
-
body: html `<div data-update-state="${newer ? "available" : "current"}">${joinHtml([answer, state[1] === "" ? "" : note(state[1]), form, rollback])}</div>` });
|
|
73
|
+
body: html `<div data-update-state="${newer ? "available" : "current"}">${joinHtml([answer, view.drift ? html `<div data-runtime-drift>${infoLine(codeWords(view.drift))}</div>` : "", state[1] === "" ? "" : note(state[1]), form, rollback])}</div>` });
|
|
74
74
|
return joinHtml([whatsNew, j ? outcomeHtml(j) : "", version]);
|
|
75
75
|
}
|
|
76
76
|
export function newerThan(a, b) {
|
package/dist/toolroll-update.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { inReadOnlyRequest } from "./read-only-request.js";
|
|
2
|
+
import { installMethod } from "./install-method.js";
|
|
2
3
|
import { createHash, randomUUID, verify as signatureValid, X509Certificate } from "node:crypto";
|
|
3
4
|
import { spawnSync } from "node:child_process";
|
|
4
5
|
import { accessSync, chmodSync, closeSync, constants, copyFileSync, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, readlinkSync, realpathSync, renameSync, rmSync, statfsSync, statSync, symlinkSync, writeFileSync } from "node:fs";
|
|
@@ -329,6 +330,8 @@ const HISTORY_RULES = {
|
|
|
329
330
|
...Object.fromEntries(Object.entries(V117_RENAMED_TABLES).map(([old, now]) => [old, { moved: { into: now, where: "1" } }])),
|
|
330
331
|
...Object.fromEntries(V117_RENAMED_COLUMNS.filter(([table]) => !Object.values(V117_RENAMED_TABLES).includes(table)).map(([table, from, to]) => [table, { renamed: { [from]: to } }])),
|
|
331
332
|
...Object.fromEntries(Object.entries(V118_MERGED_TABLES).map(([table, kind]) => [table, { moved: { into: "credential", where: `kind = '${kind}'` } }])),
|
|
333
|
+
companion_push_token: { retired: true }, companion_idempotency: { retired: true },
|
|
334
|
+
companion_host_keys: { discarded: ["relay_url"] }, companion_paired_device: { discarded: ["next_device_psk", "psk_version"] },
|
|
332
335
|
...Object.fromEntries(Object.entries(addedColumns(V119_ADDED_COLUMNS, V120_ADDED_COLUMNS, V121_ADDED_COLUMNS, V122_ADDED_COLUMNS, V123_ADDED_COLUMNS, V125_ADDED_COLUMNS, V126_ADDED_COLUMNS, V128_ADDED_COLUMNS, V129_ADDED_COLUMNS, V134_ADDED_COLUMNS, V135_ADDED_COLUMNS, V138_ADDED_COLUMNS, V143_ADDED_COLUMNS, V147_ADDED_COLUMNS, V148_ADDED_COLUMNS, V150_ADDED_COLUMNS, V151_ADDED_COLUMNS, V152_ADDED_COLUMNS, V153_ADDED_COLUMNS, V158_ADDED_COLUMNS, V159_ADDED_COLUMNS, V169_ADDED_COLUMNS, V170_ADDED_COLUMNS, V172_ADDED_COLUMNS, V173_ADDED_COLUMNS))
|
|
333
336
|
.map(([table, rule]) => [table, { ...EARLIER_RULES[table], ...rule }])),
|
|
334
337
|
};
|
|
@@ -468,7 +471,7 @@ export function changedHistory(db, before) {
|
|
|
468
471
|
return move === undefined || t.moved === undefined || arrived(db, move) - t.moved.found !== t.moved.rows;
|
|
469
472
|
}
|
|
470
473
|
const rule = HISTORY_RULES[t.name], present = new Set(tableColumns(db, t.name));
|
|
471
|
-
const kept = (c) => present.has(c) || (rule?.renamed?.[c] !== undefined && present.has(rule.renamed[c]));
|
|
474
|
+
const kept = (c) => present.has(c) || (rule?.renamed?.[c] !== undefined && present.has(rule.renamed[c])) || rule?.discarded?.includes(c) === true;
|
|
472
475
|
if (t.columns.some(c => !kept(c) && (!rule?.dropped?.includes(c) || (t.nonNull?.[c] !== 0 && !accounted(rule, t)))))
|
|
473
476
|
return true;
|
|
474
477
|
const columns = t.columns.filter(c => present.has(c));
|
|
@@ -686,13 +689,30 @@ async function stopServices(j, system, main, watches) {
|
|
|
686
689
|
await system.sleep(250);
|
|
687
690
|
}
|
|
688
691
|
}
|
|
692
|
+
export function unitRuntimes(text) {
|
|
693
|
+
const command = /<key>ProgramArguments<\/key>\s*<array>([\s\S]*?)<\/array>/.exec(text)?.[1] ?? text;
|
|
694
|
+
return [...new Set([...command.matchAll(/<string>(\/[^<]*\/dist)\/[^/<]+\.js<\/string>/g)].map(match => match[1]))];
|
|
695
|
+
}
|
|
696
|
+
export function pointUnitAt(text, from, to) {
|
|
697
|
+
const runtimes = [...new Set([from, ...unitRuntimes(text)])].filter(Boolean).sort((a, b) => b.length - a.length);
|
|
698
|
+
return text.replace(new RegExp(runtimes.map(one => one.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), "g"), () => to);
|
|
699
|
+
}
|
|
700
|
+
export function runtimeVersionAt(dist) {
|
|
701
|
+
try {
|
|
702
|
+
const pkg = JSON.parse(readFileSync(join(dist, "..", "package.json"), "utf8"));
|
|
703
|
+
return (pkg.name === NAME || pkg.name === "standing-orders") && typeof pkg.version === "string" && /^\d+\.\d+\.\d+$/.test(pkg.version) ? pkg.version : null;
|
|
704
|
+
}
|
|
705
|
+
catch {
|
|
706
|
+
return null;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
689
709
|
function pointLink(path, target) {
|
|
690
710
|
const temp = join(dirname(path), `.${basename(path)}.${randomUUID().slice(0, 8)}`);
|
|
691
711
|
symlinkSync(target, temp);
|
|
692
712
|
durableRename(temp, path);
|
|
693
713
|
}
|
|
694
714
|
function switchable(j, system) {
|
|
695
|
-
const unit = system.serviceUnit(j.from), watches = system.watchUnits(j.from), links = system.commands(j.from);
|
|
715
|
+
const unit = system.serviceUnit(j.from, j.databaseFile), watches = system.watchUnits(j.from), links = system.commands(j.from);
|
|
696
716
|
if (!unit && watches.length === 0 && links.length === 0)
|
|
697
717
|
throw new Refusal(`No background service or toolroll command runs ${j.from.version} from ${j.from.dist}, so there is nothing to switch. Nothing was changed.`);
|
|
698
718
|
const real = (path) => { try {
|
|
@@ -715,8 +735,13 @@ function switchable(j, system) {
|
|
|
715
735
|
throw new Refusal(`${dirname(link)} cannot be written, so ${link} would keep running ${j.from.version}. Make that folder writable, then update again. Nothing was changed.`);
|
|
716
736
|
}
|
|
717
737
|
}
|
|
718
|
-
|
|
719
|
-
|
|
738
|
+
if (unit) {
|
|
739
|
+
const text = readFileSync(unit, "utf8");
|
|
740
|
+
if (!text.includes(j.from.dist) && unitRuntimes(text).length === 0)
|
|
741
|
+
throw new Refusal("The service definition does not name a Toolroll runtime. Nothing was changed.");
|
|
742
|
+
}
|
|
743
|
+
for (const one of watches)
|
|
744
|
+
if (!readFileSync(one, "utf8").includes(j.from.dist))
|
|
720
745
|
throw new Refusal("The service definition does not name the current runtime. Nothing was changed.");
|
|
721
746
|
return { unit, watches, links };
|
|
722
747
|
}
|
|
@@ -748,7 +773,7 @@ async function switchRuntime(j, system) {
|
|
|
748
773
|
}
|
|
749
774
|
for (const one of [j.switched.unit, ...j.switched.watches ?? []])
|
|
750
775
|
if (one)
|
|
751
|
-
writeFileDurably(one.path, readFileSync(one.saved, "utf8")
|
|
776
|
+
writeFileDurably(one.path, pointUnitAt(readFileSync(one.saved, "utf8"), j.from.dist, j.to.dist), 0o644);
|
|
752
777
|
for (const link of j.switched.links)
|
|
753
778
|
pointLink(link.path, join(j.to.dist, "bin.js"));
|
|
754
779
|
}
|
|
@@ -855,7 +880,7 @@ function assertNoneActive(stateDir) {
|
|
|
855
880
|
export function prepareRuntimeUpdate(o, now) {
|
|
856
881
|
if (!/^\d+\.\d+\.\d+$/.test(o.version))
|
|
857
882
|
return { refused: `${o.version} is not a release version (x.y.z).` };
|
|
858
|
-
if (!o.allowDowngrade && !isNewer(o.version, o.current.version))
|
|
883
|
+
if (!o.allowDowngrade && !isNewer(o.version, o.current.version) && !(o.realign === true && o.version === o.current.version))
|
|
859
884
|
return { refused: `Toolroll ${o.version} is not newer than ${o.current.version}. To go back to an older release, run toolroll update --version ${o.version} --allow-downgrade.` };
|
|
860
885
|
if (!existsSync(o.databaseFile))
|
|
861
886
|
return { refused: `Toolroll isn't set up on this computer yet (there's no database at ${o.databaseFile}), so there's nothing to update. Nothing was changed. To get the newest command, run npm install -g toolroll@latest.` };
|
|
@@ -874,7 +899,7 @@ export function prepareRuntimeUpdate(o, now) {
|
|
|
874
899
|
return j;
|
|
875
900
|
}
|
|
876
901
|
export async function startRuntimeUpdate(o, system) {
|
|
877
|
-
if (o.version === o.current.version)
|
|
902
|
+
if (o.version === o.current.version && o.realign !== true)
|
|
878
903
|
return { ok: true, phase: "complete", message: `Toolroll ${o.version} is current.`, journal: null };
|
|
879
904
|
const j = prepareRuntimeUpdate(o, system.now());
|
|
880
905
|
if ("refused" in j)
|
|
@@ -1373,6 +1398,71 @@ const LABELS = ["com.toolroll.browser", "com.standing-orders.browser", LAPTOP_LA
|
|
|
1373
1398
|
export function currentRuntime(version) {
|
|
1374
1399
|
return { version, dist: dirname(fileURLToPath(import.meta.url)) };
|
|
1375
1400
|
}
|
|
1401
|
+
const realOr = (path) => { try {
|
|
1402
|
+
return realpathSync(path);
|
|
1403
|
+
}
|
|
1404
|
+
catch {
|
|
1405
|
+
return resolve(path);
|
|
1406
|
+
} };
|
|
1407
|
+
export function ownServiceUnit(home, from, databaseFile) {
|
|
1408
|
+
const units = LABELS.map(label => join(home, "Library", "LaunchAgents", `${label}.plist`)).filter(unit => existsSync(unit));
|
|
1409
|
+
const read = (unit) => { try {
|
|
1410
|
+
return readFileSync(unit, "utf8");
|
|
1411
|
+
}
|
|
1412
|
+
catch {
|
|
1413
|
+
return "";
|
|
1414
|
+
} };
|
|
1415
|
+
const running = units.find(unit => read(unit).includes(from.dist));
|
|
1416
|
+
if (running !== undefined || databaseFile === undefined)
|
|
1417
|
+
return running ?? null;
|
|
1418
|
+
return units.find(unit => {
|
|
1419
|
+
const text = read(unit), db = unitFlag(text, "darwin", "--db");
|
|
1420
|
+
const runtimes = unitRuntimes(text);
|
|
1421
|
+
return db !== null && isAbsolute(db) && realOr(db) === realOr(databaseFile) && runtimes.length > 0
|
|
1422
|
+
&& runtimes.every(dist => !["desktop", "source"].includes(installMethod(join(dist, "bin.js")).kind));
|
|
1423
|
+
}) ?? null;
|
|
1424
|
+
}
|
|
1425
|
+
export function serviceDrift(unit, cli) {
|
|
1426
|
+
if (unit === null)
|
|
1427
|
+
return null;
|
|
1428
|
+
let text;
|
|
1429
|
+
try {
|
|
1430
|
+
text = readFileSync(unit, "utf8");
|
|
1431
|
+
}
|
|
1432
|
+
catch {
|
|
1433
|
+
return null;
|
|
1434
|
+
}
|
|
1435
|
+
const other = unitRuntimes(text).find(dist => realOr(dist) !== realOr(cli.dist));
|
|
1436
|
+
return other === undefined ? null : { unit, service: { dist: other, version: runtimeVersionAt(other) }, cli };
|
|
1437
|
+
}
|
|
1438
|
+
export function serviceDriftHere(databaseFile, cli, seams = {}) {
|
|
1439
|
+
if ((seams.platform ?? process.platform) !== "darwin")
|
|
1440
|
+
return null;
|
|
1441
|
+
return serviceDrift(ownServiceUnit(seams.home ?? homedir(), cli, databaseFile), cli);
|
|
1442
|
+
}
|
|
1443
|
+
export function driftFact(service, cli) {
|
|
1444
|
+
return service.version !== null && service.version !== cli.version
|
|
1445
|
+
? `Your Toolroll service runs ${service.version}, but \`toolroll\` is ${cli.version}.`
|
|
1446
|
+
: `Your Toolroll service runs a different copy of Toolroll (${service.dist}) than \`toolroll\` (${cli.version}).`;
|
|
1447
|
+
}
|
|
1448
|
+
export function commandRuntime(path = process.env["PATH"] ?? "") {
|
|
1449
|
+
for (const dir of path.split(":").filter(one => isAbsolute(one))) {
|
|
1450
|
+
const candidate = join(dir, NAME);
|
|
1451
|
+
if (!existsSync(candidate))
|
|
1452
|
+
continue;
|
|
1453
|
+
const real = realOr(candidate);
|
|
1454
|
+
return basename(real) === "bin.js" && basename(dirname(real)) === "dist" ? { dist: dirname(real), version: runtimeVersionAt(dirname(real)) } : null;
|
|
1455
|
+
}
|
|
1456
|
+
return null;
|
|
1457
|
+
}
|
|
1458
|
+
export function consoleDriftWords(service, command) {
|
|
1459
|
+
if (command === null || command.version === null || realOr(command.dist) === realOr(service.dist))
|
|
1460
|
+
return null;
|
|
1461
|
+
return driftWords({ version: service.version, dist: service.dist }, { version: command.version });
|
|
1462
|
+
}
|
|
1463
|
+
export function driftWords(service, cli) {
|
|
1464
|
+
return `${driftFact(service, cli)} Run \`toolroll update --yes\` to bring them together.`;
|
|
1465
|
+
}
|
|
1376
1466
|
async function json(url) {
|
|
1377
1467
|
const response = await fetch(url, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(30_000) });
|
|
1378
1468
|
if (!response.ok)
|
|
@@ -1396,14 +1486,6 @@ export function machineSystem(home = homedir(), env = process.env, seams = {}) {
|
|
|
1396
1486
|
const supervise = seams.run ?? (async (file, args, options) => (await import("./exec.js")).run(file, args, options));
|
|
1397
1487
|
if ((seams.platform ?? process.platform) === "linux")
|
|
1398
1488
|
return { ...machineSystem(home, env, { ...seams, platform: "darwin" }), ...systemdLaptopService(home, sh, supervise, seams) };
|
|
1399
|
-
const unitFor = (from) => {
|
|
1400
|
-
for (const label of LABELS) {
|
|
1401
|
-
const unit = join(home, "Library", "LaunchAgents", `${label}.plist`);
|
|
1402
|
-
if (existsSync(unit) && readFileSync(unit, "utf8").includes(from.dist))
|
|
1403
|
-
return unit;
|
|
1404
|
-
}
|
|
1405
|
-
return null;
|
|
1406
|
-
};
|
|
1407
1489
|
const labelOf = (unit) => basename(unit, ".plist");
|
|
1408
1490
|
const domain = `gui/${typeof process.getuid === "function" ? process.getuid() : userInfo().uid}`;
|
|
1409
1491
|
const definition = (unit) => {
|
|
@@ -1482,7 +1564,7 @@ export function machineSystem(home = homedir(), env = process.env, seams = {}) {
|
|
|
1482
1564
|
if (checked.status !== 0)
|
|
1483
1565
|
throw new Refusal(`Sigstore did not verify Toolroll's provenance for ${identity.identity}: ${(checked.stderr || checked.stdout).trim().slice(-400)} Nothing was changed.`);
|
|
1484
1566
|
},
|
|
1485
|
-
serviceUnit: from =>
|
|
1567
|
+
serviceUnit: (from, databaseFile) => ownServiceUnit(home, from, databaseFile),
|
|
1486
1568
|
watchUnits: from => {
|
|
1487
1569
|
const dir = join(home, "Library", "LaunchAgents");
|
|
1488
1570
|
let names = [];
|