toolroll 0.9.108 → 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 (187) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/dist/advanced-view.js +0 -1
  3. package/dist/agent-detect.js +244 -0
  4. package/dist/agent-fence.js +47 -5
  5. package/dist/agent-state.js +5 -2
  6. package/dist/agentconfig.js +2 -2
  7. package/dist/approval-summary.js +344 -0
  8. package/dist/assignment-ui.js +5 -5
  9. package/dist/assignment.js +5 -2
  10. package/dist/attest.js +2 -2
  11. package/dist/browser/terminal.js +1 -1
  12. package/dist/browser/workspace.css +2 -2
  13. package/dist/browser/workspace.js +37 -34
  14. package/dist/browser-crew.js +4 -4
  15. package/dist/browser-workspace.js +4 -11
  16. package/dist/builder.js +45 -3
  17. package/dist/chat-actions.js +24 -17
  18. package/dist/chat-controls.js +6 -5
  19. package/dist/chat-core.js +3 -1
  20. package/dist/chat-decide.js +102 -47
  21. package/dist/chat-delivery-state.js +2 -0
  22. package/dist/chat-delivery.js +3 -2
  23. package/dist/chat-live.js +2 -1
  24. package/dist/chat-quiet.js +3 -3
  25. package/dist/chat-task-actions.js +6 -0
  26. package/dist/chat-voice.js +2 -2
  27. package/dist/check-report.js +1 -1
  28. package/dist/cli-help.js +12 -13
  29. package/dist/cli.js +6 -3
  30. package/dist/console-chrome.js +10 -3
  31. package/dist/console-instance.js +10 -1
  32. package/dist/contracts/console-api.js +14 -8
  33. package/dist/contracts/engine-api.js +271 -0
  34. package/dist/contracts/handoff.js +4 -0
  35. package/dist/coordinator.js +2 -2
  36. package/dist/decision.js +17 -0
  37. package/dist/demo-chat.js +1 -1
  38. package/dist/demo.js +6 -0
  39. package/dist/design/kit.js +4 -3
  40. package/dist/discord-api.js +4 -3
  41. package/dist/discord-chat.js +3 -1
  42. package/dist/dispatch.js +3 -8
  43. package/dist/easy-start-args.js +7 -3
  44. package/dist/easy-start.js +25 -0
  45. package/dist/egress.js +72 -10
  46. package/dist/engine-handoff.js +34 -0
  47. package/dist/engine-reads.js +261 -0
  48. package/dist/eval-world.js +3 -2
  49. package/dist/evidence.js +2 -0
  50. package/dist/fast-start.js +55 -14
  51. package/dist/fast-terms.js +2 -2
  52. package/dist/first-run.js +10 -2
  53. package/dist/flexible-agents.js +234 -0
  54. package/dist/flexible-answers-schema.js +61 -0
  55. package/dist/flexible-answers.js +889 -0
  56. package/dist/flexible-available.js +1 -0
  57. package/dist/flexible-custody.js +494 -0
  58. package/dist/flexible-import.js +782 -0
  59. package/dist/flexible-launch-schema.js +72 -0
  60. package/dist/flexible-launch.js +331 -0
  61. package/dist/flexible-launcher.js +88 -0
  62. package/dist/flexible-levels.js +34 -0
  63. package/dist/flexible-merge-guard.js +47 -0
  64. package/dist/flexible-refs.js +47 -0
  65. package/dist/flexible-relay-cancel.js +19 -0
  66. package/dist/flexible-relay-schema.js +55 -0
  67. package/dist/flexible-relay-upstreams.js +36 -0
  68. package/dist/flexible-relay.js +1032 -0
  69. package/dist/flexible-schema.js +32 -0
  70. package/dist/flexible-session.js +732 -0
  71. package/dist/flexible-ship-schema.js +81 -0
  72. package/dist/flexible-ship.js +694 -0
  73. package/dist/flexible-start.js +80 -0
  74. package/dist/flexible-thread-schema.js +30 -0
  75. package/dist/flexible-thread.js +676 -0
  76. package/dist/flexible-turns-schema.js +69 -0
  77. package/dist/flexible-turns.js +490 -0
  78. package/dist/flexible-ui.js +44 -0
  79. package/dist/flexible.js +368 -0
  80. package/dist/flow-actions.js +6 -4
  81. package/dist/flow-steps.js +1 -1
  82. package/dist/flows-cli.js +2 -1
  83. package/dist/git-views.js +44 -41
  84. package/dist/guides.js +11 -10
  85. package/dist/install-mode.js +225 -0
  86. package/dist/keymap.js +1 -1
  87. package/dist/lead-context.js +1 -1
  88. package/dist/lead-doors.js +7 -1
  89. package/dist/limits-ui.js +8 -1
  90. package/dist/live-bus.js +70 -13
  91. package/dist/live-reply.js +6 -0
  92. package/dist/live-terminal.js +425 -29
  93. package/dist/local-owner.js +6 -0
  94. package/dist/model-choices.js +12 -6
  95. package/dist/needs-you.js +3 -3
  96. package/dist/nightly-github.js +2 -2
  97. package/dist/notification-delivery.js +11 -0
  98. package/dist/operate.js +185 -33
  99. package/dist/outbound-privacy.js +204 -0
  100. package/dist/passwordless.js +2 -1
  101. package/dist/project-delete-ui.js +2 -1
  102. package/dist/project-delete.js +15 -0
  103. package/dist/provider-auth.js +1 -1
  104. package/dist/provider-connection.js +5 -3
  105. package/dist/publish.js +5 -0
  106. package/dist/pull-request-flow.js +26 -7
  107. package/dist/push.js +5 -1
  108. package/dist/release-card.js +11 -3
  109. package/dist/release.js +11 -1
  110. package/dist/result-actions.js +3 -0
  111. package/dist/result-evidence-readers.js +8 -2
  112. package/dist/result-review.js +20 -9
  113. package/dist/route-store.js +2 -2
  114. package/dist/sandbox-launch.js +32 -8
  115. package/dist/sandbox-runtime.js +16 -7
  116. package/dist/sandbox-tools.js +176 -0
  117. package/dist/scope.js +12 -36
  118. package/dist/scout-net.js +7 -2
  119. package/dist/serve.js +90 -40
  120. package/dist/server/chat.js +9 -9
  121. package/dist/server/chrome.js +19 -17
  122. package/dist/server/console.css +33 -6
  123. package/dist/server/engine-api.js +378 -0
  124. package/dist/server/flows.js +2 -2
  125. package/dist/server/guards.js +10 -4
  126. package/dist/server/home.js +37 -5
  127. package/dist/server/http.js +11 -2
  128. package/dist/server/in-place.js +5 -4
  129. package/dist/server/kit.js +2 -2
  130. package/dist/server/link-redemption.js +52 -0
  131. package/dist/server/live.js +100 -10
  132. package/dist/server/mutation-key.js +21 -7
  133. package/dist/server/pages.js +129 -74
  134. package/dist/server/people-tokens.js +17 -41
  135. package/dist/server/render-chat.js +2 -1
  136. package/dist/server/render-history.js +18 -4
  137. package/dist/server/render-new-task.js +4 -4
  138. package/dist/server/render-pages.js +21 -39
  139. package/dist/server/render-people.js +2 -2
  140. package/dist/server/render-projects.js +5 -5
  141. package/dist/server/render-results.js +30 -14
  142. package/dist/server/render-tasks.js +155 -155
  143. package/dist/server/retired-routes.js +37 -4
  144. package/dist/server/route-policy.js +8 -0
  145. package/dist/server/route-table.js +43 -5
  146. package/dist/server/settings-computers.js +140 -0
  147. package/dist/server/settings-scripts.js +15 -0
  148. package/dist/server/settings-section-table.js +59 -0
  149. package/dist/server/settings-sections.js +291 -0
  150. package/dist/server/settings.js +247 -28
  151. package/dist/server/task-views.js +55 -15
  152. package/dist/server/tasks.js +168 -98
  153. package/dist/server/terminals.js +181 -28
  154. package/dist/server/welcome.js +40 -14
  155. package/dist/settings-groups-ui.js +26 -107
  156. package/dist/settings-proofs.js +18 -11
  157. package/dist/slack-api.js +4 -3
  158. package/dist/slack-chat.js +5 -3
  159. package/dist/spend.js +46 -12
  160. package/dist/sqlite-telemetry.js +70 -21
  161. package/dist/status-probe.js +343 -0
  162. package/dist/store.js +206 -10
  163. package/dist/task-link.js +64 -0
  164. package/dist/teams-api.js +4 -3
  165. package/dist/teams-chat.js +4 -2
  166. package/dist/telegram-lead.js +2 -1
  167. package/dist/telegram-live.js +2 -1
  168. package/dist/telegram-team.js +2 -1
  169. package/dist/telegram.js +17 -5
  170. package/dist/trusted-path.js +162 -0
  171. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  172. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  173. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  174. package/dist/tui/linux-x64/toolroll-tui +0 -0
  175. package/dist/tui-launch.js +282 -0
  176. package/dist/tui-source.js +5 -3
  177. package/dist/tui.js +2 -2
  178. package/dist/typed-words-schema.js +18 -0
  179. package/dist/webhooks.js +8 -4
  180. package/dist/welcome-facts.js +25 -17
  181. package/dist/work-index.js +126 -29
  182. package/dist/work-reads.js +279 -0
  183. package/dist/workspace-ui.js +5 -0
  184. package/package.json +4 -2
  185. package/scripts/crash-canary.mjs +1 -1
  186. package/scripts/pilot.mjs +1 -1
  187. 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";
