toolroll 0.9.108 → 0.9.110
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 +69 -0
- package/dist/advanced-view.js +0 -1
- package/dist/agent-detect.js +244 -0
- package/dist/agent-fence.js +47 -5
- package/dist/agent-state.js +5 -2
- package/dist/agentconfig.js +2 -2
- package/dist/approval-summary.js +344 -0
- package/dist/assignment-ui.js +5 -5
- package/dist/assignment.js +5 -2
- package/dist/attest.js +2 -2
- package/dist/browser/terminal.js +1 -1
- package/dist/browser/workspace.css +2 -2
- package/dist/browser/workspace.js +37 -34
- package/dist/browser-crew.js +4 -4
- package/dist/browser-workspace.js +4 -11
- package/dist/builder.js +45 -3
- package/dist/chat-actions.js +24 -17
- package/dist/chat-controls.js +6 -5
- package/dist/chat-core.js +3 -1
- package/dist/chat-decide.js +102 -47
- package/dist/chat-delivery-state.js +2 -0
- package/dist/chat-delivery.js +3 -2
- package/dist/chat-live.js +2 -1
- package/dist/chat-quiet.js +3 -3
- package/dist/chat-task-actions.js +6 -0
- package/dist/chat-voice.js +2 -2
- package/dist/check-report.js +1 -1
- package/dist/cli-help.js +12 -13
- package/dist/cli.js +6 -3
- package/dist/console-chrome.js +10 -3
- package/dist/console-instance.js +10 -1
- package/dist/contracts/console-api.js +14 -8
- package/dist/contracts/engine-api.js +271 -0
- package/dist/contracts/handoff.js +4 -0
- package/dist/coordinator.js +2 -2
- 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/discord-api.js +4 -3
- package/dist/discord-chat.js +3 -1
- package/dist/dispatch.js +3 -8
- package/dist/easy-start-args.js +7 -3
- package/dist/easy-start.js +25 -0
- package/dist/egress.js +72 -10
- package/dist/engine-handoff.js +34 -0
- package/dist/engine-reads.js +261 -0
- package/dist/eval-world.js +3 -2
- package/dist/evidence.js +2 -0
- package/dist/fast-start.js +55 -14
- package/dist/fast-terms.js +2 -2
- package/dist/first-run.js +10 -2
- package/dist/flexible-agents.js +234 -0
- package/dist/flexible-answers-schema.js +61 -0
- package/dist/flexible-answers.js +889 -0
- package/dist/flexible-available.js +1 -0
- package/dist/flexible-custody.js +494 -0
- package/dist/flexible-import.js +782 -0
- package/dist/flexible-launch-schema.js +72 -0
- package/dist/flexible-launch.js +331 -0
- package/dist/flexible-launcher.js +88 -0
- package/dist/flexible-levels.js +34 -0
- package/dist/flexible-merge-guard.js +47 -0
- package/dist/flexible-refs.js +47 -0
- package/dist/flexible-relay-cancel.js +19 -0
- package/dist/flexible-relay-schema.js +55 -0
- package/dist/flexible-relay-upstreams.js +36 -0
- package/dist/flexible-relay.js +1032 -0
- package/dist/flexible-schema.js +32 -0
- package/dist/flexible-session.js +732 -0
- package/dist/flexible-ship-schema.js +81 -0
- package/dist/flexible-ship.js +694 -0
- package/dist/flexible-start.js +80 -0
- package/dist/flexible-thread-schema.js +30 -0
- package/dist/flexible-thread.js +676 -0
- package/dist/flexible-turns-schema.js +69 -0
- package/dist/flexible-turns.js +490 -0
- package/dist/flexible-ui.js +44 -0
- package/dist/flexible.js +368 -0
- package/dist/flow-actions.js +6 -4
- package/dist/flow-steps.js +1 -1
- package/dist/flows-cli.js +2 -1
- package/dist/git-views.js +44 -41
- package/dist/guides.js +11 -10
- package/dist/install-mode.js +225 -0
- package/dist/keymap.js +1 -1
- package/dist/lead-context.js +1 -1
- package/dist/lead-doors.js +7 -1
- package/dist/limits-ui.js +8 -1
- package/dist/live-bus.js +70 -13
- package/dist/live-reply.js +6 -0
- package/dist/live-terminal.js +425 -29
- package/dist/local-owner.js +6 -0
- package/dist/model-choices.js +12 -6
- package/dist/needs-you.js +3 -3
- package/dist/nightly-github.js +2 -2
- package/dist/notification-delivery.js +11 -0
- package/dist/operate.js +185 -33
- package/dist/outbound-privacy.js +204 -0
- package/dist/passwordless.js +2 -1
- package/dist/project-delete-ui.js +2 -1
- package/dist/project-delete.js +15 -0
- package/dist/provider-auth.js +1 -1
- package/dist/provider-connection.js +5 -3
- package/dist/publish.js +5 -0
- package/dist/pull-request-flow.js +26 -7
- package/dist/push.js +5 -1
- package/dist/release-card.js +11 -3
- package/dist/release.js +11 -1
- 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-store.js +2 -2
- package/dist/sandbox-launch.js +32 -8
- package/dist/sandbox-runtime.js +16 -7
- package/dist/sandbox-tools.js +176 -0
- package/dist/scope.js +12 -36
- package/dist/scout-net.js +7 -2
- package/dist/serve.js +90 -40
- package/dist/server/chat.js +9 -9
- package/dist/server/chrome.js +19 -17
- package/dist/server/console.css +33 -6
- package/dist/server/engine-api.js +378 -0
- package/dist/server/flows.js +2 -2
- package/dist/server/guards.js +10 -4
- package/dist/server/home.js +37 -5
- package/dist/server/http.js +11 -2
- package/dist/server/in-place.js +5 -4
- package/dist/server/kit.js +2 -2
- package/dist/server/link-redemption.js +52 -0
- package/dist/server/live.js +100 -10
- package/dist/server/mutation-key.js +21 -7
- package/dist/server/pages.js +129 -74
- package/dist/server/people-tokens.js +17 -41
- package/dist/server/render-chat.js +2 -1
- package/dist/server/render-history.js +18 -4
- package/dist/server/render-new-task.js +4 -4
- package/dist/server/render-pages.js +21 -39
- package/dist/server/render-people.js +2 -2
- package/dist/server/render-projects.js +5 -5
- package/dist/server/render-results.js +30 -14
- package/dist/server/render-tasks.js +155 -155
- package/dist/server/retired-routes.js +37 -4
- package/dist/server/route-policy.js +8 -0
- package/dist/server/route-table.js +43 -5
- package/dist/server/settings-computers.js +140 -0
- package/dist/server/settings-scripts.js +15 -0
- package/dist/server/settings-section-table.js +59 -0
- package/dist/server/settings-sections.js +291 -0
- package/dist/server/settings.js +247 -28
- package/dist/server/task-views.js +55 -15
- package/dist/server/tasks.js +168 -98
- package/dist/server/terminals.js +181 -28
- package/dist/server/welcome.js +40 -14
- package/dist/settings-groups-ui.js +26 -107
- package/dist/settings-proofs.js +18 -11
- package/dist/slack-api.js +4 -3
- package/dist/slack-chat.js +5 -3
- package/dist/spend.js +46 -12
- package/dist/sqlite-telemetry.js +70 -21
- package/dist/status-probe.js +343 -0
- package/dist/store.js +206 -10
- package/dist/task-link.js +64 -0
- package/dist/teams-api.js +4 -3
- package/dist/teams-chat.js +4 -2
- package/dist/telegram-lead.js +2 -1
- package/dist/telegram-live.js +2 -1
- package/dist/telegram-team.js +2 -1
- package/dist/telegram.js +17 -5
- package/dist/trusted-path.js +162 -0
- 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/tui-launch.js +282 -0
- package/dist/tui-source.js +5 -3
- package/dist/tui.js +2 -2
- package/dist/typed-words-schema.js +18 -0
- package/dist/webhooks.js +8 -4
- package/dist/welcome-facts.js +25 -17
- package/dist/work-index.js +126 -29
- package/dist/work-reads.js +279 -0
- package/dist/workspace-ui.js +5 -0
- package/package.json +4 -2
- package/scripts/crash-canary.mjs +1 -1
- package/scripts/pilot.mjs +1 -1
- package/scripts/provider-canary.mjs +5 -3
package/dist/route-store.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isProtectedWork } from "./approval-policy.js";
|
|
2
2
|
import { trialSealStandsSql } from "./approval-authority.js";
|
|
3
3
|
import { currentLocalOwner, localOwnerInFlight, localOwnerStandsNow } from "./local-owner.js";
|
|
4
|
-
import {
|
|
4
|
+
import { sessionStandsIn } from "./install-mode.js";
|
|
5
5
|
import { machineActing } from "./scope.js";
|
|
6
6
|
import { NOT_COUNTED_REASONS, RECORD_STATES, REJECT_REASONS, REVISION_ORIGINS } from "./contracts/route-results.js";
|
|
7
7
|
import { BUILT_IN, nightlyTaskRef, releaseTaskRef } from "./store.js";
|
|
@@ -209,7 +209,7 @@ export function proveRuleDoor(store, door, act, repo) {
|
|
|
209
209
|
return { ok: false, reason: "lead-refused" };
|
|
210
210
|
const account = store.accountOf(person.actor);
|
|
211
211
|
const proof = spec.raising
|
|
212
|
-
? RAISING_PROOFS.has(person.method) && ((person.method !== "session" && person.method !== "cli-login") ||
|
|
212
|
+
? RAISING_PROOFS.has(person.method) && ((person.method !== "session" && person.method !== "cli-login") || sessionStandsIn(store))
|
|
213
213
|
: RAISING_PROOFS.has(person.method) || person.method === "local-owner";
|
|
214
214
|
if (account === null || account.revokedAt !== null || account.generation !== person.generation || !store.isInstanceOperator(person.actor)
|
|
215
215
|
|| !store.accountCanAccess(person.actor, repo) || !person.live() || !proof)
|
package/dist/sandbox-launch.js
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { checkLinuxDependencies, cleanupBwrapMountPoints, getLinuxDependencyStatus, initializeLinuxNetworkBridge, wrapCommandWithSandboxLinux } from "@anthropic-ai/sandbox-runtime/dist/sandbox/linux-sandbox-utils.js";
|
|
3
3
|
import { SANDBOX_LAUNCH_SPEC, shellQuote, withRuntimeTemp } from "./sandbox-runtime.js";
|
|
4
|
+
import { isLinuxSandboxTools, sandboxToolExclusions, verifyLinuxSandboxTools } from "./sandbox-tools.js";
|
|
4
5
|
const REFUSED = 126;
|
|
5
6
|
const STOPPED = 143;
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const pathsOf = (tools) => ({ bwrapPath: tools.bwrap.real, socatPath: tools.socat.real, seccompConfig: { applyPath: tools.seccomp.real } });
|
|
8
|
+
function missing(tools, exclusions) {
|
|
9
|
+
const changed = verifyLinuxSandboxTools(tools, { exclusions });
|
|
10
|
+
if (changed !== null)
|
|
11
|
+
return changed;
|
|
12
|
+
const paths = pathsOf(tools);
|
|
13
|
+
const checked = checkLinuxDependencies(paths);
|
|
8
14
|
if (checked.errors.length > 0)
|
|
9
15
|
return checked.errors.join("; ");
|
|
10
|
-
return getLinuxDependencyStatus().hasSeccompApply ? null : "the sandbox runtime's seccomp helper isn't available";
|
|
16
|
+
return getLinuxDependencyStatus(paths).hasSeccompApply ? null : "the sandbox runtime's seccomp helper isn't available";
|
|
17
|
+
}
|
|
18
|
+
function toolsProblem(spec) {
|
|
19
|
+
const tools = spec.tools;
|
|
20
|
+
if (!isLinuxSandboxTools(tools))
|
|
21
|
+
return "the sandbox's programs weren't given by checked paths";
|
|
22
|
+
return verifyLinuxSandboxTools(tools, { exclusions: sandboxToolExclusions(spec.terms, spec.cwd) });
|
|
11
23
|
}
|
|
12
24
|
async function main() {
|
|
13
25
|
const raw = process.env[SANDBOX_LAUNCH_SPEC];
|
|
@@ -17,6 +29,15 @@ async function main() {
|
|
|
17
29
|
return REFUSED;
|
|
18
30
|
}
|
|
19
31
|
const spec = JSON.parse(raw);
|
|
32
|
+
const problem = toolsProblem(spec);
|
|
33
|
+
if (problem !== null) {
|
|
34
|
+
process.stderr.write(`toolroll sandbox: nothing was started: ${problem}\n`);
|
|
35
|
+
return REFUSED;
|
|
36
|
+
}
|
|
37
|
+
const tools = spec.tools;
|
|
38
|
+
const exclusions = sandboxToolExclusions(spec.terms, spec.cwd);
|
|
39
|
+
const launchEnv = { ...process.env };
|
|
40
|
+
process.env["PATH"] = tools.whichFolder;
|
|
20
41
|
process.chdir(spec.cwd);
|
|
21
42
|
let stopping = false;
|
|
22
43
|
let child = null;
|
|
@@ -49,7 +70,7 @@ async function main() {
|
|
|
49
70
|
};
|
|
50
71
|
try {
|
|
51
72
|
if (network.kind === "proxy")
|
|
52
|
-
bridge = await initializeLinuxNetworkBridge(network.httpPort, network.socksPort ?? network.httpPort);
|
|
73
|
+
bridge = await initializeLinuxNetworkBridge(network.httpPort, network.socksPort ?? network.httpPort, tools.socat.real);
|
|
53
74
|
if (spec.temp !== undefined)
|
|
54
75
|
process.env["CLAUDE_CODE_TMPDIR"] = spec.temp;
|
|
55
76
|
else
|
|
@@ -58,7 +79,7 @@ async function main() {
|
|
|
58
79
|
for (let attempt = 1;; attempt++) {
|
|
59
80
|
if (stopping)
|
|
60
81
|
return STOPPED;
|
|
61
|
-
const gone = missing();
|
|
82
|
+
const gone = missing(tools, exclusions);
|
|
62
83
|
if (gone !== null)
|
|
63
84
|
throw new Error(`the sandbox can't be made here: ${gone}`);
|
|
64
85
|
const command = await wrapCommandWithSandboxLinux({
|
|
@@ -71,12 +92,15 @@ async function main() {
|
|
|
71
92
|
}),
|
|
72
93
|
readConfig: spec.terms.readConfig,
|
|
73
94
|
writeConfig: spec.terms.writeConfig,
|
|
95
|
+
...pathsOf(tools),
|
|
96
|
+
binShell: tools.bash.real,
|
|
97
|
+
ripgrepConfig: { command: tools.rg.real },
|
|
74
98
|
});
|
|
75
|
-
if (!/\bbwrap\b/.test(command) || !command.includes("apply-seccomp"))
|
|
76
|
-
throw new Error("the sandbox runtime returned a command without its sandbox
|
|
99
|
+
if (!/\bbwrap\b/.test(command) || ![tools.bwrap.real, tools.seccomp.real, tools.bash.real].every(path => command.includes(path)) || !command.includes("apply-seccomp"))
|
|
100
|
+
throw new Error("the sandbox runtime returned a command without its sandbox, its seccomp filter or the programs it was handed");
|
|
77
101
|
if (stopping)
|
|
78
102
|
return STOPPED;
|
|
79
|
-
const run = spawn("/bin/sh", ["-c", command], { stdio: ["inherit", "inherit", "pipe", "pipe"] });
|
|
103
|
+
const run = spawn("/bin/sh", ["-c", command], { stdio: ["inherit", "inherit", "pipe", "pipe"], env: launchEnv });
|
|
80
104
|
child = run;
|
|
81
105
|
let ran = false;
|
|
82
106
|
const held = [];
|
package/dist/sandbox-runtime.js
CHANGED
|
@@ -5,6 +5,7 @@ import { delimiter, dirname, join } from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { wrapCommandWithSandboxMacOS } from "@anthropic-ai/sandbox-runtime/dist/sandbox/macos-sandbox-utils.js";
|
|
7
7
|
import { checkLinuxDependencies, getLinuxDependencyStatus } from "@anthropic-ai/sandbox-runtime/dist/sandbox/linux-sandbox-utils.js";
|
|
8
|
+
import { linuxSandboxTools, sandboxToolExclusions } from "./sandbox-tools.js";
|
|
8
9
|
const require = createRequire(import.meta.url);
|
|
9
10
|
export const SANDBOX_RUNTIME = (() => {
|
|
10
11
|
const name = "@anthropic-ai/sandbox-runtime";
|
|
@@ -30,14 +31,19 @@ export function sandboxRuntimeProblem(platform = process.platform) {
|
|
|
30
31
|
const missing = missingLinuxSandboxTools();
|
|
31
32
|
if (missing.length > 0)
|
|
32
33
|
return `${toolWords(missing)} ${missing.length === 1 ? "is" : "are"} not installed (${linuxSandboxInstallLine(missing)})`;
|
|
33
|
-
const
|
|
34
|
+
const resolved = linuxSandboxTools();
|
|
35
|
+
if (!resolved.ok)
|
|
36
|
+
return resolved.why;
|
|
37
|
+
const { tools } = resolved;
|
|
38
|
+
const paths = { bwrapPath: tools.bwrap.real, socatPath: tools.socat.real, seccompConfig: { applyPath: tools.seccomp.real } };
|
|
39
|
+
const checked = checkLinuxDependencies(paths);
|
|
34
40
|
if (checked.errors.length > 0)
|
|
35
41
|
return checked.errors.join("; ");
|
|
36
|
-
if (!getLinuxDependencyStatus().hasSeccompApply)
|
|
42
|
+
if (!getLinuxDependencyStatus(paths).hasSeccompApply)
|
|
37
43
|
return "the sandbox runtime's seccomp helper isn't available for this processor";
|
|
38
|
-
if (spawnSync(
|
|
39
|
-
return
|
|
40
|
-
const probe = spawnSync(
|
|
44
|
+
if (spawnSync(tools.rg.real, ["--version"], { timeout: 5_000, stdio: "ignore" }).status !== 0)
|
|
45
|
+
return `ripgrep (${tools.rg.real}) doesn't run`;
|
|
46
|
+
const probe = spawnSync(tools.bwrap.real, ["--ro-bind", "/", "/", "--unshare-pid", "--unshare-user", "--proc", "/proc", "--new-session", "--", "true"], { timeout: 5_000, stdio: "ignore" });
|
|
41
47
|
return probe.status === 0 ? null : "bubblewrap can't start a sandbox here (unprivileged user namespaces may be off)";
|
|
42
48
|
}
|
|
43
49
|
return `the sandbox runtime has no sandbox for ${platform}`;
|
|
@@ -241,13 +247,16 @@ export const sandboxLaunchHelper = () => {
|
|
|
241
247
|
const beside = fileURLToPath(new URL("./sandbox-launch.js", import.meta.url));
|
|
242
248
|
return existsSync(beside) ? beside : fileURLToPath(new URL("../dist/sandbox-launch.js", import.meta.url));
|
|
243
249
|
};
|
|
244
|
-
export function srtSpawn(file, args, terms, cwd = process.cwd(), temp, platform = process.platform) {
|
|
250
|
+
export function srtSpawn(file, args, terms, cwd = process.cwd(), temp, platform = process.platform, tools = linuxSandboxTools) {
|
|
245
251
|
if (platform === "darwin") {
|
|
246
252
|
const command = srtMacosCommand(file, args, terms, cwd, temp);
|
|
247
253
|
if (!command.includes(SANDBOX_EXEC))
|
|
248
254
|
throw new Error("the sandbox runtime returned the command unsandboxed");
|
|
249
255
|
return { file: "/usr/bin/perl", args: [...DETACH, "/bin/sh", "-c", command], env: {} };
|
|
250
256
|
}
|
|
251
|
-
const
|
|
257
|
+
const resolved = tools(sandboxToolExclusions(terms, cwd));
|
|
258
|
+
if (!resolved.ok)
|
|
259
|
+
throw new Error(resolved.why);
|
|
260
|
+
const spec = { file, args: [...args], cwd, terms, tools: resolved.tools, ...(temp === undefined ? {} : { temp }) };
|
|
252
261
|
return { file: process.execPath, args: [sandboxLaunchHelper()], env: { [SANDBOX_LAUNCH_SPEC]: JSON.stringify(spec) } };
|
|
253
262
|
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { accessSync, constants as fsConstants, existsSync, lstatSync, realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { platformAcl, rootOwnedBinary, rootOwnedFolders } from "./trusted-path.js";
|
|
6
|
+
export const SANDBOX_TOOL_FOLDERS = ["/usr/bin", "/bin", "/usr/sbin", "/sbin", "/usr/local/bin", "/run/current-system/sw/bin"];
|
|
7
|
+
const SYSTEM_TOOLS = [
|
|
8
|
+
{ key: "bwrap", command: "bwrap", words: "bubblewrap (bwrap)", install: "bubblewrap" },
|
|
9
|
+
{ key: "socat", command: "socat", words: "socat", install: "socat" },
|
|
10
|
+
{ key: "bash", command: "bash", words: "bash", install: "bash" },
|
|
11
|
+
{ key: "rg", command: "rg", words: "ripgrep (rg)", install: "ripgrep" },
|
|
12
|
+
{ key: "which", command: "which", words: "which", install: "which" },
|
|
13
|
+
];
|
|
14
|
+
const KEYS = [...SYSTEM_TOOLS.map(tool => tool.key), "seccomp"];
|
|
15
|
+
const insideOrAt = (path, root) => path === root || path.startsWith(root.endsWith("/") ? root : `${root}/`);
|
|
16
|
+
const realOrSelf = (path) => { try {
|
|
17
|
+
return realpathSync(path);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return path;
|
|
21
|
+
} };
|
|
22
|
+
const require = createRequire(import.meta.url);
|
|
23
|
+
export function seccompHelperPath(arch = process.arch) {
|
|
24
|
+
const vendor = arch === "x64" ? "x64" : arch === "arm64" ? "arm64" : null;
|
|
25
|
+
if (vendor === null)
|
|
26
|
+
return null;
|
|
27
|
+
try {
|
|
28
|
+
return join(dirname(require.resolve("@anthropic-ai/sandbox-runtime")), "..", "vendor", "seccomp", vendor, "apply-seccomp");
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function codeOwnerNow() {
|
|
35
|
+
try {
|
|
36
|
+
return lstatSync(realpathSync(fileURLToPath(import.meta.url))).uid;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const NO_EXCLUSIONS = { all: [] };
|
|
43
|
+
const withReal = (paths) => [...new Set(paths.flatMap(path => [path, realOrSelf(path)]))];
|
|
44
|
+
export function sandboxToolExclusions(terms, cwd) {
|
|
45
|
+
const write = terms.writeConfig;
|
|
46
|
+
const roots = (paths) => withReal(paths.map(path => path.replace(/\/?\*.*$/, "")).filter(path => path !== "" && path !== "/" && path.startsWith("/")));
|
|
47
|
+
const allow = withReal([...write.allowOnly, ...write.literalAllowOnly ?? []].map(path => path.includes("*") ? dirname(path.replace(/\*.*$/, "x")) : path).filter(path => path.startsWith("/")));
|
|
48
|
+
const deny = withReal([...write.denyWithinAllow, ...write.literalDenyWithinAllow ?? []].filter(path => path.startsWith("/") && !path.includes("*")));
|
|
49
|
+
return { all: roots([cwd, ...write.allowOnly, ...write.literalAllowOnly ?? [], ...write.denyWithinAllow, ...terms.readConfig.denyOnly]), writes: { allow, deny } };
|
|
50
|
+
}
|
|
51
|
+
const mayWrite = (writes, path) => writes.allow.some(root => insideOrAt(path, root)) && !writes.deny.some(root => insideOrAt(path, root));
|
|
52
|
+
const installWords = (pkg) => `install ${pkg} from your system package manager (sudo apt install ${pkg}; Fedora: sudo dnf install ${pkg})`;
|
|
53
|
+
function identify(real) {
|
|
54
|
+
try {
|
|
55
|
+
accessSync(real, fsConstants.X_OK);
|
|
56
|
+
const file = statSync(real, { bigint: true });
|
|
57
|
+
return { ok: true, tool: { real, id: `${file.dev}:${file.ino}:${file.ctimeNs}` } };
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return { ok: false, why: `${real} can't be run` };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function checkSystem(path, trust, exclusions) {
|
|
64
|
+
const checked = rootOwnedBinary(path, trust.acl, trust.root);
|
|
65
|
+
if (!checked.ok)
|
|
66
|
+
return checked;
|
|
67
|
+
if (exclusions.all.some(root => insideOrAt(checked.real, root)))
|
|
68
|
+
return { ok: false, why: `${checked.real} is inside a project, worktree or Toolroll's own folder` };
|
|
69
|
+
return identify(checked.real);
|
|
70
|
+
}
|
|
71
|
+
export function checkSeccompHelper(path, exclusions, trust = {}) {
|
|
72
|
+
const t = trustOf(trust);
|
|
73
|
+
const owners = t.codeOwner === undefined ? t.root : [...t.root, t.codeOwner];
|
|
74
|
+
const checked = rootOwnedBinary(path, t.acl, owners, "root or Toolroll's own user");
|
|
75
|
+
if (!checked.ok)
|
|
76
|
+
return checked;
|
|
77
|
+
const writes = exclusions.writes;
|
|
78
|
+
if (writes !== undefined && !rootOwnedBinary(checked.real, t.acl, t.root).ok) {
|
|
79
|
+
if (mayWrite(writes, checked.real))
|
|
80
|
+
return { ok: false, why: `the launch may write ${checked.real}, and the helper isn't root's own` };
|
|
81
|
+
if (!writes.deny.some(root => insideOrAt(checked.real, root)))
|
|
82
|
+
return { ok: false, why: `the fence's install-tree write denies don't cover ${checked.real}` };
|
|
83
|
+
}
|
|
84
|
+
return identify(checked.real);
|
|
85
|
+
}
|
|
86
|
+
const trustOf = (trust) => ({ root: trust.root ?? [0], codeOwner: "codeOwner" in trust ? trust.codeOwner : codeOwnerNow(), acl: "acl" in trust ? trust.acl ?? null : platformAcl() });
|
|
87
|
+
export function resolveLinuxSandboxTools(options = {}) {
|
|
88
|
+
const folders = options.folders ?? SANDBOX_TOOL_FOLDERS;
|
|
89
|
+
const exclusions = options.exclusions ?? NO_EXCLUSIONS;
|
|
90
|
+
const trust = trustOf(options);
|
|
91
|
+
const found = {};
|
|
92
|
+
let whichFolder = null;
|
|
93
|
+
for (const tool of SYSTEM_TOOLS) {
|
|
94
|
+
const passedOver = [];
|
|
95
|
+
for (const folder of folders) {
|
|
96
|
+
const candidate = join(folder, tool.command);
|
|
97
|
+
if (!existsSync(candidate))
|
|
98
|
+
continue;
|
|
99
|
+
const checked = checkSystem(candidate, trust, exclusions);
|
|
100
|
+
if (!checked.ok) {
|
|
101
|
+
passedOver.push(`${candidate}: ${checked.why}`);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (tool.key === "which") {
|
|
105
|
+
const dir = rootOwnedFolders(folder, trust.acl, trust.root);
|
|
106
|
+
if (!dir.ok) {
|
|
107
|
+
passedOver.push(`${candidate}: ${dir.why}`);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
whichFolder = dir.real;
|
|
111
|
+
}
|
|
112
|
+
found[tool.key] = checked.tool;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
if (found[tool.key] === undefined) {
|
|
116
|
+
return { ok: false, why: `${tool.words} has no copy owned by root in ${folders.join(", ")}${passedOver.length === 0 ? "" : ` (${passedOver.join("; ")})`}: ${installWords(tool.install)}` };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const helper = "seccomp" in options ? options.seccomp ?? null : seccompHelperPath();
|
|
120
|
+
if (helper === null)
|
|
121
|
+
return { ok: false, why: `the sandbox runtime's seccomp helper isn't available for this processor (${process.arch})` };
|
|
122
|
+
const checked = checkSeccompHelper(helper, exclusions, options);
|
|
123
|
+
if (!checked.ok)
|
|
124
|
+
return { ok: false, why: `the sandbox runtime's seccomp helper (${helper}) can't be trusted: ${checked.why}` };
|
|
125
|
+
found.seccomp = checked.tool;
|
|
126
|
+
return { ok: true, tools: { ...found, whichFolder: whichFolder } };
|
|
127
|
+
}
|
|
128
|
+
export function verifyLinuxSandboxTools(tools, options = {}) {
|
|
129
|
+
const trust = trustOf(options);
|
|
130
|
+
const exclusions = options.exclusions ?? NO_EXCLUSIONS;
|
|
131
|
+
for (const key of KEYS) {
|
|
132
|
+
const tool = tools[key];
|
|
133
|
+
const checked = key === "seccomp" ? checkSeccompHelper(tool.real, exclusions, options) : checkSystem(tool.real, trust, exclusions);
|
|
134
|
+
if (!checked.ok)
|
|
135
|
+
return `${key} (${tool.real}): ${checked.why}`;
|
|
136
|
+
if (checked.tool.real !== tool.real || checked.tool.id !== tool.id)
|
|
137
|
+
return `${key} (${tool.real}) changed since it was checked`;
|
|
138
|
+
}
|
|
139
|
+
const helper = "seccomp" in options ? options.seccomp ?? null : seccompHelperPath();
|
|
140
|
+
if (helper === null || realOrSelf(helper) !== tools.seccomp.real)
|
|
141
|
+
return `the seccomp helper (${tools.seccomp.real}) isn't Toolroll's own sandbox-runtime's`;
|
|
142
|
+
const dir = rootOwnedFolders(tools.whichFolder, trust.acl, trust.root);
|
|
143
|
+
if (!dir.ok || dir.real !== tools.whichFolder)
|
|
144
|
+
return `which's folder (${tools.whichFolder}) ${dir.ok ? "changed" : dir.why}`;
|
|
145
|
+
if (realOrSelf(join(tools.whichFolder, "which")) !== tools.which.real)
|
|
146
|
+
return `which in ${tools.whichFolder} changed since it was checked`;
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
export function isLinuxSandboxTools(value) {
|
|
150
|
+
if (value === null || typeof value !== "object")
|
|
151
|
+
return false;
|
|
152
|
+
const record = value;
|
|
153
|
+
const path = (one) => typeof one === "string" && one.startsWith("/") && !/[\u0000-\u001f\u007f]/.test(one);
|
|
154
|
+
if (!path(record["whichFolder"]))
|
|
155
|
+
return false;
|
|
156
|
+
return KEYS.every(key => {
|
|
157
|
+
const tool = record[key];
|
|
158
|
+
return tool !== null && typeof tool === "object" && path(tool["real"]) && typeof tool["id"] === "string" && /^\d+:\d+:\d+$/.test(tool["id"]);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
let discovered = null;
|
|
162
|
+
export function linuxSandboxTools(exclusions = NO_EXCLUSIONS) {
|
|
163
|
+
if (discovered === null) {
|
|
164
|
+
const found = resolveLinuxSandboxTools();
|
|
165
|
+
if (!found.ok)
|
|
166
|
+
return found;
|
|
167
|
+
discovered = found.tools;
|
|
168
|
+
}
|
|
169
|
+
const tools = discovered;
|
|
170
|
+
const why = verifyLinuxSandboxTools(tools, { exclusions });
|
|
171
|
+
if (why !== null) {
|
|
172
|
+
discovered = null;
|
|
173
|
+
return { ok: false, why: `a sandbox program failed its check right before the launch: ${why}` };
|
|
174
|
+
}
|
|
175
|
+
return { ok: true, tools };
|
|
176
|
+
}
|
package/dist/scope.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { ACCEPTANCE_LIMITS, EVIDENCE_KINDS } from "./contracts/acceptance-terms.js";
|
|
2
|
+
import { flexibleCandidateChangeRefusal } from "./flexible-merge-guard.js";
|
|
2
3
|
import { cardShowsScope, cardTermsDigest } from "./chat-terms.js";
|
|
3
4
|
import { mintSecret } from "./secret-mint.js";
|
|
5
|
+
import { sessionStandsIn } from "./install-mode.js";
|
|
4
6
|
import { passwordlessOn } from "./passwordless.js";
|
|
5
7
|
import { routeChangeProblem } from "./route-change-check.js";
|
|
6
8
|
import { issueImported } from "./task-source.js";
|
|
@@ -18,10 +20,10 @@ import { levelOfProfile } from "./policy.js";
|
|
|
18
20
|
import { canonicalJson } from "./canonical-json.js";
|
|
19
21
|
export { isAcpProfile };
|
|
20
22
|
import { createHash, randomBytes, scryptSync, timingSafeEqual } from "node:crypto";
|
|
21
|
-
import { networkFromValue
|
|
22
|
-
import { isWritesMode
|
|
23
|
-
import {
|
|
24
|
-
import { MAX_MACH_LOOKUP, MAX_READ_DENY,
|
|
23
|
+
import { networkFromValue } from "./egress.js";
|
|
24
|
+
import { isWritesMode } from "./writes-mode.js";
|
|
25
|
+
import { isCheckAccess } from "./check-access.js";
|
|
26
|
+
import { MAX_MACH_LOOKUP, MAX_READ_DENY, validMachLookup, validReadDeny } from "./project-sandbox.js";
|
|
25
27
|
import { z } from "zod";
|
|
26
28
|
import {} from "./contracts/acceptance-terms.js";
|
|
27
29
|
import { parseContract } from "./contracts/contract.js";
|
|
@@ -460,6 +462,9 @@ function proposeLocked(store, input) {
|
|
|
460
462
|
const { taskId, goal, outOfScope = null, touches = [], budgetMicrousd = null, acceptance = [], qualityMode = "default", now, mutation = {}, profile, permissionMode, posture, proposedVia = null } = input;
|
|
461
463
|
const draft = { goal, outOfScope, touches: [...touches], budgetMicrousd, acceptance: [...acceptance], qualityMode, candidate: input.candidate ?? null };
|
|
462
464
|
const previous = store.getScope(taskId);
|
|
465
|
+
const fixed = flexibleCandidateChangeRefusal(store, taskId, previous?.candidate, draft.candidate);
|
|
466
|
+
if (fixed !== null)
|
|
467
|
+
throw new Error(fixed);
|
|
463
468
|
const scope = {
|
|
464
469
|
taskId,
|
|
465
470
|
...draft,
|
|
@@ -624,7 +629,7 @@ export function proveAccountNow(store, by, token, options = {}) {
|
|
|
624
629
|
if (facts != null && facts.actor === by && !facts.live())
|
|
625
630
|
return { ok: false, reason: "not-an-approver" };
|
|
626
631
|
if (token === "") {
|
|
627
|
-
if (options.credential !== true && facts != null && facts.actor === by && facts.live() &&
|
|
632
|
+
if (options.credential !== true && facts != null && facts.actor === by && facts.live() && sessionStandsIn(store))
|
|
628
633
|
return { ok: true, method: "session", at: now };
|
|
629
634
|
if (ssoNowAvailable(by, now)) {
|
|
630
635
|
const at = facts.ssoNow();
|
|
@@ -651,7 +656,7 @@ export function proveAccountNow(store, by, token, options = {}) {
|
|
|
651
656
|
}
|
|
652
657
|
export function passwordlessSessionFor(store, by) {
|
|
653
658
|
const facts = freshFacts.getStore();
|
|
654
|
-
return facts != null && facts.actor === by && facts.live() &&
|
|
659
|
+
return facts != null && facts.actor === by && facts.live() && sessionStandsIn(store);
|
|
655
660
|
}
|
|
656
661
|
export const credentialProof = (method) => method === "password-now" || method === "sso-now";
|
|
657
662
|
export function proveCredential(store, by, token, repo) {
|
|
@@ -934,30 +939,6 @@ export function scopeRouteWords(scope, readiness = NO_READINESS) {
|
|
|
934
939
|
const route = routeFromJson(scope.proposedRouteJson ?? null);
|
|
935
940
|
return route === null ? [] : routeWords(projectRoute(route, readiness));
|
|
936
941
|
}
|
|
937
|
-
export function describeScope(scope, readiness = NO_READINESS, evidence = null) {
|
|
938
|
-
const approval = approvalOf(scope);
|
|
939
|
-
return [
|
|
940
|
-
` goal ${scope.goal}`,
|
|
941
|
-
...(scope.outOfScope === null ? [] : [` not this ${scope.outOfScope}`]),
|
|
942
|
-
...(scope.candidate ? [` commit ${scope.candidate.slice(0, 7)} — checked out by Toolroll, no agent runs`] : []),
|
|
943
|
-
...(scope.touches.length === 0 ? [] : [` files ${scope.touches.join(", ")}`]),
|
|
944
|
-
...acceptanceWords(scope.acceptance),
|
|
945
|
-
...(scope.budgetMicrousd === null
|
|
946
|
-
? []
|
|
947
|
-
: [` budget $${(scope.budgetMicrousd / 1_000_000).toFixed(2)} per build attempt — the agent is stopped at this figure`]),
|
|
948
|
-
...scopeRouteWords(scope, readiness),
|
|
949
|
-
...(evidence === null ? [] : [` why model ${evidence.replace(/^Why this model: /, "")}`]),
|
|
950
|
-
...chainTermsLines(scope).map((line, at) => at === 0 ? ` fallback ${line}` : ` ${line}`),
|
|
951
|
-
...(scope.profile === null || scope.profile === undefined ? [] : [` network ${networkWords(scope.profile.network ?? null).replace(/^Network: /, "")}`]),
|
|
952
|
-
...(scope.profile === null || scope.profile === undefined ? [] : [` writes ${writesWords(scope.profile.writes)}`]),
|
|
953
|
-
...(scope.profile?.checkAccess === undefined ? [] : [` checks ${checkAccessWords(scope.profile.checkAccess)}`]),
|
|
954
|
-
...(scope.profile === null || scope.profile === undefined ? [] : ((terms) => [` reads ${terms.reads}`, ...(terms.mach === null ? [] : [` services ${terms.mach}`])])(sandboxTermsWords(scope.profile))),
|
|
955
|
-
...releaseTermsWords(scope.releaseTerms ?? null),
|
|
956
|
-
...(scope.releaseCheck == null ? [] : [` release ${releaseCheckSentence(scope.releaseCheck)}`]),
|
|
957
|
-
` version ${scope.digest.slice(0, 8)} (the full plan version is in --json)`,
|
|
958
|
-
` approved ${describeApproval(approval)}`,
|
|
959
|
-
];
|
|
960
|
-
}
|
|
961
942
|
export function releaseTermsSentence(terms) {
|
|
962
943
|
if (!terms.policy.carry)
|
|
963
944
|
return `Release ${terms.packageVersion} from pull request #${terms.pr} at ${terms.approvedSha.slice(0, 7)}. Every later commit asks for your approval again.`;
|
|
@@ -978,12 +959,7 @@ export function releaseAsksAgainWords(terms) {
|
|
|
978
959
|
`and always once the deploy starts. Repository ${terms.repo}, branch ${terms.branch} into ${terms.base}, check grant ${terms.grant.id}, ${terms.access === "sandboxed" ? "checks in the sandbox" : `checks outside the sandbox (${terms.access}), carried because the project allows it`}, until ${terms.expiresAt}.`,
|
|
979
960
|
];
|
|
980
961
|
}
|
|
981
|
-
function
|
|
982
|
-
if (terms === null)
|
|
983
|
-
return [];
|
|
984
|
-
return [` release ${releaseTermsSentence(terms)}`, ...(terms.policy.carry ? releaseAsksAgainWords(terms).map(line => ` ${line}`) : [])];
|
|
985
|
-
}
|
|
986
|
-
function describeApproval(approval) {
|
|
962
|
+
export function describeApproval(approval) {
|
|
987
963
|
if (approval.approved)
|
|
988
964
|
return `yes, by ${approval.by} at ${approval.at}`;
|
|
989
965
|
if (approval.reason === "changed") {
|
package/dist/scout-net.js
CHANGED
|
@@ -71,19 +71,24 @@ function demoTarget(demoUrl) {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
const CONNECT_TIMEOUT_MS = 10_000;
|
|
74
|
-
export async function connectFirst(addresses, port, timeoutMs = CONNECT_TIMEOUT_MS) {
|
|
74
|
+
export async function connectFirst(addresses, port, timeoutMs = CONNECT_TIMEOUT_MS, signal) {
|
|
75
75
|
for (const address of addresses) {
|
|
76
|
+
if (signal?.aborted === true)
|
|
77
|
+
return null;
|
|
76
78
|
const socket = await new Promise(done => {
|
|
77
79
|
const attempt = connect({ host: address, port });
|
|
78
80
|
const give = (value) => {
|
|
79
81
|
attempt.removeAllListeners("connect").removeAllListeners("error").removeAllListeners("timeout");
|
|
80
82
|
attempt.setTimeout(0);
|
|
83
|
+
signal?.removeEventListener("abort", aborted);
|
|
81
84
|
if (value === null)
|
|
82
85
|
attempt.destroy();
|
|
83
86
|
done(value);
|
|
84
87
|
};
|
|
88
|
+
const aborted = () => give(null);
|
|
89
|
+
signal?.addEventListener("abort", aborted, { once: true });
|
|
85
90
|
attempt.setTimeout(timeoutMs);
|
|
86
|
-
attempt.once("connect", () => give(attempt));
|
|
91
|
+
attempt.once("connect", () => give(signal?.aborted === true ? null : attempt));
|
|
87
92
|
attempt.once("error", () => give(null));
|
|
88
93
|
attempt.once("timeout", () => give(null));
|
|
89
94
|
});
|