toolroll 0.9.109 → 0.9.111

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.
Files changed (155) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +5 -1
  3. package/THIRD_PARTY_NOTICES.md +30 -0
  4. package/dist/agent-detect.js +244 -0
  5. package/dist/agent-fence.js +12 -1
  6. package/dist/agent-said-schema.js +4 -0
  7. package/dist/agent-said.js +23 -0
  8. package/dist/agentconfig.js +2 -2
  9. package/dist/approval-summary.js +375 -0
  10. package/dist/attest.js +2 -2
  11. package/dist/browser/THIRD_PARTY_NOTICES.txt +30 -0
  12. package/dist/browser/workspace.css +2 -2
  13. package/dist/browser/workspace.js +27 -27
  14. package/dist/builder.js +42 -3
  15. package/dist/chat-actions.js +24 -17
  16. package/dist/chat-core.js +3 -1
  17. package/dist/chat-decide.js +101 -46
  18. package/dist/chat-delivery-state.js +2 -0
  19. package/dist/chat-delivery.js +3 -2
  20. package/dist/chat-live.js +2 -1
  21. package/dist/chat-task-actions.js +6 -0
  22. package/dist/check-report.js +1 -1
  23. package/dist/claim.js +28 -13
  24. package/dist/cli-help.js +1 -1
  25. package/dist/cli.js +2 -0
  26. package/dist/codex-limits.js +21 -8
  27. package/dist/console-instance.js +11 -1
  28. package/dist/contracts/console-api.js +13 -7
  29. package/dist/contracts/engine-api.js +283 -0
  30. package/dist/contracts/route.js +1 -0
  31. package/dist/coordinator.js +2 -2
  32. package/dist/discord-api.js +4 -3
  33. package/dist/discord-chat.js +3 -1
  34. package/dist/dispatch.js +1 -1
  35. package/dist/dispose.js +15 -9
  36. package/dist/easy-start-args.js +7 -3
  37. package/dist/easy-start.js +40 -1
  38. package/dist/egress.js +72 -10
  39. package/dist/engine-handoff.js +34 -0
  40. package/dist/engine-reads.js +338 -0
  41. package/dist/eval-world.js +3 -2
  42. package/dist/evidence.js +2 -0
  43. package/dist/fast-start.js +68 -18
  44. package/dist/fast-terms.js +2 -2
  45. package/dist/first-run.js +10 -2
  46. package/dist/flexible-agents.js +234 -0
  47. package/dist/flexible-answers-schema.js +61 -0
  48. package/dist/flexible-answers.js +889 -0
  49. package/dist/flexible-custody.js +494 -0
  50. package/dist/flexible-import.js +782 -0
  51. package/dist/flexible-launch-schema.js +72 -0
  52. package/dist/flexible-launch.js +331 -0
  53. package/dist/flexible-launcher.js +88 -0
  54. package/dist/flexible-levels.js +34 -0
  55. package/dist/flexible-merge-guard.js +47 -0
  56. package/dist/flexible-refs.js +47 -0
  57. package/dist/flexible-relay-cancel.js +19 -0
  58. package/dist/flexible-relay-schema.js +55 -0
  59. package/dist/flexible-relay-upstreams.js +36 -0
  60. package/dist/flexible-relay.js +1032 -0
  61. package/dist/flexible-session.js +732 -0
  62. package/dist/flexible-ship-schema.js +81 -0
  63. package/dist/flexible-ship.js +694 -0
  64. package/dist/flexible-start.js +80 -0
  65. package/dist/flexible-thread.js +175 -25
  66. package/dist/flexible-turns-schema.js +69 -0
  67. package/dist/flexible-turns.js +490 -0
  68. package/dist/flexible.js +10 -1
  69. package/dist/flow-actions.js +6 -4
  70. package/dist/flow-steps.js +1 -1
  71. package/dist/flows-cli.js +2 -1
  72. package/dist/git-views.js +6 -3
  73. package/dist/install-mode.js +225 -0
  74. package/dist/integrations.js +6 -1
  75. package/dist/lead-doors.js +7 -1
  76. package/dist/limits-ui.js +7 -0
  77. package/dist/live-reply.js +6 -0
  78. package/dist/live-terminal.js +425 -29
  79. package/dist/local-owner.js +7 -0
  80. package/dist/model-choices.js +12 -6
  81. package/dist/needs-you.js +2 -0
  82. package/dist/notification-delivery.js +11 -0
  83. package/dist/operate.js +128 -37
  84. package/dist/outbound-privacy.js +204 -0
  85. package/dist/passwordless.js +2 -1
  86. package/dist/phase-routing.js +3 -1
  87. package/dist/plane-review.js +1 -1
  88. package/dist/project-delete.js +14 -0
  89. package/dist/proposal.js +2 -2
  90. package/dist/provider-connection.js +19 -5
  91. package/dist/publish.js +5 -0
  92. package/dist/pull-request-flow.js +26 -7
  93. package/dist/push.js +5 -1
  94. package/dist/release-card.js +11 -3
  95. package/dist/release.js +10 -1
  96. package/dist/route-store.js +3 -3
  97. package/dist/sandbox-launch.js +32 -8
  98. package/dist/sandbox-runtime.js +16 -7
  99. package/dist/sandbox-tools.js +176 -0
  100. package/dist/scope.js +12 -36
  101. package/dist/scout-net.js +7 -2
  102. package/dist/serve.js +62 -13
  103. package/dist/server/chrome.js +3 -1
  104. package/dist/server/console.css +33 -6
  105. package/dist/server/engine-api.js +378 -0
  106. package/dist/server/flows.js +2 -2
  107. package/dist/server/http.js +7 -0
  108. package/dist/server/link-redemption.js +52 -0
  109. package/dist/server/mutation-key.js +21 -7
  110. package/dist/server/pages.js +72 -40
  111. package/dist/server/people-tokens.js +17 -41
  112. package/dist/server/render-chat.js +1 -0
  113. package/dist/server/render-new-task.js +3 -3
  114. package/dist/server/render-results.js +4 -4
  115. package/dist/server/render-tasks.js +133 -139
  116. package/dist/server/route-table.js +32 -1
  117. package/dist/server/settings-section-table.js +6 -0
  118. package/dist/server/settings-sections.js +69 -0
  119. package/dist/server/settings.js +120 -10
  120. package/dist/server/task-views.js +8 -2
  121. package/dist/server/tasks.js +56 -12
  122. package/dist/server/terminals.js +181 -28
  123. package/dist/server/welcome.js +35 -10
  124. package/dist/settings-groups-ui.js +2 -2
  125. package/dist/settings-proofs.js +14 -9
  126. package/dist/slack-api.js +4 -3
  127. package/dist/slack-chat.js +5 -3
  128. package/dist/spend.js +46 -12
  129. package/dist/status-probe.js +343 -0
  130. package/dist/store.js +181 -12
  131. package/dist/task-sizing-schema.js +14 -0
  132. package/dist/task-sizing.js +76 -10
  133. package/dist/teams-api.js +4 -3
  134. package/dist/teams-chat.js +4 -2
  135. package/dist/telegram-lead.js +2 -1
  136. package/dist/telegram-live.js +2 -1
  137. package/dist/telegram-team.js +2 -1
  138. package/dist/telegram.js +17 -5
  139. package/dist/toolroll-update.js +3 -1
  140. package/dist/trusted-path.js +162 -0
  141. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  142. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  143. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  144. package/dist/tui/linux-x64/toolroll-tui +0 -0
  145. package/dist/tui-launch.js +282 -0
  146. package/dist/tui-source.js +5 -3
  147. package/dist/tui.js +1 -1
  148. package/dist/webhooks.js +14 -4
  149. package/dist/welcome-facts.js +22 -15
  150. package/dist/work-index.js +2 -2
  151. package/dist/workspace-ui.js +5 -0
  152. package/package.json +1 -1
  153. package/scripts/crash-canary.mjs +1 -1
  154. package/scripts/pilot.mjs +1 -1
  155. package/scripts/provider-canary.mjs +5 -3
@@ -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
- function missing() {
7
- const checked = checkLinuxDependencies();
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 or its seccomp filter");
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 = [];
@@ -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 checked = checkLinuxDependencies();
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("rg", ["--version"], { timeout: 5_000, stdio: "ignore" }).status !== 0)
39
- return "ripgrep (rg) is not installed";
40
- const probe = spawnSync("bwrap", ["--ro-bind", "/", "/", "--unshare-pid", "--unshare-user", "--proc", "/proc", "--new-session", "--", "true"], { timeout: 5_000, stdio: "ignore" });
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 spec = { file, args: [...args], cwd, terms, ...(temp === undefined ? {} : { temp }) };
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, networkWords } from "./egress.js";
22
- import { isWritesMode, writesWords } from "./writes-mode.js";
23
- import { checkAccessWords, isCheckAccess } from "./check-access.js";
24
- import { MAX_MACH_LOOKUP, MAX_READ_DENY, sandboxTermsWords, validMachLookup, validReadDeny } from "./project-sandbox.js";
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() && passwordlessOn(store))
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() && passwordlessOn(store);
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 releaseTermsWords(terms) {
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
  });