toolroll 0.9.109 → 0.9.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/agent-detect.js +244 -0
  3. package/dist/agent-fence.js +12 -1
  4. package/dist/agentconfig.js +2 -2
  5. package/dist/approval-summary.js +344 -0
  6. package/dist/attest.js +2 -2
  7. package/dist/browser/workspace.css +2 -2
  8. package/dist/browser/workspace.js +27 -27
  9. package/dist/builder.js +36 -2
  10. package/dist/chat-actions.js +24 -17
  11. package/dist/chat-core.js +3 -1
  12. package/dist/chat-decide.js +101 -46
  13. package/dist/chat-delivery-state.js +2 -0
  14. package/dist/chat-delivery.js +3 -2
  15. package/dist/chat-live.js +2 -1
  16. package/dist/chat-task-actions.js +6 -0
  17. package/dist/check-report.js +1 -1
  18. package/dist/cli.js +2 -0
  19. package/dist/console-instance.js +10 -1
  20. package/dist/contracts/console-api.js +10 -5
  21. package/dist/contracts/engine-api.js +271 -0
  22. package/dist/coordinator.js +2 -2
  23. package/dist/discord-api.js +4 -3
  24. package/dist/discord-chat.js +3 -1
  25. package/dist/easy-start-args.js +7 -3
  26. package/dist/easy-start.js +25 -0
  27. package/dist/egress.js +72 -10
  28. package/dist/engine-handoff.js +34 -0
  29. package/dist/engine-reads.js +261 -0
  30. package/dist/eval-world.js +3 -2
  31. package/dist/evidence.js +2 -0
  32. package/dist/fast-start.js +55 -14
  33. package/dist/fast-terms.js +2 -2
  34. package/dist/first-run.js +10 -2
  35. package/dist/flexible-agents.js +234 -0
  36. package/dist/flexible-answers-schema.js +61 -0
  37. package/dist/flexible-answers.js +889 -0
  38. package/dist/flexible-custody.js +494 -0
  39. package/dist/flexible-import.js +782 -0
  40. package/dist/flexible-launch-schema.js +72 -0
  41. package/dist/flexible-launch.js +331 -0
  42. package/dist/flexible-launcher.js +88 -0
  43. package/dist/flexible-levels.js +34 -0
  44. package/dist/flexible-merge-guard.js +47 -0
  45. package/dist/flexible-refs.js +47 -0
  46. package/dist/flexible-relay-cancel.js +19 -0
  47. package/dist/flexible-relay-schema.js +55 -0
  48. package/dist/flexible-relay-upstreams.js +36 -0
  49. package/dist/flexible-relay.js +1032 -0
  50. package/dist/flexible-session.js +732 -0
  51. package/dist/flexible-ship-schema.js +81 -0
  52. package/dist/flexible-ship.js +694 -0
  53. package/dist/flexible-start.js +80 -0
  54. package/dist/flexible-thread.js +175 -25
  55. package/dist/flexible-turns-schema.js +69 -0
  56. package/dist/flexible-turns.js +490 -0
  57. package/dist/flexible.js +10 -1
  58. package/dist/flow-actions.js +6 -4
  59. package/dist/flow-steps.js +1 -1
  60. package/dist/flows-cli.js +2 -1
  61. package/dist/git-views.js +6 -3
  62. package/dist/install-mode.js +225 -0
  63. package/dist/lead-doors.js +7 -1
  64. package/dist/limits-ui.js +7 -0
  65. package/dist/live-reply.js +6 -0
  66. package/dist/live-terminal.js +425 -29
  67. package/dist/local-owner.js +6 -0
  68. package/dist/model-choices.js +12 -6
  69. package/dist/notification-delivery.js +11 -0
  70. package/dist/operate.js +74 -30
  71. package/dist/outbound-privacy.js +204 -0
  72. package/dist/passwordless.js +2 -1
  73. package/dist/project-delete.js +14 -0
  74. package/dist/provider-connection.js +5 -3
  75. package/dist/publish.js +5 -0
  76. package/dist/pull-request-flow.js +26 -7
  77. package/dist/push.js +5 -1
  78. package/dist/release-card.js +11 -3
  79. package/dist/release.js +10 -1
  80. package/dist/route-store.js +2 -2
  81. package/dist/sandbox-launch.js +32 -8
  82. package/dist/sandbox-runtime.js +16 -7
  83. package/dist/sandbox-tools.js +176 -0
  84. package/dist/scope.js +12 -36
  85. package/dist/scout-net.js +7 -2
  86. package/dist/serve.js +58 -11
  87. package/dist/server/chrome.js +3 -1
  88. package/dist/server/console.css +33 -6
  89. package/dist/server/engine-api.js +378 -0
  90. package/dist/server/flows.js +2 -2
  91. package/dist/server/http.js +7 -0
  92. package/dist/server/link-redemption.js +52 -0
  93. package/dist/server/mutation-key.js +21 -7
  94. package/dist/server/pages.js +69 -40
  95. package/dist/server/people-tokens.js +17 -41
  96. package/dist/server/render-chat.js +1 -0
  97. package/dist/server/render-new-task.js +3 -3
  98. package/dist/server/render-results.js +4 -4
  99. package/dist/server/render-tasks.js +129 -138
  100. package/dist/server/route-table.js +30 -1
  101. package/dist/server/settings-section-table.js +3 -0
  102. package/dist/server/settings-sections.js +33 -0
  103. package/dist/server/settings.js +84 -10
  104. package/dist/server/task-views.js +8 -2
  105. package/dist/server/tasks.js +25 -8
  106. package/dist/server/terminals.js +181 -28
  107. package/dist/server/welcome.js +35 -10
  108. package/dist/settings-groups-ui.js +2 -2
  109. package/dist/settings-proofs.js +13 -9
  110. package/dist/slack-api.js +4 -3
  111. package/dist/slack-chat.js +5 -3
  112. package/dist/spend.js +46 -12
  113. package/dist/status-probe.js +343 -0
  114. package/dist/store.js +102 -5
  115. package/dist/teams-api.js +4 -3
  116. package/dist/teams-chat.js +4 -2
  117. package/dist/telegram-lead.js +2 -1
  118. package/dist/telegram-live.js +2 -1
  119. package/dist/telegram-team.js +2 -1
  120. package/dist/telegram.js +17 -5
  121. package/dist/trusted-path.js +162 -0
  122. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  123. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  124. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  125. package/dist/tui/linux-x64/toolroll-tui +0 -0
  126. package/dist/tui-launch.js +282 -0
  127. package/dist/tui-source.js +5 -3
  128. package/dist/tui.js +1 -1
  129. package/dist/webhooks.js +8 -4
  130. package/dist/welcome-facts.js +22 -15
  131. package/dist/workspace-ui.js +5 -0
  132. package/package.json +1 -1
  133. package/scripts/crash-canary.mjs +1 -1
  134. package/scripts/pilot.mjs +1 -1
  135. package/scripts/provider-canary.mjs +5 -3
