toolroll 0.9.107 → 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.
@@ -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,
@@ -171,7 +171,9 @@ export const COMMAND_OUTPUTS = {
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"]),
@@ -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 = fs.realpathSync(request.path);
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/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 }); }
@@ -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
+ }
package/dist/operate.js CHANGED
@@ -89,7 +89,7 @@ import { runKnowledgeApply, runKnowledgeCommand } from "./knowledge-cli.js";
89
89
  import { FLOWS_VALUE_FLAGS, runFlowsCommand } from "./flows-cli.js";
90
90
  import { runAssignmentCommand } from "./assignment-adapters.js";
91
91
  import { applyProjectProfile, runProjectCommand } from "./project-cli.js";
92
- import { proveTaskBuildsStopped, pullRequestLines, runLocalCompletion, runTaskMergeCommand, runTaskOutcomeCommand } from "./task-outcome-cli.js";
92
+ import { passwordFreeOwner, passwordFreeShell, passwordFreeShellWords, proveTaskBuildsStopped, pullRequestLines, runLocalCompletion, runLocalRevision, runTaskMergeCommand, runTaskOutcomeCommand } from "./task-outcome-cli.js";
93
93
  import { requestPlanAsLocalOwner, retryAsLocalOwner } from "./local-owner-acts.js";
94
94
  import { withTaskAlias } from "./task-aliases.js";
95
95
  import { checklistLines, mergeChecklistOf } from "./merge-checklist.js";
@@ -117,7 +117,7 @@ import { isWritesMode, writesWords } from "./writes-mode.js";
117
117
  import { linuxFenceAvailable, macosFenceAvailable } from "./agent-fence.js";
118
118
  import { parseMachLookup, parseReadDeny, readDenyWords } from "./project-sandbox.js";
119
119
  import { LOCAL_POLICY } from "./surface.js";
120
- import { asLocalOwner, currentLocalOwner, LOCAL_MODE_CONFINES, localModeOn, localOwnerRefusal, localOwnerRequested } from "./local-owner.js";
120
+ import { asLocalOwner, currentLocalOwner, localActNow, LOCAL_MODE_CONFINES, localModeOn, localOwnerRefusal, localOwnerRequested } from "./local-owner.js";
121
121
  import { CHECK_ACCESS_WARNINGS, checkAccessRunsAs, checkAccessWords, isCheckAccess, signInHostsMissing, signInsUnavailableWords, widerThan } from "./check-access.js";
122
122
  import { CLI_PASSWORD_SOURCE, withPasswordSource } from "./sign-in-guard.js";
123
123
  import { ledgerSpent, NO_SAFE_OPENER, openSignInLink, platformOpener } from "./sign-in-page.js";
@@ -199,7 +199,7 @@ import { mintCoordinator, revokeCoordinator, listCoordinators } from "./coordina
199
199
  import { serveMcp } from "./mcp.js";
200
200
  import { createInterface } from "node:readline";
201
201
  import { hashPassword } from "./scope.js";
202
- import { noticeDueOnce, CONTAINMENT_NOTICE_FACT } from "./store.js";
202
+ import { noticeDueOnce, CONTAINMENT_NOTICE_FACT, passwordResetRefusal, resetAccountPassword } from "./store.js";
203
203
  import { propose, approve, addApprover, authenticateAccount, authenticateApprover as passwordApprover, describeScope, approvalOf, hashToken as hashApproverToken, modeFilingCoverage, acceptanceLinesToInput, parseAcceptanceCriteria, splitAcceptanceRubric, rubricIsPlaceholder, isCommitSha, credentialProof, rememberedLogin, personApprovalOf } from "./scope.js";
204
204
  import { CHAT_APPROVE_ALL, presetTerms, modeTermsJson, modeDigestOf, modeTermsFromJson, modeWords, MODE_MAX_DAYS } from "./modes.js";
205
205
  import { WorktreePool } from "./worktree.js";
@@ -267,7 +267,7 @@ import { reevaluateResultRecords } from "./route-results.js";
267
267
  import { holdRuleOff, routeRulesPass, taskEvidenceWords } from "./route-rules.js";
