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
@@ -3,7 +3,7 @@ import { btn, stepRows } from "./kit.js";
3
3
  import { whenUtc } from "../when-html.js";
4
4
  import { networkWords } from "../egress.js";
5
5
  import { wasInterrupted } from "../run-ending.js";
6
- import { chainTermsLines, liveChainFromJson, releaseAsksAgainWords, releaseCheckSentence, releaseTermsSentence } from "../scope.js";
6
+ import { liveChainFromJson, releaseAsksAgainWords, releaseCheckSentence, releaseTermsSentence } from "../scope.js";
7
7
  import { SUBSCRIPTION_CAPABLE } from "../keys.js";
8
8
  import { RELEASE_CI_RUNNING_WORDS } from "../release-ci-hold.js";
9
9
  import { writesWords } from "../writes-mode.js";
@@ -15,6 +15,7 @@ import { closedQuestionReason, closedQuestionWords } from "../decision.js";
15
15
  import {} from "../activity-line.js";
16
16
  import {} from "../agentconfig.js";
17
17
  import { gateWords } from "../approval-policy.js";
18
+ import { approvalSummaryOf, EVIDENCE_WORDS, REPAIR_BRIEF, revisionWords } from "../approval-summary.js";
18
19
  import { assignmentCardOf, assignmentStatusOf, assignmentSummaryHtml } from "../assignment-ui.js";
19
20
  import {} from "../assignment.js";
20
21
  import { holdOwnerWords } from "../board.js";
@@ -31,7 +32,7 @@ import {} from "../gaps.js";
31
32
  import { readAuthModeStrict } from "../keys.js";
32
33
  import { failedAttemptSentence, retryNoteOf, START_BUILDER_COMMAND, startBuilderHref, STORAGE_HOLD_PREFIX } from "../needs-you.js";
33
34
  import { planVersionWords } from "../plain-words.js";
34
- import { chosenWords, makesNoPlan, PHASES as ROUTE_PHASES, TASK_SIZES } from "../phase-routing.js";
35
+ import { chosenWords, PHASES as ROUTE_PHASES, TASK_SIZES } from "../phase-routing.js";
35
36
  import { parseExecutionPlanDocument } from "../plan.js";
36
37
  import {} from "../planner-source.js";
37
38
  import { projectName } from "../project.js";
@@ -222,8 +223,9 @@ export function approvalSheetHtml(input) {
222
223
  ]);
223
224
  }