@@ -0,0 +1,34 @@
1
+ import { spawn } from "node:child_process";
2
+ export const LINK_FD = 3;
3
+ const LINK = /^http:\/\/(?:127\.0\.0\.1|\[::1\]):[0-9]{1,5}\/login\/once\/[A-Za-z0-9_-]{43}$/;
4
+ export function spawnWithLink(command, args, link, options = {}) {
5
+ const held = spawnHoldingLink(command, args, link, options);
6
+ held.send();
7
+ return held.child;
8
+ }
9
+ export function spawnHoldingLink(command, args, link, options = {}) {
10
+ if (!LINK.test(link))
11
+ throw new Error("not a local one-time sign-in link");
12
+ const code = link.slice(link.lastIndexOf("/") + 1);
13
+ const env = options.env ?? process.env;
14
+ if (args.some(one => one.includes(code)) || Object.entries(env).some(([name, value]) => name.includes(code) || (value ?? "").includes(code))) {
15
+ throw new Error("the sign-in link goes only over the pipe, never in arguments or the environment");
16
+ }
17
+ const [stdin, stdout, stderr] = options.stdio ?? ["inherit", "inherit", "inherit"];
18
+ const child = spawn(command, [...args], { cwd: options.cwd, env, stdio: options.control === true ? [stdin, stdout, stderr, "pipe", "pipe"] : [stdin, stdout, stderr, "pipe"] });
19
+ const pipe = child.stdio[LINK_FD];
20
+ if (pipe === null || pipe === undefined || !("write" in pipe)) {
21
+ child.kill();
22
+ throw new Error("no pipe for the sign-in link");
23
+ }
24
+ pipe.on("error", () => { });
25
+ let sent = false;
26
+ const send = () => {
27
+ if (sent || child.exitCode !== null || child.signalCode !== null)
28
+ return false;
29
+ sent = true;
30
+ pipe.end(`${link}\n`);
31
+ return true;
32
+ };
33
+ return { child, send };
34
+ }
@@ -0,0 +1,261 @@
1
+ import { assignmentOf, owedAcceptance, personCompletionRefusal } from "./assignment.js";
2
+ import { assignmentCardOf } from "./assignment-ui.js";
3
+ import { assignmentStageOf, stageOfCode } from "./task-status.js";
4
+ import { taskRoad } from "./first-run.js";
5
+ import { stepRowsOf } from "./workspace-ui.js";
6
+ import { approvalOf } from "./scope.js";
7
+ import { approvalSummaryOf, summaryContextOf } from "./approval-summary.js";
8
+ import { taskWorkSummaryOf } from "./work-summary.js";
9
+ import { terminalDiffView } from "./result-evidence-readers.js";
10
+ import { parseReviewDiff } from "./server/render-results.js";
11
+ import { revisionSourceOf } from "./result-review.js";
12
+ import { DIFF_CONTEXT_MAX, ENGINE_API_VERSION } from "./contracts/engine-api.js";
13
+ import { agentSetupOf, detectionLines, NO_AGENT_YET, npmRegistryOf } from "./agent-detect.js";
14
+ import { scanPatchForSecrets } from "./evidence.js";
15
+ import { fastCompletionProblem } from "./fast-start.js";
16
+ import { viewedGitSync } from "./teardown-git.js";
17
+ export const isResultRun = (run) => run.finishedAt !== null && (run.role === "builder" || run.role === "scout");
18
+ const AUTOMATIC = new Set(["auto-check", "auto-green"]);
19
+ export function stepCardsOf({ store, family, now, access, evidenceRoot, viewer = null }) {
20
+ const current = family.current, root = family.root;
21
+ const ref = store.lookupRef(current.id);
22
+ const scope = store.getScope(current.id);
23
+ const runs = ref === null ? [] : store.runsFor(ref.id);
24
+ const assignment = assignmentOf(store, current.id, now, access, evidenceRoot);
25
+ const item = taskWorkSummaryOf(store, current.id, now, access);
26
+ const live = runs.find(run => run.finishedAt === null) ?? null;
27
+ const planning = live?.role === "planner";
28
+ const card = assignment === null || item === null ? null : assignmentCardOf(assignment, { workStatus: item.status, planning });
29
+ const approval = approvalOf(scope);
30
+ const approved = approval.approved;
31
+ const report = ref?.deliverable === "report";
32
+ const plannerRuns = runs.filter(run => run.role === "planner");
33
+ const justCode = plannerRuns.length === 0 && (ref?.plan ?? null) === null && approved;
34
+ const journey = current.state === "cancelled" || item === null ? null : (() => {
35
+ const read = assignment !== null ? assignmentStageOf(assignment, { token: item.status.token, views: item.status.views }, planning) : stageOfCode(item.status.token, { planning });
36
+ const checks = card?.status.check ?? null;
37
+ return taskRoad(read, approved, current.state === "done", { checks, report });
38
+ })();
39
+ const facts = {
40
+ journey,
41
+ scout: report,
42
+ status: card === null ? null : { status: { headline: card.status.headline }, attempts: card.attempts },
43
+ approved: scope !== null && approved && scope.approvedBy !== null && scope.approvedAt !== null
44
+ ? { by: scope.approvedBy, at: scope.approvedAt, automatic: AUTOMATIC.has(String(scope.approvalBasis ?? "")), rule: null } : null,
45
+ approve: null,
46
+ plan: plannerRuns.length === 0 && ref?.plan == null ? null
47
+ : { lead: null, by: plannerRuns[0]?.provider ?? null, at: plannerRuns.find(run => run.finishedAt !== null)?.finishedAt ?? null, planning },
48
+ result: assignment?.receipt == null ? null : { selected: assignment.receipt },
49
+ thread: runs.filter(isResultRun).map(run => ({ kind: "result", at: run.finishedAt })),
50
+ };
51
+ const rows = stepRowsOf(facts);
52
+ const builds = runs.filter(run => run.role === "builder" || run.role === "scout" || run.role === "repair");
53
+ const reviews = runs.filter(run => run.role === "reviewer");
54
+ const behind = { plan: plannerRuns, approve: [], build: builds, checks: [], review: reviews, ready: [] };
55
+ const terms = scope === null || approved ? null : (() => {
56
+ const summary = approvalSummaryOf(scope, summaryContextOf(store, current.id, scope, now));
57
+ return { key: summary.key, revision: summary.revision,
58
+ 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 ?? [])] : [] })),
59
+ warnings: summary.warnings.map(one => one.words), usualLabel: summary.usualLabel, usual: summary.usual.map(one => ({ label: one.label, words: one.words })) };
60
+ })();
61
+ const cards = rows === null ? null : rows.map(row => ({
62
+ key: row.key, label: row.label, state: row.state, mark: row.mark, sentence: row.sentence, at: row.at, needsYou: row.needsYou,
63
+ inChain: !(justCode && (row.key === "plan" || row.key === "approve")),
64
+ ...runFacts(behind[row.key]),
65
+ ...(row.key === "approve" && terms !== null ? { terms } : {}),
66
+ }));
67
+ if (cards !== null && reviews.length > 0) {
68
+ const latest = reviews[0];
69
+ const state = latest.finishedAt === null ? "current" : latest.outcome === "failed" || latest.outcome === "refused" ? "stuck" : "done";
70
+ const at = cards.findIndex(one => one.key === "ready");
71
+ cards.splice(at === -1 ? cards.length : at, 0, {
72
+ key: "review", label: "Review", state, mark: state === "current" ? "live" : state === "stuck" ? "stuck" : "done",
73
+ sentence: state === "current" ? "Reviewing now" : state === "stuck" ? "The review didn't finish" : "Reviewed",
74
+ at: latest.finishedAt, needsYou: false, inChain: true, ...runFacts(reviews),
75
+ });
76
+ }
77
+ return {
78
+ version: ENGINE_API_VERSION,
79
+ task: { id: current.id, root: root.id, title: root.title, state: current.state, project: current.repo },
80
+ chain: justCode ? "just-code" : "plan-first",
81
+ headline: card?.status.headline ?? null,
82
+ liveRun: live?.id ?? null,
83
+ cards,
84
+ review: assignment !== null && assignment.state === "ready-to-check" && assignment.receipt !== null && assignment.receipt.taskId === current.id
85
+ ? { run: assignment.receipt.runId, receipt: assignment.receipt.digest, source: revisionSourceOf(scope?.digest ?? null),
86
+ accept: acceptFactsOf(store, assignment, viewer, evidenceRoot) } : null,
87
+ room: `task:${encodeURIComponent(root.id)}`,
88
+ };
89
+ }
90
+ function runFacts(runs) {
91
+ const latest = runs[0] ?? null;
92
+ const costs = runs.map(run => run.costUsd).filter((one) => typeof one === "number" && Number.isFinite(one));
93
+ return {
94
+ agent: latest === null ? null : { provider: latest.provider, model: latest.modelReported ?? latest.model ?? null },
95
+ startedAt: runs.at(-1)?.startedAt ?? null,
96
+ finishedAt: latest?.finishedAt ?? null,
97
+ costUsd: costs.length === 0 ? null : Math.round(costs.reduce((sum, one) => sum + one, 0) * 1e6) / 1e6,
98
+ runs: runs.map(run => run.id),
99
+ };
100
+ }
101
+ export function resultRunsOf(store, family) {
102
+ return family.versions.flatMap(version => store.runsFor(version.refId)).filter(isResultRun).sort((a, b) => b.id - a.id);
103
+ }
104
+ export function patchFiles(text) {
105
+ return text.replace(/\r\n/g, "\n").split(/^(?=diff --git )/m).filter(part => part.startsWith("diff --git ")).map(part => part.replace(/\n$/, ""));
106
+ }
107
+ function diffSourceOf(store, evidenceRoot, run) {
108
+ const view = terminalDiffView(store.artifactsFor(run.id), evidenceRoot);
109
+ if (view === null)
110
+ return { ok: false, problem: "This result recorded no changes." };
111
+ if (view.patch === null)
112
+ return { ok: false, problem: "This result's changes weren't saved." };
113
+ if ("problem" in view.patch)
114
+ return { ok: false, problem: `This result's changes can't be shown: ${view.patch.problem}.` };
115
+ return { ok: true, patch: view.patch.text, truncated: view.patch.truncated, stat: view };
116
+ }
117
+ export function resultDiffOf(store, evidenceRoot, taskId, run) {
118
+ const empty = (problem) => ({ version: ENGINE_API_VERSION, task: taskId, run: run?.id ?? null, totals: null, files: [], patchTruncated: false, problem });
119
+ if (run === null)
120
+ return empty("No result yet.");
121
+ const source = diffSourceOf(store, evidenceRoot, run);
122
+ if (!source.ok)
123
+ return empty(source.problem);
124
+ const files = patchFiles(source.patch).map((text, index) => {
125
+ const parsed = parseReviewDiff(text).files[0];
126
+ let additions = 0, deletions = 0;
127
+ for (const line of text.split("\n")) {
128
+ if (line.startsWith("+") && !line.startsWith("+++"))
129
+ additions += 1;
130
+ else if (line.startsWith("-") && !line.startsWith("---"))
131
+ deletions += 1;
132
+ }
133
+ const binary = /^(?:Binary files .* differ|GIT binary patch)$/m.test(text);
134
+ return { file: index, path: parsed?.path ?? "changed file", oldPath: parsed?.oldPath ?? null, additions, deletions, binary, hunks: parsed?.hunks.length ?? 0 };
135
+ });
136
+ const stat = source.stat?.stat;
137
+ const totals = stat == null || "problem" in stat ? null
138
+ : { files: stat.fileCount, additions: stat.additions, deletions: stat.deletions, binary: stat.binaryCount, filesTruncated: stat.filesTruncated };
139
+ return { version: ENGINE_API_VERSION, task: taskId, run: run.id, totals, files, patchTruncated: source.truncated, problem: null };
140
+ }
141
+ export function resultDiffFileOf(store, evidenceRoot, taskId, run, file) {
142
+ const source = diffSourceOf(store, evidenceRoot, run);
143
+ if (!source.ok)
144
+ return null;
145
+ const text = patchFiles(source.patch)[file];
146
+ if (text === undefined)
147
+ return null;
148
+ const parsed = parseReviewDiff(text);
149
+ const one = parsed.files[0];
150
+ if (one === undefined)
151
+ return null;
152
+ 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 };
153
+ }
154
+ function acceptFactsOf(store, assignment, viewer, evidenceRoot) {
155
+ const receipt = assignment.receipt;
156
+ const blockers = assignment.readiness?.blockers ?? [];
157
+ const rules = assignment.repo === null ? null : store.approvalRules(assignment.repo);
158
+ const guarded = rules !== null && (rules.protectProject || rules.protectedPaths.length > 0);
159
+ return {
160
+ owed: owedAcceptance(receipt, blockers),
161
+ blockers: blockers.map(one => one.message),
162
+ needs: guarded ? personCompletionRefusal(store, receipt.taskId, receipt.runId, viewer, evidenceRoot) : fastCompletionProblem(store, receipt.taskId, receipt.runId, viewer),
163
+ };
164
+ }
165
+ const CONTEXT_FILE_BYTES = 2 * 1024 * 1024;
166
+ const CONTEXT_LINE_CHARS = 2_000;
167
+ function keyMaterialIn(content) {
168
+ if (/-----BEGIN [A-Z ]*PRIVATE KEY-----/.test(content) || /PuTTY-User-Key-File-\d+:/.test(content))
169
+ return true;
170
+ if (/\b(?:aws_secret_access_key|SecretAccessKey)\b["']?\s*[=:]/i.test(content))
171
+ return true;
172
+ return /"d"\s*:\s*"[^"]{8,}"/.test(content) && /"(?:kty|crv|n)"\s*:/.test(content);
173
+ }
174
+ export function resultDiffContextOf(store, evidenceRoot, taskId, run, file, from, count, repo) {
175
+ const source = diffSourceOf(store, evidenceRoot, run);
176
+ if (!source.ok)
177
+ return null;
178
+ const text = patchFiles(source.patch)[file];
179
+ if (text === undefined)
180
+ return null;
181
+ const one = parseReviewDiff(text).files[0];
182
+ if (one === undefined)
183
+ return null;
184
+ const answer = (lines, lineCount, problem) => ({ version: ENGINE_API_VERSION, task: taskId, run: run.id, file, from, lines, lineCount, problem });
185
+ const unread = "The rest of this file can't be read here. Press w to see it in the browser.";
186
+ if (!Number.isSafeInteger(from) || from < 1 || !Number.isSafeInteger(count) || count < 1 || count > DIFF_CONTEXT_MAX)
187
+ return answer([], null, unread);
188
+ if (/^deleted file mode /m.test(text) || /^\+\+\+ \/dev\/null$/m.test(text))
189
+ return answer([], 0, "This file was removed by the change.");
190
+ const stat = source.stat?.stat;
191
+ const head = run.headRevision;
192
+ if (repo === null || head === null || !/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/.test(head) || stat == null || "problem" in stat || stat.head !== head)
193
+ return answer([], null, unread);
194
+ const path = stat.files.map(changed => changed.path).find(changed => changed === one.path) ?? null;
195
+ if (path === null || path === "" || path.startsWith("/") || path.split("/").some(part => part === ".." || part === "." || part === "")
196
+ || /[\u0000-\u001f\u007f]/.test(path))
197
+ return answer([], null, unread);
198
+ let bytes;
199
+ try {
200
+ 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 } });
201
+ if (listed.status !== 0)
202
+ return answer([], null, unread);
203
+ 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);
204
+ if (entry == null)
205
+ return answer([], 0, "This file isn't in the result's commit.");
206
+ const [, mode, kind, oid, sized] = entry;
207
+ if (kind !== "blob" || (mode !== "100644" && mode !== "100755") || sized === "-")
208
+ return answer([], null, "This file isn't text.");
209
+ const size = Number(sized);
210
+ if (size > CONTEXT_FILE_BYTES)
211
+ return answer([], null, "This file is too large to show here. Press w to see it in the browser.");
212
+ const read = viewedGitSync(repo, ["--no-replace-objects", "cat-file", "blob", oid], { timeoutMs: 10_000, maxBuffer: size + 1024, binding: { repo }, buffer: true });
213
+ if (read.status !== 0 || read.stdout.length !== size)
214
+ return answer([], null, unread);
215
+ bytes = read.stdout;
216
+ }
217
+ catch {
218
+ return answer([], null, unread);
219
+ }
220
+ let content;
221
+ try {
222
+ if (bytes.includes(0))
223
+ throw new Error("binary");
224
+ content = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
225
+ }
226
+ catch {
227
+ return answer([], null, "This file isn't text.");
228
+ }
229
+ if (keyMaterialIn(content))
230
+ return answer([], null, "This file holds what looks like a private key or secret, so its hidden lines aren't shown here.");
231
+ const all = content.split("\n");
232
+ if (all.at(-1) === "")
233
+ all.pop();
234
+ const lineCount = all.length;
235
+ const whole = all.slice(from - 1, from - 1 + count).map(line => line.replace(/\r$/, ""));
236
+ 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]));
237
+ const lines = whole.map((line, index) => {
238
+ const name = hits.get(index);
239
+ return { newLine: from + index, text: name === undefined ? line.slice(0, CONTEXT_LINE_CHARS) : `[redacted: ${name} detected on this line]` };
240
+ });
241
+ return answer(lines, lineCount, null);
242
+ }
243
+ export function setupOf(id, home = null) {
244
+ const setup = agentSetupOf(id);
245
+ if (setup === null)
246
+ return { install: null, canInstall: false, signIn: null, canSignIn: false, key: null, check: null, note: null, registry: null, registryUnsure: false };
247
+ const pkg = setup.installRun?.binary === "npm" ? setup.installRun.args[2] ?? null : null;
248
+ const registry = pkg === null || home === null ? { url: null, unsure: false } : npmRegistryOf(home, pkg);
249
+ return { install: setup.install, canInstall: setup.installRun !== null, signIn: setup.signIn, canSignIn: setup.signInRun !== null, key: setup.key, check: setup.check, note: setup.note,
250
+ registry: registry.url, registryUnsure: registry.unsure };
251
+ }
252
+ export function agentsReadOf(detection, view = "full", home = null) {
253
+ 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) }));
254
+ const first = detection?.firstTask ?? null;
255
+ const firstTask = first === null ? null : { id: first, name: agents.find(one => one.id === first)?.name ?? first };
256
+ if (view === "summary") {
257
+ const lines = firstTask !== null ? [`Your first task goes to ${firstTask.name}.`] : detection === null ? detectionLines(null) : [NO_AGENT_YET];
258
+ return { version: ENGINE_API_VERSION, checkedAt: detection?.checkedAt ?? null, agents: [], firstTask, lines };
259
+ }
260
+ return { version: ENGINE_API_VERSION, checkedAt: detection?.checkedAt ?? null, agents, firstTask, lines: detectionLines(detection) };
261
+ }
@@ -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,18 @@ 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
14
  import { classifyTask, filingSizer, heuristicSizing } from "./task-sizing.js";
