toolroll 0.9.119 → 0.9.122
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 +77 -0
- package/README.md +18 -31
- package/dist/agent-fence.js +57 -9
- package/dist/assignment.js +9 -7
- package/dist/batch-checks.js +2 -2
- package/dist/browser/workspace.js +23 -23
- package/dist/builder.js +12 -8
- package/dist/central-recovery-stage.js +3 -3
- package/dist/cli-help.js +1 -0
- package/dist/codex-limits.js +40 -22
- package/dist/coding-provider.js +3 -3
- package/dist/contracts/console-api.js +3 -0
- package/dist/direct-chat-fence.js +9 -3
- package/dist/direct-chat.js +82 -10
- package/dist/engine-reads.js +3 -1
- package/dist/flexible-agents.js +16 -2
- package/dist/flexible-import.js +38 -0
- package/dist/flexible-save.js +128 -0
- package/dist/flexible-session.js +11 -3
- package/dist/flexible-ship.js +3 -3
- package/dist/flexible-thread.js +7 -3
- package/dist/install-method.js +1 -3
- package/dist/invoke.js +11 -9
- package/dist/lead-tools.js +3 -2
- package/dist/live-terminal.js +24 -3
- package/dist/local-checks.js +32 -0
- package/dist/local-landing.js +321 -63
- package/dist/local-owner.js +3 -0
- package/dist/operate.js +25 -7
- package/dist/plan-limits-demand.js +48 -0
- package/dist/planner.js +2 -0
- package/dist/project-delete.js +1 -1
- package/dist/project-skills.js +105 -17
- package/dist/result-follow-ups.js +24 -10
- package/dist/review-context.js +2 -1
- package/dist/scout.js +2 -1
- package/dist/serve.js +8 -1
- package/dist/server/direct-chat.js +25 -3
- package/dist/server/engine-api.js +24 -3
- package/dist/server/render-release.js +27 -15
- package/dist/server/render-results.js +6 -4
- package/dist/server/route-table.js +8 -1
- package/dist/server/send-back-build.js +4 -0
- package/dist/server/settings.js +153 -3
- package/dist/server/task-views.js +8 -3
- package/dist/server/tasks.js +51 -9
- package/dist/server/terminals.js +3 -1
- package/dist/settings-groups-ui.js +1 -1
- package/dist/skill-library-schema.js +70 -0
- package/dist/skill-library.js +693 -0
- package/dist/skill-local-sync.js +334 -0
- package/dist/skills-manifest.js +6 -3
- package/dist/skills-ui.js +122 -1
- package/dist/store.js +22 -4
- package/dist/subscription-usage.js +11 -5
- package/dist/surface.js +3 -2
- package/dist/task-base.js +23 -4
- package/dist/task-outcome-cli.js +10 -1
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/verification-evidence.js +3 -1
- package/package.json +2 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { canonicalJson } from "./canonical-json.js";
|
|
3
|
+
import { flexibleStanding } from "./flexible.js";
|
|
4
|
+
import { flexibleImportRef, importFlexibleCandidate, projectMergeHint, projectThreadBranch, readFlexibleCandidate } from "./flexible-import.js";
|
|
5
|
+
import { branchHeld, nextSeq, turnRunning } from "./flexible-ship.js";
|
|
6
|
+
import { flexibleThread, flexibleThreadBranch, withFlexibleThreadLock } from "./flexible-thread.js";
|
|
7
|
+
import { machineActing } from "./scope.js";
|
|
8
|
+
const WORDS = Object.freeze({
|
|
9
|
+
"machine-proof": "Only a person can save a thread's work. Nothing was saved.",
|
|
10
|
+
"thread-unknown": "There's no such thread.",
|
|
11
|
+
"not-owner": "Only the person who started this thread can save its work. Nothing was saved.",
|
|
12
|
+
"not-an-approver": "Only an approver for this project can save a thread's work. Nothing was saved.",
|
|
13
|
+
"stale-generation": "Your account changed since you signed in. Sign in again and retry. Nothing was saved.",
|
|
14
|
+
"thread-running": "The agent is still working on your last message. Wait for it, or stop its turn, then save. Nothing was saved.",
|
|
15
|
+
"thread-removed": "This thread's working copy was removed, so there's nothing left to save.",
|
|
16
|
+
"changed": "The thread changed while it was being saved. Try again. Nothing was saved.",
|
|
17
|
+
"branch-gone": "Toolroll saved this work before, but its branch was deleted from your repository since. Toolroll doesn't make it again by itself. Nothing was changed.",
|
|
18
|
+
"branch-moved": "This thread's branch in your repository was changed by someone else since Toolroll saved it. Toolroll won't overwrite it. Nothing was changed.",
|
|
19
|
+
});
|
|
20
|
+
const refuse = (reason) => ({ ok: false, reason, message: WORDS[reason] });
|
|
21
|
+
export const flexibleSaveDigestOf = (terms) => createHash("sha256").update(`standing-orders:flexible-save:${canonicalJson(terms)}`, "utf8").digest("hex").slice(0, 32);
|
|
22
|
+
const shellWord = (text) => /^[A-Za-z0-9_./~+@%=:,-]+$/.test(text) ? text : `'${text.replace(/'/g, "'\\''")}'`;
|
|
23
|
+
function saverStanding(store, thread, by) {
|
|
24
|
+
if (thread.createdBy !== by.name)
|
|
25
|
+
return refuse("not-owner");
|
|
26
|
+
const account = store.accountOf(by.name);
|
|
27
|
+
if (account === null || account.revokedAt !== null || account.role !== "approver" || !store.accountCanAccess(by.name, thread.repo))
|
|
28
|
+
return refuse("not-an-approver");
|
|
29
|
+
if (account.generation !== by.generation)
|
|
30
|
+
return refuse("stale-generation");
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
async function nextWords(store, thread, candidate, branch, runner) {
|
|
34
|
+
const hint = await projectMergeHint(store, { thread, candidate, ...(runner === undefined ? {} : { runner }) });
|
|
35
|
+
if (hint === null)
|
|
36
|
+
return `To use it: merge ${branch} in your repository.`;
|
|
37
|
+
const repo = shellWord(hint.repo);
|
|
38
|
+
if (hint.branch === null)
|
|
39
|
+
return `To use it: check out the branch you want it on, then run \`git -C ${repo} merge --ff-only ${branch}\`.`;
|
|
40
|
+
if (hint.fastForward)
|
|
41
|
+
return `To put it on ${hint.branch}: \`git -C ${repo} merge --ff-only ${branch}\`.`;
|
|
42
|
+
return `${hint.branch} moved since the thread started, so it won't fast-forward. To merge it: \`git -C ${repo} merge ${branch}\`.`;
|
|
43
|
+
}
|
|
44
|
+
export async function saveFlexibleBranch(store, input) {
|
|
45
|
+
if (machineActing())
|
|
46
|
+
return refuse("machine-proof");
|
|
47
|
+
const first = flexibleThread(store, input.thread);
|
|
48
|
+
if (first === null)
|
|
49
|
+
return refuse("thread-unknown");
|
|
50
|
+
const early = saverStanding(store, first, input.by);
|
|
51
|
+
if (early !== null)
|
|
52
|
+
return early;
|
|
53
|
+
if (first.state !== "ready")
|
|
54
|
+
return refuse("thread-removed");
|
|
55
|
+
const runner = input.runner === undefined ? {} : { runner: input.runner };
|
|
56
|
+
const locked = await withFlexibleThreadLock(input.thread, async () => {
|
|
57
|
+
if (turnRunning(store, input.thread))
|
|
58
|
+
return refuse("thread-running");
|
|
59
|
+
const read = await readFlexibleCandidate(store, { thread: input.thread, ...runner });
|
|
60
|
+
if (!read.ok)
|
|
61
|
+
return read;
|
|
62
|
+
const branch = flexibleThreadBranch(input.thread);
|
|
63
|
+
const held = branchHeld(store, input.thread);
|
|
64
|
+
if (held === read.candidate) {
|
|
65
|
+
const actual = await projectThreadBranch(store, { thread: input.thread, ...runner });
|
|
66
|
+
if (actual === null)
|
|
67
|
+
return refuse("branch-gone");
|
|
68
|
+
if (actual !== read.candidate)
|
|
69
|
+
return refuse("branch-moved");
|
|
70
|
+
return { ok: true, already: true, branch, candidate: read.candidate, seq: null, changedPaths: read.changedPaths, next: await nextWords(store, input.thread, read.candidate, branch, input.runner) };
|
|
71
|
+
}
|
|
72
|
+
const at = input.now.toISOString();
|
|
73
|
+
const recorded = store.transact(() => {
|
|
74
|
+
const thread = flexibleThread(store, input.thread);
|
|
75
|
+
if (thread === null)
|
|
76
|
+
return refuse("thread-unknown");
|
|
77
|
+
if (thread.state !== "ready")
|
|
78
|
+
return refuse("thread-removed");
|
|
79
|
+
const standing = saverStanding(store, thread, input.by);
|
|
80
|
+
if (standing !== null)
|
|
81
|
+
return standing;
|
|
82
|
+
if (!input.prove())
|
|
83
|
+
return refuse("stale-generation");
|
|
84
|
+
if (branchHeld(store, thread.id) !== held)
|
|
85
|
+
return refuse("changed");
|
|
86
|
+
const seq = nextSeq(store, thread.id);
|
|
87
|
+
const terms = { kind: "flexible-save", version: 1, thread: thread.id, repo: thread.repo, owner: input.by.name, ownerGeneration: input.by.generation, seq,
|
|
88
|
+
base: read.base, candidate: read.candidate, branch, importRef: flexibleImportRef(thread.id, seq), changedPaths: read.changedPaths };
|
|
89
|
+
const digest = flexibleSaveDigestOf(terms);
|
|
90
|
+
const live = flexibleStanding(store, thread.repo);
|
|
91
|
+
store.handle.prepare(`INSERT INTO flexible_ship (id, thread, seq, repo, base_sha, candidate, import_ref, branch, branch_before, terms_json, digest, summary_key, approved_by, approved_generation, proof, approved_at, delegation_id, state, state_at)
|
|
92
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'session', ?, ?, 'approved', ?)`).run(digest, thread.id, seq, thread.repo, terms.base, terms.candidate, terms.importRef, branch, held, canonicalJson(terms), digest, digest, input.by.name, input.by.generation, at, live.state === "on" ? live.id : 0, at);
|
|
93
|
+
store.recordAction({ at, actor: input.by.name, repo: thread.repo, taskId: null, runId: null, source: "work", action: "flexible branch saved", outcome: "flexible-save",
|
|
94
|
+
detail: `thread ${thread.id} · save ${seq} · candidate ${read.candidate} · ${branch}` });
|
|
95
|
+
return { seq, digest };
|
|
96
|
+
});
|
|
97
|
+
if ("ok" in recorded)
|
|
98
|
+
return recorded;
|
|
99
|
+
const imported = await importFlexibleCandidate(store, { thread: input.thread, seq: recorded.seq, expected: read.candidate, branchBefore: held, by: input.by.name, now: input.now, ...runner });
|
|
100
|
+
if (!imported.ok) {
|
|
101
|
+
store.transact(() => {
|
|
102
|
+
store.handle.prepare("UPDATE flexible_ship SET state = 'refused', reason = ?, detail = ?, state_at = ? WHERE id = ? AND state = 'approved'")
|
|
103
|
+
.run("check" in imported ? imported.check : imported.reason, imported.message.slice(0, 2000), at, recorded.digest);
|
|
104
|
+
});
|
|
105
|
+
return imported;
|
|
106
|
+
}
|
|
107
|
+
store.transact(() => { store.handle.prepare("UPDATE flexible_ship SET state = 'imported', state_at = ? WHERE id = ? AND state = 'approved'").run(at, recorded.digest); });
|
|
108
|
+
return { ok: true, already: false, branch, candidate: read.candidate, seq: recorded.seq, changedPaths: read.changedPaths, next: await nextWords(store, input.thread, read.candidate, branch, input.runner) };
|
|
109
|
+
});
|
|
110
|
+
if (locked.ok === false && (locked.reason === "not-available" || locked.reason === "thread-unknown"))
|
|
111
|
+
return refuse("thread-unknown");
|
|
112
|
+
return locked;
|
|
113
|
+
}
|
|
114
|
+
export function isFlexibleSave(termsJson) {
|
|
115
|
+
try {
|
|
116
|
+
return JSON.parse(String(termsJson)).kind === "flexible-save";
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export function latestFlexibleSave(store, thread) {
|
|
123
|
+
const rows = store.handle.prepare("SELECT seq, candidate, terms_json, state_at FROM flexible_ship WHERE thread = ? AND state = 'imported' AND task_id IS NULL ORDER BY seq DESC").all(thread);
|
|
124
|
+
const newest = rows[0];
|
|
125
|
+
if (newest === undefined || !isFlexibleSave(newest["terms_json"]))
|
|
126
|
+
return null;
|
|
127
|
+
return { seq: Number(newest["seq"]), candidate: String(newest["candidate"]), at: String(newest["state_at"]) };
|
|
128
|
+
}
|
package/dist/flexible-session.js
CHANGED
|
@@ -668,7 +668,8 @@ export async function beginFlexibleThreadTurn(store, sessions, input) {
|
|
|
668
668
|
if (!attached.ok)
|
|
669
669
|
return attached;
|
|
670
670
|
session.title ??= cardText(input.message.split("\n")[0], 80) || null;
|
|
671
|
-
const
|
|
671
|
+
const baseHanded = await conversationFor(store, { thread: turn.thread, turn: input.turn, seq: turn.seq, message: input.message });
|
|
672
|
+
const handed = started.skillsPrompt ? `${started.skillsPrompt}\n${baseHanded}` : baseHanded;
|
|
672
673
|
session.records.push({ k: "you", at: (input.clock ?? systemClock)().toISOString(), t: saidLines(input.message) });
|
|
673
674
|
try {
|
|
674
675
|
session.agent?.stdin.write(`${userFrame(handed, randomUUID())}\n`);
|
|
@@ -905,7 +906,7 @@ export async function flexibleThreadShipTerms(store, input) {
|
|
|
905
906
|
return refuse("thread-unknown");
|
|
906
907
|
const needs = flexibleShipNeeds(store, owned.repo);
|
|
907
908
|
if (needs !== null)
|
|
908
|
-
return { ok: false, reason: needs.reason, message: needs.message };
|
|
909
|
+
return { ok: false, reason: needs.reason, message: `${needs.message} ${saveInsteadWords(input.thread)}` };
|
|
909
910
|
const shown = await flexibleShipTerms(store, { thread: input.thread, by: input.by.name });
|
|
910
911
|
if (!shown.ok)
|
|
911
912
|
return shown;
|
|
@@ -1263,7 +1264,7 @@ export function flexibleShipNeedsFor(store, asked) {
|
|
|
1263
1264
|
if (found.length !== 1)
|
|
1264
1265
|
return null;
|
|
1265
1266
|
const needs = flexibleShipNeeds(store, String(found[0]["repo"]));
|
|
1266
|
-
return needs === null ? null : { reason: needs.reason, message: needs.message };
|
|
1267
|
+
return needs === null ? null : { reason: needs.reason, message: `${needs.message} ${saveInsteadWords(asked)}` };
|
|
1267
1268
|
}
|
|
1268
1269
|
async function stopSessionLocked(store, sessions, input) {
|
|
1269
1270
|
const clocked = input.clock === undefined ? {} : { clock: input.clock };
|
|
@@ -1361,3 +1362,10 @@ export async function flexibleThreadChanges(store, input) {
|
|
|
1361
1362
|
return { tip: read.base, changes: { ok: true, none: true } };
|
|
1362
1363
|
return { tip: read.tip, changes: { ok: true, patch: read.patch, truncated: read.truncated } };
|
|
1363
1364
|
}
|
|
1365
|
+
function saveInsteadWords(thread) {
|
|
1366
|
+
return `To use its work now, save it as a branch in your repository instead (S on the thread in \`toolroll\`, or \`toolroll thread save ${thread.slice(0, 8)}\`).`;
|
|
1367
|
+
}
|
|
1368
|
+
export function flexibleThreadEdited(sessions, input) {
|
|
1369
|
+
const session = sessions.threads.get(input.thread);
|
|
1370
|
+
return session !== undefined && session.records.some(one => one.k === "step" && one.kind === "edit");
|
|
1371
|
+
}
|
package/dist/flexible-ship.js
CHANGED
|
@@ -118,12 +118,12 @@ function shipProofNow(store, by, proof, repo) {
|
|
|
118
118
|
return refuse("laptop", problem);
|
|
119
119
|
return { method: "local-owner", localGeneration: local.localGeneration, accountGeneration: local.accountGeneration };
|
|
120
120
|
}
|
|
121
|
-
const turnRunning = (store, thread) => store.handle.prepare("SELECT 1 FROM thread_turn WHERE thread = ? AND status IN ('admitted', 'running')").get(thread) !== undefined;
|
|
122
|
-
function branchHeld(store, thread) {
|
|
121
|
+
export const turnRunning = (store, thread) => store.handle.prepare("SELECT 1 FROM thread_turn WHERE thread = ? AND status IN ('admitted', 'running')").get(thread) !== undefined;
|
|
122
|
+
export function branchHeld(store, thread) {
|
|
123
123
|
const row = store.handle.prepare("SELECT candidate FROM flexible_ship WHERE thread = ? AND state IN ('imported', 'armed', 'completed', 'merged', 'cancelled', 'sent-back') ORDER BY seq DESC LIMIT 1").get(thread);
|
|
124
124
|
return row === undefined ? null : String(row["candidate"]);
|
|
125
125
|
}
|
|
126
|
-
const nextSeq = (store, thread) => Number(store.handle.prepare("SELECT COALESCE(MAX(seq), 0) + 1 AS n FROM flexible_ship WHERE thread = ?").get(thread)["n"]);
|
|
126
|
+
export const nextSeq = (store, thread) => Number(store.handle.prepare("SELECT COALESCE(MAX(seq), 0) + 1 AS n FROM flexible_ship WHERE thread = ?").get(thread)["n"]);
|
|
127
127
|
function destinationOf(store, repo) {
|
|
128
128
|
const grant = store.publicationGrantFor(repo);
|
|
129
129
|
if (grant === null || !grant.capabilities.includes("push-branch") || !grant.capabilities.includes("open-pr"))
|
package/dist/flexible-thread.js
CHANGED
|
@@ -116,11 +116,15 @@ async function usableRepository(repo, read) {
|
|
|
116
116
|
throw new Error("it borrows objects from another repository");
|
|
117
117
|
const listing = await read(repo, ["config", "--list", "--show-scope", "-z"]);
|
|
118
118
|
if (listing.code !== 0)
|
|
119
|
-
throw new Error(
|
|
119
|
+
throw new Error(`its git config couldn't be read${gitSaid(listing.stderr)}`);
|
|
120
120
|
if (lazyFetchSetting(listing.stdout) !== null)
|
|
121
121
|
throw new Error("it is a partial clone");
|
|
122
122
|
return { common, objects: realpathSync(objects) };
|
|
123
123
|
}
|
|
124
|
+
function gitSaid(stderr) {
|
|
125
|
+
const line = stderr.split("\n").map(one => one.replace(/[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g, "").trim()).find(one => one !== "");
|
|
126
|
+
return line === undefined ? "" : `: ${line.length <= 240 ? line : `${line.slice(0, 239)}…`}`;
|
|
127
|
+
}
|
|
124
128
|
const ownObjects = (path) => { try {
|
|
125
129
|
const held = lstatSync(path);
|
|
126
130
|
return held.isDirectory() && !held.isSymbolicLink();
|
|
@@ -309,7 +313,7 @@ async function removeLocked(store, input) {
|
|
|
309
313
|
keepRef = "removed";
|
|
310
314
|
else
|
|
311
315
|
keepRef = (await read(project, ["rev-parse", "--verify", "--quiet", "--end-of-options", thread.keepRef])).code === 0 ? "moved" : "already-gone";
|
|
312
|
-
const ships = store.handle.prepare("SELECT import_ref, candidate, state FROM flexible_ship WHERE thread = ? ORDER BY seq").all(thread.id);
|
|
316
|
+
const ships = store.handle.prepare("SELECT import_ref, candidate, state, json_extract(terms_json, '$.kind') AS kind FROM flexible_ship WHERE thread = ? ORDER BY seq").all(thread.id);
|
|
313
317
|
for (const ship of ships.filter(one => ["imported", "merged", "cancelled", "sent-back"].includes(String(one["state"])))) {
|
|
314
318
|
const gone = await build(project, ["update-ref", "--no-deref", "-d", String(ship["import_ref"]), String(ship["candidate"])]);
|
|
315
319
|
if (gone.code === 0)
|
|
@@ -318,7 +322,7 @@ async function removeLocked(store, input) {
|
|
|
318
322
|
shipRefsLeft++;
|
|
319
323
|
}
|
|
320
324
|
const standing = [...ships].reverse().find(one => ["imported", "merged", "cancelled", "sent-back"].includes(String(one["state"])));
|
|
321
|
-
if (standing !== undefined) {
|
|
325
|
+
if (standing !== undefined && standing["kind"] !== "flexible-save") {
|
|
322
326
|
const branch = `refs/heads/${flexibleThreadBranch(thread.id)}`;
|
|
323
327
|
const gone = await build(project, ["update-ref", "--no-deref", "-d", branch, String(standing["candidate"])]);
|
|
324
328
|
if (gone.code === 0)
|
package/dist/install-method.js
CHANGED
|
@@ -25,11 +25,9 @@ function installKind(bin, probe) {
|
|
|
25
25
|
catch {
|
|
26
26
|
}
|
|
27
27
|
const path = real.replace(/\\/g, "/");
|
|
28
|
-
if (path.includes("/staged-upgrades/browser-"))
|
|
29
|
-
return "source";
|
|
30
28
|
if (/\.app\/Contents\/Resources\//.test(path))
|
|
31
29
|
return "desktop";
|
|
32
|
-
if (/\/staged-upgrades\/(release|rollback)-/.test(path))
|
|
30
|
+
if (/\/staged-upgrades\/(release|rollback|browser)-/.test(path))
|
|
33
31
|
return "managed";
|
|
34
32
|
if (/\/Cellar\/toolroll\//i.test(path))
|
|
35
33
|
return "homebrew";
|
package/dist/invoke.js
CHANGED
|
@@ -279,7 +279,7 @@ export async function invokeAgent(store, runId, spec, invocation, options) {
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
const ownTools = tools?.privateDir === undefined ? null : realpathSync(tools.privateDir);
|
|
282
|
-
const fenceOf = invocation.phase === "review" ? { fence: [], fileTools: [], grants: NO_GRANTS, gitPaths: [], cache: undefined, problem: undefined } : await runFence(store, runId, spec.provider, options.keyHome, codexProfile ? null : ownTools, launchWrites ?? WRITES_DEFAULT, launchSandbox ?? LEGACY_SANDBOX, options.skills ?? null);
|
|
282
|
+
const fenceOf = invocation.phase === "review" ? { fence: [], fileTools: [], grants: NO_GRANTS, gitPaths: [], cache: undefined, problem: undefined } : await runFence(store, runId, spec.provider, options.keyHome, codexProfile ? null : ownTools, launchWrites ?? WRITES_DEFAULT, launchSandbox ?? LEGACY_SANDBOX, options.skills ?? null, options.evidenceRoot ?? null);
|
|
283
283
|
if ("skillsProblem" in fenceOf && fenceOf.skillsProblem !== undefined) {
|
|
284
284
|
try {
|
|
285
285
|
store.addRunNote(runId, "Toolroll", `Project skills weren't shared with the agent: ${fenceOf.skillsProblem}.`, clock());
|
|
@@ -738,7 +738,7 @@ function linkedFor(store, worktree) {
|
|
|
738
738
|
const row = worktree === null ? null : store.getWorktree(worktree);
|
|
739
739
|
return row === null ? null : { repo: row.repo, setupDigest: row.setupDigest ?? null };
|
|
740
740
|
}
|
|
741
|
-
async function runFence(store, runId, provider, keyHome, ownTools, writes = WRITES_DEFAULT, sandbox = LEGACY_SANDBOX, skills = null) {
|
|
741
|
+
async function runFence(store, runId, provider, keyHome, ownTools, writes = WRITES_DEFAULT, sandbox = LEGACY_SANDBOX, skills = null, customEvidenceRoot = null) {
|
|
742
742
|
let skillsProblem = {};
|
|
743
743
|
try {
|
|
744
744
|
const databaseFile = store.databaseFile();
|
|
@@ -757,11 +757,13 @@ async function runFence(store, runId, provider, keyHome, ownTools, writes = WRIT
|
|
|
757
757
|
const granted = skillsGrant(provider === "command" ? null : skills);
|
|
758
758
|
if (granted.problem !== null)
|
|
759
759
|
skillsProblem = { skillsProblem: granted.problem };
|
|
760
|
+
const evidenceDeny = customEvidenceRoot ?? skills?.root ?? null;
|
|
760
761
|
const allowed = worktree === null || row === null || writes !== "workspace" ? null
|
|
761
762
|
: writeAllowlist({ provider, home: keyHome ?? homedir(), worktree, binding, launchFolder: ownTools, cache: buildCacheFolder(row.repo, keyHome ?? homedir()) });
|
|
762
763
|
const launch = fenceFor(provider === "command" ? "command" : "build", { databaseFile, worktree, ...home, boundary, binding, runFolders: folders, poolRoots, storage,
|
|
764
|
+
evidenceRoot: evidenceDeny,
|
|
763
765
|
extra: [...allowed?.deny ?? [], ...granted.deny], linked: linkedFor(store, worktree), writes: allowed === null ? null : { writes: allowed.writes, readOnly: allowed.readOnly }, policy: sandbox.policy, provider,
|
|
764
|
-
...(provider === "command" ? {} : { exactFile: deliveredFile(store, runId), exactFiles: granted.files }),
|
|
766
|
+
...(provider === "command" ? {} : { exactFile: deliveredFile(store, runId), exactFiles: granted.files, exactDigests: granted.digests, exactFolders: granted.folders }),
|
|
765
767
|
readDeny: [...new Set([...sandbox.readDeny, ...(row === null ? [] : store.projectSandbox(row.repo).readDeny)])].map(one => readDenyPath(one, keyHome ?? homedir())), machLookup: sandbox.machLookup });
|
|
766
768
|
return {
|
|
767
769
|
fence: launch.fence,
|
|
@@ -779,7 +781,7 @@ async function runFence(store, runId, provider, keyHome, ownTools, writes = WRIT
|
|
|
779
781
|
return { fence: [], fileTools: [], grants: NO_GRANTS, problem: error instanceof CheckoutBindingError || error instanceof ExactFileChanged ? error.message : "The build fence could not be prepared." };
|
|
780
782
|
}
|
|
781
783
|
}
|
|
782
|
-
export function fencedCommands(store, runId, writes, inner, available = () => macosFenceAvailable() || linuxFenceAvailable(), access = CHECK_ACCESS_DEFAULT, network, sandbox = LEGACY_SANDBOX) {
|
|
784
|
+
export function fencedCommands(store, runId, writes, inner, available = () => macosFenceAvailable() || linuxFenceAvailable(), access = CHECK_ACCESS_DEFAULT, network, sandbox = LEGACY_SANDBOX, customEvidenceRoot = null) {
|
|
783
785
|
if (inner !== runCommand)
|
|
784
786
|
return inner;
|
|
785
787
|
return async (file, args, options) => {
|
|
@@ -799,7 +801,7 @@ export function fencedCommands(store, runId, writes, inner, available = () => ma
|
|
|
799
801
|
stampLaunch(store, [runId], unfencedStamp());
|
|
800
802
|
return await inner(file, args, { ...options, env: { ...(options?.env ?? {}), TMPDIR: temp, TMP: temp, TEMP: temp } });
|
|
801
803
|
}
|
|
802
|
-
const fenced = await runFence(store, runId, "command", undefined, own, writes, sandbox);
|
|
804
|
+
const fenced = await runFence(store, runId, "command", undefined, own, writes, sandbox, null, customEvidenceRoot);
|
|
803
805
|
if (fenced.problem !== undefined)
|
|
804
806
|
return { code: 1, stdout: "", stderr: `${fenced.problem}\n`, timedOut: false, notFound: false };
|
|
805
807
|
if (fenced.fence.length === 0) {
|
|
@@ -836,7 +838,7 @@ export function fencedCommands(store, runId, writes, inner, available = () => ma
|
|
|
836
838
|
}
|
|
837
839
|
};
|
|
838
840
|
}
|
|
839
|
-
export function fencedCheckoutCommands(store, repo, checkout, inner, available = () => macosFenceAvailable() || linuxFenceAvailable(), access = CHECK_ACCESS_DEFAULT, network, sandbox = LEGACY_SANDBOX, stampRuns = []) {
|
|
841
|
+
export function fencedCheckoutCommands(store, repo, checkout, inner, available = () => macosFenceAvailable() || linuxFenceAvailable(), access = CHECK_ACCESS_DEFAULT, network, sandbox = LEGACY_SANDBOX, stampRuns = [], customEvidenceRoot = null) {
|
|
840
842
|
if (inner !== runCommand)
|
|
841
843
|
return inner;
|
|
842
844
|
return async (file, args, options) => {
|
|
@@ -881,7 +883,7 @@ export function fencedCheckoutCommands(store, repo, checkout, inner, available =
|
|
|
881
883
|
const allowed = store.projectWrites(repo) !== "workspace" ? null : writeAllowlist({ provider: "command", home: homedir(), worktree: checkout, binding, launchFolder: own, cache });
|
|
882
884
|
const database = options?.env?.["TOOLROLL_DB"];
|
|
883
885
|
const checkData = allowed === null || database === undefined ? null : grantFolder(dirname(database), false);
|
|
884
|
-
const launch = fenceFor("check", { databaseFile, worktree: checkout, boundary, binding, runFolders: folders, poolRoots, storage, extra: allowed?.deny ?? [], linked: linkedFor(store, checkout),
|
|
886
|
+
const launch = fenceFor("check", { databaseFile, worktree: checkout, boundary, binding, runFolders: folders, poolRoots, storage, evidenceRoot: customEvidenceRoot, extra: allowed?.deny ?? [], linked: linkedFor(store, checkout),
|
|
885
887
|
readDeny: sandbox.readDeny.map(one => readDenyPath(one, homedir())), machLookup: sandbox.machLookup, policy: sandbox.policy,
|
|
886
888
|
writes: allowed === null ? null : { writes: { ...allowed.writes, subpaths: [...allowed.writes.subpaths, ...(checkData === null ? [] : [checkData])] }, readOnly: allowed.readOnly } });
|
|
887
889
|
const grants = launch.fenceGrants;
|
|
@@ -1019,11 +1021,11 @@ export function checkoutLaunchOf(store, repo, runIds, platform = process.platfor
|
|
|
1019
1021
|
export const widestRan = (levels) => levels.includes("unsandboxed") ? "unsandboxed" : levels.includes("sign-ins") ? "sign-ins" : CHECK_ACCESS_DEFAULT;
|
|
1020
1022
|
export const ranAtLine = (level) => level === "sandboxed" ? null
|
|
1021
1023
|
: `=== Check access ===\n${level === "unsandboxed" ? "These commands ran without a sandbox." : "These commands ran sandboxed, with model and GitHub sign-ins."}`;
|
|
1022
|
-
export function checkoutRunner(store, repo, checkout, inner, runIds, ran, platform = process.platform) {
|
|
1024
|
+
export function checkoutRunner(store, repo, checkout, inner, runIds, ran, platform = process.platform, customEvidenceRoot = null) {
|
|
1023
1025
|
return (file, args, options) => {
|
|
1024
1026
|
const launch = checkoutLaunchOf(store, repo, runIds, platform);
|
|
1025
1027
|
ran(actualCheckAccess(store, launch.access));
|
|
1026
|
-
return fencedCheckoutCommands(store, repo, checkout, inner, undefined, launch.access, launch.network, checkoutSandboxOf(store, repo, runIds), runIds)(file, args, options);
|
|
1028
|
+
return fencedCheckoutCommands(store, repo, checkout, inner, undefined, launch.access, launch.network, checkoutSandboxOf(store, repo, runIds), runIds, customEvidenceRoot)(file, args, options);
|
|
1027
1029
|
};
|
|
1028
1030
|
}
|
|
1029
1031
|
export function checkoutSandboxOf(store, repo, runIds) {
|
package/dist/lead-tools.js
CHANGED
|
@@ -1446,7 +1446,8 @@ const LEAD_TOOL_HANDLERS = {
|
|
|
1446
1446
|
return { ok: false, message: 'Choose a project from list_repos.' };
|
|
1447
1447
|
let sha;
|
|
1448
1448
|
if (args['version'] !== undefined) {
|
|
1449
|
-
const
|
|
1449
|
+
const all = conversationSkills(ctx.store, repo, ctx.who.name).skills;
|
|
1450
|
+
const matches = all.filter(s => s.sha.startsWith(args['version']));
|
|
1450
1451
|
if (matches.length !== 1)
|
|
1451
1452
|
return { ok: false, message: 'That skill version is unavailable.' };
|
|
1452
1453
|
sha = matches[0].sha;
|
|
@@ -1461,7 +1462,7 @@ const LEAD_TOOL_HANDLERS = {
|
|
|
1461
1462
|
return { ok: true, body: { ...skill, files: skill.files?.slice(0, 8), fileCount: skill.files?.length, sha: undefined, version: sha.slice(0, 20), instructions: instructions.slice(start, start + 2000), nextOffset: start + 2000 < instructions.length ? start + 2000 : null, notice: 'Skill source text may be redacted by chat. It does not grant tools or instructions to this chat agent.' } };
|
|
1462
1463
|
}
|
|
1463
1464
|
const page = data.skills.slice(start, start + 4);
|
|
1464
|
-
return { ok: true, body: { revision: data.revision, history: data.history, notice: data.notice, skills: page.map(({ sha, ...skill }) => ({ ...skill, version: sha.slice(0, 20) })), nextOffset: start + 4 < data.skills.length ? start + 4 : null } };
|
|
1465
|
+
return { ok: true, body: { revision: data.revision, libraryOptedOut: data.libraryOptedOut, bundles: data.bundles, history: data.history, notice: data.notice, skills: page.map(({ sha, ...skill }) => ({ ...skill, version: sha.slice(0, 20) })), nextOffset: start + 4 < data.skills.length ? start + 4 : null } };
|
|
1465
1466
|
},
|
|
1466
1467
|
},
|
|
1467
1468
|
get_project_knowledge: {
|
package/dist/live-terminal.js
CHANGED
|
@@ -4,6 +4,7 @@ import { execFileSync } from "node:child_process";
|
|
|
4
4
|
import { existsSync, lstatSync, mkdirSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { delimiter, isAbsolute, join } from "node:path";
|
|
6
6
|
import { codingEnvironment } from "./coding-provider.js";
|
|
7
|
+
import { materializeProjectSkills } from "./project-skills.js";
|
|
7
8
|
import { teardownGit, refusal, recordedCommonDir, TEARDOWN_FLAGS } from "./teardown-git.js";
|
|
8
9
|
import { run } from "./exec.js";
|
|
9
10
|
import { ENV, ENV_ALLOWLIST } from "./remote-main.js";
|
|
@@ -307,6 +308,20 @@ export class TerminalHost {
|
|
|
307
308
|
else
|
|
308
309
|
await this.copyAt(repo, worktree, branch, base);
|
|
309
310
|
const cols = clamp(size.cols, COLS), rows = clamp(size.rows, ROWS);
|
|
311
|
+
let skillsDir = null;
|
|
312
|
+
const launchEnv = { ...env };
|
|
313
|
+
try {
|
|
314
|
+
const snapshot = this.options.skillsForRepo?.(repo);
|
|
315
|
+
if (snapshot && snapshot.packages.length > 0) {
|
|
316
|
+
const materialized = materializeProjectSkills(snapshot, join(this.options.worktreeRoot, ".skills"), id.slice(0, 16));
|
|
317
|
+
if (materialized.directory !== null) {
|
|
318
|
+
skillsDir = materialized.directory;
|
|
319
|
+
launchEnv["TOOLROLL_SKILLS_DIR"] = skillsDir;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
catch {
|
|
324
|
+
}
|
|
310
325
|
let pty;
|
|
311
326
|
try {
|
|
312
327
|
if (this.stopped)
|
|
@@ -314,9 +329,11 @@ export class TerminalHost {
|
|
|
314
329
|
const refused = admit();
|
|
315
330
|
if (refused !== null)
|
|
316
331
|
throw new TerminalError(refused);
|
|
317
|
-
pty = this.options.spawn(command.file, command.args, { cwd: worktree, env, cols, rows });
|
|
332
|
+
pty = this.options.spawn(command.file, command.args, { cwd: worktree, env: launchEnv, cols, rows });
|
|
318
333
|
}
|
|
319
334
|
catch (error) {
|
|
335
|
+
if (skillsDir !== null)
|
|
336
|
+
rmSync(skillsDir, { recursive: true, force: true });
|
|
320
337
|
if (from !== null)
|
|
321
338
|
rmSync(worktree, { recursive: true, force: true });
|
|
322
339
|
else {
|
|
@@ -328,7 +345,7 @@ export class TerminalHost {
|
|
|
328
345
|
let resolveExited;
|
|
329
346
|
const session = { id, owner, generation, localGeneration, task: from?.task ?? null, run: from?.run ?? null, agent: null, base: from === null ? null : base, repo, program, branch, worktree, startedAt: this.clock().toISOString(), endedAt: null, exit: null, endedBy: null, cleanup: null,
|
|
330
347
|
pty, leader: pty.pid, tty: pty.tty, known: new Map(), exitedAt: null, worktreeReal: realpathSync(worktree), startedMs: Date.now(), residentsOnly: false, residentsSeen: new Map(), cols, rows, screen: new ScreenMirror(cols, rows, this.options.scrollbackLines), paused: false, flowTimer: null, attaching: 0, viewers: new Set(), controller: null, leaseEpoch: 0, viewerActors: new Map(), viewerGates: new Map(), closing: null,
|
|
331
|
-
exited: new Promise(resolve => { resolveExited = resolve; }), sensitive: false, attachedOnce: false, early: [], earlyBytes: 0, dropped: false, attachTimer: null };
|
|
348
|
+
exited: new Promise(resolve => { resolveExited = resolve; }), sensitive: false, attachedOnce: false, early: [], earlyBytes: 0, dropped: false, attachTimer: null, skillsDir };
|
|
332
349
|
this.sessions.set(id, session);
|
|
333
350
|
this.ledger.running(id);
|
|
334
351
|
reserved = false;
|
|
@@ -421,7 +438,7 @@ export class TerminalHost {
|
|
|
421
438
|
let resolveExited;
|
|
422
439
|
const session = { id, owner, generation, localGeneration, task: null, run: null, agent: { ...agent }, base: null, repo: "", program: "shell", branch: "", worktree: folder, startedAt: this.clock().toISOString(), endedAt: null, exit: null, endedBy: null, cleanup: null,
|
|
423
440
|
pty, leader: pty.pid, tty: pty.tty, known: new Map(), exitedAt: null, worktreeReal: realpathSync(folder), startedMs: Date.now(), residentsOnly: false, residentsSeen: new Map(), cols, rows, screen: new ScreenMirror(cols, rows, 0), paused: false, flowTimer: null, attaching: 0, viewers: new Set(), controller: null, leaseEpoch: 0, viewerActors: new Map(), viewerGates: new Map(), closing: null,
|
|
424
|
-
exited: new Promise(resolve => { resolveExited = resolve; }), sensitive: true, attachedOnce: false, early: [], earlyBytes: 0, dropped: false, attachTimer: null };
|
|
441
|
+
exited: new Promise(resolve => { resolveExited = resolve; }), sensitive: true, attachedOnce: false, early: [], earlyBytes: 0, dropped: false, attachTimer: null, skillsDir: null };
|
|
425
442
|
this.wire(session, () => { resolveExited(); try {
|
|
426
443
|
exited();
|
|
427
444
|
}
|
|
@@ -1000,6 +1017,10 @@ export class TerminalHost {
|
|
|
1000
1017
|
}
|
|
1001
1018
|
session.viewers.clear();
|
|
1002
1019
|
session.screen.dispose();
|
|
1020
|
+
if (session.skillsDir !== null) {
|
|
1021
|
+
rmSync(session.skillsDir, { recursive: true, force: true });
|
|
1022
|
+
session.skillsDir = null;
|
|
1023
|
+
}
|
|
1003
1024
|
if (session.base !== null || session.agent !== null) {
|
|
1004
1025
|
rmSync(session.worktree, { recursive: true, force: true });
|
|
1005
1026
|
this.options.record?.("remove", this.summary(session));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { soloNow } from "./install-mode.js";
|
|
2
|
+
import { localModeOn } from "./local-owner.js";
|
|
3
|
+
import { localWorkEligible } from "./scope.js";
|
|
4
|
+
export const LOCAL_CHECKS_CEILING = "sign-ins";
|
|
5
|
+
const WORDS = {
|
|
6
|
+
team: "Running checks without a password works only on a solo install. Sign in with your password to run them.",
|
|
7
|
+
"local-mode-off": "Local mode is off, so running checks needs your password.",
|
|
8
|
+
"not-owner": "Only this computer's owner runs checks here without a password.",
|
|
9
|
+
"no-scope": "This task has no approved plan, so running its checks needs your password.",
|
|
10
|
+
release: "Running a release's checks needs your password.",
|
|
11
|
+
protected: "This is protected work, so running its checks needs your password.",
|
|
12
|
+
escalated: "Work with wider permissions needs your password to run its checks.",
|
|
13
|
+
coordinator: "Work a coordinator filed needs your password to run its checks.",
|
|
14
|
+
unsandboxed: "This project's checks run without a sandbox, so running them needs your password.",
|
|
15
|
+
imported: "A task from outside needs your password to run its checks.",
|
|
16
|
+
};
|
|
17
|
+
export function localChecksRefusal(store, by, taskId) {
|
|
18
|
+
if (!soloNow(store))
|
|
19
|
+
return WORDS.team;
|
|
20
|
+
const eligible = localWorkEligible(store, by, taskId, { act: "retry" });
|
|
21
|
+
return eligible.ok ? null : WORDS[eligible.reason];
|
|
22
|
+
}
|
|
23
|
+
export function localChecksStanding(store, input) {
|
|
24
|
+
if (!soloNow(store) || !localModeOn(store))
|
|
25
|
+
return { ok: false, problem: "Asked for without a password, and the install is no longer solo with local mode on, so they didn't run." };
|
|
26
|
+
const refused = localChecksRefusal(store, input.by, input.taskId);
|
|
27
|
+
if (refused !== null)
|
|
28
|
+
return { ok: false, problem: `Asked for without a password, and now: ${refused}` };
|
|
29
|
+
return { ok: true, access: LOCAL_CHECKS_CEILING };
|
|
30
|
+
}
|
|
31
|
+
export class LocalChecksLapsed extends Error {
|
|
32
|
+
}
|