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
@@ -20,11 +20,6 @@ export const REVIEW_CONTEXT_LIMITS = {
20
20
  aggregateBytes: 32 * 1024 * 1024,
21
21
  items: 200,
22
22
  };
23
- export function reviewContextFileName(id) {
24
- if (!ITEM_ID.test(id))
25
- throw new Error("invalid context item id");
26
- return `REVIEW-CONTEXT-${id}.txt`;
27
- }
28
23
  const CONTEXT_INPUT_KINDS = new Set(["terminal-diff", "diff-stat", "proof", "check-log", "screenshot", "review-context"]);
29
24
  function usableReviewInput(root, artifact) {
30
25
  return artifact.captureStatus !== "failed" && (!artifact.truncated || artifact.kind === "check-log") && readVerifiedArtifact(root, artifact).ok;
@@ -5,7 +5,7 @@ import { REASON_WORDS } from "./contracts/route-results.js";
5
5
  import { checkScope, effectiveRoutes } from "./model-choices.js";
6
6
  import { seenModel, seenModels } from "./model-catalog.js";
7
7
  import { exactModelId, legOf, routeFromJson } from "./phase-routing.js";
8
- import { endRuleByDoor, endRuleByPlane, endTrialByDoor, insertEarnedRule, insertTrial, keepPausedRule, liveEarnedRules, liveTrialFor, modelsGenerationOf, proveRuleDoor, recordNotNow, ruleHoldOf, trialOrdinalOf, trialPlaceLive, trialPlacesOf, writeSuggestModels, } from "./route-store.js";
8
+ import { endRuleByDoor, endRuleByPlane, endTrialByDoor, insertEarnedRule, insertTrial, keepPausedRule, liveEarnedRules, modelsGenerationOf, proveRuleDoor, recordNotNow, ruleHoldOf, trialOrdinalOf, trialPlaceLive, trialPlacesOf, writeSuggestModels, } from "./route-store.js";
9
9
  import { BUILT_IN } from "./store.js";
10
10
  export const ROUTING_POLICY_VERSION = 1;
11
11
  const DAY = 24 * 60 * 60_000;
@@ -670,7 +670,3 @@ function trialEvidenceWords(store, selection) {
670
670
  const state = trial.state === "trialling" || trial.state === "finished" ? "" : ` The trial is ${trial.state === "paused" ? "paused" : "over"} now; approving keeps ${name}.`;
671
671
  return `Trying a cheaper model: ${name}, ${which}. A person approves each trial task; you can pick another model before approving.${state}`;
672
672
  }
673
- export function liveTrialOf(store, repo, size) {
674
- const live = liveTrialFor(store, repo, size);
675
- return live === null ? null : ruleById(store, live.id);
676
- }
@@ -172,7 +172,6 @@ export function missingLinuxSandboxTools(path = process.env["PATH"] ?? "") {
172
172
  export function linuxSandboxInstallLine(packages = LINUX_SANDBOX_TOOLS.map(tool => tool.package), system = packageSystem()) {
173
173
  return installLine(packages, system);
174
174
  }
175
- export const linuxSandboxToolsWords = () => toolWords(LINUX_SANDBOX_TOOLS.map(tool => tool.package));
176
175
  export function missingSandboxToolsWords(missing) {
177
176
  return [
178
177
  `Toolroll needs ${toolWords(missing)} to run agents in a sandbox on this computer.`,
package/dist/scope.js CHANGED
@@ -36,7 +36,7 @@ import { readAcceptance, readScopeTerms, storedRubricSchema } from "./contracts/
36
36
  import { taskArchived, taskCancelled } from "./task-archive.js";
37
37
  import { releaseCiHoldOf, releaseCiHoldWords } from "./release-ci-hold.js";
38
38
  import { releaseApprovalRefusal } from "./release-refusal.js";
39
- import { NO_READINESS, exactModelId, legOf, projectRoute, routeDigestOf, routeFromJson, routeJsonProblem, routeWords, } from "./phase-routing.js";
39
+ import { exactModelId, legOf, routeDigestOf, routeFromJson, routeJsonProblem, } from "./phase-routing.js";
40
40
  function mintToken() {
41
41
  return mintSecret(32);
42
42
  }
@@ -1007,18 +1007,6 @@ export function scopeAuthorityOf(scope, env = {}) {
1007
1007
  }
1008
1008
  return { ok: true, profile, route, digest, authMode, ...(chain === null ? {} : { chain }) };
1009
1009
  }
1010
- export function acceptanceWords(criteria) {
1011
- if (criteria.length === 0)
1012
- return [];
1013
- return [
1014
- ` done when ${criteria[0].id}: ${criteria[0].statement} [shown by: ${criteria[0].evidence.join(", ")}]`,
1015
- ...criteria.slice(1).map(c => ` ${c.id}: ${c.statement} [shown by: ${c.evidence.join(", ")}]`),
1016
- ];
1017
- }
1018
- export function scopeRouteWords(scope, readiness = NO_READINESS) {
1019
- const route = routeFromJson(scope.proposedRouteJson ?? null);
1020
- return route === null ? [] : routeWords(projectRoute(route, readiness));
1021
- }
1022
1010
  export function releaseTermsSentence(terms) {
1023
1011
  if (!terms.policy.carry)
1024
1012
  return `Release ${terms.packageVersion} from pull request #${terms.pr} at ${terms.approvedSha.slice(0, 7)}. Every later commit asks for your approval again.`;
package/dist/scout.js CHANGED
@@ -717,12 +717,6 @@ function scrubbedImageNames(images) {
717
717
  return [one.file, name];
718
718
  }));
719
719
  }
720
- function withoutEnv(env, names) {
721
- const kept = { ...env };
722
- for (const name of names)
723
- delete kept[name];
724
- return kept;
725
- }
726
720
  function cleanup(worktree, names) {
727
721
  for (const name of names) {
728
722
  try {
package/dist/serve.js CHANGED
@@ -27,7 +27,7 @@ const LOCAL_AGENTS_EVERY_MS = 2 * 60_000;
27
27
  const LOCAL_AGENTS = ["claude", "codex"];
28
28
  const SIGNED_IN_STATES = new Set(["connected", "key-works", "key-present"]);
29
29
  const SIGNED_IN_HOLD_MS = 10 * 60_000;
30
- import { browserCrewFromIndex, browserCrewOf, browserNavigationOf, browserProjectsOf, needsYouLabelOf } from './browser-workspace.js';
30
+ import { boundProjectSummary, browserCrewFromIndex, browserCrewOf, browserNavigationOf, browserProjectsOf, needsYouLabelOf } from './browser-workspace.js';
31
31
  import { PAGE_WORK_HEADER, PAGE_WORK_VERSION } from './page-work-contract.js';
32
32
  import { sharedActionPayload } from './chat-actions.js';
33
33
  import { prepareCodingContext } from './coding-context.js';
@@ -124,7 +124,9 @@ import { createPagesHandlers } from './server/pages.js';
124
124
  import { createPhoneSettingsHandlers } from './server/settings-phone.js';
125
125
  import { createPhoneAccess, workspaceLabelOf } from './companion/access.js';
126
126
  import { createCompanionReads } from './companion/reads.js';
127
+ import { withCompanionCanvas } from './companion/canvas.js';
127
128
  import { createCompanionActions } from './companion/actions.js';
129
+ import { createCompanionChat } from './companion/chat.js';
128
130
  import { createPeopleHandlers } from './server/people-tokens.js';
129
131
  import { createSettingsHandlers } from './server/settings.js';
130
132
  import { readPurpose, requestContext } from "./server/request-context.js";
@@ -582,6 +584,8 @@ function buildDecisionServer(options, leaveRehearsal) {
582
584
  }
583
585
  });
584
586
  });
