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
@@ -0,0 +1,338 @@
1
+ import { agentSaidOf } from "./store.js";
2
+ import { failedAttemptSentence, latestFinishedAttempt, stopSuggestionOf } from "./needs-you.js";
3
+ import { retryPinsOf } from "./local-owner-acts.js";
4
+ import { assignmentOf, owedAcceptance, personCompletionRefusal } from "./assignment.js";
5
+ import { assignmentCardOf } from "./assignment-ui.js";
6
+ import { assignmentStageOf, stageOfCode } from "./task-status.js";
7
+ import { taskRoad } from "./first-run.js";
8
+ import { stepRowsOf } from "./workspace-ui.js";
9
+ import { approvalOf } from "./scope.js";
10
+ import { approvalSummaryOf, summaryContextOf } from "./approval-summary.js";
11
+ import { taskWorkSummaryOf } from "./work-summary.js";
12
+ import { terminalDiffView } from "./result-evidence-readers.js";
13
+ import { parseReviewDiff } from "./server/render-results.js";
14
+ import { revisionSourceOf } from "./result-review.js";
15
+ import { DIFF_CONTEXT_MAX, ENGINE_API_VERSION } from "./contracts/engine-api.js";
16
+ import { agentSetupOf, detectionLines, NO_AGENT_YET, npmRegistryOf } from "./agent-detect.js";
17
+ import { scanPatchForSecrets } from "./evidence.js";
18
+ import { fastCompletionProblem } from "./fast-start.js";
19
+ import { viewedGitSync } from "./teardown-git.js";
20
+ import { wasInterrupted } from "./run-ending.js";
21
+ export const isResultRun = (run) => run.finishedAt !== null && (run.role === "builder" || run.role === "scout");
22
+ const AUTOMATIC = new Set(["auto-check", "auto-green"]);
23
+ export function stepCardsOf({ store, family, now, access, evidenceRoot, viewer = null }) {
24
+ const current = family.current, root = family.root;
25
+ const ref = store.lookupRef(current.id);
26
+ const scope = store.getScope(current.id);
27
+ const runs = ref === null ? [] : store.runsFor(ref.id);
28
+ const assignment = assignmentOf(store, current.id, now, access, evidenceRoot);
29
+ const item = taskWorkSummaryOf(store, current.id, now, access);
30
+ const live = runs.find(run => run.finishedAt === null) ?? null;
31
+ const planning = live?.role === "planner";
32
+ const card = assignment === null || item === null ? null : assignmentCardOf(assignment, { workStatus: item.status, planning });
33
+ const approval = approvalOf(scope);
34
+ const approved = approval.approved;
35
+ const report = ref?.deliverable === "report";
36
+ const plannerRuns = runs.filter(run => run.role === "planner");
37
+ const justCode = plannerRuns.length === 0 && (ref?.plan ?? null) === null && approved;
38
+ const journey = current.state === "cancelled" || item === null ? null : (() => {
39
+ const read = assignment !== null ? assignmentStageOf(assignment, { token: item.status.token, views: item.status.views }, planning) : stageOfCode(item.status.token, { planning });
40
+ const checks = card?.status.check ?? null;
41
+ return taskRoad(read, approved, current.state === "done", { checks, report });
42
+ })();
43
+ const facts = {
44
+ journey,
45
+ scout: report,
46
+ status: card === null ? null : { status: { headline: card.status.headline }, attempts: card.attempts },
47
+ approved: scope !== null && approved && scope.approvedBy !== null && scope.approvedAt !== null
48
+ ? { by: scope.approvedBy, at: scope.approvedAt, automatic: AUTOMATIC.has(String(scope.approvalBasis ?? "")), rule: null } : null,
49
+ approve: null,
50
+ plan: plannerRuns.length === 0 && ref?.plan == null ? null
51
+ : { lead: null, by: plannerRuns[0]?.provider ?? null, at: plannerRuns.find(run => run.finishedAt !== null)?.finishedAt ?? null, planning },
52
+ result: assignment?.receipt == null ? null : { selected: assignment.receipt },
53
+ thread: runs.filter(isResultRun).map(run => ({ kind: "result", at: run.finishedAt })),
54
+ };
55
+ const rows = stepRowsOf(facts);
56
+ const builds = runs.filter(run => run.role === "builder" || run.role === "scout" || run.role === "repair");
57
+ const reviews = runs.filter(run => run.role === "reviewer");
58
+ const behind = { plan: plannerRuns, approve: [], build: builds, checks: [], review: reviews, ready: [] };
59
+ const terms = scope === null || approved ? null : (() => {
60
+ const summary = approvalSummaryOf(scope, summaryContextOf(store, current.id, scope, now));
61
+ return { key: summary.key, revision: summary.revision,
62
+ rows: [...summary.revisionChanges, ...summary.decisions, ...(summary.why === null ? [] : [{ label: "Why model", words: summary.why }]), ...summary.differs].map(one => ({ label: one.label, words: one.words, lines: "lines" in one ? [...(one.lines ?? [])] : [] })),
63
+ warnings: summary.warnings.map(one => one.words), usualLabel: summary.usualLabel, usual: summary.usual.map(one => ({ label: one.label, words: one.words })) };
64
+ })();
65
+ const cards = current.state === "cancelled" ? cancelledCards(builds, current.updatedAt ?? null) : rows === null ? null : rows.map(row => ({
66
+ key: row.key, label: row.label, state: row.state, mark: row.mark, sentence: row.sentence, at: row.at, needsYou: row.needsYou,
67
+ inChain: !(justCode && (row.key === "plan" || row.key === "approve")),
68
+ ...runFacts(behind[row.key]),
69
+ ...(row.key === "approve" && terms !== null ? { terms } : {}),
70
+ }));
71
+ if (cards !== null && reviews.length > 0) {
72
+ const latest = reviews[0];
73
+ const state = latest.finishedAt === null ? "current" : latest.outcome === "failed" || latest.outcome === "refused" ? "stuck" : "done";
74
+ const at = cards.findIndex(one => one.key === "ready");
75
+ cards.splice(at === -1 ? cards.length : at, 0, {
76
+ key: "review", label: "Review", state, mark: state === "current" ? "live" : state === "stuck" ? "stuck" : "done",
77
+ sentence: state === "current" ? "Reviewing now" : state === "stuck" ? "The review didn't finish" : "Reviewed",
78
+ at: latest.finishedAt, needsYou: false, inChain: true, ...runFacts(reviews),
79
+ });
80
+ }
81
+ return {
82
+ version: ENGINE_API_VERSION,
83
+ task: { id: current.id, root: root.id, title: root.title, state: current.state, project: current.repo },
84
+ chain: justCode ? "just-code" : "plan-first",
85
+ headline: current.state === "cancelled" ? "Cancelled" : card?.status.headline ?? null,
86
+ liveRun: live?.id ?? null,
87
+ cards,
88
+ review: assignment !== null && assignment.state === "ready-to-check" && assignment.receipt !== null && assignment.receipt.taskId === current.id
89
+ ? { run: assignment.receipt.runId, receipt: assignment.receipt.digest, source: revisionSourceOf(scope?.digest ?? null),
90
+ accept: acceptFactsOf(store, assignment, viewer, evidenceRoot) } : null,
91
+ failure: current.state === "failed" ? failureOf(store, ref?.id ?? null, builds) : null,
92
+ waiting: (() => {
93
+ const waiting = waitingOf(store, current.id, now);
94
+ if (waiting === null)
95
+ return null;
96
+ const last = latestFinishedAttempt(builds);
97
+ return { ...waiting, agentSaid: last !== null && last.outcome === "failed" ? agentSaidOf(store, last.id) : null };
98
+ })(),
99
+ held: current.state === "cancelled" || current.state === "done" ? null : heldOf(store, ref?.id ?? null, builds, now),
100
+ retry: current.state === "failed" ? (() => { const pins = retryPinsOf(store, current.id); return pins === null ? null : { run: pins.run, digest: pins.digest }; })() : null,
101
+ approval: scope !== null && approved && scope.approvedBy !== null
102
+ ? { by: scope.approvedBy, you: viewer !== null && scope.approvedBy === viewer, automatic: AUTOMATIC.has(String(scope.approvalBasis ?? "")) } : null,
103
+ room: `task:${encodeURIComponent(root.id)}`,
104
+ };
105
+ }
106
+ function failureOf(store, taskRef, builds) {
107
+ const last = latestFinishedAttempt(builds);
108
+ const failedInARow = taskRef === null ? 0
109
+ : Number(store.handle.prepare("SELECT strikes FROM task_ref WHERE id = ?").get(taskRef)?.["strikes"] ?? 0);
110
+ return { line: failedAttemptSentence(last?.reason), failedInARow, suggestion: last === null ? null : stopSuggestionOf(last.reason),
111
+ agentSaid: last === null ? null : agentSaidOf(store, last.id) };
112
+ }
113
+ function cancelledCards(builds, at) {
114
+ const out = [];
115
+ const latest = builds[0] ?? null;
116
+ if (latest !== null) {
117
+ const failed = latest.outcome === "failed" || latest.outcome === "refused" || wasInterrupted(latest);
118
+ out.push({ key: "build", label: "Build", state: failed ? "stuck" : "done", mark: failed ? "stuck" : "done",
119
+ sentence: failed ? failedAttemptSentence(latest.reason).replace(/[.\s]+$/, "") : "The build finished", at: latest.finishedAt,
120
+ needsYou: false, inChain: true, ...runFacts(builds) });
121
+ }
122
+ out.push({ key: "ready", label: "Cancelled", state: "skipped", mark: "skipped", sentence: "Cancelled: nothing else will run for this task.",
123
+ at, needsYou: false, inChain: true, ...runFacts([]) });
124
+ return out;
125
+ }
126
+ function heldOf(store, taskRef, builds, now) {
127
+ if (taskRef === null)
128
+ return null;
129
+ const hold = store.activeHolds(taskRef, now).find(one => one.ownerKind === "operator") ?? null;
130
+ if (hold === null)
131
+ return null;
132
+ const last = latestFinishedAttempt(builds);
133
+ return { id: hold.id, reason: hold.reason,
134
+ lastFailure: last !== null && last.outcome === "failed" ? failedAttemptSentence(last.reason).replace(/[.\s]+$/, "") : null };
135
+ }
136
+ export function waitingOf(store, taskId, now) {
137
+ return waitingForTasks(store, [taskId], now).get(taskId) ?? null;
138
+ }
139
+ export function waitingForTasks(store, taskIds, now) {
140
+ const out = new Map();
141
+ const ids = [...new Set(taskIds)];
142
+ if (ids.length === 0)
143
+ return out;
144
+ const at = now.toISOString();
145
+ const rows = store.handle.prepare(`SELECT task.id AS task,
146
+ EXISTS (SELECT 1 FROM hold WHERE hold.task_ref = task_ref.id AND hold.owner_kind = 'backoff' AND (hold.until IS NULL OR hold.until > ?)) AS held,
147
+ (SELECT hold.until FROM hold WHERE hold.task_ref = task_ref.id AND hold.owner_kind = 'backoff' AND (hold.until IS NULL OR hold.until > ?) ORDER BY hold.held_at, hold.id LIMIT 1) AS until,
148
+ (SELECT run.outcome FROM run WHERE run.task_ref = task_ref.id AND run.role IN ('builder', 'scout', 'repair') AND (run.finished_at IS NOT NULL OR run.outcome IS NOT NULL) ORDER BY run.id DESC LIMIT 1) AS outcome,
149
+ (SELECT run.reason FROM run WHERE run.task_ref = task_ref.id AND run.role IN ('builder', 'scout', 'repair') AND (run.finished_at IS NOT NULL OR run.outcome IS NOT NULL) ORDER BY run.id DESC LIMIT 1) AS reason
150
+ FROM task JOIN task_ref ON task_ref.backend = 'built-in' AND task_ref.external_id = task.id
151
+ WHERE task.state = 'queued' AND task.id IN (${ids.map(() => "?").join(", ")})
152
+ -- A person's hold (Stop retrying, a pause, a question, an incident) means it isn't waiting to try again.
153
+ AND NOT EXISTS (SELECT 1 FROM hold WHERE hold.task_ref = task_ref.id AND hold.owner_kind <> 'backoff' AND (hold.until IS NULL OR hold.until > ?))`).all(at, at, ...ids, at);
154
+ for (const row of rows) {
155
+ const failed = row["outcome"] === "failed";
156
+ const held = Number(row["held"]) === 1;
157
+ if (!failed && !held)
158
+ continue;
159
+ out.set(String(row["task"]), {
160
+ retryAt: held && row["until"] != null ? String(row["until"]) : null,
161
+ lastFailure: failed ? failedAttemptSentence(row["reason"] == null ? null : String(row["reason"])).replace(/[.\s]+$/, "") : null,
162
+ });
163
+ }
164
+ return out;
165
+ }
166
+ function runFacts(runs) {
167
+ const latest = runs[0] ?? null;
168
+ const costs = runs.map(run => run.costUsd).filter((one) => typeof one === "number" && Number.isFinite(one));
169
+ return {
170
+ agent: latest === null ? null : { provider: latest.provider, model: latest.modelReported ?? latest.model ?? null },
171
+ startedAt: runs.at(-1)?.startedAt ?? null,
172
+ latestStartedAt: latest?.startedAt ?? null,
173
+ finishedAt: latest?.finishedAt ?? null,
174
+ costUsd: costs.length === 0 ? null : Math.round(costs.reduce((sum, one) => sum + one, 0) * 1e6) / 1e6,
175
+ runs: runs.map(run => run.id),
176
+ };
177
+ }
178
+ export function resultRunsOf(store, family) {
179
+ return family.versions.flatMap(version => store.runsFor(version.refId)).filter(isResultRun).sort((a, b) => b.id - a.id);
180
+ }
181
+ export function patchFiles(text) {
182
+ return text.replace(/\r\n/g, "\n").split(/^(?=diff --git )/m).filter(part => part.startsWith("diff --git ")).map(part => part.replace(/\n$/, ""));
183
+ }
184
+ function diffSourceOf(store, evidenceRoot, run) {
185
+ const view = terminalDiffView(store.artifactsFor(run.id), evidenceRoot);
186
+ if (view === null)
187
+ return { ok: false, problem: "This result recorded no changes." };
188
+ if (view.patch === null)
189
+ return { ok: false, problem: "This result's changes weren't saved." };
190
+ if ("problem" in view.patch)
191
+ return { ok: false, problem: `This result's changes can't be shown: ${view.patch.problem}.` };
192
+ return { ok: true, patch: view.patch.text, truncated: view.patch.truncated, stat: view };
193
+ }
194
+ export function resultDiffOf(store, evidenceRoot, taskId, run) {
195
+ const empty = (problem) => ({ version: ENGINE_API_VERSION, task: taskId, run: run?.id ?? null, totals: null, files: [], patchTruncated: false, problem });
196
+ if (run === null)
197
+ return empty("No result yet.");
198
+ const source = diffSourceOf(store, evidenceRoot, run);
199
+ if (!source.ok)
200
+ return empty(source.problem);
201
+ const files = patchFiles(source.patch).map((text, index) => {
202
+ const parsed = parseReviewDiff(text).files[0];
203
+ let additions = 0, deletions = 0;
204
+ for (const line of text.split("\n")) {
205
+ if (line.startsWith("+") && !line.startsWith("+++"))
206
+ additions += 1;
207
+ else if (line.startsWith("-") && !line.startsWith("---"))
208
+ deletions += 1;
209
+ }
210
+ const binary = /^(?:Binary files .* differ|GIT binary patch)$/m.test(text);
211
+ return { file: index, path: parsed?.path ?? "changed file", oldPath: parsed?.oldPath ?? null, additions, deletions, binary, hunks: parsed?.hunks.length ?? 0 };
212
+ });
213
+ const stat = source.stat?.stat;
214
+ const totals = stat == null || "problem" in stat ? null
215
+ : { files: stat.fileCount, additions: stat.additions, deletions: stat.deletions, binary: stat.binaryCount, filesTruncated: stat.filesTruncated };
216
+ return { version: ENGINE_API_VERSION, task: taskId, run: run.id, totals, files, patchTruncated: source.truncated, problem: null };
217
+ }
218
+ export function resultDiffFileOf(store, evidenceRoot, taskId, run, file) {
219
+ const source = diffSourceOf(store, evidenceRoot, run);
220
+ if (!source.ok)
221
+ return null;
222
+ const text = patchFiles(source.patch)[file];
223
+ if (text === undefined)
224
+ return null;
225
+ const parsed = parseReviewDiff(text);
226
+ const one = parsed.files[0];
227
+ if (one === undefined)
228
+ return null;
229
+ return { version: ENGINE_API_VERSION, task: taskId, run: run.id, file: { file, path: one.path, oldPath: one.oldPath, meta: one.meta, hunks: one.hunks }, linesTruncated: parsed.linesTruncated };
230
+ }
231
+ function acceptFactsOf(store, assignment, viewer, evidenceRoot) {
232
+ const receipt = assignment.receipt;
233
+ const blockers = assignment.readiness?.blockers ?? [];
234
+ const rules = assignment.repo === null ? null : store.approvalRules(assignment.repo);
235
+ const guarded = rules !== null && (rules.protectProject || rules.protectedPaths.length > 0);
236
+ return {
237
+ owed: owedAcceptance(receipt, blockers),
238
+ blockers: blockers.map(one => one.message),
239
+ needs: guarded ? personCompletionRefusal(store, receipt.taskId, receipt.runId, viewer, evidenceRoot) : fastCompletionProblem(store, receipt.taskId, receipt.runId, viewer),
240
+ };
241
+ }
242
+ const CONTEXT_FILE_BYTES = 2 * 1024 * 1024;
243
+ const CONTEXT_LINE_CHARS = 2_000;
244
+ function keyMaterialIn(content) {
245
+ if (/-----BEGIN [A-Z ]*PRIVATE KEY-----/.test(content) || /PuTTY-User-Key-File-\d+:/.test(content))
246
+ return true;
247
+ if (/\b(?:aws_secret_access_key|SecretAccessKey)\b["']?\s*[=:]/i.test(content))
248
+ return true;
249
+ return /"d"\s*:\s*"[^"]{8,}"/.test(content) && /"(?:kty|crv|n)"\s*:/.test(content);
250
+ }
251
+ export function resultDiffContextOf(store, evidenceRoot, taskId, run, file, from, count, repo) {
252
+ const source = diffSourceOf(store, evidenceRoot, run);
253
+ if (!source.ok)
254
+ return null;
255
+ const text = patchFiles(source.patch)[file];
256
+ if (text === undefined)
257
+ return null;
258
+ const one = parseReviewDiff(text).files[0];
259
+ if (one === undefined)
260
+ return null;
261
+ const answer = (lines, lineCount, problem) => ({ version: ENGINE_API_VERSION, task: taskId, run: run.id, file, from, lines, lineCount, problem });
262
+ const unread = "The rest of this file can't be read here. Press w to see it in the browser.";
263
+ if (!Number.isSafeInteger(from) || from < 1 || !Number.isSafeInteger(count) || count < 1 || count > DIFF_CONTEXT_MAX)
264
+ return answer([], null, unread);
265
+ if (/^deleted file mode /m.test(text) || /^\+\+\+ \/dev\/null$/m.test(text))
266
+ return answer([], 0, "This file was removed by the change.");
267
+ const stat = source.stat?.stat;
268
+ const head = run.headRevision;
269
+ if (repo === null || head === null || !/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/.test(head) || stat == null || "problem" in stat || stat.head !== head)
270
+ return answer([], null, unread);
271
+ const path = stat.files.map(changed => changed.path).find(changed => changed === one.path) ?? null;
272
+ if (path === null || path === "" || path.startsWith("/") || path.split("/").some(part => part === ".." || part === "." || part === "")
273
+ || /[\u0000-\u001f\u007f]/.test(path))
274
+ return answer([], null, unread);
275
+ let bytes;
276
+ try {
277
+ const listed = viewedGitSync(repo, ["--no-replace-objects", "--literal-pathspecs", "ls-tree", "-z", "-l", "--full-tree", head, "--", path], { timeoutMs: 10_000, maxBuffer: 64 * 1024, binding: { repo } });
278
+ if (listed.status !== 0)
279
+ return answer([], null, unread);
280
+ const entry = listed.stdout.split("\0").map(row => /^(\d{6}) (\w+) ([0-9a-f]{40,64}) +(\d+|-)\t(.+)$/s.exec(row)).find(match => match !== null && match[5] === path);
281
+ if (entry == null)
282
+ return answer([], 0, "This file isn't in the result's commit.");
283
+ const [, mode, kind, oid, sized] = entry;
284
+ if (kind !== "blob" || (mode !== "100644" && mode !== "100755") || sized === "-")
285
+ return answer([], null, "This file isn't text.");
286
+ const size = Number(sized);
287
+ if (size > CONTEXT_FILE_BYTES)
288
+ return answer([], null, "This file is too large to show here. Press w to see it in the browser.");
289
+ const read = viewedGitSync(repo, ["--no-replace-objects", "cat-file", "blob", oid], { timeoutMs: 10_000, maxBuffer: size + 1024, binding: { repo }, buffer: true });
290
+ if (read.status !== 0 || read.stdout.length !== size)
291
+ return answer([], null, unread);
292
+ bytes = read.stdout;
293
+ }
294
+ catch {
295
+ return answer([], null, unread);
296
+ }
297
+ let content;
298
+ try {
299
+ if (bytes.includes(0))
300
+ throw new Error("binary");
301
+ content = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
302
+ }
303
+ catch {
304
+ return answer([], null, "This file isn't text.");
305
+ }
306
+ if (keyMaterialIn(content))
307
+ return answer([], null, "This file holds what looks like a private key or secret, so its hidden lines aren't shown here.");
308
+ const all = content.split("\n");
309
+ if (all.at(-1) === "")
310
+ all.pop();
311
+ const lineCount = all.length;
312
+ const whole = all.slice(from - 1, from - 1 + count).map(line => line.replace(/\r$/, ""));
313
+ const hits = new Map(scanPatchForSecrets(["diff --git a/f b/f", `@@ -0,0 +1,${whole.length} @@`, ...whole.map(line => `+${line}`)].join("\n")).map(hit => [hit.line - 3, hit.name]));
314
+ const lines = whole.map((line, index) => {
315
+ const name = hits.get(index);
316
+ return { newLine: from + index, text: name === undefined ? line.slice(0, CONTEXT_LINE_CHARS) : `[redacted: ${name} detected on this line]` };
317
+ });
318
+ return answer(lines, lineCount, null);
319
+ }
320
+ export function setupOf(id, home = null) {
321
+ const setup = agentSetupOf(id);
322
+ if (setup === null)
323
+ return { install: null, canInstall: false, signIn: null, canSignIn: false, key: null, check: null, note: null, registry: null, registryUnsure: false };
324
+ const pkg = setup.installRun?.binary === "npm" ? setup.installRun.args[2] ?? null : null;
325
+ const registry = pkg === null || home === null ? { url: null, unsure: false } : npmRegistryOf(home, pkg);
326
+ return { install: setup.install, canInstall: setup.installRun !== null, signIn: setup.signIn, canSignIn: setup.signInRun !== null, key: setup.key, check: setup.check, note: setup.note,
327
+ registry: registry.url, registryUnsure: registry.unsure };
328
+ }
329
+ export function agentsReadOf(detection, view = "full", home = null) {
330
+ const agents = (detection?.agents ?? []).map(one => ({ id: one.id, name: one.name, state: one.state, how: one.how, signIn: one.signIn, ready: one.ready, next: one.next, setup: setupOf(one.id, home) }));
331
+ const first = detection?.firstTask ?? null;
332
+ const firstTask = first === null ? null : { id: first, name: agents.find(one => one.id === first)?.name ?? first };
333
+ if (view === "summary") {
334
+ const lines = firstTask !== null ? [`Your first task goes to ${firstTask.name}.`] : detection === null ? detectionLines(null) : [NO_AGENT_YET];
335
+ return { version: ENGINE_API_VERSION, checkedAt: detection?.checkedAt ?? null, agents: [], firstTask, lines };
336
+ }
337
+ return { version: ENGINE_API_VERSION, checkedAt: detection?.checkedAt ?? null, agents, firstTask, lines: detectionLines(detection) };
338
+ }
@@ -61,9 +61,10 @@ export async function runEvalWorld(one, input) {
61
61
  "--not", "Changing package or dependency files, or anything the goal doesn't ask for."]);