268
268
  import { ruleHoldOf } from "./route-store.js";
269
269
  import { wasInterrupted } from "./run-ending.js";
270
- import { loginFileOf, migrateLegacyLogin, savedLoginFile, writableLoginFile } from "./login-secrets.js";
270
+ import { loginFileOf, migrateLegacyLogin, removeStaleSavedLogin, savedLoginFile, writableLoginFile } from "./login-secrets.js";
271
271
  export const EXIT = { ok: 0, failed: 1, usage: 2, refused: 3 };
272
272
  const STATES = ["queued", "running", "done", "failed", "cancelled"];
273
273
  export const OPERATE_HELP = `toolroll — operating the queue
@@ -434,6 +434,14 @@ External trackers — build what a tracker nominates, under local approvals
434
434
  person say yes; the bootstrap for
435
435
  every approving act
436
436
  toolroll approver list
437
+ toolroll password reset [--as <name>]
438
+ a forgotten password: typed twice,
439
+ hidden, at this computer's own
440
+ terminal; every session of that
441
+ account ends. Anyone who can run
442
+ commands as you on this computer can
443
+ reset it, as they could read the
444
+ saved first password
437
445
  toolroll task scope <id> --goal <what success is>
438
446
  [--not <text>] [--touches a,b] [--budget-usd <n>]
439
447
  toolroll task approve <id> the yes — interactive, or
@@ -6172,6 +6180,7 @@ async function upCommand(flags, context) {
6172
6180
  explicitRoots.push(canonical);
6173
6181
  }
6174
6182
  const projectRoots = [...resolveCeiling([], addRepos(loadedRegistry.roots, explicitRoots)).ceiling.roots];
6183
+ const rootNotSaved = explicitRoots.length > 0 ? ". The projects folder wasn't saved, because this Toolroll didn't start: stop the one already running, then start it again with --project-root" : "";
6175
6184
  const repos = [];
6176
6185
  const proveRepo = async (input) => {
6177
6186
  return (await upProveSaved(gitRun, input))?.root ?? null;
@@ -6241,12 +6250,12 @@ async function upCommand(flags, context) {
6241
6250
  ours = null;
6242
6251
  }
6243
6252
  if (ours?.ok === true)
6244
- return fail(write, json, "up", "already-running", `Toolroll is already running at ${ours.url}`, EXIT.refused);
6253
+ return fail(write, json, "up", "already-running", `Toolroll is already running at ${ours.url}${rootNotSaved}`, EXIT.refused);
6245
6254
  if (ours === null || ours.state !== "none")
6246
6255
  break;
6247
6256
  const serving = consoleServingNow(store, clock(), await consolesProvenDown(store, clock()));
6248
6257
  if (serving !== null)
6249
- return fail(write, json, "up", "already-running", serving.port === null ? "Toolroll's console is already serving this database" : `Toolroll is already running at http://127.0.0.1:${serving.port}`, EXIT.refused);
6258
+ return fail(write, json, "up", "already-running", `${serving.port === null ? "Toolroll's console is already serving this database" : `Toolroll is already running at http://127.0.0.1:${serving.port}`}${rootNotSaved}`, EXIT.refused);
6250
6259
  }
6251
6260
  probe = createNetServer();
6252
6261
  port = candidate;