@@ -52,6 +53,7 @@ import { TEXT_LIMITS } from "../text-limits.js";
52
53
  import { isOverdue, oneLineOf, projectChip, regionScript, safePrUrl, screen, SENSITIVE_INPUT, sentenceCase, shortDigest, whenTime } from "./chrome.js";
53
54
  import { steerDestinationWords, steerStandingParts } from "../steer-status.js";
54
55
  import { reviewHref, taskChatHref, taskHref } from "./http.js";
56
+ import { taskLinkFromLegacy, taskLinkOf } from "../task-link.js";
55
57
  import { coordinatorProposalsSection } from "./render-chat.js";
56
58
  import { completionReceiptCard, criterionMatrixHtml, evidenceWords, homePhaseWords, incidentWords, pullRequestCardHtml, reasonWords, receiptStatusOf, repairChainHtml, reportItemsHtml, reviewRetryPanel, runNoun, runOutcomeBadge, semanticCoverageHtml, verificationExplanation, verificationRecovered } from "./render-results.js";
57
59
  import {} from "./session.js";
@@ -221,8 +223,9 @@ export function approvalSheetHtml(input) {
221
223
  ]);
222
224
  }
223
225
  export function approvalSheetParts(input) {
224
- const { scope, route } = input;
225
- 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);
226
229
  const goalShown = repairText === null ? scope.goal : scope.goal.slice(0, repairText.index);
227
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("; ");
228
231
  const repairBuild = input.revision?.sourceRun ?? input.repairChain?.sourceRun ?? null;
