toolroll 0.9.109 → 0.9.111

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 (155) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +5 -1
  3. package/THIRD_PARTY_NOTICES.md +30 -0
  4. package/dist/agent-detect.js +244 -0
  5. package/dist/agent-fence.js +12 -1
  6. package/dist/agent-said-schema.js +4 -0
  7. package/dist/agent-said.js +23 -0
  8. package/dist/agentconfig.js +2 -2
  9. package/dist/approval-summary.js +375 -0
  10. package/dist/attest.js +2 -2
  11. package/dist/browser/THIRD_PARTY_NOTICES.txt +30 -0
  12. package/dist/browser/workspace.css +2 -2
  13. package/dist/browser/workspace.js +27 -27
  14. package/dist/builder.js +42 -3
  15. package/dist/chat-actions.js +24 -17
  16. package/dist/chat-core.js +3 -1
  17. package/dist/chat-decide.js +101 -46
  18. package/dist/chat-delivery-state.js +2 -0
  19. package/dist/chat-delivery.js +3 -2
  20. package/dist/chat-live.js +2 -1
  21. package/dist/chat-task-actions.js +6 -0
  22. package/dist/check-report.js +1 -1
  23. package/dist/claim.js +28 -13
  24. package/dist/cli-help.js +1 -1
  25. package/dist/cli.js +2 -0
  26. package/dist/codex-limits.js +21 -8
  27. package/dist/console-instance.js +11 -1
  28. package/dist/contracts/console-api.js +13 -7
  29. package/dist/contracts/engine-api.js +283 -0
  30. package/dist/contracts/route.js +1 -0
  31. package/dist/coordinator.js +2 -2
  32. package/dist/discord-api.js +4 -3
  33. package/dist/discord-chat.js +3 -1
  34. package/dist/dispatch.js +1 -1
  35. package/dist/dispose.js +15 -9
  36. package/dist/easy-start-args.js +7 -3
  37. package/dist/easy-start.js +40 -1
  38. package/dist/egress.js +72 -10
  39. package/dist/engine-handoff.js +34 -0
  40. package/dist/engine-reads.js +338 -0
  41. package/dist/eval-world.js +3 -2
  42. package/dist/evidence.js +2 -0
  43. package/dist/fast-start.js +68 -18
  44. package/dist/fast-terms.js +2 -2
  45. package/dist/first-run.js +10 -2
  46. package/dist/flexible-agents.js +234 -0
  47. package/dist/flexible-answers-schema.js +61 -0
  48. package/dist/flexible-answers.js +889 -0
  49. package/dist/flexible-custody.js +494 -0
  50. package/dist/flexible-import.js +782 -0
  51. package/dist/flexible-launch-schema.js +72 -0
  52. package/dist/flexible-launch.js +331 -0
  53. package/dist/flexible-launcher.js +88 -0
  54. package/dist/flexible-levels.js +34 -0
  55. package/dist/flexible-merge-guard.js +47 -0
  56. package/dist/flexible-refs.js +47 -0
  57. package/dist/flexible-relay-cancel.js +19 -0
  58. package/dist/flexible-relay-schema.js +55 -0
  59. package/dist/flexible-relay-upstreams.js +36 -0
  60. package/dist/flexible-relay.js +1032 -0
  61. package/dist/flexible-session.js +732 -0
  62. package/dist/flexible-ship-schema.js +81 -0
  63. package/dist/flexible-ship.js +694 -0
  64. package/dist/flexible-start.js +80 -0
  65. package/dist/flexible-thread.js +175 -25
  66. package/dist/flexible-turns-schema.js +69 -0
  67. package/dist/flexible-turns.js +490 -0
  68. package/dist/flexible.js +10 -1
  69. package/dist/flow-actions.js +6 -4
  70. package/dist/flow-steps.js +1 -1
  71. package/dist/flows-cli.js +2 -1
  72. package/dist/git-views.js +6 -3
  73. package/dist/install-mode.js +225 -0
  74. package/dist/integrations.js +6 -1
  75. package/dist/lead-doors.js +7 -1
  76. package/dist/limits-ui.js +7 -0
  77. package/dist/live-reply.js +6 -0
  78. package/dist/live-terminal.js +425 -29
  79. package/dist/local-owner.js +7 -0
  80. package/dist/model-choices.js +12 -6
  81. package/dist/needs-you.js +2 -0
  82. package/dist/notification-delivery.js +11 -0
  83. package/dist/operate.js +128 -37
  84. package/dist/outbound-privacy.js +204 -0
  85. package/dist/passwordless.js +2 -1
  86. package/dist/phase-routing.js +3 -1
  87. package/dist/plane-review.js +1 -1
  88. package/dist/project-delete.js +14 -0
  89. package/dist/proposal.js +2 -2
  90. package/dist/provider-connection.js +19 -5
  91. package/dist/publish.js +5 -0
  92. package/dist/pull-request-flow.js +26 -7
  93. package/dist/push.js +5 -1
  94. package/dist/release-card.js +11 -3
  95. package/dist/release.js +10 -1
  96. package/dist/route-store.js +3 -3
  97. package/dist/sandbox-launch.js +32 -8
  98. package/dist/sandbox-runtime.js +16 -7
  99. package/dist/sandbox-tools.js +176 -0
  100. package/dist/scope.js +12 -36
  101. package/dist/scout-net.js +7 -2
  102. package/dist/serve.js +62 -13
  103. package/dist/server/chrome.js +3 -1
  104. package/dist/server/console.css +33 -6
  105. package/dist/server/engine-api.js +378 -0
  106. package/dist/server/flows.js +2 -2
  107. package/dist/server/http.js +7 -0
  108. package/dist/server/link-redemption.js +52 -0
  109. package/dist/server/mutation-key.js +21 -7
  110. package/dist/server/pages.js +72 -40
  111. package/dist/server/people-tokens.js +17 -41
  112. package/dist/server/render-chat.js +1 -0
  113. package/dist/server/render-new-task.js +3 -3
  114. package/dist/server/render-results.js +4 -4
  115. package/dist/server/render-tasks.js +133 -139
  116. package/dist/server/route-table.js +32 -1
  117. package/dist/server/settings-section-table.js +6 -0
  118. package/dist/server/settings-sections.js +69 -0
  119. package/dist/server/settings.js +120 -10
  120. package/dist/server/task-views.js +8 -2
  121. package/dist/server/tasks.js +56 -12
  122. package/dist/server/terminals.js +181 -28
  123. package/dist/server/welcome.js +35 -10
  124. package/dist/settings-groups-ui.js +2 -2
  125. package/dist/settings-proofs.js +14 -9
  126. package/dist/slack-api.js +4 -3
  127. package/dist/slack-chat.js +5 -3
  128. package/dist/spend.js +46 -12
  129. package/dist/status-probe.js +343 -0
  130. package/dist/store.js +181 -12
  131. package/dist/task-sizing-schema.js +14 -0
  132. package/dist/task-sizing.js +76 -10
  133. package/dist/teams-api.js +4 -3
  134. package/dist/teams-chat.js +4 -2
  135. package/dist/telegram-lead.js +2 -1
  136. package/dist/telegram-live.js +2 -1
  137. package/dist/telegram-team.js +2 -1
  138. package/dist/telegram.js +17 -5
  139. package/dist/toolroll-update.js +3 -1
  140. package/dist/trusted-path.js +162 -0
  141. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  142. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  143. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  144. package/dist/tui/linux-x64/toolroll-tui +0 -0
  145. package/dist/tui-launch.js +282 -0
  146. package/dist/tui-source.js +5 -3
  147. package/dist/tui.js +1 -1
  148. package/dist/webhooks.js +14 -4
  149. package/dist/welcome-facts.js +22 -15
  150. package/dist/work-index.js +2 -2
  151. package/dist/workspace-ui.js +5 -0
  152. package/package.json +1 -1
  153. package/scripts/crash-canary.mjs +1 -1
  154. package/scripts/pilot.mjs +1 -1
  155. package/scripts/provider-canary.mjs +5 -3
