toolroll 0.9.109 → 0.9.110

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 (135) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/agent-detect.js +244 -0
  3. package/dist/agent-fence.js +12 -1
  4. package/dist/agentconfig.js +2 -2
  5. package/dist/approval-summary.js +344 -0
  6. package/dist/attest.js +2 -2
  7. package/dist/browser/workspace.css +2 -2
  8. package/dist/browser/workspace.js +27 -27
  9. package/dist/builder.js +36 -2
  10. package/dist/chat-actions.js +24 -17
  11. package/dist/chat-core.js +3 -1
  12. package/dist/chat-decide.js +101 -46
  13. package/dist/chat-delivery-state.js +2 -0
  14. package/dist/chat-delivery.js +3 -2
  15. package/dist/chat-live.js +2 -1
  16. package/dist/chat-task-actions.js +6 -0
  17. package/dist/check-report.js +1 -1
  18. package/dist/cli.js +2 -0
  19. package/dist/console-instance.js +10 -1
  20. package/dist/contracts/console-api.js +10 -5
  21. package/dist/contracts/engine-api.js +271 -0
  22. package/dist/coordinator.js +2 -2
  23. package/dist/discord-api.js +4 -3
  24. package/dist/discord-chat.js +3 -1
  25. package/dist/easy-start-args.js +7 -3
  26. package/dist/easy-start.js +25 -0
  27. package/dist/egress.js +72 -10
  28. package/dist/engine-handoff.js +34 -0
  29. package/dist/engine-reads.js +261 -0
  30. package/dist/eval-world.js +3 -2
  31. package/dist/evidence.js +2 -0
  32. package/dist/fast-start.js +55 -14
  33. package/dist/fast-terms.js +2 -2
  34. package/dist/first-run.js +10 -2
  35. package/dist/flexible-agents.js +234 -0
  36. package/dist/flexible-answers-schema.js +61 -0
  37. package/dist/flexible-answers.js +889 -0
  38. package/dist/flexible-custody.js +494 -0
  39. package/dist/flexible-import.js +782 -0
  40. package/dist/flexible-launch-schema.js +72 -0
  41. package/dist/flexible-launch.js +331 -0
  42. package/dist/flexible-launcher.js +88 -0
  43. package/dist/flexible-levels.js +34 -0
  44. package/dist/flexible-merge-guard.js +47 -0
  45. package/dist/flexible-refs.js +47 -0
  46. package/dist/flexible-relay-cancel.js +19 -0
  47. package/dist/flexible-relay-schema.js +55 -0
  48. package/dist/flexible-relay-upstreams.js +36 -0
  49. package/dist/flexible-relay.js +1032 -0
  50. package/dist/flexible-session.js +732 -0
  51. package/dist/flexible-ship-schema.js +81 -0
  52. package/dist/flexible-ship.js +694 -0
  53. package/dist/flexible-start.js +80 -0
  54. package/dist/flexible-thread.js +175 -25
  55. package/dist/flexible-turns-schema.js +69 -0
  56. package/dist/flexible-turns.js +490 -0
  57. package/dist/flexible.js +10 -1
  58. package/dist/flow-actions.js +6 -4
  59. package/dist/flow-steps.js +1 -1
  60. package/dist/flows-cli.js +2 -1
  61. package/dist/git-views.js +6 -3
  62. package/dist/install-mode.js +225 -0
  63. package/dist/lead-doors.js +7 -1
  64. package/dist/limits-ui.js +7 -0
  65. package/dist/live-reply.js +6 -0
  66. package/dist/live-terminal.js +425 -29
  67. package/dist/local-owner.js +6 -0
  68. package/dist/model-choices.js +12 -6
  69. package/dist/notification-delivery.js +11 -0
  70. package/dist/operate.js +74 -30
  71. package/dist/outbound-privacy.js +204 -0
  72. package/dist/passwordless.js +2 -1
  73. package/dist/project-delete.js +14 -0
  74. package/dist/provider-connection.js +5 -3
  75. package/dist/publish.js +5 -0
  76. package/dist/pull-request-flow.js +26 -7
  77. package/dist/push.js +5 -1
  78. package/dist/release-card.js +11 -3
  79. package/dist/release.js +10 -1
  80. package/dist/route-store.js +2 -2
  81. package/dist/sandbox-launch.js +32 -8
  82. package/dist/sandbox-runtime.js +16 -7
  83. package/dist/sandbox-tools.js +176 -0
  84. package/dist/scope.js +12 -36
  85. package/dist/scout-net.js +7 -2
  86. package/dist/serve.js +58 -11
  87. package/dist/server/chrome.js +3 -1
  88. package/dist/server/console.css +33 -6
  89. package/dist/server/engine-api.js +378 -0
  90. package/dist/server/flows.js +2 -2
  91. package/dist/server/http.js +7 -0
  92. package/dist/server/link-redemption.js +52 -0
  93. package/dist/server/mutation-key.js +21 -7
  94. package/dist/server/pages.js +69 -40
  95. package/dist/server/people-tokens.js +17 -41
  96. package/dist/server/render-chat.js +1 -0
  97. package/dist/server/render-new-task.js +3 -3
  98. package/dist/server/render-results.js +4 -4
  99. package/dist/server/render-tasks.js +129 -138
  100. package/dist/server/route-table.js +30 -1
  101. package/dist/server/settings-section-table.js +3 -0
  102. package/dist/server/settings-sections.js +33 -0
  103. package/dist/server/settings.js +84 -10
  104. package/dist/server/task-views.js +8 -2
  105. package/dist/server/tasks.js +25 -8
  106. package/dist/server/terminals.js +181 -28
  107. package/dist/server/welcome.js +35 -10
  108. package/dist/settings-groups-ui.js +2 -2
  109. package/dist/settings-proofs.js +13 -9
  110. package/dist/slack-api.js +4 -3
  111. package/dist/slack-chat.js +5 -3
  112. package/dist/spend.js +46 -12
  113. package/dist/status-probe.js +343 -0
  114. package/dist/store.js +102 -5
  115. package/dist/teams-api.js +4 -3
  116. package/dist/teams-chat.js +4 -2
  117. package/dist/telegram-lead.js +2 -1
  118. package/dist/telegram-live.js +2 -1
  119. package/dist/telegram-team.js +2 -1
  120. package/dist/telegram.js +17 -5
  121. package/dist/trusted-path.js +162 -0
  122. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  123. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  124. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  125. package/dist/tui/linux-x64/toolroll-tui +0 -0
  126. package/dist/tui-launch.js +282 -0
  127. package/dist/tui-source.js +5 -3
  128. package/dist/tui.js +1 -1
  129. package/dist/webhooks.js +8 -4
  130. package/dist/welcome-facts.js +22 -15
  131. package/dist/workspace-ui.js +5 -0
  132. package/package.json +1 -1
  133. package/scripts/crash-canary.mjs +1 -1
  134. package/scripts/pilot.mjs +1 -1
  135. package/scripts/provider-canary.mjs +5 -3