@@ -234,58 +237,28 @@ export function approvalSheetParts(input) {
234
237
  : `Fixes the checks that failed in ${builtBy}.`;
235
238
  const plan = input.planDocument === null ? null : parseExecutionPlanDocument(input.planDocument);
236
239
  const milestones = plan !== null && plan.ok ? plan.document.milestones : [];
237
- const permission = permissionWordsOf(scope.profile);
238
240
  const money = (micro) => `$${(micro / 1_000_000).toFixed(2)}`;
239
241
  const row = (label, body) => html `<div class="approval-row"><dt>${label}</dt><dd>${body}</dd></div>`;
240
- const changes = joinHtml([
241
- milestones.length > 0 ? html `<ol class="approval-steps">${milestones.map(one => html `<li>${one}</li>`)}</ol>` : "",
242
- scope.touches.length > 0
243
- ? html `<p>Only in these paths:</p>${approvalPathsHtml(scope.touches)}`
244
- : html `<p${milestones.length > 0 ? html ` class="meta"` : ""}>Any file in the project.</p>`,
245
- ]);
246
242
  const doneWhen = scope.acceptance.length === 0
247
243
  ? html `<p>You decide when you review the result.</p>`
248
- : html `<ul class="approval-done">${scope.acceptance.map(one => html `<li>${one.statement}</li>`)}</ul>`;
249
- const legs = route?.projection?.legs ?? [];
250
- const legOf = (phase) => legs.find(one => one.phase === phase);
251
- const who = [];
252
- const builder = legOf("build");
253
- if (builder !== undefined)
254
- who.push(`Builder ${agentNameWords(builder.provider, builder.model)}`);
255
- else if (route?.legacy != null)
256
- who.push(`Builder ${agentNameWords(route.legacy.provider, route.legacy.model)}`);
257
- else if (scope.profile != null)
258
- who.push(`Builder ${agentNameWords(scope.profile.provider, scope.profile.model)}`);
259
- const planner = legOf("plan");
260
- const sized = route?.projection?.size ?? null;
261
- const unplanned = route?.projection != null && makesNoPlan(sized, route.projection.risk) && planner?.chosen === "recommended";
262
- if (planner !== undefined && !unplanned)
263
- 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>`;
264
245
  const allowing = [];
265
246
  const warnings = [];
266
247
  const allowed = permissionPlainWords(scope.profile);
267
248
  if (allowed !== null)
268
249
  allowing.push(allowed);
269
250
  allowing.push(scope.budgetMicrousd === null ? "no attempt limit" : `up to ${money(scope.budgetMicrousd)} per attempt`);
270
- const chain = chainTermsLines(scope);
271
251
  const fallbacks = liveChainFromJson(scope.proposedChainJson ?? null)?.slice(1) ?? [];
272
252
  if (fallbacks.length > 0) {
273
253
  const paid = fallbacks.filter(one => one.authMode === "api-key" || SUBSCRIPTION_CAPABLE[one.profile.provider] !== true);
274
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 ")}`;
275
255
  allowing.push(clause);
276
- if (paid.length > 0)
277
- warnings.push(clause);
278
256
  }
279
257
  const earlier = earlierVersionsWords(input.earlier.active, input.earlier.running);
280
258
  if (earlier !== null) {
281
259
  allowing.push(earlier);
282
260
  warnings.push(earlier);
283
261
  }
284
- const yoursToCheck = scope.acceptance.filter(one => one.evidence.includes("manual-review")).map(one => one.statement.trim().replace(/[.\s]+$/, ""));
285
- const consent = joinHtml([
286
- allowing.length === 0 ? "" : html `<p class="approval-allowing" data-approval-allowing>You’re allowing: ${allowing.join(" · ")}</p>`,
287
- yoursToCheck.length === 0 ? "" : html `<p class="approval-you-check" data-approval-you-check>You’ll check: ${yoursToCheck.join("; ")}</p>`,
288
- ]);
289
262
  const rebuild = input.rebuild ?? null;
290
263
  const after = rebuild !== null
291
264
  ? html `Build #${rebuild} was made to the earlier plan. Approving builds it again to this one.`