package/dist/builder.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { legacyNetwork, repositoryEcosystems } from "./egress.js";
2
+ import { flexibleAdoption } from "./flexible-merge-guard.js";
3
+ import { agentSaidTail } from "./agent-said.js";
2
4
  import { CHECK_ACCESS_DEFAULT, checkAccessHere, checkNetworkOf, localModeCap } from "./check-access.js";
3
5
  import { localModeOn } from "./local-owner.js";
4
6
  import { checkoutGit, refusal as gitRefusal } from "./teardown-git.js";
@@ -1149,10 +1151,12 @@ export async function settleProviderOutcome(captured, result) {
1149
1151
  };
1150
1152
  }
1151
1153
  if (result.initFailed) {
1154
+ const said = agentSaidTail(result.stderr);
1152
1155
  return {
1153
1156
  ok: false,
1154
1157
  reason: "provider-init",
1155
1158
  message: `the provider harness never initialized — ${firstLine(result.stderr) || `exit ${result.code}`}`,
1159
+ ...(said.length === 0 ? {} : { agentSaid: said }),
1156
1160
  };
1157
1161
  }
1158
1162
  const liveEnding = captured.live?.close === "turn-budget" || captured.live?.close === "paused-idle";
@@ -1162,7 +1166,9 @@ export async function settleProviderOutcome(captured, result) {
1162
1166
  if (kept !== null)
1163
1167
  return kept;
1164
1168
  }
1165
- return { ok: false, reason: "agent", message: agentExitWords(result) };
1169
+ const ceiling = result.ending?.subtype === "error_max_turns" || result.ending?.subtype === "error_max_budget_usd";
1170
+ const said = agentSaidTail(result.stderr.trim() !== "" ? result.stderr : result.finalMessage);
1171
+ return { ok: false, reason: ceiling ? "agent" : "agent-error", message: agentExitWords(result), ...(said.length === 0 ? {} : { agentSaid: said }) };
1166
1172
  }
