@theokit/sdk 5.12.1 → 5.13.0
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 +40 -0
- package/dist/{agent-IG7BP6GN.js → agent-5DSDDH7K.js} +5 -5
- package/dist/{agent-IG7BP6GN.js.map → agent-5DSDDH7K.js.map} +1 -1
- package/dist/{agent-CVzDy_Oj.d.ts → agent-DSMuwADp.d.ts} +9 -2
- package/dist/{agent-BVKIUP7F.cjs → agent-WOMRT3KX.cjs} +6 -6
- package/dist/{agent-BVKIUP7F.cjs.map → agent-WOMRT3KX.cjs.map} +1 -1
- package/dist/{agent-Cn0sphpA.d.cts → agent-iW5kPpfT.d.cts} +9 -2
- package/dist/{chunk-XJ4C4NFX.js → chunk-2PRGRYEQ.js} +61 -47
- package/dist/chunk-2PRGRYEQ.js.map +1 -0
- package/dist/{chunk-HN4IKB6X.cjs → chunk-2XWAYCFM.cjs} +15 -13
- package/dist/chunk-2XWAYCFM.cjs.map +1 -0
- package/dist/{chunk-VVGFZQZC.js → chunk-3LMVJTNJ.js} +9 -5
- package/dist/chunk-3LMVJTNJ.js.map +1 -0
- package/dist/{chunk-IO4RI5ZJ.cjs → chunk-47EACDOC.cjs} +4 -4
- package/dist/{chunk-IO4RI5ZJ.cjs.map → chunk-47EACDOC.cjs.map} +1 -1
- package/dist/{chunk-LSWHDOCL.cjs → chunk-4UYHP6NF.cjs} +64 -48
- package/dist/chunk-4UYHP6NF.cjs.map +1 -0
- package/dist/{chunk-ZLFFDPXC.js → chunk-73IITAF7.js} +36 -14
- package/dist/chunk-73IITAF7.js.map +1 -0
- package/dist/{chunk-XRPMZ7TO.js → chunk-CYWOJA6B.js} +6 -4
- package/dist/chunk-CYWOJA6B.js.map +1 -0
- package/dist/{chunk-AQW54OWQ.js → chunk-DFBWYETS.js} +5 -3
- package/dist/chunk-DFBWYETS.js.map +1 -0
- package/dist/{chunk-YOVZMN4P.cjs → chunk-DVP3YMDA.cjs} +3 -3
- package/dist/{chunk-YOVZMN4P.cjs.map → chunk-DVP3YMDA.cjs.map} +1 -1
- package/dist/{chunk-EPANMGH7.cjs → chunk-FLDHYF5C.cjs} +11 -2
- package/dist/chunk-FLDHYF5C.cjs.map +1 -0
- package/dist/{chunk-BJ7BPLQK.js → chunk-JX4LB6XO.js} +124 -13
- package/dist/chunk-JX4LB6XO.js.map +1 -0
- package/dist/{chunk-Q6WT5535.cjs → chunk-KL7ZUMK3.cjs} +161 -50
- package/dist/chunk-KL7ZUMK3.cjs.map +1 -0
- package/dist/{chunk-FEAWEBWN.cjs → chunk-PDOXYXWX.cjs} +6 -4
- package/dist/chunk-PDOXYXWX.cjs.map +1 -0
- package/dist/{chunk-NBNRQN6T.js → chunk-QGDPMM3C.js} +11 -2
- package/dist/chunk-QGDPMM3C.js.map +1 -0
- package/dist/{chunk-ZWLFHSON.cjs → chunk-R35ZJAYT.cjs} +38 -15
- package/dist/chunk-R35ZJAYT.cjs.map +1 -0
- package/dist/{chunk-4YD2WI57.cjs → chunk-R427EOZE.cjs} +19 -15
- package/dist/chunk-R427EOZE.cjs.map +1 -0
- package/dist/{chunk-TLVI2OQK.cjs → chunk-SETHRLQS.cjs} +18 -2
- package/dist/chunk-SETHRLQS.cjs.map +1 -0
- package/dist/{chunk-BO3PV3OP.js → chunk-TDED5XES.js} +18 -3
- package/dist/chunk-TDED5XES.js.map +1 -0
- package/dist/{chunk-4GUFNDZR.js → chunk-XOYNB3YN.js} +3 -3
- package/dist/{chunk-4GUFNDZR.js.map → chunk-XOYNB3YN.js.map} +1 -1
- package/dist/{chunk-NJBJ3CUG.js → chunk-ZTP6ZACR.js} +3 -3
- package/dist/{chunk-NJBJ3CUG.js.map → chunk-ZTP6ZACR.js.map} +1 -1
- package/dist/{compact-session-3U2JYTVG.js → compact-session-5HMX6KYT.js} +3 -3
- package/dist/{compact-session-3U2JYTVG.js.map → compact-session-5HMX6KYT.js.map} +1 -1
- package/dist/{compact-session-NM56BREJ.cjs → compact-session-B7P6EU3Z.cjs} +12 -12
- package/dist/{compact-session-NM56BREJ.cjs.map → compact-session-B7P6EU3Z.cjs.map} +1 -1
- package/dist/{cron-BWDYetbq.d.cts → cron-BvxrLW5J.d.cts} +1 -1
- package/dist/{cron-CHn-F0fC.d.ts → cron-DdKzwJqK.d.ts} +1 -1
- package/dist/cron.cjs +5 -5
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +4 -4
- package/dist/eval.cjs +9 -9
- package/dist/eval.js +4 -4
- package/dist/{executor-HKHT4CWS.cjs → executor-5QL5AXIZ.cjs} +18 -15
- package/dist/executor-5QL5AXIZ.cjs.map +1 -0
- package/dist/{executor-3D2UDJHW.js → executor-THUXNAFR.js} +6 -3
- package/dist/executor-THUXNAFR.js.map +1 -0
- package/dist/generate-object-A5F576IT.cjs +20 -0
- package/dist/{generate-object-XBWD2PU7.cjs.map → generate-object-A5F576IT.cjs.map} +1 -1
- package/dist/{generate-object-S7MNVF2V.js → generate-object-TBDOBBYW.js} +4 -4
- package/dist/{generate-object-S7MNVF2V.js.map → generate-object-TBDOBBYW.js.map} +1 -1
- package/dist/generate-object.d.ts +14 -1
- package/dist/index.cjs +43 -43
- package/dist/index.d.cts +30 -4
- package/dist/index.d.ts +30 -4
- package/dist/index.js +13 -13
- package/dist/{inject-session-THABTKJY.js → inject-session-75L3NCNL.js} +3 -3
- package/dist/{inject-session-THABTKJY.js.map → inject-session-75L3NCNL.js.map} +1 -1
- package/dist/{inject-session-JVTZNQF6.cjs → inject-session-WOH7TPDX.cjs} +4 -4
- package/dist/{inject-session-JVTZNQF6.cjs.map → inject-session-WOH7TPDX.cjs.map} +1 -1
- package/dist/internal/providers/discovery.d.ts +2 -2
- package/dist/internal/providers/trust-gate.d.ts +35 -0
- package/dist/internal/runtime/plugin-loader/manifest-entry-import.d.ts +17 -0
- package/dist/internal/runtime/plugin-loader/workspace-plugin-trust.d.ts +16 -0
- package/dist/internal/structured-output-helpers.d.ts +5 -2
- package/dist/sandbox/bwrap.d.cts +10 -8
- package/dist/sandbox/bwrap.d.ts +10 -8
- package/dist/sandbox/deny-read.d.cts +24 -0
- package/dist/sandbox/deny-read.d.ts +24 -0
- package/dist/sandbox/index.cjs +114 -35
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.d.cts +2 -1
- package/dist/sandbox/index.d.ts +2 -1
- package/dist/sandbox/index.js +96 -21
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/linux-sandbox.d.cts +16 -1
- package/dist/sandbox/linux-sandbox.d.ts +16 -1
- package/dist/sandbox/local-sandbox.d.cts +3 -1
- package/dist/sandbox/local-sandbox.d.ts +3 -1
- package/dist/sandbox/seccomp-delivery.d.cts +3 -0
- package/dist/sandbox/seccomp-delivery.d.ts +3 -0
- package/dist/sandbox/shell-escape.d.cts +14 -2
- package/dist/sandbox/shell-escape.d.ts +14 -2
- package/dist/sandbox/types.d.cts +45 -0
- package/dist/sandbox/types.d.ts +45 -0
- package/dist/stream-object-AS4YYM4B.cjs +20 -0
- package/dist/{stream-object-TEEK3CAX.cjs.map → stream-object-AS4YYM4B.cjs.map} +1 -1
- package/dist/stream-object-EKM4WGTI.js +7 -0
- package/dist/{stream-object-R6SMYV4R.js.map → stream-object-EKM4WGTI.js.map} +1 -1
- package/dist/stream-object.d.ts +14 -1
- package/dist/subagents-loader.d.cts +1 -1
- package/dist/subagents-loader.d.ts +1 -1
- package/dist/types/agent.d.ts +8 -1
- package/dist/workflow-as-tool.d.ts +39 -5
- package/dist/workflow-errors.d.ts +16 -0
- package/dist/workflow.cjs +31 -23
- package/dist/workflow.d.cts +54 -4
- package/dist/workflow.d.ts +54 -4
- package/dist/workflow.js +2 -2
- package/docs/error-codes.md +16 -13
- package/docs/harness-capability-map.md +50 -4
- package/package.json +1 -1
- package/dist/chunk-4YD2WI57.cjs.map +0 -1
- package/dist/chunk-AQW54OWQ.js.map +0 -1
- package/dist/chunk-BJ7BPLQK.js.map +0 -1
- package/dist/chunk-BO3PV3OP.js.map +0 -1
- package/dist/chunk-EPANMGH7.cjs.map +0 -1
- package/dist/chunk-FEAWEBWN.cjs.map +0 -1
- package/dist/chunk-HN4IKB6X.cjs.map +0 -1
- package/dist/chunk-LSWHDOCL.cjs.map +0 -1
- package/dist/chunk-NBNRQN6T.js.map +0 -1
- package/dist/chunk-Q6WT5535.cjs.map +0 -1
- package/dist/chunk-TLVI2OQK.cjs.map +0 -1
- package/dist/chunk-VVGFZQZC.js.map +0 -1
- package/dist/chunk-XJ4C4NFX.js.map +0 -1
- package/dist/chunk-XRPMZ7TO.js.map +0 -1
- package/dist/chunk-ZLFFDPXC.js.map +0 -1
- package/dist/chunk-ZWLFHSON.cjs.map +0 -1
- package/dist/executor-3D2UDJHW.js.map +0 -1
- package/dist/executor-HKHT4CWS.cjs.map +0 -1
- package/dist/generate-object-XBWD2PU7.cjs +0 -20
- package/dist/stream-object-R6SMYV4R.js +0 -7
- package/dist/stream-object-TEEK3CAX.cjs +0 -20
package/dist/sandbox/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkFLDHYF5C_cjs = require('../chunk-FLDHYF5C.cjs');
|
|
4
4
|
require('../chunk-2ZPEDVLM.cjs');
|
|
5
5
|
var chunkCEGU5AVD_cjs = require('../chunk-CEGU5AVD.cjs');
|
|
6
6
|
var chunkRNXXYF22_cjs = require('../chunk-RNXXYF22.cjs');
|
|
@@ -13,6 +13,64 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
13
13
|
|
|
14
14
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
15
15
|
|
|
16
|
+
var KEPT_ROOTS_ALWAYS = ["/tmp"];
|
|
17
|
+
function isSameOrInside(outer, inner) {
|
|
18
|
+
const rel = path__default.default.relative(outer, inner);
|
|
19
|
+
return rel === "" || !rel.startsWith("..") && !path__default.default.isAbsolute(rel);
|
|
20
|
+
}
|
|
21
|
+
function resolveEntry(entry) {
|
|
22
|
+
if (!path__default.default.isAbsolute(entry)) {
|
|
23
|
+
throw new TypeError(`denyReadPaths: "${entry}" is not an absolute path`);
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
return fs.realpathSync(entry);
|
|
27
|
+
} catch (cause) {
|
|
28
|
+
throw new TypeError(`denyReadPaths: "${entry}" cannot be resolved: ${String(cause)}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function keptRoots(cwd) {
|
|
32
|
+
let real = cwd;
|
|
33
|
+
try {
|
|
34
|
+
real = fs.realpathSync(cwd);
|
|
35
|
+
} catch {
|
|
36
|
+
}
|
|
37
|
+
return [.../* @__PURE__ */ new Set([cwd, real, ...KEPT_ROOTS_ALWAYS])];
|
|
38
|
+
}
|
|
39
|
+
function denyReadFlags(paths, policy) {
|
|
40
|
+
if (paths === void 0 || paths.length === 0) return [];
|
|
41
|
+
if (policy.mode === "danger-full-access") {
|
|
42
|
+
throw new TypeError(
|
|
43
|
+
"denyReadPaths cannot be honoured under danger-full-access: no sandbox is applied"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
const roots = keptRoots(policy.cwd);
|
|
47
|
+
const resolved = /* @__PURE__ */ new Set();
|
|
48
|
+
for (const entry of paths) {
|
|
49
|
+
const target = resolveEntry(entry);
|
|
50
|
+
const covered = roots.find((root) => isSameOrInside(target, root));
|
|
51
|
+
if (covered !== void 0) {
|
|
52
|
+
throw new TypeError(
|
|
53
|
+
`denyReadPaths: "${entry}" would hide "${covered}", which the command needs`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
resolved.add(target);
|
|
57
|
+
}
|
|
58
|
+
return [...resolved].flatMap(
|
|
59
|
+
(target) => fs.statSync(target).isDirectory() ? ["--tmpfs", target] : ["--ro-bind", "/dev/null", target]
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
function refuseUnhonourableDenyRead(paths, mode, detect) {
|
|
63
|
+
if (paths === void 0 || paths.length === 0) return;
|
|
64
|
+
if (mode === "danger-full-access") denyReadFlags(paths, { mode, cwd: "/" });
|
|
65
|
+
const detection = detect();
|
|
66
|
+
if (!detection.ok) {
|
|
67
|
+
throw new chunkFLDHYF5C_cjs.SandboxNotAvailableError(
|
|
68
|
+
`denyReadPaths needs kernel confinement and it is unavailable (${detection.reason}); refusing to run unconfined`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/sandbox/bwrap.ts
|
|
16
74
|
function pushWorkspaceBinds(argv, cwd, hasGit, gitDir) {
|
|
17
75
|
for (const root of workspaceWriteRoots(cwd)) argv.push("--bind", root, root);
|
|
18
76
|
if (hasGit) argv.push("--ro-bind", gitDir, gitDir);
|
|
@@ -31,8 +89,9 @@ function writableRootsFor(mode, cwd) {
|
|
|
31
89
|
}
|
|
32
90
|
}
|
|
33
91
|
function buildBwrapArgv(mode, opts) {
|
|
34
|
-
if (mode === "danger-full-access") return null;
|
|
35
92
|
const cwd = path__default.default.resolve(opts.cwd);
|
|
93
|
+
const denyFlags = denyReadFlags(opts.denyReadPaths, { mode, cwd });
|
|
94
|
+
if (mode === "danger-full-access") return null;
|
|
36
95
|
const gitDir = path__default.default.join(cwd, ".git");
|
|
37
96
|
const hasGit = opts.gitDirExists ?? fs.existsSync(gitDir);
|
|
38
97
|
const argv = [
|
|
@@ -59,6 +118,7 @@ function buildBwrapArgv(mode, opts) {
|
|
|
59
118
|
};
|
|
60
119
|
for (const [k, v] of Object.entries(setenv)) argv.push("--setenv", k, v);
|
|
61
120
|
if (mode === "workspace-write") pushWorkspaceBinds(argv, cwd, hasGit, gitDir);
|
|
121
|
+
argv.push(...denyFlags);
|
|
62
122
|
argv.push("--chdir", cwd, "--");
|
|
63
123
|
return argv;
|
|
64
124
|
}
|
|
@@ -243,17 +303,17 @@ var PIPE_SCRIPT = '{ p=$1; shift; printf "$p" | exec "$@" 3<&0 0<&4 4<&-; } 4<&0
|
|
|
243
303
|
function wrapWithSeccompProgram(bwrapArgv, command, program) {
|
|
244
304
|
assertSeccompProgramShape(program);
|
|
245
305
|
const words = [octalPrintfArg(program), ...bwrapArgv, "--seccomp", "3", "--", "/bin/sh", "-c"];
|
|
246
|
-
return `exec /bin/sh -c ${
|
|
306
|
+
return `exec /bin/sh -c ${chunkFLDHYF5C_cjs.shellEscapePosix(PIPE_SCRIPT)} sh ${[...words, command].map(chunkFLDHYF5C_cjs.shellEscapePosix).join(" ")}`;
|
|
247
307
|
}
|
|
248
308
|
var programsWritten = /* @__PURE__ */ new Map();
|
|
249
|
-
function rememberSeccompFile(
|
|
250
|
-
programsWritten.set(path.resolve(
|
|
309
|
+
function rememberSeccompFile(path3, program) {
|
|
310
|
+
programsWritten.set(path.resolve(path3), Buffer.from(program));
|
|
251
311
|
}
|
|
252
312
|
function removeDirOnExit(dir) {
|
|
253
313
|
const cleanup = () => fs.rmSync(dir, { recursive: true, force: true });
|
|
254
314
|
process.once("exit", cleanup);
|
|
255
315
|
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
256
|
-
process.
|
|
316
|
+
process.prependOnceListener(signal, () => {
|
|
257
317
|
cleanup();
|
|
258
318
|
if (process.listenerCount(signal) === 0) process.kill(process.pid, signal);
|
|
259
319
|
});
|
|
@@ -268,7 +328,7 @@ function wrapWithSeccompPath(bwrapArgv, policy, command, seccompPath) {
|
|
|
268
328
|
...bwrapArgv.slice(-3, -1)
|
|
269
329
|
];
|
|
270
330
|
if (program !== void 0) return wrapWithSeccompProgram(flags, command, program);
|
|
271
|
-
return `${[...flags, "--seccomp", "3", "--"].map(
|
|
331
|
+
return `${[...flags, "--seccomp", "3", "--"].map(chunkFLDHYF5C_cjs.shellEscapePosix).join(" ")} /bin/sh -c ${chunkFLDHYF5C_cjs.shellEscapePosix(command)} 3< ${chunkFLDHYF5C_cjs.shellEscapePosix(seccompPath)}`;
|
|
272
332
|
}
|
|
273
333
|
function readOnlyBindForSeccompPath(mode, cwd, seccompPath, bind) {
|
|
274
334
|
const file = path.resolve(seccompPath);
|
|
@@ -281,14 +341,14 @@ function readOnlyBindForSeccompPath(mode, cwd, seccompPath, bind) {
|
|
|
281
341
|
|
|
282
342
|
// src/sandbox/linux-sandbox.ts
|
|
283
343
|
function wrapCommandForSandbox(mode, opts, command) {
|
|
284
|
-
const argv = buildBwrapArgv(mode,
|
|
344
|
+
const argv = buildBwrapArgv(mode, opts);
|
|
285
345
|
if (argv === null) return null;
|
|
286
346
|
const bin = opts.bin ?? "bwrap";
|
|
287
347
|
if (opts.seccompProgram !== void 0) {
|
|
288
348
|
return wrapWithSeccompProgram([bin, ...argv.slice(0, -1)], command, opts.seccompProgram);
|
|
289
349
|
}
|
|
290
350
|
if (opts.seccompPath === void 0) {
|
|
291
|
-
return `${[bin, ...argv].map(
|
|
351
|
+
return `${[bin, ...argv].map(chunkFLDHYF5C_cjs.shellEscapePosix).join(" ")} /bin/sh -c ${chunkFLDHYF5C_cjs.shellEscapePosix(command)}`;
|
|
292
352
|
}
|
|
293
353
|
return wrapWithSeccompPath([bin, ...argv], { mode, cwd: opts.cwd }, command, opts.seccompPath);
|
|
294
354
|
}
|
|
@@ -311,7 +371,7 @@ function allowlistedEnv(source = process.env) {
|
|
|
311
371
|
}
|
|
312
372
|
return out;
|
|
313
373
|
}
|
|
314
|
-
var LinuxSandbox = class extends
|
|
374
|
+
var LinuxSandbox = class extends chunkFLDHYF5C_cjs.LocalSandbox {
|
|
315
375
|
mode;
|
|
316
376
|
network;
|
|
317
377
|
cwd;
|
|
@@ -321,14 +381,25 @@ var LinuxSandbox = class extends chunkEPANMGH7_cjs.LocalSandbox {
|
|
|
321
381
|
* confined command could replace). `undefined` when the network is unrestricted or the arch is not
|
|
322
382
|
* x86_64 (honest fallback). */
|
|
323
383
|
seccompProgram;
|
|
384
|
+
denyReadPaths;
|
|
385
|
+
/**
|
|
386
|
+
* `"none"` exactly when the wrap passes `--unshare-net` (see `buildBwrapArgv`): a confined mode and
|
|
387
|
+
* `network` not set. With `network: true`, or under `danger-full-access` where nothing is wrapped,
|
|
388
|
+
* the command reaches whatever the host does.
|
|
389
|
+
*/
|
|
390
|
+
networkPolicy;
|
|
391
|
+
/** `denyReadPaths`: see `BwrapArgvOptions`; a list that cannot be honoured throws `TypeError` here. */
|
|
324
392
|
constructor(config, opts) {
|
|
325
393
|
super(config);
|
|
326
394
|
this.mode = opts.mode;
|
|
327
395
|
this.network = opts.network ?? false;
|
|
396
|
+
this.networkPolicy = this.network || this.mode === "danger-full-access" ? { mode: "unrestricted" } : { mode: "none" };
|
|
328
397
|
this.cwd = config.workDir ?? process.cwd();
|
|
329
398
|
this.bin = opts.bin ?? "bwrap";
|
|
330
399
|
this.env = opts.env ?? allowlistedEnv();
|
|
331
400
|
this.seccompProgram = seccompProgramForNetwork(this.network);
|
|
401
|
+
this.denyReadPaths = opts.denyReadPaths;
|
|
402
|
+
denyReadFlags(this.denyReadPaths, { mode: this.mode, cwd: this.cwd });
|
|
332
403
|
}
|
|
333
404
|
/** Extracted for test visibility — delegates to the pure `wrapCommandForSandbox` (M57, single wrap SoT). */
|
|
334
405
|
wrapCommand(command) {
|
|
@@ -339,7 +410,8 @@ var LinuxSandbox = class extends chunkEPANMGH7_cjs.LocalSandbox {
|
|
|
339
410
|
network: this.network,
|
|
340
411
|
env: this.env,
|
|
341
412
|
bin: this.bin,
|
|
342
|
-
seccompProgram: this.seccompProgram
|
|
413
|
+
seccompProgram: this.seccompProgram,
|
|
414
|
+
denyReadPaths: this.denyReadPaths
|
|
343
415
|
},
|
|
344
416
|
command
|
|
345
417
|
);
|
|
@@ -357,12 +429,12 @@ var LinuxSandbox = class extends chunkEPANMGH7_cjs.LocalSandbox {
|
|
|
357
429
|
* policy as everything else — if bwrap denies the path, the write fails, as it should. The content
|
|
358
430
|
* goes over stdin (not argv) because argv has a size limit and file content does not.
|
|
359
431
|
*/
|
|
360
|
-
async uploadFile(
|
|
361
|
-
if (this.mode === "danger-full-access") return super.uploadFile(
|
|
362
|
-
const target =
|
|
432
|
+
async uploadFile(path3, content) {
|
|
433
|
+
if (this.mode === "danger-full-access") return super.uploadFile(path3, content);
|
|
434
|
+
const target = path3.startsWith("/") ? path3 : `${this.cwd}/${path3}`;
|
|
363
435
|
const b64 = Buffer.from(content).toString("base64");
|
|
364
436
|
const r = await this.execute(
|
|
365
|
-
`mkdir -p ${
|
|
437
|
+
`mkdir -p ${chunkFLDHYF5C_cjs.shellEscapePosix(path.dirname(target))} && printf %s ${chunkFLDHYF5C_cjs.shellEscapePosix(b64)} | base64 -d > ${chunkFLDHYF5C_cjs.shellEscapePosix(target)}`
|
|
366
438
|
);
|
|
367
439
|
if (r.exitCode !== 0) {
|
|
368
440
|
throw new Error(
|
|
@@ -387,12 +459,12 @@ function seccompPathForArch(arch, warn) {
|
|
|
387
459
|
}
|
|
388
460
|
try {
|
|
389
461
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "ab-seccomp-"));
|
|
390
|
-
const
|
|
462
|
+
const path3 = path.join(dir, "filter.bpf");
|
|
391
463
|
const program = buildSeccompFilter({ networkRestricted: true });
|
|
392
|
-
fs.writeFileSync(
|
|
393
|
-
rememberSeccompFile(
|
|
464
|
+
fs.writeFileSync(path3, program);
|
|
465
|
+
rememberSeccompFile(path3, program);
|
|
394
466
|
removeDirOnExit(dir);
|
|
395
|
-
return
|
|
467
|
+
return path3;
|
|
396
468
|
} catch (err) {
|
|
397
469
|
warn(
|
|
398
470
|
`[sandbox] seccomp filter unavailable (${err instanceof Error ? err.message : String(err)}) \u2014 running without syscall filter (bwrap FS/network confinement still applies).`
|
|
@@ -403,9 +475,9 @@ function seccompPathForArch(arch, warn) {
|
|
|
403
475
|
var seccompFilterPath;
|
|
404
476
|
function restrictedSeccompPath() {
|
|
405
477
|
if (seccompFilterPath !== void 0) return seccompFilterPath ?? void 0;
|
|
406
|
-
const
|
|
407
|
-
seccompFilterPath =
|
|
408
|
-
return
|
|
478
|
+
const path3 = seccompPathForArch(process.arch, (m) => console.warn(chunkRNXXYF22_cjs.redactSecrets(m)));
|
|
479
|
+
seccompFilterPath = path3 ?? null;
|
|
480
|
+
return path3;
|
|
409
481
|
}
|
|
410
482
|
var warnedUnavailable = false;
|
|
411
483
|
function __resetSandboxWarnLatchForTests() {
|
|
@@ -423,7 +495,8 @@ function resolveSandboxPosture(opts) {
|
|
|
423
495
|
}
|
|
424
496
|
function createSandboxBackend(opts) {
|
|
425
497
|
const config = { workDir: opts.workDir, timeoutMs: opts.timeoutMs };
|
|
426
|
-
|
|
498
|
+
refuseUnhonourableDenyRead(opts.denyReadPaths, opts.mode, opts.detect ?? detectBwrapMemoized);
|
|
499
|
+
if (opts.mode === "danger-full-access") return new chunkFLDHYF5C_cjs.LocalSandbox(config);
|
|
427
500
|
const detection = (opts.detect ?? detectBwrapMemoized)();
|
|
428
501
|
if (!detection.ok) {
|
|
429
502
|
if (!warnedUnavailable) {
|
|
@@ -433,9 +506,9 @@ function createSandboxBackend(opts) {
|
|
|
433
506
|
`[sandbox] OS-level enforcement unavailable (${detection.reason}) \u2014 falling back to tool-level gating only (sandbox_mode=${opts.mode}).`
|
|
434
507
|
);
|
|
435
508
|
}
|
|
436
|
-
return new
|
|
509
|
+
return new chunkFLDHYF5C_cjs.LocalSandbox(config);
|
|
437
510
|
}
|
|
438
|
-
return new LinuxSandbox(config, {
|
|
511
|
+
return new LinuxSandbox(config, { ...opts, bin: detection.bin });
|
|
439
512
|
}
|
|
440
513
|
var interactiveWarned = false;
|
|
441
514
|
function __resetInteractiveWarnLatchForTests() {
|
|
@@ -445,6 +518,7 @@ function seccompProgramForNetwork(networkOpen) {
|
|
|
445
518
|
return networkOpen ? void 0 : restrictedSeccompProgram((m) => console.warn(chunkRNXXYF22_cjs.redactSecrets(m)));
|
|
446
519
|
}
|
|
447
520
|
function decideConfinement(opts) {
|
|
521
|
+
refuseUnhonourableDenyRead(opts.denyReadPaths, opts.mode, opts.detect ?? detectBwrapMemoized);
|
|
448
522
|
if (opts.mode === "danger-full-access") return null;
|
|
449
523
|
const detection = (opts.detect ?? detectBwrapMemoized)();
|
|
450
524
|
if (detection.ok) return detection.bin;
|
|
@@ -468,7 +542,8 @@ function interactiveWrapCommand(opts) {
|
|
|
468
542
|
network: opts.network ?? false,
|
|
469
543
|
env: allowlistedEnv(),
|
|
470
544
|
bin,
|
|
471
|
-
seccompProgram: seccompProgramForNetwork(opts.network ?? false)
|
|
545
|
+
seccompProgram: seccompProgramForNetwork(opts.network ?? false),
|
|
546
|
+
denyReadPaths: opts.denyReadPaths
|
|
472
547
|
},
|
|
473
548
|
command
|
|
474
549
|
);
|
|
@@ -490,7 +565,7 @@ var RepoProvisionError = class extends chunkCEGU5AVD_cjs.TheokitAgentError {
|
|
|
490
565
|
};
|
|
491
566
|
var SAFE_INSTANCE_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
492
567
|
async function provisionRepo(sandboxOrOpts, maybeOpts) {
|
|
493
|
-
const sandbox = maybeOpts !== void 0 ? sandboxOrOpts : new
|
|
568
|
+
const sandbox = maybeOpts !== void 0 ? sandboxOrOpts : new chunkFLDHYF5C_cjs.LocalSandbox();
|
|
494
569
|
const opts = maybeOpts ?? sandboxOrOpts;
|
|
495
570
|
const { repoUrl, ref, instanceId } = opts;
|
|
496
571
|
if (!SAFE_INSTANCE_ID.test(instanceId)) {
|
|
@@ -503,20 +578,20 @@ async function provisionRepo(sandboxOrOpts, maybeOpts) {
|
|
|
503
578
|
throw new RepoProvisionError(instanceId, `invalid ref: must not begin with '-' (got ${ref})`);
|
|
504
579
|
}
|
|
505
580
|
const clone = await sandbox.execute(
|
|
506
|
-
`git -c protocol.ext.allow=never clone --quiet -- ${
|
|
581
|
+
`git -c protocol.ext.allow=never clone --quiet -- ${chunkFLDHYF5C_cjs.shellEscapePosix(repoUrl)} ${chunkFLDHYF5C_cjs.shellEscapePosix(instanceId)}`
|
|
507
582
|
);
|
|
508
583
|
if (clone.exitCode !== 0) {
|
|
509
584
|
throw new RepoProvisionError(instanceId, `clone failed: ${clone.stderr.trim()}`);
|
|
510
585
|
}
|
|
511
586
|
const top = await sandbox.execute(
|
|
512
|
-
`git -C ${
|
|
587
|
+
`git -C ${chunkFLDHYF5C_cjs.shellEscapePosix(instanceId)} rev-parse --show-toplevel`
|
|
513
588
|
);
|
|
514
589
|
if (top.exitCode !== 0) {
|
|
515
590
|
throw new RepoProvisionError(instanceId, `resolve repoDir failed: ${top.stderr.trim()}`);
|
|
516
591
|
}
|
|
517
592
|
const repoDir = top.stdout.trim();
|
|
518
593
|
const checkout = await sandbox.execute(
|
|
519
|
-
`git -C ${
|
|
594
|
+
`git -C ${chunkFLDHYF5C_cjs.shellEscapePosix(repoDir)} checkout --quiet ${chunkFLDHYF5C_cjs.shellEscapePosix(ref)}`
|
|
520
595
|
);
|
|
521
596
|
if (checkout.exitCode !== 0) {
|
|
522
597
|
throw new RepoProvisionError(instanceId, `checkout ${ref} failed: ${checkout.stderr.trim()}`);
|
|
@@ -526,23 +601,27 @@ async function provisionRepo(sandboxOrOpts, maybeOpts) {
|
|
|
526
601
|
|
|
527
602
|
Object.defineProperty(exports, "LocalSandbox", {
|
|
528
603
|
enumerable: true,
|
|
529
|
-
get: function () { return
|
|
604
|
+
get: function () { return chunkFLDHYF5C_cjs.LocalSandbox; }
|
|
530
605
|
});
|
|
531
606
|
Object.defineProperty(exports, "SandboxBackend", {
|
|
532
607
|
enumerable: true,
|
|
533
|
-
get: function () { return
|
|
608
|
+
get: function () { return chunkFLDHYF5C_cjs.SandboxBackend; }
|
|
534
609
|
});
|
|
535
610
|
Object.defineProperty(exports, "SandboxNotAvailableError", {
|
|
536
611
|
enumerable: true,
|
|
537
|
-
get: function () { return
|
|
612
|
+
get: function () { return chunkFLDHYF5C_cjs.SandboxNotAvailableError; }
|
|
538
613
|
});
|
|
539
614
|
Object.defineProperty(exports, "SandboxSecurityError", {
|
|
540
615
|
enumerable: true,
|
|
541
|
-
get: function () { return
|
|
616
|
+
get: function () { return chunkFLDHYF5C_cjs.SandboxSecurityError; }
|
|
542
617
|
});
|
|
543
618
|
Object.defineProperty(exports, "resolveSandbox", {
|
|
544
619
|
enumerable: true,
|
|
545
|
-
get: function () { return
|
|
620
|
+
get: function () { return chunkFLDHYF5C_cjs.resolveSandbox; }
|
|
621
|
+
});
|
|
622
|
+
Object.defineProperty(exports, "shellEscapePosix", {
|
|
623
|
+
enumerable: true,
|
|
624
|
+
get: function () { return chunkFLDHYF5C_cjs.shellEscapePosix; }
|
|
546
625
|
});
|
|
547
626
|
exports.LinuxSandbox = LinuxSandbox;
|
|
548
627
|
exports.RepoProvisionError = RepoProvisionError;
|