toolroll 0.9.106 → 0.9.108
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 +38 -0
- package/README.md +5 -4
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +27 -25
- package/dist/browser-shell.js +1 -1
- package/dist/cli-help.js +5 -0
- package/dist/cli.js +18 -11
- package/dist/contracts/cli.js +3 -1
- package/dist/contracts/console-api.js +1 -1
- package/dist/demo-sign-in.js +1 -55
- package/dist/easy-start-args.js +4 -2
- package/dist/easy-start.js +78 -24
- package/dist/first-run.js +4 -1
- package/dist/folder-look.js +65 -4
- package/dist/git-floor.js +9 -2
- package/dist/guides.js +3 -1
- package/dist/lead-cli.js +2 -1
- package/dist/live-bus.js +14 -1
- package/dist/login-secrets.js +43 -0
- package/dist/operate.js +195 -27
- package/dist/project-admission.js +60 -29
- package/dist/project.js +73 -0
- package/dist/repos.js +37 -0
- package/dist/route-hooks.js +1 -0
- package/dist/sample-project.js +167 -9
- package/dist/sandbox-runtime.js +1 -1
- package/dist/scope.js +17 -2
- package/dist/serve.js +15 -3
- package/dist/server/live.js +5 -2
- package/dist/server/login-help.js +67 -0
- package/dist/server/pages.js +180 -26
- package/dist/server/people-tokens.js +36 -24
- package/dist/server/render-people.js +14 -2
- package/dist/server/render-projects.js +58 -10
- package/dist/server/route-table.js +2 -1
- package/dist/server/settings.js +3 -0
- package/dist/server/welcome.js +29 -18
- package/dist/settings-groups-ui.js +10 -1
- package/dist/sign-in-page.js +197 -0
- package/dist/store.js +33 -0
- package/dist/surface.js +4 -1
- package/dist/task-outcome-cli.js +99 -4
- package/dist/tui-source.js +11 -3
- package/dist/tui.js +46 -46
- package/dist/welcome-facts.js +17 -7
- package/package.json +1 -1
package/dist/browser-shell.js
CHANGED
|
@@ -47,6 +47,6 @@ export function browserWorkspaceDocument(document, workspace, nonce, functionalS
|
|
|
47
47
|
const initialize = `window.addEventListener('standing-orders:workspace-rendered',function initializeWorkspace(){window.removeEventListener('standing-orders:workspace-rendered',initializeWorkspace);${functionalScript}});`;
|
|
48
48
|
const settleFades = `(function(){function s(e){var f=e.viewTransition;if(f)[f.finished,f.ready,f.updateCallbackDone].forEach(function(p){if(p)p.catch(function(){})})}addEventListener('pageswap',s);addEventListener('pagereveal',s)})();`;
|
|
49
49
|
let out = replaceMarkup(document, /<\/head>/, () => html `<link rel="stylesheet" href="/assets/workspace.css">${workspace.sensitive ? "" : scriptElement(settleFades, { nonce })}</head>`);
|
|
50
|
-
out = replaceMarkup(out, /<body>/, () => html `<body><div id="standing-orders-workspace">`);
|
|
50
|
+
out = replaceMarkup(out, /<body>/, () => html `<body><div id="standing-orders-workspace" data-live-reader="stream">`);
|
|
51
51
|
return replaceMarkup(out, /<\/body>/, () => html `</div>${beside}${jsonScript(workspace, { id: "standing-orders-workspace-data", nonce })}${scriptElement(initialize, { nonce })}<script type="module" src="/assets/workspace.js" nonce="${nonce}"></script></body>`);
|
|
52
52
|
}
|
package/dist/cli-help.js
CHANGED
|
@@ -43,11 +43,16 @@ Starting and running
|
|
|
43
43
|
toolroll up app + builder for every saved project, for a server or a phone (--laptop: what bare \`toolroll\` runs)
|
|
44
44
|
toolroll open [--web] open this computer's Toolroll again, signed in (bare \`toolroll\` does the same)
|
|
45
45
|
toolroll welcome the three steps to a first result (--json: the model)
|
|
46
|
+
toolroll welcome sample add the sample project to your projects folder (at your own terminal)
|
|
46
47
|
toolroll onboard make your agent Toolroll's lead: add this repo, install its skill (--yes), offer starter flows (--starter)
|
|
47
48
|
toolroll background on|off|show
|
|
48
49
|
keep this computer's Toolroll running when you log in
|
|
49
50
|
toolroll stop stop this computer's Toolroll once its running work is saved
|
|
50
51
|
toolroll password set add a password (typed twice, at your terminal)
|
|
52
|
+
toolroll password reset forgot your password? reset it here (typed twice, at this computer's terminal;
|
|
53
|
+
--as <name> when several people sign in). Every session of that account ends.
|
|
54
|
+
Anyone who can run commands as you on this computer can do this, as they
|
|
55
|
+
could read the saved first password: that is the line Toolroll draws.
|
|
51
56
|
toolroll link put \`toolroll\` on your PATH
|
|
52
57
|
toolroll unlink take it off again
|
|
53
58
|
(link shows what it would do and changes nothing; add --yes to apply it,
|
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,13 +165,15 @@ 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"])),
|
|
172
172
|
left: int,
|
|
173
173
|
}),
|
|
174
|
+
"welcome sample": answers("welcome sample", { repo: str, created: z.boolean(), added: z.boolean(), checkSet: z.boolean() }),
|
|
174
175
|
"password set": answers("password set", { account: str, generation: int }),
|
|
176
|
+
"password reset": answers("password reset", { account: str, generation: int, removed: z.array(str) }),
|
|
175
177
|
};
|
|
176
178
|
const declared = new Map(Object.entries(COMMAND_OUTPUTS));
|
|
177
179
|
export function commandOutputSchema(command) {
|
|
@@ -117,7 +117,7 @@ export const CONSOLE_FORMS = {
|
|
|
117
117
|
google: formContract("POST /settings/google, /settings/google/disconnect", ["clientId", "clientSecret"]),
|
|
118
118
|
projectsSelect: formContract("POST /projects/select", ["path", "return"]),
|
|
119
119
|
projectsRemove: formContract("POST /projects/remove", ["repo"]),
|
|
120
|
-
projectsOpen: formContract("POST /projects/open", ["path", "return"]),
|
|
120
|
+
projectsOpen: formContract("POST /projects/open", ["path", "return", "via", "password"]),
|
|
121
121
|
codeMap: formContract("POST /settings/project/code-map, /settings/project/code-map/holdout", ["repo", "on"]),
|
|
122
122
|
codeMapRefresh: formContract("POST /projects/<project>/map/refresh", []),
|
|
123
123
|
tasksFast: formContract("POST /tasks/fast", ["preview", "digest"]),
|
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/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
|
@@ -9,7 +9,9 @@ import { backgroundAsked, installationCreatedBy, localModeCandidate, localModeOf
|
|
|
9
9
|
import { underAgent } from "./prompt.js";
|
|
10
10
|
import { savedLoginFile } from "./login-secrets.js";
|
|
11
11
|
export { easyStartApplies, easyStartArgs } from "./easy-start-args.js";
|
|
12
|
+
export const SIGN_IN_HANDOFF_MS = 60_000;
|
|
12
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.";
|
|
13
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";
|
|
14
16
|
export async function runEasyStart(mode, args, seams) {
|
|
15
17
|
const { write } = seams;
|
|
@@ -18,7 +20,8 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
18
20
|
write("--port is a whole number from 1 to 65535.");
|
|
19
21
|
return EXIT.usage;
|
|
20
22
|
}
|
|
21
|
-
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"] : [])];
|
|
22
25
|
const elsewhere = (proof) => {
|
|
23
26
|
if (port !== null && proof.ok && proof.port !== port)
|
|
24
27
|
write(`Toolroll is already set up on port ${proof.port}, so it opens there.`);
|
|
@@ -72,10 +75,21 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
72
75
|
if (args.web && !first.ok && !seams.serviceInstalled())
|
|
73
76
|
return seams.runUpForeground(["--laptop", ...rootArgs]);
|
|
74
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
|
+
};
|
|
75
88
|
const upArgs = ["--laptop", "--no-open", ...rootArgs];
|
|
76
89
|
const startOwned = async () => {
|
|
77
90
|
const child = seams.spawnUp(upArgs);
|
|
78
91
|
owned = child;
|
|
92
|
+
void child.exited.then(code => { exitCodes.set(child, code); });
|
|
79
93
|
const deadline = Date.now() + (seams.startTimeoutMs ?? 90_000);
|
|
80
94
|
for (;;) {
|
|
81
95
|
const proof = await seams.prove();
|
|
@@ -86,7 +100,7 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
86
100
|
return { ok: false, state: "refused", message: last === "" ? "it stopped while starting" : last };
|
|
87
101
|
}
|
|
88
102
|
if (Date.now() >= deadline) {
|
|
89
|
-
child
|
|
103
|
+
stopOwned(child);
|
|
90
104
|
return { ok: false, state: "refused", message: "it didn't answer in time" };
|
|
91
105
|
}
|
|
92
106
|
await sleep(250);
|
|
@@ -127,18 +141,26 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
127
141
|
return waitOwned();
|
|
128
142
|
}
|
|
129
143
|
if (args.web) {
|
|
130
|
-
const
|
|
131
|
-
if (!
|
|
132
|
-
write(`Toolroll is on ${url}, but it couldn't sign you in: ${
|
|
133
|
-
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);
|
|
134
150
|
return EXIT.refused;
|
|
135
151
|
}
|
|
136
152
|
write(`Toolroll is on ${url}`);
|
|
137
|
-
|
|
153
|
+
if (ownedNow() === null) {
|
|
154
|
+
write("Opening Toolroll in your browser…");
|
|
155
|
+
await opened.wait(SIGN_IN_HANDOFF_MS);
|
|
156
|
+
return EXIT.ok;
|
|
157
|
+
}
|
|
138
158
|
return waitOwned();
|
|
139
159
|
}
|
|
140
160
|
const handoff = async () => {
|
|
141
161
|
const child = ownedNow();
|
|
162
|
+
if (child !== null)
|
|
163
|
+
stoppedHere.add(child);
|
|
142
164
|
const result = await seams.backgroundOn(child === null ? null : {
|
|
143
165
|
controllerPid: child.pid,
|
|
144
166
|
restart: async () => { const again = await startOwned(); if (!again.ok)
|
|
@@ -150,12 +172,10 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
150
172
|
};
|
|
151
173
|
const session = {
|
|
152
174
|
owned: () => ownedNow() !== null,
|
|
175
|
+
stopped: stoppedOnItsOwn,
|
|
153
176
|
openBrowser: async () => {
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
return `The browser couldn't be opened: ${link.message}.`;
|
|
157
|
-
await seams.openBrowser(link.url);
|
|
158
|
-
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}.`;
|
|
159
179
|
},
|
|
160
180
|
shouldAskBackground: () => ownedNow() !== null && !seams.serviceInstalled() && !seams.backgroundAsked(),
|
|
161
181
|
answerBackground: async (yes) => {
|
|
@@ -164,6 +184,17 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
164
184
|
},
|
|
165
185
|
};
|
|
166
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
|
+
}
|
|
167
198
|
const child = ownedNow();
|
|
168
199
|
if (child !== null) {
|
|
169
200
|
if (exit === "keep") {
|
|
@@ -173,7 +204,7 @@ export async function runEasyStart(mode, args, seams) {
|
|
|
173
204
|
return EXIT.ok;
|
|
174
205
|
}
|
|
175
206
|
write("Stopping Toolroll… (running work is saved)");
|
|
176
|
-
child
|
|
207
|
+
stopOwned(child);
|
|
177
208
|
await child.exited;
|
|
178
209
|
write("Toolroll stopped.");
|
|
179
210
|
}
|
|
@@ -256,17 +287,7 @@ export function defaultEasyStartSeams(options) {
|
|
|
256
287
|
spawnUp: args => spawnOwnedUp(args, { cwd, databaseFile: file }),
|
|
257
288
|
runUpForeground: async (args) => (await import("./operate.js")).runOperate("up", [...args, "--db", file], options.write, options.operate ?? {}),
|
|
258
289
|
openBrowser: async (url) => { (await import("./operate.js")).openBrowser(url); },
|
|
259
|
-
|
|
260
|
-
const store = openStoreReadOnly(file);
|
|
261
|
-
if (store === null)
|
|
262
|
-
return { ok: false, message: "Toolroll's database can't be read" };
|
|
263
|
-
try {
|
|
264
|
-
return await requestLocalLink(file, store, options.build);
|
|
265
|
-
}
|
|
266
|
-
finally {
|
|
267
|
-
store.close();
|
|
268
|
-
}
|
|
269
|
-
},
|
|
290
|
+
openSignedIn: () => openLocalSignIn(file, options.build),
|
|
270
291
|
openTui: async (session) => {
|
|
271
292
|
const { createTuiSource } = await import("./tui-source.js");
|
|
272
293
|
const { runAsLocalOwner } = await import("./local-owner.js");
|
|
@@ -348,3 +369,36 @@ export function localModeRead(file) {
|
|
|
348
369
|
store.close();
|
|
349
370
|
}
|
|
350
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/folder-look.js
CHANGED
|
@@ -59,7 +59,7 @@ function children(folder, roots, links) {
|
|
|
59
59
|
const spelled = path.join(folder, entry.name);
|
|
60
60
|
if (offLimits(spelled, roots)) continue;
|
|
61
61
|
let real, stat;
|
|
62
|
-
try { real = fs.realpathSync(spelled); } catch { continue; }
|
|
62
|
+
try { real = (request.native === true ? fs.realpathSync.native : fs.realpathSync)(spelled); } catch { continue; }
|
|
63
63
|
if (offLimits(real, roots) || !roots.some(root => within(real, root))) continue;
|
|
64
64
|
try { stat = fs.statSync(real); } catch { continue; }
|
|
65
65
|
if (!stat.isDirectory()) continue;
|
|
@@ -70,7 +70,45 @@ function children(folder, roots, links) {
|
|
|
70
70
|
} finally { dir.closeSync(); }
|
|
71
71
|
return out;
|
|
72
72
|
}
|
|
73
|
+
// A folder's identity and the identities of every folder above it, by device and inode (bigint stats: no precision
|
|
74
|
+
// lost), what containment is judged on. A folder that isn't there is said as such, with its path in the disk's spelling
|
|
75
|
+
// for the part that exists; any other failure is "unreadable", never "absent", so a check that can't read fails closed.
|
|
76
|
+
const ABSENT = new Set(["ENOENT", "ENOTDIR"]);
|
|
77
|
+
function absentPath(p) {
|
|
78
|
+
const rest = [];
|
|
79
|
+
let at = p;
|
|
80
|
+
for (;;) {
|
|
81
|
+
const up = path.dirname(at);
|
|
82
|
+
if (up === at) return p;
|
|
83
|
+
rest.unshift(path.basename(at));
|
|
84
|
+
at = up;
|
|
85
|
+
try { return path.join(fs.realpathSync.native(at), ...rest); }
|
|
86
|
+
catch (error) { if (!(error && ABSENT.has(error.code))) return null; }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function facts(p) {
|
|
90
|
+
const asked = path.resolve(p);
|
|
91
|
+
let real;
|
|
92
|
+
try { real = fs.realpathSync.native(asked); }
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (!(error && ABSENT.has(error.code))) return { kind: "unreadable" };
|
|
95
|
+
const missing = absentPath(asked);
|
|
96
|
+
return missing === null ? { kind: "unreadable" } : { kind: "missing", path: missing };
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
const stat = fs.statSync(real, { bigint: true });
|
|
100
|
+
const names = real.split("/").filter(Boolean);
|
|
101
|
+
const chain = [];
|
|
102
|
+
// Every folder from this one up to the top, each stat'ed: the walk is exactly as long as the path, never cut short.
|
|
103
|
+
for (let depth = names.length; depth >= 0; depth--) {
|
|
104
|
+
const one = fs.statSync("/" + names.slice(0, depth).join("/"), { bigint: true });
|
|
105
|
+
chain.push(String(one.dev) + ":" + String(one.ino));
|
|
106
|
+
}
|
|
107
|
+
return { kind: "found", real, dir: stat.isDirectory(), uid: Number(stat.uid), chain };
|
|
108
|
+
} catch { return { kind: "unreadable" }; }
|
|
109
|
+
}
|
|
73
110
|
function look() {
|
|
111
|
+
if (request.op === "folder") return { target: facts(request.path), compare: request.compare.map(facts) };
|
|
74
112
|
if (request.op === "projectMcp") {
|
|
75
113
|
const text = readBounded(path.join(request.path, ".mcp.json"), 1024 * 1024, 1024 * 1024);
|
|
76
114
|
if (text === null) return { config: null };
|
|
@@ -84,8 +122,9 @@ function look() {
|
|
|
84
122
|
}) };
|
|
85
123
|
}
|
|
86
124
|
const roots = request.roots;
|
|
125
|
+
const realOf = request.native === true ? fs.realpathSync.native : fs.realpathSync;
|
|
87
126
|
if (request.op === "list") {
|
|
88
|
-
const at =
|
|
127
|
+
const at = realOf(request.path);
|
|
89
128
|
const root = rootOf(at, roots);
|
|
90
129
|
if (root === undefined || offLimits(at, roots) || !fs.statSync(at).isDirectory()) return { at: null, entries: [] };
|
|
91
130
|
// A folder on another drive than the root that allows it is not entered (the root itself may be one).
|
|
@@ -163,7 +202,8 @@ let starts = 0;
|
|
|
163
202
|
function lookKey(request) {
|
|
164
203
|
const sorted = (paths) => paths.map(one => resolve(one)).sort();
|
|
165
204
|
switch (request.op) {
|
|
166
|
-
case "list": return JSON.stringify([request.op, resolve(request.path), sorted(request.roots), request.home]);
|
|
205
|
+
case "list": return JSON.stringify([request.op, resolve(request.path), sorted(request.roots), request.home, "native" in request]);
|
|
206
|
+
case "folder": return JSON.stringify([request.op, resolve(request.path), sorted(request.compare)]);
|
|
167
207
|
case "origins": return JSON.stringify([request.op, sorted(request.registered), sorted(request.roots), request.home]);
|
|
168
208
|
case "identities": return JSON.stringify([request.op, sorted(request.paths)]);
|
|
169
209
|
case "projectMcp": return JSON.stringify([request.op, resolve(request.path)]);
|
|
@@ -212,7 +252,7 @@ export async function lookFolders(request, options = {}) {
|
|
|
212
252
|
}
|
|
213
253
|
const text = (value) => typeof value === "string" && value.length > 0 && value.length <= 4096 && !value.includes("\0");
|
|
214
254
|
export async function listFolder(path, roots, options = {}) {
|
|
215
|
-
const looked = await lookFolders({ op: "list", path, roots: [...roots], home: options.home ?? homedir() }, options);
|
|
255
|
+
const looked = await lookFolders(options.native === true ? { op: "list", path, roots: [...roots], home: options.home ?? homedir(), native: true } : { op: "list", path, roots: [...roots], home: options.home ?? homedir() }, options);
|
|
216
256
|
if (!looked.ok)
|
|
217
257
|
return looked;
|
|
218
258
|
const value = looked.value;
|
|
@@ -262,3 +302,24 @@ export async function lookProjectMcp(repo, options = {}) {
|
|
|
262
302
|
const config = value.config;
|
|
263
303
|
return { ok: true, value: config !== null && typeof config === "object" && !Array.isArray(config) ? config : null };
|
|
264
304
|
}
|
|
305
|
+
const factsOf = (value) => {
|
|
306
|
+
const one = value;
|
|
307
|
+
if (one === null || typeof one !== "object")
|
|
308
|
+
return { kind: "unreadable" };
|
|
309
|
+
if (one.kind === "missing" && text(one.path) && one.path.startsWith("/"))
|
|
310
|
+
return { kind: "missing", path: one.path };
|
|
311
|
+
if (one.kind !== "found" || !text(one.real) || typeof one.dir !== "boolean" || typeof one.uid !== "number" || !Array.isArray(one.chain))
|
|
312
|
+
return { kind: "unreadable" };
|
|
313
|
+
const chain = one.chain.filter((id) => typeof id === "string" && /^\d+:\d+$/.test(id));
|
|
314
|
+
const complete = chain.length === one.chain.length && chain.length === one.real.split("/").filter(Boolean).length + 1;
|
|
315
|
+
return complete ? { kind: "found", real: one.real, dir: one.dir, uid: one.uid, chain } : { kind: "unreadable" };
|
|
316
|
+
};
|
|
317
|
+
export async function folderFacts(path, compare, options = {}) {
|
|
318
|
+
const looked = await lookFolders({ op: "folder", path, compare: [...compare] }, options);
|
|
319
|
+
if (!looked.ok)
|
|
320
|
+
return looked;
|
|
321
|
+
const value = looked.value;
|
|
322
|
+
if (value === null || typeof value !== "object" || !Array.isArray(value.compare) || value.compare.length !== compare.length)
|
|
323
|
+
return { ok: false, why: "failed" };
|
|
324
|
+
return { ok: true, value: { target: factsOf(value.target), compare: value.compare.map(factsOf) } };
|
|
325
|
+
}
|
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
|
@@ -279,7 +279,9 @@ ${AUTHORITY_LINE}
|
|
|
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),
|
|
281
281
|
registers the machine as a worker, runs the console, opens the browser. Later starts ask for the
|
|
282
|
-
password at most once and remember it on that machine.
|
|
282
|
+
password at most once and remember it on that machine. A forgotten
|
|
283
|
+
password: the person runs \`toolroll password reset\` in a terminal on that
|
|
284
|
+
computer (typed twice; never you, never under an agent).
|
|
283
285
|
- From a phone over a tailnet: add \`--host 0.0.0.0 --allow-host
|
|
284
286
|
<name>:4180\`.
|
|
285
287
|
- Console only, no worker: \`toolroll serve --repo .\`. With no
|
package/dist/lead-cli.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cardPlainOf, isCardProposal } from "./chat-card.js";
|
|
2
2
|
import { currentLocalOwner } from "./local-owner.js";
|
|
3
|
+
import { passwordFreeOwner } from "./task-outcome-cli.js";
|
|
3
4
|
import { parseFeedbackImage } from "./result-review.js";
|
|
4
5
|
import { configureLeadFollow, leadFollowStatus } from './lead-follow.js';
|
|
5
6
|
import { closedQuestionWords } from "./decision.js";
|
|
@@ -337,7 +338,7 @@ export async function runLeadCli(input) {
|
|
|
337
338
|
emit({ ok: outcome.ok, act: "confirm", proposal: proposal.id, ...(outcome.ok ? { said: outcome.said, taskId: outcome.taskId } : { reason: outcome.reason, said: outcome.said }) });
|
|
338
339
|
say(outcome.ok ? outcome.said : outcome.reason === "needs-confirm" ? `${outcome.said}: confirm ${act[2]} yes` : `refused: ${outcome.said}`);
|
|
339
340
|
if (outcome.ok && outcome.kind === "scope" && outcome.taskId !== null)
|
|
340
|
-
say(`approve it with your password: toolroll task approve ${outcome.taskId}`);
|
|
341
|
+
say(passwordFreeOwner(store) ? `approve it in \`toolroll\`: press a on ${outcome.taskId}` : `approve it with your password: toolroll task approve ${outcome.taskId}`);
|
|
341
342
|
}
|
|
342
343
|
continue;
|
|
343
344
|
}
|
package/dist/live-bus.js
CHANGED
|
@@ -141,6 +141,9 @@ export class LiveStream {
|
|
|
141
141
|
keepAlive() {
|
|
142
142
|
this.write(": keep-alive\n\n");
|
|
143
143
|
}
|
|
144
|
+
tick() {
|
|
145
|
+
this.write("event: tick\ndata: {}\n\n");
|
|
146
|
+
}
|
|
144
147
|
}
|
|
145
148
|
export class LiveConnection {
|
|
146
149
|
response;
|
|
@@ -150,8 +153,10 @@ export class LiveConnection {
|
|
|
150
153
|
timer;
|
|
151
154
|
closed = false;
|
|
152
155
|
refusing = false;
|
|
156
|
+
frames;
|
|
153
157
|
constructor(response, options = {}) {
|
|
154
158
|
this.response = response;
|
|
159
|
+
this.frames = options.frames === true;
|
|
155
160
|
this.stream = new LiveStream(response, options.limitBytes, () => this.close());
|
|
156
161
|
this.timer = setInterval(() => this.keepAlive(), options.keepAliveMs ?? KEEP_ALIVE_MS);
|
|
157
162
|
this.timer.unref();
|
|
@@ -163,9 +168,17 @@ export class LiveConnection {
|
|
|
163
168
|
return;
|
|
164
169
|
prove();
|
|
165
170
|
}
|
|
166
|
-
if (this.open)
|
|
171
|
+
if (!this.open)
|
|
172
|
+
return;
|
|
173
|
+
if (this.frames)
|
|
174
|
+
this.stream.tick();
|
|
175
|
+
else
|
|
167
176
|
this.stream.keepAlive();
|
|
168
177
|
}
|
|
178
|
+
hello(data) {
|
|
179
|
+
if (this.frames && this.open)
|
|
180
|
+
this.stream.send("hello", data);
|
|
181
|
+
}
|
|
169
182
|
onKeepAlive(prove) { this.proofs.add(prove); return () => { this.proofs.delete(prove); }; }
|
|
170
183
|
get open() { return !this.closed && this.stream.open; }
|
|
171
184
|
send(room, event, data = {}) { this.stream.send(event, { room, ...data }); }
|
package/dist/login-secrets.js
CHANGED
|
@@ -157,3 +157,46 @@ export function migrateLegacyLogin(stateDir) {
|
|
|
157
157
|
removeOld();
|
|
158
158
|
return { kind: "moved", from, to };
|
|
159
159
|
}
|
|
160
|
+
export function removeStaleSavedLogin(stateDir, account, current, beforeRemove) {
|
|
161
|
+
const done = { removed: [], stale: [], unchecked: [] };
|
|
162
|
+
const uid = process.getuid?.();
|
|
163
|
+
const proved = (parts) => {
|
|
164
|
+
for (let index = 1; index <= parts.length; index += 1) {
|
|
165
|
+
let held;
|
|
166
|
+
try {
|
|
167
|
+
held = lstatSync(join(stateDir, ...parts.slice(0, index)));
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return "absent";
|
|
171
|
+
}
|
|
172
|
+
const last = index === parts.length;
|
|
173
|
+
if (held.isSymbolicLink() || (uid !== undefined && held.uid !== uid))
|
|
174
|
+
return "doubtful";
|
|
175
|
+
if (last ? !held.isFile() || held.nlink !== 1 : !held.isDirectory())
|
|
176
|
+
return "doubtful";
|
|
177
|
+
}
|
|
178
|
+
return "contained";
|
|
179
|
+
};
|
|
180
|
+
for (const parts of [[SECRETS_DIR, LOGIN_FILE_NAME], [LOGIN_FILE_NAME]]) {
|
|
181
|
+
const path = join(stateDir, ...parts);
|
|
182
|
+
const first = proved(parts);
|
|
183
|
+
if (first === "absent")
|
|
184
|
+
continue;
|
|
185
|
+
if (first === "doubtful") {
|
|
186
|
+
done.unchecked.push(path);
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const held = ownRegularBytes(path, LOGIN_LIMIT);
|
|
190
|
+
if (held === null) {
|
|
191
|
+
done.unchecked.push(path);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const raw = held.bytes.toString("utf8").trim();
|
|
195
|
+
const cut = raw.indexOf(" ");
|
|
196
|
+
if (cut <= 0 || raw.slice(0, cut) !== account || raw.slice(cut + 1) === current)
|
|
197
|
+
continue;
|
|
198
|
+
beforeRemove?.(path);
|
|
199
|
+
done.stale.push(path);
|
|
200
|
+
}
|
|
201
|
+
return done;
|
|
202
|
+
}
|