224
225
  export function approvalSheetParts(input) {
225
- const { scope, route } = input;
226
- const repairText = / — (repair exactly the unmet criteria named below; a comment cannot widen the scope\. Unmet: ([^.]+)\.|Collect only the missing observations for ([^.]+)\. .*|Diagnose the saved failed project check and repair within the original scope\. .*)$/s.exec(scope.goal);
226
+ const { scope } = input;
227
+ const repairText = REPAIR_BRIEF.exec(scope.goal);
228
+ const summary = input.summary ?? approvalSummaryOf(scope);
227
229
  const goalShown = repairText === null ? scope.goal : scope.goal.slice(0, repairText.index);
228
230
  const statementsOf = (ids) => ids.split(",").map(id => id.trim()).map(id => scope.acceptance.find(one => one.id === id)?.statement ?? id).map(one => one.replace(/[.\s]+$/, "")).join("; ");
229
231
  const repairBuild = input.revision?.sourceRun ?? input.repairChain?.sourceRun ?? null;
@@ -235,58 +237,28 @@ export function approvalSheetParts(input) {
235
237
  : `Fixes the checks that failed in ${builtBy}.`;
236
238
  const plan = input.planDocument === null ? null : parseExecutionPlanDocument(input.planDocument);
237
239
  const milestones = plan !== null && plan.ok ? plan.document.milestones : [];
238
- const permission = permissionWordsOf(scope.profile);
239
240
  const money = (micro) => `$${(micro / 1_000_000).toFixed(2)}`;
240
241
  const row = (label, body) => html `<div class="approval-row"><dt>${label}</dt><dd>${body}</dd></div>`;
241
- const changes = joinHtml([
242
- milestones.length > 0 ? html `<ol class="approval-steps">${milestones.map(one => html `<li>${one}</li>`)}</ol>` : "",
243
- scope.touches.length > 0
244
- ? html `<p>Only in these paths:</p>${approvalPathsHtml(scope.touches)}`
245
- : html `<p${milestones.length > 0 ? html ` class="meta"` : ""}>Any file in the project.</p>`,
246
- ]);
247
242
  const doneWhen = scope.acceptance.length === 0
248
243
  ? html `<p>You decide when you review the result.</p>`
249
- : html `<ul class="approval-done">${scope.acceptance.map(one => html `<li>${one.statement}</li>`)}</ul>`;
250
- const legs = route?.projection?.legs ?? [];
251
- const legOf = (phase) => legs.find(one => one.phase === phase);
252
- const who = [];
253
- const builder = legOf("build");
254
- if (builder !== undefined)
255
- who.push(`Builder ${agentNameWords(builder.provider, builder.model)}`);
256
- else if (route?.legacy != null)
257
- who.push(`Builder ${agentNameWords(route.legacy.provider, route.legacy.model)}`);
258
- else if (scope.profile != null)
259
- who.push(`Builder ${agentNameWords(scope.profile.provider, scope.profile.model)}`);
260
- const planner = legOf("plan");
261
- const sized = route?.projection?.size ?? null;
262
- const unplanned = route?.projection != null && makesNoPlan(sized, route.projection.risk) && planner?.chosen === "recommended";
263
- if (planner !== undefined && !unplanned)
264
- who.push(`Planner ${agentNameWords(planner.provider, planner.model)}`);
244
+ : html `<ul class="approval-done">${scope.acceptance.map(one => html `<li>${one.statement} <span class="meta">${one.evidence.map(kind => EVIDENCE_SHEET[kind] ?? kind).join(" · ")}</span></li>`)}</ul>`;
265
245
  const allowing = [];
266
246
  const warnings = [];
267
247
  const allowed = permissionPlainWords(scope.profile);
268
248
  if (allowed !== null)
269
249
  allowing.push(allowed);
270
250
  allowing.push(scope.budgetMicrousd === null ? "no attempt limit" : `up to ${money(scope.budgetMicrousd)} per attempt`);
271
- const chain = chainTermsLines(scope);
272
251
  const fallbacks = liveChainFromJson(scope.proposedChainJson ?? null)?.slice(1) ?? [];
273
252
  if (fallbacks.length > 0) {
274
253
  const paid = fallbacks.filter(one => one.authMode === "api-key" || SUBSCRIPTION_CAPABLE[one.profile.provider] !== true);
275
254
  const clause = `if it runs out of its plan, the work moves to ${fallbacks.map(one => `${agentNameWords(one.profile.provider, one.profile.model)}${paid.includes(one) ? " on an API key, which spends money" : ""}`).join(", then ")}`;
276
255
  allowing.push(clause);
277
- if (paid.length > 0)
278
- warnings.push(clause);
279
256
  }
280
257
  const earlier = earlierVersionsWords(input.earlier.active, input.earlier.running);
281
258
  if (earlier !== null) {
282
259
  allowing.push(earlier);
283
260
  warnings.push(earlier);
284
261
  }
285
- const yoursToCheck = scope.acceptance.filter(one => one.evidence.includes("manual-review")).map(one => one.statement.trim().replace(/[.\s]+$/, ""));
286
- const consent = joinHtml([
287
- allowing.length === 0 ? "" : html `<p class="approval-allowing" data-approval-allowing>You’re allowing: ${allowing.join(" · ")}</p>`,
288
- yoursToCheck.length === 0 ? "" : html `<p class="approval-you-check" data-approval-you-check>You’ll check: ${yoursToCheck.join("; ")}</p>`,
289
- ]);
290
262
  const rebuild = input.rebuild ?? null;
291
263
  const after = rebuild !== null
292
264
  ? html `Build #${rebuild} was made to the earlier plan. Approving builds it again to this one.`
@@ -295,14 +267,15 @@ export function approvalSheetParts(input) {
295
267
  : html `An agent starts in its own branch. You'll hear when it's ready to review.`;
296
268
  const submit = rebuild !== null ? html `Approve and retry` : html `Approve`;
297
269
  const detail = (title, body, attrs = html ``) => isEmptyHtml(body) ? html `` : html `<section class="approval-detail"${attrs}><h3>${title}</h3>${body}</section>`;
298
- const revisionBody = input.revision === null ? html `` : joinHtml([
270
+ const revisionBodyOf = (sentenceToo) => input.revision === null ? html `` : joinHtml([
299
271
  html `<div class="revision-card" data-revision-feedback>`,
300
272
  html `<p><a href="${input.revisionSourceHref}"${input.surface === "chat" ? html ` data-revision-source` : ""}>${input.surface === "chat" ? html `Original result: build #${input.revision.sourceRun} →` : html `build #${input.revision.sourceRun}`}</a></p>`,
301
273
  input.revision.comments.length === 0 ? "" : html `<ul>${input.revision.comments.map(one => html `<li>${revisionImageLink(one.image)}${one.path === null ? "" : html `<span class="mono">${one.path}${one.line === null ? "" : `:${one.line}`}</span> · `}${one.note} <span class="meta">— ${one.author}</span></li>`)}</ul>`,
302
- revisionLineageHtml(input.revision.lineage),
274
+ !sentenceToo || summary.revision === null ? "" : html `<p data-revision-plain>${summary.revision}</p>`,
303
275
  html `</div>`,
304
276
  ]);
305
- const revisionDetail = input.revision === null ? "" : detail("Earlier build", revisionBody);
277
+ const revisionBody = revisionBodyOf(true);
278
+ const revisionDetail = input.revision === null ? "" : detail("Earlier build", revisionBodyOf(false));
306
279
  const contract = input.planContract;
307
280
  const amendment = approvalAmendmentHtml(contract);
308
281
  const contractDetail = input.planDocument === null || !isEmptyHtml(amendment) ? html ``
@@ -312,32 +285,12 @@ export function approvalSheetParts(input) {
312
285
  : html `<p class="meta">${contract.revision === true ? "Same terms as the previous version." : "The plan keeps exactly what you filed."} <a href="/r/${contract.run}">Planner's record</a></p>`;
313
286
  const criteriaDetail = scope.acceptance.length === 0 ? html ``
314
287
  : html `<ul class="approval-signed-criteria">${scope.acceptance.map(one => html `<li><code>${one.id}</code> ${one.statement} <span class="meta">shown by ${one.evidence.map(kind => EVIDENCE_PLAIN[kind] ?? kind).join(", ")}</span></li>`)}</ul>`;
315
- const projection = route?.projection ?? null;
316
- const agentsDetail = route === null || route === undefined ? html ``
317
- : projection === null
318
- ? route.legacy === null ? html `` : html `<p>${agentsSummaryWords(route)}</p>`
319
- : joinHtml([
320
- html `<p>${projection.summary}</p>`,
321
- html `<p class="meta">Uses ${projection.postureWords}.</p>`,
322
- projection.demands.length === 0 ? "" : html `<ul class="meta">${projection.demands.map(one => html `<li>${one}</li>`)}</ul>`,
323
- html `<dl class="approval-roles">${projection.legs.map(leg => html `<div><dt>${ROLE_NOUN[leg.phase]}</dt><dd><span class="mono">${leg.provider} · ${leg.model}</span> <span class="meta">${chosenWords(leg)}</span><ul>${leg.reasons.map(reason => html `<li>${reason}</li>`)}${leg.problem === null ? "" : html `<li><strong>${leg.problem}</strong></li>`}</ul></dd></div>`)}</dl>`,
324
- html `<p class="meta">These exact agents are part of what you approve. Changing any of them asks for a fresh approval.</p>`,
325
- ]);
326
- const limits = joinHtml([
327
- profileWords(scope),
328
- html `<p class="meta">Checks level: ${qualityModeTitle(scope.qualityMode ?? "default")}${permission === null ? "" : ` · ${permission}`}</p>`,
329
- scope.budgetMicrousd === null ? "" : html `<p class="meta">Each build attempt has a ${money(scope.budgetMicrousd)} agent-reported usage cap. On a subscription this limits work; it is not an API charge.</p>`,
330
- ]);
331
288
  const details = joinHtml([
332
289
  html `<details class="approval-details"${input.surface === "task" ? html ` open` : ""}><summary>Plan details</summary>`,
333
290
  revisionDetail,
334
- repairText === null ? "" : detail("Full goal", html `<p>${scope.goal}</p>`),
335
291
  detail("Plan record", contractDetail),
336
292
  detail("Requirements", criteriaDetail),
337
- detail("Why these agents", agentsDetail, html ` id="${input.surface === "task" ? "approval-agents" : "chat-approval-agents"}"`),
338
- detail("Runtime limits", limits),
339
- scope.candidate ? detail("Saved commit", html `<p><code class="approval-commit">${scope.candidate}</code></p>`) : "",
340
- detail("Plan version", html `<p class="meta">Approving agrees to exactly this plan. <span class="seal mono" title="${planVersionWords(scope.digest)}">${planVersionWords(scope.digest)}</span></p>`),
293
+ detail("Plan version", html `<p class="meta"><span class="seal mono" title="${planVersionWords(scope.digest)}">${planVersionWords(scope.digest)}</span></p>`),
341
294
  html `</details>`,
342
295
  ]);
343
296
  const passwordNote = input.surface === "task" ? "approval-password-note" : "chat-approval-password-note";
@@ -386,26 +339,30 @@ export function approvalSheetParts(input) {
386
339
  input.deliverable === "report" ? html `<p class="approval-note">Read-only: it reports back and changes nothing in the repository.</p>` : "",
387
340
  originNote(input.origin) === null ? "" : html `<p class="approval-note" data-approval-origin>${originNote(input.origin)}</p>`,
388
341
  ]);
389
- const releaseBody = scope.releaseTerms == null && scope.releaseCheck == null ? "" : joinHtml([
390
- scope.releaseTerms == null ? "" : html `<p>${releaseTermsSentence(scope.releaseTerms)}</p>`,
391
- scope.releaseCheck == null ? "" : html `<p>${releaseCheckSentence(scope.releaseCheck)}</p>`,
342
+ const releaseRows = summary.decisions.filter(one => one.fields.includes("releaseTerms") || one.fields.includes("releaseCheck"));
343
+ const releaseBody = releaseRows.length === 0 ? "" : joinHtml([
344
+ ...releaseRows.map(one => html `<p>${one.words}</p>`),
392
345
  input.releaseCiRunning === true ? html `<p class="meta">${RELEASE_CI_RUNNING_WORDS}</p>` : "",
393
- scope.releaseTerms?.policy.carry !== true ? "" : html `<p class="plan-sheet-sub">What asks again</p><ul class="plan-sheet-list">${releaseAsksAgainWords(scope.releaseTerms).map(line => html `<li>${line}</li>`)}</ul>`,
346
+ ...releaseRows.map(one => (one.lines ?? []).length === 0 ? "" : one.fields.includes("releaseTerms") && scope.releaseTerms?.policy.carry === true
347
+ ? html `<p class="plan-sheet-sub">What asks again</p><ul class="plan-sheet-list">${one.lines.map(line => html `<li>${line}</li>`)}</ul>`
348
+ : html `${one.lines.map(line => html `<p>${line}</p>`)}`),
394
349
  ]);
350
+ const termRow = (one) => one.label === "Done when" ? row("Done when", doneWhen)
351
+ : one.fields.includes("touches") && scope.touches.length > 0 ? row(one.label, html `<p>Only ${joinHtml(scope.touches.map(path => html `<code class="approval-path">${path}</code>`), ", ")}</p>`)
352
+ : row(one.label, html `<p>${one.words}</p>${(one.lines ?? []).length === 0 ? "" : html `<ul>${one.lines.map(line => html `<li>${line}</li>`)}</ul>`}`);
395
353
  const rows = joinHtml([
396
- html `<dl class="approval-rows">`,
397
- row("Goal", html `<p class="approval-goal">${goalShown}</p>`),
398
- row("Changes", changes),
399
- row("Won’t touch", html `<p>${scope.outOfScope === null ? "Nothing is ruled out." : scope.outOfScope}</p>`),
400
- row("Done when", doneWhen),
354
+ summary.revision === null ? "" : html `<p class="approval-revision-plain" data-terms-revision>${summary.revision}</p>`,
355
+ summary.revisionChanges.length === 0 ? "" : html `<dl class="approval-rows" data-terms-revision-changes>${summary.revisionChanges.map(termRow)}</dl>`,
356
+ summaryWarningsHtml(summary),
357
+ html `<dl class="approval-rows" data-terms-summary>`,
358
+ ...summary.decisions.filter(one => !one.fields.includes("releaseTerms") && !one.fields.includes("releaseCheck")).map(one => one.label === "Goal" ? row("Goal", html `<p class="approval-goal">${one.words}</p>`) : termRow(one)),
359
+ milestones.length === 0 ? "" : row("Steps", html `<ol class="approval-steps">${milestones.map(one => html `<li>${one}</li>`)}</ol>`),
401
360
  releaseBody === "" ? "" : html `<div class="approval-row" data-approval-release><dt>Release</dt><dd>${releaseBody}</dd></div>`,
402
- chain.length === 0 ? "" : row("If it runs out", html `<p>${chain[0]}</p><ol class="approval-steps" data-approval-fallback>${chain.slice(1).map(one => html `<li>${one.replace(/^\d+\. /, "")}</li>`)}</ol>`),
361
+ ...summary.differs.map(termRow),
362
+ summary.why === null ? "" : row("Why this model", html `<p>${summary.why}</p>`),
403
363
  html `</dl>`,
404
364
  amendment,
405
- projection === null ? "" : sizeLineHtml(projection),
406
- who.length === 0 ? "" : html `<p class="approval-who">${who.join(" · ")}</p>`,
407
- routeEvidenceHtml(route, "approval-evidence"),
408
- consent,
365
+ summaryUsualHtml(summary),
409
366
  ]);
410
367
  const parsedPlan = plan !== null && plan.ok ? plan.document : null;
411
368
  const approach = parsedPlan?.approach.trim() ?? "";
@@ -421,45 +378,86 @@ export function approvalSheetParts(input) {
421
378
  extraProof.length === 0 ? "" : html `<ul class="plan-sheet-done plan-sheet-proof">${extraProof.map(line => html `<li><span>${line}</span><span class="plan-sheet-how">From the plan</span></li>`)}</ul>`,
422
379
  ]);
423
380
  const reportNote = input.deliverable === "report" ? html `<p class="approval-note">Read-only: it reports back and changes nothing in the repository.</p>` : "";
424
- const notAllowingWarnings = allowing.filter(one => !warnings.includes(one));
381
+ const revisionTail = "";
382
+ const fixes = (text) => /^[A-Z][a-z]/.test(text) ? `${text.charAt(0).toLowerCase()}${text.slice(1)}` : text;
383
+ const revisionLead = (() => {
384
+ const tail = revisionTail === "" ? "" : ` ${revisionTail}`;
385
+ if (sentence !== null) {
386
+ const missed = /^Fixes what (.+?) missed: ([\s\S]*)$/.exec(sentence);
387
+ if (missed !== null)
388
+ return `Revises ${missed[1]}: fixes ${fixes(missed[2])}${tail}`;
389
+ const checks = /^Fixes the checks that failed in (.+)\.$/.exec(sentence);
390
+ if (checks !== null)
391
+ return `Revises ${checks[1]}: fixes the checks that failed.${tail}`;
392
+ const shows = /^Shows what (.+?) couldn't show for: ([\s\S]*)$/.exec(sentence);
393
+ if (shows !== null)
394
+ return `Revises ${shows[1]}: shows what it couldn't show for: ${shows[2]}${tail}`;
395
+ const back = /^Sends back (.+)\.$/.exec(sentence);
396
+ if (back !== null)
397
+ return `Revises ${back[1]}.${tail}`;
398
+ return `${sentence}${tail}`;
399
+ }
400
+ return summary.revision === null ? null : summary.revision.replace(/^This revises ([^.]+\.).*$/s, "Revises $1");
401
+ })();
402
+ const revising = revisionLead !== null;
403
+ const briefText = repairText === null ? null : scope.goal.slice(repairText.index).replace(/^\s*—\s*/, "");
404
+ const briefShown = briefText === null ? null : briefText.replace(/\b(c\d+)\b/g, id => {
405
+ const named = scope.acceptance.find(one => one.id === id);
406
+ return named === undefined ? id : `${id} (“${named.statement.replace(/[.\s]+$/, "")}”)`;
407
+ });
408
+ const goalBody = joinHtml([
409
+ goalShown.trim() === sheetLead && !revising ? "" : html `<p class="approval-goal">${goalShown}</p>`,
410
+ briefShown === null ? "" : html `<p class="approval-goal plan-sheet-brief" data-plan-brief>${briefShown}</p>`,
411
+ ], " ");
412
+ const comments = input.revision === null || input.revision.comments.length === 0 ? "" : revisionBodyOf(false);
413
+ const leadHtml = joinHtml([
414
+ html `<p class="${sheetLead.length > 180 ? "plan-sheet-lead plan-sheet-lead-long" : "plan-sheet-lead"}">${sheetLead}</p>`,
415
+ approachRest === "" ? "" : html `<p class="plan-sheet-text">${approachRest}</p>`,
416
+ ]);
417
+ const unparsedHtml = plan !== null && !plan.ok
418
+ ? html `<section class="plan-sheet-part" data-plan-unparsed><p class="plan-sheet-sub">This plan couldn’t be read as steps, so it is shown as written.</p><pre class="recap plan-doc">${input.planDocument ?? ""}</pre></section>` : html ``;
419
+ const stepsHtml = milestones.length === 0 ? html `` : part("Steps", html `<ol class="plan-sheet-steps">${milestones.map(one => html `<li><span>${one}</span></li>`)}</ol>`);
420
+ const riskyRows = [...summary.decisions.filter(one => one.risky === true && !one.fields.includes("releaseTerms") && !one.fields.includes("releaseCheck")), ...summary.differs];
421
+ const contractNote = contract === null || contract === undefined || "problem" in contract || !contract.filed && contract.revision !== true ? contractDetail : html ``;
422
+ const before = joinHtml([
423
+ amendment,
424
+ summaryWarningsHtml(summary),
425
+ ...summary.revisionNotes.filter(one => summary.revisionChanges.length === 0 || !/ from that build: /.test(one)).map(one => html `<p data-plan-revision-note>${one}</p>`),
426
+ summary.revisionChanges.length === 0 ? "" : html `<dl class="approval-rows" data-plan-revision-changes>${summary.revisionChanges.map(termRow)}</dl>`,
427
+ ...warnings.map(one => html `<p class="plan-sheet-warn" data-plan-warning>${one.charAt(0).toUpperCase()}${one.slice(1)}.</p>`),
428
+ riskyRows.length === 0 ? "" : html `<dl class="approval-rows" data-terms-risky>${riskyRows.map(termRow)}</dl>`,
429
+ (parsedPlan?.risks.length ?? 0) === 0 ? "" : html `<ul class="plan-sheet-list">${parsedPlan.risks.map(one => html `<li>${one}</li>`)}</ul>`,
430
+ (parsedPlan?.dependencies.length ?? 0) === 0 ? "" : html `<p class="plan-sheet-sub">Depends on</p><ul class="plan-sheet-list">${parsedPlan.dependencies.map(one => html `<li>${one}</li>`)}</ul>`,
431
+ input.planDocument === null || !isEmptyHtml(amendment) ? "" : contractNote,
432
+ ]);
433
+ const record = contract !== null && contract !== undefined && !("problem" in contract) && (contract.filed || contract.revision === true) && isEmptyHtml(amendment)
434
+ ? html ` · <a href="/r/${contract.run}">Planner’s record</a>` : html ``;
425
435
  const sheet = joinHtml([
426
436
  html `<article class="plan-sheet" data-plan-sheet aria-label="${input.deliverable === "report" ? "The investigation" : "The plan"}">`,
427
- sentence === null ? "" : html `<p class="approval-revision">${sentence}</p>`,
428
437
  input.coordinator === null ? "" : html `<p class="approval-note">An agent filed this: <span class="mono">${input.coordinator.label}</span>${input.coordinator.filedAgo === null ? "" : html `, ${input.coordinator.filedAgo}`}. Nothing runs until you approve, and approving runs its request.</p>`,
429
438
  reportNote,
430
439
  originNote(input.origin) === null ? "" : html `<p class="approval-note" data-plan-origin>${originNote(input.origin)}</p>`,
431
- html `<p class="${sheetLead.length > 180 ? "plan-sheet-lead plan-sheet-lead-long" : "plan-sheet-lead"}">${sheetLead}</p>`,
432
- approachRest === "" ? "" : html `<p class="plan-sheet-text">${approachRest}</p>`,
433
- plan !== null && !plan.ok ? html `<pre class="recap plan-doc">${input.planDocument ?? ""}</pre>` : "",
434
- goalShown.trim() === sheetLead ? "" : part("Goal", html `<p class="approval-goal">${goalShown}</p>`),
435
- repairText === null ? "" : part("Full goal", html `<p>${scope.goal}</p>`),
436
- input.revision === null ? "" : part("Asked for changes", revisionBody),
440
+ html `<section class="plan-group" data-plan-group="plan">`,
441
+ revisionLead === null ? "" : html `<p class="approval-revision plan-sheet-revision" data-plan-revision>${revisionLead}</p>`,
442
+ revising ? "" : leadHtml,
443
+ unparsedHtml,
444
+ part("Goal", goalBody),
445
+ comments === "" ? "" : part("Asked for changes", comments),
437
446
  releaseBody === "" ? "" : part("Release", releaseBody, html ` data-plan-release`),
438
- milestones.length === 0 ? "" : part("Steps", html `<ol class="plan-sheet-steps">${milestones.map(one => html `<li><span>${one}</span></li>`)}</ol>`),
447
+ revising ? "" : stepsHtml,
439
448
  part("Done when", doneWhenSheet),
440
- html `<div class="plan-sheet-pair">`,
441
- part("Will change", scope.touches.length > 0 ? approvalPathsHtml(scope.touches) : html `<p>Any file in the project.</p>`),
442
- part("Won’t touch", html `<p>${scope.outOfScope === null ? "Nothing is ruled out." : scope.outOfScope}</p>`),
443
- html `</div>`,
444
- part("Worth knowing", joinHtml([
445
- amendment,
446
- ...warnings.map(one => html `<p class="plan-sheet-warn" data-plan-warning>${one.charAt(0).toUpperCase()}${one.slice(1)}.</p>`),
447
- (parsedPlan?.risks.length ?? 0) === 0 ? "" : html `<ul class="plan-sheet-list">${parsedPlan.risks.map(one => html `<li>${one}</li>`)}</ul>`,
448
- (parsedPlan?.dependencies.length ?? 0) === 0 ? "" : html `<p class="plan-sheet-sub">Depends on</p><ul class="plan-sheet-list">${parsedPlan.dependencies.map(one => html `<li>${one}</li>`)}</ul>`,
449
- ])),
450
- part("The agent", joinHtml([
451
- projection === null ? "" : sizeLineHtml(projection),
452
- who.length === 0 ? "" : html `<p class="approval-who">${who.join(" · ")}</p>`,
453
- routeEvidenceHtml(route, "approval-evidence"),
454
- agentsDetail,
455
- limits,
456
- notAllowingWarnings.length === 0 ? "" : html `<p class="approval-allowing" data-plan-allowing>You’re allowing: ${notAllowingWarnings.join(" · ")}</p>`,
457
- yoursToCheck.length === 0 ? "" : html `<p class="approval-you-check" data-plan-you-check>You’ll check: ${yoursToCheck.join("; ")}</p>`,
458
- chain.length === 0 ? "" : html `<p>${chain[0]}</p><ol class="plan-sheet-list" data-plan-fallback>${chain.slice(1).map(one => html `<li>${one.replace(/^\d+\. /, "")}</li>`)}</ol>`,
459
- ])),
460
- part("Plan record", contractDetail),
461
- scope.candidate ? part("Saved commit", html `<p><code class="approval-commit">${scope.candidate}</code></p>`) : "",
462
- part("Plan version", html `<p class="meta">Approving agrees to exactly this plan. <span class="seal mono" title="${planVersionWords(scope.digest)}">${planVersionWords(scope.digest)}</span></p>`),
449
+ revising && parsedPlan !== null && (!isEmptyHtml(leadHtml) || !isEmptyHtml(stepsHtml))
450
+ ? html `<details class="plan-sheet-full" data-plan-full><summary>Full plan</summary>${leadHtml}${stepsHtml}</details>` : "",
451
+ html `</section>`,
452
+ isEmptyHtml(before) ? "" : html `<section class="plan-group plan-group-before" data-plan-group="before"><h3 class="plan-sheet-h">Before you approve</h3><div class="plan-notice">${before}</div></section>`,
453
+ html `<section class="plan-group" data-plan-group="may-do"><h3 class="plan-sheet-h">What it may do</h3>`,
454
+ html `<dl class="approval-rows" data-terms-summary>`,
455
+ ...summary.decisions.filter(one => one.risky !== true && !one.fields.some(field => field === "goal" || field === "acceptance" || field === "releaseTerms" || field === "releaseCheck")).map(termRow),
456
+ summary.why === null ? "" : row("Why this model", html `<p>${summary.why}</p>`),
457
+ html `</dl>`,
458
+ summaryUsualHtml(summary),
459
+ html `<p class="plan-sheet-foot" data-plan-version>Plan version <span class="mono">${scope.digest.slice(0, 8)}</span>${record}</p>`,
460
+ html `</section>`,
463
461
  html `</article>`,
464
462
  ]);
465
463
  return { lead, rows, editor, editorForm, details, submit, label: rebuild !== null ? "Approve and retry" : "Approve", after, allowing, passwordNote, sheet, sheetLead };
@@ -467,7 +465,15 @@ export function approvalSheetParts(input) {
467
465
  export function planSheetHtml(input) {
468
466
  return approvalSheetParts(input).sheet;
469
467
  }
470
- export const EVIDENCE_SHEET = { check: "Runs automatically", screenshot: "Shown in a screenshot", "changed-path": "Seen in the changed files", "manual-review": "You review it" };
468
+ export function summaryWarningsHtml(summary) {
469
+ return joinHtml(summary.warnings.map(one => html `<p class="plan-sheet-warn" data-terms-warning>${one.words}</p>`));
470
+ }
471
+ export function summaryUsualHtml(summary) {
472
+ if (summary.usual.length === 0)
473
+ return html ``;
474
+ return html `<details class="approval-details terms-usual" data-terms-usual><summary>${summary.usualLabel}</summary><dl class="approval-rows">${summary.usual.map(one => html `<div class="approval-row"><dt>${one.label}</dt><dd><p>${one.words}</p></dd></div>`)}</dl></details>`;
475
+ }
476
+ export const EVIDENCE_SHEET = Object.fromEntries(Object.entries(EVIDENCE_WORDS).map(([kind, words]) => [kind, `${words.charAt(0).toUpperCase()}${words.slice(1)}`]));
471
477
  export function earlierVersionsWords(active, running) {
472
478
  if (active <= 0)
473
479
  return null;
@@ -574,7 +580,7 @@ export function profileWords(scope) {
574
580
  ? html `<p class="meta">Runs on <span class="mono">${ACP_AGENTS[profile.provider].name} (via ACP) · ${profile.model}</span> — full access inside Toolroll's sandbox; the agent runs any tool it chooses and nothing asks. No turn limit: stops after ${Math.round(profile.timeoutSeconds / 60)} min, or ${Math.round(profile.idleTimeoutSeconds / 60)} min silent; repairs on ${repair}, ${Math.round(profile.repairTimeoutSeconds / 60)} min, or ${Math.round(profile.repairIdleTimeoutSeconds / 60)} min silent.</p>`
575
581
  : html `<p class="meta">Runs on <span class="mono">${profile.provider} · ${profile.model}</span> — ${profile.sandboxMode === "danger-full-access" ? "FULL permissions via --dangerously-bypass-approvals-and-sandbox; nothing asks" : "workspace-write sandbox"}, no turn limit (${Math.round(profile.timeoutSeconds / 60)} min ${profile.timeoutKind === "idle" ? "without progress" : "per attempt"}); repairs on ${repair}, ${Math.round(profile.repairTimeoutSeconds / 60)} min</p>`;
576
582
  const terms = sandboxTermsWords(profile);
577
- return html `${base}<p class="meta" data-scope-network>${networkWords(profile.network ?? null)}</p><p class="meta" data-scope-writes>Writes: ${writesWords(profile.writes)}.</p>${profile.checkAccess === undefined ? "" : html `<p class="meta" data-scope-checks>Checks: ${checkAccessWords(profile.checkAccess)}.</p>`}<p class="meta" data-scope-reads>Reads: ${terms.reads}.</p>${terms.mach === null ? "" : html `<p class="meta" data-scope-mach>${terms.mach.charAt(0).toUpperCase()}${terms.mach.slice(1)}.</p>`}`;
583
+ return html `${base}<p class="meta" data-scope-network>${networkWords(profile.network ?? null, profile.provider)}</p><p class="meta" data-scope-writes>Writes: ${writesWords(profile.writes)}.</p>${profile.checkAccess === undefined ? "" : html `<p class="meta" data-scope-checks>Checks: ${checkAccessWords(profile.checkAccess)}.</p>`}<p class="meta" data-scope-reads>Reads: ${terms.reads}.</p>${terms.mach === null ? "" : html `<p class="meta" data-scope-mach>${terms.mach.charAt(0).toUpperCase()}${terms.mach.slice(1)}.</p>`}`;
578
584
  }
579
585
  export function routeEvidenceHtml(view, className = "meta") {
580
586
  const words = view?.evidence ?? null;
@@ -792,14 +798,14 @@ export function approveRefusalWords(reason) {
792
798
  return "That password didn't match.";
793
799
  return `not approved: ${reason}`;
794
800
  }
795
- export function approvalFormDigest(scopeDigest, planSha) {
796
- if (planSha === null)
801
+ export function approvalFormDigest(scopeDigest, planSha, termsKey = null) {
802
+ if (planSha === null && termsKey === null)
797
803
  return scopeDigest;
798
804
  return createHash("sha256")
799
805
  .update("standing-orders/browser-approval/v1\0", "utf8")
800
806
  .update(scopeDigest, "utf8")
801
807
  .update("\0", "utf8")
802
- .update("", "utf8")
808
+ .update(termsKey ?? "", "utf8")
803
809
  .update("\0", "utf8")
804
810
  .update(planSha ?? "", "utf8")
805
811
  .digest("hex");
@@ -1116,31 +1122,12 @@ function revisionImageLink(image) {
1116
1122
  return image == null ? html `` : html `<a href="/r/${image.run}/evidence/${image.artifact}">Screenshot ${image.artifact} · result #${image.run}</a> · `;
1117
1123
  }
1118
1124
  export function revisionLineageWords(lineage) {
1119
- const words = [];
1120
- if (lineage.problem !== undefined)
1121
- words.push(`lineage verification gap: ${lineage.problem}; no automatic repair allowance can be inferred`);
1122
- const chain = lineage.ancestors.length > 1 ? ` · lineage ${lineage.ancestors.join(" → ")}` : "";
1123
- words.push(`revises ${lineage.sourceTask}${lineage.sourceRun === null ? "" : ` (build #${lineage.sourceRun})`}${chain}`);
1124
- if (!lineage.sourceHadScope) {
1125
- words.push("the earlier version had no plan, so nothing was copied; the placeholder requirements wait for real ones");
1126
- }
1127
- else if (lineage.terms !== null) {
1128
- const terms = lineage.terms;
1129
- words.push(`inherited terms, as they stand now: ${qualityModeTitle(terms.qualityMode)} quality · ` +
1130
- `${terms.permissionMode === "bypassPermissions" ? "full access" : "auto permissions"} · ` +
1131
- `${terms.budgetMicrousd === null ? "no attempt cap" : `$${(terms.budgetMicrousd / 1_000_000).toFixed(2)} attempt cap`} · ` +
1132
- `${terms.exclusions ? "its exclusions" : "no exclusions"} · ${terms.touches === 0 ? "any path" : `${terms.touches} path limit${terms.touches === 1 ? "" : "s"}`} · ` +
1133
- `${terms.criteria} criteri${terms.criteria === 1 ? "on" : "a"}${terms.routeOverrides === 0 ? "" : ` · ${terms.routeOverrides} agent override${terms.routeOverrides === 1 ? "" : "s"}`}`);
1134
- }
1135
- words.push("re-resolved for this approval: the agents route — a yes on the source never covers it");
1136
- words.push("never inherited: the source's approval, publication and merge grants");
1137
- if (lineage.repair !== null) {
1138
- const repair = lineage.repair;
1139
- words.push(`repair chain rooted at ${repair.rootTask}: ${repair.attemptsUsed} attempt${repair.attemptsUsed === 1 ? "" : "s"} used` +
1140
- `${repair.cap === null ? " — each further attempt needs your yes" : ` of ${repair.cap} automatic · ${repair.remaining} remaining`}` +
1141
- `${repair.thisAttempt === null ? "" : ` · this is attempt ${repair.thisAttempt}`}${repair.via === null ? "" : ` · continued through ${repair.via}`}`);
1142
- }
1143
- return words;
1125
+ const facts = { sourceTask: lineage.sourceTask, sourceRun: lineage.sourceRun, hadPlan: lineage.sourceHadScope, changed: null,
1126
+ problem: lineage.problem ?? null, repair: lineage.repair === null ? null : { cap: lineage.repair.cap, remaining: lineage.repair.remaining } };
1127
+ return [
1128
+ ...(facts.problem === null ? [] : [`Toolroll can’t check what this revises (${facts.problem}), so no fix runs on its own.`]),
1129
+ revisionWords(facts),
1130
+ ];
1144
1131
  }
1145
1132
  export function revisionLineageHtml(lineage) {
1146
1133
  if (lineage === null)
@@ -1188,6 +1175,8 @@ export function taskBodyParts(data) {
1188
1175
  return html `<div class="card attempt-live" data-live-run="${liveRun.id}">${head}${peek}${door}</div>`;
1189
1176
  })();
1190
1177
  const dispatchStatus = (() => {
1178
+ if (data.dispatch?.action === "approve-scope" && (data.nonce ?? "") !== "" && task.state !== "cancelled")
1179
+ return html ``;
1191
1180
  const workToken = resultStatus?.token ?? data.dispatch?.code ?? "unknown";
1192
1181
  const headline = status.label;
1193
1182
  const box = (kind, title, detail, code, controls = "") => html `<div class="${kind === "problem" && !inReview && headline === "Failed" ? "problem" : "answered"} dispatch-status" id="run-status" data-dispatch-status="${code ?? title.toLowerCase().replace(/[^a-z0-9]+/g, "-")}" data-work-status="${workToken}"><div class="dispatch-copy"><strong>${inReview ? "Recorded checks" : title}</strong><span class="meta">${detail}</span></div>${controls}</div>`;
@@ -1465,6 +1454,7 @@ export function taskBodyParts(data) {
1465
1454
  csrf: data.csrf,
1466
1455
  nonce: data.nonce,
1467
1456
  digest: data.approvalDigest ?? scope.digest,
1457
+ summary: data.approvalSummary ?? null,
1468
1458
  freshSince: data.approvalFresh ?? null,
1469
1459
  localOwner: data.approvalLocal ?? null,
1470
1460
  returnTo: null,
@@ -2079,7 +2069,7 @@ export function taskBodyParts(data) {
2079
2069
  ];
2080
2070
  const plannerRun = familyRuns.filter(run => run.role === "planner" && run.outcome !== null).sort((a, b) => b.id - a.id)[0];
2081
2071
  const sheetShown = scope === null ? null : sheetInput ?? {
2082
- surface: "task", action: "", csrf: "", nonce: "", digest: scope.digest, returnTo: null, scope,
2072
+ surface: "task", action: "", csrf: "", nonce: "", digest: scope.digest, returnTo: null, scope, summary: data.approvalSummary ?? null,
2083
2073
  planDocument: data.planDocument ?? null, planContract: data.planContract ?? null,
2084
2074
  revision: data.revision == null || "problem" in data.revision ? null : data.revision,
2085
2075
  revisionSourceHref: data.revision == null || "problem" in data.revision ? "" : `/r/${data.revision.sourceRun}`,
@@ -2194,6 +2184,7 @@ export function taskBodyParts(data) {
2194
2184
  key === here.key && !outcomeFirst ? statusHtml : "",
2195
2185
  key === "plan" ? planCard : "",
2196
2186
  key === "approve" ? (approvalHtml !== "" ? approvalHtml : view.approved == null ? "" : html `<p class="meta">${view.approved.automatic ? `Approved automatically by ${view.approved.rule ?? "a rule"}` : `Approved by ${view.approved.by}`} · ${whenTime(view.approved.at)}</p>`) : "",
2187
+ key === "approve" && !rowFacts.some(row => row.key === "plan") ? planCard : "",
2197
2188
  key === "build" ? joinHtml([controlHtml, progressCard, revisionLedgerCard]) : "",
2198
2189
  key === "ready" && previousResult !== null ? html `<section class="task-previous-result" aria-label="${previousResult.title}">${previousResult.html}</section>` : "",
2199
2190
  ]);
@@ -2305,20 +2296,20 @@ export function approveKitOf(input, freshSince) {
2305
2296
  const parts = approvalSheetParts(input);
2306
2297
  const rebuild = input.rebuild ?? null;
2307
2298
  const after = rebuild !== null ? "builds it again to this plan" : input.deliverable === "report" ? "starts the investigation" : "starts the build";
2308
- const allowing = parts.allowing.length === 0 ? "" : ` You’re allowing ${parts.allowing.join(", ")}.`;
2309
2299
  const until = freshSince === null ? null : freshUntil(freshSince);
2310
2300
  return {
2311
2301
  action: input.action,
2312
2302
  fields: { nonce: input.nonce, digest: input.digest, ...(rebuild === null ? {} : { rebuild: String(rebuild) }) },
2313
2303
  label: parts.label,
2314
2304
  heading: rebuild !== null ? "The plan changed" : input.deliverable === "report" ? "Investigation ready" : "Plan ready",
2315
- text: `Approving ${after}.${allowing}`,
2305
+ text: `Approving ${after}.`,
2316
2306
  kind: "standard",
2317
2307
  facts: { passwordless: passwordlessRendering() || input.localOwner?.eligible === true, remembered: until !== null },
2318
2308
  rememberedUntil: until,
2319
2309
  ...(input.localOwner?.eligible === true ? { termsWords: "No password needed on this computer." } : {}),
2320
2310
  planHtml: htmlString(joinHtml([parts.sheet, parts.editor ?? "", parts.editorForm])),
2321
2311
  sheetHtml: htmlString(parts.sheet),
2312
+ editorHtml: htmlString(joinHtml([parts.editor ?? "", parts.editorForm])),
2322
2313
  };
2323
2314
  }
2324
2315
  export function approvedKitOf(scope, approval, proof) {
@@ -47,6 +47,8 @@ const LOCAL_POSTS = Object.freeze({
47
47
  "task.act.approve": "approve-plan",
48
48
  "task.act.keep-grown": "approve-plan",
49
49
  "decision.answer": "answer-question",
50
+ "agents.live.thread.answer": "answer-question",
51
+ "agents.live.thread.start": "start-thread",
50
52
  "task.act.reply": "answer-question",
51
53
  "task.act.stop": "stop-run",
52
54
  "task.act.cancel": "stop-run",
@@ -61,6 +63,13 @@ const LOCAL_POSTS = Object.freeze({
61
63
  "run.act.revise": "request-revision",
62
64
  "run.act.note": "request-revision",
63
65
  "run.act.comment": "request-revision",
66
+ "term.start": "take-over",
67
+ "term.close": "take-over",
68
+ "term.remove": "take-over",
69
+ "term.agent-sign-in": "agent-sign-in",
70
+ "term.agent-install": "agent-install",
71
+ "engine.agents-check": "check-agents",
72
+ "settings.models-agent": "change-models",
64
73
  "task.act.archive": "archive-task",
65
74
  "task.act.restore": "archive-task",
66
75
  "projects.open": "add-project",
@@ -108,6 +117,7 @@ export const EDGE_LOCAL = Object.freeze({
108
117
  "edge.desktop-health": { local: "allow", why: "public read" },
109
118
  "edge.login-page": { local: "allow", why: "before sign-in" },
110
119
  "edge.login-link": { local: "allow", why: "before sign-in: a one-time link" },
120
+ "edge.login-link-json": { local: "allow", why: "before sign-in: the same one-time local link, redeemed by a terminal client into the same local-owner session (engine-api.ts redeemLink)" },
111
121
  "edge.sso-start": { local: "allow", why: "before sign-in" },
112
122
  "edge.sso-callback": { local: "allow", why: "before sign-in" },
113
123
  "edge.sso-finish": { local: "allow", why: "before sign-in" },
@@ -174,6 +184,7 @@ edge("pages", "edge.font", "GET", "^\\/fonts\\/geist-(sans|mono)-(400|500|600)\\
174
184
  edge("pages", "edge.desktop-health", "GET", "/desktop/health");
175
185
  edge("people", "edge.login-page", "GET", "/login");
176
186
  edge("people", "edge.login-link", "GET", "^\\/login\\/once\\/[^/]+$", { sample: "/login/once/abc" });
187
+ edge("people", "edge.login-link-json", "POST", "/login/once");
177
188
  edge("people", "edge.sso-start", "GET", "/login/sso");
178
189
  edge("people", "edge.sso-callback", "GET", "/login/sso/callback", { callers: ["service"], proof: "adapter" });
179
190
  edge("people", "edge.sso-finish", "GET", "/login/sso/finish");
@@ -208,6 +219,11 @@ get("pages", "projects.project", "^\\/projects\\/[^/]+$", { limited: "unscoped",
208
219
  get("pages", "projects.map", "^\\/projects\\/[^/]+\\/map$", { limited: "unscoped", ...free, sample: "/projects/payments-api/map" });
209
220
  get("pages", "projects.flaky", "^\\/projects\\/[^/]+\\/flaky$", { limited: "unscoped", ...free, sample: "/projects/payments-api/flaky" });
210
221
  get("pages", "home", "/", { limited: "collection", ...free });
222
+ get("pages", "work.rows", "/work/rows", { limited: "collection", ...free });
223
+ get("pages", "engine.hello", "/engine/hello", { limited: "unscoped", ...free });
224
+ get("pages", "engine.agents", "/engine/agents", { limited: "unscoped", callers: ["cookie"], ...free });
225
+ get("settings", "engine.models", "/engine/models", { limited: "unscoped", callers: ["cookie"], ...free });
226
+ post("pages", "engine.agents-check", "/engine/agents/check", { limited: "unscoped", callers: ["cookie"], ...free });
211
227
  get("pages", "search", "/search", { limited: "collection", ...free });
212
228
  const RETIRED = { limited: "collection", ...free, retired: true };
213
229
  get("tasks", "inbox", "/inbox", RETIRED);
@@ -236,6 +252,11 @@ get("pages", "peek", "/peek", free);
236
252
  get("pages", "agents", "/agents", { limited: "unscoped", ...free });
237
253
  get("pages", "agents.live", "/agents/live", { limited: "unscoped", callers: ["cookie"], ...free });
238
254
  get("pages", "agents.live.read", `^\\/agents\\/live\\/${ID}$`, { limited: "unscoped", callers: ["cookie"], ...free, sample: "/agents/live/1" });
255
+ get("pages", "agents.live.run", `^\\/agents\\/live\\/run\\/${ID}$`, { limited: "unscoped", callers: ["cookie"], ...free, sample: "/agents/live/run/1" });
256
+ get("pages", "agents.live.thread", "^\\/agents\\/live\\/thread\\/[0-9a-f]{32}$", { limited: "unscoped", callers: ["cookie"], ...free, sample: `/agents/live/thread/${"a".repeat(32)}` });
257
+ get("pages", "agents.live.threads", "/agents/live/threads", { limited: "unscoped", callers: ["cookie"], ...free });
258
+ post("pages", "agents.live.thread.answer", "^\\/agents\\/live\\/thread\\/[0-9a-f]{32}\\/answer$", { limited: "unscoped", callers: ["cookie"], project: "none", sample: `/agents/live/thread/${"a".repeat(32)}/answer` });
259
+ post("pages", "agents.live.thread.start", "/agents/live/thread", { limited: "unscoped", callers: ["cookie"], project: "none", ...approver("An approver starts threads.") });
239
260
  get("pages", "agents.terminals", "/agents/terminals", TERM);
240
261
  get("pages", "fleet", "/fleet", free);
241
262
  get("tasks", "tasks.new", "/tasks/new", { limited: "collection", ...free });
@@ -243,6 +264,8 @@ get("tasks", "welcome", "/welcome", { limited: "collection", ...free });
243
264
  post("tasks", "welcome.sample", "/welcome/sample", { callers: ["cookie"], project: "none", ...approver("An approver adds projects.", "/welcome") });
244
265
  get("tasks", "task.page", `^\\/t\\/${TASK}$`, { project: "task", limited: "resource", ...free, sample: "/t/one" });
245
266
  get("tasks", "task.evidence", `^\\/t\\/${TASK}\\/evidence$`, { project: "task", limited: "resource", ...free, sample: "/t/one/evidence" });
267
+ get("tasks", "task.steps", `^\\/t\\/${TASK}\\/steps$`, { project: "task", limited: "resource", ...free, sample: "/t/one/steps" });
268
+ get("tasks", "task.diff", `^\\/t\\/${TASK}\\/diff$`, { project: "task", limited: "resource", ...free, sample: "/t/one/diff" });
246
269
  get("tasks", "task.release", `^\\/t\\/${TASK}\\/release$`, { project: "task", limited: "resource", ...free, sample: "/t/one/release" });
247
270
  get("tasks", "release.locate", `^\\/approve\\/${ID}$`, { project: "task-ref", limited: "resource", ...free, sample: "/approve/1" });
248
271
  get("pages", "ledger.export", "/ledger/export", { limited: "unscoped", ...free });
@@ -328,6 +351,8 @@ post("settings", "settings.advanced", "/settings/advanced", { ...free, limited:
328
351
  const CODING_ACT = { scope: "step-up", project: "coding", limited: "self" };
329
352
  post("tasks", "code.start", "/code/start", CODING_ACT);
330
353
  post("tasks", "term.start", "/term/start", { ...TERM, scope: "step-up" });
354
+ for (const one of ["sign-in", "install"])
355
+ post("tasks", `term.agent-${one}`, `/term/agent/${one}`, { ...TERM, scope: "step-up" });
331
356
  for (const one of ["close", "remove"])
332
357
  post("tasks", `term.${one}`, `^\\/term\\/${TERMINAL}\\/${one}$`, { ...TERM, sample: `/term/${"a".repeat(32)}/${one}` });
333
358
  for (const one of ["send", "stop", "resume", "recover", "continue", "ship", "answer"])
@@ -391,6 +416,7 @@ post("tasks", "sweep.cancel-rest", "^\\/sweeps\\/[1-9][0-9]{0,9}\\/cancel-rest$"
391
416
  get("settings", "settings.passwordless", "/settings/passwordless", { ...free, ...operator("An instance operator sets Passwordless.", "/settings") });
392
417
  post("settings", "settings.passwordless-send", "/settings/passwordless", { callers: ["cookie"], ...operator("An instance operator sets Passwordless.", "/settings") });
393
418
  post("settings", "settings.local-mode-off", "/settings/local-mode/off", { callers: ["cookie"], scope: "step-up", ...operator("An instance operator turns off local mode.", "/settings/general?section=local-mode") });
419
+ post("settings", "settings.just-me", "/settings/install-mode/solo", { callers: ["cookie"], scope: "step-up", ...operator("An instance operator says it's just them.", "/settings/general?section=install-mode") });
394
420
  post("settings", "settings.release-approval-send", "/settings/release-approval", { callers: ["cookie"], ...approver("An approver sets how releases are approved.", "/settings/approval") });
395
421
  post("pages", "ledger.checkpoint", "/ledger/checkpoint", operator("An instance operator makes ledger checkpoints.", "/ledger"));
396
422
  const SETTINGS_ACT_ROLES = {
@@ -452,9 +478,12 @@ for (const one of ["confirm", "save", "off"])
452
478
  post("settings", `settings.chat-approval-${one}`, `/settings/chat-approval/${one}`, { limited: "self", callers: ["cookie"], ...(one === "save" ? { scope: "step-up" } : {}), ...approver("An approver turns on approving from their own chat.", "/settings") });
453
479
  post("settings", "settings.telegram-pair", "/settings/telegram/pair", { limited: "self", scope: "step-up", ...approver("An approver can pair their own phone.", "/settings") });
454
480
  post("settings", "settings.telegram-unpair", "/settings/telegram/unpair", { limited: "self", scope: "step-up", ...approver("An approver can pair their own phone.", "/settings") });
455
- for (const one of ["messaging", "permission-default", "quality-default", "notifications", "notifications/mute", "telegram-digest", "provider-key", "provider-key-clear", "telegram-token", "email", "email-test", "email-read-test", "google", "google/disconnect"]) {
481
+ for (const one of ["messaging", "permission-default", "quality-default", "notifications", "notifications/mute", "telegram-digest", "provider-key-clear", "email-test", "email-read-test", "google/disconnect"]) {
456
482
  post("settings", `settings.${one.replaceAll("/", "-")}-send`, `/settings/${one}`);
457
483
  }
484
+ for (const one of ["provider-key", "telegram-token", "email", "google"]) {
485
+ post("settings", `settings.${one}-send`, `/settings/${one}`, { callers: ["cookie"], scope: "step-up" });
486
+ }
458
487
  post("pages", "projects.github-list", "/projects/github", { callers: ["cookie"], ...anyApprover("your login can watch — adding projects is an approver's act") });
459
488
  post("pages", "projects.select", "/projects/select", { project: "form-path", limited: "unscoped", viewer: true });
460
489
  post("pages", "projects.map-refresh", "^\\/projects\\/[^/]+\\/map\\/refresh$", { project: "form", sample: "/projects/payments-api/map/refresh", ...approver("An approver asks for a check of main.", "/projects") });
@@ -14,6 +14,9 @@ export const SETTINGS_SECTIONS = Object.freeze([
14
14
  read: ["password-holder"], scope: { passwordless: ["installation"] }, act: {}, changes: [], opens: false, scripts: [], oldIds: [] },
15
15
  { id: "version", area: "general", title: "Version", pinnedFrom: "settings.group-general", policy: GROUP_PAGE,
16
16
  read: [], scope: { "updates-version": ["installation"], "package-version": ["operator"] }, act: { updates: ["operator"] }, changes: [], opens: false, scripts: [], oldIds: [] },
17
+ { id: "install-mode", area: "general", title: "Solo or team", pinnedFrom: "settings.group-general", policy: GROUP_PAGE,
18
+ read: [], scope: {}, act: { "just-me": ["full-session", "operator"] }, changes: [{ id: "just-me", act: "just-me", proof: "install-solo" }],
19
+ opens: false, scripts: [], oldIds: [] },
17
20
  { id: "advanced", area: "general", title: "Show advanced features", pinnedFrom: "settings.group-advanced", policy: GROUP_PAGE,
18
21
  read: [], scope: { "operator-pages": ["operator"] }, act: { switch: ["cookie-session"] }, changes: [], opens: true, scripts: [], oldIds: ["show-advanced"] },
19
22
  { id: "local-mode", area: "general", title: "Local mode", pinnedFrom: "settings.group-access", policy: GROUP_PAGE,