toolroll 0.9.105 → 0.9.107
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.
- package/CHANGELOG.md +43 -0
- package/README.md +5 -4
- package/dist/bin.js +38 -4
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +4 -4
- package/dist/cli.js +18 -11
- package/dist/contracts/cli.js +1 -1
- package/dist/demo-sign-in.js +1 -55
- package/dist/demo.js +8 -3
- package/dist/easy-start-args.js +4 -2
- package/dist/easy-start.js +125 -28
- package/dist/first-run.js +4 -1
- package/dist/flow-code.js +2 -1
- package/dist/git-floor.js +9 -2
- package/dist/guides.js +1 -1
- package/dist/invoke.js +4 -4
- package/dist/lead-voice.js +3 -3
- package/dist/operate.js +36 -10
- package/dist/sandbox-runtime.js +36 -2
- package/dist/sign-in-page.js +197 -0
- package/dist/store.js +4 -0
- package/dist/toolroll-update-cli.js +18 -1
- package/dist/tui.js +48 -48
- package/dist/welcome-facts.js +5 -2
- package/dist/work-index.js +81 -66
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1172,7 +1172,19 @@ async function runDemoCommand(argv, write, seams = {}) {
|
|
|
1172
1172
|
const url = allowedHosts.length > 0 ? `http://${allowedHosts[0]}` : `http://127.0.0.1:${boundPort}`;
|
|
1173
1173
|
const terminal = seams.terminal ?? (process.stdin.isTTY === true && process.stdout.isTTY === true);
|
|
1174
1174
|
const demoSignIn = await import("./demo-sign-in.js");
|
|
1175
|
-
const
|
|
1175
|
+
const signInPage = await import("./sign-in-page.js");
|
|
1176
|
+
const canOpen = signInPage.platformOpener() !== null;
|
|
1177
|
+
const { SIGN_IN_LINK_MS } = await import("./server/session.js");
|
|
1178
|
+
const linkExpiresAt = Date.now() + SIGN_IN_LINK_MS;
|
|
1179
|
+
const signIn = canOpen ? demoSignIn.demoSignInLink(server, seed.login.name, { stdin: terminal, stdout: terminal, agent: seams.underAgent ?? underAgent(process.env), json }) : null;
|
|
1180
|
+
let removePage = () => { };
|
|
1181
|
+
let opened = false;
|
|
1182
|
+
if (signIn !== null) {
|
|
1183
|
+
const page = await signInPage.openSignInLink(signIn, { parent: sandbox, spent: signInPage.ledgerSpent(store, "one-time link", seed.login.name), expiresAt: linkExpiresAt,
|
|
1184
|
+
...(seams.opener === undefined ? {} : { opener: seams.opener }) });
|
|
1185
|
+
removePage = page.stop;
|
|
1186
|
+
opened = page.opened;
|
|
1187
|
+
}
|
|
1176
1188
|
if (json) {
|
|
1177
1189
|
write(envelopeJson({ ok: true, command: "demo", url, sandbox, login: { name: seed.login.name, passwordFile }, keep }));
|
|
1178
1190
|
}
|
|
@@ -1183,10 +1195,14 @@ async function runDemoCommand(argv, write, seams = {}) {
|
|
|
1183
1195
|
write(` login ${seed.login.name} / ${seed.login.password}`);
|
|
1184
1196
|
write(` sandbox ${sandbox}`);
|
|
1185
1197
|
write("");
|
|
1186
|
-
if (
|
|
1198
|
+
if (opened) {
|
|
1187
1199
|
write("Opened in your browser, signed in.");
|
|
1188
1200
|
write("");
|
|
1189
1201
|
}
|
|
1202
|
+
else if (signIn !== null) {
|
|
1203
|
+
write("Your browser didn't open: go to the address above and sign in with the login above.");
|
|
1204
|
+
write("");
|
|
1205
|
+
}
|
|
1190
1206
|
write("Open Chat and ask for a change, like \"fix the flaky refund test\".");
|
|
1191
1207
|
write("For your own project, run `toolroll` in its folder.");
|
|
1192
1208
|
write("");
|
|
@@ -1194,15 +1210,6 @@ async function runDemoCommand(argv, write, seams = {}) {
|
|
|
1194
1210
|
? "Ctrl-C stops the server; the sandbox is KEPT. It stays a demo forever — every spending command refuses it."
|
|
1195
1211
|
: "Ctrl-C stops the server and deletes the sandbox. --keep preserves it (still fenced from spending).");
|
|
1196
1212
|
}
|
|
1197
|
-
let removePage = () => { };
|
|
1198
|
-
if (signIn !== null) {
|
|
1199
|
-
const page = demoSignIn.writeSignInPage(sandbox, signIn);
|
|
1200
|
-
removePage = demoSignIn.removeSignInPageWhenSpent(store, page, seed.login.name);
|
|
1201
|
-
if (seams.openPage !== undefined)
|
|
1202
|
-
seams.openPage(page);
|
|
1203
|
-
else
|
|
1204
|
-
demoSignIn.openSignInPage(page);
|
|
1205
|
-
}
|
|
1206
1213
|
await new Promise(done => {
|
|
1207
1214
|
const stop = () => {
|
|
1208
1215
|
process.off("SIGINT", stop);
|
package/dist/contracts/cli.js
CHANGED
|
@@ -165,7 +165,7 @@ export const COMMAND_OUTPUTS = {
|
|
|
165
165
|
audit: auditOutput,
|
|
166
166
|
"skills list": answers("skills list", { guides: rows({ name: str, title: str, oneLiner: str }) }),
|
|
167
167
|
welcome: answers("welcome", {
|
|
168
|
-
agent: z.looseObject({ done: z.boolean(), checking: z.boolean(), agents: rows({ id: str, name: str, state: str, command: nullable(str), inUse: z.boolean(), canUse: z.boolean() }), inUse: nullable(str), buildsWith: nullable(str) }),
|
|
168
|
+
agent: z.looseObject({ done: z.boolean(), checking: z.boolean(), agents: rows({ id: str, name: str, state: str, command: nullable(str), inUse: z.boolean(), canUse: z.boolean(), optional: z.boolean() }), inUse: nullable(str), buildsWith: nullable(str) }),
|
|
169
169
|
project: z.looseObject({ done: z.boolean(), projects: rows({ name: str, path: str }), sample: nullable(str), notTakingWork: z.boolean() }),
|
|
170
170
|
task: z.looseObject({ done: z.boolean(), open: z.boolean(), starters: rows({ label: str, draft: str, href: str }) }),
|
|
171
171
|
next: nullable(z.enum(["agent", "project", "task"])),
|
package/dist/demo-sign-in.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { chmodSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { SIGN_IN_LINK_MS, SIGN_IN_LINK_PATH } from "./server/session.js";
|
|
1
|
+
import { SIGN_IN_LINK_PATH } from "./server/session.js";
|
|
5
2
|
export function demoLoopbackOrigin(address) {
|
|
6
3
|
if (address === null || typeof address === "string")
|
|
7
4
|
return null;
|
|
@@ -24,54 +21,3 @@ export function demoSignInLink(server, account, caller) {
|
|
|
24
21
|
return null;
|
|
25
22
|
return `${origin}${path}`;
|
|
26
23
|
}
|
|
27
|
-
export function writeSignInPage(parent, link) {
|
|
28
|
-
const dir = mkdtempSync(join(parent, "sign-in-"));
|
|
29
|
-
chmodSync(dir, 0o700);
|
|
30
|
-
const file = join(dir, "open.html");
|
|
31
|
-
const attribute = link.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
32
|
-
writeFileSync(file, `<!doctype html><meta charset="utf-8"><meta name="referrer" content="no-referrer">`
|
|
33
|
-
+ `<meta http-equiv="refresh" content="0;url=${attribute}"><title>Toolroll</title>`
|
|
34
|
-
+ `<script>location.replace(${JSON.stringify(link).replace(/</g, "\\u003c")})</script><p>Opening Toolroll…</p>\n`, { mode: 0o600 });
|
|
35
|
-
chmodSync(file, 0o600);
|
|
36
|
-
return file;
|
|
37
|
-
}
|
|
38
|
-
export function removeSignInPage(file) {
|
|
39
|
-
rmSync(join(file, ".."), { recursive: true, force: true });
|
|
40
|
-
}
|
|
41
|
-
export function openSignInPage(file, spawn = spawnChild, platform = process.platform) {
|
|
42
|
-
const command = platform === "darwin" ? "open" : platform === "linux" ? "xdg-open" : null;
|
|
43
|
-
if (command === null)
|
|
44
|
-
return false;
|
|
45
|
-
try {
|
|
46
|
-
spawn(command, [file], { detached: true, stdio: "ignore" }).unref();
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export function removeSignInPageWhenSpent(store, file, account, options = {}) {
|
|
54
|
-
const sinceRow = store.handle.prepare("SELECT coalesce(max(id), 0) AS id FROM action_ledger").get();
|
|
55
|
-
const since = Number(sinceRow?.["id"] ?? 0);
|
|
56
|
-
const spent = store.handle.prepare("SELECT 1 FROM action_ledger WHERE id > ? AND source = 'sign-in' AND actor = ? AND action = 'signed in' AND outcome = 'one-time link' LIMIT 1");
|
|
57
|
-
let done = false;
|
|
58
|
-
const finish = () => {
|
|
59
|
-
if (done)
|
|
60
|
-
return;
|
|
61
|
-
done = true;
|
|
62
|
-
clearInterval(timer);
|
|
63
|
-
clearTimeout(expiry);
|
|
64
|
-
removeSignInPage(file);
|
|
65
|
-
};
|
|
66
|
-
const timer = setInterval(() => { try {
|
|
67
|
-
if (spent.get(since, account) !== undefined)
|
|
68
|
-
finish();
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
finish();
|
|
72
|
-
} }, options.everyMs ?? 500);
|
|
73
|
-
const expiry = setTimeout(finish, options.expiresMs ?? SIGN_IN_LINK_MS);
|
|
74
|
-
timer.unref?.();
|
|
75
|
-
expiry.unref?.();
|
|
76
|
-
return finish;
|
|
77
|
-
}
|
package/dist/demo.js
CHANGED
|
@@ -148,7 +148,7 @@ const DEMO_PROOF = {
|
|
|
148
148
|
],
|
|
149
149
|
checks: [{ command: "npm test", exitCode: 0, summary: "214 tests passed, including the new rounding boundary cases." }],
|
|
150
150
|
changed: ["src/payout.ts", "src/payout.test.ts"],
|
|
151
|
-
caveats: [
|
|
151
|
+
caveats: [],
|
|
152
152
|
screenshots: [{ path: "evidence/payout-dashboard.png", caption: "Payout dashboard after the fix — totals match the ledger." }],
|
|
153
153
|
};
|
|
154
154
|
const DEMO_COPY_PATCH = `diff --git a/src/inbox-copy.ts b/src/inbox-copy.ts
|
|
@@ -479,6 +479,7 @@ export function seedDemo(store, repos, evidenceRoot, now) {
|
|
|
479
479
|
now: hoursAgo(27),
|
|
480
480
|
});
|
|
481
481
|
approve(store, done, "demo", hoursAgo(26), doneProposed.digest, token);
|
|
482
|
+
const doneCheck = store.setVerifyCommand({ repo: store.refFor("built-in", done).repo ?? repos.api, command: DEMO_CHECK_COMMAND, timeoutMs: 120_000, approvedBy: "demo" }, hoursAgo(26));
|
|
482
483
|
const doneRoute = store.approvedRouteOf(done);
|
|
483
484
|
const doneRun = store.startRun({
|
|
484
485
|
taskRef: store.refFor("built-in", done).id,
|
|
@@ -505,11 +506,14 @@ export function seedDemo(store, repos, evidenceRoot, now) {
|
|
|
505
506
|
],
|
|
506
507
|
filesTruncated: false,
|
|
507
508
|
};
|
|
509
|
+
store.recordOutcomeFacts(doneRun, { headRevision: stat.head, handoff: DEMO_HANDOFF.conclusion });
|
|
508
510
|
storeEvidence(store, evidenceRoot, doneRun, "diff-stat", "diff-stat.json", budgetedStatJson(stat), "parsed from git diff --numstat -z [demo: synthetic]", hoursAgo(8.5));
|
|
509
511
|
storeEvidence(store, evidenceRoot, doneRun, "handoff", "handoff.json", demoHandoffBytes(store, doneRun, DEMO_HANDOFF), "composed at completion [demo: synthetic]", hoursAgo(8.4));
|
|
510
512
|
storeEvidence(store, evidenceRoot, doneRun, "proof", "proof.json", Buffer.from(JSON.stringify(DEMO_PROOF, null, 2), "utf8"), "agent-authored proof (validated, re-serialized) [demo: synthetic]", hoursAgo(8.4));
|
|
511
513
|
storeEvidence(store, evidenceRoot, doneRun, "screenshot", "screenshot-demo.png", DEMO_SCREENSHOT_PNG, "agent-claimed screenshot at evidence/payout-dashboard.png (validated png) [demo: synthetic]", hoursAgo(8.4));
|
|
512
|
-
storeEvidence(store, evidenceRoot, doneRun, "check-log", "check-log.txt", Buffer.from(
|
|
514
|
+
storeEvidence(store, evidenceRoot, doneRun, "check-log", "check-log.txt", Buffer.from(`=== Attempt summary ===\n- Project check · attempt 1: (exit 0)\n\n=== Project check · attempt 1 ===\n$ ${DEMO_CHECK_COMMAND}\n(exit 0)\n\n--- stdout ---\n214 tests passed.\n\n--- stderr ---\n`, "utf8"), `${DEMO_CHECK_COMMAND} (attempt recorded) [demo: synthetic]`, hoursAgo(8.4), { captureStatus: "ok" });
|
|
515
|
+
sealVerificationReceipt(store, evidenceRoot, doneRun, stat.head, doneCheck, { configured: true, ran: true, exitCode: 0 }, hoursAgo(8.4));
|
|
516
|
+
store.recordRunCheck(doneRun, { status: "passed", exitCode: 0, suites: [] }, hoursAgo(8.4));
|
|
513
517
|
const demoProofParse = parseProof(JSON.stringify(DEMO_PROOF));
|
|
514
518
|
const demoPngDims = imageDimensions(DEMO_SCREENSHOT_PNG, "png");
|
|
515
519
|
const demoAdjudicated = adjudicate({
|
|
@@ -607,7 +611,7 @@ export function seedDemo(store, repos, evidenceRoot, now) {
|
|
|
607
611
|
const copyStat = {
|
|
608
612
|
schema: 1,
|
|
609
613
|
base: "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
|
|
610
|
-
head: "
|
|
614
|
+
head: "1c2d3e4f52aa01c9f3d7700e54bf8d69288fbe99",
|
|
611
615
|
fileCount: 1,
|
|
612
616
|
additions: 3,
|
|
613
617
|
deletions: 1,
|
|
@@ -615,6 +619,7 @@ export function seedDemo(store, repos, evidenceRoot, now) {
|
|
|
615
619
|
files: [{ path: "src/inbox-copy.ts", additions: 3, deletions: 1 }],
|
|
616
620
|
filesTruncated: false,
|
|
617
621
|
};
|
|
622
|
+
store.recordOutcomeFacts(copyReviewRun, { headRevision: copyStat.head, handoff: DEMO_COPY_HANDOFF.conclusion });
|
|
618
623
|
storeEvidence(store, evidenceRoot, copyReviewRun, "diff-stat", "diff-stat.json", budgetedStatJson(copyStat), "parsed from git diff --numstat -z [demo: synthetic]", hoursAgo(3.6));
|
|
619
624
|
storeEvidence(store, evidenceRoot, copyReviewRun, "handoff", "handoff.json", demoHandoffBytes(store, copyReviewRun, DEMO_COPY_HANDOFF), "composed at completion [demo: synthetic]", hoursAgo(3.5));
|
|
620
625
|
storeEvidence(store, evidenceRoot, copyReviewRun, "proof", "proof.json", Buffer.from(JSON.stringify(DEMO_COPY_PROOF, null, 2), "utf8"), "agent-authored proof (validated, re-serialized) [demo: synthetic]", hoursAgo(3.5));
|
package/dist/easy-start-args.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export function easyStartArgs(argv) {
|
|
2
|
-
let web = false, projectRoot = null, port = null;
|
|
2
|
+
let web = false, verbose = false, projectRoot = null, port = null;
|
|
3
3
|
for (let index = 0; index < argv.length; index += 1) {
|
|
4
4
|
const one = argv[index];
|
|
5
5
|
if (one === "--web" && !web)
|
|
6
6
|
web = true;
|
|
7
|
+
else if (one === "--verbose" && !verbose)
|
|
8
|
+
verbose = true;
|
|
7
9
|
else if ((one === "--project-root" && projectRoot === null) || (one === "--port" && port === null)) {
|
|
8
10
|
const value = argv[index + 1];
|
|
9
11
|
if (value === undefined || value === "" || value.startsWith("-"))
|
|
@@ -17,7 +19,7 @@ export function easyStartArgs(argv) {
|
|
|
17
19
|
else
|
|
18
20
|
return null;
|
|
19
21
|
}
|
|
20
|
-
return { web, projectRoot, port };
|
|
22
|
+
return { web, projectRoot, port, ...(verbose ? { verbose } : {}) };
|
|
21
23
|
}
|
|
22
24
|
export function easyStartApplies(argv, facts) {
|
|
23
25
|
return facts.stdin && facts.stdout && !facts.agent && easyStartArgs(argv) !== null;
|
package/dist/easy-start.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { existsSync, realpathSync } from "node:fs";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
3
4
|
import { pathToFileURL } from "node:url";
|
|
4
5
|
import { requestLocalLink } from "./console-instance.js";
|
|
5
6
|
import { backgroundInstalled, backgroundOn, startInstalledService } from "./laptop-background.js";
|
|
6
7
|
import { proveConsoleReadOnly } from "./quick-start.js";
|
|
7
|
-
import { backgroundAsked, localModeCandidate, localModeOf, openStore, openStoreReadOnly, recordBackgroundAsked } from "./store.js";
|
|
8
|
+
import { backgroundAsked, installationCreatedBy, localModeCandidate, localModeOf, openStore, openStoreReadOnly, recordBackgroundAsked } from "./store.js";
|
|
8
9
|
import { underAgent } from "./prompt.js";
|
|
10
|
+
import { savedLoginFile } from "./login-secrets.js";
|
|
9
11
|
export { easyStartApplies, easyStartArgs } from "./easy-start-args.js";
|
|
12
|
+
export const SIGN_IN_HANDOFF_MS = 60_000;
|
|
10
13
|
const EXIT = { ok: 0, failed: 1, usage: 2, refused: 3 };
|
|
14
|
+
export const UP_STOPPED_LINE = "Toolroll's background worker stopped. Run `toolroll --verbose` to see why.";
|
|
15
|
+
export const START_OVER_POINTER = "This Toolroll was set up with a password. To start over without one: https://github.com/ap9000/toolroll/blob/main/docs/guide/linux.md#start-over-without-a-password";
|
|
11
16
|
export async function runEasyStart(mode, args, seams) {
|
|
12
17
|
const { write } = seams;
|
|
13
18
|
const port = args.port === undefined || args.port === null ? null : Number(args.port);
|
|
@@ -15,7 +20,8 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
15
20
|
write("--port is a whole number from 1 to 65535.");
|
|
16
21
|
return EXIT.usage;
|
|
17
22
|
}
|
|
18
|
-
const rootArgs = [...(args.projectRoot === null ? [] : ["--project-root", args.projectRoot]), ...(port === null ? [] : ["--port", String(port)])
|
|
23
|
+
const rootArgs = [...(args.projectRoot === null ? [] : ["--project-root", args.projectRoot]), ...(port === null ? [] : ["--port", String(port)]),
|
|
24
|
+
...(args.verbose === true ? ["--verbose"] : [])];
|
|
19
25
|
const elsewhere = (proof) => {
|
|
20
26
|
if (port !== null && proof.ok && proof.port !== port)
|
|
21
27
|
write(`Toolroll is already set up on port ${proof.port}, so it opens there.`);
|
|
@@ -40,11 +46,22 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
40
46
|
return (await seams.enrolled(repo)) ? EXIT.ok : seams.admit(repo);
|
|
41
47
|
};
|
|
42
48
|
let local = seams.localMode();
|
|
43
|
-
if ((local === "candidate" || local === "absent") && !first.ok && first.state === "none"
|
|
44
|
-
|
|
49
|
+
if ((local === "candidate" || local === "absent") && !first.ok && first.state === "none") {
|
|
50
|
+
const sandbox = await seams.sandbox();
|
|
51
|
+
if (sandbox.missing.length > 0) {
|
|
52
|
+
const { missingSandboxToolsWords } = await import("./sandbox-runtime.js");
|
|
53
|
+
for (const line of missingSandboxToolsWords(sandbox.missing))
|
|
54
|
+
write(line);
|
|
55
|
+
return EXIT.refused;
|
|
56
|
+
}
|
|
57
|
+
if (await seams.initLocal())
|
|
58
|
+
local = "on";
|
|
59
|
+
}
|
|
45
60
|
if (local === "candidate")
|
|
46
61
|
local = "off";
|
|
47
62
|
if (local === "off") {
|
|
63
|
+
if (seams.passwordByLaptopStart())
|
|
64
|
+
write(START_OVER_POINTER);
|
|
48
65
|
if (!first.ok)
|
|
49
66
|
return seams.runUpForeground(rootArgs);
|
|
50
67
|
const joined = await joinRepo();
|
|
@@ -58,10 +75,21 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
58
75
|
if (args.web && !first.ok && !seams.serviceInstalled())
|
|
59
76
|
return seams.runUpForeground(["--laptop", ...rootArgs]);
|
|
60
77
|
let owned = null;
|
|
78
|
+
const stoppedHere = new Set();
|
|
79
|
+
const exitCodes = new Map();
|
|
80
|
+
const stopOwned = (child) => { stoppedHere.add(child); child.stop(); };
|
|
81
|
+
const stoppedOnItsOwn = () => {
|
|
82
|
+
const child = owned;
|
|
83
|
+
if (child === null || child.running() || stoppedHere.has(child))
|
|
84
|
+
return null;
|
|
85
|
+
const code = exitCodes.get(child);
|
|
86
|
+
return typeof code === "number" && code !== 0 ? UP_STOPPED_LINE : null;
|
|
87
|
+
};
|
|
61
88
|
const upArgs = ["--laptop", "--no-open", ...rootArgs];
|
|
62
89
|
const startOwned = async () => {
|
|
63
90
|
const child = seams.spawnUp(upArgs);
|
|
64
91
|
owned = child;
|
|
92
|
+
void child.exited.then(code => { exitCodes.set(child, code); });
|
|
65
93
|
const deadline = Date.now() + (seams.startTimeoutMs ?? 90_000);
|
|
66
94
|
for (;;) {
|
|
67
95
|
const proof = await seams.prove();
|
|
@@ -72,7 +100,7 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
72
100
|
return { ok: false, state: "refused", message: last === "" ? "it stopped while starting" : last };
|
|
73
101
|
}
|
|
74
102
|
if (Date.now() >= deadline) {
|
|
75
|
-
child
|
|
103
|
+
stopOwned(child);
|
|
76
104
|
return { ok: false, state: "refused", message: "it didn't answer in time" };
|
|
77
105
|
}
|
|
78
106
|
await sleep(250);
|
|
@@ -104,23 +132,35 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
104
132
|
return EXIT.ok;
|
|
105
133
|
};
|
|
106
134
|
if (seams.localMode() !== "on") {
|
|
107
|
-
|
|
135
|
+
const problem = (await seams.sandbox()).problem;
|
|
136
|
+
if (problem !== null)
|
|
137
|
+
write(`Toolroll can't start without a password here: ${problem}.`);
|
|
138
|
+
const saved = seams.savedLogin();
|
|
139
|
+
write(saved === null ? `Toolroll is on ${url}. Sign in with your password.` : `Toolroll is on ${url}. Your password: run \`cat -- '${saved.replaceAll("'", "'\\''")}'\``);
|
|
108
140
|
await seams.openBrowser(url);
|
|
109
141
|
return waitOwned();
|
|
110
142
|
}
|
|
111
143
|
if (args.web) {
|
|
112
|
-
const
|
|
113
|
-
if (!
|
|
114
|
-
write(`Toolroll is on ${url}, but it couldn't sign you in: ${
|
|
115
|
-
ownedNow()
|
|
144
|
+
const opened = await seams.openSignedIn();
|
|
145
|
+
if (!opened.ok) {
|
|
146
|
+
write(`Toolroll is on ${url}, but it couldn't sign you in: ${opened.message}.`);
|
|
147
|
+
const child = ownedNow();
|
|
148
|
+
if (child !== null)
|
|
149
|
+
stopOwned(child);
|
|
116
150
|
return EXIT.refused;
|
|
117
151
|
}
|
|
118
152
|
write(`Toolroll is on ${url}`);
|
|
119
|
-
|
|
153
|
+
if (ownedNow() === null) {
|
|
154
|
+
write("Opening Toolroll in your browser…");
|
|
155
|
+
await opened.wait(SIGN_IN_HANDOFF_MS);
|
|
156
|
+
return EXIT.ok;
|
|
157
|
+
}
|
|
120
158
|
return waitOwned();
|
|
121
159
|
}
|
|
122
160
|
const handoff = async () => {
|
|
123
161
|
const child = ownedNow();
|
|
162
|
+
if (child !== null)
|
|
163
|
+
stoppedHere.add(child);
|
|
124
164
|
const result = await seams.backgroundOn(child === null ? null : {
|
|
125
165
|
controllerPid: child.pid,
|
|
126
166
|
restart: async () => { const again = await startOwned(); if (!again.ok)
|
|
@@ -132,12 +172,10 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
132
172
|
};
|
|
133
173
|
const session = {
|
|
134
174
|
owned: () => ownedNow() !== null,
|
|
175
|
+
stopped: stoppedOnItsOwn,
|
|
135
176
|
openBrowser: async () => {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
return `The browser couldn't be opened: ${link.message}.`;
|
|
139
|
-
await seams.openBrowser(link.url);
|
|
140
|
-
return "Opened in your browser.";
|
|
177
|
+
const opened = await seams.openSignedIn();
|
|
178
|
+
return opened.ok ? "Opened in your browser." : `The browser couldn't be opened: ${opened.message}.`;
|
|
141
179
|
},
|
|
142
180
|
shouldAskBackground: () => ownedNow() !== null && !seams.serviceInstalled() && !seams.backgroundAsked(),
|
|
143
181
|
answerBackground: async (yes) => {
|
|
@@ -146,6 +184,17 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
146
184
|
},
|
|
147
185
|
};
|
|
148
186
|
const exit = await seams.openTui(session);
|
|
187
|
+
const ended = owned;
|
|
188
|
+
if (ended !== null && !ended.running())
|
|
189
|
+
await ended.exited;
|
|
190
|
+
const died = stoppedOnItsOwn();
|
|
191
|
+
if (died !== null) {
|
|
192
|
+
if (args.verbose === true)
|
|
193
|
+
for (const line of ended?.tail() ?? [])
|
|
194
|
+
write(line);
|
|
195
|
+
write(died);
|
|
196
|
+
return EXIT.failed;
|
|
197
|
+
}
|
|
149
198
|
const child = ownedNow();
|
|
150
199
|
if (child !== null) {
|
|
151
200
|
if (exit === "keep") {
|
|
@@ -155,7 +204,7 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
155
204
|
return EXIT.ok;
|
|
156
205
|
}
|
|
157
206
|
write("Stopping Toolroll… (running work is saved)");
|
|
158
|
-
child
|
|
207
|
+
stopOwned(child);
|
|
159
208
|
await child.exited;
|
|
160
209
|
write("Toolroll stopped.");
|
|
161
210
|
}
|
|
@@ -200,6 +249,31 @@ export function defaultEasyStartSeams(options) {
|
|
|
200
249
|
stdin: process.stdin.isTTY === true, stdout: process.stdout.isTTY === true, agent: underAgent(process.env), json: false,
|
|
201
250
|
remote: (await import("./local-owner.js")).localOwnerRequested(),
|
|
202
251
|
}),
|
|
252
|
+
sandbox: async () => {
|
|
253
|
+
const { missingLinuxSandboxTools, sandboxRuntimeProblem } = await import("./sandbox-runtime.js");
|
|
254
|
+
if (process.platform !== "linux")
|
|
255
|
+
return { missing: [], problem: sandboxRuntimeProblem() };
|
|
256
|
+
const missing = missingLinuxSandboxTools();
|
|
257
|
+
return { missing, problem: missing.length > 0 ? null : sandboxRuntimeProblem() };
|
|
258
|
+
},
|
|
259
|
+
passwordByLaptopStart: () => {
|
|
260
|
+
const store = openStoreReadOnly(file);
|
|
261
|
+
if (store === null)
|
|
262
|
+
return false;
|
|
263
|
+
try {
|
|
264
|
+
return installationCreatedBy(store) === "laptop" && localModeOf(store) === null;
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
finally {
|
|
270
|
+
store.close();
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
savedLogin: () => {
|
|
274
|
+
const saved = resolve(savedLoginFile(dirname(file)));
|
|
275
|
+
return existsSync(saved) ? saved : null;
|
|
276
|
+
},
|
|
203
277
|
serviceInstalled: () => backgroundInstalled(),
|
|
204
278
|
startService: async () => {
|
|
205
279
|
const store = openStore(file);
|
|
@@ -213,17 +287,7 @@ export function defaultEasyStartSeams(options) {
|
|
|
213
287
|
spawnUp: args => spawnOwnedUp(args, { cwd, databaseFile: file }),
|
|
214
288
|
runUpForeground: async (args) => (await import("./operate.js")).runOperate("up", [...args, "--db", file], options.write, options.operate ?? {}),
|
|
215
289
|
openBrowser: async (url) => { (await import("./operate.js")).openBrowser(url); },
|
|
216
|
-
|
|
217
|
-
const store = openStoreReadOnly(file);
|
|
218
|
-
if (store === null)
|
|
219
|
-
return { ok: false, message: "Toolroll's database can't be read" };
|
|
220
|
-
try {
|
|
221
|
-
return await requestLocalLink(file, store, options.build);
|
|
222
|
-
}
|
|
223
|
-
finally {
|
|
224
|
-
store.close();
|
|
225
|
-
}
|
|
226
|
-
},
|
|
290
|
+
openSignedIn: () => openLocalSignIn(file, options.build),
|
|
227
291
|
openTui: async (session) => {
|
|
228
292
|
const { createTuiSource } = await import("./tui-source.js");
|
|
229
293
|
const { runAsLocalOwner } = await import("./local-owner.js");
|
|
@@ -305,3 +369,36 @@ export function localModeRead(file) {
|
|
|
305
369
|
store.close();
|
|
306
370
|
}
|
|
307
371
|
}
|
|
372
|
+
export async function openLocalSignIn(databaseFile, build, seams = {}) {
|
|
373
|
+
const { ledgerSpent, NO_SAFE_OPENER, openSignInLink, platformOpener } = await import("./sign-in-page.js");
|
|
374
|
+
if (platformOpener(seams.platform) === null)
|
|
375
|
+
return { ok: false, message: NO_SAFE_OPENER };
|
|
376
|
+
const { instanceRunDir, prepareRunDir } = await import("./console-instance.js");
|
|
377
|
+
const parent = instanceRunDir(databaseFile);
|
|
378
|
+
const problem = prepareRunDir(parent);
|
|
379
|
+
if (problem !== null)
|
|
380
|
+
return { ok: false, message: problem };
|
|
381
|
+
const store = openStoreReadOnly(databaseFile);
|
|
382
|
+
if (store === null)
|
|
383
|
+
return { ok: false, message: "Toolroll's database can't be read" };
|
|
384
|
+
let handed = false;
|
|
385
|
+
try {
|
|
386
|
+
const spent = ledgerSpent(store, "local link", null);
|
|
387
|
+
const expiresAt = Date.now() + (seams.expiresMs ?? (await import("./server/session.js")).SIGN_IN_LINK_MS);
|
|
388
|
+
const link = await (seams.request ?? (one => requestLocalLink(databaseFile, one, build)))(store);
|
|
389
|
+
if (!link.ok)
|
|
390
|
+
return link;
|
|
391
|
+
handed = true;
|
|
392
|
+
const opened = await openSignInLink(link.url, {
|
|
393
|
+
parent, spent, expiresAt, onEnd: () => store.close(),
|
|
394
|
+
...(seams.opener === undefined ? {} : { opener: seams.opener }),
|
|
395
|
+
...(seams.platform === undefined ? {} : { platform: seams.platform }),
|
|
396
|
+
...(seams.everyMs === undefined ? {} : { everyMs: seams.everyMs }),
|
|
397
|
+
});
|
|
398
|
+
return opened.opened ? { ok: true, wait: opened.wait } : { ok: false, message: "the browser opener didn't start or failed" };
|
|
399
|
+
}
|
|
400
|
+
finally {
|
|
401
|
+
if (!handed)
|
|
402
|
+
store.close();
|
|
403
|
+
}
|
|
404
|
+
}
|
package/dist/first-run.js
CHANGED
|
@@ -191,9 +191,12 @@ export function welcomeModel(facts) {
|
|
|
191
191
|
const state = seen === null ? "checking" : SIGNED_IN.has(seen) ? "signed-in" : seen === "not-installed" ? "not-installed" : "signed-out";
|
|
192
192
|
const command = state === "signed-in" || state === "checking" ? null : state === "not-installed" ? `${one.install}${join} ${one.signIn}` : one.signIn;
|
|
193
193
|
const inUse = facts.inUse === one.id;
|
|
194
|
-
return { id: one.id, name: one.name, state, command, inUse, canUse: facts.canChoose && !inUse && seen === "connected" };
|
|
194
|
+
return { id: one.id, name: one.name, state, command, inUse, canUse: facts.canChoose && !inUse && seen === "connected", optional: false };
|
|
195
195
|
});
|
|
196
196
|
const signedIn = agents.some(one => one.state === "signed-in");
|
|
197
|
+
const installed = agents.some(one => one.state === "signed-in" || one.state === "signed-out");
|
|
198
|
+
for (const one of agents)
|
|
199
|
+
one.optional = signedIn ? one.state !== "signed-in" : installed && one.state === "not-installed";
|
|
197
200
|
const checking = !signedIn && agents.some(one => one.state === "checking");
|
|
198
201
|
const builds = facts.buildsOn === null ? null : WELCOME_AGENTS.find(one => one.id === facts.buildsOn)?.name ?? facts.buildsOn;
|
|
199
202
|
const buildsWith = facts.inUse !== null && facts.buildsOn !== null && facts.buildsOn !== facts.inUse ? builds : null;
|
package/dist/flow-code.js
CHANGED
|
@@ -6,6 +6,7 @@ import { dirname, join } from "node:path";
|
|
|
6
6
|
import { buildCacheEnv, buildCacheFolder, checkLaunchRoot, fenceFor, linuxFenceAvailable, macosFenceAvailable, runFolders, taskBoundary, trustedWorktreeBinding, writeAllowlist } from "./agent-fence.js";
|
|
7
7
|
import { readDenyPath } from "./project-sandbox.js";
|
|
8
8
|
import { poolRootOf } from "./worktree.js";
|
|
9
|
+
import { linuxSandboxToolsWords } from "./sandbox-runtime.js";
|
|
9
10
|
import { SETUP_ENV_ALLOWLIST, SETUP_ENV_DENYLIST } from "./builder.js";
|
|
10
11
|
import { redactSecretLines, scanForSecrets } from "./evidence.js";
|
|
11
12
|
import { scrubSecrets } from "./flow-secrets.js";
|
|
@@ -129,7 +130,7 @@ export async function flowLaunch(store, options) {
|
|
|
129
130
|
const available = options.available ?? (() => macosFenceAvailable() || linuxFenceAvailable());
|
|
130
131
|
const fenced = available();
|
|
131
132
|
if (!fenced && !store.unfencedAgentsAllowed()) {
|
|
132
|
-
return { problem: "This machine can't confine the flow's script (no macOS sandbox, no working bubblewrap), so it didn't run. Install
|
|
133
|
+
return { problem: "This machine can't confine the flow's script (no macOS sandbox, no working bubblewrap), so it didn't run. Install " + linuxSandboxToolsWords() + " (Linux), or an instance operator allows unconfined agents with `toolroll config unconfined-agents allow`." };
|
|
133
134
|
}
|
|
134
135
|
let own;
|
|
135
136
|
try {
|
package/dist/git-floor.js
CHANGED
|
@@ -5,13 +5,20 @@ export function parseGitVersion(text) {
|
|
|
5
5
|
const found = /^git version (\d+)\.(\d+)(?:\.(\d+))?/.exec(text.trim());
|
|
6
6
|
return found === null ? null : { major: Number(found[1]), minor: Number(found[2]), words: `${found[1]}.${found[2]}${found[3] === undefined ? "" : `.${found[3]}`}` };
|
|
7
7
|
}
|
|
8
|
-
export function
|
|
8
|
+
export function newerGitHow(platform = process.platform) {
|
|
9
|
+
if (platform === "linux")
|
|
10
|
+
return "get one from https://git-scm.com/downloads/linux (Ubuntu: `sudo add-apt-repository ppa:git-core/ppa && sudo apt update && sudo apt install git`)";
|
|
11
|
+
if (platform === "darwin")
|
|
12
|
+
return "`brew install git`, or update Xcode's Command Line Tools in Software Update";
|
|
13
|
+
return "get one from https://git-scm.com/downloads";
|
|
14
|
+
}
|
|
15
|
+
export function gitFloorWords(versionText, platform = process.platform) {
|
|
9
16
|
const version = parseGitVersion(versionText);
|
|
10
17
|
if (version === null)
|
|
11
18
|
return null;
|
|
12
19
|
if (version.major > GIT_FLOOR.major || (version.major === GIT_FLOOR.major && version.minor >= GIT_FLOOR.minor))
|
|
13
20
|
return null;
|
|
14
|
-
return `Toolroll needs git ${GIT_FLOOR_WORDS} or newer, and this machine's git is ${version.words}. Install a newer git (and put it first on PATH)
|
|
21
|
+
return `Toolroll needs git ${GIT_FLOOR_WORDS} or newer, and this machine's git is ${version.words}. Install a newer git (and put it first on PATH): ${newerGitHow(platform)}. Then start Toolroll again.`;
|
|
15
22
|
}
|
|
16
23
|
let probed;
|
|
17
24
|
export function installedGitFloorProblem() {
|
package/dist/guides.js
CHANGED
|
@@ -274,7 +274,7 @@ ${AUTHORITY_LINE}
|
|
|
274
274
|
## Install and sign-in
|
|
275
275
|
|
|
276
276
|
- One command, inside the repository: \`npx toolroll up\` (or
|
|
277
|
-
\`bunx toolroll up\`; Node 22.
|
|
277
|
+
\`bunx toolroll up\`; Node 22.20+ must be installed — Bun's own
|
|
278
278
|
runtime cannot host it). \`up\` mints the first login and saves it beside the
|
|
279
279
|
database in \`.toolroll-secrets/up-login.txt\` (every start prints that path and the
|
|
280
280
|
\`cat\` command that shows the password, never the password itself),
|
package/dist/invoke.js
CHANGED
|
@@ -28,7 +28,7 @@ import { localModeOn } from "./local-owner.js";
|
|
|
28
28
|
import { CHECK_STAMP_VERSION, EVERYWHERE, unfencedStamp } from "./check-stamp.js";
|
|
29
29
|
import { CHECK_ACCESS_DEFAULT, checkAccessHere, localModeCap, narrowestAccess, narrowestNetwork, signInsAvailable } from "./check-access.js";
|
|
30
30
|
import { readDenyPath } from "./project-sandbox.js";
|
|
31
|
-
import { sandboxRuntimeWords } from "./sandbox-runtime.js";
|
|
31
|
+
import { linuxSandboxToolsWords, sandboxRuntimeWords } from "./sandbox-runtime.js";
|
|
32
32
|
import { canonicalJson } from "./canonical-json.js";
|
|
33
33
|
import { deliveredFile } from "./code-map-admission.js";
|
|
34
34
|
import { buildCacheEnv, buildCacheFolder, grantFolder, writeAllowlist, WRITES_DEFAULT, CheckoutBindingError, trustedWorktreeBinding, checkoutGitEnv, HARDENED_GIT_ARGS, codexFenceArgv, fenceFor, fencedGitEnv, LEGACY_SANDBOX, launchSandboxOf, linuxFenceAvailable, macosFenceAvailable, NO_GRANTS, sandboxedSpawn, serverGrantsOf, runFolders, taskBoundary } from "./agent-fence.js";
|
|
@@ -318,7 +318,7 @@ export async function invokeAgent(store, runId, spec, invocation, options) {
|
|
|
318
318
|
codexHome?.cleanup();
|
|
319
319
|
removeAgentDatabase(isolatedDb.dir);
|
|
320
320
|
return { kind: "refused", reason: "containment", providerVersion: attested?.version ?? null,
|
|
321
|
-
diagnostic: "This machine can't confine an agent (no macOS sandbox, no working bubblewrap), so nothing was started. Install
|
|
321
|
+
diagnostic: "This machine can't confine an agent (no macOS sandbox, no working bubblewrap), so nothing was started. Install " + linuxSandboxToolsWords() + " (Linux), or an instance operator allows unconfined agents with `toolroll config unconfined-agents allow`." };
|
|
322
322
|
}
|
|
323
323
|
let egress = null;
|
|
324
324
|
let runTemp = null;
|
|
@@ -755,7 +755,7 @@ export function fencedCommands(store, runId, writes, inner, available = () => ma
|
|
|
755
755
|
stampLaunch(store, [runId], unfencedStamp());
|
|
756
756
|
return inner(file, args, options);
|
|
757
757
|
}
|
|
758
|
-
return { code: 1, stdout: "", stderr: "This machine can't confine the build's commands (no macOS sandbox, no working bubblewrap), so they didn't run. Install
|
|
758
|
+
return { code: 1, stdout: "", stderr: "This machine can't confine the build's commands (no macOS sandbox, no working bubblewrap), so they didn't run. Install " + linuxSandboxToolsWords() + " (Linux), or an instance operator allows unconfined agents with `toolroll config unconfined-agents allow`.\n", timedOut: false, notFound: false };
|
|
759
759
|
}
|
|
760
760
|
const own = realpathSync(mkdtempSync(join(checkLaunchRoot(), "so-cmd-")));
|
|
761
761
|
try {
|
|
@@ -811,7 +811,7 @@ export function fencedCheckoutCommands(store, repo, checkout, inner, available =
|
|
|
811
811
|
stampLaunch(store, stampRuns, unfencedStamp());
|
|
812
812
|
return inner(file, args, options);
|
|
813
813
|
}
|
|
814
|
-
return { code: 1, stdout: "", stderr: "This machine can't confine the project's checks (no macOS sandbox, no working bubblewrap), so they didn't run. Install
|
|
814
|
+
return { code: 1, stdout: "", stderr: "This machine can't confine the project's checks (no macOS sandbox, no working bubblewrap), so they didn't run. Install " + linuxSandboxToolsWords() + " (Linux), or an instance operator allows unconfined agents with `toolroll config unconfined-agents allow`.\n", timedOut: false, notFound: false };
|
|
815
815
|
}
|
|
816
816
|
const databaseFile = store.databaseFile();
|
|
817
817
|
if (databaseFile === null) {
|
package/dist/lead-voice.js
CHANGED
|
@@ -17,11 +17,11 @@ export const LEAD_SAY_MAX = 300;
|
|
|
17
17
|
const BATCH_LINES = 8;
|
|
18
18
|
const ENDS_SQL = LEAD_ENDS.map(one => `'${one}'`).join(",");
|
|
19
19
|
export const LEAD_CLAIM_SQL = `COALESCE((SELECT CASE
|
|
20
|
-
WHEN EXISTS(SELECT 1 FROM action_ledger e WHERE e.task_id IN (SELECT
|
|
20
|
+
WHEN EXISTS(SELECT 1 FROM action_ledger e WHERE e.task_id IN (SELECT value FROM json_each(c.fam_ids))
|
|
21
21
|
AND e.id > claim.id AND e.actor = claim.actor AND e.action IN (${ENDS_SQL})) THEN 0
|
|
22
|
-
WHEN EXISTS(SELECT 1 FROM task_act t WHERE t.task_ref IN (SELECT
|
|
22
|
+
WHEN EXISTS(SELECT 1 FROM task_act t WHERE t.task_ref IN (SELECT value FROM json_each(c.fam_refs))
|
|
23
23
|
AND t.act IN (${DONE_ACTS_SQL}) AND t.at >= claim.at) THEN 0
|
|
24
|
-
WHEN (SELECT MAX(a.at) FROM action_ledger a WHERE a.task_id IN (SELECT
|
|
24
|
+
WHEN (SELECT MAX(a.at) FROM action_ledger a WHERE a.task_id IN (SELECT value FROM json_each(c.fam_ids))
|
|
25
25
|
AND a.id >= claim.id AND a.actor = claim.actor) > $leadIdleSince THEN 1 ELSE 2 END
|
|
26
26
|
FROM action_ledger claim WHERE claim.id = (SELECT MAX(id) FROM action_ledger WHERE task_id = c.root_id AND action = '${LEAD_CLAIMED}' AND actor = $leadOf)), 0)`;
|
|
27
27
|
function familyOf(store, taskId) {
|