toolroll 0.9.129 → 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.
Files changed (113) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/agent-fence.js +0 -2
  3. package/dist/agents-board.js +0 -3
  4. package/dist/assignment.js +4 -3
  5. package/dist/backup-ui.js +6 -3
  6. package/dist/bounded-spawn.js +0 -1
  7. package/dist/browser/manifest.json +57 -0
  8. package/dist/browser/terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js.br +0 -0
  9. package/dist/browser/terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js.gz +0 -0
  10. package/dist/browser/terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css.br +0 -0
  11. package/dist/browser/terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css.gz +0 -0
  12. package/dist/browser/{workspace.js → workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js} +25 -25
  13. package/dist/browser/workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js.br +0 -0
  14. package/dist/browser/workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js.gz +0 -0
  15. package/dist/browser/{workspace.css → workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css} +1 -1
  16. package/dist/browser/workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css.br +0 -0
  17. package/dist/browser/workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css.gz +0 -0
  18. package/dist/browser-shell.js +271 -25
  19. package/dist/canvas-freshness.js +122 -0
  20. package/dist/canvas-fs.js +273 -0
  21. package/dist/canvas-reads.js +747 -0
  22. package/dist/canvas-state-key.js +45 -0
  23. package/dist/canvas-state-worker.js +12 -0
  24. package/dist/central-recovery-stage.js +3 -3
  25. package/dist/chat-actions.js +26 -0
  26. package/dist/chat-channel.js +4 -3
  27. package/dist/chat-task-actions.js +1 -1
  28. package/dist/chat-warmth.js +0 -1
  29. package/dist/check-report.js +0 -6
  30. package/dist/commit-extract.js +79 -40
  31. package/dist/companion/access.js +1 -0
  32. package/dist/companion/actions.js +79 -16
  33. package/dist/companion/canvas.js +141 -0
  34. package/dist/companion/chat-origin.js +92 -0
  35. package/dist/companion/chat.js +571 -0
  36. package/dist/companion/daemon.js +46 -5
  37. package/dist/companion/finish.js +51 -0
  38. package/dist/companion/reads.js +5 -1
  39. package/dist/companion/schema.js +64 -0
  40. package/dist/companion/service.js +1 -0
  41. package/dist/companion/store.js +1 -0
  42. package/dist/companion/webauthn.js +11 -2
  43. package/dist/console-instance.js +0 -4
  44. package/dist/contracts/console-api.js +1 -1
  45. package/dist/converse.js +0 -1
  46. package/dist/coordinator.js +1 -1
  47. package/dist/desktop-config.js +156 -0
  48. package/dist/desktop-host.js +6 -152
  49. package/dist/desktop-update.js +1 -1
  50. package/dist/finished-task-sql.js +14 -0
  51. package/dist/flexible-answers.js +0 -1
  52. package/dist/github-read.js +41 -0
  53. package/dist/guides.js +4 -3
  54. package/dist/lead-doors.js +50 -3
  55. package/dist/lead-queue-runtime.js +11 -2
  56. package/dist/lead-queue.js +25 -0
  57. package/dist/live-backup-change.js +93 -0
  58. package/dist/live-backup.js +75 -31
  59. package/dist/live-bus.js +3 -2
  60. package/dist/live-records.js +0 -1
  61. package/dist/local-owner.js +0 -1
  62. package/dist/model-choices.js +0 -11
  63. package/dist/nightly-check.js +0 -3
  64. package/dist/nightly-github.js +1 -2
  65. package/dist/notification-retention.js +119 -0
  66. package/dist/observations.js +0 -1
  67. package/dist/operate.js +17 -4
  68. package/dist/pull-request-flow.js +56 -15
  69. package/dist/qr.js +0 -25
  70. package/dist/release-adapters.js +12 -42
  71. package/dist/release-auto.js +17 -13
  72. package/dist/release-card.js +0 -4
  73. package/dist/release-cli.js +37 -2
  74. package/dist/release.js +13 -2
  75. package/dist/restore-retirement.js +4 -1
  76. package/dist/result-review.js +0 -3
  77. package/dist/retention-ui.js +1 -1
  78. package/dist/retention.js +14 -21
  79. package/dist/review-context.js +0 -5
  80. package/dist/route-rules.js +1 -5
  81. package/dist/sandbox-runtime.js +0 -1
  82. package/dist/scope.js +1 -13
  83. package/dist/scout.js +0 -6
  84. package/dist/serve.js +31 -7
  85. package/dist/server/kit.js +1 -0
  86. package/dist/server/live.js +9 -2
  87. package/dist/server/pages.js +3 -2
  88. package/dist/server/phone-engine-api.js +22 -2
  89. package/dist/server/render-pages.js +1 -11
  90. package/dist/server/render-results.js +0 -1
  91. package/dist/server/render-tasks.js +0 -68
  92. package/dist/server/route-table.js +1 -1
  93. package/dist/server/settings-phone.js +32 -9
  94. package/dist/server/settings-scripts.js +1 -1
  95. package/dist/server/settings-section-table.js +0 -3
  96. package/dist/server/settings-sections.js +4 -2
  97. package/dist/server/settings.js +20 -5
  98. package/dist/server/terminals.js +2 -1
  99. package/dist/store.js +20 -5
  100. package/dist/structured-output.js +0 -1
  101. package/dist/style-asset.js +20 -7
  102. package/dist/tailnet.js +0 -3
  103. package/dist/task-control.js +5 -0
  104. package/dist/task-sizing.js +0 -1
  105. package/dist/toolroll-update-cli.js +19 -3
  106. package/dist/toolroll-update-ui.js +2 -2
  107. package/dist/toolroll-update.js +95 -15
  108. package/package.json +1 -1
  109. package/dist/companion/webauthn-test-support.js +0 -44
  110. package/dist/contracts/contract-test.js +0 -55
  111. package/dist/unfenced-test-support.js +0 -6
  112. /package/dist/browser/{terminal.js → terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js} +0 -0
  113. /package/dist/browser/{terminal.css → terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css} +0 -0