@@ -294,14 +267,15 @@ export function approvalSheetParts(input) {
294
267
  : html `An agent starts in its own branch. You'll hear when it's ready to review.`;
295
268
  const submit = rebuild !== null ? html `Approve and retry` : html `Approve`;
296
269
  const detail = (title, body, attrs = html ``) => isEmptyHtml(body) ? html `` : html `<section class="approval-detail"${attrs}><h3>${title}</h3>${body}</section>`;
297
- const revisionBody = input.revision === null ? html `` : joinHtml([
270
+ const revisionBodyOf = (sentenceToo) => input.revision === null ? html `` : joinHtml([
298
271
  html `<div class="revision-card" data-revision-feedback>`,
299
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>`,
300
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>`,
301
- revisionLineageHtml(input.revision.lineage),
274
+ !sentenceToo || summary.revision === null ? "" : html `<p data-revision-plain>${summary.revision}</p>`,
302
275
  html `</div>`,
303
276
  ]);
304
- 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));
305
279
  const contract = input.planContract;
306
280
  const amendment = approvalAmendmentHtml(contract);
307
281
  const contractDetail = input.planDocument === null || !isEmptyHtml(amendment) ? html ``
@@ -311,32 +285,12 @@ export function approvalSheetParts(input) {
311
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>`;
312
286
  const criteriaDetail = scope.acceptance.length === 0 ? html ``
313
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>`;
314
- const projection = route?.projection ?? null;
315
- const agentsDetail = route === null || route === undefined ? html ``
316
- : projection === null
317
- ? route.legacy === null ? html `` : html `<p>${agentsSummaryWords(route)}</p>`
318
- : joinHtml([
319
- html `<p>${projection.summary}</p>`,
320
- html `<p class="meta">Uses ${projection.postureWords}.</p>`,
321
- projection.demands.length === 0 ? "" : html `<ul class="meta">${projection.demands.map(one => html `<li>${one}</li>`)}</ul>`,
322
- 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>`,
323
- html `<p class="meta">These exact agents are part of what you approve. Changing any of them asks for a fresh approval.</p>`,
324
- ]);
325
- const limits = joinHtml([
326
- profileWords(scope),
327
- html `<p class="meta">Checks level: ${qualityModeTitle(scope.qualityMode ?? "default")}${permission === null ? "" : ` · ${permission}`}</p>`,
328
- 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>`,
329
- ]);
330
288
  const details = joinHtml([
331
289
  html `<details class="approval-details"${input.surface === "task" ? html ` open` : ""}><summary>Plan details</summary>`,
332
290
  revisionDetail,
333
- repairText === null ? "" : detail("Full goal", html `<p>${scope.goal}</p>`),
334
291
  detail("Plan record", contractDetail),
335
292
  detail("Requirements", criteriaDetail),
336
- detail("Why these agents", agentsDetail, html ` id="${input.surface === "task" ? "approval-agents" : "chat-approval-agents"}"`),
337
- detail("Runtime limits", limits),
338
- scope.candidate ? detail("Saved commit", html `<p><code class="approval-commit">${scope.candidate}</code></p>`) : "",
339
- 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>`),
340
294
  html `</details>`,
341
295
  ]);
342
296
  const passwordNote = input.surface === "task" ? "approval-password-note" : "chat-approval-password-note";
@@ -385,26 +339,30 @@ export function approvalSheetParts(input) {
385
339
  input.deliverable === "report" ? html `<p class="approval-note">Read-only: it reports back and changes nothing in the repository.</p>` : "",
386
340
  originNote(input.origin) === null ? "" : html `<p class="approval-note" data-approval-origin>${originNote(input.origin)}</p>`,
387
341
  ]);
388
- const releaseBody = scope.releaseTerms == null && scope.releaseCheck == null ? "" : joinHtml([
389
- scope.releaseTerms == null ? "" : html `<p>${releaseTermsSentence(scope.releaseTerms)}</p>`,
390
- 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>`),
391
345
  input.releaseCiRunning === true ? html `<p class="meta">${RELEASE_CI_RUNNING_WORDS}</p>` : "",
392
- 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>`)}`),
393
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>`}`);
394
353
  const rows = joinHtml([
395
- html `<dl class="approval-rows">`,
396
- row("Goal", html `<p class="approval-goal">${goalShown}</p>`),
397
- row("Changes", changes),
398
- row("Won’t touch", html `<p>${scope.outOfScope === null ? "Nothing is ruled out." : scope.outOfScope}</p>`),
399
- 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>`),
400
360
  releaseBody === "" ? "" : html `<div class="approval-row" data-approval-release><dt>Release</dt><dd>${releaseBody}</dd></div>`,
401
- 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>`),
402
363
  html `</dl>`,
403
364
  amendment,
404
- projection === null ? "" : sizeLineHtml(projection),
405
- who.length === 0 ? "" : html `<p class="approval-who">${who.join(" · ")}</p>`,
406
- routeEvidenceHtml(route, "approval-evidence"),
407
- consent,
365
+ summaryUsualHtml(summary),
408
366
  ]);
409
367
  const parsedPlan = plan !== null && plan.ok ? plan.document : null;
410
368
  const approach = parsedPlan?.approach.trim() ?? "";
@@ -420,45 +378,86 @@ export function approvalSheetParts(input) {
420
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>`,
421
379
  ]);
422
380
  const reportNote = input.deliverable === "report" ? html `<p class="approval-note">Read-only: it reports back and changes nothing in the repository.</p>` : "";
423
- 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 ``;
424
435
  const sheet = joinHtml([
425
436
  html `<article class="plan-sheet" data-plan-sheet aria-label="${input.deliverable === "report" ? "The investigation" : "The plan"}">`,
426
- sentence === null ? "" : html `<p class="approval-revision">${sentence}</p>`,
427
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>`,
428
438
  reportNote,
429
439
  originNote(input.origin) === null ? "" : html `<p class="approval-note" data-plan-origin>${originNote(input.origin)}</p>`,
430
- html `<p class="${sheetLead.length > 180 ? "plan-sheet-lead plan-sheet-lead-long" : "plan-sheet-lead"}">${sheetLead}</p>`,
431
- approachRest === "" ? "" : html `<p class="plan-sheet-text">${approachRest}</p>`,
432
- plan !== null && !plan.ok ? html `<pre class="recap plan-doc">${input.planDocument ?? ""}</pre>` : "",
433
- goalShown.trim() === sheetLead ? "" : part("Goal", html `<p class="approval-goal">${goalShown}</p>`),
434
- repairText === null ? "" : part("Full goal", html `<p>${scope.goal}</p>`),
435
- 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),
436
446
  releaseBody === "" ? "" : part("Release", releaseBody, html ` data-plan-release`),
437
- milestones.length === 0 ? "" : part("Steps", html `<ol class="plan-sheet-steps">${milestones.map(one => html `<li><span>${one}</span></li>`)}</ol>`),
447
+ revising ? "" : stepsHtml,
438
448
  part("Done when", doneWhenSheet),