@@ -1,5 +1,6 @@
1
1
  import { ADVANCED_PAGES } from "../advanced-view.js";
2
2
  import { accentNote, ACCENT_PRESETS } from "../accent-colors.js";
3
+ import { installModeLine, justMeAllowed, TEAM_FACT_WORDS } from "../install-mode.js";
3
4
  import { html, joinHtml, postForm } from "../html.js";
4
5
  import { kitSectionForm } from "../settings-kit.js";
5
6
  import { evaluateRoutePolicy, holdsRole } from "./route-policy.js";
@@ -237,12 +238,44 @@ function localModeSection(deps) {
237
238
  },
238
239
  };
239
240
  }
241
+ function installModeSection(deps) {
242
+ return {
243
+ loadSummary: ctx => {
244
+ const read = deps.installMode();
245
+ const canSwitch = ctx.can["just-me"] === true;
246
+ return { mode: read.mode, facts: read.facts, canSwitch, offered: canSwitch && justMeAllowed(read) };
247
+ },
248
+ render: ({ declaration, summary, attrs }) => {
249
+ const line = installModeLine(summary.mode);
250
+ return settingsSection({ id: "install-mode", title: line.label, attrs, lead: line.words,
251
+ ...(summary.offered ? { right: btn("It's just me", { sm: true, href: changeHref(declaration.changes[0]) }) } : {}), body: html `` });
252
+ },
253
+ refusal: "An instance operator signed in with a password says it's just them.",
254
+ renderChange: ({ declaration, summary, problem }) => {
255
+ const home = sectionHref(declaration);
256
+ const title = "It's just me";
257
+ const blocked = summary === null ? [] : summary.facts.filter(fact => fact !== "existing-install" && !fact.endsWith("-added"));
258
+ const words = summary === null || summary.mode === "solo"
259
+ ? html `${infoLine("This install is solo.")}<div class="k-acts">${btn("Back to General", { href: home })}</div>`
260
+ : !summary.offered
261
+ ? html `${blocked.map(fact => notice(TEAM_FACT_WORDS[fact]))}<div class="k-acts">${btn("Back to General", { href: home })}</div>`
262
+ : joinHtml([
263
+ html `<p>Approvals and Accept then need only you signed in. Signing in, tokens and connecting things still ask for your password. If anyone joins, this install switches back to Team.</p>`,
264
+ problem === null ? "" : notice(problem),
265
+ kitSectionForm({ proof: "install-solo", action: "/settings/install-mode/solo", id: "just-me-form", native: true, save: { label: title }, confirm: title, body: html `` }),
266
+ html `<div class="k-acts">${btn("Cancel", { variant: "ghost", href: home })}</div>`,
267
+ ]);
268
+ return { title, body: html `<div data-kit-page>${phoneHeader(title, { back: home })}${doc(docHeader({ title, back: [home, "General"], same: true }), words)}</div>` };
269
+ },
270
+ };
271
+ }
240
272
  export function generalSections(deps) {
241
273
  return {
242
274
  appearance: appearanceSection(),
243
275
  "this-browser": thisBrowserSection(),
244
276
  "your-password": yourPasswordSection(deps),
245
277
  version: versionSection(deps),
278
+ "install-mode": installModeSection(deps),
246
279
  advanced: advancedSection(),
247
280
  "local-mode": localModeSection(deps),
248
281
  };
@@ -1,4 +1,5 @@
1
1
  import { PASSWORDLESS_TRADE, passwordlessSetting, setPasswordless } from "../passwordless.js";
2
+ import { declareJustMe, installModeNow, sessionStandsIn, soloNow, TEAM_FACT_WORDS } from "../install-mode.js";
2
3
  import { ACP_AGENTS, isKeyedProvider } from "../acp-agents.js";
3
4
  import { LIVE_VIEW_CONSENT, liveViewConsentDigest, setLiveCommands } from "../live-detail.js";
4
5
  import { CONSOLE_FORMS, readForm } from "../contracts/console-api.js";
@@ -23,6 +24,7 @@ import { adapterPolicy } from "./route-policy.js";
23
24
  import { createHash } from "node:crypto";
24
25
  import { basename, dirname, join } from "node:path";
25
26
  import { INSTALLATION_SCOPE } from "../agentconfig.js";
27
+ import { checkEngineResponse, ENGINE_API_VERSION } from "../contracts/engine-api.js";
26
28
  import { rulesSummary } from "../approval-rules-ui.js";
27
29
  import { installMethod } from "../install-method.js";
28
30
  import { logEvent } from "../log.js";
@@ -92,7 +94,7 @@ import { decideProposal, defaultTidyAnalyzer, listProposals, memoryStatus } from
92
94
  import { checkModels, isNewModel, modelOptions, modelWords, RUNTIME_TOOLS, runtimeStates, seenModels, setWatch, updateRuntime, watchState } from "../model-catalog.js";
93
95
  import { modelsHtml, modelsScript } from "../models-ui.js";
94
96
  import { acceptSuggestion, dismissSuggestion, grantWords, keepRule, modelName, ruleWords, rulesOf, setSuggestModels, startTrial, stopTrial, suggestionsFor, suggestionWords, suggestModelsOn, trialOffersFor, trialOfferWords, trialsOf, trialWords, turnOffRule } from "../route-rules.js";
95
- import { ALL_SLOTS, applyModelChoices, browserWords, checkScope, DEFAULT_PRESET, defaultAgentOf, fillDefaultRouting, isPresetName, newerModels, PRESETS, presetChange, presetInUse, previewModelChange, recentRuns, rowAt, slotKey, SLOTS, slotWords, stateDigest, switchChange } from "../model-choices.js";
97
+ import { AGENT_PRESETS, ALL_SLOTS, applyModelChoices, browserWords, checkScope, DEFAULT_PRESET, defaultAgentOf, fillDefaultRouting, isPresetName, newerModels, PRESETS, presetChange, presetInUse, previewModelChange, recentRuns, rowAt, slotKey, SLOTS, slotWords, stateDigest, switchChange } from "../model-choices.js";
96
98
  import { HEADROOM_FIVE_HOUR_LIMIT, HEADROOM_WEEKLY_LIMIT, exactModelId } from "../phase-routing.js";
97
99
  import { RISKY_MEANS, SIZE_MEANS, SIZING_CLAUDE_MODEL } from "../task-sizing.js";
98
100
  import { CHAT_APPROVE_ALL, CHECK_REPAIR_LIMIT, MODE_MAX_DAYS, modeDigestOf, modeTermsJson, modeWords, presetTerms } from "../modes.js";
@@ -544,7 +546,7 @@ ${connectionHtml(asked, connection, task)}${command === null ? "" : html `<p>On
544
546
  const setting = passwordlessSetting(store);
545
547
  const said = url.searchParams.get("said"), problem = url.searchParams.get("problem");
546
548
  const since = setting.at === null ? null : `${setting.on ? "on" : "off"} since ${new Date(setting.at).toLocaleString("en-US", { dateStyle: "medium", timeStyle: "short" })}, by ${setting.setBy ?? "someone"}`;
547
- return sendScreen(response, 200, screen("Passwordless", passwordlessHtml({ on: setting.on, since, trade: PASSWORDLESS_TRADE, said, problem }), { chrome: chromeFor(project, "settings") }));
549
+ return sendScreen(response, 200, screen("Passwordless", passwordlessHtml({ on: sessionStandsIn(store), since, trade: PASSWORDLESS_TRADE, said, problem }), { chrome: chromeFor(project, "settings") }));
548
550
  }
549
551
  async function passwordlessSave(ctx) {
550
552
  const { response, now, posted } = ctx;
@@ -726,7 +728,7 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
726
728
  const updates = minimal ? null : settingsUpdates(who.name, csrf);
727
729
  const lastBackup = operator ? store.backupRuns(1)[0] ?? null : null;
728
730
  const accounts = minimal || !operator ? null : store.accountFacts().filter(one => one.revokedAt === null);
729
- const passwordless = minimal ? null : passwordlessSetting(store).on;
731
+ const passwordless = minimal ? null : sessionStandsIn(store);
730
732
  const facts = {
731
733
  name: who.name, approver: who.role === "approver", operator, browser: who.via === "cookie", installation: !minimal,
732
734
  said: url.searchParams.get("said"), problem: url.searchParams.get("problem"),
@@ -1243,12 +1245,16 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
1243
1245
  return refuse(response, who, 403, "An approver sets up pull requests.", "/projects");
1244
1246
  const back = sayTo(response, `/settings/pull-requests?repo=${encodeURIComponent(repo)}`);
1245
1247
  const act = body.get("act");
1246
- if (!authenticateApprover(who, body.get("password") ?? "", repo).ok)
1248
+ const provedGeneration = store.accountOf(who.name)?.generation ?? -1;
1249
+ if (!(act === "on" ? authenticateCredential(who, body.get("password") ?? "", repo) : authenticateApprover(who, body.get("password") ?? "", repo)).ok)
1247
1250
  return back("problem", "Enter your Toolroll password to change pull requests.");
1248
1251
  if (act === "on") {
1249
1252
  const checked = await checkPublishing(repo, options.publishExec === undefined ? {} : { exec: options.publishExec });
1250
1253
  if (!checked.ok)
1251
1254
  return back("problem", checked.message);
1255
+ const account = store.accountOf(who.name);
1256
+ if (account === null || account.revokedAt !== null || account.role !== "approver" || account.generation !== provedGeneration || !store.accountCanAccess(who.name, repo))
1257
+ return back("problem", "Your access changed meanwhile. Nothing changed.");
1252
1258
  if (checked.plan.githubRepo !== body.get("github") || checked.plan.base !== body.get("base"))
1253
1259
  return back("problem", "GitHub answered differently from what you saw. Check the details again.");
1254
1260
  savePublishing(store, checked.plan, who.name, {}, now);
@@ -1442,7 +1448,7 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
1442
1448
  if (!options.configDir)
1443
1449
  return refuse(response, who, 403, "An instance operator sets up monitoring.", "/settings");
1444
1450
  const back = sayTo(response, "/settings/monitoring");
1445
- if (!authenticateApprover(who, body.get("password") ?? "").ok)
1451
+ if (!authenticateCredential(who, body.get("password") ?? "").ok)
1446
1452
  return back("problem", "Enter your Toolroll password to change monitoring.");
1447
1453
  const before = readMonitoring(options.configDir);
1448
1454
  const saved = saveMonitoring(options.configDir, { webhook: body.get("webhook") ?? "", folder: body.get("folder") ?? "", tracesEndpoint: body.get("traces") ?? "",
@@ -1490,8 +1496,11 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
1490
1496
  if (connectionsOf(store, target).find(one => one.id === service.id)?.state !== "open")
1491
1497
  return back(`${projectName(target)} already has ${service.label}.`);
1492
1498
  }
1493
- if (!authenticateApprover(who, body.get("password") ?? "").ok)
1499
+ const provedGeneration = store.accountOf(who.name)?.generation ?? -1;
1500
+ if (!authenticateCredential(who, body.get("password") ?? "").ok)
1494
1501
  return back("Enter your Toolroll password to connect a tool.");
1502
+ if ((store.accountOf(who.name)?.generation ?? -2) !== provedGeneration)
1503
+ return back("Your sign-in changed. Connect again.");
1495
1504
  if (local !== null) {
1496
1505
  const had = projectToolsOf(store, repo).find(one => one.name === local.id);
1497
1506
  if (had !== undefined && localAppOf(had.spec) === null)
@@ -1520,12 +1529,15 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
1520
1529
  const started = await startConnect({ service: service.id, repo: target, by: who.name, origin, kit: also === null ? kit : null, template, readOnly }, options.connectFetch ?? fetch);
1521
1530
  if (!started.ok)
1522
1531
  return back(started.said);
1532
+ const standing = store.accountOf(who.name);
1533
+ if (standing === null || standing.revokedAt !== null || standing.role !== "approver" || standing.generation !== provedGeneration || !store.accountCanAccess(who.name, target))
1534
+ return back("Your sign-in changed. Connect again.");
1523
1535
  for (const [key, visit] of connectVisits)
1524
1536
  if (visit.expires < Date.now())
1525
1537
  connectVisits.delete(key);
1526
1538
  const kitSet = kit === null || also !== null ? null : kitOf(kit);
1527
1539
  const installed = kitSet === null || !kitSet.tools.some(one => one.tool === service.id) ? null : kitInstalled(store, kitSet, target);
1528
- connectVisits.set(started.state, { ...started.visit, generation: store.accountOf(who.name)?.generation ?? -1,
1540
+ connectVisits.set(started.state, { ...started.visit, generation: provedGeneration,
1529
1541
  grant: installed === null ? null : { subagent: installed.mate.id, tool: service.id, repo: target } });
1530
1542
  return goOutside(response, started.go, `Going to ${service.label} to sign in…`, { state: started.state, path: CONNECT_CALLBACK, secure: origin.startsWith("https:") });
1531
1543
  }
@@ -1543,9 +1555,12 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
1543
1555
  }
1544
1556
  const action = body.get("action") ?? "";
1545
1557
  const name = body.get("name") ?? "";
1546
- if (["add-catalog", "add-custom", "import", "secret"].includes(action) && !authenticateApprover(who, body.get("password") ?? "").ok) {
1558
+ const widening = ["add-catalog", "add-custom", "import", "secret"].includes(action);
1559
+ const provedGeneration = store.accountOf(who.name)?.generation ?? -1;
1560
+ if (widening && !authenticateCredential(who, body.get("password") ?? "").ok) {
1547
1561
  return back("problem", "Enter your Toolroll password to change this project's tools.");
1548
1562
  }
1563
+ const stillProved = () => { const account = store.accountOf(who.name); return account !== null && account.revokedAt === null && account.role === "approver" && account.generation === provedGeneration && store.accountCanAccess(who.name, repo); };
1549
1564
  const now = clock();
1550
1565
  const finish = (added, label) => {
1551
1566
  if (!added.ok)
@@ -1582,6 +1597,8 @@ ${restoreHtml(chosen, retired, undoableMerges(store, chosen), disabledLessons(st
1582
1597
  projectConfig = looked.value;
1583
1598
  }
1584
1599
  const found = discoverTools(repo, await codexServers(repo), toolHome, process.env, projectConfig);
1600
+ if (!stillProved())
1601
+ return back("problem", "Your access changed while this was read. Nothing was added.");
1585
1602
  const added = [], problems = [];
1586
1603
  for (const one of wanted) {
1587
1604
  const match = found.find(tool => tool.spec.name === one);
@@ -2136,7 +2153,7 @@ ${postForm("/settings/chat-approval/save", html `\
2136
2153
  if (wanted !== "auto" && wanted !== "bypassPermissions") {
2137
2154
  return refuse(response, who, 400, "permissions must be Auto or Full access", "/settings");
2138
2155
  }
2139
- if (wanted === "bypassPermissions" && store.permissionDefault().mode !== "bypassPermissions" && !authenticateApprover(who, body.get("password") ?? "").ok) {
2156
+ if (wanted === "bypassPermissions" && store.permissionDefault().mode !== "bypassPermissions" && !authenticateCredential(who, body.get("password") ?? "").ok) {
2140
2157
  return redirect(response, `/settings/approval?problem=${encodeURIComponent("Enter your Toolroll password to start new tasks with Full access. Nothing changed.")}#defaults`);
2141
2158
  }
2142
2159
  store.setPermissionDefault(wanted, who.name, now);
@@ -2219,6 +2236,8 @@ ${postForm("/settings/chat-approval/save", html `\
2219
2236
  ? `the ${provider} key is removed — ${provider} uses its own login, so builds are unaffected`
2220
2237
  : `the ${provider} key is removed — an environment variable, if one exists, takes over`)}#providers`);
2221
2238
  }
2239
+ if (!authenticateCredential(who, body.get("password") ?? "").ok)
2240
+ return redirect(response, `/settings/agents?problem=${encodeURIComponent("Enter your Toolroll password to save a key. Nothing changed.")}#providers`);
2222
2241
  const wantedMode = body.get("auth-mode");
2223
2242
  const value = (body.get("value") ?? "").trim();
2224
2243
  const modeSelected = wantedMode === "subscription" || wantedMode === "api-key";
@@ -2250,6 +2269,8 @@ ${postForm("/settings/chat-approval/save", html `\
2250
2269
  if (options.telegramTokenFile === undefined)
2251
2270
  return refuse(response, who, 404, "There's no page at this address.", "/chat");
2252
2271
  const body = readForm(posted, CONSOLE_FORMS.telegramToken);
2272
+ if (!authenticateCredential(who, body.get("password") ?? "").ok)
2273
+ return redirect(response, `/settings/alerts?problem=${encodeURIComponent("Enter your Toolroll password to save the bot token. Nothing changed.")}#telegram-token`);
2253
2274
  const value = body.get("token") ?? "";
2254
2275
  const saved = saveBotToken(options.telegramTokenFile, value);
2255
2276
  if (!saved.ok)
@@ -2263,6 +2284,8 @@ ${postForm("/settings/chat-approval/save", html `\
2263
2284
  const body = readForm(posted, CONSOLE_FORMS.email);
2264
2285
  const said = (words, key = "said") => redirect(response, `/settings/alerts?${key}=${encodeURIComponent(words)}#email`);
2265
2286
  if (op === "save") {
2287
+ if (!authenticateCredential(who, body.get("token") ?? "").ok)
2288
+ return said("Enter your Toolroll password to save email. Nothing changed.", "problem");
2266
2289
  const saved = saveEmailSettings(options.configDir, { host: body.get("host"), port: body.get("port"), secure: body.get("secure"), user: body.get("user"), from: body.get("from"), password: body.get("password"), imapHost: body.get("imapHost"), imapPort: body.get("imapPort") });
2267
2290
  return saved.ok ? said(saved.said) : said(saved.message, "problem");
2268
2291
  }
@@ -2290,6 +2313,8 @@ ${postForm("/settings/chat-approval/save", html `\
2290
2313
  await disconnectGoogle(options.configDir, options.googleFetch ?? fetch);
2291
2314
  return said("Google disconnected. Email goes through the mail server again, if one is set up.");
2292
2315
  }
2316
+ if (!authenticateCredential(who, body.get("password") ?? "").ok)
2317
+ return redirect(response, `/settings/alerts?problem=${encodeURIComponent("Enter your Toolroll password to connect Google. Nothing changed.")}#email`);
2293
2318
  const saved = saveGoogleClient(options.configDir, { clientId: body.get("clientId"), clientSecret: body.get("clientSecret") });
2294
2319
  if (!saved.ok)
2295
2320
  return said(saved.message);
@@ -2609,6 +2634,7 @@ ${postForm("/settings/chat-approval/save", html `\
2609
2634
  "settings.passwordless": passwordlessPage,
2610
2635
  "settings.passwordless-send": passwordlessSave,
2611
2636
  "settings.local-mode-off": localModeOff,
2637
+ "settings.just-me": justMe,
2612
2638
  "settings.release-approval-send": releaseApprovalSave,
2613
2639
  "settings.project-flexible": projectFlexible,
2614
2640
  "settings.lead": leadPage,
@@ -2674,6 +2700,7 @@ ${postForm("/settings/chat-approval/save", html `\
2674
2700
  "settings.models-watch": modelsAct("watch"),
2675
2701
  "settings.models-update": modelsAct("update"),
2676
2702
  "settings.models-agent": modelsSave,
2703
+ "engine.models": modelsRead,
2677
2704
  "settings.models-apply": modelsApply,
2678
2705
  "settings.models-act": modelsAct("other"),
2679
2706
  "settings.models-accept": modelsRuleAct("accept"),
@@ -2856,6 +2883,31 @@ ${postForm("/settings/chat-approval/save", html `\
2856
2883
  const done = count === 0 ? "Nothing changed." : `${what}: ${count} change${count === 1 ? "" : "s"} saved for tasks filed from now on.`;
2857
2884
  return { key: "said", words: result.unresolved === null ? done : `${done} Some roles have no model yet, so new tasks can't be filed here.` };
2858
2885
  }
2886
+ async function modelsRead(ctx) {
2887
+ const { who, response, now } = ctx;
2888
+ if (who.via !== "cookie")
2889
+ return respond(response, 403, "application/json", JSON.stringify({ error: "session" }));
2890
+ const operator = store.isInstanceOperator(who.name) && !store.isDemo();
2891
+ const canChange = operator && (who.authority === "full" || soloNow(store));
2892
+ const view = modelsView(canChange, who.session.csrf, now, null, null);
2893
+ const keys = ["plan", "build", "review"];
2894
+ const roles = keys.map(key => {
2895
+ const role = view.roles.find(one => one.key === key);
2896
+ return { key, label: role.label, current: role.current, words: role.words,
2897
+ choices: role.groups.map(group => ({ provider: group.provider, label: group.label, models: group.options.map(option => ({ value: option.value, label: option.label })) })) };
2898
+ });
2899
+ const build = rowAt(store, INSTALLATION_SCOPE, { phase: "build", tier: "routine" });
2900
+ const presets = ["claude", "codex"].map(agent => ({
2901
+ agent, name: agent === "claude" ? "Claude Code" : "Codex", words: AGENT_PRESETS[agent].words,
2902
+ fields: Object.fromEntries(SLOTS.map(slot => { const model = AGENT_PRESETS[agent].rows[slotKey(slot)]; return [slotKey(slot), model === null || model === undefined ? "clear" : `${agent}|${model}`]; })),
2903
+ }));
2904
+ const checked = checkScope(store, null);
2905
+ response.setHeader("cache-control", "no-store");
2906
+ return respond(response, 200, "application/json", JSON.stringify(checkEngineResponse("models", {
2907
+ version: ENGINE_API_VERSION, canChange, digest: stateDigest(store, INSTALLATION_SCOPE), problem: checked.kind === "ok" ? null : browserWords(checked.problem),
2908
+ roles, defaultAgent: build?.provider ?? null, presets,
2909
+ })));
2910
+ }
2859
2911
  async function modelsSave(ctx) {
2860
2912
  const { response, now, posted } = ctx;
2861
2913
  const who = browserCaller(ctx.who);
@@ -2933,6 +2985,27 @@ ${postForm("/settings/chat-approval/save", html `\
2933
2985
  return back("problem", turned.reason === "not-on" ? "Local mode is already off." : "Only an instance operator can turn off local mode.");
2934
2986
  return done("said", "Local mode is off. This computer's browser signs in with your password now.");
2935
2987
  }
2988
+ async function justMe(ctx) {
2989
+ const { response, now, posted } = ctx;
2990
+ const who = browserCaller(ctx.who);
2991
+ const body = readForm(posted, CONSOLE_FORMS.justMe);
2992
+ const done = sayTo(response, "/settings/general?section=install-mode");
2993
+ const back = sayTo(response, "/settings/change/just-me");
2994
+ if (body.sent.getAll("password").length > 1)
2995
+ return back("problem", "That form was sent twice over. Nothing changed.");
2996
+ if (who.authority !== "full")
2997
+ return back("problem", "Sign in with your password to do this.");
2998
+ const said = store.transact(() => {
2999
+ if (!authenticateCredential(who, body.get("password") ?? "").ok)
3000
+ return null;
3001
+ return declareJustMe(store, who.name, now);
3002
+ });
3003
+ if (said === null)
3004
+ return back("problem", "Enter your Toolroll password to say it's just you.");
3005
+ if (!said.ok)
3006
+ return back("problem", said.reason === "already-solo" ? "This install is already solo." : said.reason === "not-owner" ? "Only an instance operator can say this." : said.facts.map(fact => TEAM_FACT_WORDS[fact]).join(" "));
3007
+ return done("said", "This install is solo now.");
3008
+ }
2936
3009
  function suggestedView(repo, projects, asked, now) {
2937
3010
  const repos = repo === null ? projects : [repo];
2938
3011
  const offers = repos.flatMap(one => suggestionsFor(store, one, now));
@@ -3087,8 +3160,9 @@ ${postForm("/settings/chat-approval/save", html `\
3087
3160
  updatesVersion: name => settingsUpdates(name, "")?.current ?? null,
3088
3161
  packageVersion: PACKAGE_VERSION,
3089
3162
  firstResult: now => { const at = store.firstSuccessAt(now), since = store.installationStartedAt(); return at === null || since === null ? null : firstResultWords(since, at); },
3090
- passwordless: () => passwordlessSetting(store).on,
3163
+ passwordless: () => sessionStandsIn(store),
3091
3164
  localModeOn: () => localModeOf(store)?.enabled === true,
3165
+ installMode: () => installModeNow(store),
3092
3166
  });
3093
3167
  const computersDeps = {
3094
3168
  computers: (now, manage) => computersOf(store, now, visible, manage),
@@ -58,10 +58,11 @@ import { buildReviewOf } from "../review-switch.js";
58
58
  import { isAlive as runnerAlive } from "../runner.js";
59
59
  import { approvalOf } from "../scope.js";
60
60
  import { oneLineOf, refuse, screen, withScript } from "./chrome.js";
61
- import { chatResultHref, reviewHref, taskChatHref, taskHref } from "./http.js";
61
+ import { chatResultHref, refusedInPlace, reviewHref, taskChatHref, taskHref } from "./http.js";
62
62
  import { decisionsFor } from "./render-chat.js";
63
63
  import {} from "./render-pages.js";
64
64
  import { completionReceiptView, diffFileAnchor, evidenceLinksFor, followUpsFor, orderChangedFiles, parseReviewDiff, proofBundleView, receiptStatusOf, withinSignedTouches } from "./render-results.js";
65
+ import { approvalSummaryOf, summaryContextOf } from "../approval-summary.js";
65
66
  import { approvalFormDigest, consentDoorOf, nonceHashOf, publicationFactsOf, resumeCeremonyPage, resumeDigestOf, taskBody, taskPage } from "./render-tasks.js";
66
67
  import {} from "./session.js";
67
68
  import { mergeReadyViewOf } from "./merge-ready-view.js";
@@ -241,8 +242,9 @@ export function createTaskViews(runtime) {
241
242
  const revision = revisionViewOf(ref);
242
243
  const revisionBroken = revision !== null && "problem" in revision;
243
244
  const planView = ref === null ? null : planViewOf(ref.id);
244
- const approvalDigest = scope === null ? null : approvalFormDigest(scope.digest, planView?.sha256 ?? null);
245
245
  const routeView = routeViewOf(taskId, ref, scope, now, who);
246
+ const approvalSummary = scope === null ? null : approvalSummaryOf(scope, summaryContextOf(runtime.store, taskId, scope, now, routeView?.evidence ?? null));
247
+ const approvalDigest = scope === null ? null : approvalFormDigest(scope.digest, planView?.sha256 ?? null, approvalSummary?.key ?? null);
246
248
  const nonce = who.via === "cookie" && scope !== null && approvalDigest !== null && !approvalOf(scope).approved && !revisionBroken && ref?.plan !== "requested" && consentDoorOf(scope, routeView).open
247
249
  ? render.mintNonce === false ? "unminted" : runtime.mintApprovalNonce(who.name, taskId, approvalDigest)
248
250
  : "";
@@ -406,6 +408,7 @@ export function createTaskViews(runtime) {
406
408
  mirror: runtime.store.mirrorByTask(taskId),
407
409
  scope,
408
410
  approvalDigest,
411
+ approvalSummary,
409
412
  route: routeView,
410
413
  canEditRoute: who.role === "approver",
411
414
  resultRecord: resultRecordWordsOf(runtime.store, taskId, runtime.evidenceRoot, now),
@@ -547,6 +550,7 @@ export function createTaskViews(runtime) {
547
550
  scope,
548
551
  nonce: view.nonce,
549
552
  digest: view.approvalDigest ?? scope.digest,
553
+ summary: view.approvalSummary ?? null,
550
554
  planDocument: view.planDocument,
551
555
  planContract: view.planContract ?? null,
552
556
  deliverable: view.deliverable ?? "branch",
@@ -691,6 +695,8 @@ export function createTaskViews(runtime) {
691
695
  };
692
696
  }
693
697
  function taskScreen(response, who, taskId, problem, status, scopeDraft, cancelDraft, editPlan = false, extras = {}) {
698
+ if (problem !== null && refusedInPlace(response, status, problem))
699
+ return;
694
700
  const admittedFamily = runtime.familyOf(taskId);
695
701
  if (admittedFamily?.problem != null)
696
702
  return runtime.sendScreen(response, status, screen(admittedFamily.root.title, html `<h1>${admittedFamily.root.title}</h1><p>${admittedFamily.current.state}</p><p class="problem" data-history-problem>${admittedFamily.problem}</p>${extras.result == null ? "" : html `<section class="task-result-tab" id="task-result" aria-label="Result" data-result-task="${extras.result.selected.taskId}">${extras.result.html}</section>`}`, { chrome: runtime.chromeFor(admittedFamily.root.repo, "tasks"), ...(extras.result == null ? {} : { functional: { script: `${reviewEvidenceScript()}${RESULT_REVIEW_SCRIPT}` } }) }));
@@ -67,6 +67,7 @@ import { structuredHandoffView, terminalDiffView } from "../result-evidence-read
67
67
  import { fileAddTestsTask, requestFollowUpChecks } from '../result-follow-ups.js';
68
68
  import { commentSourceKey, isRevisionFeedback, parseResultTab, resultReturnTarget } from "../result-review.js";
69
69
  import { isAlive as runnerAlive } from "../runner.js";
70
+ import { soloNow } from "../install-mode.js";
70
71
  import { passwordlessSessionFor, acceptanceLinesToInput, acceptanceToLines, approvalOf, approve as approveScope, freshnessFor, freshlyApprovable, localApprovalEligible, spendingOnlyOnSuccess, ssoNowAvailable, withFreshness, modeFilingCoverage, PLACEHOLDER_RUBRIC, proposeGuarded } from "../scope.js";
71
72
  import { subagentNames as subagentNamesOf } from "../spend.js";
72
73
  import { verifiedAuthor } from "../store.js";
@@ -80,20 +81,23 @@ import { buildProgressOf, parseWorkView } from "../workspace-ui.js";
80
81
  import { requestContext } from "./request-context.js";
81
82
  import { boardTickScript, oneLineOf, QUEUE_VIEW, refuse, regionScript, screen, transcriptScript, whenTime } from "./chrome.js";
82
83
  import { retiredHandler, retiredRedirect, TASK_VIEW_REDIRECTS } from "./retired-routes.js";
83
- import { answersInPlace, chatReturnWithSaid, matchTaskPath, redirect, respond, reviewHref, safeChatReturn, safeReturn, SAFETY, taskChatHref, taskHref } from "./http.js";
84
+ import { answersInPlace, refusedInPlace, chatReturnWithSaid, matchTaskPath, redirect, respond, reviewHref, safeChatReturn, safeReturn, SAFETY, taskChatHref, taskHref } from "./http.js";
84
85
  import { taskLinkOf } from "../task-link.js";
85
86
  import { putAwayPage, boardBody, boardWorkers, QUEUE_FRONT, queueBody, queueScript, TASK_STATES, workPage } from "./render-pages.js";
86
87
  import { runEfficiencyOf } from "../run-efficiency.js";
87
88
  import { timingFor } from "../latency-timeline.js";
88
89
  import { ACCEPT_ANYWAY_NEEDS_REASON, editorFileHref, proofBundleView, rankReviewQueue, RESULT_REFUSALS, REVIEW_QUEUE_CAP, reviewCockpitDetailParts, reviewCockpitPage, reviewPriorityOf, runFactsFragment, runOutcomeBadge, withRefusal } from "./render-results.js";
90
+ import { approvalSummaryFor } from "../approval-summary.js";
89
91
  import { approvalFormDigest, approveRefusalWords, checkProgressHtml, consentDoorOf, nonceHashOf, PermissionsWouldChange, requirementsFromEditor, resumeDigestOf, taskOf } from "./render-tasks.js";
90
92
  import {} from "./session.js";
91
93
  import { approveReleaseCard, releaseApprovalCard, releaseSheetHref, releaseTaskOf } from "../release-approval.js";
92
94
  import { releaseSheetPage } from "./render-release.js";
93
95
  import { approvalFactsNow } from "./kit.js";
94
96
  import { localOwnerRefusal } from "../local-owner.js";
97
+ import { firstTaskRouted } from "../welcome-facts.js";
98
+ export const FIRST_TASK_DETECT_WAIT_MS = 8_000;
95
99
  export function createTasksHandlers(runtime) {
96
- const { identities, store, peekSay, peekCache, PEEK_CACHE_TTL_MS, peekInFlight, PEEK_GLOBAL_INFLIGHT, peekBySession, PEEK_SESSION_INFLIGHT, clock, peekName, PEEK_FRAGMENT_BYTES, peekEvict, evidenceRoot, sendScreen, chromeFor, visible, consumeApprovalNonce, authenticateApprover, options, mintApprovalNonce, taskScreen, unscopedMode, admissionList, planViewOf, revisionViewOf, runIsTaskResult, leadPrincipal, familyOf, armTaskResume, runIsLive, revisionLedgerOf, resultDetailOf, reviewFactsFor, taskRepoOf, runVisible, restricted, codingActorAllowed, codingProjectAllowed, managedRepos, routeViewOf, workAccess, firstRunStepsNow, revisionDocOf, failureOf, dockedConversation, planContractViewOf, familiesInView, explainAttempt, taskChatFocus, familyTasksInView, liveCeiling, projectOf, ceiling, bustBadge, revisionDestination } = runtime;
100
+ const { identities, store, peekSay, peekCache, PEEK_CACHE_TTL_MS, peekInFlight, PEEK_GLOBAL_INFLIGHT, peekBySession, PEEK_SESSION_INFLIGHT, clock, peekName, PEEK_FRAGMENT_BYTES, peekEvict, evidenceRoot, sendScreen, chromeFor, visible, consumeApprovalNonce, authenticateApprover, authenticateCredential, options, mintApprovalNonce, taskScreen, unscopedMode, admissionList, planViewOf, revisionViewOf, runIsTaskResult, leadPrincipal, familyOf, armTaskResume, runIsLive, revisionLedgerOf, resultDetailOf, reviewFactsFor, taskRepoOf, runVisible, restricted, codingActorAllowed, codingProjectAllowed, managedRepos, routeViewOf, workAccess, firstRunStepsNow, revisionDocOf, failureOf, dockedConversation, planContractViewOf, familiesInView, explainAttempt, taskChatFocus, familyTasksInView, liveCeiling, projectOf, ceiling, bustBadge, revisionDestination } = runtime;
97
101
  function noPage(who, response) {
98
102
  return refuse(response, who, 404, "There's no page at this address.", "/chat");
99
103
  }
@@ -651,7 +655,7 @@ export function createTasksHandlers(runtime) {
651
655
  const decision = body.get('decision');
652
656
  if (decision !== 'accept' && decision !== 'decline' && decision !== 'cancel')
653
657
  return fail(400, 'Choose an explicit decision for this request.');
654
- if (pending.kind !== 'questions' && decision === 'accept' && !authenticateApprover(who, body.get('password') ?? '').ok)
658
+ if (pending.kind !== 'questions' && decision === 'accept' && !authenticateCredential(who, body.get('password') ?? '').ok)
655
659
  return fail(403, 'Enter your password to approve this additional access.');
656
660
  const answers = body.has('answers') ? JSON.parse(body.get('answers')) : Object.fromEntries(pending.questions.map(q => [q.id, { answers: [body.get(`question:${q.id}`) ?? ''] }]));
657
661
  runtime.coding.answer(id, actor, token, decision, answers);
@@ -747,7 +751,12 @@ export function createTasksHandlers(runtime) {
747
751
  }
748
752
  if (who.via === "cookie" && body.get("plain") !== "1" && repo !== "" && goal === "" && notThis === "" && touchesGiven.length === 0 && !scout && id === "" && after === ""
749
753
  && (qualityMode === null || qualityMode === "default") && (permissionMode === null || permissionMode === "auto")) {
750
- const fast = await prepareFastStart(store, { actor: who.name, repo, title: typed.trim(), via: "console", ...(permissionMode === null ? {} : { permissionMode }), password: fastPasswordFacts(who) }, now);
754
+ if (firstTaskRouted(store) === null)
755
+ await runtime.localAgentsSettled(FIRST_TASK_DETECT_WAIT_MS);
756
+ const fast = await prepareFastStart(store, { actor: who.name, repo, title: typed.trim(), via: "console", ...(permissionMode === null ? {} : { permissionMode }), password: fastPasswordFacts(who),
757
+ planFirst: body.get("plan-first") === "1" }, now);
758
+ if (fast.eligible && requestContext.getStore()?.terminalAct === true)
759
+ return answerTermsInPlace(response, { preview: fast.preview, digest: fast.digest, terms: fastTermsRows(store, fast.scope, repo) });
751
760
  if (fast.eligible)
752
761
  return sendScreen(response, 200, fastStartPage(chromeFor(project ?? null, "tasks"), { title: typed.trim(), repo, preview: fast.preview, digest: fast.digest, terms: fastTermsRows(store, fast.scope, repo) }));
753
762
  }
@@ -1981,8 +1990,11 @@ export function createTasksHandlers(runtime) {
1981
1990
  const scopeRow = store.getScope(taskId);
1982
1991
  if (scopeRow === null)
1983
1992
  return approvalProblem("refused", "this task has no scope to approve", 409);
1984
- const planView = planViewOf(ref.id);
1985
- const expectedDigest = approvalFormDigest(scopeRow.digest, planView?.sha256 ?? null);
1993
+ const formDigestNow = () => {
1994
+ const live = store.getScope(taskId);
1995
+ return live === null ? null : approvalFormDigest(live.digest, planViewOf(ref.id)?.sha256 ?? null, approvalSummaryFor(store, taskId, now)?.key ?? null);
1996
+ };
1997
+ const expectedDigest = formDigestNow();
1986
1998
  if (digest !== expectedDigest) {
1987
1999
  return approvalProblem("refused", "the scope or plan changed while this form was open — read the latest version and approve again", 409);
1988
2000
  }
@@ -1992,7 +2004,7 @@ export function createTasksHandlers(runtime) {
1992
2004
  return approvalProblem("refused", `approval is blocked: ${view.problem}`, 409);
1993
2005
  }
1994
2006
  }
1995
- const approved = spendingOnlyOnSuccess(() => withFreshness("approve-standard", () => approveScope(store, taskId, who.name, now, scopeRow.digest, token)), result => !result.ok && !(result.reason === "second-approver" && !result.already));
2007
+ const approved = spendingOnlyOnSuccess(() => withFreshness("approve-standard", () => store.transact(() => formDigestNow() !== digest ? { ok: false, reason: "changed" } : approveScope(store, taskId, who.name, now, scopeRow.digest, token))), result => !result.ok && !(result.reason === "second-approver" && !result.already));
1996
2008
  if (!approved.ok) {
1997
2009
  if (approved.reason === "second-approver")
1998
2010
  return approvalProblem("vote", gateWords({ verdict: "vote", have: approved.have, need: 2, already: approved.already }), 200);
@@ -2590,6 +2602,8 @@ export function createTasksHandlers(runtime) {
2590
2602
  });
2591
2603
  function newTaskScreen(ctx, status, problem, draft, text = null) {
2592
2604
  const { who, response, project } = ctx;
2605
+ if (problem !== null && refusedInPlace(response, status, problem))
2606
+ return;
2593
2607
  const chainable = store
2594
2608
  .listTasksScoped(project, undefined, 100, null)
2595
2609
  .filter(one => one.state !== "done" && one.state !== "cancelled" && visible(one.repo))
@@ -2602,7 +2616,7 @@ export function createTasksHandlers(runtime) {
2602
2616
  const startsOn = draft?.values?.get("repo") ?? project ?? chrome.projects?.[0]?.path ?? null;
2603
2617
  const found = startsOn === null ? null : runtime.firstTasks.get(startsOn)?.found ?? null;
2604
2618
  const ideas = found ?? (runtime.firstRunStepsNow(ctx.now) !== null && !store.hasAnyWork() ? firstTaskSuggestions({ issues: [], todos: [] }) : []);
2605
- return sendScreen(response, status, newTaskPage(chrome, project, revision, problem, chainable, store.permissionDefault().mode, store.qualityDefault().mode, chrome.projects ?? [], draft, text, ideas, ctx.url.searchParams.get("from")?.slice(0, 300) ?? null));
2619
+ return sendScreen(response, status, newTaskPage(chrome, project, revision, problem, chainable, store.permissionDefault().mode, store.qualityDefault().mode, chrome.projects ?? [], draft, text, ideas, ctx.url.searchParams.get("from")?.slice(0, 300) ?? null, soloNow(store)));
2606
2620
  }
2607
2621
  function fastPasswordFacts(who) {
2608
2622
  return { passwordless: passwordlessSessionFor(store, who.name), localOwner: who.via === "cookie" && who.authority === "local-owner",
@@ -2898,3 +2912,6 @@ export function withContext(context, typed) {
2898
2912
  return [(context ?? "").trim(), typed.trim()].filter(one => one !== "").join("\n\n");
2899
2913
  }
2900
2914
  export const YOU_SAID_CAP = 8;
2915
+ export function answerTermsInPlace(response, offer) {
2916
+ respond(response, 200, "application/json; charset=utf-8", JSON.stringify({ outcome: "terms", preview: offer.preview, digest: offer.digest, terms: offer.terms.map(([label, words]) => ({ label, words })) }));
2917
+ }