@@ -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 view = { current, latest: active ? { version: current } : known ?? (checksOff ? { off: true } : { pending: true }), method: options.updates?.method ?? installMethod(), journal: status.journal, running: status.running, whatsNew: status.whatsNew, rollbackTo: status.lastUpdate?.to === current ? status.lastUpdate.from : null, csrf: who.session.csrf };
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) {
@@ -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="/assets/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="/assets/terminal.js" nonce="${nonce}"></script></body></html>`;
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'`,
package/dist/store.js CHANGED
@@ -41,7 +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 { adoptLegacyCompanion, companionPasskeyShapeProblem, companionShapeProblem, V187_STEPS, V188_SCHEMA, V188_STEPS } from "./companion/schema.js";
44
+ import { adoptCompanionChatOrigin, adoptLegacyCompanion, companionChatShapeProblem, companionPasskeyShapeProblem, companionShapeProblem, V187_STEPS, V188_SCHEMA, V188_STEPS, V189_STEPS } from "./companion/schema.js";
45
45
  import { endThreadAuthorityFor } from "./flexible-authority-end.js";
46
46
  import { relayCancel } from "./flexible-relay-cancel.js";
47
47
  import { endLapsedFlexible } from "./flexible.js";
@@ -848,7 +848,7 @@ export function checkSuitesOf(value) {
848
848
  }
849
849
  }
850
850
  const REGISTERED_AT_FILING = "again, as it was filed";
851
- export const SCHEMA_VERSION = 188;
851
+ export const SCHEMA_VERSION = 189;
852
852
  export const V179_STEPS = Object.freeze(["antigravity-provider"]);
853
853
  export const V118_MERGED_TABLES = Object.freeze({ api_token: "person", coordinator_credential: "coordinator", lead_credential: "lead" });
854
854
  const V118_REFERENCES = /REFERENCES (?:coordinator_credential\(cid\)|api_token\(id\))/g;
@@ -914,7 +914,7 @@ export const V115_DROPPED_TABLES = Object.freeze([
914
914
  "fallback_config", "fallback_cycle", "fallback_transition",
915
915
  ]);