1167
1173
  if (captured.live?.close === "turn-budget" && ![done, mailbox, captured.plan?.proposal].some(name => name !== undefined && existsSync(join(worktree, name)))) {
1168
1174
  return { ok: false, reason: "agent", message: agentExitWords({ ...result, ending: { subtype: "error_max_turns", turns: captured.live.maxTurns } }) };
@@ -1358,9 +1364,13 @@ export async function settleProviderOutcome(captured, result) {
1358
1364
  return { ok: false, reason: "stopped", message: await stoppedWords(captured) };
1359
1365
  }
1360
1366
  store.setRunPhase(request.runId, "committing");
1367
+ const flexibleAdopt = flexibleAdoption(store, taskId, scope?.candidate ?? null, scope?.digest ?? null);
1368
+ if (flexibleAdopt !== null && ("refuse" in flexibleAdopt || finishesKeptWork)) {
1369
+ return { ok: false, reason: "commit-failure", message: "refuse" in flexibleAdopt ? flexibleAdopt.refuse : "This task came from a Flexible thread; it takes only its Ship's imported commit. Nothing was committed." };
1370
+ }
1361
1371
  const made = finishesKeptWork
1362
1372
  ? await keptWorkResult(captured, baseRevision, handoff.conclusion)
1363
- : await commit(git, worktree, branch, taskId, scope, handoff.conclusion, scope?.candidate ?? null, words => store.addRunNote(request.runId, "Toolroll", words, clock()));
1373
+ : await commit(git, worktree, branch, taskId, scope, handoff.conclusion, scope?.candidate ?? null, words => store.addRunNote(request.runId, "Toolroll", words, clock()), flexibleAdopt === null ? null : flexibleAdopt.adopt);
1364
1374
  if (made.ok && made.parked === undefined && made.committed) {
1365
1375
  const newHead = await git(GIT, ["--no-optional-locks", "rev-parse", "HEAD"], { cwd: worktree });
1366
1376
  if (newHead.code === 0) {
@@ -2807,7 +2817,7 @@ function brief(scope, branch, mailbox, done, proof, answers = [], planDocument =
2807
2817
  " else.",
2808
2818
  ].join("\n");
2809
2819
  }
2810
- async function commit(git, worktree, branch, taskId, scope, summary, preparedCandidate = null, notice) {
2820
+ async function commit(git, worktree, branch, taskId, scope, summary, preparedCandidate = null, notice, adopt = null) {
2811
2821
  const status = await git(GIT, ["--no-optional-locks", "status", "--porcelain"], { cwd: worktree });
2812
2822
  if (status.code !== 0) {
2813
2823
  return { ok: false, reason: "commit-failure", message: firstLine(status.stderr) };
@@ -2856,6 +2866,12 @@ async function commit(git, worktree, branch, taskId, scope, summary, preparedCan
2856
2866
  ? "The staged files no longer match the approved prepared candidate. The checkout is preserved; nothing was committed."
2857
2867
  : "The staged prepared candidate could not be verified. The checkout is preserved; nothing was committed." };
2858
2868
  }
2869
+ if (adopt !== null) {
2870
+ if (preparedCandidate !== adopt.candidate)
2871
+ return { ok: false, reason: "commit-failure", message: "The prepared commit isn't the Ship's imported commit. Nothing was committed." };
2872
+ const adopted = await adoptPreparedCommit(git, worktree, adopt.candidate, adopt.importRef);
2873
+ return adopted.ok ? { ok: true, committed: true, branch, summary } : { ok: false, reason: "commit-failure", message: adopted.message };
2874
+ }
2859
2875
  const message = [`${taskId}: ${firstSentence(scope.goal, 68)}`, "", summary].join("\n");
2860
2876
  const made = await git(GIT, ["commit", "--no-verify", "-m", message], { cwd: worktree });
2861
2877
  if (made.code !== 0) {
@@ -2915,3 +2931,26 @@ function firstSentence(goal, limit) {
2915
2931
  const lastSpace = cut.lastIndexOf(" ");
2916
2932
  return `${lastSpace > 20 ? cut.slice(0, lastSpace) : cut}…`;
2917
2933
  }
2934
+ export async function adoptPreparedCommit(git, worktree, candidate, importRef) {
2935
+ if (!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(candidate))
2936
+ return { ok: false, message: "The shipped commit isn't an exact commit id. Nothing was committed." };
2937
+ if (!/^refs\/toolroll\/import\/[0-9a-f]{32}\/[1-9]\d{0,6}$/.test(importRef))
2938
+ return { ok: false, message: "The Ship's import isn't one Toolroll made. Nothing was committed." };
2939
+ const imported = await git(GIT, ["--no-optional-locks", "rev-parse", "--verify", "--quiet", "--end-of-options", `${importRef}^{commit}`], { cwd: worktree });
2940
+ if (imported.code !== 0 || imported.stdout.trim() !== candidate)
2941
+ return { ok: false, message: "The prepared commit isn't the one the Ship's import checked. The checkout is preserved; nothing was committed." };
2942
+ const descends = await git(GIT, ["--no-optional-locks", "merge-base", "--is-ancestor", "HEAD", candidate], { cwd: worktree });
2943
+ if (descends.code !== 0)
2944
+ return { ok: false, message: "The shipped commit doesn't build on this branch's commit. The checkout is preserved; nothing was committed." };
2945
+ const staged = await git(GIT, ["--no-optional-locks", "diff", "--cached", "--quiet", candidate, "--"], { cwd: worktree });
2946
+ if (staged.code !== 0)
2947
+ return { ok: false, message: "The staged files aren't exactly the shipped commit's. The checkout is preserved; nothing was committed." };
2948
+ const moved = await git(GIT, ["reset", "--soft", "-q", candidate], { cwd: worktree });
2949
+ if (moved.code !== 0)
2950
+ return { ok: false, message: `${firstLine(moved.stderr) || "The branch couldn't be moved to the shipped commit"}. The checkout is preserved.` };
2951
+ const head = await git(GIT, ["--no-optional-locks", "rev-parse", "HEAD"], { cwd: worktree });
2952
+ const clean = await git(GIT, ["--no-optional-locks", "diff", "--cached", "--quiet", "HEAD", "--"], { cwd: worktree });
2953
+ if (head.code !== 0 || head.stdout.trim() !== candidate || clean.code !== 0)
2954
+ return { ok: false, message: "The branch didn't land exactly on the shipped commit. The checkout is preserved." };
2955
+ return { ok: true };
2956
+ }
@@ -22,6 +22,7 @@ import { isProviderId } from "./provider.js";
22
22
  import { approverStandsNow, familyRepoOf } from "./tidy.js";
23
23
  import { chatApproveMode, effectiveChatApproval } from "./chat-approval.js";
24
24
  import { cardTermsDigest, chatLimitProblem, scopeTermsText, shownAsWritten } from "./chat-terms.js";
25
+ import { approvalSummaryOf, describeScope, summaryContextOf, summaryText } from "./approval-summary.js";
25
26
  import { chatStartDryRun, chatStartPreview, fastRefusalWords, fastStartBuild, FAST_MAX_FILES, FAST_MAX_LINES } from "./fast-start.js";
26
27
  import { fastTermsLines } from "./fast-terms.js";
27
28
  import { TYPED_START_REFUSED, typedStartNames } from "./typed-start.js";
@@ -30,7 +31,7 @@ import { archiveTaskFamily, leadTurnKeepsProposals, restoreTaskFamily, verifiedA
30
31
  import { isVerifiedApprover, reproveApprover, } from "./principal.js";
31
32
  import { changeSkills, importSkill, skillsView, skillsVersion, testSkill, validateSkill, } from "./project-skills.js";
32
33
  import { changeKnowledge, knowledgeVersion, knowledgeView, } from "./project-knowledge.js";
33
- import { passwordlessSessionFor, approve, authenticateApprover, describeScope, scopeAuthorityOf, machineActing, freshnessFor, localApprovalEligible, spendingOnlyOnSuccess, ssoNowAvailable, withFreshness, } from "./scope.js";
34
+ import { passwordlessSessionFor, approve, authenticateApprover, proveCredential, scopeAuthorityOf, machineActing, freshnessFor, localApprovalEligible, spendingOnlyOnSuccess, ssoNowAvailable, withFreshness, } from "./scope.js";
34
35
  import { readVerifiedArtifact, scanForSecrets } from "./evidence.js";
35
36
  import { readAuthModeStrict } from "./keys.js";
36
37
  import { acceptAndCompleteAsOperator, assignmentOf } from "./assignment.js";
@@ -57,6 +58,7 @@ import { answerSubagentQuestion } from "./subagent-work.js";
57
58
  import { callWords, checkRule, defaultRule, grantListed, revokeTool, ruleLoosens, ruleWords, setToolRules } from "./subagent-tools.js";
58
59
  import { aboutYouOf, checkAboutYouLine, saveAboutYou, withAboutYouLine } from "./lead-about.js";
59
60
  import { CHAT_ACTION_FIELDS, readChatActionRequest, readSharedAction, SHARED_ACTION_VERSION } from "./contracts/chat-actions.js";
61
+ import { soloChatSeatRefusal } from "./install-mode.js";
60
62
  export { CHAT_ACTION_FIELDS };
61
63
  function toolSpecFromRequest(input) {
62
64
  if (input["catalog"] !== undefined) {
@@ -162,6 +164,7 @@ export const CHAT_ACTIONS = {
162
164
  task_resume: { label: "Resume task", protected: true, password: false },
163
165
  task_start: { label: "Start work", protected: true, password: false },
164
166
  };
167
+ const CREDENTIAL_ACTIONS = new Set(["tool_add", "flow_browser"]);
165
168
  const SAME_ACTIONS = true;
166
169
  void SAME_ACTIONS;
167
170
  export const APPROVAL_ACTIONS = new Set(["scope_approve", "task_resume", "sweep_file", "flow_browser", "task_reopen", "revision_accept", "revision_reject", "flow_unattended", "task_start"]);
@@ -993,14 +996,8 @@ export function prepareSharedAction(store, who, operation, input, root, now = ne
993
996
  if (!authority.ok)
994
997
  throw Error(authority.problem);
995
998
  state["authMode"] = authority.authMode;
996
- terms.push(scopeTermsText(scope), ...describeScope(scope, undefined, taskEvidenceWords(store, scope.taskId, now))
997
- .filter((line) => !/^\s*(reference|approved|goal|not this|touches)\s/.test(line))
998
- .map((line) => line
999
- .trimStart()
1000
- .replace(/^why model\s+/, "Why this model: ")
1001
- .replace(/^goal\s+/, "Work: ")
1002
- .replace(/^not this\s+/, "Excluded: ")
1003
- .replace(/^touches\s+/, "Allowed files: ")), `Agent permissions and limits\n${runtimeTerms(authority.profile)}\n${authority.authMode === "api-key" ? "Uses your API key; spend is charged to that account." : authority.authMode === "subscription" ? "Uses your subscription login." : ""}`);
999
+ const summary = approvalSummaryOf(scope, summaryContextOf(store, scope.taskId, scope, now, taskEvidenceWords(store, scope.taskId, now)));
1000
+ terms.push(scopeTermsText(scope), summaryText(summary, one => one.fields.includes("goal") || one.fields.includes("outOfScope") || one.fields.includes("acceptance")), `Agent permissions and limits\n${runtimeTerms(authority.profile)}\n${authority.authMode === "api-key" ? "Uses your API key; spend is charged to that account." : authority.authMode === "subscription" ? "Uses your subscription login." : ""}`);
1004
1001
  const plan = store.latestPlanArtifact(ref.id), revision = ref.revisionBriefArtifact === null
1005
1002
  ? null
1006
1003
  : store.getArtifact(ref.revisionBriefArtifact);
@@ -1187,13 +1184,20 @@ export function executeSharedAction(store, who, id, payload, now, options) {
1187
1184
  return refuse("needs-confirm", "Only a person approves this.");
1188
1185
  if (APPROVAL_ACTIONS.has(live.operation) && options.via === "web" && options.authority !== "local-owner" && options.person !== true)
1189
1186
  return refuse("needs-confirm", "Approve this yourself, in your signed-in chat.");
1187
+ let reviewProof = null;
1188
+ if (CREDENTIAL_ACTIONS.has(live.operation) && (challenged || options.via !== "web" || !options.review || options.confirm !== true))
1189
+ return refuse("needs-confirm", "Confirm with your password in the secure screen.");
1190
1190
  if (sharedActionNeedsReview(payload) && !challenged) {
1191
1191
  if (options.via !== "web" || !options.review || options.confirm !== true)
1192
1192
  return refuse("needs-confirm", "Review the complete action in the secure confirmation screen.");
1193
1193
  if (!store.consumeCeremonyNonce(nonceHash(options.review.nonce), who.name, "chat-action", id, savedStamp, now))
1194
1194
  return refuse("needs-confirm", "This confirmation expired or was already used. Open the review again.");
1195
- const proved = config.password ? authenticateApprover(store, who.name, options.review.password, payload.repo) : null;
1196
- if (config.password && proved?.ok !== true)
1195
+ const credential = CREDENTIAL_ACTIONS.has(live.operation);
1196
+ const proved = credential ? proveCredential(store, who.name, options.review.password, payload.repo)
1197
+ : config.password ? authenticateApprover(store, who.name, options.review.password, payload.repo) : null;
1198
+ if (proved?.ok === true)
1199
+ reviewProof = proved.method;
1200
+ if ((credential || config.password) && proved?.ok !== true)
1197
1201
  return refuse("needs-confirm", "Confirm with your password in the secure screen.");
1198
1202
  }
1199
1203
  try {
@@ -1240,7 +1244,7 @@ export function executeSharedAction(store, who, id, payload, now, options) {
1240
1244
  const by = approvalBy(store, who, repo, now, options, drafted);
1241
1245
  if (by.ok === false)
1242
1246
  throw Error(by.why);
1243
- const signed = signFlowBrowser(store, { flow, signer: actor, proof: options.via === "web" ? "session" : "chat", sawDigest: String(payload.state["digest"] ?? ""), console: { generation: who.generation } }, now);
1247
+ const signed = signFlowBrowser(store, { flow, signer: actor, proof: reviewProof, sawDigest: String(payload.state["digest"] ?? ""), console: { generation: who.generation } }, now);
1244
1248
  if (!signed.ok)
1245
1249
  throw Error(signed.message);
1246
1250
  return { ok: true, taskId: null, said: "Browser allowed. Its browser zones can start Chromium now.", href: `/flows/${flow}` };
@@ -1425,14 +1429,14 @@ function fileSweepChild(store, who, repo, brief, one, acceptance, now) {
1425
1429
  filedVia: "mate", filedBy: { name: who.name, kind: "person" }, proposedVia: "mate", admittedRepos: [...who.repos],
1426
1430
  }, now);
1427
1431
  }
1428
- function sweepChildScopeOf(store, taskId) {
1432
+ function sweepChildScopeOf(store, taskId, now) {
1429
1433
  const scope = store.getScope(taskId);
1430
1434
  if (scope === null)
1431
1435
  throw Error("A sweep item has no scope to show.");
1432
1436
  const authority = scopeAuthorityOf(scope, { authMode: readAuthModeStrict });
1433
1437
  if (!authority.ok)
1434
1438
  throw Error(authority.problem);
1435
- const words = describeScope(scope).filter(line => !/^\s*(reference|approved)\s/.test(line)).map(line => line.trim());
1439
+ const words = describeScope(scope, undefined, null, summaryContextOf(store, taskId, scope, now)).filter(line => !/^\s*(reference|approved)\s/.test(line)).map(line => line.trim());
1436
1440
  const runtime = `Agent permissions and limits: ${runtimeTerms(authority.profile)} ${authority.authMode === "api-key" ? "Uses your API key; spend is charged to that account." : authority.authMode === "subscription" ? "Uses your subscription login." : ""}`.trim();
1437
1441
  const { taskId: _task, digest: _digest, approvedDigest: _approved, approvedBy: _by, approvedAt: _at, proposedAt: _proposed, approvalBasis: _basis, modeDigest: _mode, approvedProfile: _approvedProfile, approvedProfileJson: _approvedProfileJson, approvedChainJson: _approvedChain, ...terms } = scope;
1438
1442
  return { fingerprint: hash({ words, runtime, authMode: authority.authMode, profile: authority.profile, terms }), runtime, words, terms: scopeTermsText(scope) };
@@ -1447,7 +1451,7 @@ function sweepChildScopes(store, who, repo, brief, items, acceptance, now) {
1447
1451
  const made = fileSweepChild(store, who, repo, brief, one, acceptance, now);
1448
1452
  if (!made.ok)
1449
1453
  throw Error(`Item ${index + 1} (${one.title}) can't be filed: ${made.message}`);
1450
- return sweepChildScopeOf(store, made.id);
1454
+ return sweepChildScopeOf(store, made.id, now);
1451
1455
  });
1452
1456
  throw dryRun;
1453
1457
  });
@@ -1470,7 +1474,7 @@ function startFromCard(store, who, proposal, drafted, options, now) {
1470
1474
  const chat = by.chat;
1471
1475
  proof = { chat: by.limits };
1472
1476
  const typed = options.typedStart;
1473
- approveNow = (taskId, saw, fast) => approve(store, taskId, who.name, now, saw, "", {}, typed === undefined ? fast : { ...fast, typed: { provider: typed.provider, event: typed.event } }, chat);
1477
+ approveNow = (taskId, saw, fast) => approve(store, taskId, who.name, now, saw, "", {}, typed === undefined || fast === undefined ? fast : { ...fast, typed: { provider: typed.provider, event: typed.event } }, chat);
1474
1478
  }
1475
1479
  else if (options.authority === "local-owner" && currentLocalOwner() !== null) {
1476
1480
  proof = { password: { localOwner: true, passwordless: false, freshAt: null, returnTo: "/chat" } };
@@ -1508,6 +1512,9 @@ function approvalBy(store, who, repo, now, options, drafted) {
1508
1512
  const allowed = effectiveChatApproval(store, repo, who.name);
1509
1513
  return allowed.ok ? { ok: true, limits: allowed.limits, chat: { modeDigest: allowed.setting.digest, shown } } : { ok: false, why: allowed.why };
1510
1514
  }
1515
+ const solo = soloChatSeatRefusal(store, { provider: options.via, binding: options.binding, approver: who.name });
1516
+ if (solo !== null)
1517
+ return { ok: false, why: solo };
1511
1518
  const allowed = chatApproveMode(store, repo, who.name, now, options.via);
1512
1519
  return allowed.ok ? { ok: true, limits: allowed.limits, chat: { modeDigest: allowed.digest, shown } } : allowed;
1513
1520
  }
@@ -1527,7 +1534,7 @@ function fileSweep(store, who, proposal, payload, by, now) {
1527
1534
  const made = fileSweepChild(store, who, payload.repo, brief, one, req["acceptance"], now);
1528
1535
  if (!made.ok)
1529
1536
  throw Error(`Item ${index + 1} (${one.title}) couldn't be filed: ${made.message}. Nothing was filed.`);
1530
- if (sweepChildScopeOf(store, made.id).fingerprint !== payload.state["children"]?.[index])
1537
+ if (sweepChildScopeOf(store, made.id, now).fingerprint !== payload.state["children"]?.[index])
1531
1538
  throw Error(`Item ${index + 1} (${one.title}) no longer matches what you reviewed (a project default changed). Nothing was filed; ask for a fresh card.`);
1532
1539
  store.addSweepTask(sweep, made.id, index, one.title);
1533
1540
  filed.push({ id: made.id, title: one.title });
package/dist/chat-core.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
+ import { soloChatSeatRefusal } from "./install-mode.js";
2
3
  const REVOKED = "revoked";
3
4
  export const chatHash = (text) => createHash("sha256").update(text).digest("hex");
4
5
  export const PAIRING_CODE_TTL_MS = 10 * 60_000;
@@ -57,7 +58,8 @@ export class ChatCore {
57
58
  const current = this.bindingById(binding.id);
58
59
  const account = this.store.accountOf(binding.approver);
59
60
  return current !== null && current.approver === binding.approver && current.generation === binding.generation &&
60
- account?.role === "approver" && account.revokedAt === null && account.generation === binding.generation;
61
+ account?.role === "approver" && account.revokedAt === null && account.generation === binding.generation
62
+ && soloChatSeatRefusal(this.store, { provider: this.provider, binding: binding.id, approver: binding.approver }) === null;
61
63
  }
62
64
  liveBindings(installation) {
63
65
  return this.bindings(installation).filter(binding => this.live(binding));
@@ -7,7 +7,8 @@ import { acceptAndCompleteAsOperator, assignmentOf, owedAcceptance } from "./ass
7
7
  import { chatControlHref, chatResultHref } from "./chat-controls.js";
8
8
  import { applyChatTaskAction, chatTaskStamp } from "./chat-task-actions.js";
9
9
  import { chatTitle } from "./chat-voice.js";
10
- import { readVerifiedArtifact, scanForSecrets } from "./evidence.js";
10
+ import { readVerifiedArtifact } from "./evidence.js";
11
+ import { outboundPrivate, privateWords } from "./outbound-privacy.js";
11
12
  import { chatApproveMode } from "./chat-approval.js";
12
13
  import { parseExecutionPlanDocument } from "./plan.js";
13
14
  import { verifyApproverStanding } from "./principal.js";
@@ -20,11 +21,12 @@ import { releaseCardOf } from "./release-card.js";
20
21
  import { releaseCiHoldOf, releaseCiHoldWords } from "./release-ci-hold.js";
21
22
  import { phoneText, projectLabel } from "./telegram-status.js";
22
23
  import { cardTermsDigest, chatLimitProblem, permissionPlainWords, scopeTermsText, shownAsWritten, shownTermsDigest } from "./chat-terms.js";
23
- import { chainTermsLines } from "./scope.js";
24
+ import { approvalSummaryOf, EVIDENCE_WORDS, summaryContextOf, summaryText } from "./approval-summary.js";
24
25
  import { YOUIYOUX_CARD_KIND, YOUIYOUX_FILED_VIA, YOUIYOUX_HOME_PATH } from "./contracts/youiyoux-request.js";
25
26
  import { FILED_PER_PASS, requestKindWord, requestPassOf } from "./youiyoux-intake.js";
26
27
  import { discordPlain } from "./reply-shape.js";
27
28
  import { PLATFORM_LIMITS } from "./text-limits.js";
29
+ import { soloChatSeatRefusal } from "./install-mode.js";
28
30
  export { permissionPlainWords };
29
31
  export const DECIDE_LABELS = {
30
32
  accept: "Accept",
@@ -49,7 +51,6 @@ const sha = (text) => createHash("sha256").update(text).digest("hex");
49
51
  const isAct = (one) => "act" in one;
50
52
  const title = (store, taskId) => phoneText(chatTitle(store, taskId), 60);
51
53
  export { chatApproveMode };
52
- const money = (micro) => `$${(micro / 1_000_000).toFixed(2)}`;
53
54
  export function planInChat(store, taskId, approver, now, channel, root, from) {
54
55
  if (from !== "requests" && store.filedViaOf(taskId) === YOUIYOUX_FILED_VIA)
55
56
  return { ok: false, why: OUTSIDE_TERMS };
@@ -104,7 +105,8 @@ export function planInChat(store, taskId, approver, now, channel, root, from) {
104
105
  if (!verified)
105
106
  return { ok: false, why: "The saved plan can't be verified here, so you approve it in Toolroll." };
106
107
  }
107
- return { ok: true, modeDigest: mode.digest, source: mode.source, scope, whole, digest: sha(`${scope.digest}:${plan?.sha256 ?? ""}${whole ? `:${cardTermsDigest(scopeTermsText(scope))}` : ""}`) };
108
+ const summaryKey = approvalSummaryOf(scope, summaryContextOf(store, taskId, scope, now)).key;
109
+ return { ok: true, modeDigest: mode.digest, source: mode.source, scope, whole, digest: sha(`${scope.digest}:${plan?.sha256 ?? ""}:${summaryKey}${whole ? `:${cardTermsDigest(scopeTermsText(scope))}` : ""}`) };
108
110
  }
109
111
  export function mergeInChat(store, taskId, run, approver, now, channel) {
110
112
  const ref = store.lookupRef(taskId);
@@ -130,6 +132,11 @@ const OPEN_IN_TOOLROLL = "Open in Toolroll";
130
132
  const OUTSIDE_TERMS = "A youiyoux request is approved from its own youiyoux card, which shows every word, or in Toolroll.";
131
133
  const TOO_LONG = "its full terms don't fit in one chat message";
132
134
  const ROOM = 400;
135
+ export function wholeTermsText(store, taskId, scope, now) {
136
+ const summary = approvalSummaryOf(scope, summaryContextOf(store, taskId, scope, now));
137
+ return `${scopeTermsText(scope)}\n\n${summaryText(summary, one => one.fields.some(field => field === "goal" || field === "outOfScope" || field === "acceptance"))}`;
138
+ }
139
+ const wholeCardDigest = (store, taskId, scope, now) => sha(`${shownTermsDigest(scope)}:${approvalSummaryOf(scope, summaryContextOf(store, taskId, scope, now)).key}`);
133
140
  const listedDigest = (list) => `${REQUESTS_DIGEST}${list.map(one => `${one.taskId}=${one.digest}`).join(",")}`;
134
141
  const LISTABLE_ID = /^[A-Za-z0-9._-]{1,64}$/;
135
142
  function listedOf(digest) {
@@ -154,9 +161,6 @@ export function shownWhole(text, channel) {
154
161
  case "teams": return false;
155
162
  }
156
163
  }
157
- function privateWords(text) {
158
- return scanForSecrets(text).length > 0 || /\b\d{5,}:[A-Za-z0-9_-]{20,}\b/.test(text) || /(?:^|[\s"'`(<[=:,])(?:\/Users\/|\/home\/|\/root\/|~\/)|(?:[A-Za-z]:[\\/]|\\\\)/.test(text);
159
- }
160
164
  function waitsForApproval(store, taskId) {
161
165
  const state = store.getTask(taskId)?.state;
162
166
  const scope = store.getScope(taskId);
@@ -174,7 +178,7 @@ function requestsOffer(store, taskId, who, now, channel, root, said) {
174
178
  const head = `${waiting.length === 1 ? `A youiyoux ${what} waits` : `${waiting.length} youiyoux ${what}s wait`} for you · ${projectLabel(repo)}`;
175
179
  const mode = chatApproveMode(store, repo, who.name, now, channel);
176
180
  const items = waiting.map((id, index) => ({ n: index + 1, taskId: id, name: title(store, id), listed: null, why: null }));
177
- const block = (item) => `${item.n}. ${item.name}\n${scopeTermsText(store.getScope(item.taskId))}`;
181
+ const block = (item) => `${item.n}. ${item.name}\n${wholeTermsText(store, item.taskId, store.getScope(item.taskId), now)}`;
178
182
  const compose = () => {
179
183
  const shown = items.filter(one => one.listed !== null);
180
184
  const open = items.filter(one => one.listed === null);
@@ -201,11 +205,11 @@ function requestsOffer(store, taskId, who, now, channel, root, said) {
201
205
  item.why = "it needs your password in Toolroll";
202
206
  continue;
203
207
  }
204
- if (privateWords(scopeTermsText(plan.scope))) {
208
+ if (privateWords(block(item))) {
205
209
  item.why = "its terms name a key or a folder on this computer";
206
210
  continue;
207
211
  }
208
- item.listed = { taskId: item.taskId, digest: shownTermsDigest(plan.scope) };
212
+ item.listed = { taskId: item.taskId, digest: wholeCardDigest(store, item.taskId, plan.scope, now) };
209
213
  if (!shownWhole(compose(), channel)) {
210
214
  item.listed = null;
211
215
  item.why = TOO_LONG;
@@ -248,11 +252,11 @@ function requestsNow(store, tokenTask, digest, who, now, channel, root) {
248
252
  skipped.push({ name, why: "it needs your password in Toolroll" });
249
253
  continue;
250
254
  }
251
- if (shownTermsDigest(plan.scope) !== one.digest) {
255
+ if (wholeCardDigest(store, one.taskId, plan.scope, now) !== one.digest) {
252
256
  skipped.push({ name, why: "its terms changed since this card was sent" });
253
257
  continue;
254
258
  }
255
- ready.push({ taskId: one.taskId, name, digest: one.digest, plan });
259
+ ready.push({ taskId: one.taskId, name, digest: shownTermsDigest(plan.scope), plan });
256
260
  }
257
261
  return { ok: true, ready, skipped };
258
262
  }
@@ -286,7 +290,7 @@ function approveRequests(store, seat, who, tokenTask, digest, target, body, mess
286
290
  return { ack, edit: { text: `${body}\n\n${said}`, rows: skipped.length === 0 ? [] : linksFor(target), tokens: [] } };
287
291
  return { ack, edit: { text: again.text ?? said, ...mintDecideButtons(store, seat, target, again, now, message) } };
288
292
  }
289
- export function planCardText(store, taskId, scope, root, channel) {
293
+ export function planCardText(store, taskId, scope, root, _channel) {
290
294
  const ref = store.lookupRef(taskId);
291
295
  const artifact = ref === null ? null : store.latestPlanArtifact(ref.id);
292
296
  let milestones = [];
@@ -302,44 +306,34 @@ export function planCardText(store, taskId, scope, root, channel) {
302
306
  }
303
307
  }
304
308
  const bullets = (items, cap) => [...items.slice(0, cap).map(one => `• ${phoneText(one, 120)}`), ...(items.length > cap ? [`• and ${items.length - cap} more`] : [])];
305
- const goal = scope.goal.split("\n").filter(one => one.trim() !== "").slice(0, 2).map(one => phoneText(one, 160));
306
- const allowing = [permissionPlainWords(scope.profile), scope.budgetMicrousd === null ? "no attempt limit" : `up to ${money(scope.budgetMicrousd)} per attempt`]
307
- .filter((one) => one !== null);
309
+ const goal = scope.goal.split("\n").filter(one => one.trim() !== "");
308
310
  const changed = routeChangeOf(store, taskId);
309
- const chain = chainTermsLines(scope);
310
- if (channel === "telegram") {
311
- return [
312
- `Plan ready: ${title(store, taskId)}`,
313
- ...(changed === null ? [] : [changed]),
314
- ...chain,
315
- `Starting allows: ${allowing.join(" · ")}`,
316
- "",
317
- ...goal,
318
- ...(scope.touches.length > 0 ? [`Only in: ${scope.touches.slice(0, 6).map(one => phoneText(one, 80)).join(", ")}${scope.touches.length > 6 ? ", …" : ""}`] : ["Any file in the project."]),
319
- "",
320
- "Done when:",
321
- ...(scope.acceptance.length > 0 ? bullets(scope.acceptance.map(one => one.statement), 5) : ["You decide when you review the result."]),
322
- ...(milestones.length > 0 ? ["", "Steps:", ...bullets(milestones, 3)] : []),
323
- ].join("\n");
324
- }
311
+ const summary = approvalSummaryOf(scope, summaryContextOf(store, taskId, scope, new Date()));
312
+ const shown = (one) => !one.fields.some(field => field === "goal" || field === "acceptance");
325
313
  return [
326
314
  `Plan ready: ${title(store, taskId)}`,
327
315
  ...(changed === null ? [] : [changed]),
328
- ...chain,
316
+ ...(summary.revision === null ? [] : [summary.revision, ...summary.revisionChanges.map(one => `${one.label}: ${one.words}`)]),
317
+ ...summary.warnings.map(one => one.words),
329
318
  "",
330
319
  ...goal,
331
- "",
332
- "Changes:",
333
- ...(milestones.length > 0 ? bullets(milestones, 5) : []),
334
- ...(scope.touches.length > 0 ? [`Only in: ${scope.touches.slice(0, 6).map(one => phoneText(one, 80)).join(", ")}${scope.touches.length > 6 ? ", …" : ""}`] : milestones.length > 0 ? [] : ["Any file in the project."]),
320
+ ...(milestones.length > 0 ? ["", "Steps:", ...bullets(milestones, 3)] : []),
335
321
  "",
336
322
  "Done when:",
337
- ...(scope.acceptance.length > 0 ? bullets(scope.acceptance.map(one => one.statement), 5) : ["You decide when you review the result."]),
323
+ ...(scope.acceptance.length > 0 ? scope.acceptance.map(one => `• ${one.statement} (${one.evidence.map(kind => EVIDENCE_WORDS[kind] ?? kind).join(", ")})`) : ["You decide when you review the result."]),
338
324
  "",
339
- `You're allowing: ${allowing.join(" · ")}`,
325
+ ...[...summary.decisions.filter(shown), ...summary.differs].flatMap(one => [`${one.label}: ${one.words}`, ...(one.lines ?? [])]),
326
+ ...(summary.usual.length === 0 ? [] : [`${summary.usualLabel}: ${summary.usual.map(one => `${one.label.toLowerCase()} ${one.words}`).join(" · ")}`]),
340
327
  ].join("\n");
341
328
  }
342
329
  export function decideOffer(store, target, who, now, channel, root) {
330
+ const offer = decideOfferUnchecked(store, target, who, now, channel, root);
331
+ if (offer === null || !outboundPrivate(offerFields(offer)))
332
+ return offer;
333
+ const link = decideFallbackLink(target);
334
+ return { text: `${title(store, target.taskId)}\n\n${PRIVATE_CARD}`, rows: link === null ? [] : [[link]] };
335
+ }
336
+ function decideOfferUnchecked(store, target, who, now, channel, root) {
343
337
  const ref = store.lookupRef(target.taskId);
344
338
  if (ref === null || ref.repo === null || !who.repos.includes(ref.repo))
345
339
  return null;
@@ -369,7 +363,7 @@ export function decideOffer(store, target, who, now, channel, root) {
369
363
  if (passwordOnlySeal(plan.scope)) {
370
364
  let head;
371
365
  try {
372
- head = release ? releaseCardOf(store, plan.scope, plan.digest, { profile: permissionPlainWords }).short.split("\n").slice(0, 3)
366
+ head = release ? releaseCardOf(store, plan.scope, plan.digest, { profile: permissionPlainWords, chat: true }).short.split("\n").slice(0, 3)
373
367
  : planCardText(store, target.taskId, plan.scope, root, channel).split("\n").slice(0, 1);
374
368
  }
375
369
  catch {
@@ -499,7 +493,7 @@ export function releaseInChat(store, taskId, approver, now, channel, seat, root)
499
493
  return { ok: false, why: "A release is approved only in your private chat with Toolroll." };
500
494
  let card;
501
495
  try {
502
- card = releaseCardOf(store, plan.scope, plan.digest, { profile: permissionPlainWords });
496
+ card = releaseCardOf(store, plan.scope, plan.digest, { profile: permissionPlainWords, chat: true });
503
497
  }
504
498
  catch {
505
499
  return { ok: false, why: "This release's terms can't be shown here, so you approve it in Toolroll." };
@@ -620,6 +614,61 @@ function cardBody(shown) {
620
614
  return at >= 0 && (QUESTION_STARTS.some(start => shown.startsWith(start, at + 2)) || /^Approve \d+ tasks\?/.test(shown.slice(at + 2))) ? shown.slice(0, at) : shown;
621
615
  }
622
616
  export function applyDecideTap(store, seat, input) {
617
+ if (input.token.startsWith("d:")) {
618
+ const solo = soloChatSeatRefusal(store, { provider: seat.channel, binding: seat.binding, approver: seat.approver });
619
+ if (solo !== null)
620
+ return { ack: solo, ignored: true };
621
+ }
622
+ const outcome = decideTapUnchecked(store, seat, input);
623
+ if (outcome === null)
624
+ return null;
625
+ const fitted = (card) => {
626
+ if (card.tokens.length === 0 || fitsOneMessage(card.text, seat.channel))
627
+ return card;
628
+ dropDecideTokens(store, card.tokens, input.now);
629
+ const target = decideTargetOfToken(store, input.token);
630
+ const why = `This doesn't fit in one ${CHANNEL_NAMES[seat.channel]} message, so you approve it in Toolroll. Nothing was done.`;
631
+ return { text: `${cardBody(input.shown).slice(0, 1_000)}\n\n${why}`, rows: target === null ? [] : linksFor(target), tokens: [] };
632
+ };
633
+ if (outboundPrivate(tapFields(outcome))) {
634
+ for (const card of [outcome.edit, outcome.unsent])
635
+ if (card !== undefined)
636
+ dropDecideTokens(store, card.tokens, input.now);
637
+ if (outcome.prompt !== undefined && outcome.prompt.id > 0)
638
+ store.handle.prepare("UPDATE chat_decide_prompt SET consumed_at = ? WHERE id = ? AND consumed_at IS NULL").run(input.now.toISOString(), outcome.prompt.id);
639
+ const target = decideTargetOfToken(store, input.token);
640
+ return { ack: "Review it in Toolroll.", ...(outcome.merge === undefined ? {} : { merge: outcome.merge }),
641
+ edit: { text: `${target === null ? "" : `${title(store, target.taskId)}\n\n`}${PRIVATE_CARD} Open it there to see where it stands.`,
642
+ rows: target === null ? [] : linksFor(target), tokens: [] } };
643
+ }
644
+ return { ...outcome, ...(outcome.edit === undefined ? {} : { edit: fitted(outcome.edit) }), ...(outcome.unsent === undefined ? {} : { unsent: fitted(outcome.unsent) }) };
645
+ }
646
+ function tapFields(outcome) {
647
+ const cards = [outcome.edit, outcome.unsent].filter((one) => one !== undefined);
648
+ return [outcome.ack, ...cards.flatMap(card => [card.text, ...card.rows.flat().map(button => "link" in button ? `${button.label} ${button.link.label}` : button.label)]),
649
+ ...(outcome.file === undefined ? [] : [outcome.file.name, outcome.file.text]), ...(outcome.prompt === undefined ? [] : [outcome.prompt.text])];
650
+ }
651
+ function offerFields(offer) {
652
+ return [...(offer.text === null ? [] : [offer.text]), ...(offer.file === undefined ? [] : [offer.file.name, offer.file.text]),
653
+ ...offer.rows.flat().map(one => one.label ?? "")];
654
+ }
655
+ const PRIVATE_CARD = "Its words name a key or a folder on this computer, so you review it in Toolroll.";
656
+ export function fitsOneMessage(text, channel) {
657
+ switch (channel) {
658
+ case "telegram": return text.length <= 4_000;
659
+ case "slack": return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").length <= PLATFORM_LIMITS.slack;
660
+ case "discord": return discordPlain(text).length <= PLATFORM_LIMITS.discord;
661
+ case "teams": return text.length <= PLATFORM_LIMITS.teams;
662
+ }
663
+ }
664
+ function decideTargetOfToken(store, token) {
665
+ const raw = store.handle.prepare("SELECT * FROM chat_decide_action WHERE token = ?").get(token);
666
+ if (raw === undefined)
667
+ return null;
668
+ const read = readAction(raw);
669
+ return read.ok ? targetOf(read.value) : null;
670
+ }
671
+ function decideTapUnchecked(store, seat, input) {
623
672
  const raw = input.token.startsWith("d:") ? store.handle.prepare("SELECT * FROM chat_decide_action WHERE token = ?").get(input.token) : undefined;
624
673
  if (raw === undefined)
625
674
  return null;
@@ -678,8 +727,11 @@ export function applyDecideTap(store, seat, input) {
678
727
  }
679
728
  if (row.phase === "offer") {
680
729
  if (row.act === "changes") {
730
+ const asked = `${WHAT_SHOULD_CHANGE} Your next message is the feedback for "${name}".`;
731
+ if (privateWords(asked))
732
+ return { ack: WHAT_SHOULD_CHANGE, prompt: { id: 0, text: asked } };
681
733
  const id = openDecidePrompt(store, seat, row.taskId, row.run ?? 0, row.digest, now);
682
- return { ack: WHAT_SHOULD_CHANGE, prompt: { id, text: `${WHAT_SHOULD_CHANGE} Your next message is the feedback for "${name}".` } };
734
+ return { ack: WHAT_SHOULD_CHANGE, prompt: { id, text: asked } };
683
735
  }
684
736
  if (row.act === "not-now") {
685
737
  spend();
@@ -714,9 +766,12 @@ export function applyDecideTap(store, seat, input) {
714
766
  const spec = { act: "approve", run: null, digest: row.digest };
715
767
  const yes = mint(store, seat, input.message, spec, row.taskId, "yes", now);
716
768
  const later = mint(store, seat, input.message, { act: "not-now", run: null, digest: row.digest }, row.taskId, "offer", now);
717
- if (plan.whole && scopeTermsText(plan.scope).length > PLATFORM_LIMITS[seat.channel] - ROOM)
769
+ const text = `${plan.whole ? `${name}\n\n${wholeTermsText(store, row.taskId, plan.scope, now)}` : planCardText(store, row.taskId, plan.scope, input.root, seat.channel)}\n\n${QUESTIONS.approve(name)} This approves exactly this plan.`;
770
+ if (!fitsOneMessage(text, seat.channel) || (plan.whole && !shownAsWritten(text, seat.channel)))
718
771
  return stale(`This plan's ${TOO_LONG}, so you approve it in Toolroll.`);
719
- return { ack: "Read the plan, then approve.", edit: { text: `${plan.whole ? `${name}\n\n${scopeTermsText(plan.scope)}` : planCardText(store, row.taskId, plan.scope, input.root, seat.channel)}\n\n${QUESTIONS.approve(name)} This approves exactly this plan.`,
772
+ if (privateWords(text))
773
+ return stale("Its terms name a key or a folder on this computer, so you review it in Toolroll.");
774
+ return { ack: "Read the plan, then approve.", edit: { text,
720
775
  rows: [[{ label: DECIDE_LABELS.approve, token: yes }], [{ label: DECIDE_LABELS.edit, link: { label: DECIDE_LABELS.edit, path: chatControlHref("approval", row.taskId) } }, { label: DECIDE_LABELS["not-now"], token: later }]], tokens: [yes, later] } };
721
776
  }
722
777
  spend();
@@ -774,8 +829,8 @@ export function applyDecideTap(store, seat, input) {
774
829
  return notDone("This is a release: approve it from its release card.");
775
830
  if (passwordOnlySeal(plan.scope))
776
831
  return notDone(needsFullCard(plan.scope));
777
- const words = scopeTermsText(plan.scope);
778
- if (plan.whole && (plan.digest !== row.digest || words.length > PLATFORM_LIMITS[seat.channel] - ROOM))
832
+ const words = wholeTermsText(store, row.taskId, plan.scope, now);
833
+ if (plan.whole && (plan.digest !== row.digest || !fitsOneMessage(words, seat.channel) || privateWords(words)))
779
834
  return notDone("this plan changed. Open it in Toolroll.");
780
835
  const approved = approve(store, row.taskId, who.name, now, plan.scope.digest, "", {}, undefined, { modeDigest: plan.modeDigest, shown: plan.whole ? { expect: cardTermsDigest(words), terms: words } : null });
781
836
  if (!approved.ok && approved.reason === "second-approver")
@@ -4,6 +4,7 @@ import { ChatCore, chatHash } from "./chat-core.js";
4
4
  import { ChatMessages } from "./chat-messages.js";
5
5
  import { unsentPart } from "./chat-message-states.js";
6
6
  import { readChatPart, savedChatEventBody, savedChatPart } from "./contracts/chat-content.js";
7
+ import { WITHHELD } from "./outbound-privacy.js";
7
8
  export { savedChatPart, chatHash };
8
9
  const DAY_MS = 86_400_000;
9
10
  export class ChatState extends ChatMessages {
@@ -178,3 +179,4 @@ export class ChatDeliveryError extends Error {
178
179
  this.permanent = permanent;
179
180
  }
180
181
  }
182
+ export const withheldPart = () => new ChatDeliveryError(WITHHELD, 0, false, true);
@@ -3,6 +3,7 @@ import { applyChatAskTap, chatAskText } from "./chat-ask.js";
3
3
  import { channelRepos, resolveChannelLead, proposalPreview, proposalOutcomeText, confirmedLink, confirmedCardText, replyContextFor, mirrorToTaskChat, focusContextFor, taskInCeiling, tooLongText, } from "./chat-channel.js";
4
4
  import { LEAD_MESSAGE_MAX_CHARS, leadFailureText, runLeadTurn } from "./lead.js";
5
5
  import { shapeReplyParts } from "./reply-shape.js";
6
+ import { checkedChunks, taskSubject } from "./outbound-privacy.js";
6
7
  import { warmTurn } from "./chat-warmth.js";
7
8
  import { openChatLive, planWithLive, settleLive } from "./chat-live.js";
8
9
  import { confirmLeadProposal, dismissLeadProposal, } from "./lead-doors.js";
@@ -459,7 +460,7 @@ export async function processChatEvent(options) {
459
460
  const reply = store
460
461
  .listLeadMessages(turn.thread, 200)
461
462
  .find((message) => message.turn === turn.id && message.role === "assistant")?.text ?? "The reply is no longer in the saved thread.";
462
- const shapedParts = shapeReplyParts(reply, options.partSize ?? CHAT_PART_SIZE, { asked: text, appOrigin: options.origin() });
463
+ const shapedParts = checkedChunks(reply, shapeReplyParts(reply, options.partSize ?? CHAT_PART_SIZE, { asked: text, appOrigin: options.origin() }), taskSubject(store, about?.task));
463
464
  const parts = (shapedParts.length > 0 ? shapedParts : splitChatText("")).map((text) => (about === null ? { text, voice: true } : { text, voice: true, task: about.task, ...(about.run === null ? {} : { run: about.run }) }));
464
465
  const ask = store.leadAsk(turn.id);
465
466
  if (ask !== null)
@@ -704,7 +705,7 @@ export async function planRoomMessages(options) {
704
705
  const parts = [];
705
706
  if (text !== null) {
706
707
  if (message.role === "assistant")
707
- for (const part of shapeReplyParts(text, options.partSize ?? CHAT_PART_SIZE, { appOrigin: options.origin() }))
708
+ for (const part of checkedChunks(text, shapeReplyParts(text, options.partSize ?? CHAT_PART_SIZE, { appOrigin: options.origin() })))
708
709
  parts.push({ text: part, voice: true, channel: room.chat });
709
710
  else
710
711
  parts.push({ text, channel: room.chat });
package/dist/chat-live.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createLiveReply, createLiveSender, LIVE_STATUS } from "./live-reply.js";
2
2
  import { renderReply, shapeReplyParts } from "./reply-shape.js";
3
+ import { checkedChunks } from "./outbound-privacy.js";
3
4
  import { unsent } from "./chat-message-states.js";
4
5
  export const LIVE_WORDS = {
5
6
  working: "Working on it…",
@@ -42,7 +43,7 @@ export function liveText(view, platform, limit, shape = {}) {
42
43
  case "writing": {
43
44
  const marker = italic(platform, view.status === LIVE_STATUS.writing ? LIVE_WORDS.notFinal : `${view.status} ${LIVE_WORDS.notFinal}`);
44
45
  const room = Math.max(200, limit - marker.length - LIVE_WORDS.continues.length - 8);
45
- const windows = shapeReplyParts(view.text, room, shape, shaped => renderReply(shaped, platform).length);
46
+ const windows = checkedChunks(view.text, shapeReplyParts(view.text, room, shape, shaped => renderReply(shaped, platform).length));
46
47
  const first = renderReply(windows[0] ?? "", platform).slice(0, room);
47
48
  const more = windows.length > 1 ? `\n\n${italic(platform, LIVE_WORDS.continues)}` : "";
48
49
  return `${first}${more}\n\n${marker}`;
@@ -3,6 +3,7 @@ import { chatApproveMode, effectiveChatApproval } from "./chat-approval.js";
3
3
  import { requestTaskStop, resumeTaskStop, taskControlOf } from "./task-control.js";
4
4
  import { authorizePlanUnderMode } from "./plan-auto.js";
5
5
  import { fileAddTestsTask, requestFollowUpChecks } from "./result-follow-ups.js";
6
+ import { soloChatSeatRefusal } from "./install-mode.js";
6
7
  export const CHAT_TASK_ACTIONS = {
7
8
  stop: { label: "Stop task", detail: "Pauses this task once the run acknowledges the stop. Saved work remains; other tasks continue." },
8
9
  resume: { label: "Resume task", detail: "Lifts this stop’s hold and continues from saved work. Other holds and approval requirements still apply." },
@@ -35,6 +36,11 @@ export function chatTaskRun(store, task, operation, now) {
35
36
  return (operation === "stop" && control.kind === "stop") || (operation === "resume" && control.kind === "paused") ? control.run : null;
36
37
  }
37
38
  export function applyChatTaskAction(store, who, payload, now, web, controls = {}) {
39
+ if (controls.via !== undefined && controls.via !== "web" && controls.via !== "cli") {
40
+ const solo = soloChatSeatRefusal(store, { provider: controls.via, binding: controls.binding, approver: who.name });
41
+ if (solo !== null)
42
+ return { ok: false, message: solo };
43
+ }
38
44
  const task = payload["task"], operation = payload["operation"];
39
45
  if (typeof task !== "string" || !isChatTaskAction(operation))
40
46
  return { ok: false, message: "This task action is incomplete." };
@@ -14,7 +14,7 @@ export const CHECK_CONTEXT_CAPTURE = "release check context v1";
14
14
  export const CHECK_ARTIFACT_CAP = CHECK_REPORT_MAX_BYTES;
15
15
  export const HARNESS_FILES = Object.freeze([
16
16
  "scripts/release-check.mjs", "scripts/release-check-ci.mjs", "scripts/upgrade-rule.mjs", "scripts/suite-lifecycle.mjs", "scripts/provider-gate.mjs",
17
- "scripts/e2e-parallel.mjs", "scripts/e2e-kit.mjs", "scripts/upgrade-path.mjs", "scripts/check-results.mjs",
17
+ "scripts/e2e-parallel.mjs", "scripts/e2e-kit.mjs", "scripts/isolated-env.mjs", "scripts/upgrade-path.mjs", "scripts/check-results.mjs",
18
18
  "vitest.config.ts", "test/attacks/vitest.config.ts",
19
19
  "test/setup-state.ts", "test/fresh-store.ts", "test/temp-root.ts", "test/ensure-build.ts", "test/release-reporter.ts",
20
20
  ]);