toolroll 0.9.114 → 0.9.116

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 (96) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dist/agent-state-words.js +1 -1
  3. package/dist/assignment-ui.js +1 -1
  4. package/dist/browser/terminal.css +1 -1
  5. package/dist/browser/terminal.js +1 -1
  6. package/dist/browser/workspace.css +2 -2
  7. package/dist/browser/workspace.js +29 -28
  8. package/dist/chat-controls.js +1 -1
  9. package/dist/chat-quiet.js +2 -2
  10. package/dist/chat-voice.js +3 -3
  11. package/dist/check-levels.js +1 -1
  12. package/dist/claim.js +7 -2
  13. package/dist/cli.js +1 -0
  14. package/dist/code-map-cli.js +2 -1
  15. package/dist/coding-shipping-ui.js +2 -1
  16. package/dist/console-instance.js +21 -1
  17. package/dist/contracts/console-api.js +6 -2
  18. package/dist/contracts/engine-api.js +32 -4
  19. package/dist/demo-chat.js +1 -1
  20. package/dist/design/kit.css +3 -0
  21. package/dist/design/kit.js +1 -1
  22. package/dist/dispatch.js +19 -2
  23. package/dist/easy-start.js +23 -11
  24. package/dist/engine-reads.js +98 -7
  25. package/dist/export.js +16 -4
  26. package/dist/flexible-authority-end.js +94 -0
  27. package/dist/flexible-everyday-schema.js +76 -0
  28. package/dist/flexible-interactive-schema.js +133 -0
  29. package/dist/flexible-interactive.js +94 -0
  30. package/dist/flexible-laptop.js +38 -0
  31. package/dist/flexible-relay.js +9 -3
  32. package/dist/flexible-session.js +430 -10
  33. package/dist/flexible-ship.js +77 -12
  34. package/dist/flexible-sign-in.js +16 -1
  35. package/dist/flexible-start.js +17 -2
  36. package/dist/flexible-thread.js +1 -1
  37. package/dist/flexible-turns.js +9 -0
  38. package/dist/flexible-ui.js +3 -2
  39. package/dist/flexible.js +13 -0
  40. package/dist/flow-card-task.js +1 -1
  41. package/dist/home-groups.js +1 -1
  42. package/dist/lead-status.js +5 -3
  43. package/dist/lead-tools.js +1 -0
  44. package/dist/local-owner-acts.js +44 -1
  45. package/dist/local-owner.js +10 -0
  46. package/dist/needs-you.js +18 -6
  47. package/dist/operate-remote-arguments.js +1 -1
  48. package/dist/operate.js +250 -32
  49. package/dist/plan-problems-schema.js +4 -0
  50. package/dist/planner.js +17 -6
  51. package/dist/release-cli.js +2 -2
  52. package/dist/result-actions.js +1 -2
  53. package/dist/retention-ui.js +1 -1
  54. package/dist/scope.js +18 -7
  55. package/dist/server/chat.js +3 -3
  56. package/dist/server/console.css +15 -10
  57. package/dist/server/engine-api.js +161 -15
  58. package/dist/server/flows.js +4 -3
  59. package/dist/server/home.js +1 -1
  60. package/dist/server/kit.js +2 -2
  61. package/dist/server/render-chat.js +1 -1
  62. package/dist/server/render-pages.js +1 -1
  63. package/dist/server/render-tasks.js +21 -12
  64. package/dist/server/route-table.js +16 -0
  65. package/dist/server/settings-sections.js +6 -2
  66. package/dist/server/settings.js +22 -8
  67. package/dist/server/task-views.js +10 -4
  68. package/dist/server/tasks.js +51 -4
  69. package/dist/settings-kit.js +3 -3
  70. package/dist/skills-ui.js +3 -2
  71. package/dist/spend-report.js +2 -2
  72. package/dist/spend.js +3 -3
  73. package/dist/store.js +202 -7
  74. package/dist/subagent-admin.js +23 -10
  75. package/dist/subagent-backup-schema.js +36 -0
  76. package/dist/subagent-backup.js +92 -0
  77. package/dist/subagent-week.js +2 -2
  78. package/dist/subagent-work.js +70 -47
  79. package/dist/subagents-ui.js +6 -2
  80. package/dist/subagents.js +5 -2
  81. package/dist/subscription-chat.js +4 -0
  82. package/dist/surface.js +8 -1
  83. package/dist/task-status.js +13 -13
  84. package/dist/telegram-status.js +3 -3
  85. package/dist/terminal-safety.js +114 -0
  86. package/dist/toolroll-update.js +2 -1
  87. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  88. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  89. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  90. package/dist/tui/linux-x64/toolroll-tui +0 -0
  91. package/dist/tui-launch.js +20 -1
  92. package/dist/tui.js +1 -1
  93. package/dist/work-index.js +23 -10
  94. package/dist/workspace-ui.js +5 -5
  95. package/dist/youiyoux-intake.js +1 -1
  96. package/package.json +2 -2
@@ -13,6 +13,8 @@ import { fileTaskProposal } from "./proposal.js";
13
13
  import { validateTaskText } from "./task-text.js";
14
14
  import { taskBranch } from "./names.js";
15
15
  import { verifyApproverStanding } from "./principal.js";
16
+ import { laptopShipBinding, laptopShipProblem } from "./flexible-laptop.js";
17
+ import { localActNow } from "./local-owner.js";
16
18
  import { assignmentOf } from "./assignment.js";
17
19
  import { completeAndOpenPullRequest, mergePullRequest } from "./pull-request-flow.js";
18
20
  import { fullCheckGate } from "./result-follow-ups.js";
@@ -73,6 +75,7 @@ const WORDS = Object.freeze({
73
75
  "cancelled": "The merge was stopped for good.",
74
76
  "no-publishing": "This project can't publish pull requests, so a Flexible thread's work can't merge from it. Set up pull requests first. Nothing changed.",
75
77
  "merging": "Too late: the merge is already happening. Its outcome is read back from GitHub.",
78
+ "laptop": "Shipping from the workbench without a password works only on a laptop install where nobody has a password. Ship with your password instead: `toolroll thread ship`. Nothing was shipped.",
76
79
  });
77
80
  const refuse = (reason, detail) => ({ ok: false, reason, message: detail === undefined ? WORDS[reason] : `${WORDS[reason]} (${detail})` });