916
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;
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]);
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]);
918
918
  export const V119_ADDED_COLUMNS = Object.freeze({
919
919
  task_ref: { planning_generation: { definition: "INTEGER NOT NULL DEFAULT 0", saved: "0" } },
920
920
  run: { planning_generation: { definition: "INTEGER NOT NULL DEFAULT 0", saved: "0" } },
@@ -1457,7 +1457,7 @@ export { V156_STEPS };
1457
1457
  export { V157_STEPS };
1458
1458
  export { V158_STEPS };
1459
1459
  export { V159_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 };
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 };
1461
1461
  export const RELEASE_ONCE_SCHEMA = `
1462
1462
  CREATE TABLE IF NOT EXISTS release_authority (
1463
1463
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -4246,7 +4246,7 @@ function initializeStore(db, file, options = {}) {
4246
4246
  throw new Error(`${file}: ${problem}; refusing to move chat history it cannot name`);
4247
4247
  }
4248
4248
  if (preflight === SCHEMA_VERSION && !findingSourcesStale(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);
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);
4250
4250
  if (missing !== null)
4251
4251
  throw new Error(`${file}: refusing to open — ${missing}, though the schema says v${SCHEMA_VERSION}`);
4252
4252
  db.exec("PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON;");
@@ -4771,6 +4771,21 @@ CREATE INDEX IF NOT EXISTS run_checkpoint_by_task ON run_checkpoint (task_ref, i
4771
4771
  throw new Error(`${file}: refusing to open — ${error.message}`);
4772
4772
  throw error;
4773
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
+ }
4774
4789
  if (!fresh)
4775
4790
  reclaimDatabase(db, "migration");
4776
4791
  const expectedMarker = preflight < 0 ? preflight : -preflight;
@@ -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 = [];
@@ -8,13 +8,7 @@ export function styleAsset(css) {
8
8
  return {
9
9
  path,
10
10
  serve(request, response) {
11
- const encodings = (request.headers["accept-encoding"] ?? "").split(",").map(value => {
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
@@ -58,9 +58,6 @@ export function tailnetIpv4Of(statusJson) {
58
58
  }
59
59
  return null;
60
60
  }
61
- export async function readTailnetIpv4(runner = run, platform = process.platform) {
62
- return (await readTailnetStatus(runner, platform)).ipv4;
63
- }
64
61
  export async function readTailnetStatus(runner = run, platform = process.platform) {
65
62
  const candidates = ["tailscale", ...(platform === "darwin" && existsSync(MAC_APP_CLI) ? [MAC_APP_CLI] : [])];
66
63
  let found = false;
@@ -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.";
@@ -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
- if (version === current.version) {
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) {
@@ -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";
@@ -688,13 +689,30 @@ async function stopServices(j, system, main, watches) {
688
689
  await system.sleep(250);
689
690
  }
690
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
+ }
691
709
  function pointLink(path, target) {
692
710
  const temp = join(dirname(path), `.${basename(path)}.${randomUUID().slice(0, 8)}`);
693
711
  symlinkSync(target, temp);
694
712
  durableRename(temp, path);
695
713
  }
696
714
  function switchable(j, system) {
697
- 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);
698
716
  if (!unit && watches.length === 0 && links.length === 0)
699
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.`);
700
718
  const real = (path) => { try {
@@ -717,8 +735,13 @@ function switchable(j, system) {
717
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.`);
718
736
  }
719
737
  }
720
- for (const one of [unit, ...watches])
721
- if (one && !readFileSync(one, "utf8").includes(j.from.dist))
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))
722
745
  throw new Refusal("The service definition does not name the current runtime. Nothing was changed.");
723
746
  return { unit, watches, links };
724
747
  }
@@ -750,7 +773,7 @@ async function switchRuntime(j, system) {
750
773
  }
751
774
  for (const one of [j.switched.unit, ...j.switched.watches ?? []])
752
775
  if (one)
753
- writeFileDurably(one.path, readFileSync(one.saved, "utf8").replaceAll(j.from.dist, j.to.dist), 0o644);
776
+ writeFileDurably(one.path, pointUnitAt(readFileSync(one.saved, "utf8"), j.from.dist, j.to.dist), 0o644);
754
777
  for (const link of j.switched.links)
755
778
  pointLink(link.path, join(j.to.dist, "bin.js"));
756
779
  }
@@ -857,7 +880,7 @@ function assertNoneActive(stateDir) {
857
880
  export function prepareRuntimeUpdate(o, now) {
858
881
  if (!/^\d+\.\d+\.\d+$/.test(o.version))
859
882
  return { refused: `${o.version} is not a release version (x.y.z).` };
860
- 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))
861
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.` };
862
885
  if (!existsSync(o.databaseFile))
863
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.` };
@@ -876,7 +899,7 @@ export function prepareRuntimeUpdate(o, now) {
876
899
  return j;
877
900
  }
878
901
  export async function startRuntimeUpdate(o, system) {
879
- if (o.version === o.current.version)
902
+ if (o.version === o.current.version && o.realign !== true)
880
903
  return { ok: true, phase: "complete", message: `Toolroll ${o.version} is current.`, journal: null };
881
904
  const j = prepareRuntimeUpdate(o, system.now());
882
905
  if ("refused" in j)
@@ -1375,6 +1398,71 @@ const LABELS = ["com.toolroll.browser", "com.standing-orders.browser", LAPTOP_LA
1375
1398
  export function currentRuntime(version) {
1376
1399
  return { version, dist: dirname(fileURLToPath(import.meta.url)) };
1377
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
+ }
1378
1466
  async function json(url) {
1379
1467
  const response = await fetch(url, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(30_000) });
1380
1468
  if (!response.ok)
@@ -1398,14 +1486,6 @@ export function machineSystem(home = homedir(), env = process.env, seams = {}) {
1398
1486
  const supervise = seams.run ?? (async (file, args, options) => (await import("./exec.js")).run(file, args, options));
1399
1487
  if ((seams.platform ?? process.platform) === "linux")
1400
1488
  return { ...machineSystem(home, env, { ...seams, platform: "darwin" }), ...systemdLaptopService(home, sh, supervise, seams) };
1401
- const unitFor = (from) => {
1402
- for (const label of LABELS) {
1403
- const unit = join(home, "Library", "LaunchAgents", `${label}.plist`);
1404
- if (existsSync(unit) && readFileSync(unit, "utf8").includes(from.dist))
1405
- return unit;
1406
- }
1407
- return null;
1408
- };
1409
1489
  const labelOf = (unit) => basename(unit, ".plist");
1410
1490
  const domain = `gui/${typeof process.getuid === "function" ? process.getuid() : userInfo().uid}`;
1411
1491
  const definition = (unit) => {
@@ -1484,7 +1564,7 @@ export function machineSystem(home = homedir(), env = process.env, seams = {}) {
1484
1564
  if (checked.status !== 0)
1485
1565
  throw new Refusal(`Sigstore did not verify Toolroll's provenance for ${identity.identity}: ${(checked.stderr || checked.stdout).trim().slice(-400)} Nothing was changed.`);
1486
1566
  },
1487
- serviceUnit: from => unitFor(from),
1567
+ serviceUnit: (from, databaseFile) => ownServiceUnit(home, from, databaseFile),
1488
1568
  watchUnits: from => {
1489
1569
  const dir = join(home, "Library", "LaunchAgents");
1490
1570
  let names = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolroll",
3
- "version": "0.9.129",
3
+ "version": "0.9.130",
4
4
  "description": "Your agents build. You decide. A control plane for coding agents — Claude Code, Codex, Gemini: approve the exact scope once, get results back Ready with the diff, the passing check and screenshots. Runs on your machine.",
5
5
  "directories": {
6
6
  "doc": "docs"
@@ -1,44 +0,0 @@
1
- export function encodeCbor(value) {
2
- const header = (major, n) => {
3
- if (n < 24)
4
- return Buffer.from([(major << 5) | n]);
5
- if (n < 0x100)
6
- return Buffer.from([(major << 5) | 24, n]);
7
- if (n < 0x10000) {
8
- const b = Buffer.alloc(3);
9
- b[0] = (major << 5) | 25;
10
- b.writeUInt16BE(n, 1);
11
- return b;
12
- }
13
- const b = Buffer.alloc(5);
14
- b[0] = (major << 5) | 26;
15
- b.writeUInt32BE(n, 1);
16
- return b;
17
- };
18
- if (typeof value === "number") {
19
- if (!Number.isInteger(value))
20
- throw new Error("non_integer");
21
- return value >= 0 ? header(0, value) : header(1, -1 - value);
22
- }
23
- if (Buffer.isBuffer(value))
24
- return Buffer.concat([header(2, value.length), value]);
25
- if (typeof value === "string") {
26
- const b = Buffer.from(value, "utf8");
27
- return Buffer.concat([header(3, b.length), b]);
28
- }
29
- if (Array.isArray(value))
30
- return Buffer.concat([header(4, value.length), ...value.map(encodeCbor)]);
31
- if (value instanceof Map) {
32
- const parts = [header(5, value.size)];
33
- for (const [k, v] of value.entries())
34
- parts.push(encodeCbor(k), encodeCbor(v));
35
- return Buffer.concat(parts);
36
- }
37
- if (value === false)
38
- return Buffer.from([0xf4]);
39
- if (value === true)
40
- return Buffer.from([0xf5]);
41
- if (value === null)
42
- return Buffer.from([0xf6]);
43
- throw new Error("unsupported_cbor");
44
- }
@@ -1,55 +0,0 @@
1
- import { z } from "zod";
2
- import { toModelSchema } from "./contract.js";
3
- export function jsonSchemaKeywords(schema, pointer = "") {
4
- if (Array.isArray(schema))
5
- return schema.flatMap((item, index) => jsonSchemaKeywords(item, `${pointer}/${index}`)).sort();
6
- if (schema === null || typeof schema !== "object")
7
- return [];
8
- const out = [];
9
- for (const [key, value] of Object.entries(schema)) {
10
- if (value !== null && typeof value === "object") {
11
- if (Array.isArray(value) && value.every(item => item === null || typeof item !== "object"))
12
- out.push(`${pointer} ${key}=${JSON.stringify(value)}`);
13
- else
14
- out.push(...jsonSchemaKeywords(value, `${pointer}/${key}`));
15
- }
16
- else {
17
- out.push(`${pointer} ${key}=${JSON.stringify(value)}`);
18
- }
19
- }
20
- return out.sort();
21
- }
22
- export function roundTripLoss(schema) {
23
- const before = toModelSchema(schema);
24
- const after = toModelSchema(z.fromJSONSchema(before));
25
- const kept = new Set(jsonSchemaKeywords(after));
26
- return jsonSchemaKeywords(before).filter(keyword => !kept.has(keyword)).map(keyword => `lost in the round trip: ${keyword}`);
27
- }
28
- export function replaySamples(spec) {
29
- const failures = [];
30
- for (const sample of spec.valid) {
31
- const verdict = spec.read(sample.input);
32
- if (!verdict.ok)
33
- failures.push(`${sample.name}: refused — ${verdict.lines.join("; ")}`);
34
- }
35
- for (const sample of spec.invalid) {
36
- const verdict = spec.read(sample.input);
37
- if (verdict.ok) {
38
- failures.push(`${sample.name}: accepted, expected a refusal naming ${sample.paths.join(", ")}`);
39
- continue;
40
- }
41
- for (const path of sample.paths) {
42
- if (!verdict.lines.some(line => line.startsWith(`${path}:`)))
43
- failures.push(`${sample.name}: no line names ${path} — ${verdict.lines.join("; ")}`);
44
- }
45
- }
46
- return failures;
47
- }
48
- export function contractFailures(spec) {
49
- return [...(spec.schema === undefined ? [] : roundTripLoss(spec.schema)), ...replaySamples(spec)];
50
- }
51
- export function assertContract(spec) {
52
- const failures = contractFailures(spec);
53
- if (failures.length > 0)
54
- throw new Error(`the contract does not hold:\n${failures.map(one => `- ${one}`).join("\n")}`);
55
- }
@@ -1,6 +0,0 @@
1
- import { linuxFenceAvailable, macosFenceAvailable } from "./agent-fence.js";
2
- export function allowWhereUnfenced(store) {
3
- if (!macosFenceAvailable() && !linuxFenceAvailable())
4
- store.setUnfencedAgentsAllowed(true, "test", new Date(0));
5
- return store;
6
- }