14
15
  import { issueImported } from "./task-source.js";
15
16
  import { titleWithin } from "./task-text.js";
16
17
  import { viewedGitSync } from "./teardown-git.js";
18
+ import { soloNow } from "./install-mode.js";
19
+ import { withLocalAct } from "./local-owner.js";
17
20
  export const FAST_START_RULE = "small-v1";
21
+ export const SOLO_START_RULE = "solo-v1";
22
+ export const SOLO_START_ACTION = "solo start";
18
23
  export const FAST_WINDOW_MS = 30 * 60_000;
19
24
  export const FAST_MAX_FILES = 3;
20
25
  export const FAST_MAX_LINES = 150;
@@ -37,6 +42,7 @@ const FAST_WORDS = {
37
42
  machine: "Only a person starts work this way.",
38
43
  mode: "This project's mode approves it.",
39
44
  limit: "This is more than your chat approval setting allows.",
45
+ team: "Someone else uses this install now, so this needs its plan approved.",
40
46
  };
41
47
  export const fastRefusalWords = (reason) => FAST_WORDS[reason];
42
48
  export function fastStartOn(store, repo) {
@@ -63,16 +69,19 @@ export function fastStartEligible(store, input, now) {
63
69
  }
64
70
  export function fastStartRules(store, input, now) {
65
71
  const no = (reason) => ({ ok: false, reason });
72
+ const solo = input.rule === "solo";
73
+ if (solo && ("chat" in input.proof || !soloNow(store)))
74
+ return no("team");
66
75
  if (!fastStartOn(store, input.repo))
67
76
  return no("setting");
68
77
  const account = store.accountOf(input.actor);
69
78
  if (account === null || account.revokedAt !== null || account.role !== "approver" || !store.accountCanAccess(input.actor, input.repo))
70
79
  return no("rules");
71
- if (heuristicSizing({ title: input.title, goal: input.title }).size !== "small")
80
+ if (!solo && heuristicSizing({ title: input.title, goal: input.title }).size !== "small")
72
81
  return no("size");
73
- if (input.sizing.source !== "classifier")
82
+ if (!solo && input.sizing.source !== "classifier")
74
83
  return no("classifier");
75
- if (input.sizing.size !== "small" || input.sizing.risky)
84
+ if (!solo && (input.sizing.size !== "small" || input.sizing.risky))
76
85
  return no("size");
77
86
  const scope = store.getScope(input.taskId);
78
87
  if (scope === null)
@@ -84,7 +93,7 @@ export function fastStartRules(store, input, now) {
84
93
  const route = routeFromJson(scope.proposedRouteJson ?? null);
85
94
  if (route === null)
86
95
  return no("agents");
87
- if (!makesNoPlan(input.sizing, route.risk))
96
+ if (!solo && !makesNoPlan(input.sizing, route.risk))
88
97
  return no("plan");
89
98
  if ((scope.qualityMode ?? "default") !== "default")
90
99
  return no("quality");
@@ -146,6 +155,16 @@ function dryRun(store, body) {
146
155
  }
147
156
  throw new Error("unreachable");
148
157
  }
158
+ function withTermsKey(store, read, taskId, now) {
159
+ const scope = store.getScope(taskId);
160
+ return { ...read, termsKey: scope === null ? "" : approvalSummaryOf(scope, summaryContextOf(store, taskId, scope, now)).key };
161
+ }
162
+ const previewDigest = (scope, terms, rule = "small") => rule === "solo" ? `${scope} ${terms} ${SOLO_START_RULE}` : `${scope} ${terms}`;
163
+ function previewParts(value) {
164
+ const [scope, terms, rule, ...rest] = String(value ?? "").split(" ");
165
+ return { scope: scope ?? "", terms: terms === undefined || terms === "" ? null : terms,
166
+ rule: rest.length > 0 ? null : rule === undefined ? "small" : rule === SOLO_START_RULE ? "solo" : null };
167
+ }
149
168
  export async function prepareFastStart(store, input, now) {
150
169
  if (machineActing())
151
170
  return { eligible: false, reason: "machine" };
@@ -153,25 +172,31 @@ export async function prepareFastStart(store, input, now) {
153
172
  return { eligible: false, reason: "rules" };
154
173
  if (!fastStartOn(store, input.repo))
155
174
  return { eligible: false, reason: "setting" };
156
- if (heuristicSizing({ title: input.title, goal: input.title }).size !== "small")
175
+ const small = heuristicSizing({ title: input.title, goal: input.title }).size === "small";
176
+ const solo = input.planFirst !== true && soloNow(store);
177
+ if (!small && !solo)
157
178
  return { eligible: false, reason: "size" };
158
179
  const mode = store.activeMode(input.repo, now);
159
180
  if (mode !== null && /"autoApproveFiling":true/.test(mode.termsJson))
160
181
  return { eligible: false, reason: "mode" };
161
182
  const sizer = filingSizer();
162
- const sizing = await classifyTask({ title: input.title, goal: input.title }, sizer.sizer, sizer.budget);
183
+ const sizing = small ? await classifyTask({ title: input.title, goal: input.title }, sizer.sizer, sizer.budget) : heuristicSizing({ title: input.title, goal: input.title });
163
184
  const taskId = `task-${randomBytes(8).toString("hex")}`;
164
- const read = dryRun(store, () => {
185
+ const readUnder = (rule) => dryRun(store, () => {
165
186
  const filed = fileIt(store, taskId, { ...input, sizing }, now);
166
187
  if (!filed.ok)
167
188
  return { ok: false, reason: "plan" };
168
- return fastStartEligible(store, { ...input, taskId, sizing }, now);
189
+ return withTermsKey(store, fastStartEligible(store, { ...input, taskId, sizing, rule }, now), taskId, now);
169
190
  });
191
+ let rule = small ? "small" : "solo";
192
+ let read = readUnder(rule);
193
+ if (!read.ok && rule === "small" && solo && (read.reason === "size" || read.reason === "classifier" || read.reason === "plan"))
194
+ read = readUnder(rule = "solo");
170
195
  if (!read.ok)
171
196
  return { eligible: false, reason: read.reason };
172
197
  const preview = randomBytes(16).toString("hex");
173
198
  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());
199
+ .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
200
  return { eligible: true, preview, digest: read.scope.digest, scope: read.scope, taskId };
176
201
  }
177
202
  export function fastStartBuild(store, input, now) {
@@ -201,16 +226,32 @@ export function fastStartBuild(store, input, now) {
201
226
  const filed = fileIt(store, taskId, { ...filing, via: input.via, sizing }, now);
202
227
  if (!filed.ok)
203
228
  return refuse({ ok: false, reason: "changed", message: filed.message });
204
- const eligible = fastStartEligible(store, { ...filing, taskId, sizing, proof }, now);
229
+ const shown = previewParts(row["digest"]);
230
+ if (shown.rule === null)
231
+ return refuse({ ok: false, reason: "gone", message: "This form has expired. Start again." });
232
+ const rule = shown.rule;
233
+ const eligible = fastStartEligible(store, { ...filing, taskId, sizing, proof, rule }, now);
205
234
  if (!eligible.ok)
206
235
  return refuse({ ok: false, reason: eligible.reason, message: FAST_WORDS[eligible.reason] });
236
+ const shownKey = shown.terms;
237
+ const filedScope = store.getScope(taskId);
238
+ if (shownKey === null || filedScope === null || approvalSummaryOf(filedScope, summaryContextOf(store, taskId, filedScope, now)).key !== shownKey)
239
+ return refuse({ ok: false, reason: "changed", message: "This changed since you read it. Read it again." });
207
240
  const at = now.toISOString();
208
- const approved = input.approveNow(taskId, input.digest, { rule: FAST_START_RULE, at });
241
+ const approved = rule === "solo"
242
+ ? withLocalAct("approve-plan", () => input.approveNow(taskId, input.digest, undefined))
243
+ : input.approveNow(taskId, input.digest, { rule: FAST_START_RULE, at });
209
244
  if (!approved.ok && approved.reason === "changed")
210
245
  return refuse({ ok: false, reason: "changed", message: "This changed since you read it. Read it again." });
211
246
  if (!approved.ok)
212
247
  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
248
  store.handle.prepare("UPDATE fast_preview SET consumed_at = ? WHERE id = ?").run(at, input.preview);
249
+ if (rule === "solo") {
250
+ store.recordAction({ at, actor: input.actor, repo: filing.repo, taskId, runId: null, action: SOLO_START_ACTION, outcome: "approved", source: "request",
251
+ detail: JSON.stringify({ v: 1, rule: SOLO_START_RULE, digest: input.digest, terms: shownKey, via: input.via }) });
252
+ store.bumpWake();
253
+ return { ok: true, taskId };
254
+ }
214
255
  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
256
  store.bumpWake();
216
257
  return { ok: true, taskId };
@@ -403,20 +444,20 @@ export async function prepareChatStart(store, input, now) {
403
444
  const filed = fileIt(store, taskId, { ...filing, via: "chat", sizing }, now);
404
445
  if (!filed.ok)
405
446
  return { ok: false, reason: "plan" };
406
- return fastStartRules(store, { ...filing, taskId, sizing, proof: { chat: { fullAccess: false, capMicrousd: null } } }, now);
447
+ return withTermsKey(store, fastStartRules(store, { ...filing, taskId, sizing, proof: { chat: { fullAccess: false, capMicrousd: null } } }, now), taskId, now);
407
448
  });
408
449
  if (!read.ok)
409
450
  return { eligible: false, reason: read.reason };
410
451
  const preview = randomBytes(16).toString("hex");
411
452
  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);
453
+ .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
454
  return { eligible: true, preview, digest: read.scope.digest, scope: read.scope, taskId };
414
455
  }
415
456
  export function chatStartPreview(store, preview, actor, turn, now) {
416
457
  const row = store.handle.prepare("SELECT * FROM fast_preview WHERE id = ? AND consumed_at IS NULL AND expires_at > ?").get(preview, now.toISOString());
417
458
  if (row === undefined || row["actor"] !== actor || row["via"] !== "chat" || row["turn"] === null || Number(row["turn"]) !== turn)
418
459
  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"]) };
460
+ 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
461
  }
421
462
  export function consumeChatStartPreview(store, preview, now) {
422
463
  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 };