78
81
  function ownerStanding(store, thread, by) {
@@ -88,15 +91,30 @@ function ownerStanding(store, thread, by) {
88
91
  return refuse("not-flexible", standing.state);
89
92
  return { generation: account.generation, termsId: standing.id, termsDigest: standing.digest };
90
93
  }
91
- function personNow(store, by, token, repo) {
94
+ function shipProofNow(store, by, proof, repo) {
92
95
  if (machineActing())
93
96
  return refuse("machine-proof");
94
- const proved = authenticateApprover(store, by, token, repo);
95
- if (!proved.ok)
97
+ if (proof?.kind === "password-now") {
98
+ if (typeof proof.password !== "string" || proof.password === "")
99
+ return refuse("proof-refused");
100
+ const proved = authenticateApprover(store, by, proof.password, repo);
101
+ if (!proved.ok || !personProof(proved.method))
102
+ return refuse("proof-refused");
103
+ if (proved.method !== "password-now")
104
+ return refuse("proof-refused");
105
+ return { method: "password-now" };
106
+ }
107
+ if (proof?.kind !== "local-owner" || typeof proof.held !== "function")
96
108
  return refuse("proof-refused");
97
- if (!personProof(proved.method))
98
- return refuse("machine-proof");
99
- return { method: proved.method };
109
+ if (!proof.held())
110
+ return refuse("proof-refused");
111
+ const local = localActNow(store, "ship-thread");
112
+ if (local === null || local.account !== by)
113
+ return refuse("proof-refused");
114
+ const problem = laptopShipProblem(store, { owner: by, localGeneration: local.localGeneration });
115
+ if (problem !== null)
116
+ return refuse("laptop", problem);
117
+ return { method: "local-owner", localGeneration: local.localGeneration, accountGeneration: local.accountGeneration };
100
118
  }
101
119
  const turnRunning = (store, thread) => store.handle.prepare("SELECT 1 FROM thread_turn WHERE thread = ? AND status IN ('admitted', 'running')").get(thread) !== undefined;
102
120
  function branchHeld(store, thread) {
@@ -146,10 +164,10 @@ export async function shipFlexible(store, input) {
146
164
  const first = flexibleThread(store, input.thread);
147
165
  if (first === null)
148
166
  return refuse("thread-unknown");
149
- const proved = personNow(store, input.by, input.token, first.repo);
167
+ const proved = shipProofNow(store, input.by, input.proof, first.repo);
150
168
  if ("ok" in proved)
151
169
  return proved;
152
- const locked = await withFlexibleThreadLock(input.thread, () => shipLocked(store, input, proved.method));
170
+ const locked = await withFlexibleThreadLock(input.thread, () => shipLocked(store, input));
153
171
  if (locked.ok === false && (locked.reason === "not-available" || locked.reason === "thread-unknown"))
154
172
  return refuse(locked.reason);
155
173
  return locked;
@@ -161,7 +179,7 @@ class ShipStop extends Error {
161
179
  this.refusal = refusal;
162
180
  }
163
181
  }
164
- async function shipLocked(store, input, method) {
182
+ async function shipLocked(store, input) {
165
183
  if (turnRunning(store, input.thread) || unsettledLaunch(store, input.thread) !== null)
166
184
  return refuse("thread-running");
167
185
  const shown = await flexibleShipTerms(store, { thread: input.thread, by: input.by, ...(input.text === undefined ? {} : { text: input.text }), ...(input.runner === undefined ? {} : { runner: input.runner }) });
@@ -175,11 +193,17 @@ async function shipLocked(store, input, method) {
175
193
  const thread = flexibleThread(store, input.thread);
176
194
  if (thread === null || thread.state !== "ready")
177
195
  return refuse("thread-unknown");
196
+ const again = shipProofNow(store, input.by, input.proof, thread.repo);
197
+ if ("ok" in again)
198
+ return again;
199
+ const method = again.method;
178
200
  const standing = ownerStanding(store, thread, input.by);
179
201
  if ("ok" in standing)
180
202
  return standing;
181
203
  if (standing.generation !== terms.ownerGeneration)
182
204
  return refuse("stale-generation");
205
+ if (again.method === "local-owner" && again.accountGeneration !== standing.generation)
206
+ return refuse("stale-generation");
183
207
  if (standing.termsDigest !== terms.delegation)
184
208
  return refuse("changed");
185
209
  if (nextSeq(store, thread.id) !== terms.seq || store.handle.prepare("SELECT 1 FROM flexible_ship WHERE id = ?").get(digest) !== undefined)
@@ -187,6 +211,9 @@ async function shipLocked(store, input, method) {
187
211
  const branchBefore = branchHeld(store, thread.id);
188
212
  store.handle.prepare(`INSERT INTO flexible_ship (id, thread, seq, repo, base_sha, candidate, import_ref, branch, branch_before, terms_json, digest, summary_key, approved_by, approved_generation, proof, approved_at, delegation_id, state, state_at)
189
213
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'approved', ?)`).run(digest, thread.id, terms.seq, thread.repo, terms.base, terms.candidate, terms.importRef, terms.branch, branchBefore, canonicalJson(terms), digest, shown.summary.key, input.by, standing.generation, method, now, standing.termsId, now);
214
+ if (again.method === "local-owner")
215
+ store.handle.prepare("INSERT INTO flexible_ship_laptop (ship, owner, local_generation, account_generation, consented_at) VALUES (?, ?, ?, ?, ?)")
216
+ .run(digest, input.by, again.localGeneration, again.accountGeneration, now);
190
217
  store.recordAction({ at: now, actor: input.by, repo: thread.repo, taskId: null, runId: null, source: "work", action: "flexible ship approved", outcome: "flexible-ship",
191
218
  detail: `thread ${thread.id} · ship ${terms.seq} · terms ${digest} · candidate ${terms.candidate} · ${method} · generation ${standing.generation}` });
192
219
  return { branchBefore };
@@ -205,7 +232,8 @@ async function shipLocked(store, input, method) {
205
232
  return imported;
206
233
  }
207
234
  store.transact(() => { store.handle.prepare("UPDATE flexible_ship SET state = 'imported', state_at = ? WHERE id = ? AND state = 'approved'").run(now, digest); });
208
- return fileAndSeal(store, { terms, digest, by: input.by, token: input.token, now: input.now, refsChanged: imported.refsChanged, ...(input.runner === undefined ? {} : { runner: input.runner }) });
235
+ return fileAndSeal(store, { terms, digest, by: input.by, token: input.proof.kind === "password-now" ? input.proof.password : "", now: input.now, refsChanged: imported.refsChanged,
236
+ ...(input.runner === undefined ? {} : { runner: input.runner }) });
209
237
  }
210
238
  async function fileAndSeal(store, input) {
211
239
  const { terms, digest } = input;
@@ -227,6 +255,12 @@ async function fileAndSeal(store, input) {
227
255
  const row = store.handle.prepare("SELECT state FROM flexible_ship WHERE id = ?").get(digest);
228
256
  if (row?.["state"] !== "imported")
229
257
  throw new ShipStop(refuse("wrong-state"));
258
+ const laptop = laptopShipBinding(store, digest);
259
+ if (laptop !== null) {
260
+ const problem = laptopShipProblem(store, { owner: laptop.owner, localGeneration: laptop.localGeneration });
261
+ if (problem !== null)
262
+ throw new ShipStop(refuse("laptop", problem));
263
+ }
230
264
  const made = fileTaskProposal(store, { id: taskId, title: terms.title, repo: terms.repo, goal: terms.goal, outOfScope: terms.outOfScope, acceptance: terms.acceptance,
231
265
  filedVia: `${FLEXIBLE_FILED_PREFIX}${digest}`, filedBy: { name: input.by, kind: "person" }, planning: "skip", admittedRepos: [terms.repo] }, input.now);
232
266
  if (!made.ok)
@@ -253,11 +287,30 @@ async function fileAndSeal(store, input) {
253
287
  }
254
288
  catch (error) {
255
289
  await flexibleTaskBranch(store, { thread: terms.thread, branch, at: terms.base, make: false, ...runner });
290
+ if (error instanceof ShipStop && error.refusal.reason === "laptop")
291
+ return endedAtSeal(store, { terms, digest, by: input.by, now: input.now, refusal: error.refusal, ...runner });
256
292
  if (error instanceof ShipStop)
257
293
  return kept(error.refusal);
258
294
  return kept(refuse("handoff-failed", error instanceof Error ? error.message.slice(0, 300) : undefined));
259
295
  }
260
296
  }
297
+ async function endedAtSeal(store, input) {
298
+ const { terms, digest, refusal } = input;
299
+ const at = input.now.toISOString();
300
+ const row = store.handle.prepare("SELECT branch_before FROM flexible_ship WHERE id = ? AND state = 'imported' AND task_id IS NULL").get(digest);
301
+ const putBack = row === undefined ? null : await removeFlexibleImportRefs(store, { thread: terms.thread, seq: terms.seq, candidate: terms.candidate,
302
+ branchBefore: row["branch_before"] === null ? null : String(row["branch_before"]), ...(input.runner === undefined ? {} : { runner: input.runner }) });
303
+ store.transact(() => {
304
+ if (putBack?.ok === true)
305
+ store.handle.prepare("UPDATE flexible_ship SET state = 'removed', reason = ?, detail = ?, state_at = ? WHERE id = ? AND state = 'imported' AND task_id IS NULL")
306
+ .run(refusal.reason, refusal.message.slice(0, 2000), at, digest);
307
+ else
308
+ store.handle.prepare("UPDATE flexible_ship SET detail = ?, state_at = ? WHERE id = ? AND state = 'imported'").run(refusal.message.slice(0, 2000), at, digest);
309
+ store.recordAction({ at, actor: input.by, repo: terms.repo, taskId: null, runId: null, source: "work", action: "flexible ship refused", outcome: refusal.reason,
310
+ detail: `thread ${terms.thread} · ship ${terms.seq} · at the seal · ${putBack?.ok === true ? "import taken back" : "import kept"} · ${refusal.message}`.slice(0, 2000) });
311
+ });
312
+ return refusal;
313
+ }
261
314
  function readRow(row) {
262
315
  if (row === undefined)
263
316
  return null;
@@ -278,7 +331,7 @@ function readRow(row) {
278
331
  return { id: String(row["id"]), thread: terms.thread, seq: terms.seq, repo: terms.repo, base: terms.base, candidate: terms.candidate, importRef: terms.importRef, branch: terms.branch,
279
332
  branchBefore: text("branch_before"), terms, approvedBy: String(row["approved_by"]), approvedGeneration: Number(row["approved_generation"]), state: String(row["state"]), reason: text("reason"),
280
333
  detail: text("detail"), taskId: text("task_id"), scopeDigest: text("scope_digest"), feedback: text("feedback"), mergeHead: text("merge_head"), checkReceipt: text("check_receipt"),
281
- mergeToken: text("merge_token"), mergeReservedAt: text("merge_reserved_at"), delegationId: Number(row["delegation_id"]), stateAt: String(row["state_at"]) };
334
+ mergeToken: text("merge_token"), mergeReservedAt: text("merge_reserved_at"), delegationId: Number(row["delegation_id"]), stateAt: String(row["state_at"]), proof: String(row["proof"]) };
282
335
  }
283
336
  export function flexibleShipsOf(store, thread) {
284
337
  const rows = store.handle.prepare("SELECT * FROM flexible_ship WHERE thread = ? ORDER BY seq DESC").all(thread);
@@ -328,6 +381,14 @@ function authorityProblem(store, ship) {
328
381
  return "where it merges, or what Toolroll may do there, changed since it was shipped";
329
382
  if (store.liveVerifyCommand(ship.repo)?.digest !== ship.terms.check.digest)
330
383
  return "the project's check command changed since it was shipped";
384
+ if (ship.proof === "local-owner") {
385
+ const laptop = laptopShipBinding(store, ship.id);
386
+ if (laptop === null)
387
+ return "its laptop consent can't be read";
388
+ const problem = laptopShipProblem(store, { owner: laptop.owner, localGeneration: laptop.localGeneration });
389
+ if (problem !== null)
390
+ return `it was shipped without a password from the workbench, and ${problem}`;
391
+ }
331
392
  return null;
332
393
  }
333
394
  function newestRun(store, taskId) {
@@ -388,6 +449,7 @@ export async function mergeArmedFlexible(store, input) {
388
449
  const receipt = assignmentOf(store, input.taskId, clock(), { principal: "operator", repos: [found.repo] }, input.root)?.receipt ?? null;
389
450
  if (receipt === null || receipt.runId !== newest.id || (receipt.head !== null && receipt.head !== head))
390
451
  return { ok: true, state: "waiting", why: "its result isn't ready to complete yet" };
452
+ let cancelled = null;
391
453
  try {
392
454
  store.transact(() => {
393
455
  if (!flexibleAvailable(store))
@@ -398,7 +460,8 @@ export async function mergeArmedFlexible(store, input) {
398
460
  const problem = authorityProblem(store, again);
399
461
  if (problem !== null) {
400
462
  cancelArmed(store, again, problem, clock());
401
- throw new ShipStop(refuse("cancelled", problem));
463
+ cancelled = refuse("cancelled", problem);
464
+ return;
402
465
  }
403
466
  const who = verifyApproverStanding(store, again.approvedBy, again.approvedGeneration, [again.repo]);
404
467
  if (!who.ok)
@@ -420,6 +483,8 @@ export async function mergeArmedFlexible(store, input) {
420
483
  return error.refusal.reason === "cancelled" ? error.refusal : { ok: true, state: "waiting", why: error.refusal.message };
421
484
  throw error;
422
485
  }
486
+ if (cancelled !== null)
487
+ return cancelled;
423
488
  return { ok: true, state: "completed" };
424
489
  }
425
490
  const publication = store.publicationForRun(newest.id);
@@ -6,6 +6,7 @@ import { CLAUDE_EXACT } from "./model-catalog.js";
6
6
  import { FLEXIBLE_RELAY_UPSTREAMS } from "./flexible-relay-upstreams.js";
7
7
  import { credentialProof, freshFacts, proveCredential } from "./scope.js";
8
8
  import { createSignInSecret, readSignInSecret, removeSignInSecret, withSignInLockAsync } from "./tool-secret-store.js";
9
+ import { endThreadAuthorityFor } from "./flexible-authority-end.js";
9
10
  import { relayCancel } from "./flexible-relay-cancel.js";
10
11
  export const SIGN_IN_ACTION = "claude sign-in for threads";
11
12
  export const SIGN_IN_STAGE_MS = 15 * 60_000;
@@ -190,7 +191,8 @@ export function removeFlexibleSignIn(store, input) {
190
191
  raiseSignInEpoch(store, input.person);
191
192
  if (removed)
192
193
  relayCancel({ person: input.person });
193
- return { removed };
194
+ const ended = endThreadAuthorityFor(store, { person: input.person, cause: input.by === input.person ? "removed" : "removed-by-operator", at, signInsEnded: true });
195
+ return { removed, ended };
194
196
  });
195
197
  }
196
198
  export function resetFlexibleSignInsForRestore(store, input) {
@@ -201,6 +203,9 @@ export function resetFlexibleSignInsForRestore(store, input) {
201
203
  for (const one of input.carried)
202
204
  if (PERSON(one.person))
203
205
  raiseSignInEpoch(store, one.person);
206
+ for (const row of store.handle.prepare("SELECT DISTINCT owner AS person FROM thread_turn WHERE status IN ('admitted', 'running') UNION SELECT created_by AS person FROM flexible_thread").all()) {
207
+ endThreadAuthorityFor(store, { person: String(row["person"]), cause: "restored", at, signInsEnded: true });
208
+ }
204
209
  for (const one of input.carried) {
205
210
  if (!PERSON(one.person) || !GENERATION.test(one.generation) || !Number.isSafeInteger(one.accountGeneration) || one.accountGeneration < 0)
206
211
  continue;
@@ -468,3 +473,13 @@ export function signInEpochOf(store, person) {
468
473
  function raiseSignInEpoch(store, person) {
469
474
  store.handle.prepare("INSERT INTO flexible_sign_in_epoch (person, epoch) VALUES (?, 1) ON CONFLICT (person) DO UPDATE SET epoch = epoch + 1").run(person);
470
475
  }
476
+ export function signInForInteractiveStands(store, sessionId) {
477
+ const session = store.handle.prepare("SELECT * FROM flexible_interactive_session WHERE id = ? AND state IN ('prepared', 'active')").get(sessionId);
478
+ if (session === undefined || session["provider"] !== "claude" || session["billing"] !== "subscription")
479
+ return false;
480
+ const thread = store.handle.prepare("SELECT created_by FROM flexible_thread WHERE id = ?").get(session["thread"]);
481
+ if (thread === undefined || thread["created_by"] !== session["owner"] || signInEpochOf(store, String(session["owner"])) !== session["sign_in_epoch"])
482
+ return false;
483
+ const billing = flexibleSignInBilling(store, { name: String(session["owner"]), generation: Number(session["account_generation"]) });
484
+ return billing.ok && billing.billing === "subscription";
485
+ }
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import { flexibleAvailable } from "./flexible-available.js";
3
3
  import { FLEXIBLE_LAPSE_WORDS, FLEXIBLE_LEVEL_WORDS, FLEXIBLE_UNAVAILABLE, flexibleStanding, FULL_ACCESS_WORDS, OPEN_NETWORK_WORDS } from "./flexible.js";
4
4
  import { flexibleNetworkDigest, flexibleThreadNetwork } from "./flexible-launcher.js";
5
+ import { FLEXIBLE_RELAY_UPSTREAMS } from "./flexible-relay-upstreams.js";
5
6
  import { flexibleSignInBilling, flexibleSignInStatus } from "./flexible-sign-in.js";
6
7
  import { networkWords } from "./egress.js";
7
8
  import { agentModelName } from "./model-names.js";
@@ -26,6 +27,12 @@ export const FLEXIBLE_UNKNOWN_COST_WORDS = "If Toolroll can't measure what a tur
26
27
  export function flexibleStartCard(store, input) {
27
28
  if (!flexibleAvailable(store))
28
29
  return refuse("not-available");
30
+ const helperModels = [...new Set(input.helperModels ?? [])].sort();
31
+ if (helperModels.some(model => !FLEXIBLE_RELAY_UPSTREAMS.claude.helperModels.test(model)))
32
+ return refuse("invalid-request");
33
+ const runtime = input.runtime ?? "stream-json";
34
+ if (runtime !== "stream-json" && runtime !== "interactive")
35
+ return refuse("invalid-request");
29
36
  const model = input.model === null || input.model === "" ? FLEXIBLE_DEFAULT_MODEL : input.model;
30
37
  if (typeof input.repo !== "string" || input.repo === "" || typeof model !== "string" || !RELAY_MODEL.test(model) || typeof input.message !== "string"
31
38
  || typeof input.by?.name !== "string" || !Number.isSafeInteger(input.by.generation))
@@ -47,6 +54,8 @@ export function flexibleStartCard(store, input) {
47
54
  if (!credential.ok)
48
55
  return refuse(credential.reason);
49
56
  const billing = credential.billing;
57
+ if (runtime === "interactive" && billing !== "subscription")
58
+ return refuse("invalid-request");
50
59
  const signedIn = flexibleSignInStatus(store, input.by.name);
51
60
  const savedOn = signedIn.state === "none" ? null : signedIn.savedAt.slice(0, 10);
52
61
  const open = network.mode === "open";
@@ -69,6 +78,12 @@ export function flexibleStartCard(store, input) {
69
78
  { label: "Ship", words: FLEXIBLE_SHIP_WORDS, fields: ["flexible.ship"] },
70
79
  { label: "Terms", words: `this project's Flexible terms, turned on by ${terms.signer}`, lines: [`They last until someone turns them off or lowers them, or ${terms.signer}'s account or access changes.`], fields: ["flexible.terms"] },
71
80
  ];
81
+ if (runtime === "interactive") {
82
+ decisions.splice(decisions.findIndex(row => row.label === "Limits"), 1);
83
+ decisions.push({ label: "Concurrent agents", words: `${plural(caps.liveThreads, "thread")} at once in this project`, fields: ["flexible.caps"] });
84
+ decisions.push({ label: "Runtime", words: "Interactive Claude, using your subscription; no turn or cost limits", lines: helperModels.length === 0 ? [] : [`Permitted helper models: ${helperModels.join(", ")}`], fields: ["flexible.agent"] });
85
+ decisions.find(row => row.label === "Agent").lines = ["Your Claude subscription powers this interactive session. Your sign-in stays with Toolroll."];
86
+ }
72
87
  const warnings = [
73
88
  { words: "The agent can read this repository's whole history, not just the commit it starts from.", fields: ["flexible.repository"] },
74
89
  { words: "Anything it reads can end up in what it writes: its messages and its commits. Toolroll checks for secrets before Ship, but that isn't a guarantee.", fields: ["flexible.network"] },
@@ -76,10 +91,10 @@ export function flexibleStartCard(store, input) {
76
91
  ];
77
92
  const digestOfMessage = createHash("sha256").update(input.message, "utf8").digest("hex");
78
93
  const networkDigest = flexibleNetworkDigest(network);
79
- const key = createHash("sha256").update(JSON.stringify({ v: 1, kind: "standing-orders:flexible-start", digest: standing.digest, repo: input.repo, by: input.by, model, level: "full", billing,
94
+ const key = createHash("sha256").update(JSON.stringify({ v: 1, kind: "standing-orders:flexible-start", termsId: standing.id, digest: standing.digest, repo: input.repo, by: input.by, runtime, helperModels, model, level: "full", billing,
80
95
  network: networkDigest, message: digestOfMessage, decisions, warnings }), "utf8").digest("hex").slice(0, 32);
81
96
  const summary = { revision: null, revisionNotes: [], revisionChanges: [], decisions, why: null, differs: [], warnings, usual: [], usualLabel: "Other settings", usualSummary: "", key };
82
- return { ok: true, card: { summary, digest: standing.digest, network: networkDigest, model, level: "full", billing, terms } };
97
+ return { ok: true, card: { summary, termsId: standing.id, digest: standing.digest, network: networkDigest, model, level: "full", billing, runtime, helperModels, terms } };
83
98
  }
84
99
  export const FLEXIBLE_NEXT_WORDS = Object.freeze({
85
100
  "turn-on": "Threads are off. Turn them on in Settings → General, or with `toolroll config set flexible on`. Nothing was started.",
@@ -287,7 +287,7 @@ async function removeLocked(store, input) {
287
287
  const after = flexibleThread(store, thread.id);
288
288
  if (after.livePid !== null && processMayBeAlive(after.livePid, true))
289
289
  return refuse("thread-running");
290
- const claimed = store.transact(() => Number(store.handle.prepare("UPDATE flexible_thread SET state = 'removing', live_pid = NULL, live_since = NULL WHERE id = ? AND state IN ('ready', 'removing') AND live_pid IS ? AND NOT EXISTS (SELECT 1 FROM flexible_thread_launch WHERE thread = ? AND state <> 'exited')")
290
+ const claimed = store.transact(() => (input.prove === undefined || input.prove()) && Number(store.handle.prepare("UPDATE flexible_thread SET state = 'removing', live_pid = NULL, live_since = NULL WHERE id = ? AND state IN ('ready', 'removing') AND live_pid IS ? AND NOT EXISTS (SELECT 1 FROM flexible_thread_launch WHERE thread = ? AND state <> 'exited')")
291
291
  .run(thread.id, after.livePid, thread.id).changes) === 1);
292
292
  if (!claimed)
293
293
  return refuse("thread-not-ready");
@@ -43,7 +43,9 @@ const WORDS = Object.freeze({
43
43
  "not-an-operator": "Only an instance operator can change the installation's Flexible limits. Nothing changed.",
44
44
  "request-changed": "That message is already waiting to start with different settings (level, agent, billing or session). Send it again as a new message.",
45
45
  "turn-expired": "This turn waited past midnight UTC, so it didn't start. Send the message again.",
46
+ "thread-ended": "This thread has ended. Start a new thread to go on.",
46
47
  });
48
+ const threadEnded = (store, thread) => store.handle.prepare("SELECT 1 AS ended FROM flexible_thread_meta WHERE thread = ? AND ended_at IS NOT NULL").get(thread) !== undefined;
47
49
  const refuse = (reason) => ({ ok: false, reason, message: WORDS[reason] });
48
50
  function timeOf(clock) {
49
51
  const now = (clock ?? (() => new Date()))();
@@ -165,6 +167,8 @@ export function admitFlexibleTurn(store, input) {
165
167
  return refuse("thread-not-ready");
166
168
  if (thread["created_by"] !== input.starter.name)
167
169
  return refuse("not-owner");
170
+ if (threadEnded(store, input.thread))
171
+ return refuse("thread-ended");
168
172
  const repo = String(thread["repo"]);
169
173
  const delegation = flexibleDelegationAtUse(store, { repo, starter: input.starter, digest: input.digest, level: input.level, freshProof: input.freshProof });
170
174
  if (!delegation.ok)
@@ -299,6 +303,8 @@ export function beginFlexibleTurn(store, input) {
299
303
  return withdraw(refuse("thread-not-ready"));
300
304
  if (thread["created_by"] !== turn.owner)
301
305
  return withdraw(refuse("not-owner"));
306
+ if (threadEnded(store, turn.thread))
307
+ return withdraw(refuse("thread-ended"));
302
308
  const delegation = flexibleDelegationAtUse(store, { repo: turn.repo, starter: { name: turn.owner, generation: turn.ownerGeneration }, digest: turn.termsDigest, level: turn.level, freshProof: true });
303
309
  if (!delegation.ok)
304
310
  return withdraw(delegation);
@@ -313,6 +319,9 @@ export function beginFlexibleTurn(store, input) {
313
319
  if (spend !== null)
314
320
  return withdraw(spend);
315
321
  store.handle.prepare("UPDATE thread_turn SET status = 'running', started_at = ? WHERE id = ? AND status = 'admitted'").run(at, turn.id);
322
+ const epoch = Number(store.handle.prepare("SELECT epoch FROM flexible_sign_in_epoch WHERE person = ?").get(turn.owner)?.["epoch"] ?? 0);
323
+ store.handle.prepare("INSERT INTO flexible_turn_dispatch (turn, person, sign_in_epoch, account_generation) VALUES (?, ?, ?, ?) ON CONFLICT (turn) DO NOTHING")
324
+ .run(turn.id, turn.owner, epoch, turn.ownerGeneration);
316
325
  return { ok: true, turn: flexibleTurn(store, turn.id) };
317
326
  });
318
327
  }
@@ -3,6 +3,7 @@ import { html, joinHtml, postForm } from "./html.js";
3
3
  import { acts, btn, disclose, formRow, note, notice, select, settingsSection } from "./server/kit.js";
4
4
  import { kitSectionForm } from "./settings-kit.js";
5
5
  const ACTION = "/settings/project/flexible";
6
+ export const FLEXIBLE_MEANS = "Flexible: people here can start interactive agent threads right away, without a plan approved first. A thread's changes reach the project only when you Ship them and the project's checks pass.";
6
7
  const termsList = (terms) => html `<ul class="k-note">${flexibleTermsWords(terms).map(line => html `<li>${line}</li>`)}</ul>`;
7
8
  function enableForm(view, label) {
8
9
  if ("problem" in view.proposal)
@@ -27,7 +28,7 @@ export function flexibleSettingsHtml(view) {
27
28
  const standing = view.standing;
28
29
  const changer = view.canChange ? null : note("An approver for this project can change this.");
29
30
  if (standing.state === "secure") {
30
- return settingsSection({ id: "flexible", title: "How work starts", state: " · Secure", lead: "Work is planned and approved before it starts.",
31
+ return settingsSection({ id: "flexible", title: "How work starts", state: " · Secure", lead: `Work is planned and approved before it starts. ${FLEXIBLE_MEANS}`,
31
32
  body: changer ?? disclose("Turn on Flexible", enableForm(view, "Turn on Flexible")) });
32
33
  }
33
34
  if (standing.state === "unreadable") {
@@ -39,6 +40,6 @@ export function flexibleSettingsHtml(view) {
39
40
  body: changer ?? joinHtml([disclose("Turn on again", enableForm(view, "Turn on again")), lowerAndOff(view, null)]) });
40
41
  }
41
42
  return settingsSection({ id: "flexible", title: "How work starts", state: ` · Flexible, up to ${FLEXIBLE_LEVEL_WORDS[standing.terms.max]}`,
42
- lead: `Agent threads start at once, at ${FLEXIBLE_LEVEL_WORDS[standing.terms.default]}. Turned on by ${standing.signedBy}.`,
43
+ lead: `${FLEXIBLE_MEANS} Threads start at ${FLEXIBLE_LEVEL_WORDS[standing.terms.default]}. Turned on by ${standing.signedBy}.`,
43
44
  body: joinHtml([disclose("Terms", termsList(standing.terms)), changer ?? lowerAndOff(view, standing.terms)]) });
44
45
  }
package/dist/flexible.js CHANGED
@@ -364,3 +364,16 @@ export function flexibleSettingsView(store, repo, viewer) {
364
364
  return { repo, standing, canChange: viewer.canChange,
365
365
  proposal: proposed.ok ? { terms: proposed.terms, digest: proposed.digest } : { problem: proposed.message.replace(/ Nothing changed\.$/, "") } };
366
366
  }
367
+ export function flexibleRuntime(store, thread) {
368
+ const row = store.handle.prepare("SELECT runtime FROM flexible_thread_runtime WHERE thread = ?").get(thread);
369
+ if (row === undefined)
370
+ return "stream-json";
371
+ if (row["runtime"] !== "stream-json" && row["runtime"] !== "interactive")
372
+ throw new Error("unreadable thread runtime");
373
+ return row["runtime"];
374
+ }
375
+ export function recordFlexibleRuntime(store, thread, runtime) {
376
+ const changed = store.handle.prepare("UPDATE flexible_thread_runtime SET runtime = ?, chosen = 1 WHERE thread = ?").run(runtime, thread);
377
+ if (Number(changed.changes) !== 1)
378
+ throw new Error("missing thread runtime");
379
+ }
@@ -55,5 +55,5 @@ export function flowCardTaskLine(store, taskId, repo, now, secrets = []) {
55
55
  }
56
56
  if (status.headline === "Failed")
57
57
  return `Stuck: ${cardReason(status.sentence, "Open the task", secrets)}`;
58
- return status.headline === "Ready for review" ? "Ready" : status.headline;
58
+ return status.headline;
59
59
  }
@@ -1,5 +1,5 @@
1
1
  export const HOME_GROUPS = ["you", "working", "done"];
2
- export const HOME_GROUP_LABEL = { you: "Waiting on you", working: "Working", done: "Done" };
2
+ export const HOME_GROUP_LABEL = { you: "Waiting on you", working: "Working", done: "Complete" };
3
3
  export function homeGroupOf(item) {
4
4
  const views = item.status.views;
5
5
  if (views.includes("needs-you"))
@@ -89,8 +89,10 @@ export function taskWaitSnapshot(store, taskId, now, watchedRun) {
89
89
  return answer("Complete", "No action needed", true, 0, "complete");
90
90
  if (state === "done")
91
91
  return answer("Ready", "Open result", true, 0, "ready");
92
- if (state === "failed" || state === "cancelled")
93
- return answer("Failed", state === "cancelled" ? "Review cancellation" : "Inspect failure", true, 1, "failed");
92
+ if (state === "cancelled")
93
+ return answer("Cancelled", "Open the task", true, 1, "failed");
94
+ if (state === "failed")
95
+ return answer("Failed", "Inspect failure", true, 1, "failed");
94
96
  const decision = store.handle.prepare(`SELECT decision.id FROM run INDEXED BY lead_status_task_run
95
97
  JOIN decision INDEXED BY work_open_decision ON decision.run = run.id
96
98
  WHERE run.task_ref = ? AND decision.state <> 'answered' AND decision.answered_at IS NULL LIMIT 1`).get(taskRef);
@@ -260,7 +262,7 @@ export function renderInstallationStatus(status, limited = false) {
260
262
  }
261
263
  lines.push(status.running.count === 0 ? "Building: none" : `Building: ${status.running.count} — ${status.running.tasks.map(one => `${one.task} (#${one.run}, ${one.phase})`).join(", ")}${status.running.count > status.running.tasks.length ? ", …" : ""}`);
262
264
  lines.push(status.queued.count === 0 ? "Queued: none" : `Queued: ${status.queued.count} — ${status.queued.tasks.map(one => `${one.task} (${queueReasonWords(one.reason)})`).join(", ")}${status.queued.count > status.queued.tasks.length ? ", …" : ""}`);
263
- lines.push(status.waitingForReview.count === 0 ? "Ready for review: none" : `Ready for review: ${status.waitingForReview.count} — ${status.waitingForReview.results.map(one => one.run === null ? one.task : `${one.task} (#${one.run})`).join(", ")}${status.waitingForReview.count > status.waitingForReview.results.length ? ", …" : ""}`);
265
+ lines.push(status.waitingForReview.count === 0 ? "Ready: none" : `Ready: ${status.waitingForReview.count} — ${status.waitingForReview.results.map(one => one.run === null ? one.task : `${one.task} (#${one.run})`).join(", ")}${status.waitingForReview.count > status.waitingForReview.results.length ? ", …" : ""}`);
264
266
  if (limited)
265
267
  return lines;
266
268
  if (status.releaseCheck === null) {
@@ -1235,6 +1235,7 @@ const LEAD_TOOL_HANDLERS = {
1235
1235
  return { ok: true, body: {
1236
1236
  subagents: mates.map(mate => ({
1237
1237
  subagent: mate.id, name: nameOf(mate), label: labelOf(mate), handle: mate.handle, project: repoIdOf(ctx.who, mate.repo), working: mate.state === "active",
1238
+ codexBackup: { enabled: mate.codexBackupModel !== null, model: mate.codexBackupModel, settings: `/settings/lead/subagents/${mate.id}#backup`, change: "Enable or change with your password in Settings; Claude stays primary." },
1238
1239
  reportsTo: whoIs(mate.manager), soul: args["subagent"] === undefined ? mate.soul.slice(0, 600) : mate.soul, version: mate.version,
1239
1240
  worksOn: zonesOf(ctx.store, mate).map(one => ({ flow: one.flow, flowName: one.flowName, zone: one.title, how: one.kind })),
1240
1241
  today: summaryOf(ctx.store, mate, today.toISOString()).said,
@@ -1,4 +1,4 @@
1
- import { refArchived, requeueEligibility } from "./store.js";
1
+ import { PLAN_AGAIN_ACTIONS, planAgain, refArchived, requeueEligibility } from "./store.js";
2
2
  import { LOCAL_OWNER_LAPSED, localActNow } from "./local-owner.js";
3
3
  import { approverStanding, localWorkEligible, personApprovalOf } from "./scope.js";
4
4
  import { plannerContractOf, plannerSourceDigest } from "./planner-source.js";
@@ -166,3 +166,46 @@ class Undone extends Error {
166
166
  this.result = result;
167
167
  }
168
168
  }
169
+ export const PLAN_AGAIN_FIRST = "The plan didn't pass its checks. Use Plan again first.";
170
+ export const RESOLVE_INCIDENT_FIRST = "Resolve the incident first.";
171
+ export function planAgainAsLocalOwner(store, taskId, pins, now) {
172
+ try {
173
+ return store.transact(() => {
174
+ const local = localActNow(store, "request-plan");
175
+ if (local === null)
176
+ return { ok: false, reason: "local-owner", message: LOCAL_OWNER_LAPSED };
177
+ const ref = store.lookupRef(taskId);
178
+ if (ref === null || store.getTask(taskId) === null || !approverStanding(store, local.account, ref.repo).ok) {
179
+ return { ok: false, reason: "not-found", message: "That task is unavailable in your projects." };
180
+ }
181
+ if (refArchived(store, ref.id))
182
+ return { ok: false, reason: "archived", message: "This task is put away. Restore it first." };
183
+ const eligible = localWorkEligible(store, local.account, taskId, { act: "plan" });
184
+ if (!eligible.ok)
185
+ return { ok: false, reason: "refused", message: eligible.message };
186
+ if (ref.planProvider !== null || ref.planModel !== null) {
187
+ return { ok: false, reason: "refused", message: "This task names its own planning agent, so planning it again needs your password." };
188
+ }
189
+ if (planSourceOf(store, taskId) !== pins.source)
190
+ return { ok: false, reason: "stale", message: LOCAL_TASK_CHANGED };
191
+ const done = planAgain(store, { taskId, incident: pins.incident, by: local.account, actor: `operator:${local.account}`, action: PLAN_AGAIN_ACTIONS.local,
192
+ detail: { source: pins.source, via: local.transport }, now,
193
+ before: () => withdrawPlanAuthorization(store, taskId, ref.repo, local.account, now, "the local owner asked to plan again") });
194
+ return done.ok ? done : { ok: false, reason: done.reason, message: done.message };
195
+ });
196
+ }
197
+ catch (error) {
198
+ if (error instanceof Error && error.message === LOCAL_OWNER_LAPSED)
199
+ return { ok: false, reason: "local-owner", message: LOCAL_OWNER_LAPSED };
200
+ throw error;
201
+ }
202
+ }
203
+ function withdrawPlanAuthorization(store, taskId, repo, account, now, why) {
204
+ const armed = store.handle.prepare("SELECT signed_by, basis FROM plan_authorization WHERE task_id = ?").get(taskId);
205
+ if (armed === undefined)
206
+ return;
207
+ store.handle.prepare("DELETE FROM plan_authorization WHERE task_id = ?").run(taskId);
208
+ store.recordAction({ at: now.toISOString(), actor: `operator:${account}`, repo, taskId, runId: null, source: "request",
209
+ action: "unchanged plan pre-authorization withdrawn", outcome: "withdrawn",
210
+ detail: JSON.stringify({ v: 1, signedBy: String(armed["signed_by"]), basis: String(armed["basis"]), why }) });
211
+ }
@@ -32,13 +32,23 @@ export const LOCAL_OWNER_ACTS = Object.freeze([
32
32
  "view-preference",
33
33
  "take-over",
34
34
  "start-thread",
35
+ "reply-thread",
36
+ "stop-thread",
37
+ "end-thread",
35
38
  "check-agents",
36
39
  "agent-sign-in",
37
40
  "agent-install",
38
41
  "change-models",
39
42
  "task-sizing-switch",
40
43
  "flexible-switch",
44
+ "ship-thread",
45
+ "cancel-ship",
46
+ "flexible-sign-in-save",
47
+ "flexible-sign-in-check",
48
+ "flexible-sign-in-clear",
49
+ "project-flexible",
41
50
  ]);
51
+ export const LOCAL_PASSWORD_ACTS = new Set(["flexible-switch", "flexible-sign-in-save", "flexible-sign-in-check", "project-flexible"]);
42
52
  const ACT_SET = new Set(LOCAL_OWNER_ACTS);
43
53
  export function localOwnerAct(value) {
44
54
  return typeof value === "string" && ACT_SET.has(value);
package/dist/needs-you.js CHANGED
@@ -7,7 +7,7 @@ const build = (context) => context.build == null ? "the last build"
7
7
  : context.attempt == null ? `build #${context.build}` : `attempt ${context.attempt} (build #${context.build})`;
8
8
  const Build = (context) => context.build == null ? "The last build" : `Build #${context.build}`;
9
9
  export const NEEDS = {
10
- approval: { sentence: () => "Review the plan and approve it to start.", action: { code: "approve-scope", label: "Approve plan" } },
10
+ approval: { sentence: () => "Review the plan and approve it to start.", action: { code: "approve-scope", label: "Review plan" } },
11
11
  card: { sentence: () => "This card is waiting for your approval.", action: { code: "approve-card", label: "Approve card" } },
12
12
  answer: { sentence: () => "Answer the question so the work can continue.", action: { code: "answer-decision", label: "Answer the question" }, useReason: always },
13
13
  questions: { sentence: () => "Too many questions are open. Answer one so this task can start.", action: { code: "inspect-decisions", label: "Answer questions" } },
@@ -31,27 +31,35 @@ export const NEEDS = {
31
31
  vanished: { sentence: context => `${Build(context)} stopped unexpectedly. Retry it.`, action: { code: "reconcile-run", label: "Open the build" } },
32
32
  "review-result": { sentence: () => "Check the result, then accept it or send it back.", action: { code: "open-result", label: "Open result" } },
33
33
  rebuild: { sentence: context => `${Build(context)} was made to an earlier plan. Retry it on the current plan.`, action: { code: "retry-task", label: "Retry" } },
34
- replan: { sentence: context => `The plan changed after ${build(context)}. Approve the new plan, then retry it.`, action: { code: "approve-scope", label: "Approve plan" } },
34
+ replan: { sentence: context => `The plan changed after ${build(context)}. Approve the new plan, then retry it.`, action: { code: "approve-scope", label: "Review plan" } },
35
35
  "earlier-version": { sentence: context => context.task == null ? "An earlier version of this task still needs you. Finish it first." : `An earlier version, ${context.task}, still needs you. Finish it first.`,
36
36
  action: { code: "inspect-task", label: "Open earlier version" } },
37
37
  history: { sentence: () => "Toolroll can't read this task's history. Open it to retry or archive it.", action: { code: "inspect-task", label: "Open the task" } },
38
38
  finding: { sentence: () => "A finding has used its rounds. Read both sides and decide.", action: { code: "inspect-findings", label: "Open finding" } },
39
+ "plan-again": { sentence: () => "The plan didn't pass its checks. Plan again, or edit the task.", action: { code: "inspect-task", label: "Plan again" } },
40
+ "planning-stopped": { sentence: () => "Planning stopped after repeated failures. Plan again, or edit the task.", action: { code: "inspect-task", label: "Plan again" } },
39
41
  other: { sentence: () => "Open the task to see what it needs from you.", action: { code: "inspect-task", label: "Open the task" }, useReason: always },
40
42
  };
41
43
  export const ASKS = ["decide", "review", "unblock"];
42
44
  export const ASK_LABEL = { decide: "Decide", review: "Review", unblock: "Unblock" };
43
45
  export function askChipOf(read) {
46
+ if (read.need === "plan-again")
47
+ return "Plan didn't pass";
48
+ if (read.need === "planning-stopped")
49
+ return "Planning stopped";
44
50
  if (read.headline === "Failed")
45
51
  return "Failed";
46
52
  if (read.planChanged === true || read.need === "rebuild" || read.need === "replan")
47
53
  return "Plan changed";
48
54
  if (read.mismatch === true)
49
55
  return "Mismatch";
50
- if (read.headline === "Ready for review" || read.need === "review-result" || read.ask === "review")
51
- return "Result";
56
+ if (read.headline === "Ready" || read.need === "review-result" || read.ask === "review")
57
+ return "Ready";
52
58
  if (read.need === "approval")
53
59
  return "Plan";
54
- if (read.need === "start-builder" || read.need === "connect-builder")
60
+ if (read.need === "connect-builder")
61
+ return "No builder";
62
+ if (read.need === "start-builder")
55
63
  return "Builder offline";
56
64
  if (read.need === "answer" || read.need === "questions")
57
65
  return "Question";
@@ -90,7 +98,7 @@ export const NEED_ASK = {
90
98
  "fix-request": "decide", "choose-agent": "decide",
91
99
  "review-result": "review", rebuild: "review", replan: "decide",
92
100
  "sign-in": "unblock", "stop-unproven": "unblock", hold: "unblock", storage: "unblock", "fix-dependency": "unblock",
93
- "add-requirement": "unblock", "connect-builder": "unblock", "start-builder": "unblock", vanished: "unblock", "earlier-version": "unblock", history: "unblock", other: "unblock",
101
+ "add-requirement": "unblock", "connect-builder": "unblock", "start-builder": "unblock", vanished: "unblock", "earlier-version": "unblock", history: "unblock", "plan-again": "unblock", "planning-stopped": "unblock", other: "unblock",
94
102
  };
95
103
  export const WAITS = {
96
104
  "build-finishing": () => "Finishing up; this clears on its own.",
@@ -106,6 +114,7 @@ export const WAITS = {
106
114
  "retry-later": context => context.attempt != null && context.build != null
107
115
  ? `Waiting: Toolroll tries attempt ${context.attempt + 1} ${context.retry ?? "soon"}, after attempt ${context.attempt} (build #${context.build}).`
108
116
  : `Waiting: Toolroll retries ${build(context)} ${context.retry ?? "soon"}.`,
117
+ "plan-retry-later": context => `Waiting: Toolroll tries the plan again ${context.retry ?? "soon"}.`,
109
118
  "app-update": () => "Waiting: Toolroll is updating. New work starts after it.",
110
119
  "other-task": context => context.task == null ? "Waiting for another task to finish first." : `Waiting for ${context.task} to finish first.`,
111
120
  };
@@ -148,10 +157,13 @@ export const CODE_READING = {
148
157
  stopped: { stage: "stopped", act: "resume-run" },
149
158
  failed: { stage: "failed", act: "retry-task" }, "checks-failed": { stage: "failed" },
150
159
  "waiting-incident": { stage: "failed", act: "retry-task" },
160
+ "plan-stopped": { stage: "needs-you", need: "plan-again", act: "inspect-task" },
161
+ "planning-stopped": { stage: "needs-you", need: "planning-stopped", act: "inspect-task" },
151
162
  stopping: { stage: "waiting", wait: "build-stopping" },
152
163
  "build-stopping": { stage: "waiting", wait: "build-stopping" }, "other-computer": { stage: "waiting", wait: "other-computer" },
153
164
  "planning-ready": { stage: "waiting", wait: "plan-next" }, "scouting-ready": { stage: "waiting", wait: "research-next" },
154
165
  "worker-at-capacity": { stage: "waiting", wait: "builders-busy" }, "retry-scheduled": { stage: "waiting", wait: "retry-later" },
166
+ "plan-retry": { stage: "waiting", wait: "plan-retry-later" },
155
167
  updating: { stage: "waiting", wait: "app-update" }, "waiting-dependency": { stage: "waiting", wait: "other-task" },
156
168
  "history-problem": { stage: "needs-you", need: "history", act: "inspect-task" },
157
169
  "earlier-active": { stage: "needs-you", need: "earlier-version", act: "inspect-task" },
@@ -32,7 +32,7 @@ export const REMOTE_ARGUMENTS = new Map([
32
32
  ['task continue', args('id:task', 'request key', { run: 'run' })],
33
33
  ['task assign', args('id:task', 'key runner anyone')],
34
34
  ['task scope', args('id:task', 'key goal not touches budget-usd risk acceptance candidate model provider repair-model')],
35
- ['task plan', args('id:task', 'key provider model', { digest: 'refused' })],
35
+ ['task plan', args('id:task', 'key provider model', { digest: 'refused', incident: 'refused' })],
36
36
  ['task hold', args('id:task', 'key reason until')],
37
37
  ['task unhold', args('id:task', 'key')],
38
38
  ['task require', args('id:task', 'key cap require')],