439
- html `<div class="plan-sheet-pair">`,
440
- part("Will change", scope.touches.length > 0 ? approvalPathsHtml(scope.touches) : html `<p>Any file in the project.</p>`),
441
- part("Won’t touch", html `<p>${scope.outOfScope === null ? "Nothing is ruled out." : scope.outOfScope}</p>`),
442
- html `</div>`,
443
- part("Worth knowing", joinHtml([
444
- amendment,
445
- ...warnings.map(one => html `<p class="plan-sheet-warn" data-plan-warning>${one.charAt(0).toUpperCase()}${one.slice(1)}.</p>`),
446
- (parsedPlan?.risks.length ?? 0) === 0 ? "" : html `<ul class="plan-sheet-list">${parsedPlan.risks.map(one => html `<li>${one}</li>`)}</ul>`,
447
- (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>`,
448
- ])),
449
- part("The agent", joinHtml([
450
- projection === null ? "" : sizeLineHtml(projection),
451
- who.length === 0 ? "" : html `<p class="approval-who">${who.join(" · ")}</p>`,
452
- routeEvidenceHtml(route, "approval-evidence"),
453
- agentsDetail,
454
- limits,
455
- notAllowingWarnings.length === 0 ? "" : html `<p class="approval-allowing" data-plan-allowing>You’re allowing: ${notAllowingWarnings.join(" · ")}</p>`,
456
- yoursToCheck.length === 0 ? "" : html `<p class="approval-you-check" data-plan-you-check>You’ll check: ${yoursToCheck.join("; ")}</p>`,
457
- 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>`,
458
- ])),
459
- part("Plan record", contractDetail),
460
- scope.candidate ? part("Saved commit", html `<p><code class="approval-commit">${scope.candidate}</code></p>`) : "",
461
- 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>`,
462
461
  html `</article>`,
463
462
  ]);
464
463
  return { lead, rows, editor, editorForm, details, submit, label: rebuild !== null ? "Approve and retry" : "Approve", after, allowing, passwordNote, sheet, sheetLead };
@@ -466,7 +465,15 @@ export function approvalSheetParts(input) {
466
465
  export function planSheetHtml(input) {
467
466
  return approvalSheetParts(input).sheet;
468
467
  }
469
- 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)}`]));
470
477
  export function earlierVersionsWords(active, running) {
471
478
  if (active <= 0)
472
479
  return null;
@@ -573,7 +580,7 @@ export function profileWords(scope) {
573
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>`
574
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>`;
575
582
  const terms = sandboxTermsWords(profile);
576
- 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>`}`;
577
584
  }
578
585
  export function routeEvidenceHtml(view, className = "meta") {
579
586
  const words = view?.evidence ?? null;
@@ -791,14 +798,14 @@ export function approveRefusalWords(reason) {
791
798
  return "That password didn't match.";
792
799
  return `not approved: ${reason}`;
793
800
  }
794
- export function approvalFormDigest(scopeDigest, planSha) {
795
- if (planSha === null)
801
+ export function approvalFormDigest(scopeDigest, planSha, termsKey = null) {
802
+ if (planSha === null && termsKey === null)
796
803
  return scopeDigest;
797
804
  return createHash("sha256")
798
805
  .update("standing-orders/browser-approval/v1\0", "utf8")
799
806
  .update(scopeDigest, "utf8")
800
807
  .update("\0", "utf8")
801
- .update("", "utf8")
808
+ .update(termsKey ?? "", "utf8")
802
809
  .update("\0", "utf8")
803
810
  .update(planSha ?? "", "utf8")
804
811
  .digest("hex");
@@ -1115,31 +1122,12 @@ function revisionImageLink(image) {
1115
1122
  return image == null ? html `` : html `<a href="/r/${image.run}/evidence/${image.artifact}">Screenshot ${image.artifact} · result #${image.run}</a> · `;
1116
1123
  }
1117
1124
  export function revisionLineageWords(lineage) {
1118
- const words = [];
1119
- if (lineage.problem !== undefined)
1120
- words.push(`lineage verification gap: ${lineage.problem}; no automatic repair allowance can be inferred`);
1121
- const chain = lineage.ancestors.length > 1 ? ` · lineage ${lineage.ancestors.join(" → ")}` : "";
1122
- words.push(`revises ${lineage.sourceTask}${lineage.sourceRun === null ? "" : ` (build #${lineage.sourceRun})`}${chain}`);
1123
- if (!lineage.sourceHadScope) {
1124
- words.push("the earlier version had no plan, so nothing was copied; the placeholder requirements wait for real ones");
1125
- }
1126
- else if (lineage.terms !== null) {
1127
- const terms = lineage.terms;
1128
- words.push(`inherited terms, as they stand now: ${qualityModeTitle(terms.qualityMode)} quality · ` +
1129
- `${terms.permissionMode === "bypassPermissions" ? "full access" : "auto permissions"} · ` +
1130
- `${terms.budgetMicrousd === null ? "no attempt cap" : `$${(terms.budgetMicrousd / 1_000_000).toFixed(2)} attempt cap`} · ` +
1131
- `${terms.exclusions ? "its exclusions" : "no exclusions"} · ${terms.touches === 0 ? "any path" : `${terms.touches} path limit${terms.touches === 1 ? "" : "s"}`} · ` +
1132
- `${terms.criteria} criteri${terms.criteria === 1 ? "on" : "a"}${terms.routeOverrides === 0 ? "" : ` · ${terms.routeOverrides} agent override${terms.routeOverrides === 1 ? "" : "s"}`}`);
1133
- }
1134
- words.push("re-resolved for this approval: the agents route — a yes on the source never covers it");
1135
- words.push("never inherited: the source's approval, publication and merge grants");
1136
- if (lineage.repair !== null) {
1137
- const repair = lineage.repair;
1138
- words.push(`repair chain rooted at ${repair.rootTask}: ${repair.attemptsUsed} attempt${repair.attemptsUsed === 1 ? "" : "s"} used` +
1139
- `${repair.cap === null ? " — each further attempt needs your yes" : ` of ${repair.cap} automatic · ${repair.remaining} remaining`}` +
1140
- `${repair.thisAttempt === null ? "" : ` · this is attempt ${repair.thisAttempt}`}${repair.via === null ? "" : ` · continued through ${repair.via}`}`);
1141
- }
1142
- 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
+ ];
1143
1131
  }
1144
1132
  export function revisionLineageHtml(lineage) {
1145
1133
  if (lineage === null)
@@ -1187,6 +1175,8 @@ export function taskBodyParts(data) {
1187
1175
  return html `<div class="card attempt-live" data-live-run="${liveRun.id}">${head}${peek}${door}</div>`;
1188
1176
  })();
1189
1177
  const dispatchStatus = (() => {
1178
+ if (data.dispatch?.action === "approve-scope" && (data.nonce ?? "") !== "" && task.state !== "cancelled")
1179
+ return html ``;
1190
1180
  const workToken = resultStatus?.token ?? data.dispatch?.code ?? "unknown";
1191
1181
  const headline = status.label;
1192
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>`;
@@ -1464,6 +1454,7 @@ export function taskBodyParts(data) {
1464
1454
  csrf: data.csrf,
1465
1455
  nonce: data.nonce,
1466
1456
  digest: data.approvalDigest ?? scope.digest,
1457
+ summary: data.approvalSummary ?? null,
1467
1458
  freshSince: data.approvalFresh ?? null,
1468
1459
  localOwner: data.approvalLocal ?? null,
1469
1460
  returnTo: null,
@@ -1480,7 +1471,7 @@ export function taskBodyParts(data) {
1480
1471
  releaseCiRunning: data.releaseCiRunning === true,
1481
1472
  rebuild: data.assignment?.need != null && "key" in data.assignment.need && data.assignment.need.key === "replan" ? data.assignment.need.build : null,
1482
1473
  editHref: data.csrf !== "" && data.planSha != null && data.planDocument !== null ? "#plan-edit" : "#scope",
1483
- notNowHref: "/tasks",
1474
+ notNowHref: "/",
1484
1475
  sticky: approvalLeads,
1485
1476
  earlier: { active: data.assignment?.earlierActive ?? 0, running: data.assignment?.earlierRunning ?? 0 },
1486
1477
  edit: data.csrf === "" ? null
@@ -1620,7 +1611,7 @@ export function taskBodyParts(data) {
1620
1611
  ? prop("last attempt", html `<a href="/r/${data.runs[0].id}">${runNoun(data.runs[0])} #${data.runs[0].id}</a> · ${data.runs[0].role === "planner" && data.runs[0].reason === "plan-drafted" ? "planned" : wasInterrupted(data.runs[0]) ? "interrupted" : data.runs[0].id === liveHistoryRunId ? "running" : data.runs[0].outcome ?? "never finished"} · ${data.runs[0].runner}`)
1621
1612
  : "";
1622
1613
  const queueRow = data.position !== null && data.position !== undefined && task.state === "queued"
1623
- ? prop("queue", html `${data.position.position} of ${data.position.total}${data.position.column === null ? " in the shared queue" : html ` in ${data.position.column}'s queue`} · <a href="/tasks?view=order">reorder</a>`)
1614
+ ? prop("queue", html `${data.position.position} of ${data.position.total}${data.position.column === null ? " in the shared queue" : html ` in ${data.position.column}'s queue`} · <a href="/?view=order">reorder</a>`)
1624
1615
  : "";
1625
1616
  const scopeRow = scope === null
1626
1617
  ? prop("plan", "none yet")
@@ -1641,7 +1632,7 @@ export function taskBodyParts(data) {
1641
1632
  facts.push({ label: "Last attempt", parts: [{ label: `${runNoun(lastRun)} #${lastRun.id}`, href: `/r/${lastRun.id}` },
1642
1633
  ` · ${lastRun.role === "planner" && lastRun.reason === "plan-drafted" ? "planned" : wasInterrupted(lastRun) ? "interrupted" : lastRun.id === liveHistoryRunId ? "running" : lastRun.outcome ?? "never finished"} · ${lastRun.runner}`] });
1643
1634
  if (data.position !== null && data.position !== undefined && task.state === "queued") {
1644
- facts.push({ label: "Queue", parts: [`${data.position.position} of ${data.position.total}${data.position.column === null ? " in the shared queue" : ` in ${data.position.column}'s queue`} · `, { label: "Reorder", href: "/tasks?view=order" }] });
1635
+ facts.push({ label: "Queue", parts: [`${data.position.position} of ${data.position.total}${data.position.column === null ? " in the shared queue" : ` in ${data.position.column}'s queue`} · `, { label: "Reorder", href: "/?view=order" }] });
1645
1636
  }
1646
1637
  facts.push(scope === null ? { label: "Plan", parts: ["none yet"] }
1647
1638
  : approval.approved && data.autoRelease != null ? { label: "Approved plan", parts: [autoReleaseWords(data.autoRelease)] }
@@ -1659,7 +1650,7 @@ export function taskBodyParts(data) {
1659
1650
  ? (votes.length === 0 ? "needs two approvers" : `approved by ${votes.join(", ")} · needs one more`)
1660
1651
  : data.approvalRules.words] });
1661
1652
  }
1662
- facts.push({ label: "Audit", parts: [{ label: "Audit record", href: `${taskHref(task.id)}/evidence` }] });
1653
+ facts.push({ label: "Audit", parts: [{ label: "Audit record", href: taskLinkOf({ task: task.id, record: true }) }] });
1663
1654
  if (data.budgetHold != null)
1664
1655
  facts.push({ label: "Budget", parts: [`${data.budgetHold} · `, { label: "Spend", href: "/spend" }] });
1665
1656
  if (data.policyHold != null)
@@ -2044,10 +2035,7 @@ export function taskBodyParts(data) {
2044
2035
  const retry = failedCard && task.state === "failed" && !data.claimed && !stopControlsActive && data.csrf !== ""
2045
2036
  ? { action: `${taskHref(task.id)}/requeue`, pins: data.retryPins ?? null, ...(data.failure == null ? {} : { note: retryNoteOf(data.failure.suggestion) }) } : null;
2046
2037
  const runChecks = data.runChecks ?? null;
2047
- const resultPageOf = (href) => {
2048
- const chat = href === null ? null : /^\/chat\?task=([A-Za-z0-9._~%-]{1,200})&result=([0-9]{1,15})(?:&tab=(changes|checks))?(#[A-Za-z0-9_-]{1,80})?$/.exec(href);
2049
- return chat === null ? href : `/review?result=${chat[1]}&run=${chat[2]}${chat[3] === undefined ? "" : `&tab=${chat[3]}`}${chat[4] ?? ""}`;
2050
- };
2038
+ const resultPageOf = (href) => href === null ? null : taskLinkFromLegacy(href) ?? href;
2051
2039
  const inPlaceChecks = (card) => {
2052
2040
  const status = data.demo === true ? demoChecksOf(card.status) : card.status;
2053
2041
  return { ...card, status: { ...status, details: status.details.map(one => one.action?.href?.endsWith("#follow-ups") === true ? { ...one, action: runChecks === null ? null : { label: one.action.label, href: runChecks.action } }
@@ -2081,12 +2069,12 @@ export function taskBodyParts(data) {
2081
2069
  ];
2082
2070
  const plannerRun = familyRuns.filter(run => run.role === "planner" && run.outcome !== null).sort((a, b) => b.id - a.id)[0];
2083
2071
  const sheetShown = scope === null ? null : sheetInput ?? {
2084
- 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,
2085
2073
  planDocument: data.planDocument ?? null, planContract: data.planContract ?? null,
2086
2074
  revision: data.revision == null || "problem" in data.revision ? null : data.revision,
2087
2075
  revisionSourceHref: data.revision == null || "problem" in data.revision ? "" : `/r/${data.revision.sourceRun}`,
2088
2076
  repairChain: data.repairChain ?? null, route: data.route, coordinator: data.coordinator ?? null, origin: data.origin ?? null,
2089
- deliverable: data.deliverable ?? "branch", releaseCiRunning: data.releaseCiRunning === true, editHref: "#scope", notNowHref: "/tasks", sticky: false,
2077
+ deliverable: data.deliverable ?? "branch", releaseCiRunning: data.releaseCiRunning === true, editHref: "#scope", notNowHref: "/", sticky: false,
2090
2078
  earlier: { active: data.assignment?.earlierActive ?? 0, running: data.assignment?.earlierRunning ?? 0 }, edit: null,
2091
2079
  };
2092
2080
  const sheetParts = sheetShown === null ? null : approvalSheetParts(sheetShown);
@@ -2142,7 +2130,7 @@ export function taskBodyParts(data) {
2142
2130
  approve: data.archived != null || sheetInput === null || dependencyChoiceNeeded || data.csrf === "" ? null : approveKitOf(sheetInput, data.approvalFresh ?? null),
2143
2131
  approved: scope !== null && approval.approved ? approvedKitOf(scope, approval, data.approvalProof ?? null) : null,
2144
2132
  more,
2145
- audit: facts.some(one => one.label === "Audit") ? { label: "Full record", href: `${taskHref(rootOf)}/evidence` } : null,
2133
+ audit: facts.some(one => one.label === "Audit") ? { label: "Full record", href: taskLinkOf({ task: rootOf, record: true }) } : null,
2146
2134
  recheckStopped: data.csrf !== "" && data.assignment?.primaryAction?.code === "recheck-stopped" && data.assignment.primaryAction.target.runId !== null
2147
2135
  ? { action: `${taskHref(data.assignment.rootId)}/recheck-stopped`, run: data.assignment.primaryAction.target.runId } : null,
2148
2136
  rebuild,
@@ -2186,29 +2174,41 @@ export function taskBodyParts(data) {
2186
2174
  })(),
2187
2175
  };
2188
2176
  const rowFacts = data.archived != null ? null : stepRowsOf(view);
2189
- const rowsHtml = rowFacts === null ? null : (() => {
2177
+ let composed = false;
2178
+ const rowsHtmlOf = (section) => rowFacts === null ? null : (() => {
2190
2179
  const here = rowFacts.find(row => row.state === "current" || row.state === "stuck") ?? rowFacts.find(row => row.open) ?? rowFacts.at(-1);
2180
+ const ready = rowFacts.find(row => row.key === "ready");
2181
+ const outcomeFirst = view.approve == null && view.status !== null && ready !== undefined
2182
+ && (ready.state === "current" || ready.state === "stuck" || rowFacts.every(row => row.state === "done" || row.state === "skipped"));
2191
2183
  const bodyOf = (key) => joinHtml([
2192
- key === here.key ? statusHtml : "",
2184
+ key === here.key && !outcomeFirst ? statusHtml : "",
2193
2185
  key === "plan" ? planCard : "",
2194
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 : "",
2195
2188
  key === "build" ? joinHtml([controlHtml, progressCard, revisionLedgerCard]) : "",
2196
2189
  key === "ready" && previousResult !== null ? html `<section class="task-previous-result" aria-label="${previousResult.title}">${previousResult.html}</section>` : "",
2197
2190
  ]);
2198
- return stepRows(rowFacts.map(row => ({ key: row.key, label: row.label, mark: row.mark, sentence: row.sentence, needsYou: row.needsYou, current: row.state === "current" || row.state === "stuck",
2191
+ const rows = stepRows(rowFacts.map(row => ({ key: row.key, label: row.label, mark: row.mark, sentence: row.sentence, needsYou: row.needsYou, current: row.state === "current" || row.state === "stuck",
2199
2192
  at: row.at, when: row.at === null ? "" : whenText(row.at), body: bodyOf(row.key), open: true })));
2193
+ if (!outcomeFirst)
2194
+ return rows;
2195
+ if (section !== null)
2196
+ composed = true;
2197
+ return joinHtml([html `<div class="task-outcome" data-task-outcome>${statusHtml}${section ?? ""}</div>`,
2198
+ html `<details class="k-disclose task-steps" data-task-steps><summary>Plan and steps</summary>${rows}</details>`]);
2200
2199
  })();
2201
- return { html: nativeBody(rowsHtml), view };
2200
+ const withResult = nativeBody(rowsHtmlOf(data.resultSection ?? null));
2201
+ return { html: withResult, view, ...(composed ? { bare: nativeBody(rowsHtmlOf(null)) } : {}) };
2202
2202
  }
2203
2203
  export function taskBody(data) {
2204
2204
  return taskBodyParts(data).html;
2205
2205
  }
2206
2206
  export function taskPage(chrome, data) {
2207
2207
  const first = taskBodyParts(data);
2208
- const sensitive = SENSITIVE_INPUT.test(htmlString(first.html)) || (chrome.listPane !== undefined && SENSITIVE_INPUT.test(htmlString(chrome.listPane)));
2208
+ const sensitive = SENSITIVE_INPUT.test(htmlString(first.bare ?? first.html)) || (chrome.listPane !== undefined && SENSITIVE_INPUT.test(htmlString(chrome.listPane)));
2209
2209
  if (sensitive) {
2210
2210
  const degraded = taskBodyParts({ ...data, degraded: "sensitive" });
2211
- return screen(`task \u00b7 ${data.task.id}`, degraded.html, { chrome, workspace: { view: degraded.view } });
2211
+ return screen(`task \u00b7 ${data.task.id}`, degraded.html, { chrome, workspace: { view: degraded.view, ...(degraded.bare === undefined ? {} : { pageHtml: degraded.bare }) } });
2212
2212
  }
2213
2213
  const liveRunId = data.liveRunId ?? null;
2214
2214
  const liveRun = liveRunId === null ? undefined : data.runs.find(one => one.id === liveRunId);
@@ -2225,7 +2225,7 @@ export function taskPage(chrome, data) {
2225
2225
  app.push({ kind: "answer" });
2226
2226
  return screen(`task \u00b7 ${data.task.id}`, first.html, {
2227
2227
  chrome,
2228
- workspace: { view: first.view },
2228
+ workspace: { view: first.view, ...(first.bare === undefined ? {} : { pageHtml: first.bare }) },
2229
2229
  ...(script === "" ? {} : { functional: { script, fetches: true, app } }),
2230
2230
  });
2231
2231
  }
@@ -2296,20 +2296,20 @@ export function approveKitOf(input, freshSince) {
2296
2296
  const parts = approvalSheetParts(input);
2297
2297
  const rebuild = input.rebuild ?? null;
2298
2298
  const after = rebuild !== null ? "builds it again to this plan" : input.deliverable === "report" ? "starts the investigation" : "starts the build";
2299
- const allowing = parts.allowing.length === 0 ? "" : ` You’re allowing ${parts.allowing.join(", ")}.`;
2300
2299
  const until = freshSince === null ? null : freshUntil(freshSince);
2301
2300
  return {
2302
2301
  action: input.action,
2303
2302
  fields: { nonce: input.nonce, digest: input.digest, ...(rebuild === null ? {} : { rebuild: String(rebuild) }) },
2304
2303
  label: parts.label,
2305
2304
  heading: rebuild !== null ? "The plan changed" : input.deliverable === "report" ? "Investigation ready" : "Plan ready",
2306
- text: `Approving ${after}.${allowing}`,
2305
+ text: `Approving ${after}.`,
2307
2306
  kind: "standard",
2308
2307
  facts: { passwordless: passwordlessRendering() || input.localOwner?.eligible === true, remembered: until !== null },
2309
2308
  rememberedUntil: until,
2310
2309
  ...(input.localOwner?.eligible === true ? { termsWords: "No password needed on this computer." } : {}),
2311
2310
  planHtml: htmlString(joinHtml([parts.sheet, parts.editor ?? "", parts.editorForm])),
2312
2311
  sheetHtml: htmlString(parts.sheet),
2312
+ editorHtml: htmlString(joinHtml([parts.editor ?? "", parts.editorForm])),
2313
2313
  };
2314
2314
  }
2315
2315
  export function approvedKitOf(scope, approval, proof) {