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
@@ -1,9 +1,9 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { isAcpProvider } from "./acp-agents.js";
3
- import { currentLocalOwner, localModeOn, localOwnerInFlight, localOwnerStandsNow } from "./local-owner.js";
3
+ import { currentLocalOwner, localActNow, localModeOn, localOwnerInFlight, localOwnerStandsNow } from "./local-owner.js";
4
4
  import { INSTALLATION_SCOPE, resolvePhaseAgent, resolveRouteCandidates } from "./agentconfig.js";
5
5
  import { seenModels } from "./model-catalog.js";
6
- import { passwordlessOn } from "./passwordless.js";
6
+ import { sessionStandsIn, soloNow } from "./install-mode.js";
7
7
  import { exactModelId, recommendRoute, routeProblems } from "./phase-routing.js";
8
8
  import { liveEarnedRules } from "./route-store.js";
9
9
  import { isProviderId, validateSpec } from "./provider.js";
@@ -252,7 +252,10 @@ function applyLocked(store, input, authority, now) {
252
252
  {
253
253
  {
254
254
  const account = store.accountOf(authority.actor);
255
- const standsNow = PERSON_PROOFS.has(authority.method) && ((authority.method !== "session" && authority.method !== "cli-login") || passwordlessOn(store));
255
+ const local = authority.method === "local-owner" ? localActNow(store, "change-models") : null;
256
+ const standsNow = authority.method === "local-owner"
257
+ ? local !== null && local.account === authority.actor && soloNow(store)
258
+ : PERSON_PROOFS.has(authority.method) && ((authority.method !== "session" && authority.method !== "cli-login") || sessionStandsIn(store));
256
259
  if (account === null || account.revokedAt !== null || account.generation !== authority.generation || !store.isInstanceOperator(authority.actor) || !authority.live() || !standsNow) {
257
260
  throw new Refused({ ok: false, reason: "authority", problem: "Only an instance operator, signed in now, can change models." });
258
261
  }
@@ -369,6 +372,7 @@ export function agentPresetChange(agent) {
369
372
  export function defaultAgentOf(provider) {
370
373
  return provider === "claude-subscription" ? "claude" : provider === "codex-subscription" ? "codex" : null;
371
374
  }
375
+ export const FIRST_TASK_AGENT_FACT = "first-task-agent";
372
376
  export function fillDefaultRouting(store, agent, actor, door, now) {
373
377
  const refused = (reason, problem) => ({ filled: false, reason, problem });
374
378
  return store.transact(() => {
@@ -378,13 +382,13 @@ export function fillDefaultRouting(store, agent, actor, door, now) {
378
382
  return refused("authority", "Only this computer's owner, choosing an agent now, starts its models.");
379
383
  }
380
384
  }
381
- else if (!localModeOn(store)) {
385
+ else if (door.kind === "first-start" && !localModeOn(store)) {
382
386
  return refused("authority", "Only a laptop install's first start chooses its models by itself.");
383
387
  }
384
388
  const anyRow = store.handle.prepare("SELECT 1 FROM phase_config UNION ALL SELECT 1 FROM phase_tier_config UNION ALL SELECT 1 FROM phase_tier_alternate LIMIT 1").get();
385
389
  if (anyRow !== undefined)
386
390
  return refused("already-set", "Models are already chosen here.");
387
- if (door.kind === "first-start" && store.handle.prepare("SELECT 1 FROM models_generation LIMIT 1").get() !== undefined) {
391
+ if (door.kind !== "local-owner" && store.handle.prepare("SELECT 1 FROM models_generation LIMIT 1").get() !== undefined) {
388
392
  return refused("already-set", "Models were chosen here before.");
389
393
  }
390
394
  store.handle.exec("SAVEPOINT default_routing");
@@ -398,9 +402,11 @@ export function fillDefaultRouting(store, agent, actor, door, now) {
398
402
  else
399
403
  store.setPhaseTierConfig(INSTALLATION_SCOPE, slot.phase, slot.tier, to.provider, to.model, actor, now);
400
404
  store.recordAction({ at: now.toISOString(), actor, repo: null, taskId: null, runId: null, action: ACTION_OF(slot), outcome: "changed", source: "policy",
401
- detail: `not set → ${pairWords(to)} (${AGENT_PRESETS[agent].label}, the default for the agent chosen)` });
405
+ detail: `not set → ${pairWords(to)} (${AGENT_PRESETS[agent].label}, ${door.kind === "detected" ? "the default for the agent found signed in on this computer" : "the default for the agent chosen"})` });
402
406
  rows++;
403
407
  }
408
+ if (door.kind === "detected")
409
+ store.recordInstallationFact(FIRST_TASK_AGENT_FACT, agent, now);
404
410
  const checked = checkScope(store, null);
405
411
  if (checked.kind !== "ok") {
406
412
  store.handle.exec("ROLLBACK TO default_routing");
package/dist/needs-you.js CHANGED
@@ -216,6 +216,7 @@ export const RUN_REASON_WORDS = {
216
216
  interrupted: "the attempt was interrupted",
217
217
  orphaned: "the attempt lost its builder",
218
218
  "retryable-infra": "a temporary problem on the machine stopped it",
219
+ "agent-error": "the agent stopped with an error",
219
220
  unknown: "the attempt stopped unexpectedly",
220
221
  "spawn-failed": "the agent process could not start",
221
222
  "provider-protocol": "the agent's reply could not be read",
@@ -286,6 +287,7 @@ const STOP_SUGGESTIONS = {
286
287
  "moved-head": "Retry: the next attempt starts from where the branch is now.",
287
288
  "moved-branch": "Retry: the next attempt starts from where the branch is now.",
288
289
  "retryable-infra": "Retry as it is.",
290
+ "agent-error": "Read what the agent said, change what it needs, then retry.",
289
291
  interrupted: "Retry as it is.",
290
292
  orphaned: "Retry as it is.",
291
293
  capability: "Add what the project is missing, then retry.",
@@ -1,4 +1,15 @@
1
1
  import { createHash } from "node:crypto";
2
+ import { envTwins } from "./names.js";
3
+ import { outboundPrivate, safeWords } from "./outbound-privacy.js";
4
+ export function notificationCommandEnv(row) {
5
+ const withheld = outboundPrivate([row.subject, row.body]);
6
+ return {
7
+ ...envTwins("KIND", row.kind),
8
+ ...envTwins("SUBJECT", withheld ? safeWords({ project: row.project }) : row.subject),
9
+ ...envTwins("BODY", withheld ? "" : row.body),
10
+ ...envTwins("DEDUPE_KEY", row.dedupeKey),
11
+ };
12
+ }
2
13
  export function notificationDestination(kind, target) {
3
14
  return `${kind}:${createHash("sha256").update(target).digest("hex")}`;
4
15
  }
package/dist/operate.js CHANGED
@@ -1,10 +1,12 @@
1
+ import { FLEXIBLE_CANDIDATE_FIXED, FLEXIBLE_FILED_PREFIX, flexibleMergeRefusal } from "./flexible-merge-guard.js";
2
+ import { flexibleArmedPass } from "./flexible-ship.js";
1
3
  import { runCardCommand } from "./card-cli.js";
2
4
  import { mintSecret } from "./secret-mint.js";
3
5
  import { ACP_AGENTS, ACP_PROVIDER_IDS, isAcpProvider, isKeyedProvider } from "./acp-agents.js";
4
6
  import { inspectAcpAgent } from "./acp-inspect.js";
5
7
  import { runAcpChecks } from "./acp-check.js";
6
8
  import { verifyLaunch } from "./acp-attest.js";
7
- import { notificationClaimHeld, claimNotifications, finalizeNotification, notificationDestination } from "./notification-delivery.js";
9
+ import { notificationClaimHeld, claimNotifications, finalizeNotification, notificationCommandEnv, notificationDestination } from "./notification-delivery.js";
8
10
  import { adapterPolicy } from "./server/route-policy.js";
9
11
  import { UNSENT_REPLY_MS } from "./telegram-settings.js";
10
12
  import { checkPublicCommand } from "./public-check.js";
@@ -46,16 +48,16 @@ import { runTokensCommand } from "./tokens-cli.js";
46
48
  import { startTokenNotices } from "./token-notices.js";
47
49
  import { liftAuthPause, openAuthPauses, signInGate, signInWords, startSignInProbes } from "./provider-auth.js";
48
50
  import { createConnectionChecker } from "./provider-connection.js";
49
- import { checkIntegrations, integrationsBrokenLine, integrationsNow, renderIntegrations } from "./integrations.js";
51
+ import { agentsSignedOutLines, checkIntegrations, integrationsBrokenLine, integrationsNow, renderIntegrations } from "./integrations.js";
50
52
  import { buildHandoff, handoffLines, loginAccount, runOnboard } from "./agent-onboard.js";
51
53
  import { backupFiles, backupFolderOf, backupOwner, backupNow, restoreDatabase, startBackups } from "./backup.js";
52
54
  import { startLiveBackups } from "./live-backup.js";
53
55
  import { pushLimitSink } from "./provider-limits.js";
54
- import { heuristicSizing, installFilingSizer, ownerSizer, refineFiledSizing, settleSizings } from "./task-sizing.js";
56
+ import { filingSizing, installFilingSizer, ownerSizer, refineFiledSizing, setTaskSizing, settleSizings, taskSizingSetting } from "./task-sizing.js";
55
57
  import { tierLines, tierReport } from "./tier-report.js";
56
58
  import { savingsLines, savingsReportOrError } from "./route-savings.js";
57
59
  import { limitsView } from "./limits-ui.js";
58
- import { startCodexLimits } from "./codex-limits.js";
60
+ import { codexSignedInNow, startCodexLimits } from "./codex-limits.js";
59
61
  import { packageVersion, startMonitoring, targetOf } from "./monitoring.js";
60
62
  import { origin, readMonitoring } from "./monitoring-settings.js";
61
63
  import { logEvent } from "./log.js";
@@ -87,6 +89,7 @@ import { scheduledTidy } from "./memory-tidy.js";
87
89
  import { CI_READ_EVERY_MS, ciCursorKey, ciRepositoriesOf, observeCiAttempts } from "./flaky-ci.js";
88
90
  import { runKnowledgeApply, runKnowledgeCommand } from "./knowledge-cli.js";
89
91
  import { FLOWS_VALUE_FLAGS, runFlowsCommand } from "./flows-cli.js";
92
+ import { approvalSummaryFor, approvalSummaryOf, describeScope, summaryContextOf } from "./approval-summary.js";
90
93
  import { runAssignmentCommand } from "./assignment-adapters.js";
91
94
  import { applyProjectProfile, runProjectCommand } from "./project-cli.js";
92
95
  import { passwordFreeOwner, passwordFreeShell, passwordFreeShellWords, proveTaskBuildsStopped, pullRequestLines, runLocalCompletion, runLocalRevision, runTaskMergeCommand, runTaskOutcomeCommand } from "./task-outcome-cli.js";
@@ -109,7 +112,7 @@ import { addRepos, removeRepos, updateRepos, loadRepos, loadProjectRegistry, upd
109
112
  import { deleteProject, holdingsWords, projectHoldings, projectRunning } from "./project-delete.js";
110
113
  import { pushPass } from "./push.js";
111
114
  import { chmodSync, closeSync, constants as fsConstants, existsSync, fstatSync, fsyncSync, mkdirSync, openSync, readFileSync, readSync, realpathSync, renameSync, unlinkSync, writeSync, writeFileSync } from "node:fs";
112
- import { BRANCH_PREFIX, envTwins, envValue, existingOrFirst, taskBranches } from "./names.js";
115
+ import { BRANCH_PREFIX, envValue, existingOrFirst, taskBranches } from "./names.js";
113
116
  import { claimActor, currentActor, withActor } from "./actor.js";
114
117
  import { parseLeadToken } from "./api-tokens.js";
115
118
  import { MAX_NETWORK_HOSTS, normalizeHost } from "./egress.js";
@@ -200,7 +203,7 @@ import { serveMcp } from "./mcp.js";
200
203
  import { createInterface } from "node:readline";
201
204
  import { hashPassword } from "./scope.js";
202
205
  import { noticeDueOnce, CONTAINMENT_NOTICE_FACT, passwordResetRefusal, resetAccountPassword } from "./store.js";
203
- import { propose, approve, addApprover, authenticateAccount, authenticateApprover as passwordApprover, describeScope, approvalOf, hashToken as hashApproverToken, modeFilingCoverage, acceptanceLinesToInput, parseAcceptanceCriteria, splitAcceptanceRubric, rubricIsPlaceholder, isCommitSha, credentialProof, rememberedLogin, personApprovalOf } from "./scope.js";
206
+ import { propose, approve, addApprover, authenticateAccount, authenticateApprover as passwordApprover, approvalOf, hashToken as hashApproverToken, modeFilingCoverage, acceptanceLinesToInput, parseAcceptanceCriteria, splitAcceptanceRubric, rubricIsPlaceholder, isCommitSha, credentialProof, rememberedLogin, personApprovalOf } from "./scope.js";
204
207
  import { CHAT_APPROVE_ALL, presetTerms, modeTermsJson, modeDigestOf, modeTermsFromJson, modeWords, MODE_MAX_DAYS } from "./modes.js";
205
208
  import { WorktreePool } from "./worktree.js";
206
209
  import { baseStandingWords, freshBaseFor, taskBaseOf } from "./task-base.js";
@@ -232,7 +235,7 @@ import { fileGithubItem, readGithubItem } from "./github-import.js";
232
235
  import { runRelease } from "./release.js";
233
236
  import { releaseAdapters } from "./release-adapters.js";
234
237
  import { routeChangeOf, routeLegacyPlans } from "./route-change.js";
235
- import { passwordlessOn } from "./passwordless.js";
238
+ import { sessionStandsIn } from "./install-mode.js";
236
239
  import { parseDemoUrl, projectDemoUrl, saveProjectDemo } from "./project-demo.js";
237
240
  import { effectiveConcurrency, maySlotTake, parseProjectConcurrency, PROJECT_CONCURRENCY_DEFAULT, ProjectPasses, projectConcurrency, saveProjectConcurrency, savedProjectConcurrency } from "./project-concurrency.js";
238
241
  import { activeWebhookTargets, webhookPass, LEGACY_WEBHOOK_WARNING, loadWebhookTargets, effectivePrimary, isMessagingChannel, loadConsoleUrl, phoneOrigin, readUpConsoleUrl, saveConsoleUrl, savePrimary, UP_CONSOLE_FILE } from "./webhooks.js";
@@ -447,7 +450,7 @@ External trackers — build what a tracker nominates, under local approvals
447
450
  toolroll task scope <id> --goal <what success is>
448
451
  [--not <text>] [--touches a,b] [--budget-usd <n>]
449
452
  toolroll task approve <id> the yes — interactive, or
450
- --yes --digest <d> --as <you> --token <t> for scripts
453
+ --yes --digest <d> --terms <key> --as <you> --token <t>
451
454
  toolroll task requeue <id> --as <you> --token <t>
452
455
  exit a stall: incidents resolved,
453
456
  strikes cleared, queued again
@@ -578,6 +581,10 @@ Agents — which provider and model each phase runs on
578
581
  toolroll config set|clear|show quick-answers --as <you> --token <t>
579
582
  quick answers on (set) or off (clear): plain status questions go to a
580
583
  faster model on the Claude membership; changes stay on the main model
584
+ toolroll config set task-sizing on|off --as <you> --token <t>
585
+ size each new task with a quick model call (Claude Haiku, on your
586
+ plan) before you approve; off, the default, sizes from the words alone
587
+ and plans anything uncertain (config show task-sizing says which)
581
588
  toolroll chat --as <you> [--repo <path>…] [--say "…"] [--end]
582
589
  [--ceiling-usd <n>] [--json] (password at the prompt;
583
590
  --token <t> only for scripts — it lands in shell history)
@@ -708,7 +715,7 @@ export const SECRET_VALUE_FLAGS = new Set(["token", "password"]);
708
715
  export const OPERATE_VALUE_FLAGS = new Set([
709
716
  "key", "db", "runner", "ttl", "state", "flow", "on", "reason", "until", "id", "backend", "build", "from",
710
717
  "allow", "selector", "paths", "credentials", "repo", "token", "capacity", "agents",
711
- "goal", "not", "touches", "acceptance", "candidate", "by", "digest", "as", "branch", "pool", "base", "model", "turns",
718
+ "goal", "not", "touches", "acceptance", "candidate", "by", "digest", "terms", "as", "branch", "pool", "base", "model", "turns",
712
719
  "max", "cap", "probe", "kind", "expires", "cmd", "since", "repair-model",
713
720
  "choose", "choice", "claim", "revision", "note", "max-open-decisions", "name", "days", "publication", "auto-approve", "review-auto", "port", "host", "allow-host",
714
721
  "for", "tick-every", "bridge-every", "reconcile-every", "incarnation",
@@ -3444,13 +3451,14 @@ async function startConsole(options) {
3444
3451
  store: context.store, settings: () => readMonitoring(dirname(context.databaseFile)),
3445
3452
  instance: options.publicUrl ?? hostname(), version: packageVersion(),
3446
3453
  });
3454
+ const signIns = createConnectionChecker({ store: context.store });
3447
3455
  const besideConsole = [
3448
3456
  stopMonitoring,
3449
3457
  startBudgetAlerts(context.store),
3450
3458
  startTokenNotices(context.store),
3451
- startSignInProbes(context.store, createConnectionChecker()),
3459
+ startSignInProbes(context.store, signIns),
3452
3460
  startBackups(context.store, context.databaseFile),
3453
- startCodexLimits(context.store),
3461
+ startCodexLimits(context.store, () => codexSignedInNow(signIns)),
3454
3462
  startUpdateChecks(context.store, dirname(context.databaseFile), PACKAGE_VERSION, installMethod(context.installBin).updateCommand, context.releaseIo ?? {}),
3455
3463
  ];
3456
3464
  server.on("close", () => { for (const stop of besideConsole)
@@ -3541,6 +3549,7 @@ async function requeueTask(positional, flags, context) {
3541
3549
  "accepted-result": `${id}'s last result was accepted; change it through a revision, not a rerun`,
3542
3550
  published: `${id}'s last result is published; revise it through its pull request`,
3543
3551
  moved: `${id} changed since its page was read; read it again`,
3552
+ stale: `${id} changed since its page was read; read it again`,
3544
3553
  archived: `${id} is put away — restore it with \`toolroll task restore ${id}\` first`,
3545
3554
  };
3546
3555
  return fail(write, json, "task requeue", result.reason, why[result.reason], EXIT.refused);
@@ -3858,10 +3867,20 @@ async function agentsCommand(positional, flags, context) {
3858
3867
  const latest = store.acpChecksFor(id, 1)[0] ?? null;
3859
3868
  return { provider: id, name: ACP_AGENTS[id].name, installed: seen.found ? seen.realpath : null, checked, latestCheck: latest === null ? null : { id: latest.id, state: latest.state, model: latest.model, result: latest.result } };
3860
3869
  });
3870
+ const { detectAgents, detectionReport } = await import("./agent-detect.js");
3871
+ const { agentsReadOf } = await import("./engine-reads.js");
3872
+ const { acpCheckedHere, firstTaskRouted } = await import("./welcome-facts.js");
3873
+ const detection = await detectAgents({ routed: firstTaskRouted(store), acpChecked: acpCheckedHere(store), store,
3874
+ ...(context.easySeams?.check === undefined ? {} : { check: context.easySeams.check }) });
3875
+ const { version: _version, ...detected } = agentsReadOf(detection);
3861
3876
  if (json) {
3862
- write(envelopeJson({ ok: true, command: "agents", agents: rows }));
3877
+ write(envelopeJson({ ok: true, command: "agents", detected: { ...detected, tookMs: detection.tookMs }, agents: rows }));
3863
3878
  return EXIT.ok;
3864
3879
  }
3880
+ for (const line of detectionReport(detection))
3881
+ write(line);
3882
+ write("");
3883
+ write("Checks (agents that run over ACP)");
3865
3884
  for (const row of rows) {
3866
3885
  write(` ${row.name.padEnd(10)} ${row.installed === null ? "not installed" : row.installed}`);
3867
3886
  for (const one of row.checked)
@@ -4208,6 +4227,8 @@ async function configCommand(positional, flags, context) {
4208
4227
  const scope = repoGiven === undefined ? INSTALLATION_SCOPE : canonicalProject(repoGiven) ?? resolve(repoGiven);
4209
4228
  if (phase === "quick-answers")
4210
4229
  return quickAnswersConfig(action ?? "show", repoGiven !== undefined, flags, context);
4230
+ if (phase === "task-sizing")
4231
+ return taskSizingConfig(action ?? "show", positional[2], repoGiven !== undefined, flags, context);
4211
4232
  if (action === undefined || action === "show") {
4212
4233
  const installation = store.listPhaseConfig(INSTALLATION_SCOPE);
4213
4234
  const project = scope === INSTALLATION_SCOPE ? [] : store.listPhaseConfig(scope);
@@ -5474,6 +5495,18 @@ async function runWatchLoop(args) {
5474
5495
  reconciliationReady = true;
5475
5496
  if (recovered)
5476
5497
  wakes.poke();
5498
+ if (!stopping()) {
5499
+ try {
5500
+ const shipped = await flexibleArmedPass(store, { root: context.evidenceRoot, ...(context.publishExec === undefined ? {} : { exec: context.publishExec }) });
5501
+ if (shipped.ok && shipped.merged > 0)
5502
+ progress(`watch: merged ${shipped.merged} Flexible result(s) whose checks passed`);
5503
+ if (shipped.ok && shipped.cancelled > 0)
5504
+ progress(`watch: stopped ${shipped.cancelled} Flexible merge(s) whose terms no longer held`);
5505
+ }
5506
+ catch (error) {
5507
+ progress(`watch: the Flexible ship pass failed — ${describe(error)}; retrying on its next interval`);
5508
+ }
5509
+ }
5477
5510
  if (!stopping() && store.openedPublications().length > 0) {
5478
5511
  try {
5479
5512
  const checks = await observeChecks(store, {
@@ -6052,7 +6085,7 @@ async function onboardCommand(flags, context) {
6052
6085
  const loginFile = savedLoginFile(dirname(context.databaseFile));
6053
6086
  const gitRun = context.gitRunner ?? ((file, args, opts) => run(file, [...args], { ...(opts?.cwd === undefined ? {} : { cwd: opts.cwd }), timeoutMs: 10_000 }));
6054
6087
  const registryPath = registryPathOf(context);
6055
- const checker = createConnectionChecker({ home, env });
6088
+ const checker = createConnectionChecker({ home, env, store: context.store });
6056
6089
  const code = await runOnboard({
6057
6090
  write,
6058
6091
  json,
@@ -6874,7 +6907,7 @@ async function publishCommand(positional, flags, context) {
6874
6907
  return EXIT.refused;
6875
6908
  }
6876
6909
  const acting = await askCredentials(flags, context);
6877
- const verified = acting === null ? null : authenticateApprover(store, acting.name, acting.token, repo);
6910
+ const verified = acting === null ? null : credentialApprover(store, acting.name, acting.token, repo);
6878
6911
  if (acting === null || !verified?.ok)
6879
6912
  return refuseApprover(context, "publish setup", verified, "turning on pull requests takes --as <you> --token <your password>", acting?.name);
6880
6913
  savePublishing(store, plan, acting.name, settings, clock());
@@ -6923,7 +6956,7 @@ async function publishCommand(positional, flags, context) {
6923
6956
  return EXIT.refused;
6924
6957
  }
6925
6958
  const acting = await askCredentials(flags, context);
6926
- const verified = acting === null ? null : authenticateApprover(store, acting.name, acting.token);
6959
+ const verified = acting === null ? null : credentialApprover(store, acting.name, acting.token);
6927
6960
  if (acting === null || !verified?.ok)
6928
6961
  return refuseApprover(context, "publish grant", verified, "granting takes --as <you> --token <your password> — pushing your repos is a person's yes", acting?.name);
6929
6962
  const { name: asWho, token } = acting;
@@ -6973,6 +7006,9 @@ async function publishCommand(positional, flags, context) {
6973
7006
  const publication = store.openedPublications().find(one => one.prNumber === pr);
6974
7007
  if (publication === undefined)
6975
7008
  return fail(write, json, `publish ${action}`, "unknown", `no open publication holds PR #${pr}`, EXIT.refused);
7009
+ const flexibleHold = flexibleMergeRefusal(store, store.refForId(publication.taskRef)?.externalId ?? null, action === "merge" ? "publish-merge" : "publish-refire");
7010
+ if (flexibleHold !== null)
7011
+ return fail(write, json, `publish ${action}`, "flexible", flexibleHold, EXIT.refused);
6976
7012
  const intent = store.mergeIntentFor(publication.id);
6977
7013
  if (intent === null)
6978
7014
  return fail(write, json, `publish ${action}`, "no-intent", `PR #${pr} has no merge intent yet — the sweep writes one when a merge-capable grant covers it`, EXIT.refused);
@@ -7144,12 +7180,7 @@ async function outboxCommand(positional, flags, context) {
7144
7180
  }
7145
7181
  const sent = await run("sh", ["-lc", command], {
7146
7182
  timeoutMs: 30_000,
7147
- env: {
7148
- ...envTwins("KIND", one.kind),
7149
- ...envTwins("SUBJECT", one.subject),
7150
- ...envTwins("BODY", one.body),
7151
- ...envTwins("DEDUPE_KEY", one.dedupeKey),
7152
- },
7183
+ env: notificationCommandEnv(one),
7153
7184
  });
7154
7185
  if (sent.code === 0) {
7155
7186
  const receipt = sent.stdout.split("\n")[0]?.trim() ?? "";
@@ -7343,8 +7374,11 @@ async function statusCommand(positional, flags, context) {
7343
7374
  notifySecurityRelease(context.store, release, current, method.updateCommand, context.clock());
7344
7375
  const line = updateLine(release, current, method.updateCommand);
7345
7376
  const update = release === null ? {} : { update: { current, latest: release.version, security: release.security, updateCommand: method.updateCommand, url: release.url } };
7346
- const brokenIntegrations = await savedIntegrations(context).then(list => list.filter(one => one.state === "broken"), () => []);
7377
+ const savedList = await savedIntegrations(context).catch(() => []);
7378
+ const brokenIntegrations = savedList.filter(one => one.state === "broken");
7347
7379
  const brokenLine = integrationsBrokenLine(brokenIntegrations);
7380
+ const signedOutLines = agentsSignedOutLines(savedList);
7381
+ const signedOut = signedOutLines.length === 0 ? {} : { agentsSignedOut: signedOutLines };
7348
7382
  const integrations = brokenIntegrations.length === 0 ? {} : { integrations: { broken: brokenIntegrations.map(one => ({ key: one.key, name: one.name, fix: one.action.kind === "fix" ? one.action.words : null })) } };
7349
7383
  const waiting = waitingUpdate(context.databaseFile, run => context.store.stopQuiescenceProblem(run) !== null, context.clock());
7350
7384
  const updateWaiting = waiting === null ? {} : { updateWaiting: { app: waiting.app, version: waiting.version, stopped: waiting.stopped, run: waiting.run, on: waiting.on, action: waiting.action } };
@@ -7358,7 +7392,7 @@ async function statusCommand(positional, flags, context) {
7358
7392
  const laptop = { laptop: await laptopStatus(context.store, context.databaseFile, context.laptopSeams) };
7359
7393
  if (!laptop.laptop.running && laptop.laptop.background === "on" && !machineActing())
7360
7394
  await restartOwnBuilder(context.store, context.databaseFile, context.laptopSeams, context.clock()).catch(() => null);
7361
- return succeed(context.write, context.json, command, { ...status, projects, ...laptop, ...update, ...integrations, ...updateWaiting, ...unsentReplies, ...(legacyWebhookWarning === null ? {} : { legacyWebhookWarning }) }, () => [...(waiting === null ? [] : [waiting.words]), ...(unsentLine === null ? [] : [unsentLine]), ...renderInstallationStatus(status), ...(projectsLine === null ? [] : [projectsLine]), ...(line === null ? [] : [line]), ...(brokenLine === null ? [] : [brokenLine]), ...(legacyWebhookWarning === null ? [] : [legacyWebhookWarning])]);
7395
+ return succeed(context.write, context.json, command, { ...status, projects, ...laptop, ...update, ...integrations, ...signedOut, ...updateWaiting, ...unsentReplies, ...(legacyWebhookWarning === null ? {} : { legacyWebhookWarning }) }, () => [...(waiting === null ? [] : [waiting.words]), ...(unsentLine === null ? [] : [unsentLine]), ...renderInstallationStatus(status), ...(projectsLine === null ? [] : [projectsLine]), ...(line === null ? [] : [line]), ...signedOutLines, ...(brokenLine === null ? [] : [brokenLine]), ...(legacyWebhookWarning === null ? [] : [legacyWebhookWarning])]);
7362
7396
  }
7363
7397
  function unsentRepliesLine(unsent) {
7364
7398
  if (unsent.length === 0)
@@ -7390,7 +7424,7 @@ async function integrationIoFor(context) {
7390
7424
  env: process.env,
7391
7425
  repos,
7392
7426
  gh: (file, args, options) => run(file, [...args], options),
7393
- checkConnection: createConnectionChecker(),
7427
+ checkConnection: createConnectionChecker({ store: context.store }),
7394
7428
  clock: context.clock,
7395
7429
  ...seams,
7396
7430
  };
@@ -8018,6 +8052,7 @@ function showTask(positional, context) {
8018
8052
  pullRequest: newestPullRequestOf(store, store.taskFamilyOf(id, null, true)?.versions.map(one => one.id) ?? [id]),
8019
8053
  steering: store.listSteerNotes(ref.id).map(one => ({ id: one.id, author: one.author, createdAt: one.createdAt, note: one.note,
8020
8054
  standing: steerStandingOf(one, steeringLive), words: steerStandingWords(one, steeringLive, utcMinute) })),
8055
+ approvalTerms: scope === null ? null : approvalSummaryOf(scope, summaryContextOf(store, id, scope, now)).key,
8021
8056
  };
8022
8057
  return succeed(write, json, "task show", detail, () => [
8023
8058
  `${task.id} ${task.state}${ref.deliverable === "report" ? " (scout — delivers a report)" : ""}`,
@@ -8065,7 +8100,7 @@ function showTask(positional, context) {
8065
8100
  ...(detail.automaticReview === null ? reviewStatusLines(detail.review, latestFinished?.id ?? null) : buildReviewLines(detail.automaticReview)),
8066
8101
  ...(scope === null
8067
8102
  ? [" no plan yet — nothing is built until one is written and approved"]
8068
- : describeScope(scope, readiness, taskEvidenceWords(store, task.id, now))),
8103
+ : describeScope(scope, readiness, taskEvidenceWords(store, task.id, now), summaryContextOf(store, task.id, scope, now))),
8069
8104
  ...planContractLines(store, context.evidenceRoot, id),
8070
8105
  ...taskRouteStandingLines(id, routed, detail.dispatch?.summary === NO_AGENT_TITLE),
8071
8106
  ...detail.runs
@@ -8607,6 +8642,8 @@ async function scopeTask(positional, flags, context) {
8607
8642
  return fail(write, json, "task scope", "usage", "`toolroll task scope <id> --goal <what success is> --acceptance <rubric> [--not <text>] [--touches a,b] [--candidate <commit>] [--budget-usd <n>]`", EXIT.usage);
8608
8643
  if (store.getTask(id) === null)
8609
8644
  return fail(write, json, "task scope", "unknown-task", `no task \`${id}\``, EXIT.refused);
8645
+ if (store.filedViaOf(id)?.startsWith(FLEXIBLE_FILED_PREFIX) === true)
8646
+ return fail(write, json, "task scope", "flexible", FLEXIBLE_CANDIDATE_FIXED, EXIT.refused);
8610
8647
  const acceptanceGiven = text(flags, "acceptance");
8611
8648
  if (acceptanceGiven === undefined) {
8612
8649
  return fail(write, json, "task scope", "acceptance-required", "a scope needs at least one signed acceptance criterion — `--acceptance \"<statement>|<evidence,kinds>\"`, `;`-separated for more than one; evidence kinds are check, screenshot, changed-path, manual-review", EXIT.usage);
@@ -8676,7 +8713,7 @@ async function scopeTask(positional, flags, context) {
8676
8713
  previous?.proposedVia === "coordinator" || store.filedViaOf(id)?.startsWith("mcp:"))
8677
8714
  return null;
8678
8715
  const input = { title: store.getTask(id).title, goal, outOfScope: text(flags, "not") ?? null, touches };
8679
- const sized = store.applySizing(id, heuristicSizing(input), { followPlanning: true }, now);
8716
+ const sized = store.applySizing(id, filingSizing(store, input), { followPlanning: true }, now);
8680
8717
  if (sized.ok)
8681
8718
  refinement = refineFiledSizing(store, id, input, true, context.clock);
8682
8719
  return null;
@@ -8728,13 +8765,13 @@ async function scopeTask(positional, flags, context) {
8728
8765
  if (filed.modeRefusedCoordinator === true) {
8729
8766
  return succeed(write, json, "task scope", { scope, approvedUnderMode: false, quarantined: true }, () => [
8730
8767
  `Scope written for ${id} — but coordinator-filed: mode coverage cannot admit it; sign the scope.`,
8731
- ...describeScope(scope),
8768
+ ...describeScope(scope, undefined, null, summaryContextOf(store, id, scope, now)),
8732
8769
  ]);
8733
8770
  }
8734
8771
  if (filed.sealedUnderMode) {
8735
8772
  return succeed(write, json, "task scope", { scope, approvedUnderMode: true }, () => [
8736
8773
  `Scope written AND approved for ${id} — your operating mode covered it; it dispatches on the next pass.`,
8737
- ...describeScope(scope),
8774
+ ...describeScope(scope, undefined, null, summaryContextOf(store, id, scope, now)),
8738
8775
  ]);
8739
8776
  }
8740
8777
  const replanned = (store.lookupRef(id)?.planningGeneration ?? 0) > generationBefore;
@@ -8743,7 +8780,7 @@ async function scopeTask(positional, flags, context) {
8743
8780
  replanned
8744
8781
  ? `Scope written for ${id}. The scope changed, so planning starts again; nothing builds until somebody approves the new plan.`
8745
8782
  : `Scope written for ${id}. Nothing will build it until somebody approves it.`,
8746
- ...describeScope(scope),
8783
+ ...describeScope(scope, undefined, null, summaryContextOf(store, id, scope, now)),
8747
8784
  "",
8748
8785
  ` toolroll task approve ${id} --yes`,
8749
8786
  ]);
@@ -8864,6 +8901,8 @@ async function approveTask(positional, flags, context) {
8864
8901
  if (store.lookupRef(id)?.plan === "requested")
8865
8902
  return fail(write, json, "task approve", "planning", `${id} is waiting on a planner — approval is blocked until the drafted plan lands`, EXIT.refused);
8866
8903
  let saw = text(flags, "digest");
8904
+ const summary = approvalSummaryOf(scope, summaryContextOf(store, id, scope, now));
8905
+ let shownTerms = text(flags, "terms");
8867
8906
  let { name: asWho, token } = credentialsFrom(flags, context);
8868
8907
  let confirmedAloud = false;
8869
8908
  if ((!flags.has("yes") || saw === undefined || asWho === undefined || token === undefined) &&
@@ -8875,7 +8914,7 @@ async function approveTask(positional, flags, context) {
8875
8914
  write(changed);
8876
8915
  write("");
8877
8916
  }
8878
- for (const line of describeScope(scope))
8917
+ for (const line of describeScope(scope, undefined, null, summaryContextOf(store, id, scope, now)))
8879
8918
  write(line);
8880
8919
  for (const line of planContractLines(store, context.evidenceRoot, id))
8881
8920
  write(line);
@@ -8886,6 +8925,7 @@ async function approveTask(positional, flags, context) {
8886
8925
  return EXIT.refused;
8887
8926
  }
8888
8927
  saw ??= scope.digest;
8928
+ shownTerms ??= summary.key;
8889
8929
  const acting = await askCredentials(flags, context);
8890
8930
  if (acting === null)
8891
8931
  return fail(write, json, "task approve", "usage", "approval needs who is agreeing", EXIT.usage);
@@ -8897,7 +8937,7 @@ async function approveTask(positional, flags, context) {
8897
8937
  saw !== undefined && asWho !== undefined && token !== undefined;
8898
8938
  if (!armed) {
8899
8939
  if (json) {
8900
- write(envelopeJson({ ok: false, command: "task approve", reason: "unconfirmed", scope }));
8940
+ write(envelopeJson({ ok: false, command: "task approve", reason: "unconfirmed", scope, terms: summary.key }));
8901
8941
  return EXIT.refused;
8902
8942
  }
8903
8943
  write(`Would approve this, and let a builder work on ${id}:`);
@@ -8907,18 +8947,33 @@ async function approveTask(positional, flags, context) {
8907
8947
  write(changed);
8908
8948
  write("");
8909
8949
  }
8910
- for (const line of describeScope(scope))
8950
+ for (const line of describeScope(scope, undefined, null, summaryContextOf(store, id, scope, now)))
8911
8951
  write(line);
8912
8952
  for (const line of planContractLines(store, context.evidenceRoot, id))
8913
8953
  write(line);
8914
8954
  write("");
8915
8955
  write("Nothing has been approved. Agree to this exact scope with:");
8916
- write(` toolroll task approve ${id} --yes --digest ${scope.digest} --as <you> --token <your password>`);
8956
+ write(` toolroll task approve ${id} --yes --digest ${scope.digest} --terms ${summary.key} --as <you> --token <your password>`);
8917
8957
  return EXIT.refused;
8918
8958
  }
8919
8959
  if (saw === undefined || asWho === undefined || token === undefined)
8920
- return fail(write, json, "task approve", "usage", "approving non-interactively takes --yes --digest <d> --as <you> --token <t>", EXIT.usage);
8921
- const approved = approve(store, id, asWho, now, saw, token, mutationFrom(flags, now));
8960
+ return fail(write, json, "task approve", "usage", "approving non-interactively takes --yes --digest <d> --terms <key> --as <you> --token <t>", EXIT.usage);
8961
+ if (shownTerms === undefined) {
8962
+ if (json) {
8963
+ write(envelopeJson({ ok: false, command: "task approve", reason: "unconfirmed", message: "Name the terms you read: --terms <key>. Nothing was approved.", scope, terms: summary.key }));
8964
+ return EXIT.refused;
8965
+ }
8966
+ write(`Name the terms you read. Nothing was approved. ${id} would be approved on exactly this:`);
8967
+ write("");
8968
+ for (const line of describeScope(scope, undefined, null, summaryContextOf(store, id, scope, now)))
8969
+ write(line);
8970
+ write("");
8971
+ write(` toolroll task approve ${id} --yes --digest ${scope.digest} --terms ${summary.key} --as <you> --token <your password>`);
8972
+ return EXIT.refused;
8973
+ }
8974
+ const terms = shownTerms;
8975
+ const approved = store.transact(() => terms !== undefined && approvalSummaryFor(store, id, now)?.key !== terms ? { ok: false, reason: "changed" }
8976
+ : approve(store, id, asWho, now, saw, token, mutationFrom(flags, now)));
8922
8977
  if (!approved.ok) {
8923
8978
  if (approved.reason === "policy")
8924
8979
  return fail(write, json, "task approve", "policy", `${id}: ${approved.message}`, EXIT.refused);
@@ -8926,7 +8981,7 @@ async function approveTask(positional, flags, context) {
8926
8981
  }
8927
8982
  return succeed(write, json, "task approve", { scope: approved.scope }, () => [
8928
8983
  `Approved. A builder may now work on ${id}, within this scope:`,
8929
- ...describeScope(approved.scope),
8984
+ ...describeScope(approved.scope, undefined, null, summaryContextOf(store, id, approved.scope, now)),
8930
8985
  ]);
8931
8986
  }
8932
8987
  function describeApproveFailure(reason, id) {
@@ -11822,7 +11877,7 @@ async function newTaskCommand(positional, flags, context) {
11822
11877
  if (local === null && (json || !personAtTerminal(context)))
11823
11878
  return fail(write, json, command, "person-only", "`task new` asks a person at a terminal. Use `task add` from a script or an agent.", EXIT.refused);
11824
11879
  const { name, token } = credentialsFrom(flags, context);
11825
- const passwordFree = token !== undefined && (local !== null || passwordlessOn(store));
11880
+ const passwordFree = token !== undefined && (local !== null || sessionStandsIn(store));
11826
11881
  const facts = { passwordless: local === null && passwordFree, localOwner: local !== null, freshAt: null, returnTo: "/" };
11827
11882
  const buildNow = (preview, digest) => fastStartBuild(store, { preview, digest, actor: name ?? "", via: local === null ? "cli" : "terminal-ui", password: facts,
11828
11883
  approveNow: (taskId, sawDigest, fast) => approve(store, taskId, name ?? "", clock(), sawDigest, token ?? "", {}, fast) }, clock());
@@ -12599,3 +12654,39 @@ async function projectFlexibleCommand(positional, flags, context) {
12599
12654
  return fail(write, json, command, done.reason, done.message, EXIT.refused);
12600
12655
  return succeed(write, json, command, { repo, changed: done.changed, flexible: { state: "secure" } }, () => [done.changed ? `${repo} is Secure again. No new Flexible threads start.` : `${repo} is already Secure.`]);
12601
12656
  }
12657
+ async function taskSizingConfig(action, value, repoGiven, flags, context) {
12658
+ const { store, write, json, clock } = context;
12659
+ const command = `config ${action}`;
12660
+ if (repoGiven)
12661
+ return fail(write, json, command, "usage", "task sizing is installation-wide: no --repo", EXIT.usage);
12662
+ const said = () => {
12663
+ const read = taskSizingSetting(store);
12664
+ const on = read.on && !read.byEnv;
12665
+ const name = (one) => one === "jev" ? "Jev via OpenRouter (your credit)" : "Claude Haiku (on your plan)";
12666
+ return { payload: { taskSizing: { on, setting: read.chosen ? "on" : "off", sizer: read.sizer, available: read.available, byEnv: read.byEnv } }, lines: () => [read.byEnv
12667
+ ? "Task sizing is off: TOOLROLL_NO_TASK_CLASSIFIER is set, so no model call happens before you approve; uncertain tasks get a plan first."
12668
+ : on ? `Task sizing is on: each new task is sized by ${name(read.sizer)} before you approve.`
12669
+ : read.chosen && read.sizer !== null ? `Task sizing is off: it was turned on for ${name(read.sizer)}, but ${name(read.available)} is the one available now, so nothing is sent. Run \`toolroll config set task-sizing on\` to choose it.`
12670
+ : "Task sizing is off: no model call before you approve; uncertain tasks get a plan first."] };
12671
+ };
12672
+ if (action === "show") {
12673
+ const shown = said();
12674
+ return succeed(write, json, command, shown.payload, shown.lines);
12675
+ }
12676
+ if (action !== "set" || (value !== "on" && value !== "off"))
12677
+ return fail(write, json, command, "usage", "`toolroll config set task-sizing on|off --as <you> --token <t>`", EXIT.usage);
12678
+ const acting = await askCredentials(flags, context);
12679
+ if (acting === null)
12680
+ return fail(write, json, command, "usage", "changing task sizing takes `--as <you> --token <t>`", EXIT.usage);
12681
+ const saved = store.transact(() => {
12682
+ const verified = authenticateApprover(store, acting.name, acting.token);
12683
+ if (!verified.ok || !store.isInstanceOperator(acting.name))
12684
+ return false;
12685
+ setTaskSizing(store, value === "on" ? taskSizingSetting(store).available : false, acting.name, clock());
12686
+ return true;
12687
+ });
12688
+ if (!saved)
12689
+ return fail(write, json, command, "unauthenticated", "an instance operator changes task sizing, with their password", EXIT.refused);
12690
+ const shown = said();
12691
+ return succeed(write, json, command, shown.payload, shown.lines);
12692
+ }