@@ -6265,8 +6274,8 @@ async function upCommand(flags, context) {
6265
6274
  if (!reserved) {
6266
6275
  const holder = consoleRowForPort(store, port);
6267
6276
  if (holder?.state === "draining")
6268
- return fail(write, json, "up", "port-busy", `Toolroll is restarting (draining): the console on port ${port} is stopping — try again in a few seconds`, EXIT.refused);
6269
- return fail(write, json, "up", "port-busy", `port ${port} is taken — another \`up\` or \`serve\` may already be running; stop it, or pick a different --port`, EXIT.refused);
6277
+ return fail(write, json, "up", "port-busy", `Toolroll is restarting (draining): the console on port ${port} is stopping — try again in a few seconds${rootNotSaved}`, EXIT.refused);
6278
+ return fail(write, json, "up", "port-busy", `port ${port} is taken — another \`up\` or \`serve\` may already be running; stop it, or pick a different --port${rootNotSaved}`, EXIT.refused);
6270
6279
  }
6271
6280
  const agentRunning = underAgent(context.upSeams?.env ?? process.env);
6272
6281
  const canPrompt = !json && !agentRunning && process.stdin.isTTY === true && process.stdout.isTTY === true;
@@ -7471,13 +7480,15 @@ function taskAction(action, rest, flags, context) {
7471
7480
  case "revise":
7472
7481
  if (action === "complete" && currentLocalOwner() !== null)
7473
7482
  return runLocalCompletion(rest, flags, context);
7483
+ if (action === "revise" && currentLocalOwner() !== null)
7484
+ return runLocalRevision(rest, flags, context);
7474
7485
  return runTaskOutcomeCommand(action, rest, flags, { ...context, operator: async () => {
7475
7486
  const acting = await askCredentials(flags, context);
7476
7487
  if (acting === null)
7477
7488
  return null;
7478
7489
  const authenticated = verifyApproverByPassword(context.store, acting.name, acting.token, context.store.knownRepos().filter(repo => context.store.accountCanAccess(acting.name, repo)));
7479
7490
  return authenticated.ok ? authenticated.who : null;
7480
- } });
7491
+ }, caller: () => shellCallerFacts(context) });
7481
7492
  case "merge":
7482
7493
  return runTaskMergeCommand(rest, flags, { store: context.store, json: context.json, write: context.write, clock: context.clock,
7483
7494
  demo: context.store.isDemo(), credentials: () => askCredentials(flags, context), ...(context.publishExec === undefined ? {} : { exec: context.publishExec }) });
@@ -8103,7 +8114,7 @@ async function acceptTaskProof(positional, flags, context) {
8103
8114
  return null;
8104
8115
  const authenticated = verifyApproverByPassword(context.store, acting.name, acting.token, context.store.knownRepos().filter(repo => context.store.accountCanAccess(acting.name, repo)));
8105
8116
  return authenticated.ok ? authenticated.who : null;
8106
- } });
8117
+ }, caller: () => shellCallerFacts(context) });
8107
8118
  }
8108
8119
  const id = positional[0];
8109
8120
  if (id === undefined)
@@ -8821,6 +8832,8 @@ async function approveTask(positional, flags, context) {
8821
8832
  const id = positional[0];
8822
8833
  if (id === undefined)
8823
8834
  return fail(write, json, "task approve", "usage", "which task?", EXIT.usage);
8835
+ if (passwordFreeShell(store))
8836
+ return fail(write, json, "task approve", "local-owner", passwordFreeShellWords("a", shellCallerFacts(context)), EXIT.refused);
8824
8837
  const scope = store.getScope(id);
8825
8838
  if (scope === null)
8826
8839
  return fail(write, json, "task approve", "no-scope", `${id} has no scope to approve — write one first`, EXIT.refused);
@@ -8984,7 +8997,7 @@ async function proposalsCommand(positional, flags, context) {
8984
8997
  return fail(write, json, "proposals confirm", outcome.reason, outcome.reason === "needs-confirm" ? `${outcome.said} — read the consequences above, then pass --yes` : outcome.said, EXIT.refused);
8985
8998
  return succeed(write, json, "proposals confirm", { proposal: id, kind: outcome.kind, said: outcome.said, ...(outcome.taskId === null ? {} : { task: outcome.taskId }) }, () => [
8986
8999
  outcome.said,
8987
- ...(outcome.kind === "scope" && outcome.taskId !== null ? [`approve it with your password: toolroll task approve ${outcome.taskId}`] : []),
9000
+ ...(outcome.kind === "scope" && outcome.taskId !== null ? [passwordFreeOwner(store) ? `approve it in \`toolroll\`: press a on ${outcome.taskId}` : `approve it with your password: toolroll task approve ${outcome.taskId}`] : []),
8988
9001
  ]);
8989
9002
  }
8990
9003
  async function chatCommand(flags, context) {
@@ -10623,7 +10636,7 @@ async function runUpConsoleRole(context, config, port, build) {
10623
10636
  admittedRepos: () => [...activeRepos],
10624
10637
  upConsole: true,
10625
10638
  registryPath: config.registryPath,
10626
- projectRoots: config.projectRoots,
10639
+ projectRoots: await (async () => { const saved = await loadProjectRegistry(config.registryPath); return "error" in saved ? config.projectRoots : saved.roots; })(),
10627
10640
  ...(config.editor ? { editorLinks: "vscode" } : {}),
10628
10641
  });
10629
10642
  }