62
62
  const shown = await say(["task", "show", "work"]);
63
63
  const digest = shown["scope"]?.["digest"];
64
- if (typeof digest !== "string")
64
+ const terms = shown["approvalTerms"];
65
+ if (typeof digest !== "string" || typeof terms !== "string")
65
66
  throw new Error("the world's task has no scope to approve");
66
- await say(["task", "approve", "work", "--yes", "--digest", digest, ...auth]);
67
+ await say(["task", "approve", "work", "--yes", "--digest", digest, "--terms", terms, ...auth]);
67
68
  writeNew(join(dirname(databaseFile), "worker-token"), String(registered["token"]), 0o600);
68
69
  }
69
70
  catch (error) {
package/dist/evidence.js CHANGED
@@ -508,6 +508,8 @@ export const SECRET_PATTERNS = [
508
508
  { name: "telegram-bot-token", pattern: /\b\d{8,10}:AA[A-Za-z0-9_-]{33}\b/ },
509
509
  { name: "discord-bot-token", pattern: /\b[MN][A-Za-z\d]{23,25}\.[\w-]{6}\.[\w-]{27,}\b/ },
510
510
  { name: "password-in-url", pattern: /\b[a-z][a-z0-9+.-]*:\/\/[^\s:@/]+:[^\s:@/]{3,}@[^\s/]/i },
511
+ { name: "putty-private-key", pattern: /PuTTY-User-Key-File-\d+:/ },
512
+ { name: "aws-secret-key", pattern: /\b(?:aws_secret_access_key|SecretAccessKey)\b["']?\s*[=:]\s*["']?[A-Za-z0-9/+]{40}/i },
511
513
  ];
512
514
  export function scanForSecrets(text) {
513
515
  const hits = [];
@@ -8,13 +8,19 @@ import { levelOfProfile } from "./policy.js";
8
8
  import { fileTaskProposal } from "./proposal.js";
9
9
  import { releaseCiHoldOf } from "./release-ci-hold.js";
10
10
  import { COMPLETION_ACTION, COMPLETION_BY_PERSON } from "./result-completion.js";
11
+ import { approvalSummaryOf, summaryContextOf } from "./approval-summary.js";
11
12
  import { deployGateScope, machineActing, propose, releaseCheckScope } from "./scope.js";
12
13
  import { BUILT_IN, withdrawApproval } from "./store.js";
13
- import { classifyTask, filingSizer, heuristicSizing } from "./task-sizing.js";
14
+ import { classifyTask, filingSizer, filingSizing, heuristicSizing, SIZING_OFF_REASON, taskSizingOn } from "./task-sizing.js";
15
+ const JUST_CODE_SIZING_OFF = `${SIZING_OFF_REASON}; Just code, as you chose`;
14
16
  import { issueImported } from "./task-source.js";
15
17
  import { titleWithin } from "./task-text.js";
16
18
  import { viewedGitSync } from "./teardown-git.js";
19
+ import { soloNow } from "./install-mode.js";
20
+ import { withLocalAct } from "./local-owner.js";
17
21
  export const FAST_START_RULE = "small-v1";
22
+ export const SOLO_START_RULE = "solo-v1";
23
+ export const SOLO_START_ACTION = "solo start";
18
24
  export const FAST_WINDOW_MS = 30 * 60_000;
19
25
  export const FAST_MAX_FILES = 3;
20
26
  export const FAST_MAX_LINES = 150;
@@ -23,6 +29,7 @@ const FAST_WORDS = {
23
29
  setting: "Small tasks don't start right away in this project.",
24
30
  size: "This looks bigger than a small change.",
25
31
  classifier: "Toolroll couldn't confirm this is a small change.",
32
+ "sizing-off": "Quick start needs task sizing, which is off.",
26
33
  plan: "This needs a plan first.",
27
34
  quality: "Strict checks need a plan first.",
28
35
  rules: "This project's approval rules need a plan first.",
@@ -37,6 +44,7 @@ const FAST_WORDS = {
37
44
  machine: "Only a person starts work this way.",
38
45
  mode: "This project's mode approves it.",
39
46
  limit: "This is more than your chat approval setting allows.",
47
+ team: "Someone else uses this install now, so this needs its plan approved.",
40
48
  };
41
49
  export const fastRefusalWords = (reason) => FAST_WORDS[reason];
42
50
  export function fastStartOn(store, repo) {
@@ -63,16 +71,20 @@ export function fastStartEligible(store, input, now) {
63
71
  }
64
72
  export function fastStartRules(store, input, now) {
65
73
  const no = (reason) => ({ ok: false, reason });
74
+ const solo = input.rule === "solo";
75
+ if (solo && ("chat" in input.proof || !soloNow(store)))
76
+ return no("team");
66
77
  if (!fastStartOn(store, input.repo))
67
78
  return no("setting");
68
79
  const account = store.accountOf(input.actor);
69
80
  if (account === null || account.revokedAt !== null || account.role !== "approver" || !store.accountCanAccess(input.actor, input.repo))
70
81
  return no("rules");
71
- if (heuristicSizing({ title: input.title, goal: input.title }).size !== "small")
82
+ const sizingOff = !solo && !taskSizingOn(store);
83
+ if (!solo && !sizingOff && heuristicSizing({ title: input.title, goal: input.title }).size !== "small")
72
84
  return no("size");
73
- if (input.sizing.source !== "classifier")
85
+ if (!solo && !sizingOff && input.sizing.source !== "classifier")
74
86
  return no("classifier");
75
- if (input.sizing.size !== "small" || input.sizing.risky)
87
+ if (!solo && !sizingOff && (input.sizing.size !== "small" || input.sizing.risky))
76
88
  return no("size");
77
89
  const scope = store.getScope(input.taskId);
78
90
  if (scope === null)
@@ -84,7 +96,7 @@ export function fastStartRules(store, input, now) {
84
96
  const route = routeFromJson(scope.proposedRouteJson ?? null);
85
97
  if (route === null)
86
98
  return no("agents");
87
- if (!makesNoPlan(input.sizing, route.risk))
99
+ if (!solo && !sizingOff && !makesNoPlan(input.sizing, route.risk))
88
100
  return no("plan");
89
101
  if ((scope.qualityMode ?? "default") !== "default")
90
102
  return no("quality");
@@ -95,6 +107,8 @@ export function fastStartRules(store, input, now) {
95
107
  return no("rules");
96
108
  if (isProtectedWork(rules, scope.touches))
97
109
  return no("protected");
110
+ if (sizingOff)
111
+ return no("sizing-off");
98
112
  const gate = store.approvalGate(input.taskId, input.actor, "person");
99
113
  if (gate.verdict !== "seal" || gate.protectedWork)
100
114
  return no("rules");
@@ -146,6 +160,16 @@ function dryRun(store, body) {
146
160
  }
147
161
  throw new Error("unreachable");
148
162
  }
163
+ function withTermsKey(store, read, taskId, now) {
164
+ const scope = store.getScope(taskId);
165
+ return { ...read, termsKey: scope === null ? "" : approvalSummaryOf(scope, summaryContextOf(store, taskId, scope, now)).key };
166
+ }
167
+ const previewDigest = (scope, terms, rule = "small") => rule === "solo" ? `${scope} ${terms} ${SOLO_START_RULE}` : `${scope} ${terms}`;
168
+ function previewParts(value) {
169
+ const [scope, terms, rule, ...rest] = String(value ?? "").split(" ");
170
+ return { scope: scope ?? "", terms: terms === undefined || terms === "" ? null : terms,
171
+ rule: rest.length > 0 ? null : rule === undefined ? "small" : rule === SOLO_START_RULE ? "solo" : null };
172
+ }
149
173
  export async function prepareFastStart(store, input, now) {
150
174
  if (machineActing())
151
175
  return { eligible: false, reason: "machine" };
@@ -153,25 +177,33 @@ export async function prepareFastStart(store, input, now) {
153
177
  return { eligible: false, reason: "rules" };
154
178
  if (!fastStartOn(store, input.repo))
155
179
  return { eligible: false, reason: "setting" };
156
- if (heuristicSizing({ title: input.title, goal: input.title }).size !== "small")
157
- return { eligible: false, reason: "size" };
180
+ const small = filingSizing(store, { title: input.title, goal: input.title }).size === "small";
181
+ const solo = input.planFirst !== true && soloNow(store);
182
+ if (!small && !solo)
183
+ return { eligible: false, reason: taskSizingOn(store) ? "size" : "sizing-off" };
158
184
  const mode = store.activeMode(input.repo, now);
159
185
  if (mode !== null && /"autoApproveFiling":true/.test(mode.termsJson))
160
186
  return { eligible: false, reason: "mode" };
161
- const sizer = filingSizer();
162
- const sizing = await classifyTask({ title: input.title, goal: input.title }, sizer.sizer, sizer.budget);
187
+ const sizer = filingSizer(store);
188
+ const words = filingSizing(store, { title: input.title, goal: input.title });
189
+ const sizing = small && !sizer.off ? await classifyTask({ title: input.title, goal: input.title }, sizer.sizer, sizer.budget)
190
+ : sizer.off && words.size !== "small" ? { ...words, reason: JUST_CODE_SIZING_OFF } : words;
163
191
  const taskId = `task-${randomBytes(8).toString("hex")}`;
164
- const read = dryRun(store, () => {
192
+ const readUnder = (rule) => dryRun(store, () => {
165
193
  const filed = fileIt(store, taskId, { ...input, sizing }, now);
166
194
  if (!filed.ok)
167
195
  return { ok: false, reason: "plan" };
168
- return fastStartEligible(store, { ...input, taskId, sizing }, now);
196
+ return withTermsKey(store, fastStartEligible(store, { ...input, taskId, sizing, rule }, now), taskId, now);
169
197
  });
198
+ let rule = small ? "small" : "solo";
199
+ let read = readUnder(rule);
200
+ if (!read.ok && rule === "small" && solo && (read.reason === "size" || read.reason === "classifier" || read.reason === "sizing-off" || read.reason === "plan"))
201
+ read = readUnder(rule = "solo");
170
202
  if (!read.ok)
171
203
  return { eligible: false, reason: read.reason };
172
204
  const preview = randomBytes(16).toString("hex");
173
205
  store.handle.prepare(`INSERT INTO fast_preview (id, actor, via, task_id, repo, title, permission, sizing_json, digest, created_at, expires_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
174
- .run(preview, input.actor, input.via, taskId, input.repo, input.title, input.permissionMode ?? null, JSON.stringify(sizing), read.scope.digest, now.toISOString(), new Date(now.getTime() + FAST_PREVIEW_MS).toISOString());
206
+ .run(preview, input.actor, input.via, taskId, input.repo, input.title, input.permissionMode ?? null, JSON.stringify(sizing), previewDigest(read.scope.digest, read.termsKey, rule), now.toISOString(), new Date(now.getTime() + FAST_PREVIEW_MS).toISOString());
175
207
  return { eligible: true, preview, digest: read.scope.digest, scope: read.scope, taskId };
176
208
  }
177
209
  export function fastStartBuild(store, input, now) {
@@ -201,16 +233,32 @@ export function fastStartBuild(store, input, now) {
201
233
  const filed = fileIt(store, taskId, { ...filing, via: input.via, sizing }, now);
202
234
  if (!filed.ok)
203
235
  return refuse({ ok: false, reason: "changed", message: filed.message });
204
- const eligible = fastStartEligible(store, { ...filing, taskId, sizing, proof }, now);
236
+ const shown = previewParts(row["digest"]);
237
+ if (shown.rule === null)
238
+ return refuse({ ok: false, reason: "gone", message: "This form has expired. Start again." });
239
+ const rule = shown.rule;
240
+ const eligible = fastStartEligible(store, { ...filing, taskId, sizing, proof, rule }, now);
205
241
  if (!eligible.ok)
206
242
  return refuse({ ok: false, reason: eligible.reason, message: FAST_WORDS[eligible.reason] });
243
+ const shownKey = shown.terms;
244
+ const filedScope = store.getScope(taskId);
245
+ if (shownKey === null || filedScope === null || approvalSummaryOf(filedScope, summaryContextOf(store, taskId, filedScope, now)).key !== shownKey)
246
+ return refuse({ ok: false, reason: "changed", message: "This changed since you read it. Read it again." });
207
247
  const at = now.toISOString();
208
- const approved = input.approveNow(taskId, input.digest, { rule: FAST_START_RULE, at });
248
+ const approved = rule === "solo"
249
+ ? withLocalAct("approve-plan", () => input.approveNow(taskId, input.digest, undefined))
250
+ : input.approveNow(taskId, input.digest, { rule: FAST_START_RULE, at });
209
251
  if (!approved.ok && approved.reason === "changed")
210
252
  return refuse({ ok: false, reason: "changed", message: "This changed since you read it. Read it again." });
211
253
  if (!approved.ok)
212
254
  return refuse(input.via === "chat" ? { ok: false, reason: "rules", message: approved.reason === "policy" ? approved.message : FAST_WORDS.rules } : { ok: false, reason: "password", message: FAST_WORDS.password });
213
255
  store.handle.prepare("UPDATE fast_preview SET consumed_at = ? WHERE id = ?").run(at, input.preview);
256
+ if (rule === "solo") {
257
+ store.recordAction({ at, actor: input.actor, repo: filing.repo, taskId, runId: null, action: SOLO_START_ACTION, outcome: "approved", source: "request",
258
+ detail: JSON.stringify({ v: 1, rule: SOLO_START_RULE, digest: input.digest, terms: shownKey, via: input.via }) });
259
+ store.bumpWake();
260
+ return { ok: true, taskId };
261
+ }
214
262
  store.handle.prepare("UPDATE task_ref SET fast_start_at = ?, fast_start_until = ? WHERE backend = ? AND external_id = ?").run(at, new Date(now.getTime() + FAST_WINDOW_MS).toISOString(), BUILT_IN, taskId);
215
263
  store.bumpWake();
216
264
  return { ok: true, taskId };
@@ -390,12 +438,14 @@ export async function prepareChatStart(store, input, now) {
390
438
  return { eligible: false, reason: "rules" };
391
439
  if (!fastStartOn(store, input.repo))
392
440
  return { eligible: false, reason: "setting" };
441
+ if (!taskSizingOn(store))
442
+ return { eligible: false, reason: "sizing-off" };
393
443
  if (heuristicSizing({ title: input.title, goal: input.title }).size !== "small")
394
444
  return { eligible: false, reason: "size" };
395
445
  const mode = store.activeMode(input.repo, now);
396
446
  if (mode !== null && /"autoApproveFiling":true/.test(mode.termsJson))
397
447
  return { eligible: false, reason: "mode" };
398
- const sizer = filingSizer();
448
+ const sizer = filingSizer(store);
399
449
  const sizing = await classifyTask({ title: input.title, goal: input.title }, sizer.sizer, sizer.budget);
400
450
  const taskId = `task-${randomBytes(8).toString("hex")}`;
401
451
  const filing = { actor: input.actor, repo: input.repo, title: input.title };
@@ -403,20 +453,20 @@ export async function prepareChatStart(store, input, now) {
403
453
  const filed = fileIt(store, taskId, { ...filing, via: "chat", sizing }, now);
404
454
  if (!filed.ok)
405
455
  return { ok: false, reason: "plan" };
406
- return fastStartRules(store, { ...filing, taskId, sizing, proof: { chat: { fullAccess: false, capMicrousd: null } } }, now);
456
+ return withTermsKey(store, fastStartRules(store, { ...filing, taskId, sizing, proof: { chat: { fullAccess: false, capMicrousd: null } } }, now), taskId, now);
407
457
  });
408
458
  if (!read.ok)
409
459
  return { eligible: false, reason: read.reason };
410
460
  const preview = randomBytes(16).toString("hex");
411
461
  store.handle.prepare(`INSERT INTO fast_preview (id, actor, via, task_id, repo, title, permission, sizing_json, digest, created_at, expires_at, turn) VALUES (?, ?, 'chat', ?, ?, ?, NULL, ?, ?, ?, ?, ?)`)
412
- .run(preview, input.actor, taskId, input.repo, input.title, JSON.stringify(sizing), read.scope.digest, now.toISOString(), new Date(now.getTime() + FAST_PREVIEW_MS).toISOString(), input.turn);
462
+ .run(preview, input.actor, taskId, input.repo, input.title, JSON.stringify(sizing), previewDigest(read.scope.digest, read.termsKey), now.toISOString(), new Date(now.getTime() + FAST_PREVIEW_MS).toISOString(), input.turn);
413
463
  return { eligible: true, preview, digest: read.scope.digest, scope: read.scope, taskId };
414
464
  }
415
465
  export function chatStartPreview(store, preview, actor, turn, now) {
416
466
  const row = store.handle.prepare("SELECT * FROM fast_preview WHERE id = ? AND consumed_at IS NULL AND expires_at > ?").get(preview, now.toISOString());
417
467
  if (row === undefined || row["actor"] !== actor || row["via"] !== "chat" || row["turn"] === null || Number(row["turn"]) !== turn)
418
468
  return null;
419
- return { taskId: String(row["task_id"]), repo: String(row["repo"]), title: String(row["title"]), sizing: JSON.parse(String(row["sizing_json"])), digest: String(row["digest"]) };
469
+ return { taskId: String(row["task_id"]), repo: String(row["repo"]), title: String(row["title"]), sizing: JSON.parse(String(row["sizing_json"])), digest: previewParts(row["digest"]).scope };
420
470
  }
421
471
  export function consumeChatStartPreview(store, preview, now) {
422
472
  store.handle.prepare("UPDATE fast_preview SET consumed_at = ? WHERE id = ? AND via = 'chat' AND consumed_at IS NULL").run(now.toISOString(), preview);
@@ -1,8 +1,8 @@
1
- import { describeScope } from "./scope.js";
1
+ import { describeScope, summaryContextOf } from "./approval-summary.js";
2
2
  const LABELS = { goal: "Goal", "not this": "Not this", files: "Files", budget: "Budget", network: "Network", writes: "Writes", reads: "Reads", checks: "Checks", services: "Services" };
3
3
  export function fastTermsLines(store, scope, repo) {
4
4
  const lines = [];
5
- for (const raw of describeScope(scope)) {
5
+ for (const raw of describeScope(scope, undefined, null, summaryContextOf(store, scope.taskId, scope, new Date(), null, repo))) {
6
6
  const line = raw.trimEnd();
7
7
  const named = /^ {2}(\S+(?: \S+)?) {2,}(.*)$/.exec(line);
8
8
  if (named !== null && (named[1] === "version" || named[1] === "approved"))
package/dist/first-run.js CHANGED
@@ -2,6 +2,7 @@ import { run } from "./exec.js";
2
2
  import { hardenedGit } from "./teardown-git.js";
3
3
  import { githubIssues } from "./issues.js";
4
4
  import { START_BUILDER_HREF } from "./needs-you.js";
5
+ import { firstRunAgentLines, firstTaskOf, withNext } from "./agent-detect.js";
5
6
  export const SIGN_IN_COMMAND = "claude auth login";
6
7
  export const SANDBOX_COMMAND = "npx toolroll demo";
7
8
  export const START_COMMAND = "npx toolroll";
@@ -198,6 +199,13 @@ export function welcomeModel(facts) {
198
199
  for (const one of agents)
199
200
  one.optional = signedIn ? one.state !== "signed-in" : installed && one.state === "not-installed";
200
201
  const checking = !signedIn && agents.some(one => one.state === "checking");
202
+ const others = (facts.others ?? []).filter(one => one.state !== "not-installed" && !WELCOME_AGENTS.some(own => own.id === one.id))
203
+ .map(one => ({ id: one.id, name: one.name, state: one.state, signIn: one.signIn, next: one.next, ready: one.ready }));
204
+ const rows = [...agents.map(one => withNext({ id: one.id, name: one.name, how: null, ready: false, next: null,
205
+ state: one.state === "checking" ? "unknown" : one.state, signIn: one.state === "signed-out" ? WELCOME_AGENTS.find(own => own.id === one.id).signIn : null }, facts.routed ?? null)), ...others];
206
+ const firstTask = firstTaskOf(rows, facts.routed ?? null);
207
+ const firstTaskName = firstTask === null ? null : rows.find(one => one.id === firstTask)?.name ?? null;
208
+ const lines = firstRunAgentLines(rows, firstTask, checking, facts.routed ?? null);
201
209
  const builds = facts.buildsOn === null ? null : WELCOME_AGENTS.find(one => one.id === facts.buildsOn)?.name ?? facts.buildsOn;
202
210
  const buildsWith = facts.inUse !== null && facts.buildsOn !== null && facts.buildsOn !== facts.inUse ? builds : null;
203
211
  const hasProject = facts.projects.length > 0;
@@ -207,11 +215,11 @@ export function welcomeModel(facts) {
207
215
  const taskOpen = hasProject;
208
216
  const starters = facts.starters.slice(0, 3).map(one => ({ label: one.label, draft: one.draft, href: `/tasks/new?text=${encodeURIComponent(one.draft)}` }));
209
217
  const model = {
210
- agent: { done: signedIn, checking, agents, inUse: facts.inUse, buildsWith },
218
+ agent: { done: firstTask !== null, checking, agents, inUse: facts.inUse, buildsWith, others, firstTask: firstTaskName, lines },
211
219
  project: { done: projectDone, projects: [...facts.projects], sample, notTakingWork: hasProject && !facts.ready },
212
220
  task: { done: facts.hasTask, open: taskOpen, starters: taskOpen ? starters : [] },
213
221
  };
214
- const agentAct = !signedIn ? false : facts.inUse === null && agents.some(one => one.canUse);
222
+ const agentAct = firstTask === null ? false : facts.inUse === null && agents.some(one => one.canUse);
215
223
  const next = agentAct ? "agent" : !projectDone ? "project" : !facts.hasTask ? "task" : null;
216
224
  const left = [model.agent.done, model.project.done, model.task.done].filter(done => !done).length;
217
225
  return { ...model, next, left };