587
+ server.keepAliveTimeout = 65_000;
588
+ server.headersTimeout = 66_000;
585
589
  if (options.rehearsal !== true) {
586
590
  server.once('listening', () => store.telemetry.start());
587
591
  server.once('close', () => store.telemetry.stop());
@@ -1557,13 +1561,30 @@ function buildDecisionServer(options, leaveRehearsal) {
1557
1561
  const projects = sidebarProjects();
1558
1562
  const actor = requestContext.getStore()?.actor ?? '';
1559
1563
  const access = workAccess();
1560
- return chromeRead(summaryKey(actor, access, projects), () => projectSummaryOf(store, clock(), access, actor, projects, evidenceRoot));
1564
+ const rows = chromeRead(summaryKey(actor, access, projects), () => projectSummaryOf(store, clock(), access, actor, projects, evidenceRoot));
1565
+ let counts;
1566
+ try {
1567
+ counts = projectCounts(clock());
1568
+ }
1569
+ catch {
1570
+ return rows;
1571
+ }
1572
+ const needsOf = (path) => counts.find(one => one.repo === path)?.totals['needs-you'] ?? 0;
1573
+ return boundProjectSummary(rows.map(one => one.others === true ? one : { ...one, needsYou: needsOf(one.path) }));
1561
1574
  }
1562
1575
  const projectScopeFor = (account) => store.accountOf(account) === null ? null : requestContext.run({ csrf: '', returnTo: '/', actor: account }, () => {
1563
1576
  const access = workAccess();
1564
1577
  return JSON.stringify({ projects: sidebarProjects().map(one => one.path).sort(), access: { ...access, repos: access.repos === null ? null : [...access.repos].sort() } });
1565
1578
  });
1566
- const projectSummaryFor = (account, scope) => projectScopeFor(account) !== scope ? null : requestContext.run({ csrf: '', returnTo: '/', actor: account }, () => withWorkReads(() => JSON.stringify(projectSummary())));
1579
+ const projectSummaryFor = (account, scope) => projectScopeFor(account) !== scope ? null : requestContext.run({ csrf: '', returnTo: '/', actor: account }, () => withWorkReads(() => {
1580
+ const states = JSON.stringify(projectSummary());
1581
+ try {
1582
+ return `${states}\n${needsYouCount(null).count}`;
1583
+ }
1584
+ catch {
1585
+ return states;
1586
+ }
1587
+ }));
1567
1588
  function chromeFor(project, active, listPane, scope) {
1568
1589
  if (restricted() && !visible(project))
1569
1590
  project = null;
@@ -1866,7 +1887,7 @@ function buildDecisionServer(options, leaveRehearsal) {
1866
1887
  detachReads();
1867
1888
  liveFollower.close();
1868
1889
  void Promise.all([closeCoding(), terminalClosing.close?.().then(problem => { terminalClosing.problem = problem; }), bounded(team.close()), bounded(personalQueue.close()), bounded(leadMaintenance?.stop()), bounded(backgroundChecks?.stop()), bounded(reads?.close()), bounded(engineHandlers.close()), bounded(phoneAccessRef?.stop())])
1869
- .then(() => closeServer(error => callback?.(error ?? terminalClosing.problem ?? undefined))).catch(error => {
1890
+ .then(() => { const closing = closeServer(error => callback?.(error ?? terminalClosing.problem ?? undefined)); server.closeAllConnections?.(); return closing; }).catch(error => {
1870
1891
  if (callback)
1871
1892
  callback(error instanceof Error ? error : Error('Coding session shutdown failed.'));
1872
1893
  else
@@ -2035,15 +2056,18 @@ function buildDecisionServer(options, leaveRehearsal) {
2035
2056
  };
2036
2057
  const tasksHandlers = createTasksHandlers(handlerRuntime);
2037
2058
  const pagesHandlers = createPagesHandlers(handlerRuntime, { listFor: tasksHandlers.workListFor, showOrder: tasksHandlers.showOrder });
2038
- const companionReads = createCompanionReads({ runtime: handlerRuntime, readWorkRows: pagesHandlers.readWorkRows, subscribeBus: listener => liveBus.subscribe(() => listener()),
2039
- workspaceLabel: workspaceLabelOf, toolrollVersion: PACKAGE_VERSION });
2059
+ const companionReads = withCompanionCanvas(createCompanionReads({ runtime: handlerRuntime, readWorkRows: pagesHandlers.readWorkRows, subscribeBus: listener => liveBus.subscribe(() => listener()),
2060
+ workspaceLabel: workspaceLabelOf, toolrollVersion: PACKAGE_VERSION }), { runtime: handlerRuntime });
2040
2061
  const companionActions = createCompanionActions({ runtime: handlerRuntime, workspaceLabel: workspaceLabelOf,
2041
2062
  onMutated: () => liveBus.publish({ revision: `phone:${Date.now()}` }) });
2042
2063
  phoneReadsByServer.set(server, companionReads);
2064
+ const companionChat = createCompanionChat({ runtime: handlerRuntime, queue: personalQueue, liveTurns,
2065
+ subscribeBus: listener => liveBus.subscribe(() => listener()), demoLead: demoLeadHere });
2043
2066
  const phoneAccess = createPhoneAccess({
2044
2067
  store,
2045
2068
  reads: companionReads,
2046
2069
  actions: companionActions,
2070
+ chat: companionChat,
2047
2071
  log: line => console.error(line),
2048
2072
  consoleUrl: () => publicOrigin !== null ? publicOrigin.origin : servedPort() === null ? null : `http://127.0.0.1:${servedPort()}`,
2049
2073
  bonjour: options.rehearsal !== true,
@@ -2097,7 +2121,7 @@ function buildDecisionServer(options, leaveRehearsal) {
2097
2121
  get terminalHost() { return () => terminals.host; },
2098
2122
  };
2099
2123
  const liveHandlers = createLiveHandlers(handlerRuntime, { bus: liveBus, workspaceRevision, chatProjectOf: chatHandlers.chatProjectOf, projectSummaryFor, projectScopeFor });
2100
- liveTurnStarted = liveHandlers.turnStarted;
2124
+ liveTurnStarted = thread => { liveHandlers.turnStarted(thread); companionChat.turnStarted(thread); };
2101
2125
  const terminalHandlers = createTerminalHandlers(handlerRuntime, { ...terminals, bus: liveBus, allowedHost, publicOrigin, forwardedSourceOf, server,
2102
2126
  ...(options.agentCommandEnv === undefined ? {} : { agentEnv: options.agentCommandEnv }) });
2103
2127
  terminalClosing.close = terminalHandlers.close;
@@ -76,6 +76,7 @@ export function facts(rows) {
76
76
  export const note = (text) => html `<p class="k-note">${text}</p>`;
77
77
  export const notice = (text) => html `<p class="k-notice" role="alert">${icon("alert", true)}<span>${text}</span></p>`;
78
78
  export const infoLine = (text) => html `<p class="k-notice info">${text}</p>`;
79
+ export const codeWords = (text) => joinHtml(text.split("`").map((part, i) => i % 2 === 1 ? html `<code class="k-mono">${part}</code>` : html `${part}`));
79
80
  export function empty(options) {
80
81
  return html `<div class="k-empty"><p class="k-empty-t">${options.title}</p>${options.text ? html `<p class="k-empty-x">${options.text}</p>` : ""}${options.action ?? ""}</div>`;
81
82
  }
@@ -52,7 +52,14 @@ export const LIVE_ROOMS_PER_PAGE = 6;
52
52
  const ROOM_NAME = /^(workspace|task|flow|chat|team|agent|summary|agents-live|direct-chat)(?::([^?]{1,400}))?(?:\?([^#]{0,600}))?$/;
53
53
  const WORKSPACE_SETTLE_MS = 1_000;
54
54
  const TURN_SETTLE_MS = 80;
55
- function chatSnapshot(turn) {
55
+ export function summaryFrame(fingerprint) {
56
+ const cut = fingerprint?.indexOf("\n") ?? -1;
57
+ if (fingerprint === null || cut < 0)
58
+ return { at: fingerprint };
59
+ const count = Number(fingerprint.slice(cut + 1));
60
+ return { at: fingerprint.slice(0, cut), ...(Number.isInteger(count) && count >= 0 ? { needsYou: count } : {}) };
61
+ }
62
+ export function chatSnapshot(turn) {
56
63
  const view = turn.reply?.view() ?? { phase: "working", status: LIVE_STATUS.thinking };
57
64
  const steps = (turn.reply?.tools() ?? []).map(calls => ({ tools: calls.map(call => call.label), toolCalls: calls }));
58
65
  return { steps, phase: view.phase, status: turn.done ? "" : turn.reply?.status() ?? LIVE_STATUS.thinking, text: view.phase === "writing" ? view.text : "", done: turn.done, ok: turn.ok };
@@ -116,7 +123,7 @@ export function createLiveHandlers(runtime, live) {
116
123
  const summaryRooms = createLiveRooms(key => {
117
124
  const [account, scope] = JSON.parse(key);
118
125
  return live.projectSummaryFor(account, scope);
119
- }, null, { bus: live.bus, minIntervalMs: WORKSPACE_SETTLE_MS, readSettleMs: WORKSPACE_SETTLE_MS });
126
+ }, null, { bus: live.bus, minIntervalMs: WORKSPACE_SETTLE_MS, readSettleMs: WORKSPACE_SETTLE_MS, frame: summaryFrame });
120
127
  const teamActors = new Map();
121
128
  const teamRooms = createLiveRooms(key => {
122
129
  const actor = teamActors.get(key);
@@ -20,7 +20,7 @@ import { pipeline } from "node:stream/promises";
20
20
  import { setImmediate as yieldEventLoop } from "node:timers/promises";
21
21
  import { parseApiToken, tokenLive } from "../api-tokens.js";
22
22
  import { classify } from "../board.js";
23
- import { serveBrowserAsset } from '../browser-shell.js';
23
+ import { retainBrowserAssets, serveBrowserAsset } from '../browser-shell.js';
24
24
  import { projectCheckLevel } from '../check-levels.js';
25
25
  import { checkResponse, CONSOLE_FORMS, readForm } from "../contracts/console-api.js";
26
26
  import { hasForbiddenControls } from "../decision.js";
@@ -972,9 +972,10 @@ export function createPagesHandlers(runtime, work) {
972
972
  const { response, method } = ctx;
973
973
  return healthz(store, response, method === 'HEAD', options.draining?.() === true);
974
974
  }
975
+ const retainedAssets = options.browserAssetCache === undefined ? null : retainBrowserAssets(options.browserAssetCache);
975
976
  async function browserAsset(ctx) {
976
977
  const { request, response, url } = ctx;
977
- serveBrowserAsset(request, response, url.pathname);
978
+ serveBrowserAsset(request, response, url.pathname, retainedAssets);
978
979
  }
979
980
  async function workspaceStyle(ctx) {
980
981
  const { request, response, url } = ctx;
@@ -1,7 +1,7 @@
1
1
  import { listPhones as listPhoneRows, renamePhone as renamePhoneRow, revokePairedDeviceRecord, getPairedDevice, listAllAccountPasskeys, revokeAccountPasskey } from "../companion/store.js";
2
2
  import { passkeyApprovalWindowMinutes, setPasskeyApprovalWindowMinutes, parsePasskeyWindowMinutes, PASSKEY_WINDOW_OPTIONS, } from "../companion/passkey-gate.js";
3
+ import { cancelPhoneWork, PHONE_ORIGIN_GONE } from "../companion/chat-origin.js";
3
4
  export { parsePasskeyWindowMinutes, PASSKEY_WINDOW_OPTIONS };
4
- export const RETIRED_WINDOW_MS = 30 * 24 * 60 * 60 * 1000;
5
5
  export function pathStates(service) {
6
6
  const status = service.status();
7
7
  return { direct: status.direct, hosted: status.hosted };
@@ -30,7 +30,10 @@ export function removePhone(service, store, deviceId, accountName, now) {
30
30
  const device = getPairedDevice(store.handle, deviceId);
31
31
  if (device === null || device.accountName !== accountName || device.revokedAt !== null)
32
32
  return false;
33
- return revokePairedDeviceRecord(store.handle, deviceId, now, "removed");
33
+ const revoked = revokePairedDeviceRecord(store.handle, deviceId, now, "removed");
34
+ if (revoked)
35
+ cancelPhoneWork(store, { deviceId }, PHONE_ORIGIN_GONE, now);
36
+ return revoked;
34
37
  }
35
38
  export function listPasskeys(store, accountName) {
36
39
  const identity = store.workspaceIdentity();
@@ -57,3 +60,20 @@ export function savePasskeyWindow(store, minutes) {
57
60
  export function endPasskeyWindows(service) {
58
61
  service?.engine.actions?.clearFreshLeases();
59
62
  }
63
+ export function openPasskeySetupForPairedPhone(service, store, accountName, accountGeneration, deviceId) {
64
+ const actions = service.engine.actions;
65
+ const account = store.accountOf(accountName);
66
+ if (actions === null || actions === undefined || account === null)
67
+ return null;
68
+ if (account.role !== "approver" || account.revokedAt !== null || account.passwordSet !== true || account.generation !== accountGeneration)
69
+ return null;
70
+ const device = getPairedDevice(store.handle, deviceId);
71
+ if (device === null || device.accountName !== accountName || device.revokedAt !== null)
72
+ return null;
73
+ if (listPasskeys(store, accountName).some(one => one.revokedAt === null))
74
+ return null;
75
+ return actions.openEnrollmentWindow(accountName, deviceId);
76
+ }
77
+ export function closePasskeySetup(service, accountName, windowId) {
78
+ service?.engine.actions?.closeEnrollmentWindow(accountName, windowId);
79
+ }
@@ -8,7 +8,7 @@ import {} from "../dispatch.js";
8
8
  import {} from "../first-run.js";
9
9
  import {} from "../gaps.js";
10
10
  import { limitsHtml } from "../limits-ui.js";
11
- import { ASK_LABEL, ASKS, START_BUILDER_COMMAND } from "../needs-you.js";
11
+ import { ASK_LABEL, ASKS } from "../needs-you.js";
12
12
  import {} from "../peek.js";
13
13
  import { projectName } from "../project.js";
14
14
  import {} from "../proof.js";
@@ -29,16 +29,6 @@ import { taskLinkOf } from "../task-link.js";
29
29
  import { criterionMatrixSummary, incidentWords, PHASE_WORDS, phaseWords } from "./render-results.js";
30
30
  import { decisionAnswerCard, decisionAnswerScript, dispatchHeadline, statusLineHtml, workDiagnosticsHtml } from "./render-tasks.js";
31
31
  export const TASK_STATES = ["queued", "running", "done", "failed", "cancelled"];
32
- export function startBuilderHtml(data) {
33
- const where = data.project === null ? null : html ` to <strong>${data.project}</strong>`;
34
- const state = data.connected === null ? null
35
- : data.connected ? html `<p>A builder is connected${where}. Approved tasks there start on their own.</p>`
36
- : html `<p><strong>No builder is connected</strong>${where}. Tasks wait until one is.</p>`;
37
- const title = data.heading === "h1" ? html `<h1 id="builder-heading">Start a builder</h1>` : html `<h2 id="builder-heading">Start a builder</h2>`;
38
- return html `<section id="builder" aria-labelledby="builder-heading">${title}<div class="card">${state}<p>On the computer where ${data.project ?? "the project"} lives, open the project's folder in a terminal and run:</p><p><code class="start-builder-command" style="user-select:all">${START_BUILDER_COMMAND}</code></p>${data.managed
39
- ? html `<p class="meta">Keep it running. Approved tasks start on their own. The console alone (<code>toolroll serve</code>) doesn't build.</p>`
40
- : html `<p class="meta">Starting a builder takes someone who manages this Toolroll. Ask them to run it there; your tasks start on their own once it connects.</p>`}</div></section>`;
41
- }
42
32
  export const BUILD_STEPS = ["setting up", "writing", "checking and committing"];
43
33
  export function buildStepOf(claim) {
44
34
  if (claim.role === "planner" || claim.role === "reviewer" || claim.role === "scout")
@@ -32,7 +32,6 @@ import { taskLinkOf } from "../task-link.js";
32
32
  import { attributes, html, htmlString, joinHtml, postForm, reauth } from "../html.js";
33
33
  import { chip, facts } from "./kit.js";
34
34
  import { publicationFactsOf, statusActionHref, statusLineHtml } from "./render-tasks.js";
35
- export const RUNS_PAGE = 50;
36
35
  export function editorFileHref(worktree, path, line) {
37
36
  if (!worktree.startsWith("/") || /[\u0000-\u001f\u007f]/.test(worktree))
38
37
  return null;
@@ -113,11 +113,6 @@ export function planContractHtml(view, mode) {
113
113
  html `</div>`,
114
114
  ]);
115
115
  }
116
- export function approvalPathsHtml(touches) {
117
- if (touches.length === 0)
118
- return html `<p>anything</p>`;
119
- return html `<ul class="approval-paths">${touches.map(one => html `<li><span class="mono">${one}</span></li>`)}</ul>`;
120
- }
121
116
  export function acceptanceCeremonyHtml(criteria) {
122
117
  if (criteria.length === 0)
123
118
  return html ``;
@@ -126,16 +121,6 @@ export function acceptanceCeremonyHtml(criteria) {
126
121
  export function agentNameWords(provider, model) {
127
122
  return agentModelName(provider, model);
128
123
  }
129
- export function permissionWordsOf(profile) {
130
- if (profile === null || profile === undefined)
131
- return null;
132
- return profile.provider === "claude"
133
- ? profile.permissionArgv === "bypassPermissions" ? "Full access" : "Auto permissions"
134
- : profile.provider === "gemini"
135
- ? profile.approvalArgv === "yolo" ? "Full access" : "Auto permissions"
136
- : isAcpProfile(profile) ? "Full access"
137
- : profile.sandboxMode === "danger-full-access" ? "Full access" : "Workspace sandbox";
138
- }
139
124
  export function revisionSentence(revision, acceptance) {
140
125
  const build = `build #${revision.sourceRun}`;
141
126
  if (revision.kind === "ci-repair")
@@ -601,11 +586,6 @@ export function agentsStandingWords(view) {
601
586
  ? "awaiting approval"
602
587
  : "recommended";
603
588
  }
604
- export function sizeLineHtml(projection) {
605
- if (projection.sizeWords === null)
606
- return html ``;
607
- return html `<p class="agents-size"><strong>${projection.sizeWords}.</strong>${projection.sizeReason === null ? "" : html ` <span class="meta">${projection.sizeReason}</span>`}</p>`;
608
- }
609
589
  export function sizeConsequence(size, risky) {
610
590
  if (size === "small" && !risky)
611
591
  return "Small change: fast model, no plan";
@@ -655,33 +635,6 @@ export function agentsWhyHtml(projection, summaryLabel = "Why these agents") {
655
635
  html `</dl></details>`,
656
636
  ]);
657
637
  }
658
- export function agentsCeremonyHtml(view) {
659
- if (view === null || view === undefined)
660
- return html ``;
661
- if (view.projection === null) {
662
- if (view.legacy !== null) {
663
- return html `<div class="agents-ceremony"><p class="approval-label">agents</p><p class="agents-summary">${agentsSummaryWords(view)}</p></div>`;
664
- }
665
- return html ``;
666
- }
667
- return joinHtml([
668
- html `<div class="agents-ceremony"><p class="approval-label">agents</p>`,
669
- sizeLineHtml(view.projection),
670
- html `<p class="agents-summary">${view.projection.summary}</p>`,
671
- routeEvidenceHtml(view),
672
- html `<div class="agents-badges">${riskBadgeHtml(view.projection)}<span class="badge">${sentenceCase(view.projection.postureWords)}</span></div>`,
673
- agentsWhyHtml(view.projection),
674
- html `<p class="meta">These exact agents are part of what you approve; changing any of them asks for a fresh approval.</p></div>`,
675
- ]);
676
- }
677
- export function runtimeDetailsHtml(scope) {
678
- if (scope.profileState === "unresolved")
679
- return profileWords(scope);
680
- const words = profileWords(scope);
681
- if (isEmptyHtml(words))
682
- return html ``;
683
- return html `<details class="agents-runtime"><summary>Runtime limits</summary>${words}</details>`;
684
- }
685
638
  export function agentsCardHtml(taskId, view, canEdit, signIn) {
686
639
  if (view === null || view === undefined)
687
640
  return html ``;
@@ -2258,27 +2211,6 @@ export function qualityModeChoices(name, selected) {
2258
2211
  html `</div>`,
2259
2212
  ]);
2260
2213
  }
2261
- export function decisionOptionForms(decision, returnTo) {
2262
- return joinHtml(decision.options
2263
- .map(option => {
2264
- const recommended = option.id === decision.recommendation;
2265
- const inner = postForm(`/d/${decision.id}/answer`, joinHtml([
2266
- "",
2267
- recommended ? html `<p class="meta" style="margin:0 0 .375rem"><span class="badge">Recommended</span></p>` : "",
2268
- html `<p class="consequence">${option.consequence}</p>`,
2269
- html `<button type="submit">${option.label}${option.reversible ? "" : html ` <span class="badge badge-overdue">Irreversible</span>`}</button>`,
2270
- html `<input type="text" name="note" placeholder="optional note — travels with this answer" aria-label="optional note">`,
2271
- "",
2272
- ], "\n"), {
2273
- attrs: { class: `option${recommended ? " recommended" : ""}` },
2274
- returnTo,
2275
- hidden: { choice: option.id, confirm: option.reversible ? null : "yes" },
2276
- });
2277
- return option.reversible
2278
- ? inner
2279
- : html `<details class="arm-danger"><summary>${option.label} — irreversible, tap to arm</summary>${inner}</details>`;
2280
- }), "\n");
2281
- }
2282
2214
  export function taskOf(store, decision) {
2283
2215
  const run = store.getRun(decision.run);
2284
2216
  return run === null ? "?" : store.externalIdFor(run.taskRef) ?? "?";
@@ -244,7 +244,7 @@ edge("remote", "edge.connect-pair-poll", "POST", "/api/connect/pair/poll");
244
244
  edge("remote", "edge.connect-pair-page", "GET", "^\\/connect\\/pair\\/[A-Z2-9]{4}-[A-Z2-9]{4}$", { sample: "/connect/pair/ABCD-EFGH" });
245
245
  edge("remote", "edge.connect-pair-confirm", "POST", "^\\/connect\\/pair\\/[A-Z2-9]{4}-[A-Z2-9]{4}$", { callers: ["cookie"], scope: "step-up", viewer: true, proof: "adapter", sample: "/connect/pair/ABCD-EFGH" });
246
246
  edge("remote", "edge.teams", "POST", "/teams/messages", { callers: ["service"], proof: "adapter" });
247
- edge("pages", "edge.browser-asset", "GET,HEAD", "^\\/assets\\/(workspace\\.js|workspace\\.css|terminal\\.js|terminal\\.css|THIRD_PARTY_NOTICES\\.txt)$", { sample: "/assets/workspace.js" });
247
+ edge("pages", "edge.browser-asset", "GET,HEAD", "^\\/assets\\/((workspace|terminal)(\\.[0-9a-f]{64})?\\.(js|css)|THIRD_PARTY_NOTICES\\.txt)$", { sample: `/assets/workspace.${"0".repeat(64)}.js` });
248
248
  edge("pages", "edge.workspace-style", "GET,HEAD", "^\\/assets\\/workspace-[0-9a-f]{64}\\.css$", { sample: `/assets/workspace-${"0".repeat(64)}.css` });
249
249
  edge("pages", "edge.install-asset", "GET", "^\\/(manifest\\.webmanifest|favicon\\.ico|icon\\.svg|icon-attention\\.svg|icon-192\\.png|icon-512\\.png|apple-touch-icon\\.png|sw\\.js)$", { sample: "/sw.js" });
250
250
  edge("pages", "edge.font", "GET", "^\\/fonts\\/geist-(sans|mono)-(400|500|600)\\.woff2$", { sample: "/fonts/geist-sans-400.woff2" });
@@ -9,7 +9,7 @@ import { refuse, relativeAge, screen } from "./chrome.js";
9
9
  import { handlersOf } from "./handler-registry.js";
10
10
  import { redirect, respond } from "./http.js";
11
11
  import { acts, btn, codeLine, infoLine, note, notice, settingsRecord, settingsSection } from "./kit.js";
12
- import { cancelPairing, confirmPairing, isPasskeyEnrollmentOpen, listPasskeys, listPhones, openPasskeyEnrollment, pairingView, parsePasskeyWindowMinutes, passkeyWindowMinutes, pathStates, removePhone, renamePhone, revokePasskey, savePasskeyWindow, endPasskeyWindows, startPairing, } from "./phone-engine-api.js";
12
+ import { cancelPairing, confirmPairing, isPasskeyEnrollmentOpen, listPasskeys, listPhones, openPasskeyEnrollment, pairingView, parsePasskeyWindowMinutes, passkeyWindowMinutes, pathStates, removePhone, renamePhone, revokePasskey, savePasskeyWindow, endPasskeyWindows, startPairing, openPasskeySetupForPairedPhone, closePasskeySetup, } from "./phone-engine-api.js";
13
13
  import { browserCaller } from "./session.js";
14
14
  export const COMPANION_DOCS_URL = "https://github.com/ap9000/toolroll/blob/main/docs/companion-app.md";
15
15
  const DEFAULT_RELAY_HOST = "relay.toolroll.dev";
@@ -69,7 +69,14 @@ export const PHONE_PAIRING_SCRIPT = `(function(){var first=document.getElementBy
69
69
  `.then(function(r){if(r.status===404||r.type==="opaqueredirect"){leave();return null;}if(!r.ok)throw 0;return r.json();})` +
70
70
  `.then(function(v){if(v===null)return;misses=0;apply(v);if(!done)setTimeout(poll,1000);})` +
71
71
  `.catch(function(){misses++;if(misses>20)return leave();setTimeout(poll,Math.min(10000,1000*misses));});}` +
72
- `clock();setTimeout(poll,1000);})();`;
72
+ `clock();setTimeout(poll,1000);})();` +
73
+ `(function(){if(!document.getElementById("phone-passkey-wait")||document.getElementById("phone-pairing"))return;var done=false,misses=0;` +
74
+ `function check(){if(done)return;if(document.hidden){setTimeout(check,3000);return;}` +
75
+ `fetch("/settings/phone",{credentials:"same-origin",cache:"no-store",redirect:"manual",headers:{accept:"text/html"}})` +
76
+ `.then(function(r){if(r.type==="opaqueredirect"||!r.ok)throw 0;return r.text();})` +
77
+ `.then(function(t){misses=0;if(t.indexOf('id="phone-passkey-wait"')<0){done=true;location.reload();return;}setTimeout(check,3000);})` +
78
+ `.catch(function(){misses++;if(misses>20)return;setTimeout(check,Math.min(15000,3000*misses));});}` +
79
+ `setTimeout(check,3000);})();`;
73
80
  export function createPhoneSettingsHandlers(runtime, deps) {
74
81
  const { store } = runtime;
75
82
  const mac = (deps.platform ?? process.platform) === "darwin";
@@ -123,7 +130,7 @@ export function createPhoneSettingsHandlers(runtime, deps) {
123
130
  hosted.superseded === true ? notice("Another Toolroll with this workspace's keys is connected to the relay. Phones connecting from anywhere reach that one; stop it, or turn off connecting from anywhere on one of them.") : "",
124
131
  ]) });
125
132
  }
126
- function pairingPanel(view, qr) {
133
+ function pairingPanel(view, qr, setsUpApprovals) {
127
134
  const id = view.pairSessionId;
128
135
  const left = Math.max(0, view.expiresAtMs - runtime.clock().getTime());
129
136
  const shown = view.status === "awaiting_confirm" ? "code" : view.status === "confirming" ? "confirming" : view.status === "finishing" ? "finishing" : qr !== undefined ? "scan" : "waiting";
@@ -147,7 +154,8 @@ ${note("The QR code is shown only once. If you closed it before scanning, cancel
147
154
  <p class="k-note" data-phone-device>${codeLead(view.deviceName)}</p>\
148
155
  <p class="k-phone-code"><span aria-hidden="true" data-phone-code>${code}</span><span class="k-sr" data-phone-code-spoken>${spokenCode(code)}</span></p>\
149
156
  ${note("Only confirm if your iPhone shows exactly this code. If it doesn't, cancel: someone else may have scanned your QR code.")}${expires}\
150
- <div class="k-acts">${postForm("/settings/phone/confirm", html `<button type="submit" class="k-btn k-btn-primary k-btn-sm"><span class="k-face">Codes match — pair</span></button>`, { hidden: { pairing: id } })}${cancel()}</div></div>\
157
+ <div class="k-acts">${postForm("/settings/phone/confirm", html `<button type="submit" class="k-btn k-btn-primary k-btn-sm"><span class="k-face">Codes match — pair</span></button>`, { hidden: setsUpApprovals ? { pairing: id, setup: "1" } : { pairing: id } })}${cancel()}</div>\
158
+ ${setsUpApprovals ? note("Confirming also lets this iPhone set up its passkey for approvals in the next 5 minutes.") : ""}</div>\
151
159
  <div data-view="confirming"${hidden("confirming")}>${shown === "confirming" ? reload : ""}<p class="k-phone-wait" role="status">Saving the pairing…</p></div>\
152
160
  <div data-view="finishing"${hidden("finishing")}>${shown === "finishing" ? reload : ""}<p class="k-phone-wait" role="status">Finishing on the iPhone…</p>\
153
161
  ${note("Keep the Toolroll app open until it says it's paired.")}</div>\
@@ -227,6 +235,11 @@ ${note("Keep the Toolroll app open until it says it's paired.")}</div>\
227
235
  : "Let the Toolroll iPhone app see your work. Nothing is shared until you pair a phone.",
228
236
  body: accessBody,
229
237
  });
238
+ const passkeys = passworded ? listPasskeys(store, who.name) : [];
239
+ const activePasskeys = passkeys.filter(k => k.revokedAt === null);
240
+ let lastStepSaid = false;
241
+ const lastStepOpen = () => passworded && activePasskeys.length === 0 && isPasskeyEnrollmentOpen(service, who.name);
242
+ const lastStepLine = () => { lastStepSaid = true; return html `<div id="phone-passkey-wait">${infoLine("Last step: on your iPhone, confirm with Face ID or your passcode to turn on approvals.")}</div>`; };
230
243
  const binding = bindingOf(who);
231
244
  let script = false;
232
245
  let pairBody = null;
@@ -243,12 +256,17 @@ ${note("Keep the Toolroll app open until it says it's paired.")}</div>\
243
256
  const live = open !== null && ["awaiting_scan", "awaiting_ready", "awaiting_confirm", "confirming", "finishing"].includes(open.status);
244
257
  if (open !== null && live) {
245
258
  script = true;
246
- pairBody = pairingPanel(open, options.qr?.pairSessionId === open.pairSessionId ? options.qr : undefined);
259
+ pairBody = pairingPanel(open, options.qr?.pairSessionId === open.pairSessionId ? options.qr : undefined, activePasskeys.length === 0);
247
260
  }
248
261
  else {
249
262
  if (open !== null)
250
263
  openPairings.delete(binding);
251
- const last = options.problem !== undefined ? "" : open !== null ? outcomeLine(open) : restarted ? notice("Pairing stopped because phone access restarted. Pair again.") : "";
264
+ if (open !== null && open.status !== "paired" && opened?.passkeyWindow !== undefined)
265
+ closePasskeySetup(service, who.name, opened.passkeyWindow);
266
+ const paired = options.problem === undefined && open !== null && open.status === "paired";
267
+ const last = options.problem !== undefined ? ""
268
+ : paired && lastStepOpen() ? joinHtml([infoLine("Your iPhone is paired."), lastStepLine()])
269
+ : open !== null ? outcomeLine(open) : restarted ? notice("Pairing stopped because phone access restarted. Pair again.") : "";
252
270
  const why = !on ? note(operator ? "Turn on phone access first." : "Ask whoever runs this Toolroll to turn on phone access.")
253
271
  : hosted.state === "starting" && !directWorks ? note(`Connecting to ${new URL(hosted.relay).host}… Reload this page in a moment.`)
254
272
  : direct !== null && direct.state === "failed" && !hostedWorks
@@ -276,8 +294,6 @@ ${note("Keep the Toolroll app open until it says it's paired.")}</div>\
276
294
  retired.length === 0 ? "" : html `<h3 class="k-phone-sub">Removed or signed out in the last 30 days</h3>${joinHtml(retired.map(phone => phoneRecord(phone, now)))}`,
277
295
  ]),
278
296
  });
279
- const passkeys = passworded ? listPasskeys(store, who.name) : [];
280
- const activePasskeys = passkeys.filter(k => k.revokedAt === null);
281
297
  const enrollmentOpen = isPasskeyEnrollmentOpen(service, who.name);
282
298
  const windowMins = passkeyWindowMinutes(store);
283
299
  const passkeyRecord = (k) => settingsRecord({
@@ -307,7 +323,8 @@ ${note("Keep the Toolroll app open until it says it's paired.")}</div>\
307
323
  lead: "Approve plans, accept results, land and ship from your paired iPhone. Each one is confirmed with a passkey and checked on this Mac.",
308
324
  body: joinHtml([
309
325
  enrollmentOpen
310
- ? infoLine("Set up is open for 5 minutes. On your paired iPhone, open Settings → Passkey approvals and tap Set up passkey.")
326
+ ? activePasskeys.length === 0 ? (lastStepSaid ? "" : lastStepLine())
327
+ : infoLine("Set up is open for 5 minutes. On your paired iPhone, open Settings → Passkey approvals and tap Add another passkey.")
311
328
  : on && current.length > 0
312
329
  ? kitSectionForm({ proof: "phone-passkey-enable", action: "/settings/phone/passkey/enable", id: "phone-passkey-enable-form", native: true,
313
330
  save: { label: activePasskeys.length === 0 ? "Set up a passkey on iPhone" : "Add another passkey", variant: "outline" },
@@ -320,6 +337,8 @@ ${note("Keep the Toolroll app open until it says it's paired.")}</div>\
320
337
  : settingsRecord({ title: "Passkey prompt", sub: `${promptLabel(windowMins)} · Whoever runs this Toolroll sets this.`, more: alwaysAsks }),
321
338
  ]),
322
339
  });
340
+ if (lastStepSaid)
341
+ script = true;
323
342
  return { body: settingsSubPage("access", "Phone", joinHtml([problem, accessSection, pairSection, devices, passkeySection]), { lead: "The Toolroll iPhone app: what needs you, in your pocket." }), script };
324
343
  }
325
344
  const render = (response, status, who, options = {}) => {
@@ -395,6 +414,10 @@ ${note("Keep the Toolroll app open until it says it's paired.")}</div>\
395
414
  const confirmed = await confirmPairing(service, pairing, binding);
396
415
  if (!confirmed.ok)
397
416
  return render(ctx.response, 409, who, { problem: confirmed.error });
417
+ const disclosed = body.getAll("setup").length === 1 && body.get("setup") === "1";
418
+ const setup = disclosed ? openPasskeySetupForPairedPhone(service, store, who.name, who.session.generation, confirmed.deviceId) : null;
419
+ if (setup !== null)
420
+ openPairings.set(binding, { ...opened, passkeyWindow: setup.windowId });
398
421
  return redirect(ctx.response, "/settings/phone#phone-pair");
399
422
  };
400
423
  async function renameAct(ctx) {
@@ -10,7 +10,7 @@ export const SCRIPT_INVENTORY = Object.freeze([
10
10
  { id: "tools", does: "Saves a tool's settings as they change, and switches project", symbol: "TOOLS_PROJECT_SCRIPT", module: "tools-ui.ts", today: "settings.tools", section: "tools", slice: "P4", fetches: false,
11
11
  keep: "kit and connect links lead to the tools change document, which owns the script (round 2, change 4)" },
12
12
  { id: "push", does: "Enrolls this device for alerts (a service worker and a push subscription)", symbol: "pushScriptOf", module: "settings-groups-ui.ts", today: "settings.group-alerts", section: "this-device", slice: "C1", fetches: true },
13
- { id: "phone-pairing", does: "Follows a phone pairing in progress: swaps the QR for the code to compare, counts down, and reloads on the outcome", symbol: "PHONE_PAIRING_SCRIPT", module: "server/settings-phone.ts", today: "settings.phone", section: "phone-pair", slice: "companion-perfect", fetches: true,
13
+ { id: "phone-pairing", does: "Follows a phone pairing in progress: swaps the QR for the code to compare, counts down, and reloads on the outcome; then waits for the iPhone's passkey", symbol: "PHONE_PAIRING_SCRIPT", module: "server/settings-phone.ts", today: "settings.phone", section: "phone-pair", slice: "companion-perfect", fetches: true,
14
14
  keep: "the pair POST's sensitive answer carries it too; without JavaScript the page works by reload" },
15
15
  { id: "hub-anchors", does: "Forwards the overview's old #anchors to their group pages", symbol: "HUB_ANCHOR_SCRIPT", module: "settings-groups-ui.ts", today: "settings.page", section: "home", slice: "D", fetches: false,
16
16
  keep: "replaced by the retired-address resolvers once every anchor's page is an area" },
@@ -43,9 +43,6 @@ export const CHANGE_DOCUMENTS = SETTINGS_SECTIONS.flatMap(section => section.cha
43
43
  export function changeDocumentOf(id) {
44
44
  return CHANGE_DOCUMENTS.find(one => one.id === id);
45
45
  }
46
- export function sectionDeclaration(id) {
47
- return SETTINGS_SECTIONS.find(one => one.id === id);
48
- }
49
46
  export const AREA_PATHS = Object.freeze({ general: "/settings/general", computers: "/settings/computers" });
50
47
  export function sectionHref(declaration, options = {}) {
51
48
  const path = AREA_PATHS[declaration.area] ?? "/settings";
@@ -5,7 +5,7 @@ import { html, joinHtml, postForm } from "../html.js";
5
5
  import { kitSectionForm, secretInput } from "../settings-kit.js";
6
6
  import { signInCheckWords, statusCheck } from "../flexible-sign-in.js";
7
7
  import { evaluateRoutePolicy, holdsRole } from "./route-policy.js";
8
- import { btn, codeLine, disclose, doc, docHeader, formRow, infoLine, input, notice, phoneHeader, select, settingsLink, settingsSection } from "./kit.js";
8
+ import { btn, codeLine, codeWords, disclose, doc, docHeader, formRow, infoLine, input, notice, phoneHeader, select, settingsLink, settingsSection } from "./kit.js";
9
9
  import { changeDocumentOf, changeHref, sectionHref, SETTINGS_SECTIONS } from "./settings-section-table.js";
10
10
  export function gateHolds(gate, person) {
11
11
  switch (gate) {
@@ -183,12 +183,14 @@ function versionSection(deps) {
183
183
  return {
184
184
  loadSummary: ctx => {
185
185
  const version = (ctx.scopes.has("updates-version") ? deps.updatesVersion(ctx.person.name) : null) ?? (ctx.scopes.has("package-version") ? deps.packageVersion : null);
186
- return version === null ? null : { version, firstResult: deps.firstResult(ctx.now), updates: ctx.can["updates"] === true };
186
+ const drift = ctx.scopes.has("updates-version") ? deps.runtimeDrift?.() ?? null : null;
187
+ return version === null ? null : { version, firstResult: deps.firstResult(ctx.now), updates: ctx.can["updates"] === true, drift };
187
188
  },
188
189
  render: ({ summary, attrs }) => settingsSection({
189
190
  id: "version", title: "Version", attrs,
190
191
  body: joinHtml([
191
192
  formRow("Toolroll", summary.firstResult ?? "Installed on this computer.", html `<span class="k-mono">${summary.version}</span>`, "inline"),
193
+ summary.drift === null ? "" : html `<div data-runtime-drift>${infoLine(codeWords(summary.drift))}</div>`,
192
194
  summary.updates ? formRow("Updates", null, btn("Open updates", { sm: true, variant: "ghost", href: "/settings/updates" }), "inline") : "",
193
195
  ]),
194
196
  }),