toolroll 0.9.107 → 0.9.109
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 +54 -0
- package/README.md +4 -3
- package/dist/advanced-view.js +0 -1
- package/dist/agent-fence.js +35 -4
- package/dist/agent-state.js +5 -2
- package/dist/assignment-ui.js +5 -5
- package/dist/assignment.js +5 -2
- package/dist/browser/terminal.js +1 -1
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +38 -33
- package/dist/browser-crew.js +4 -4
- package/dist/browser-shell.js +1 -1
- package/dist/browser-workspace.js +4 -11
- package/dist/builder.js +9 -1
- package/dist/chat-controls.js +6 -5
- package/dist/chat-decide.js +1 -1
- package/dist/chat-quiet.js +3 -3
- package/dist/chat-voice.js +2 -2
- package/dist/cli-help.js +17 -13
- package/dist/cli.js +4 -3
- package/dist/console-chrome.js +10 -3
- package/dist/contracts/cli.js +2 -0
- package/dist/contracts/console-api.js +5 -4
- package/dist/contracts/handoff.js +4 -0
- package/dist/decision.js +17 -0
- package/dist/demo-chat.js +1 -1
- package/dist/demo.js +6 -0
- package/dist/design/kit.js +4 -3
- package/dist/dispatch.js +3 -8
- package/dist/flexible-available.js +1 -0
- package/dist/flexible-schema.js +32 -0
- package/dist/flexible-thread-schema.js +30 -0
- package/dist/flexible-thread.js +526 -0
- package/dist/flexible-ui.js +44 -0
- package/dist/flexible.js +359 -0
- package/dist/folder-look.js +65 -4
- package/dist/git-views.js +38 -38
- package/dist/guides.js +14 -11
- package/dist/keymap.js +1 -1
- package/dist/lead-cli.js +2 -1
- package/dist/lead-context.js +1 -1
- package/dist/limits-ui.js +1 -1
- package/dist/live-bus.js +82 -12
- package/dist/login-secrets.js +43 -0
- package/dist/needs-you.js +3 -3
- package/dist/nightly-github.js +2 -2
- package/dist/operate.js +278 -21
- package/dist/project-admission.js +60 -29
- package/dist/project-delete-ui.js +2 -1
- package/dist/project-delete.js +1 -0
- package/dist/project.js +73 -0
- package/dist/provider-auth.js +1 -1
- package/dist/release.js +1 -0
- package/dist/repos.js +37 -0
- package/dist/result-actions.js +3 -0
- package/dist/result-evidence-readers.js +8 -2
- package/dist/result-review.js +20 -9
- package/dist/route-hooks.js +1 -0
- package/dist/sample-project.js +167 -9
- package/dist/scope.js +17 -2
- package/dist/serve.js +47 -32
- package/dist/server/chat.js +9 -9
- package/dist/server/chrome.js +16 -16
- package/dist/server/guards.js +10 -4
- package/dist/server/home.js +37 -5
- package/dist/server/http.js +4 -2
- package/dist/server/in-place.js +5 -4
- package/dist/server/kit.js +2 -2
- package/dist/server/live.js +103 -10
- package/dist/server/login-help.js +67 -0
- package/dist/server/pages.js +258 -78
- package/dist/server/people-tokens.js +36 -24
- package/dist/server/render-chat.js +1 -1
- package/dist/server/render-history.js +18 -4
- package/dist/server/render-new-task.js +2 -2
- package/dist/server/render-pages.js +21 -39
- package/dist/server/render-people.js +16 -4
- package/dist/server/render-projects.js +63 -15
- package/dist/server/render-results.js +26 -10
- package/dist/server/render-tasks.js +26 -17
- package/dist/server/retired-routes.js +37 -4
- package/dist/server/route-policy.js +8 -0
- package/dist/server/route-table.js +15 -5
- package/dist/server/settings-computers.js +140 -0
- package/dist/server/settings-scripts.js +15 -0
- package/dist/server/settings-section-table.js +56 -0
- package/dist/server/settings-sections.js +258 -0
- package/dist/server/settings.js +167 -19
- package/dist/server/task-views.js +47 -13
- package/dist/server/tasks.js +143 -90
- package/dist/server/welcome.js +35 -23
- package/dist/settings-groups-ui.js +34 -106
- package/dist/settings-proofs.js +5 -2
- package/dist/sqlite-telemetry.js +70 -21
- package/dist/store.js +141 -9
- package/dist/surface.js +4 -1
- package/dist/task-link.js +64 -0
- package/dist/task-outcome-cli.js +99 -4
- package/dist/tui-source.js +11 -3
- package/dist/tui.js +39 -39
- package/dist/typed-words-schema.js +18 -0
- package/dist/welcome-facts.js +15 -7
- package/dist/work-index.js +126 -29
- package/dist/work-reads.js +279 -0
- package/package.json +4 -2
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";
|
|
@@ -166,7 +166,7 @@ function planContractLines(store, evidenceRoot, taskId) {
|
|
|
166
166
|
}
|
|
167
167
|
import { verdictWords as proofVerdictWords, matrixWords, plainReasonWords, semanticCoverage, coverageWords } from "./proof.js";
|
|
168
168
|
import { probeRepo } from "./probe.js";
|
|
169
|
-
import { agentlessFirstRun, diagnoseTaskDispatch, diagnosisIsDispatchable, NO_AGENT_TITLE, scopeApprovedForDispatch, } from "./dispatch.js";
|
|
169
|
+
import { agentlessFirstRun, buildersFor, diagnoseTaskDispatch, diagnosisIsDispatchable, NO_AGENT_TITLE, scopeApprovedForDispatch, } from "./dispatch.js";
|
|
170
170
|
import { createDecisionServer, SIGN_IN_LINK_MS } from "./serve.js";
|
|
171
171
|
import { readTailnetNames } from "./tailnet.js";
|
|
172
172
|
import { daemonLaunchCommand, daemonStatus, installReplacingLegacy, installedLegacyDaemon, planDaemon, uninstallDaemon, awaitFreshHeartbeat, } from "./daemon.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";
|
|
@@ -263,11 +263,13 @@ import { latestRelease, newerRelease, notifySecurityRelease, notifyVersionLive,
|
|
|
263
263
|
import { installMethod } from "./install-method.js";
|
|
264
264
|
import { PACKAGE_VERSION } from "./version.js";
|
|
265
265
|
import { machineActing } from "./scope.js";
|
|
266
|
+
import { FLEXIBLE_AVAILABLE } from "./flexible-available.js";
|
|
267
|
+
import { enableFlexible, FLEXIBLE_LAPSE_WORDS, FLEXIBLE_LEVEL_WORDS, FLEXIBLE_UNAVAILABLE, flexibleStanding, flexibleTermsWords, isFlexibleLevel, lowerFlexible, proposedFlexibleTerms, turnFlexibleOff } from "./flexible.js";
|
|
266
268
|
import { reevaluateResultRecords } from "./route-results.js";
|
|
267
269
|
import { holdRuleOff, routeRulesPass, taskEvidenceWords } from "./route-rules.js";
|
|
268
270
|
import { ruleHoldOf } from "./route-store.js";
|
|
269
271
|
import { wasInterrupted } from "./run-ending.js";
|
|
270
|
-
import { loginFileOf, migrateLegacyLogin, savedLoginFile, writableLoginFile } from "./login-secrets.js";
|
|
272
|
+
import { loginFileOf, migrateLegacyLogin, removeStaleSavedLogin, savedLoginFile, writableLoginFile } from "./login-secrets.js";
|
|
271
273
|
export const EXIT = { ok: 0, failed: 1, usage: 2, refused: 3 };
|
|
272
274
|
const STATES = ["queued", "running", "done", "failed", "cancelled"];
|
|
273
275
|
export const OPERATE_HELP = `toolroll — operating the queue
|
|
@@ -434,6 +436,14 @@ External trackers — build what a tracker nominates, under local approvals
|
|
|
434
436
|
person say yes; the bootstrap for
|
|
435
437
|
every approving act
|
|
436
438
|
toolroll approver list
|
|
439
|
+
toolroll password reset [--as <name>]
|
|
440
|
+
a forgotten password: typed twice,
|
|
441
|
+
hidden, at this computer's own
|
|
442
|
+
terminal; every session of that
|
|
443
|
+
account ends. Anyone who can run
|
|
444
|
+
commands as you on this computer can
|
|
445
|
+
reset it, as they could read the
|
|
446
|
+
saved first password
|
|
437
447
|
toolroll task scope <id> --goal <what success is>
|
|
438
448
|
[--not <text>] [--touches a,b] [--budget-usd <n>]
|
|
439
449
|
toolroll task approve <id> the yes — interactive, or
|
|
@@ -726,6 +736,7 @@ export const OPERATE_VALUE_FLAGS = new Set([
|
|
|
726
736
|
"token-name",
|
|
727
737
|
"request",
|
|
728
738
|
"read-deny", "mach",
|
|
739
|
+
"default",
|
|
729
740
|
"release",
|
|
730
741
|
"despite",
|
|
731
742
|
]);
|
|
@@ -1152,6 +1163,8 @@ async function dispatch(command, positional, flags, context) {
|
|
|
1152
1163
|
return projectCheckAccessCommand(positional, flags, context);
|
|
1153
1164
|
if (positional[0] === "sandbox")
|
|
1154
1165
|
return projectSandboxCommand(positional, flags, context);
|
|
1166
|
+
if (positional[0] === "flexible")
|
|
1167
|
+
return projectFlexibleCommand(positional, flags, context);
|
|
1155
1168
|
if (positional[0] === "checks")
|
|
1156
1169
|
return projectChecksCommand(positional, flags, context);
|
|
1157
1170
|
if (positional[0] === "demo")
|
|
@@ -6172,6 +6185,7 @@ async function upCommand(flags, context) {
|
|
|
6172
6185
|
explicitRoots.push(canonical);
|
|
6173
6186
|
}
|
|
6174
6187
|
const projectRoots = [...resolveCeiling([], addRepos(loadedRegistry.roots, explicitRoots)).ceiling.roots];
|
|
6188
|
+
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
6189
|
const repos = [];
|
|
6176
6190
|
const proveRepo = async (input) => {
|
|
6177
6191
|
return (await upProveSaved(gitRun, input))?.root ?? null;
|
|
@@ -6241,12 +6255,12 @@ async function upCommand(flags, context) {
|
|
|
6241
6255
|
ours = null;
|
|
6242
6256
|
}
|
|
6243
6257
|
if (ours?.ok === true)
|
|
6244
|
-
return fail(write, json, "up", "already-running", `Toolroll is already running at ${ours.url}`, EXIT.refused);
|
|
6258
|
+
return fail(write, json, "up", "already-running", `Toolroll is already running at ${ours.url}${rootNotSaved}`, EXIT.refused);
|
|
6245
6259
|
if (ours === null || ours.state !== "none")
|
|
6246
6260
|
break;
|
|
6247
6261
|
const serving = consoleServingNow(store, clock(), await consolesProvenDown(store, clock()));
|
|
6248
6262
|
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);
|
|
6263
|
+
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
6264
|
}
|
|
6251
6265
|
probe = createNetServer();
|
|
6252
6266
|
port = candidate;
|
|
@@ -6265,8 +6279,8 @@ async function upCommand(flags, context) {
|
|
|
6265
6279
|
if (!reserved) {
|
|
6266
6280
|
const holder = consoleRowForPort(store, port);
|
|
6267
6281
|
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);
|
|
6282
|
+
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);
|
|
6283
|
+
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
6284
|
}
|
|
6271
6285
|
const agentRunning = underAgent(context.upSeams?.env ?? process.env);
|
|
6272
6286
|
const canPrompt = !json && !agentRunning && process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
@@ -7471,13 +7485,15 @@ function taskAction(action, rest, flags, context) {
|
|
|
7471
7485
|
case "revise":
|
|
7472
7486
|
if (action === "complete" && currentLocalOwner() !== null)
|
|
7473
7487
|
return runLocalCompletion(rest, flags, context);
|
|
7488
|
+
if (action === "revise" && currentLocalOwner() !== null)
|
|
7489
|
+
return runLocalRevision(rest, flags, context);
|
|
7474
7490
|
return runTaskOutcomeCommand(action, rest, flags, { ...context, operator: async () => {
|
|
7475
7491
|
const acting = await askCredentials(flags, context);
|
|
7476
7492
|
if (acting === null)
|
|
7477
7493
|
return null;
|
|
7478
7494
|
const authenticated = verifyApproverByPassword(context.store, acting.name, acting.token, context.store.knownRepos().filter(repo => context.store.accountCanAccess(acting.name, repo)));
|
|
7479
7495
|
return authenticated.ok ? authenticated.who : null;
|
|
7480
|
-
} });
|
|
7496
|
+
}, caller: () => shellCallerFacts(context) });
|
|
7481
7497
|
case "merge":
|
|
7482
7498
|
return runTaskMergeCommand(rest, flags, { store: context.store, json: context.json, write: context.write, clock: context.clock,
|
|
7483
7499
|
demo: context.store.isDemo(), credentials: () => askCredentials(flags, context), ...(context.publishExec === undefined ? {} : { exec: context.publishExec }) });
|
|
@@ -7660,13 +7676,32 @@ async function addTask(positional, flags, context) {
|
|
|
7660
7676
|
return fail(write, json, "task add", "checks-fixed", chosen.message, EXIT.refused);
|
|
7661
7677
|
}
|
|
7662
7678
|
const link = consoleLinkFor(context, `/t/${encodeURIComponent(outcome.task.id)}`);
|
|
7679
|
+
let noAgent = null;
|
|
7680
|
+
const filedRef = placedIn === undefined || remote !== null ? null : store.lookupRef(outcome.task.id);
|
|
7681
|
+
if (filedRef !== null && filedRef.repo !== null) {
|
|
7682
|
+
try {
|
|
7683
|
+
const agentless = agentlessFirstRun(store, filedRef, true, buildersFor(store, filedRef.repo, now).alive.map(one => one.name));
|
|
7684
|
+
if (agentless !== null)
|
|
7685
|
+
noAgent = `${NO_AGENT_TITLE}. Run \`${agentless.command}\` so it can be planned.`;
|
|
7686
|
+
}
|
|
7687
|
+
catch {
|
|
7688
|
+
noAgent = null;
|
|
7689
|
+
}
|
|
7690
|
+
}
|
|
7691
|
+
const next = filedRef !== null && filedRef.repo !== null && filedRef.plan === null && !flags.has("report")
|
|
7692
|
+
? "Next: open `toolroll` and press p on it to ask for its plan." : null;
|
|
7663
7693
|
return succeed(write, json, "task add", {
|
|
7664
7694
|
task: outcome.task,
|
|
7665
7695
|
...(replaces === undefined ? {} : { replaces }),
|
|
7666
7696
|
repo: placedIn === undefined ? null : resolve(placedIn),
|
|
7667
7697
|
...(checks === undefined ? {} : { checks }),
|
|
7668
7698
|
...(link === null ? {} : { links: { task: link } }),
|
|
7669
|
-
|
|
7699
|
+
...(noAgent === null ? {} : { waiting: noAgent }),
|
|
7700
|
+
...(next === null ? {} : { next }),
|
|
7701
|
+
}, () => [`Queued ${outcome.task.id} — ${outcome.task.title}${flags.has("report") ? " (a scout task: it delivers a report)" : ""}${checks === undefined ? "" : ` · checks: ${CHECK_LEVEL_WORDS[checks]}`}`, ...(replaces === undefined ? [] : [` It replaces ${replaces}.`]), ...(noAgent === null ? [] : [` ${noAgent}`]),
|
|
7702
|
+
...(placedIn === undefined && remote === null ? [" It has no project yet: choose one on its page in Toolroll, or file it with `--repo <folder>`."] : []),
|
|
7703
|
+
...(next === null ? [] : [` ${next}`]),
|
|
7704
|
+
...(link === null ? [] : [` ${link}`])]);
|
|
7670
7705
|
}
|
|
7671
7706
|
function latestBuildResult(store, taskId) {
|
|
7672
7707
|
const family = store.taskFamilyOf(taskId, null, true);
|
|
@@ -8029,7 +8064,7 @@ function showTask(positional, context) {
|
|
|
8029
8064
|
: [` control: review #${detail.control.run} was stopped by ${detail.control.stop.requestedBy} — inspect its saved result and give feedback; separate model review has been removed`]),
|
|
8030
8065
|
...(detail.automaticReview === null ? reviewStatusLines(detail.review, latestFinished?.id ?? null) : buildReviewLines(detail.automaticReview)),
|
|
8031
8066
|
...(scope === null
|
|
8032
|
-
? [" no
|
|
8067
|
+
? [" no plan yet — nothing is built until one is written and approved"]
|
|
8033
8068
|
: describeScope(scope, readiness, taskEvidenceWords(store, task.id, now))),
|
|
8034
8069
|
...planContractLines(store, context.evidenceRoot, id),
|
|
8035
8070
|
...taskRouteStandingLines(id, routed, detail.dispatch?.summary === NO_AGENT_TITLE),
|
|
@@ -8103,7 +8138,7 @@ async function acceptTaskProof(positional, flags, context) {
|
|
|
8103
8138
|
return null;
|
|
8104
8139
|
const authenticated = verifyApproverByPassword(context.store, acting.name, acting.token, context.store.knownRepos().filter(repo => context.store.accountCanAccess(acting.name, repo)));
|
|
8105
8140
|
return authenticated.ok ? authenticated.who : null;
|
|
8106
|
-
} });
|
|
8141
|
+
}, caller: () => shellCallerFacts(context) });
|
|
8107
8142
|
}
|
|
8108
8143
|
const id = positional[0];
|
|
8109
8144
|
if (id === undefined)
|
|
@@ -8821,6 +8856,8 @@ async function approveTask(positional, flags, context) {
|
|
|
8821
8856
|
const id = positional[0];
|
|
8822
8857
|
if (id === undefined)
|
|
8823
8858
|
return fail(write, json, "task approve", "usage", "which task?", EXIT.usage);
|
|
8859
|
+
if (passwordFreeShell(store))
|
|
8860
|
+
return fail(write, json, "task approve", "local-owner", passwordFreeShellWords("a", shellCallerFacts(context)), EXIT.refused);
|
|
8824
8861
|
const scope = store.getScope(id);
|
|
8825
8862
|
if (scope === null)
|
|
8826
8863
|
return fail(write, json, "task approve", "no-scope", `${id} has no scope to approve — write one first`, EXIT.refused);
|
|
@@ -8984,7 +9021,7 @@ async function proposalsCommand(positional, flags, context) {
|
|
|
8984
9021
|
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
9022
|
return succeed(write, json, "proposals confirm", { proposal: id, kind: outcome.kind, said: outcome.said, ...(outcome.taskId === null ? {} : { task: outcome.taskId }) }, () => [
|
|
8986
9023
|
outcome.said,
|
|
8987
|
-
...(outcome.kind === "scope" && outcome.taskId !== null ? [`approve it with your password: toolroll task approve ${outcome.taskId}`] : []),
|
|
9024
|
+
...(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
9025
|
]);
|
|
8989
9026
|
}
|
|
8990
9027
|
async function chatCommand(flags, context) {
|
|
@@ -10623,7 +10660,7 @@ async function runUpConsoleRole(context, config, port, build) {
|
|
|
10623
10660
|
admittedRepos: () => [...activeRepos],
|
|
10624
10661
|
upConsole: true,
|
|
10625
10662
|
registryPath: config.registryPath,
|
|
10626
|
-
projectRoots: config.projectRoots,
|
|
10663
|
+
projectRoots: await (async () => { const saved = await loadProjectRegistry(config.registryPath); return "error" in saved ? config.projectRoots : saved.roots; })(),
|
|
10627
10664
|
...(config.editor ? { editorLinks: "vscode" } : {}),
|
|
10628
10665
|
});
|
|
10629
10666
|
}
|
|
@@ -11534,22 +11571,26 @@ async function openCommand(positional, flags, context) {
|
|
|
11534
11571
|
async function welcomeCommand(positional, flags, context) {
|
|
11535
11572
|
const { write, json } = context;
|
|
11536
11573
|
const command = "welcome";
|
|
11574
|
+
if (positional[0] === "sample")
|
|
11575
|
+
return welcomeSampleCommand(positional.slice(1), flags, context);
|
|
11537
11576
|
if (positional.length > 0)
|
|
11538
|
-
return fail(write, json, command, "usage", "Use `toolroll welcome [--json]`.", EXIT.usage);
|
|
11577
|
+
return fail(write, json, command, "usage", "Use `toolroll welcome [--json]`, or `toolroll welcome sample`.", EXIT.usage);
|
|
11539
11578
|
for (const name of flags.keys())
|
|
11540
11579
|
if (!["db", "json"].includes(name))
|
|
11541
11580
|
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");
|
|
11581
|
+
const { welcomeHere, welcomeLines, welcomeStepLines, WELCOME_STEPS, sampleOffered } = await import("./welcome-facts.js");
|
|
11543
11582
|
const read = async () => (await welcomeHere(context.store, context.databaseFile, context.clock(), context.easySeams?.check === undefined ? {} : { check: context.easySeams.check })).model;
|
|
11544
11583
|
let model = await read();
|
|
11584
|
+
const shellMayAdd = () => { const mode = localModeOf(context.store); return mode?.enabled === true && context.store.accountOf(mode.owner)?.passwordSet !== true; };
|
|
11585
|
+
const offer = () => sampleOffered(model, shellMayAdd(), context.store.isDemo()) ? "command" : null;
|
|
11545
11586
|
if (json || !personAtTerminal(context) || localOwnerRequested())
|
|
11546
|
-
return succeed(write, json, command, { ...model }, () => welcomeLines(model));
|
|
11587
|
+
return succeed(write, json, command, { ...model }, () => welcomeLines(model, offer()));
|
|
11547
11588
|
const askNow = context.easySeams?.ask ?? ask;
|
|
11548
11589
|
write(model.left === 0 ? "Setup is done." : `Welcome to Toolroll. ${model.left} ${model.left === 1 ? "step" : "steps"} to your first result.`);
|
|
11549
11590
|
for (const key of WELCOME_STEPS) {
|
|
11550
11591
|
for (;;) {
|
|
11551
11592
|
write("");
|
|
11552
|
-
for (const line of welcomeStepLines(model, key))
|
|
11593
|
+
for (const line of welcomeStepLines(model, key, offer()))
|
|
11553
11594
|
write(line);
|
|
11554
11595
|
if (model[key].done)
|
|
11555
11596
|
break;
|
|
@@ -11569,8 +11610,10 @@ async function passwordCommand(positional, flags, context) {
|
|
|
11569
11610
|
const { write, json, store } = context;
|
|
11570
11611
|
const [action, ...rest] = positional;
|
|
11571
11612
|
const command = action === undefined ? "password" : `password ${action}`;
|
|
11613
|
+
if (action === "reset")
|
|
11614
|
+
return passwordResetCommand(rest, flags, context);
|
|
11572
11615
|
if (action !== "set" || rest.length > 0)
|
|
11573
|
-
return fail(write, json, command, "usage", "Use `toolroll password set
|
|
11616
|
+
return fail(write, json, command, "usage", "Use `toolroll password set` (a first password) or `toolroll password reset` (a forgotten one).", EXIT.usage);
|
|
11574
11617
|
for (const name of flags.keys())
|
|
11575
11618
|
if (!["db", "json"].includes(name))
|
|
11576
11619
|
return fail(write, json, command, "usage", `--${name} is not a password set option: the password is only ever typed.`, EXIT.usage);
|
|
@@ -11835,7 +11878,7 @@ async function keepGrownCommand(positional, flags, context) {
|
|
|
11835
11878
|
const kept = keepGrownChange(store, id, clock());
|
|
11836
11879
|
if (!kept.ok)
|
|
11837
11880
|
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}\`.`]);
|
|
11881
|
+
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
11882
|
}
|
|
11840
11883
|
let resumingReleases = false;
|
|
11841
11884
|
async function resumeHeldReleases(store, stateDir, now) {
|
|
@@ -12342,3 +12385,217 @@ export async function consolesProvenDown(store, now, probe = probeConsoleAddress
|
|
|
12342
12385
|
async function closeServedConsole(server) {
|
|
12343
12386
|
await new Promise(resolve => { server.close(() => resolve()); server.closeAllConnections?.(); });
|
|
12344
12387
|
}
|
|
12388
|
+
async function welcomeSampleCommand(positional, flags, context) {
|
|
12389
|
+
const { write, json, store } = context;
|
|
12390
|
+
const command = "welcome sample";
|
|
12391
|
+
if (positional.length > 0)
|
|
12392
|
+
return fail(write, json, command, "usage", "Use `toolroll welcome sample`: it takes no folder or name.", EXIT.usage);
|
|
12393
|
+
for (const name of flags.keys())
|
|
12394
|
+
if (!["db", "json"].includes(name))
|
|
12395
|
+
return fail(write, json, command, "usage", `--${name} is not a welcome sample option.`, EXIT.usage);
|
|
12396
|
+
if (context.principal !== undefined)
|
|
12397
|
+
return fail(write, json, command, "not-remote", "The sample project is added on Toolroll's own computer.", EXIT.refused);
|
|
12398
|
+
const lead = envValue(process.env, "LEAD_TOKEN");
|
|
12399
|
+
if (context.leadToken !== undefined || (lead !== undefined && lead !== ""))
|
|
12400
|
+
return fail(write, json, command, "refused", "A lead token can't add the sample project. Run `toolroll` yourself and press s.", EXIT.refused);
|
|
12401
|
+
if (store.isDemo())
|
|
12402
|
+
return fail(write, json, command, "refused", "The sandbox never makes projects.", EXIT.refused);
|
|
12403
|
+
const viaScreen = localOwnerRequested();
|
|
12404
|
+
if (!viaScreen && !personAtTerminal(context))
|
|
12405
|
+
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);
|
|
12406
|
+
const binding = localOwnerBinding(store);
|
|
12407
|
+
if (binding === null)
|
|
12408
|
+
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);
|
|
12409
|
+
if (!viaScreen && store.accountOf(binding.account)?.passwordSet === true) {
|
|
12410
|
+
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);
|
|
12411
|
+
}
|
|
12412
|
+
const principal = viaScreen ? currentLocalOwner()
|
|
12413
|
+
: { account: binding.account, localGeneration: binding.localGeneration, accountGeneration: binding.accountGeneration, transport: "terminal", act: "add-project", sessionHash: null, request: null };
|
|
12414
|
+
if (principal === null || principal.act !== "add-project")
|
|
12415
|
+
return fail(write, json, command, "refused", "Set a password, or sign in with your password, to do this.", EXIT.refused);
|
|
12416
|
+
const registryFile = registryPathOf(context);
|
|
12417
|
+
const { readProjectRegistryNow } = await import("./repos.js");
|
|
12418
|
+
const ceiling = (registry) => {
|
|
12419
|
+
const read = registry ?? readProjectRegistryNow(registryFile);
|
|
12420
|
+
return "error" in read ? { repos: [], roots: [] } : resolveCeiling(read.repos, read.roots).ceiling;
|
|
12421
|
+
};
|
|
12422
|
+
if ("error" in readProjectRegistryNow(registryFile))
|
|
12423
|
+
return fail(write, json, command, "registry", "Toolroll's project list can't be read, so nothing was added.", EXIT.refused);
|
|
12424
|
+
const { addSampleProject } = await import("./sample-project.js");
|
|
12425
|
+
const added = await asLocalOwner(principal, async () => {
|
|
12426
|
+
const stands = () => localActNow(store, "add-project") !== null;
|
|
12427
|
+
return addSampleProject({ store, registryFile, now: context.clock(), ceiling, authority: { actor: { label: principal.account, origin: "cli" }, stands } });
|
|
12428
|
+
});
|
|
12429
|
+
if (!added.ok) {
|
|
12430
|
+
const words = {
|
|
12431
|
+
"no-root": "There's no projects folder to put the sample in. Run `toolroll` once to choose one, then try again.",
|
|
12432
|
+
exists: "A folder named toolroll-sample is already in your projects folder and wasn't made by Toolroll, so nothing was changed.",
|
|
12433
|
+
failed: "The sample project couldn't be made. Nothing was added. Try again.",
|
|
12434
|
+
"not-added": "The sample project was made but couldn't be added. Try again.",
|
|
12435
|
+
refused: "Your local sign-in changed while the sample was being added. Nothing was added. Run `toolroll` to sign in again.",
|
|
12436
|
+
incomplete: "The sample project wasn't added, and its line in your project list couldn't be taken back.",
|
|
12437
|
+
};
|
|
12438
|
+
return fail(write, json, command, added.reason, added.message ?? words[added.reason], EXIT.refused);
|
|
12439
|
+
}
|
|
12440
|
+
return succeed(write, json, command, { repo: added.repo, created: added.created, added: added.added, checkSet: added.checkSet }, () => [
|
|
12441
|
+
added.added ? `Added the sample project: ${added.repo}` : `The sample project is already added: ${added.repo}`,
|
|
12442
|
+
"Next: write a first task. Run `toolroll` and press n.",
|
|
12443
|
+
]);
|
|
12444
|
+
}
|
|
12445
|
+
async function passwordResetCommand(rest, flags, context) {
|
|
12446
|
+
const { write, json, store } = context;
|
|
12447
|
+
const command = "password reset";
|
|
12448
|
+
if (rest.length > 0)
|
|
12449
|
+
return fail(write, json, command, "usage", "Use `toolroll password reset` (or `--as <name>` when several people sign in here).", EXIT.usage);
|
|
12450
|
+
for (const name of flags.keys())
|
|
12451
|
+
if (!["db", "json", "as"].includes(name))
|
|
12452
|
+
return fail(write, json, command, "usage", `--${name} is not a password reset option: the new password is only ever typed.`, EXIT.usage);
|
|
12453
|
+
const leadInShell = envValue(process.env, "LEAD_TOKEN");
|
|
12454
|
+
if (context.principal !== undefined || activeRemote() !== null || context.leadToken !== undefined || (leadInShell !== undefined && leadInShell !== "")) {
|
|
12455
|
+
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);
|
|
12456
|
+
}
|
|
12457
|
+
if (localOwnerRequested() || !personAtTerminal(context)) {
|
|
12458
|
+
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);
|
|
12459
|
+
}
|
|
12460
|
+
const asked = flags.get("as");
|
|
12461
|
+
if (asked === true || asked === "")
|
|
12462
|
+
return fail(write, json, command, "usage", "Say whose password: `--as <name>`.", EXIT.usage);
|
|
12463
|
+
let account;
|
|
12464
|
+
if (typeof asked === "string") {
|
|
12465
|
+
account = asked;
|
|
12466
|
+
}
|
|
12467
|
+
else {
|
|
12468
|
+
const people = store.listApprovers().map(one => one.name).filter(name => store.accountOf(name)?.revokedAt === null);
|
|
12469
|
+
if (people.length === 0)
|
|
12470
|
+
return fail(write, json, command, "no-account", "No one signs in to this Toolroll yet. Nothing changed.", EXIT.refused);
|
|
12471
|
+
if (people.length > 1)
|
|
12472
|
+
return fail(write, json, command, "several", `Several people sign in here (${people.join(", ")}). Say whose: \`toolroll password reset --as <name>\`.`, EXIT.usage);
|
|
12473
|
+
account = people[0];
|
|
12474
|
+
}
|
|
12475
|
+
const sso = (await import("./sso-settings.js")).readSsoSettings(dirname(context.databaseFile));
|
|
12476
|
+
const operatorsOnly = sso !== null && sso.passwords === "operators";
|
|
12477
|
+
const refusalWords = (reason) => reason === "no-account" ? `No account named \`${account}\`. Nothing changed.`
|
|
12478
|
+
: reason === "revoked" ? `${account} was removed and can't sign in. Nothing changed.`
|
|
12479
|
+
: reason === "sso-only" ? `${account} signs in with ${sso?.label ?? "your identity provider"} and has no password to reset. Nothing changed.`
|
|
12480
|
+
: reason === "no-password" ? `${account} has no password yet. Set one with \`toolroll password set\`. Nothing changed.`
|
|
12481
|
+
: reason === "password-not-allowed" ? `${account} signs in with ${sso?.label ?? "your identity provider"}: passwords are only for instance operators here. Nothing changed.`
|
|
12482
|
+
: "The account changed while you were typing. Nothing changed; run `toolroll password reset` again.";
|
|
12483
|
+
const before = passwordResetRefusal(store, account, operatorsOnly);
|
|
12484
|
+
if (before !== null)
|
|
12485
|
+
return fail(write, json, command, before, refusalWords(before), EXIT.refused);
|
|
12486
|
+
const generation = store.accountOf(account).generation;
|
|
12487
|
+
write(`Reset the password for ${account}.`);
|
|
12488
|
+
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\`).`);
|
|
12489
|
+
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.");
|
|
12490
|
+
const typeHidden = context.easySeams?.askHidden ?? askHidden;
|
|
12491
|
+
const chosen = await typeHidden("New password: ");
|
|
12492
|
+
if (chosen.length < 8)
|
|
12493
|
+
return fail(write, json, command, "weak-password", "A password needs at least 8 characters. Nothing changed.", EXIT.refused);
|
|
12494
|
+
const again = await typeHidden("Type it again: ");
|
|
12495
|
+
if (again !== chosen)
|
|
12496
|
+
return fail(write, json, command, "mismatch", "The two passwords didn't match. Nothing changed.", EXIT.refused);
|
|
12497
|
+
const reset = resetAccountPassword(store, account, hashPassword(chosen), generation, operatorsOnly, context.clock());
|
|
12498
|
+
if (!reset.ok)
|
|
12499
|
+
return fail(write, json, command, reset.reason, refusalWords(reset.reason), EXIT.refused);
|
|
12500
|
+
const cleanup = removeStaleSavedLogin(dirname(context.databaseFile), account, chosen);
|
|
12501
|
+
const { shownPath } = await import("./server/login-help.js");
|
|
12502
|
+
const shown = (path) => shownPath(path, homedir(), null) ?? path;
|
|
12503
|
+
return succeed(write, json, command, { account, generation: reset.generation, removed: cleanup.removed }, () => [
|
|
12504
|
+
`Password reset for ${account}. Every session of ${account} has ended; sign in with the new password.`,
|
|
12505
|
+
...(reset.leadTokens > 0 ? [`${account}'s lead token ended: mint a new one with \`toolroll lead token\`.`] : []),
|
|
12506
|
+
...cleanup.removed.map(path => `Removed ${shown(path)}: it held the old password.`),
|
|
12507
|
+
...cleanup.stale.map(path => `The saved first password at ${shown(path)} no longer works; delete it yourself.`),
|
|
12508
|
+
...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.`),
|
|
12509
|
+
]);
|
|
12510
|
+
}
|
|
12511
|
+
function shellCallerFacts(context) {
|
|
12512
|
+
return {
|
|
12513
|
+
json: context.json,
|
|
12514
|
+
agent: context.easySeams?.agent ?? underAgent(process.env),
|
|
12515
|
+
terminal: context.easySeams?.terminal ?? (process.stdin.isTTY === true && process.stdout.isTTY === true),
|
|
12516
|
+
};
|
|
12517
|
+
}
|
|
12518
|
+
async function projectFlexibleCommand(positional, flags, context) {
|
|
12519
|
+
const action = positional[1] ?? "show";
|
|
12520
|
+
const command = `project flexible ${action}`;
|
|
12521
|
+
const { write, json } = context;
|
|
12522
|
+
if (!FLEXIBLE_AVAILABLE)
|
|
12523
|
+
return fail(write, json, command, "not-available", FLEXIBLE_UNAVAILABLE, EXIT.refused);
|
|
12524
|
+
const options = { show: [], enable: ["max", "default", "digest"], lower: ["max"], off: [] };
|
|
12525
|
+
const own = options[action];
|
|
12526
|
+
if (own === undefined || positional.length > 2)
|
|
12527
|
+
return fail(write, json, command, "usage", "Use project flexible [show | enable [--max <level>] [--default <level>] [--digest <d>] | lower --max <level> | off] --repo <project path>.", EXIT.usage);
|
|
12528
|
+
const allowed = new Set(["repo", "db", "json", ...own, ...(action === "show" ? [] : ["as", "token", "token-file", "token-env"])]);
|
|
12529
|
+
for (const name of flags.keys())
|
|
12530
|
+
if (!allowed.has(name))
|
|
12531
|
+
return fail(write, json, command, "usage", `--${name} is not a project flexible ${action} option.`, EXIT.usage);
|
|
12532
|
+
const repoFlag = text(flags, "repo");
|
|
12533
|
+
if (repoFlag === undefined)
|
|
12534
|
+
return fail(write, json, command, "usage", "Name the project with --repo <path>.", EXIT.usage);
|
|
12535
|
+
const level = (name) => { const value = text(flags, name); return value === undefined ? undefined : isFlexibleLevel(value) ? value : null; };
|
|
12536
|
+
const max = level("max"), chosenDefault = level("default");
|
|
12537
|
+
if (max === null || chosenDefault === null)
|
|
12538
|
+
return fail(write, json, command, "usage", "A level is supervised, auto or full.", EXIT.usage);
|
|
12539
|
+
const repo = await knownProject(context, repoFlag, { listed: true, canonical: true });
|
|
12540
|
+
if (repo === undefined)
|
|
12541
|
+
return fail(write, json, command, "not-found", "That isn't a project Toolroll knows.", EXIT.refused);
|
|
12542
|
+
const store = context.store;
|
|
12543
|
+
const termsLines = (terms, digest) => [...flexibleTermsWords(terms), `Terms ${digest}`];
|
|
12544
|
+
const shown = (standing) => {
|
|
12545
|
+
if (standing.state === "secure")
|
|
12546
|
+
return { data: { state: "secure" }, lines: [`${repo}: Secure. Work is planned and approved before it starts.`] };
|
|
12547
|
+
if (standing.state === "unreadable")
|
|
12548
|
+
return { data: { state: "unreadable" }, lines: [`${repo}: its Flexible terms can't be read, so they allow nothing. Turn Flexible off, then on again.`] };
|
|
12549
|
+
const data = { state: standing.state, digest: standing.digest, terms: standing.terms, signedBy: standing.signedBy, signedAt: standing.signedAt, ...(standing.state === "lapsed" ? { lapse: standing.reason } : {}) };
|
|
12550
|
+
if (standing.state === "lapsed")
|
|
12551
|
+
return { data, lines: [`${repo}: Flexible terms no longer count. ${FLEXIBLE_LAPSE_WORDS[standing.reason]} Turn it on again to sign new terms.`] };
|
|
12552
|
+
return { data, lines: [`${repo}: Flexible, turned on by ${standing.signedBy}.`, ...termsLines(standing.terms, standing.digest)] };
|
|
12553
|
+
};
|
|
12554
|
+
if (action === "show") {
|
|
12555
|
+
const now = shown(flexibleStanding(store, repo));
|
|
12556
|
+
return succeed(write, json, command, { repo, flexible: now.data }, () => now.lines);
|
|
12557
|
+
}
|
|
12558
|
+
const refused = (message) => fail(write, json, command, "person-only", message, EXIT.refused);
|
|
12559
|
+
if (machineActing() || process.env["TOOLROLL_LEAD_TOKEN"] !== undefined || process.env["TOOLROLL_REMOTE_TOKEN"] !== undefined)
|
|
12560
|
+
return refused("Only a person changes a project's Flexible terms, never the lead, a token or a chat app.");
|
|
12561
|
+
const acting = await askCredentials(flags, context);
|
|
12562
|
+
if (acting === null)
|
|
12563
|
+
return refused(`${action === "enable" ? "Turning on Flexible needs your password" : "This needs your sign-in"}: pass --as and --token.`);
|
|
12564
|
+
if (action === "enable") {
|
|
12565
|
+
const proved = credentialApprover(store, acting.name, acting.token, repo);
|
|
12566
|
+
if (!proved.ok)
|
|
12567
|
+
return refused("Only an approver of this project, with their password typed now, turns on Flexible.");
|
|
12568
|
+
const choice = { ...(max === undefined ? {} : { max }), ...(chosenDefault === undefined ? {} : { default: chosenDefault }) };
|
|
12569
|
+
const proposed = proposedFlexibleTerms(store, repo, acting.name, choice);
|
|
12570
|
+
if (!proposed.ok)
|
|
12571
|
+
return fail(write, json, command, proposed.reason, proposed.message, EXIT.refused);
|
|
12572
|
+
let digest = text(flags, "digest");
|
|
12573
|
+
if (digest === undefined) {
|
|
12574
|
+
if (!interactive() || json)
|
|
12575
|
+
return fail(write, json, command, "review-terms", [...termsLines(proposed.terms, proposed.digest), `Read these terms, then run again with --digest ${proposed.digest} to agree to them. Nothing changed.`].join("\n"), EXIT.refused, { digest: proposed.digest, terms: proposed.terms });
|
|
12576
|
+
write(termsLines(proposed.terms, proposed.digest).join("\n"));
|
|
12577
|
+
if (!(await confirm("Turn on Flexible with these terms? [y/N] ")))
|
|
12578
|
+
return fail(write, json, command, "declined", "Nothing changed.", EXIT.refused);
|
|
12579
|
+
digest = proposed.digest;
|
|
12580
|
+
}
|
|
12581
|
+
const done = enableFlexible(store, { repo, by: acting.name, proof: proved.method, choice, shownDigest: digest, now: context.clock() });
|
|
12582
|
+
if (!done.ok)
|
|
12583
|
+
return fail(write, json, command, done.reason, done.message, EXIT.refused);
|
|
12584
|
+
return succeed(write, json, command, { repo, flexible: shown(flexibleStanding(store, repo)).data, replaced: done.replaced }, () => [`${repo} is Flexible.`, ...termsLines(done.terms, done.digest)]);
|
|
12585
|
+
}
|
|
12586
|
+
const proved = authenticateApprover(store, acting.name, acting.token, repo);
|
|
12587
|
+
if (!proved.ok || !personProof(proved.method))
|
|
12588
|
+
return refused("Only an approver of this project, signed in as a person, changes its Flexible terms.");
|
|
12589
|
+
if (action === "lower") {
|
|
12590
|
+
if (max === undefined)
|
|
12591
|
+
return fail(write, json, command, "usage", "Name the highest level with --max supervised, auto or full.", EXIT.usage);
|
|
12592
|
+
const done = lowerFlexible(store, { repo, by: acting.name, max, now: context.clock() });
|
|
12593
|
+
if (!done.ok)
|
|
12594
|
+
return fail(write, json, command, done.reason, done.message, EXIT.refused);
|
|
12595
|
+
return succeed(write, json, command, { repo, changed: done.changed, flexible: shown(flexibleStanding(store, repo)).data }, () => [done.changed ? `Lowered: threads in ${repo} run at ${FLEXIBLE_LEVEL_WORDS[done.terms.max]} at most. New threads start under these terms only.` : "Nothing changed.", ...termsLines(done.terms, done.digest)]);
|
|
12596
|
+
}
|
|
12597
|
+
const done = turnFlexibleOff(store, { repo, by: acting.name, now: context.clock() });
|
|
12598
|
+
if (!done.ok)
|
|
12599
|
+
return fail(write, json, command, done.reason, done.message, EXIT.refused);
|
|
12600
|
+
return succeed(write, json, command, { repo, changed: done.changed, flexible: { state: "secure" } }, () => [done.changed ? `${repo} is Secure again. No new Flexible threads start.` : `${repo} is already Secure.`]);
|
|
12601
|
+
}
|
|
@@ -4,13 +4,14 @@ import { dirname, join, resolve } from "node:path";
|
|
|
4
4
|
import { run } from "./exec.js";
|
|
5
5
|
import { canonicalProject, projectName, sameRepo } from "./project.js";
|
|
6
6
|
import { remoteUrlProblem } from "./remote-main.js";
|
|
7
|
-
import { addRepos, loadProjectRegistry, removeRepos, updateRepos } from "./repos.js";
|
|
7
|
+
import { addRepos, loadProjectRegistry, removeRepos, updateProjectRegistry, updateRepos } from "./repos.js";
|
|
8
8
|
import { FolderUnavailable } from "./folder-gate.js";
|
|
9
9
|
const ADMISSION_GIT = {
|
|
10
10
|
envAllowlist: ["PATH", "HOME", "TMPDIR", "LANG", "LC_ALL"],
|
|
11
11
|
env: { GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", GIT_NO_REPLACE_OBJECTS: "1" },
|
|
12
12
|
};
|
|
13
13
|
export const PROJECT_ADDED = "project added";
|
|
14
|
+
export const PROJECT_ADD_INCOMPLETE = "project add incomplete";
|
|
14
15
|
export const PROJECT_REMOVED = "project removed";
|
|
15
16
|
export async function proveProjectRoot(path, exec = run, resolveFolder) {
|
|
16
17
|
if (path.trim() === "" || path.length > 4096 || /[\x00-\x1f]/.test(path)) {
|
|
@@ -53,48 +54,78 @@ export async function admitProject(store, input) {
|
|
|
53
54
|
const discovered = !known && input.captureOrigin === true && input.actor.origin !== "console"
|
|
54
55
|
? await originOf(repo, input.exec ?? run) : null;
|
|
55
56
|
let remote = { url: store.projectRemote(repo), why: null };
|
|
56
|
-
let
|
|
57
|
+
let enrolledHere = false;
|
|
58
|
+
const latestAdmission = () => Number(store.handle.prepare("SELECT COALESCE(MAX(id), 0) AS id FROM action_ledger WHERE repo = ? AND action = ?").get(repo, PROJECT_ADDED)?.["id"] ?? 0);
|
|
59
|
+
let admittedBefore = 0;
|
|
57
60
|
const allowed = () => input.stillAllowed === undefined || input.stillAllowed(repo);
|
|
58
61
|
const moved = { ok: false, reason: "moved", message: `${projectName(repo)} wasn't added: a project folder changed while it was being checked. Try again.` };
|
|
59
62
|
if (input.registryFile !== null) {
|
|
60
63
|
let refused = false;
|
|
61
64
|
let had = false;
|
|
62
|
-
const enrolled = await
|
|
63
|
-
had = repos.includes(repo);
|
|
64
|
-
|
|
65
|
+
const enrolled = await updateProjectRegistry(input.registryFile, current => {
|
|
66
|
+
had = current.repos.includes(repo);
|
|
67
|
+
admittedBefore = latestAdmission();
|
|
68
|
+
if (!allowed() || (input.registryAllowed !== undefined && !input.registryAllowed(repo, current))) {
|
|
65
69
|
refused = true;
|
|
66
|
-
return
|
|
70
|
+
return current;
|
|
67
71
|
}
|
|
68
|
-
return addRepos(repos, [repo]);
|
|
72
|
+
return { ...current, repos: addRepos(current.repos, [repo]) };
|
|
69
73
|
});
|
|
70
74
|
if (!enrolled.ok)
|
|
71
75
|
return { ok: false, reason: enrolled.reason, message: `${projectName(repo)} wasn't added: ${enrolled.message}` };
|
|
72
76
|
if (refused)
|
|
73
77
|
return moved;
|
|
74
|
-
|
|
78
|
+
enrolledHere = !had;
|
|
75
79
|
}
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
const giveBack = async (failure) => {
|
|
81
|
+
if (input.registryFile === null || !enrolledHere)
|
|
82
|
+
return failure;
|
|
83
|
+
let problem;
|
|
84
|
+
try {
|
|
85
|
+
const removed = await updateProjectRegistry(input.registryFile, current => !current.repos.includes(repo) || latestAdmission() > admittedBefore ? current : { ...current, repos: removeRepos(current.repos, [repo]) });
|
|
86
|
+
problem = removed.ok ? null : removed.message;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
problem = error instanceof Error ? error.message : String(error);
|
|
90
|
+
}
|
|
91
|
+
if (problem === null)
|
|
92
|
+
return failure;
|
|
93
|
+
let unrecorded = "";
|
|
94
|
+
try {
|
|
95
|
+
store.recordAction({ at: input.now.toISOString(), actor: input.actor.label, repo, taskId: null, runId: null, action: PROJECT_ADD_INCOMPLETE, outcome: "rollback-failed", source: "access",
|
|
96
|
+
detail: `its line in the project list couldn't be taken back: ${problem}` });
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
unrecorded = ` It couldn't be recorded in the history either (${error instanceof Error ? error.message : String(error)}).`;
|
|
100
|
+
}
|
|
101
|
+
return { ok: false, reason: "incomplete", message: `${projectName(repo)} wasn't added, and its line in the project list couldn't be taken back (${problem}). Remove it with \`toolroll repos remove ${repo}\`.${unrecorded}` };
|
|
102
|
+
};
|
|
103
|
+
let added;
|
|
104
|
+
try {
|
|
105
|
+
added = store.transact(() => {
|
|
106
|
+
if (!allowed())
|
|
107
|
+
return null;
|
|
108
|
+
const rowHad = store.listProjects().some(one => one.path === repo);
|
|
109
|
+
const previous = store.projectRemote(repo);
|
|
110
|
+
const first = !known && !store.projectAdmissionKnown(repo);
|
|
111
|
+
remote = input.remoteUrl !== undefined ? { url: input.remoteUrl, why: null }
|
|
112
|
+
: first && discovered !== null ? discovered : { url: previous, why: previous === null ? "no remote recorded; use repos add --remote <url>" : null };
|
|
113
|
+
store.upsertProject(repo, projectName(repo), input.now, { remoteUrl: remote.url });
|
|
114
|
+
if (input.remoteUrl !== undefined)
|
|
115
|
+
store.recordProjectRemote(input.actor.label, repo, previous, input.remoteUrl, input.now);
|
|
116
|
+
input.withinAdmission?.(repo);
|
|
117
|
+
if (rowHad && !enrolledHere)
|
|
118
|
+
return false;
|
|
119
|
+
store.recordAction({ at: input.now.toISOString(), actor: input.actor.label, repo, taskId: null, runId: null, action: PROJECT_ADDED, outcome: "added", source: "access", detail: `from ${input.actor.origin}` });
|
|
120
|
+
return true;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
return giveBack({ ok: false, reason: "failed", message: `${projectName(repo)} wasn't added: ${error instanceof Error ? error.message : String(error)}` });
|
|
96
125
|
}
|
|
97
|
-
|
|
126
|
+
if (added === null)
|
|
127
|
+
return giveBack(moved);
|
|
128
|
+
return { ok: true, repo, name: projectName(repo), added, remote, enrolled: enrolledHere };
|
|
98
129
|
}
|
|
99
130
|
export async function releaseProject(store, input) {
|
|
100
131
|
const unavailable = (error) => error instanceof FolderUnavailable;
|
|
@@ -6,6 +6,7 @@ import { html, joinHtml, postForm } from "./html.js";
|
|
|
6
6
|
import { holdingsWords } from "./project-delete.js";
|
|
7
7
|
import { acts, btn, codeLine, disclose, formRow, infoLine, input, note, notice, radios, settingsSection, switchInput, textarea } from "./server/kit.js";
|
|
8
8
|
import { kitSectionForm } from "./settings-kit.js";
|
|
9
|
+
import { flexibleSettingsHtml } from "./flexible-ui.js";
|
|
9
10
|
export const PROJECT_DELETE_CSS = ".k-opt [data-check-access-warning]{display:none;color:var(--so-ink)}.k-opt:has(input:checked) [data-check-access-warning]{display:block}" +
|
|
10
11
|
".k-opt:has(input:disabled){cursor:default;opacity:.6}";
|
|
11
12
|
const mono = (text) => html `<span class="k-mono">${text}</span>`;
|
|
@@ -199,7 +200,7 @@ export function projectSettingsHtml(view, said) {
|
|
|
199
200
|
disclose("Change remote", joinHtml([note("An owner or instance operator can run:"), codeLine("toolroll repos add <project> --remote <url>")])),
|
|
200
201
|
]) });
|
|
201
202
|
const advanced = advancedShownNow();
|
|
202
|
-
const settings = joinHtml([buildsHtml(view), accessHtml(view), networkHtml(view), advanced || (view.fallback?.setting ?? null) !== null ? fallbackHtml(view) : "",
|
|
203
|
+
const settings = joinHtml([flexibleSettingsHtml(view.flexible), buildsHtml(view), accessHtml(view), networkHtml(view), advanced || (view.fallback?.setting ?? null) !== null ? fallbackHtml(view) : "",
|
|
203
204
|
writesHtml(view), sandboxHtml(view), checkAccessHtml(view), advanced || view.liveView?.commands === true ? liveViewHtml(view) : "", advanced ? codeMapHtml(view) : ""]);
|
|
204
205
|
if (!view.canDelete)
|
|
205
206
|
return joinHtml([answer, project, settings, note("An instance operator can remove or delete a project.")]);
|