@@ -11534,22 +11547,26 @@ async function openCommand(positional, flags, context) {
11534
11547
  async function welcomeCommand(positional, flags, context) {
11535
11548
  const { write, json } = context;
11536
11549
  const command = "welcome";
11550
+ if (positional[0] === "sample")
11551
+ return welcomeSampleCommand(positional.slice(1), flags, context);
11537
11552
  if (positional.length > 0)
11538
- return fail(write, json, command, "usage", "Use `toolroll welcome [--json]`.", EXIT.usage);
11553
+ return fail(write, json, command, "usage", "Use `toolroll welcome [--json]`, or `toolroll welcome sample`.", EXIT.usage);
11539
11554
  for (const name of flags.keys())
11540
11555
  if (!["db", "json"].includes(name))
11541
11556
  return fail(write, json, command, "usage", `--${name} is not a welcome option.`, EXIT.usage);
11542
- const { welcomeHere, welcomeLines, welcomeStepLines, WELCOME_STEPS } = await import("./welcome-facts.js");
11557
+ const { welcomeHere, welcomeLines, welcomeStepLines, WELCOME_STEPS, sampleOffered } = await import("./welcome-facts.js");
11543
11558
  const read = async () => (await welcomeHere(context.store, context.databaseFile, context.clock(), context.easySeams?.check === undefined ? {} : { check: context.easySeams.check })).model;
11544
11559
  let model = await read();
11560
+ const shellMayAdd = () => { const mode = localModeOf(context.store); return mode?.enabled === true && context.store.accountOf(mode.owner)?.passwordSet !== true; };
11561
+ const offer = () => sampleOffered(model, shellMayAdd(), context.store.isDemo()) ? "command" : null;
11545
11562
  if (json || !personAtTerminal(context) || localOwnerRequested())
11546
- return succeed(write, json, command, { ...model }, () => welcomeLines(model));
11563
+ return succeed(write, json, command, { ...model }, () => welcomeLines(model, offer()));
11547
11564
  const askNow = context.easySeams?.ask ?? ask;
11548
11565
  write(model.left === 0 ? "Setup is done." : `Welcome to Toolroll. ${model.left} ${model.left === 1 ? "step" : "steps"} to your first result.`);
11549
11566
  for (const key of WELCOME_STEPS) {
11550
11567
  for (;;) {
11551
11568
  write("");
11552
- for (const line of welcomeStepLines(model, key))
11569
+ for (const line of welcomeStepLines(model, key, offer()))
11553
11570
  write(line);
11554
11571
  if (model[key].done)
11555
11572
  break;
@@ -11569,8 +11586,10 @@ async function passwordCommand(positional, flags, context) {
11569
11586
  const { write, json, store } = context;
11570
11587
  const [action, ...rest] = positional;
11571
11588
  const command = action === undefined ? "password" : `password ${action}`;
11589
+ if (action === "reset")
11590
+ return passwordResetCommand(rest, flags, context);
11572
11591
  if (action !== "set" || rest.length > 0)
11573
- return fail(write, json, command, "usage", "Use `toolroll password set`.", EXIT.usage);
11592
+ return fail(write, json, command, "usage", "Use `toolroll password set` (a first password) or `toolroll password reset` (a forgotten one).", EXIT.usage);
11574
11593
  for (const name of flags.keys())
11575
11594
  if (!["db", "json"].includes(name))
11576
11595
  return fail(write, json, command, "usage", `--${name} is not a password set option: the password is only ever typed.`, EXIT.usage);
@@ -11835,7 +11854,7 @@ async function keepGrownCommand(positional, flags, context) {
11835
11854
  const kept = keepGrownChange(store, id, clock());
11836
11855
  if (!kept.ok)
11837
11856
  return fail(write, json, "task keep", "refused", kept.message, EXIT.refused);
11838
- return succeed(write, json, "task keep", { id, digest: kept.digest }, () => [`Its plan now names the exact commit. Approve it with \`toolroll task approve ${id}\`.`]);
11857
+ return succeed(write, json, "task keep", { id, digest: kept.digest }, () => [`Its plan now names the exact commit. ${passwordFreeOwner(store) ? "Approve it in `toolroll`: press a on the task." : `Approve it with \`toolroll task approve ${id}\`.`}`]);
11839
11858
  }
11840
11859
  let resumingReleases = false;
11841
11860
  async function resumeHeldReleases(store, stateDir, now) {
@@ -12342,3 +12361,133 @@ export async function consolesProvenDown(store, now, probe = probeConsoleAddress
12342
12361
  async function closeServedConsole(server) {
12343
12362
  await new Promise(resolve => { server.close(() => resolve()); server.closeAllConnections?.(); });
12344
12363
  }
12364
+ async function welcomeSampleCommand(positional, flags, context) {
12365
+ const { write, json, store } = context;
12366
+ const command = "welcome sample";
12367
+ if (positional.length > 0)
12368
+ return fail(write, json, command, "usage", "Use `toolroll welcome sample`: it takes no folder or name.", EXIT.usage);
12369
+ for (const name of flags.keys())
12370
+ if (!["db", "json"].includes(name))
12371
+ return fail(write, json, command, "usage", `--${name} is not a welcome sample option.`, EXIT.usage);
12372
+ if (context.principal !== undefined)
12373
+ return fail(write, json, command, "not-remote", "The sample project is added on Toolroll's own computer.", EXIT.refused);
12374
+ const lead = envValue(process.env, "LEAD_TOKEN");
12375
+ if (context.leadToken !== undefined || (lead !== undefined && lead !== ""))
12376
+ return fail(write, json, command, "refused", "A lead token can't add the sample project. Run `toolroll` yourself and press s.", EXIT.refused);
12377
+ if (store.isDemo())
12378
+ return fail(write, json, command, "refused", "The sandbox never makes projects.", EXIT.refused);
12379
+ const viaScreen = localOwnerRequested();
12380
+ if (!viaScreen && !personAtTerminal(context))
12381
+ return fail(write, json, command, "not-a-terminal", "Add the sample project yourself at a terminal: run `toolroll` and press s, or `toolroll welcome sample`.", EXIT.refused);
12382
+ const binding = localOwnerBinding(store);
12383
+ if (binding === null)
12384
+ return fail(write, json, command, "not-local", "This Toolroll signs in with a password. Open it in the browser and choose Try a sample project on the welcome page.", EXIT.refused);
12385
+ if (!viaScreen && store.accountOf(binding.account)?.passwordSet === true) {
12386
+ return fail(write, json, command, "password-set", "This Toolroll has a password. Run `toolroll` and press s, or sign in in the browser and choose Try a sample project.", EXIT.refused);
12387
+ }
12388
+ const principal = viaScreen ? currentLocalOwner()
12389
+ : { account: binding.account, localGeneration: binding.localGeneration, accountGeneration: binding.accountGeneration, transport: "terminal", act: "add-project", sessionHash: null, request: null };
12390
+ if (principal === null || principal.act !== "add-project")
12391
+ return fail(write, json, command, "refused", "Set a password, or sign in with your password, to do this.", EXIT.refused);
12392
+ const registryFile = registryPathOf(context);
12393
+ const { readProjectRegistryNow } = await import("./repos.js");
12394
+ const ceiling = (registry) => {
12395
+ const read = registry ?? readProjectRegistryNow(registryFile);
12396
+ return "error" in read ? { repos: [], roots: [] } : resolveCeiling(read.repos, read.roots).ceiling;
12397
+ };
12398
+ if ("error" in readProjectRegistryNow(registryFile))
12399
+ return fail(write, json, command, "registry", "Toolroll's project list can't be read, so nothing was added.", EXIT.refused);
12400
+ const { addSampleProject } = await import("./sample-project.js");
12401
+ const added = await asLocalOwner(principal, async () => {
12402
+ const stands = () => localActNow(store, "add-project") !== null;
12403
+ return addSampleProject({ store, registryFile, now: context.clock(), ceiling, authority: { actor: { label: principal.account, origin: "cli" }, stands } });
12404
+ });
12405
+ if (!added.ok) {
12406
+ const words = {
12407
+ "no-root": "There's no projects folder to put the sample in. Run `toolroll` once to choose one, then try again.",
12408
+ exists: "A folder named toolroll-sample is already in your projects folder and wasn't made by Toolroll, so nothing was changed.",
12409
+ failed: "The sample project couldn't be made. Nothing was added. Try again.",
12410
+ "not-added": "The sample project was made but couldn't be added. Try again.",
12411
+ refused: "Your local sign-in changed while the sample was being added. Nothing was added. Run `toolroll` to sign in again.",
12412
+ incomplete: "The sample project wasn't added, and its line in your project list couldn't be taken back.",
12413
+ };
12414
+ return fail(write, json, command, added.reason, added.message ?? words[added.reason], EXIT.refused);
12415
+ }
12416
+ return succeed(write, json, command, { repo: added.repo, created: added.created, added: added.added, checkSet: added.checkSet }, () => [
12417
+ added.added ? `Added the sample project: ${added.repo}` : `The sample project is already added: ${added.repo}`,
12418
+ "Next: write a first task. Run `toolroll` and press n.",
12419
+ ]);
12420
+ }
12421
+ async function passwordResetCommand(rest, flags, context) {
12422
+ const { write, json, store } = context;
12423
+ const command = "password reset";
12424
+ if (rest.length > 0)
12425
+ return fail(write, json, command, "usage", "Use `toolroll password reset` (or `--as <name>` when several people sign in here).", EXIT.usage);
12426
+ for (const name of flags.keys())
12427
+ if (!["db", "json", "as"].includes(name))
12428
+ return fail(write, json, command, "usage", `--${name} is not a password reset option: the new password is only ever typed.`, EXIT.usage);
12429
+ const leadInShell = envValue(process.env, "LEAD_TOKEN");
12430
+ if (context.principal !== undefined || activeRemote() !== null || context.leadToken !== undefined || (leadInShell !== undefined && leadInShell !== "")) {
12431
+ return fail(write, json, command, "not-remote", "A password is reset by a person at the computer running Toolroll, from their own shell (not with a remote or lead token).", EXIT.refused);
12432
+ }
12433
+ if (localOwnerRequested() || !personAtTerminal(context)) {
12434
+ return fail(write, json, command, "not-a-terminal", "Reset the password yourself at a terminal on the computer running Toolroll: run `toolroll password reset`.", EXIT.refused);
12435
+ }
12436
+ const asked = flags.get("as");
12437
+ if (asked === true || asked === "")
12438
+ return fail(write, json, command, "usage", "Say whose password: `--as <name>`.", EXIT.usage);
12439
+ let account;
12440
+ if (typeof asked === "string") {
12441
+ account = asked;
12442
+ }
12443
+ else {
12444
+ const people = store.listApprovers().map(one => one.name).filter(name => store.accountOf(name)?.revokedAt === null);
12445
+ if (people.length === 0)
12446
+ return fail(write, json, command, "no-account", "No one signs in to this Toolroll yet. Nothing changed.", EXIT.refused);
12447
+ if (people.length > 1)
12448
+ return fail(write, json, command, "several", `Several people sign in here (${people.join(", ")}). Say whose: \`toolroll password reset --as <name>\`.`, EXIT.usage);
12449
+ account = people[0];
12450
+ }
12451
+ const sso = (await import("./sso-settings.js")).readSsoSettings(dirname(context.databaseFile));
12452
+ const operatorsOnly = sso !== null && sso.passwords === "operators";
12453
+ const refusalWords = (reason) => reason === "no-account" ? `No account named \`${account}\`. Nothing changed.`
12454
+ : reason === "revoked" ? `${account} was removed and can't sign in. Nothing changed.`
12455
+ : reason === "sso-only" ? `${account} signs in with ${sso?.label ?? "your identity provider"} and has no password to reset. Nothing changed.`
12456
+ : reason === "no-password" ? `${account} has no password yet. Set one with \`toolroll password set\`. Nothing changed.`
12457
+ : reason === "password-not-allowed" ? `${account} signs in with ${sso?.label ?? "your identity provider"}: passwords are only for instance operators here. Nothing changed.`
12458
+ : "The account changed while you were typing. Nothing changed; run `toolroll password reset` again.";
12459
+ const before = passwordResetRefusal(store, account, operatorsOnly);
12460
+ if (before !== null)
12461
+ return fail(write, json, command, before, refusalWords(before), EXIT.refused);
12462
+ const generation = store.accountOf(account).generation;
12463
+ write(`Reset the password for ${account}.`);
12464
+ write(`This ends ${account}'s browser sessions and remembered passwords, the terminal UI's sign-in, paired chats, phone notifications, lead sessions and lead tokens (mint a new one with \`toolroll lead token\`).`);
12465
+ write("It keeps API and MCP tokens (revoke them in Settings → Sessions & tokens) and coordinator credentials (`toolroll coordinator revoke`). Revoke those too if someone else may know the old password.");
12466
+ const typeHidden = context.easySeams?.askHidden ?? askHidden;
12467
+ const chosen = await typeHidden("New password: ");
12468
+ if (chosen.length < 8)
12469
+ return fail(write, json, command, "weak-password", "A password needs at least 8 characters. Nothing changed.", EXIT.refused);
12470
+ const again = await typeHidden("Type it again: ");
12471
+ if (again !== chosen)
12472
+ return fail(write, json, command, "mismatch", "The two passwords didn't match. Nothing changed.", EXIT.refused);
12473
+ const reset = resetAccountPassword(store, account, hashPassword(chosen), generation, operatorsOnly, context.clock());
12474
+ if (!reset.ok)
12475
+ return fail(write, json, command, reset.reason, refusalWords(reset.reason), EXIT.refused);
12476
+ const cleanup = removeStaleSavedLogin(dirname(context.databaseFile), account, chosen);
12477
+ const { shownPath } = await import("./server/login-help.js");
12478
+ const shown = (path) => shownPath(path, homedir(), null) ?? path;
12479
+ return succeed(write, json, command, { account, generation: reset.generation, removed: cleanup.removed }, () => [
12480
+ `Password reset for ${account}. Every session of ${account} has ended; sign in with the new password.`,
12481
+ ...(reset.leadTokens > 0 ? [`${account}'s lead token ended: mint a new one with \`toolroll lead token\`.`] : []),
12482
+ ...cleanup.removed.map(path => `Removed ${shown(path)}: it held the old password.`),
12483
+ ...cleanup.stale.map(path => `The saved first password at ${shown(path)} no longer works; delete it yourself.`),
12484
+ ...cleanup.unchecked.map(path => `${shown(path)} isn't a plain file in Toolroll's folder, so it was left alone. If it holds ${account}'s old password, delete it yourself.`),
12485
+ ]);
12486
+ }
12487
+ function shellCallerFacts(context) {
12488
+ return {
12489
+ json: context.json,
12490
+ agent: context.easySeams?.agent ?? underAgent(process.env),
12491
+ terminal: context.easySeams?.terminal ?? (process.stdin.isTTY === true && process.stdout.isTTY === true),
12492
+ };
12493
+ }