toolroll 0.9.125 → 0.9.126
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 +36 -0
- package/README.md +1 -1
- package/dist/agent-detect.js +23 -3
- package/dist/bounded-spawn.js +5 -36
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +29 -29
- package/dist/browser-open.js +49 -0
- package/dist/chat-acceptance.js +1 -1
- package/dist/check-only.js +1 -1
- package/dist/cli.js +2 -2
- package/dist/connect-cli.js +2 -8
- package/dist/contracts/engine-api.js +5 -0
- package/dist/direct-chat.js +26 -18
- package/dist/doctor.js +30 -3
- package/dist/easy-start.js +43 -17
- package/dist/engine-reads.js +14 -0
- package/dist/evals.js +17 -19
- package/dist/first-run.js +5 -1
- package/dist/flexible-import.js +3 -2
- package/dist/flexible-save.js +2 -0
- package/dist/flexible-session.js +1 -1
- package/dist/flow-code.js +2 -2
- package/dist/invoke.js +4 -4
- package/dist/laptop-background.js +2 -11
- package/dist/linux-packages.js +46 -0
- package/dist/local-landing.js +26 -5
- package/dist/merge-checklist.js +33 -4
- package/dist/operate.js +16 -19
- package/dist/preflight.js +14 -0
- package/dist/process-identity.js +155 -0
- package/dist/quick-start.js +6 -1
- package/dist/release.js +8 -0
- package/dist/runner-process.js +9 -25
- package/dist/sandbox-launch.js +3 -2
- package/dist/sandbox-runtime.js +115 -15
- package/dist/sandbox-tools.js +91 -6
- package/dist/server/direct-chat.js +4 -3
- package/dist/server/merge-ready-view.js +4 -2
- package/dist/server/pages.js +1 -1
- package/dist/server/render-pages.js +1 -0
- package/dist/server/render-results.js +6 -6
- package/dist/server/render-tasks.js +2 -2
- package/dist/server/task-views.js +12 -8
- package/dist/server/tasks.js +2 -2
- package/dist/shown-text.js +14 -0
- package/dist/status-probe.js +32 -0
- package/dist/task-base.js +2 -2
- package/dist/task-status.js +7 -4
- package/dist/telegram-status.js +1 -1
- package/dist/toolroll-update.js +4 -0
- package/dist/trust-repair.js +187 -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/work-index.js +51 -3
- package/dist/workspace-ui.js +4 -2
- package/package.json +1 -1
package/dist/sandbox-runtime.js
CHANGED
|
@@ -5,7 +5,10 @@ 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
|
+
import { linuxSandboxTools, sandboxToolExclusions, sandboxToolsRepair } from "./sandbox-tools.js";
|
|
9
|
+
import { trustRepairLines } from "./trust-repair.js";
|
|
10
|
+
import { shownText } from "./shown-text.js";
|
|
11
|
+
import { installLine, packageSystem } from "./linux-packages.js";
|
|
9
12
|
const require = createRequire(import.meta.url);
|
|
10
13
|
export const SANDBOX_RUNTIME = (() => {
|
|
11
14
|
const name = "@anthropic-ai/sandbox-runtime";
|
|
@@ -20,38 +23,135 @@ export const SANDBOX_RUNTIME = (() => {
|
|
|
20
23
|
export const sandboxRuntimeWords = () => `Anthropic's sandbox-runtime ${SANDBOX_RUNTIME.version}`;
|
|
21
24
|
const SANDBOX_EXEC = "/usr/bin/sandbox-exec";
|
|
22
25
|
export const SEATBELT_PROBE = "(version 1)(deny default)(allow process-exec)(allow process-fork)(allow file-read*)(allow sysctl-read)(allow mach-lookup)";
|
|
26
|
+
const DETAIL_MAX = 300;
|
|
27
|
+
const bounded = (text) => shownText(text.trim()).slice(0, DETAIL_MAX);
|
|
23
28
|
export function sandboxRuntimeProblem(platform = process.platform) {
|
|
29
|
+
const diagnosis = sandboxRuntimeDiagnosis(platform);
|
|
30
|
+
return diagnosis.ok ? null : diagnosis.why;
|
|
31
|
+
}
|
|
32
|
+
export function sandboxRuntimeDiagnosis(platform = process.platform, io = {}) {
|
|
33
|
+
const found = diagnose(platform, io);
|
|
34
|
+
return found.ok ? found : { ...found, why: shownText(found.why) };
|
|
35
|
+
}
|
|
36
|
+
function diagnose(platform, io) {
|
|
24
37
|
if (platform === "darwin") {
|
|
25
38
|
if (!existsSync(SANDBOX_EXEC))
|
|
26
|
-
return "this Mac has no sandbox-exec";
|
|
27
|
-
const probe = spawnSync(SANDBOX_EXEC, ["-p", SEATBELT_PROBE, "/usr/bin/true"], { timeout: 5_000, stdio: "ignore" });
|
|
28
|
-
return probe.status === 0 ?
|
|
39
|
+
return { ok: false, kind: "missing-tool", why: "this Mac has no sandbox-exec" };
|
|
40
|
+
const probe = spawnSync(SANDBOX_EXEC, ["-p", SEATBELT_PROBE, "/usr/bin/true"], { timeout: 5_000, stdio: ["ignore", "ignore", "pipe"], encoding: "utf8" });
|
|
41
|
+
return probe.status === 0 ? { ok: true } : { ok: false, kind: "sandbox-denied", why: "sandbox-exec can't start a sandbox here (is this already inside one?)", detail: bounded(probe.stderr ?? "") };
|
|
29
42
|
}
|
|
30
43
|
if (platform === "linux") {
|
|
31
44
|
const missing = missingLinuxSandboxTools();
|
|
32
45
|
if (missing.length > 0)
|
|
33
|
-
return `${toolWords(missing)} ${missing.length === 1 ? "is" : "are"} not installed (${linuxSandboxInstallLine(missing)})
|
|
46
|
+
return { ok: false, kind: "missing-tool", why: `${toolWords(missing)} ${missing.length === 1 ? "is" : "are"} not installed (${linuxSandboxInstallLine(missing)})` };
|
|
34
47
|
const resolved = linuxSandboxTools();
|
|
35
|
-
if (!resolved.ok)
|
|
36
|
-
|
|
48
|
+
if (!resolved.ok) {
|
|
49
|
+
const kind = resolved.failure === "unsupported-arch" ? "unsupported-arch" : resolved.failure === "missing" ? "missing-tool" : "trust";
|
|
50
|
+
return { ok: false, kind, why: resolved.why };
|
|
51
|
+
}
|
|
37
52
|
const { tools } = resolved;
|
|
38
53
|
const paths = { bwrapPath: tools.bwrap.real, socatPath: tools.socat.real, seccompConfig: { applyPath: tools.seccomp.real } };
|
|
39
54
|
const checked = checkLinuxDependencies(paths);
|
|
40
55
|
if (checked.errors.length > 0)
|
|
41
|
-
return checked.errors.join("; ");
|
|
56
|
+
return { ok: false, kind: "launch-error", why: checked.errors.join("; ") };
|
|
42
57
|
if (!getLinuxDependencyStatus(paths).hasSeccompApply)
|
|
43
|
-
return "the sandbox runtime's seccomp helper isn't available for this processor";
|
|
58
|
+
return { ok: false, kind: "unsupported-arch", why: "the sandbox runtime's seccomp helper isn't available for this processor" };
|
|
44
59
|
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" });
|
|
47
|
-
|
|
60
|
+
return { ok: false, kind: "launch-error", why: `ripgrep (${tools.rg.real}) doesn't run` };
|
|
61
|
+
const probe = spawnSync(tools.bwrap.real, ["--ro-bind", "/", "/", "--unshare-pid", "--unshare-user", "--proc", "/proc", "--new-session", "--", "true"], { timeout: 5_000, stdio: ["ignore", "ignore", "pipe"], encoding: "utf8", maxBuffer: 64 * 1024 });
|
|
62
|
+
if (probe.status === 0)
|
|
63
|
+
return { ok: true };
|
|
64
|
+
const detail = bounded(probe.stderr ?? "");
|
|
65
|
+
const code = probe.error?.code;
|
|
66
|
+
if (code === "ETIMEDOUT")
|
|
67
|
+
return { ok: false, kind: "timeout", why: "bubblewrap didn't finish starting a sandbox in time", detail };
|
|
68
|
+
if (probe.error !== undefined)
|
|
69
|
+
return { ok: false, kind: "launch-error", why: `bubblewrap (${tools.bwrap.real}) couldn't be started (${code ?? "error"})`, detail };
|
|
70
|
+
return deniedDiagnosis(detail, io);
|
|
48
71
|
}
|
|
49
|
-
return `the sandbox runtime has no sandbox for ${platform}
|
|
72
|
+
return { ok: false, kind: "unsupported-platform", why: `the sandbox runtime has no sandbox for ${platform}` };
|
|
73
|
+
}
|
|
74
|
+
export function deniedDiagnosis(detail, io = {}) {
|
|
75
|
+
return { ok: false, kind: "sandbox-denied", context: userNamespaceSettings(io), detail,
|
|
76
|
+
why: "this system denied the user namespace the sandbox needs; the cause isn't visible from inside this machine" };
|
|
77
|
+
}
|
|
78
|
+
export function userNamespaceSettings(io = {}) {
|
|
79
|
+
const found = [];
|
|
80
|
+
const read = (file) => { try {
|
|
81
|
+
return (io.read ?? (one => readFileSync(one, "utf8")))(file).trim();
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return null;
|
|
85
|
+
} };
|
|
86
|
+
if (read("/proc/sys/kernel/apparmor_restrict_unprivileged_userns") === "1")
|
|
87
|
+
found.push({
|
|
88
|
+
words: "kernel.apparmor_restrict_unprivileged_userns = 1 (AppArmor restricts unprivileged user namespaces)",
|
|
89
|
+
fix: "an administrator can give bubblewrap an AppArmor profile that allows user namespaces (a profile for /usr/bin/bwrap with `userns,`), rather than lifting the restriction for every program",
|
|
90
|
+
});
|
|
91
|
+
if (read("/proc/sys/kernel/unprivileged_userns_clone") === "0")
|
|
92
|
+
found.push({
|
|
93
|
+
words: "kernel.unprivileged_userns_clone = 0 (unprivileged user namespaces off)",
|
|
94
|
+
fix: "an administrator can turn them on: `sudo sysctl -w kernel.unprivileged_userns_clone=1`, kept in a file under /etc/sysctl.d/",
|
|
95
|
+
});
|
|
96
|
+
if (read("/proc/sys/user/max_user_namespaces") === "0")
|
|
97
|
+
found.push({
|
|
98
|
+
words: "user.max_user_namespaces = 0 (no user namespaces at all)",
|
|
99
|
+
fix: "an administrator can allow them: `sudo sysctl -w user.max_user_namespaces=15000`, kept in a file under /etc/sysctl.d/",
|
|
100
|
+
});
|
|
101
|
+
return found;
|
|
102
|
+
}
|
|
103
|
+
function looksContained(io) {
|
|
104
|
+
const exists = io.exists ?? existsSync;
|
|
105
|
+
if (exists("/.dockerenv") || exists("/run/.containerenv"))
|
|
106
|
+
return true;
|
|
107
|
+
try {
|
|
108
|
+
return /^Seccomp:\s*2$/m.test((io.read ?? (one => readFileSync(one, "utf8")))("/proc/self/status"));
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export function sandboxRemedyLines(diagnosis, io = {}) {
|
|
115
|
+
if (diagnosis.ok || diagnosis.kind === "missing-tool" || diagnosis.kind === "trust")
|
|
116
|
+
return [];
|
|
117
|
+
const lines = [];
|
|
118
|
+
if (diagnosis.kind === "sandbox-denied")
|
|
119
|
+
for (const setting of diagnosis.context ?? [])
|
|
120
|
+
lines.push(`This machine shows ${setting.words}, which may be what denies it; if so, ${setting.fix}.`);
|
|
121
|
+
if (diagnosis.kind === "sandbox-denied" && looksContained(io)) {
|
|
122
|
+
lines.push("In a container (Docker, a devcontainer, Codespaces) its seccomp or AppArmor profile usually denies user namespaces: an administrator can allow them with a profile for this container. Starting it with `--security-opt seccomp=unconfined --security-opt apparmor=unconfined` also works, but weakens the container's own protection.");
|
|
123
|
+
}
|
|
124
|
+
if (diagnosis.kind === "unsupported-arch")
|
|
125
|
+
lines.push("This processor has no sandbox helper: Toolroll's sandbox runs on 64-bit Intel/AMD (x64) and ARM (arm64) Linux.");
|
|
126
|
+
lines.push(UNCONFINED_OPT_IN);
|
|
127
|
+
return lines;
|
|
128
|
+
}
|
|
129
|
+
export const UNCONFINED_OPT_IN = "Or an instance operator can let agents run without OS confinement: `toolroll config unconfined-agents allow` (their password, logged; refused while Toolroll runs without a password).";
|
|
130
|
+
export function sandboxAdviceLines(diagnosis, io = {}) {
|
|
131
|
+
if (diagnosis.ok || diagnosis.kind === "missing-tool")
|
|
132
|
+
return [];
|
|
133
|
+
if (diagnosis.kind === "trust")
|
|
134
|
+
return sandboxRuntimeRepair();
|
|
135
|
+
const said = diagnosis.detail === undefined || diagnosis.detail === "" ? [] : [`(${diagnosis.kind === "sandbox-denied" || diagnosis.kind === "timeout" ? "bubblewrap" : "it"} said: ${diagnosis.detail})`];
|
|
136
|
+
return [...said, ...sandboxRemedyLines(diagnosis, io)].map(shownText);
|
|
137
|
+
}
|
|
138
|
+
export function noConfinementWords(what, done, diagnosis = sandboxRuntimeDiagnosis()) {
|
|
139
|
+
const why = diagnosis.ok ? "its sandbox isn't available to this run" : diagnosis.why;
|
|
140
|
+
const fix = diagnosis.ok || diagnosis.kind === "missing-tool" ? "" : diagnosis.kind === "trust" ? " `toolroll doctor` prints the exact fix." : "";
|
|
141
|
+
return shownText(`This machine can't confine ${what}, so ${done}: ${why}.${fix} ${UNCONFINED_OPT_IN}`);
|
|
142
|
+
}
|
|
143
|
+
export function sandboxRuntimeRepair(platform = process.platform) {
|
|
144
|
+
if (platform !== "linux")
|
|
145
|
+
return [];
|
|
146
|
+
const repair = sandboxToolsRepair();
|
|
147
|
+
return repair === null ? [] : trustRepairLines(repair);
|
|
50
148
|
}
|
|
51
149
|
export const LINUX_SANDBOX_TOOLS = [
|
|
52
150
|
{ command: "bwrap", package: "bubblewrap" },
|
|
53
151
|
{ command: "socat", package: "socat" },
|
|
54
152
|
{ command: "rg", package: "ripgrep" },
|
|
153
|
+
{ command: "bash", package: "bash" },
|
|
154
|
+
{ command: "which", package: "which" },
|
|
55
155
|
];
|
|
56
156
|
function toolWords(packages) {
|
|
57
157
|
return packages.length <= 1 ? packages.join("") : `${packages.slice(0, -1).join(", ")} and ${packages.at(-1)}`;
|
|
@@ -69,8 +169,8 @@ export function missingLinuxSandboxTools(path = process.env["PATH"] ?? "") {
|
|
|
69
169
|
});
|
|
70
170
|
return LINUX_SANDBOX_TOOLS.filter(tool => !found(tool.command)).map(tool => tool.package);
|
|
71
171
|
}
|
|
72
|
-
export function linuxSandboxInstallLine(packages = LINUX_SANDBOX_TOOLS.map(tool => tool.package)) {
|
|
73
|
-
return
|
|
172
|
+
export function linuxSandboxInstallLine(packages = LINUX_SANDBOX_TOOLS.map(tool => tool.package), system = packageSystem()) {
|
|
173
|
+
return installLine(packages, system);
|
|
74
174
|
}
|
|
75
175
|
export const linuxSandboxToolsWords = () => toolWords(LINUX_SANDBOX_TOOLS.map(tool => tool.package));
|
|
76
176
|
export function missingSandboxToolsWords(missing) {
|
package/dist/sandbox-tools.js
CHANGED
|
@@ -2,6 +2,9 @@ import { accessSync, constants as fsConstants, existsSync, lstatSync, realpathSy
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { installLine, reinstallLine } from "./linux-packages.js";
|
|
6
|
+
import { hasUnsafeText, shownText } from "./shown-text.js";
|
|
7
|
+
import { mergeRepairs, toolrollPackageRoot, trustFaults, trustFaultWords, trustRepair } from "./trust-repair.js";
|
|
5
8
|
import { platformAcl, rootOwnedBinary, rootOwnedFolders } from "./trusted-path.js";
|
|
6
9
|
export const SANDBOX_TOOL_FOLDERS = ["/usr/bin", "/bin", "/usr/sbin", "/sbin", "/usr/local/bin", "/run/current-system/sw/bin"];
|
|
7
10
|
const SYSTEM_TOOLS = [
|
|
@@ -49,7 +52,7 @@ export function sandboxToolExclusions(terms, cwd) {
|
|
|
49
52
|
return { all: roots([cwd, ...write.allowOnly, ...write.literalAllowOnly ?? [], ...write.denyWithinAllow, ...terms.readConfig.denyOnly]), writes: { allow, deny } };
|
|
50
53
|
}
|
|
51
54
|
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 (
|
|
55
|
+
const installWords = (pkg) => `install ${pkg} from your system package manager (${installLine([pkg])})`;
|
|
53
56
|
function identify(real) {
|
|
54
57
|
try {
|
|
55
58
|
accessSync(real, fsConstants.X_OK);
|
|
@@ -92,6 +95,7 @@ export function resolveLinuxSandboxTools(options = {}) {
|
|
|
92
95
|
let whichFolder = null;
|
|
93
96
|
for (const tool of SYSTEM_TOOLS) {
|
|
94
97
|
const passedOver = [];
|
|
98
|
+
const rejected = [];
|
|
95
99
|
for (const folder of folders) {
|
|
96
100
|
const candidate = join(folder, tool.command);
|
|
97
101
|
if (!existsSync(candidate))
|
|
@@ -99,12 +103,14 @@ export function resolveLinuxSandboxTools(options = {}) {
|
|
|
99
103
|
const checked = checkSystem(candidate, trust, exclusions);
|
|
100
104
|
if (!checked.ok) {
|
|
101
105
|
passedOver.push(`${candidate}: ${checked.why}`);
|
|
106
|
+
rejected.push(candidate);
|
|
102
107
|
continue;
|
|
103
108
|
}
|
|
104
109
|
if (tool.key === "which") {
|
|
105
110
|
const dir = rootOwnedFolders(folder, trust.acl, trust.root);
|
|
106
111
|
if (!dir.ok) {
|
|
107
112
|
passedOver.push(`${candidate}: ${dir.why}`);
|
|
113
|
+
rejected.push(candidate);
|
|
108
114
|
continue;
|
|
109
115
|
}
|
|
110
116
|
whichFolder = dir.real;
|
|
@@ -112,20 +118,28 @@ export function resolveLinuxSandboxTools(options = {}) {
|
|
|
112
118
|
found[tool.key] = checked.tool;
|
|
113
119
|
break;
|
|
114
120
|
}
|
|
121
|
+
if (found[tool.key] === undefined && rejected.length === 0) {
|
|
122
|
+
return { ok: false, failure: "missing", why: shownText(`${tool.words} has no copy owned by root in ${folders.join(", ")}: ${installWords(tool.install)}`) };
|
|
123
|
+
}
|
|
115
124
|
if (found[tool.key] === undefined) {
|
|
116
|
-
return { ok: false,
|
|
125
|
+
return { ok: false, failure: "untrusted", rejected,
|
|
126
|
+
why: shownText(`${tool.words} has no copy Toolroll can trust in ${folders.join(", ")} (${passedOver.join("; ")}): remove a copy your package manager didn't install, or reinstall ${tool.install} (${reinstallLine([tool.install])}); \`toolroll doctor\` says which`) };
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
129
|
const helper = "seccomp" in options ? options.seccomp ?? null : seccompHelperPath();
|
|
120
130
|
if (helper === null)
|
|
121
|
-
return { ok: false, why: `the sandbox runtime's seccomp helper isn't available for this processor (${process.arch})` };
|
|
131
|
+
return { ok: false, failure: "unsupported-arch", why: `the sandbox runtime's seccomp helper isn't available for this processor (${process.arch})` };
|
|
122
132
|
const checked = checkSeccompHelper(helper, exclusions, options);
|
|
123
133
|
if (!checked.ok)
|
|
124
|
-
return { ok: false, why: `the sandbox runtime's seccomp helper (${helper}) can't be trusted: ${checked.why}` };
|
|
134
|
+
return { ok: false, failure: "seccomp-untrusted", rejected: [helper], why: shownText(`the sandbox runtime's seccomp helper (${helper}) can't be trusted: ${checked.why}`) };
|
|
125
135
|
found.seccomp = checked.tool;
|
|
126
136
|
return { ok: true, tools: { ...found, whichFolder: whichFolder } };
|
|
127
137
|
}
|
|
128
138
|
export function verifyLinuxSandboxTools(tools, options = {}) {
|
|
139
|
+
const why = verifyNow(tools, options);
|
|
140
|
+
return why === null ? null : shownText(why);
|
|
141
|
+
}
|
|
142
|
+
function verifyNow(tools, options) {
|
|
129
143
|
const trust = trustOf(options);
|
|
130
144
|
const exclusions = options.exclusions ?? NO_EXCLUSIONS;
|
|
131
145
|
for (const key of KEYS) {
|
|
@@ -150,7 +164,7 @@ export function isLinuxSandboxTools(value) {
|
|
|
150
164
|
if (value === null || typeof value !== "object")
|
|
151
165
|
return false;
|
|
152
166
|
const record = value;
|
|
153
|
-
const path = (one) => typeof one === "string" && one.startsWith("/") &&
|
|
167
|
+
const path = (one) => typeof one === "string" && one.startsWith("/") && !hasUnsafeText(one);
|
|
154
168
|
if (!path(record["whichFolder"]))
|
|
155
169
|
return false;
|
|
156
170
|
return KEYS.every(key => {
|
|
@@ -170,7 +184,78 @@ export function linuxSandboxTools(exclusions = NO_EXCLUSIONS) {
|
|
|
170
184
|
const why = verifyLinuxSandboxTools(tools, { exclusions });
|
|
171
185
|
if (why !== null) {
|
|
172
186
|
discovered = null;
|
|
173
|
-
return { ok: false, why: `a sandbox program failed its check right before the launch: ${why}` };
|
|
187
|
+
return { ok: false, failure: "changed", why: shownText(`a sandbox program failed its check right before the launch: ${why}`) };
|
|
174
188
|
}
|
|
175
189
|
return { ok: true, tools };
|
|
176
190
|
}
|
|
191
|
+
export function seccompHelperRepair(options = {}, packageRoot = toolrollPackageRoot()) {
|
|
192
|
+
const helper = "seccomp" in options ? options.seccomp ?? null : seccompHelperPath();
|
|
193
|
+
if (helper === null || checkSeccompHelper(helper, NO_EXCLUSIONS, options).ok)
|
|
194
|
+
return null;
|
|
195
|
+
const t = trustOf(options);
|
|
196
|
+
const owners = t.codeOwner === undefined ? t.root : [...t.root, t.codeOwner];
|
|
197
|
+
const root = packageRoot;
|
|
198
|
+
const real = realOrSelf(helper);
|
|
199
|
+
let mine = false;
|
|
200
|
+
try {
|
|
201
|
+
mine = root !== null && lstatSync(root).uid === (process.geteuid?.() ?? -1);
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
mine = false;
|
|
205
|
+
}
|
|
206
|
+
return trustRepair(helper, { owners, ownTree: root !== null && mine && insideOrAt(real, root) ? root : null });
|
|
207
|
+
}
|
|
208
|
+
export function sandboxToolsRepair(options = {}, packageRoot = toolrollPackageRoot()) {
|
|
209
|
+
const folders = options.folders ?? SANDBOX_TOOL_FOLDERS;
|
|
210
|
+
const trust = trustOf(options);
|
|
211
|
+
const managed = options.managed ?? fromPackageManager;
|
|
212
|
+
const faults = [];
|
|
213
|
+
const notes = [];
|
|
214
|
+
for (const tool of SYSTEM_TOOLS) {
|
|
215
|
+
const candidates = folders.map(folder => join(folder, tool.command)).filter(candidate => existsSync(candidate));
|
|
216
|
+
const passing = candidates.filter(candidate => checkSystem(candidate, trust, NO_EXCLUSIONS).ok
|
|
217
|
+
&& (tool.key !== "which" || rootOwnedFolders(dirname(candidate), trust.acl, trust.root).ok));
|
|
218
|
+
for (const copy of candidates.filter(candidate => !passing.includes(candidate))) {
|
|
219
|
+
const found = trustFaults(copy, { owners: trust.root }) ?? [];
|
|
220
|
+
faults.push(...found);
|
|
221
|
+
const why = `${shownText(copy)} can't be trusted${found.length === 0 ? "" : ` (${shownText(found.map(trustFaultWords).join("; "))})`}`;
|
|
222
|
+
if (!managed(copy)) {
|
|
223
|
+
notes.push(`${why}: remove it (it isn't from your system package manager, and Toolroll won't run it)${passing.length > 0 ? "." : `, then install ${tool.install}: ${installLine([tool.install])}.`}`);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
notes.push(`${why}: reinstall ${tool.install} so its own files come back (${reinstallLine([tool.install])}), and don't change its permissions by hand.`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const system = faults.length === 0 && notes.length === 0 ? null : { faults, commands: [], notes };
|
|
231
|
+
const protectedPaths = new Set();
|
|
232
|
+
for (const tool of SYSTEM_TOOLS) {
|
|
233
|
+
for (const folder of folders) {
|
|
234
|
+
const copy = join(folder, tool.command);
|
|
235
|
+
if (!existsSync(copy))
|
|
236
|
+
continue;
|
|
237
|
+
for (const start of new Set([copy, realOrSelf(copy)]))
|
|
238
|
+
for (let at = start;; at = dirname(at)) {
|
|
239
|
+
protectedPaths.add(at);
|
|
240
|
+
if (dirname(at) === at)
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const helper = seccompHelperRepair(options, packageRoot);
|
|
246
|
+
const kept = helper === null ? null : { ...helper, commands: helper.commands.filter(command => !touchesProtected(command, protectedPaths)) };
|
|
247
|
+
return mergeRepairs(system, kept);
|
|
248
|
+
}
|
|
249
|
+
function touchesProtected(command, protectedPaths) {
|
|
250
|
+
const quoted = / '((?:[^']|'\\'')*)'$/.exec(command);
|
|
251
|
+
if (quoted === null)
|
|
252
|
+
return true;
|
|
253
|
+
const target = quoted[1].replace(/'\\''/g, "'");
|
|
254
|
+
if (protectedPaths.has(target))
|
|
255
|
+
return true;
|
|
256
|
+
return / -R /.test(command) && [...protectedPaths].some(path => insideOrAt(path, target));
|
|
257
|
+
}
|
|
258
|
+
const PACKAGE_FOLDERS = new Set(["/usr/bin", "/bin", "/usr/sbin", "/sbin", "/run/current-system/sw/bin"]);
|
|
259
|
+
function fromPackageManager(copy) {
|
|
260
|
+
return PACKAGE_FOLDERS.has(dirname(realOrSelf(copy)));
|
|
261
|
+
}
|
|
@@ -232,7 +232,7 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
232
232
|
})),
|
|
233
233
|
attachments: found.attachments.map(toArtifactView),
|
|
234
234
|
ships,
|
|
235
|
-
diff: responseDiff,
|
|
235
|
+
diff: { changedFiles: responseDiff.changedFiles, diffText: responseDiff.diffText, dirty: responseDiff.dirty, ...(responseDiff.unread === true ? { unread: true } : {}) },
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
238
|
async function start(ctx) {
|
|
@@ -595,8 +595,9 @@ export function createDirectChatHandlers(runtime, deps) {
|
|
|
595
595
|
const { thread, turns, diff, running } = found;
|
|
596
596
|
const turnHtml = turns.map(turn => html `<section class="card" data-turn="${turn.id}"><p><b>You</b> · <span class="k-note">${STATUS_WORDS[turn.status] ?? turn.status}</span></p><p class="pre-wrap">${turn.userPrompt}</p>${turn.assistantText.trim() === "" ? "" : html `<p><b>${thread.provider === "claude" ? "Claude" : thread.provider === "codex" ? "Codex" : "Gemini"}</b></p><p class="pre-wrap">${turn.assistantText}</p>`}${turn.errorText === null ? "" : html `<p class="problem">${turn.errorText}</p>`}</section>`);
|
|
597
597
|
const shownDiff = diff.diffText.length > DIFF_SHOWN ? `${diff.diffText.slice(0, DIFF_SHOWN)}\n… (shortened)` : diff.diffText;
|
|
598
|
-
const
|
|
599
|
-
|
|
598
|
+
const unread = diff.unread === true ? html `<p class="k-note" data-direct-chat-diff-unread>Toolroll couldn't read its copy of the project after its last turn${diff.changedFiles.length === 0 ? "" : ", so these are the changes it saw before"}.</p>` : "";
|
|
599
|
+
const changes = diff.changedFiles.length === 0 ? unread !== "" ? unread : html `<p class="k-note">No changes in its copy of the project.</p>`
|
|
600
|
+
: html `${unread}<p class="k-note">${diff.changedFiles.length} ${diff.changedFiles.length === 1 ? "file" : "files"} changed in its own copy of the project, as of its last turn${running ? " (it's still working)" : ""}.</p><ul>${diff.changedFiles.map(file => html `<li class="k-mono">${file}</li>`)}</ul>${shownDiff === "" ? "" : html `<details><summary>The changes</summary><pre class="k-mono" data-direct-chat-diff>${shownDiff}</pre></details>`}`;
|
|
600
601
|
const ships = listDirectChatShips(store, thread.id);
|
|
601
602
|
const bringIn = (one) => {
|
|
602
603
|
if (one.mode !== "keep-branch" || one.state !== "kept" || !/^[0-9a-f]{40}$/.test(one.candidateSha))
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
2
|
import { checklistFromAssignment } from "../merge-checklist.js";
|
|
3
3
|
import { isRevisionFeedback, revisionBatchOf, revisionSourceOf } from "../result-review.js";
|
|
4
|
-
export function mergeReadyViewOf(store, taskId, assignment, who, runChecks, returnTo) {
|
|
4
|
+
export function mergeReadyViewOf(store, taskId, assignment, who, runChecks, returnTo, landed = null, base = null) {
|
|
5
5
|
if (assignment == null || assignment.receipt === null)
|
|
6
6
|
return null;
|
|
7
|
-
const list = checklistFromAssignment(store, taskId, assignment);
|
|
7
|
+
const list = checklistFromAssignment(store, taskId, assignment, landed, base);
|
|
8
|
+
if (list.answer === "landed")
|
|
9
|
+
return null;
|
|
8
10
|
const person = who.via === "cookie" && who.role === "approver" && !store.isDemo();
|
|
9
11
|
const receipt = assignment.receipt;
|
|
10
12
|
const notes = store.liveDiffComments(receipt.runId).filter(one => isRevisionFeedback(one));
|
package/dist/server/pages.js
CHANGED
|
@@ -1308,7 +1308,7 @@ export function createPagesHandlers(runtime, work) {
|
|
|
1308
1308
|
const body = {
|
|
1309
1309
|
version: ENGINE_API_VERSION, project: view.project, projectName: view.projectName, needsCount: view.needsCount, groups: list.groups,
|
|
1310
1310
|
rows: list.rows.map(row => ({ id: row.id, title: row.title, href: row.href, project: row.project, age: row.age, status: row.status, word: row.word, ask: row.ask,
|
|
1311
|
-
chip: row.chip, group: row.group, rank: row.rank, detail: row.detail, problem: row.problem, need: row.need === undefined ? null : needOf(row.need),
|
|
1311
|
+
chip: row.chip, group: row.group, rank: row.rank, ...(row.check === undefined ? {} : { check: row.check }), detail: row.detail, problem: row.problem, need: row.need === undefined ? null : needOf(row.need),
|
|
1312
1312
|
waiting: waiting.get(row.id) ?? null })),
|
|
1313
1313
|
needs: view.needs.map(group => ({ key: group.key, label: group.label, count: group.count, rows: group.rows.map(needOf) })),
|
|
1314
1314
|
next: list.pages.next, room: "workspace", spend, limits,
|
|
@@ -344,6 +344,7 @@ export function workPage(chrome, data) {
|
|
|
344
344
|
id: row.rootId, title: row.title, href: taskHref(row.rootId), project: projectOf(row), age: relativeAge(row.updatedAt, data.now),
|
|
345
345
|
status: { label: row.status.label, tone: row.status.tone, token: row.status.token }, chip: row.chip, word: chip,
|
|
346
346
|
ask: row.ask, group: row.ask ?? (row.status.rank === 1 ? 'building' : 'rest'), rank: row.status.rank,
|
|
347
|
+
...(row.check === undefined ? {} : { check: row.check }),
|
|
347
348
|
action: actionHref === null || row.primaryAction === null || row.ask === null ? null : { label: row.primaryAction.label, href: actionHref },
|
|
348
349
|
detail: needsYouDetail ? row.status.detail : row.progress ?? (row.ask === null && row.status.detail !== row.status.label ? row.status.detail : null),
|
|
349
350
|
problem: row.familyProblem,
|
|
@@ -591,7 +591,7 @@ export function reviewCockpitDetailParts(view, csrf, noted, canRetryReview, tab,
|
|
|
591
591
|
const matrix = proof === null || proof.proofProblem !== null ? [] : proof.matrix;
|
|
592
592
|
const unanswered = accepted || youCheck == null ? [] : youCheck.items.length > 0 ? youCheck.items.map(one => one.statement === "" ? one.words : one.statement) : youCheck.lines;
|
|
593
593
|
const base = !acceptsHere ? null : acceptWordsOf({
|
|
594
|
-
checks: checks === undefined ? null : { passed: "passed", failed: "failed", running: "running", "not-run": "not-run", off: "off", unreadable: "unavailable" }[approvedCheckStateOf(checks)],
|
|
594
|
+
checks: checks === undefined ? null : { passed: "passed", failed: "failed", running: "running", "not-run": "not-run", off: "off", stale: "unavailable", unreadable: "unavailable" }[approvedCheckStateOf(checks)],
|
|
595
595
|
unmet: matrix.filter(row => !["Met", "You check", CHECKED_AT_RELEASE].includes(requirementWordOf(row, null, checks === undefined ? undefined : checkBackingOf(checks)))).length,
|
|
596
596
|
action: complete !== null ? "complete" : "accept",
|
|
597
597
|
publishing: view.detail?.publishing ?? "other",
|
|
@@ -603,7 +603,7 @@ export function reviewCockpitDetailParts(view, csrf, noted, canRetryReview, tab,
|
|
|
603
603
|
const followUps = view.detail.followUps ?? null;
|
|
604
604
|
const checksRunning = checks?.running != null || (followUps?.checks.some(one => one.state === "waiting" || one.state === "running") ?? false);
|
|
605
605
|
const runChecks = canRetryReview && csrf !== "" && followUps !== null && (followUps.full || followUps.quick) && !checksRunning &&
|
|
606
|
-
(checks === undefined || ((checks.status === "not-run" || checks.status === "unavailable") && checks.release == null))
|
|
606
|
+
(checks === undefined || ((checks.status === "not-run" || checks.status === "unavailable" || (checks.status === "failed" && assignment?.state === "complete")) && checks.release == null))
|
|
607
607
|
? { action: `/r/${run.id}/checks`, level: followUps.full ? "full" : "quick", returnTo: at("checks") } : null;
|
|
608
608
|
const need = panel.panel.need;
|
|
609
609
|
const nextKind = selected.next?.kind;
|
|
@@ -1378,7 +1378,7 @@ export function resultPanelParts(detail, o) {
|
|
|
1378
1378
|
}
|
|
1379
1379
|
if (detail.ciFailing && publication !== null && taskStatus === null)
|
|
1380
1380
|
attention.push(`CI is failing on PR #${publication.prNumber} at the last check.`);
|
|
1381
|
-
const personChecks = proof === null || proof.accepted !== null ? [] : [
|
|
1381
|
+
const personChecks = proof === null || proof.accepted !== null || detail.landed === true ? [] : [
|
|
1382
1382
|
...proof.matrix.filter(row => row.state === "manual-review").map(row => personCheckWords(row.statement)),
|
|
1383
1383
|
...(proof.matrix.length > 0 ? [] : proof.reasons.filter(reason => manualReviewCriterionOf(reason) !== null).map(() => personCheckWords(null))),
|
|
1384
1384
|
];
|
|
@@ -1657,9 +1657,9 @@ export function resultPanelParts(detail, o) {
|
|
|
1657
1657
|
views: [{ key: "summary", html: htmlString(joinHtml(summaryParts, "\n")) }, { key: "changes", html: htmlString(joinHtml(changeParts, "\n")) }, { key: "checks", html: htmlString(joinHtml(checkParts, "\n")) }],
|
|
1658
1658
|
history: detail.history === undefined ? "" : htmlString(detail.history),
|
|
1659
1659
|
learning: detail.learning === undefined ? "" : htmlString(detail.learning),
|
|
1660
|
-
request: detail.skillTest ? null : htmlString(joinHtml(requestParts, "\n")),
|
|
1661
|
-
canRequest: detail.canAnnotate && o.csrf !== "",
|
|
1662
|
-
sendBack: detail.skillTest || !detail.canAnnotate || o.csrf === "" ? null
|
|
1660
|
+
request: detail.skillTest || detail.landed === true ? null : htmlString(joinHtml(requestParts, "\n")),
|
|
1661
|
+
canRequest: detail.canAnnotate && o.csrf !== "" && detail.landed !== true,
|
|
1662
|
+
sendBack: detail.skillTest || !detail.canAnnotate || o.csrf === "" || detail.landed === true ? null
|
|
1663
1663
|
: { action: `/r/${runId}/comment`, batch: revisionBatchOf(detail.comments), source: revisionSourceOf(detail.sourceDigest), request: o.requestToken },
|
|
1664
1664
|
need,
|
|
1665
1665
|
requestQuiet: detail.canAnnotate && o.csrf !== "" && detail.comments.length === 0 && (detail.pastComments?.length ?? 0) === 0 && detail.revisions.length === 0,
|
|
@@ -1979,7 +1979,7 @@ export function taskBodyParts(data) {
|
|
|
1979
1979
|
if (data.repo !== null)
|
|
1980
1980
|
work.push({ label: "Project", parts: [projectName(data.repo)] });
|
|
1981
1981
|
if (data.base != null)
|
|
1982
|
-
work.push({ label: "Base", parts: [baseStandingWords(data.base)] });
|
|
1982
|
+
work.push({ label: "Base", parts: [baseStandingWords(data.base, data.landing?.onBranch === true)] });
|
|
1983
1983
|
work.push({ label: "Agent", parts: [lastRunForAgent !== undefined ? `${lastRunForAgent.provider}${lastRunForAgent.model === null ? "" : ` · ${lastRunForAgent.model}`} on ${lastRunForAgent.runner}`
|
|
1984
1984
|
: data.route?.legacy != null ? `${data.route.legacy.provider} · ${data.route.legacy.model}` : "The project's default"] });
|
|
1985
1985
|
if (scope !== null)
|
|
@@ -2150,7 +2150,7 @@ export function taskBodyParts(data) {
|
|
|
2150
2150
|
{ key: "route-change", html: data.routeChange == null ? "" : htmlString(html `<div class="card"><p>${data.routeChange}</p></div>`) },
|
|
2151
2151
|
{ key: "fast-grown", html: data.fastGrown == null || data.csrf === "" ? "" : htmlString(html `<div class="card"><p>${data.fastGrown}</p>${postForm(`${taskHref(task.id)}/keep-grown`, btn("Approve it", { variant: "primary", type: "submit" }))}</div>`) },
|
|
2152
2152
|
{ key: "pull-request", html: fragmentString(pullRequestCard) },
|
|
2153
|
-
{ key: "landing", html: data.landing == null ? "" : htmlString(landingCardHtml(data.landing, data.csrf)) },
|
|
2153
|
+
{ key: data.landing?.onBranch === true ? "landed" : "landing", html: data.landing == null ? "" : htmlString(landingCardHtml(data.landing, data.csrf)) },
|
|
2154
2154
|
{ key: "needs-scope", html: fragmentString(needsScopeCard) },
|
|
2155
2155
|
{ key: "mirror", html: fragmentString(mirrorCard) }, { key: "attempt", html: fragmentString(attemptPanel), ...(liveRunId === null ? {} : { instance: String(liveRunId) }) },
|
|
2156
2156
|
].filter(one => one.html !== ""),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { localOwnerRefusal } from "../local-owner.js";
|
|
2
|
-
import { broughtInOnBranch, keptHandoffOf,
|
|
2
|
+
import { broughtInOnBranch, keptHandoffOf, landingHistoryOf, landingOf, publishesThroughPullRequests } from "../local-landing.js";
|
|
3
3
|
import { requestContext } from "./request-context.js";
|
|
4
4
|
import { heldFindingCount } from "../findings.js";
|
|
5
5
|
import { familyInWebReach } from "../findings.js";
|
|
@@ -21,6 +21,7 @@ import { routeChangeOf } from "../route-change.js";
|
|
|
21
21
|
import { liveAttemptOf, steerControlsFor } from "../steer-controls.js";
|
|
22
22
|
import { originOf } from "../task-source.js";
|
|
23
23
|
import { recentGitReads, taskBaseOf } from "../task-base.js";
|
|
24
|
+
import { landedNowOf } from "../merge-checklist.js";
|
|
24
25
|
import { assignmentPresentationOf, historicalAssessmentReason } from '../assignment-presentation.js';
|
|
25
26
|
import { html, htmlString, joinHtml } from "../html.js";
|
|
26
27
|
import { assignmentStatusOf, assignmentWithEvidence } from '../assignment-ui.js';
|
|
@@ -618,12 +619,12 @@ export function createTaskViews(runtime) {
|
|
|
618
619
|
if (!complete && record === null)
|
|
619
620
|
return null;
|
|
620
621
|
const person = who.via === "cookie" && who.role === "approver";
|
|
621
|
-
const
|
|
622
|
-
if (
|
|
623
|
-
return { taskId: rootId, landed:
|
|
624
|
-
const standing =
|
|
622
|
+
const history = landingHistoryOf(runtime.store, repo, rootId, complete ? assignment?.receipt?.head ?? null : null, baseGit);
|
|
623
|
+
if (history !== null && !history.recorded)
|
|
624
|
+
return { taskId: rootId, landed: history.words, onBranch: true, canLand: false, canUndo: person && !history.reverted && broughtInOnBranch(runtime.store, repo, rootId, baseGit) };
|
|
625
|
+
const standing = history;
|
|
625
626
|
const kept = complete && (record === null || record.undone) ? keptHandoffOf(runtime.store, repo, rootId, assignment?.receipt?.head ?? null) : null;
|
|
626
|
-
return { taskId: rootId, landed: standing?.words ?? null, canLand: person && complete && (record === null || record.undone), canUndo: person && record !== null && !record.undone && standing?.reverted !== true,
|
|
627
|
+
return { taskId: rootId, landed: standing?.words ?? null, onBranch: standing?.landed === true, canLand: person && complete && (record === null || record.undone), canUndo: person && record !== null && !record.undone && standing?.reverted !== true,
|
|
627
628
|
...(kept === null ? {} : { kept }) };
|
|
628
629
|
}
|
|
629
630
|
function failureOf(runs, assignment, readLog = true) {
|
|
@@ -787,7 +788,7 @@ export function createTaskViews(runtime) {
|
|
|
787
788
|
const rootId = family?.root.id ?? taskId;
|
|
788
789
|
const oneTaskView = onePage?.kind === "task" ? { ...onePage, ship: shipViewOf(shipChecksForTask(runtime.store, rootId), runtime.clock()),
|
|
789
790
|
release: releaseStepsViewOf(releaseProgressFor(runtime.store, rootId), runtime.clock()),
|
|
790
|
-
mergeReady: mergeReadyViewOf(runtime.store, taskId, data.assignment, who, presentedData.runChecks ?? null, taskHref(taskId)) } : onePage;
|
|
791
|
+
mergeReady: mergeReadyViewOf(runtime.store, taskId, data.assignment, who, presentedData.runChecks ?? null, taskHref(taskId), landedOf(presentedData), data.base ?? null) } : onePage;
|
|
791
792
|
if (oneTaskView?.kind === "task" && machineChecked(runtime.store, taskId)) {
|
|
792
793
|
const words = machineCheckWords(runtime.store, taskId, data.liveRunId ?? null, oneTaskView.release ?? null, runtime.clock());
|
|
793
794
|
const card = oneTaskView.status;
|
|
@@ -1053,7 +1054,7 @@ export function createTaskViews(runtime) {
|
|
|
1053
1054
|
const assignment = value?.receipt?.runId === run.id && value.activeTaskId === taskId ? freshAssignment(value, receipt) : null;
|
|
1054
1055
|
const completeRefusal = assignment?.state !== "ready-to-check" || assignment.receipt === null ? null
|
|
1055
1056
|
: personCompletionRefusal(runtime.store, assignment.receipt.taskId, run.id, who.via === "cookie" ? who.name : null, runtime.evidenceRoot, who.via === "cookie" && who.authority === "local-owner" ? { rootId: assignment.rootId } : null);
|
|
1056
|
-
return { assignment, completeRefusal };
|
|
1057
|
+
return { assignment, completeRefusal, landed: assignment !== null && landedNowOf(runtime.store, assignment) !== null };
|
|
1057
1058
|
})(),
|
|
1058
1059
|
handoff,
|
|
1059
1060
|
proof,
|
|
@@ -1174,3 +1175,6 @@ export function releaseStepsViewOf(progress, now) {
|
|
|
1174
1175
|
startedAt: progress.startedAt,
|
|
1175
1176
|
};
|
|
1176
1177
|
}
|
|
1178
|
+
function landedOf(data) {
|
|
1179
|
+
return data.landing?.onBranch === true ? data.landing.landed : null;
|
|
1180
|
+
}
|
package/dist/server/tasks.js
CHANGED
|
@@ -94,7 +94,7 @@ import {} from "./session.js";
|
|
|
94
94
|
import { approveReleaseCard, releaseApprovalCard, releaseSheetHref, releaseTaskOf } from "../release-approval.js";
|
|
95
95
|
import { releaseSheetPage } from "./render-release.js";
|
|
96
96
|
import { approvalFactsNow, btn } from "./kit.js";
|
|
97
|
-
import { handoffWords, land, landingWords, publishesThroughPullRequests, PULL_REQUESTS_INSTEAD, readLanding } from "../local-landing.js";
|
|
97
|
+
import { handoffWords, land, landedLine, landingWords, publishesThroughPullRequests, PULL_REQUESTS_INSTEAD, readLanding } from "../local-landing.js";
|
|
98
98
|
import { localActNow, localOwnerRefusal, withLocalAct } from "../local-owner.js";
|
|
99
99
|
import { localChecksRefusal } from "../local-checks.js";
|
|
100
100
|
import { sessionYesPossible } from "./send-back-build.js";
|
|
@@ -2831,7 +2831,7 @@ export function createTasksHandlers(runtime) {
|
|
|
2831
2831
|
return taskScreen(response, who, shown, read.message, 409);
|
|
2832
2832
|
if (!("plan" in read)) {
|
|
2833
2833
|
if (answersInPlace(ctx.request))
|
|
2834
|
-
return answerActInPlace(response, "done", `Already on ${read.landed.ref.replace(/^refs\/heads\//, "")} (${read.landed.commit.slice(0, 7)}).`, 200);
|
|
2834
|
+
return answerActInPlace(response, "done", read.landed.reverted === true ? landedLine(read.landed) : `Already on ${read.landed.ref.replace(/^refs\/heads\//, "")} (${read.landed.commit.slice(0, 7)}).`, 200);
|
|
2835
2835
|
return redirect(response, taskHref(shown));
|
|
2836
2836
|
}
|
|
2837
2837
|
const plan = read.plan;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const UNSAFE = new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\p{Cf}]", "gu");
|
|
2
|
+
const NAMED = { "\n": "\\n", "\r": "\\r", "\t": "\\t" };
|
|
3
|
+
export function shownText(text) {
|
|
4
|
+
return text.replace(UNSAFE, char => {
|
|
5
|
+
const named = NAMED[char];
|
|
6
|
+
if (named !== undefined)
|
|
7
|
+
return named;
|
|
8
|
+
const code = char.codePointAt(0);
|
|
9
|
+
return code <= 0xff ? `\\x${code.toString(16).padStart(2, "0")}` : `\\u${code.toString(16).padStart(4, "0")}`;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export function hasUnsafeText(text) {
|
|
13
|
+
return new RegExp(UNSAFE.source, "u").test(text);
|
|
14
|
+
}
|
package/dist/status-probe.js
CHANGED
|
@@ -2,6 +2,7 @@ import { spawn } from "node:child_process";
|
|
|
2
2
|
import { accessSync, closeSync, constants, existsSync, lstatSync, mkdtempSync, openSync, readSync, realpathSync, rmSync } from "node:fs";
|
|
3
3
|
import { homedir, tmpdir } from "node:os";
|
|
4
4
|
import { delimiter, dirname, isAbsolute, join, resolve, sep } from "node:path";
|
|
5
|
+
import { trustRepair } from "./trust-repair.js";
|
|
5
6
|
import { boundedAcl, trustedBinary, trustedFolders } from "./trusted-path.js";
|
|
6
7
|
export const STATUS_TIMEOUT_MS = 800;
|
|
7
8
|
export const BACKGROUND_STATUS_TIMEOUT_MS = 3_000;
|
|
@@ -341,3 +342,34 @@ export function statusProbe(options = {}) {
|
|
|
341
342
|
}
|
|
342
343
|
};
|
|
343
344
|
}
|
|
345
|
+
export function statusBinaryDiagnosis(binary, trust) {
|
|
346
|
+
const found = resolveLaunch(binary, trust);
|
|
347
|
+
if (found.ok || found.missing)
|
|
348
|
+
return null;
|
|
349
|
+
const firstMatch = (name) => {
|
|
350
|
+
for (const entry of trust.path.split(delimiter)) {
|
|
351
|
+
if (entry === "" || !isAbsolute(entry))
|
|
352
|
+
continue;
|
|
353
|
+
try {
|
|
354
|
+
accessSync(join(entry, name), constants.X_OK);
|
|
355
|
+
return { folder: entry, file: join(entry, name) };
|
|
356
|
+
}
|
|
357
|
+
catch { }
|
|
358
|
+
}
|
|
359
|
+
return null;
|
|
360
|
+
};
|
|
361
|
+
const paths = [];
|
|
362
|
+
const first = firstMatch(binary);
|
|
363
|
+
if (first !== null) {
|
|
364
|
+
paths.push(first.folder, first.file);
|
|
365
|
+
const real = realOrNull(first.file);
|
|
366
|
+
if (real !== null && isScript(real)) {
|
|
367
|
+
paths.push(packageFolderOf(real));
|
|
368
|
+
const bang = shebangOf(real);
|
|
369
|
+
const interpreter = bang === null ? null : bang.kind === "absolute" ? { folder: dirname(bang.path), file: bang.path } : firstMatch(bang.name);
|
|
370
|
+
if (interpreter !== null)
|
|
371
|
+
paths.push(interpreter.folder, interpreter.file);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return { why: found.why, repair: trust.uid === undefined || paths.length === 0 ? null : trustRepair(paths, { owners: [trust.uid, 0], stickyAbove: true }) };
|
|
375
|
+
}
|
package/dist/task-base.js
CHANGED
|
@@ -9,9 +9,9 @@ export const readGit = (cwd, args) => {
|
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
11
|
const commits = (count) => `${count} commit${count === 1 ? "" : "s"}`;
|
|
12
|
-
export function baseStandingWords(view) {
|
|
12
|
+
export function baseStandingWords(view, landed = false) {
|
|
13
13
|
const short = view.family === true ? `Whole change since ${view.base.slice(0, 8)} (includes earlier attempts' work that's still in it)` : view.base.slice(0, 8);
|
|
14
|
-
if (view.main === null || view.behind === null)
|
|
14
|
+
if (landed || view.main === null || view.behind === null)
|
|
15
15
|
return short;
|
|
16
16
|
return view.behind === 0 ? `${short} · Up to date with ${view.main}` : `${short} · Behind ${view.main} by ${commits(view.behind)}`;
|
|
17
17
|
}
|