@kitman-sh/cli 0.10.90 → 0.10.92
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/dist/{chunk-yx90ye72.js → chunk-0cbdb51w.js} +7 -7
- package/dist/{chunk-xb70ys3n.js → chunk-25q7mg6g.js} +17 -17
- package/dist/{chunk-e8zm8z3a.js → chunk-2ndnvcp3.js} +8 -8
- package/dist/{chunk-jq8hhvdv.js → chunk-5qmjv3n4.js} +8 -8
- package/dist/{chunk-5vsqzmvf.js → chunk-5s6e82wd.js} +5 -5
- package/dist/{chunk-py4t32pa.js → chunk-63mhk3ft.js} +110 -108
- package/dist/{chunk-dd5aa39j.js → chunk-8zhjaef4.js} +263 -34
- package/dist/{chunk-fq47a5yd.js → chunk-9m9cv82t.js} +2 -2
- package/dist/{chunk-j9frwmmt.js → chunk-a7zc3zf8.js} +3 -3
- package/dist/{chunk-75d425rk.js → chunk-bjdn0pww.js} +4 -4
- package/dist/{chunk-76ctrqm6.js → chunk-c3k32vw4.js} +1 -1
- package/dist/{chunk-x11j5jcj.js → chunk-cb4z73yk.js} +35 -27
- package/dist/{chunk-jbwk6k6m.js → chunk-dstm8aen.js} +71 -28
- package/dist/{chunk-62565d52.js → chunk-hsf2sj69.js} +2 -2
- package/dist/{chunk-tzz4fv17.js → chunk-k4fvnphp.js} +1 -1
- package/dist/{chunk-bbvvx5z1.js → chunk-kd3y2tq5.js} +19 -19
- package/dist/{chunk-mgmsx0bm.js → chunk-m4ac8xka.js} +7 -7
- package/dist/{chunk-kgdppbdr.js → chunk-mbqeakm1.js} +1 -1
- package/dist/{chunk-ky974pcr.js → chunk-rmsm8vnc.js} +4 -4
- package/dist/{chunk-rq6bn96v.js → chunk-vsb31vgf.js} +5 -5
- package/dist/{chunk-0gs7cjkt.js → chunk-vzhkp7xw.js} +4 -4
- package/dist/{chunk-m1ewm9dy.js → chunk-vzynb4qs.js} +25 -25
- package/dist/{chunk-98sg1yyd.js → chunk-w0sehmpd.js} +14 -60
- package/dist/{chunk-9zd52pda.js → chunk-yzmyy4vs.js} +5 -5
- package/dist/index.js +4 -4
- package/package.json +1 -1
|
@@ -6,11 +6,12 @@ import {
|
|
|
6
6
|
isObject,
|
|
7
7
|
isJsonObject,
|
|
8
8
|
isString
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-k4fvnphp.js";
|
|
10
10
|
import {
|
|
11
11
|
pipeArguments,
|
|
12
12
|
dual,
|
|
13
13
|
identity,
|
|
14
|
+
hasProperty,
|
|
14
15
|
isTagged,
|
|
15
16
|
isUint8Array,
|
|
16
17
|
PipeInspectableProto,
|
|
@@ -46,7 +47,7 @@ import {
|
|
|
46
47
|
isFailure2,
|
|
47
48
|
hasInterrupts,
|
|
48
49
|
makeUnsafe5,
|
|
49
|
-
|
|
50
|
+
make15,
|
|
50
51
|
_await,
|
|
51
52
|
fail5,
|
|
52
53
|
isDoneUnsafe,
|
|
@@ -129,6 +130,7 @@ import {
|
|
|
129
130
|
fnUntraced,
|
|
130
131
|
logWarning,
|
|
131
132
|
logError,
|
|
133
|
+
logInfo,
|
|
132
134
|
is,
|
|
133
135
|
decodeUnknownEffect2,
|
|
134
136
|
decodeEffect,
|
|
@@ -165,12 +167,12 @@ import {
|
|
|
165
167
|
encodePrettyJsonString,
|
|
166
168
|
decodeJsonStringSync,
|
|
167
169
|
encodeUnknownJsonStringSync
|
|
168
|
-
} from "./chunk-
|
|
170
|
+
} from "./chunk-dstm8aen.js";
|
|
169
171
|
import {
|
|
170
172
|
Id,
|
|
171
173
|
secretReference,
|
|
172
174
|
secretPlaceholder
|
|
173
|
-
} from "./chunk-
|
|
175
|
+
} from "./chunk-mbqeakm1.js";
|
|
174
176
|
import {
|
|
175
177
|
currentTimeMillis,
|
|
176
178
|
SecureRandom,
|
|
@@ -243,7 +245,7 @@ import {
|
|
|
243
245
|
installCommand,
|
|
244
246
|
checkServicesFile,
|
|
245
247
|
checkServices
|
|
246
|
-
} from "./chunk-
|
|
248
|
+
} from "./chunk-63mhk3ft.js";
|
|
247
249
|
import {
|
|
248
250
|
join,
|
|
249
251
|
interrupt,
|
|
@@ -252,7 +254,7 @@ import {
|
|
|
252
254
|
unbounded2,
|
|
253
255
|
offer,
|
|
254
256
|
makeUnsafe3,
|
|
255
|
-
|
|
257
|
+
make10,
|
|
256
258
|
fromQueue,
|
|
257
259
|
fromPubSub,
|
|
258
260
|
map2,
|
|
@@ -283,7 +285,7 @@ import {
|
|
|
283
285
|
writeSrtSettings2,
|
|
284
286
|
srtStepArgv2,
|
|
285
287
|
srtArgv2
|
|
286
|
-
} from "./chunk-
|
|
288
|
+
} from "./chunk-25q7mg6g.js";
|
|
287
289
|
import {
|
|
288
290
|
writeAgentEnvironmentConfigFile2,
|
|
289
291
|
readManifestSkillPaths2,
|
|
@@ -299,8 +301,8 @@ import {
|
|
|
299
301
|
applyAgentEnvironmentMaterialization2,
|
|
300
302
|
isPathWithin2,
|
|
301
303
|
skillIdentity2
|
|
302
|
-
} from "./chunk-
|
|
303
|
-
import"./chunk-
|
|
304
|
+
} from "./chunk-5s6e82wd.js";
|
|
305
|
+
import"./chunk-a7zc3zf8.js";
|
|
304
306
|
import {
|
|
305
307
|
egressAllowed,
|
|
306
308
|
writeSecretRegistry,
|
|
@@ -310,7 +312,7 @@ import {
|
|
|
310
312
|
secretFilter2,
|
|
311
313
|
opaqueTunnelRefusal2,
|
|
312
314
|
isOpaqueConnectReason2
|
|
313
|
-
} from "./chunk-
|
|
315
|
+
} from "./chunk-hsf2sj69.js";
|
|
314
316
|
import {
|
|
315
317
|
sliceBytes2,
|
|
316
318
|
maxLineBytes2,
|
|
@@ -318,23 +320,23 @@ import {
|
|
|
318
320
|
decodedOption2,
|
|
319
321
|
decoded2,
|
|
320
322
|
readOpencode2
|
|
321
|
-
} from "./chunk-
|
|
323
|
+
} from "./chunk-2ndnvcp3.js";
|
|
322
324
|
import {
|
|
323
325
|
uploadRunFile,
|
|
324
326
|
programLease,
|
|
325
327
|
rpcRunFiles,
|
|
326
328
|
programHostsEnv,
|
|
327
329
|
undeclaredHostsEnv
|
|
328
|
-
} from "./chunk-
|
|
329
|
-
import"./chunk-
|
|
330
|
+
} from "./chunk-vzhkp7xw.js";
|
|
331
|
+
import"./chunk-m4ac8xka.js";
|
|
330
332
|
import {
|
|
331
333
|
nextInt
|
|
332
|
-
} from "./chunk-
|
|
334
|
+
} from "./chunk-c3k32vw4.js";
|
|
333
335
|
import {
|
|
334
336
|
ChildProcessSpawner,
|
|
335
|
-
|
|
336
|
-
} from "./chunk-
|
|
337
|
-
import"./chunk-
|
|
337
|
+
make2
|
|
338
|
+
} from "./chunk-w0sehmpd.js";
|
|
339
|
+
import"./chunk-vsb31vgf.js";
|
|
338
340
|
|
|
339
341
|
// packages/core/src/sync-kit.ts
|
|
340
342
|
import { createHash } from "crypto";
|
|
@@ -3682,6 +3684,219 @@ var stepSecretRegistry = (directory, initial, references) => gen(function* () {
|
|
|
3682
3684
|
};
|
|
3683
3685
|
});
|
|
3684
3686
|
|
|
3687
|
+
// packages/agent-runtime/src/step-processes.ts
|
|
3688
|
+
var stepAttemptVariable = "KITMAN_STEP_ATTEMPT";
|
|
3689
|
+
var stepRunnerVariable = "KITMAN_STEP_RUNNER";
|
|
3690
|
+
var listSeparator = ":";
|
|
3691
|
+
var listing = (outer, id) => {
|
|
3692
|
+
const ids = (outer ?? "").split(listSeparator).filter((candidate) => candidate !== "" && candidate !== id);
|
|
3693
|
+
return [...ids, id].join(listSeparator);
|
|
3694
|
+
};
|
|
3695
|
+
var stepProcessEnvironment = (runnerId, attemptId, outer = process.env) => ({
|
|
3696
|
+
[stepRunnerVariable]: listing(outer[stepRunnerVariable], runnerId),
|
|
3697
|
+
[stepAttemptVariable]: listing(outer[stepAttemptVariable], attemptId)
|
|
3698
|
+
});
|
|
3699
|
+
var lists = (value, id) => value.split(listSeparator).includes(id);
|
|
3700
|
+
var signalProcess = (pid, signal) => ignore(try_2(() => process.kill(pid, signal)));
|
|
3701
|
+
var signalled = (pid) => try_2(() => process.kill(pid, 0)).pipe(as(true), catch_((error) => succeed6(hasProperty(error.cause, "code") && error.cause.code === "EPERM")));
|
|
3702
|
+
var procCommand = (fs, pid) => map8(fs.readFile(`/proc/${pid}/cmdline`).pipe(orElseSucceed(() => new Uint8Array)), commandLine);
|
|
3703
|
+
var procProcessTable = map8(FileSystem, (fs) => ({
|
|
3704
|
+
marked: ({ name, value }) => gen(function* () {
|
|
3705
|
+
const prefix = `${name}=`;
|
|
3706
|
+
const pids = (yield* fs.readDirectory("/proc").pipe(orElseSucceed(() => []))).filter((pid) => /^\d+$/.test(pid));
|
|
3707
|
+
const found = yield* forEach(pids, (pid) => fs.readFile(`/proc/${pid}/environ`).pipe(flatMap3((environ) => environEntries(environ).some((entry) => entry.startsWith(prefix) && lists(entry.slice(prefix.length), value)) ? map8(procCommand(fs, Number(pid)), (command) => [{ pid: Number(pid), command }]) : succeed6([])), orElseSucceed(() => [])), { concurrency: 16 });
|
|
3708
|
+
return found.flat();
|
|
3709
|
+
}),
|
|
3710
|
+
signal: signalProcess,
|
|
3711
|
+
alive: (pid) => fs.readFileString(`/proc/${pid}/stat`).pipe(map8((stat) => !/^[ZX]/.test(stat.slice(stat.lastIndexOf(")") + 2))), orElseSucceed(() => false))
|
|
3712
|
+
}));
|
|
3713
|
+
var environEntries = (environ) => new TextDecoder().decode(environ).split("\x00");
|
|
3714
|
+
var commandLine = (cmdline) => new TextDecoder().decode(cmdline).split("\x00").filter((part) => part !== "").join(" ");
|
|
3715
|
+
var psRows = (listed) => listed.split(`
|
|
3716
|
+
`).flatMap((line) => {
|
|
3717
|
+
const matched = /^\s*(\d+)\s+(.*)$/.exec(line);
|
|
3718
|
+
return matched === null ? [] : [{ pid: Number(matched[1]), text: matched[2] ?? "" }];
|
|
3719
|
+
});
|
|
3720
|
+
var psProcessTable = map8(ChildProcessSpawner, (spawner) => {
|
|
3721
|
+
const ps = (args) => runCommand2("ps", [...args, "-ww", "-U", String(process.getuid?.() ?? ""), "-o", "pid=,command="], {
|
|
3722
|
+
timeout: "30 seconds"
|
|
3723
|
+
}).pipe(provideService(ChildProcessSpawner, spawner), map8(psRows));
|
|
3724
|
+
return {
|
|
3725
|
+
marked: ({ name, value }) => gen(function* () {
|
|
3726
|
+
const entry = ` ${name}=`;
|
|
3727
|
+
const pids = (yield* ps(["-E"])).flatMap(({ pid, text }) => {
|
|
3728
|
+
const at = text.lastIndexOf(entry);
|
|
3729
|
+
if (at < 0)
|
|
3730
|
+
return [];
|
|
3731
|
+
const listed = text.slice(at + entry.length).split(" ")[0] ?? "";
|
|
3732
|
+
return lists(listed, value) ? [pid] : [];
|
|
3733
|
+
});
|
|
3734
|
+
if (pids.length === 0)
|
|
3735
|
+
return [];
|
|
3736
|
+
const commands = new Map((yield* ps([])).map(({ pid, text }) => [pid, text]));
|
|
3737
|
+
return pids.flatMap((pid) => {
|
|
3738
|
+
const command = commands.get(pid);
|
|
3739
|
+
return command === undefined ? [] : [{ pid, command }];
|
|
3740
|
+
});
|
|
3741
|
+
}).pipe(orElseSucceed(() => [])),
|
|
3742
|
+
signal: signalProcess,
|
|
3743
|
+
alive: signalled
|
|
3744
|
+
};
|
|
3745
|
+
});
|
|
3746
|
+
var systemProcessTable = process.platform === "linux" ? procProcessTable : psProcessTable;
|
|
3747
|
+
var unitPart = (id) => id.replaceAll(/[^A-Za-z0-9-]/g, (char) => `_${char.charCodeAt(0).toString(16)}`);
|
|
3748
|
+
var unitPrefix = (runnerId, attemptId) => `kitman-step-${unitPart(runnerId)}.${attemptId === undefined ? "" : `${unitPart(attemptId)}.`}`;
|
|
3749
|
+
var unitSuffix = SecureRandom.pipe(flatMap3((random) => random.uuidV4()), map8((uuid) => uuid.slice(0, 8)), provide3(layerWebCrypto));
|
|
3750
|
+
var busVariables = ["XDG_RUNTIME_DIR", "DBUS_SESSION_BUS_ADDRESS"];
|
|
3751
|
+
var systemdScopes = gen(function* () {
|
|
3752
|
+
if (process.platform !== "linux")
|
|
3753
|
+
return;
|
|
3754
|
+
const fs = yield* FileSystem;
|
|
3755
|
+
const spawner = yield* ChildProcessSpawner;
|
|
3756
|
+
const systemd = (command, args) => runCommand2(command, args, { timeout: "30 seconds" }).pipe(provideService(ChildProcessSpawner, spawner));
|
|
3757
|
+
const usable = yield* systemd("systemd-run", ["--user", "--scope", "--quiet", "--collect", "--", "true"]).pipe(as(true), catch_((error) => as(logWarning("step_scopes_unavailable", error), false)));
|
|
3758
|
+
if (!usable)
|
|
3759
|
+
return;
|
|
3760
|
+
const bus = Object.entries(yield* inheritedEnvironment2(busVariables)).map(([name, value]) => `${name}=${value}`);
|
|
3761
|
+
const cgroupProcesses = (cgroup) => gen(function* () {
|
|
3762
|
+
const root = `/sys/fs/cgroup${cgroup}`;
|
|
3763
|
+
const nested = (yield* fs.readDirectory(root, { recursive: true }).pipe(orElseSucceed(() => []))).filter((entry) => entry.endsWith("/cgroup.procs")).map((entry) => `${root}/${entry}`);
|
|
3764
|
+
const pids = yield* forEach([`${root}/cgroup.procs`, ...nested], (file) => fs.readFileString(file).pipe(orElseSucceed(() => "")));
|
|
3765
|
+
return pids.flatMap((text) => text.split(`
|
|
3766
|
+
`).filter((pid) => /^\d+$/.test(pid))).map(Number);
|
|
3767
|
+
});
|
|
3768
|
+
return {
|
|
3769
|
+
contain: (runnerId, attemptId, argv) => map8(unitSuffix, (suffix) => {
|
|
3770
|
+
const unit = `${unitPrefix(runnerId, attemptId)}${suffix}.scope`;
|
|
3771
|
+
const scoped = [
|
|
3772
|
+
"systemd-run",
|
|
3773
|
+
"--user",
|
|
3774
|
+
"--scope",
|
|
3775
|
+
"--quiet",
|
|
3776
|
+
"--collect",
|
|
3777
|
+
`--unit=${unit}`,
|
|
3778
|
+
`--description=Kitman StepAttempt ${attemptId}`,
|
|
3779
|
+
"--",
|
|
3780
|
+
...argv
|
|
3781
|
+
];
|
|
3782
|
+
return bus.length === 0 ? scoped : ["env", ...bus, ...scoped];
|
|
3783
|
+
}),
|
|
3784
|
+
processes: (runnerId, attemptId) => gen(function* () {
|
|
3785
|
+
const units = (yield* systemd("systemctl", [
|
|
3786
|
+
"--user",
|
|
3787
|
+
"list-units",
|
|
3788
|
+
"--all",
|
|
3789
|
+
"--plain",
|
|
3790
|
+
"--no-legend",
|
|
3791
|
+
"--type=scope",
|
|
3792
|
+
`${unitPrefix(runnerId, attemptId)}*`
|
|
3793
|
+
])).split(`
|
|
3794
|
+
`).flatMap((line) => line.trim().split(/\s+/)[0] ?? []).filter((unit) => unit.endsWith(".scope"));
|
|
3795
|
+
const pids = yield* forEach(units, (unit) => flatMap3(systemd("systemctl", ["--user", "show", "--property=ControlGroup", "--value", unit]), (cgroup) => cgroup.trim() === "" ? succeed6([]) : cgroupProcesses(cgroup.trim())));
|
|
3796
|
+
return yield* forEach([...new Set(pids.flat())], (pid) => map8(procCommand(fs, pid), (command) => ({ pid, command })));
|
|
3797
|
+
}).pipe(orElseSucceed(() => []))
|
|
3798
|
+
};
|
|
3799
|
+
});
|
|
3800
|
+
var reapRounds = 3;
|
|
3801
|
+
var problemText = (text) => text.length <= 500 ? text : `${text.slice(0, 499)}\u2026`;
|
|
3802
|
+
var makeStepProcesses = (table, options = {}) => {
|
|
3803
|
+
const { scopes } = options;
|
|
3804
|
+
const unreaped = new Map;
|
|
3805
|
+
const pollMs = options.pollMs ?? 50;
|
|
3806
|
+
const finding = (marker, scoped) => map8(all3([table.marked(marker), scoped]), ([marked, inScopes]) => {
|
|
3807
|
+
const found = new Map([...marked, ...inScopes].map((candidate) => [candidate.pid, candidate]));
|
|
3808
|
+
found.delete(process.pid);
|
|
3809
|
+
return [...found.values()];
|
|
3810
|
+
});
|
|
3811
|
+
const running = (processes) => filter3(processes, ({ pid }) => table.alive(pid));
|
|
3812
|
+
const outlasting = (processes, graceMs) => gen(function* () {
|
|
3813
|
+
const deadline = (yield* currentTimeMillis) + graceMs;
|
|
3814
|
+
let left = processes;
|
|
3815
|
+
while (left.length > 0 && (yield* currentTimeMillis) < deadline) {
|
|
3816
|
+
yield* sleep(pollMs);
|
|
3817
|
+
left = yield* running(left);
|
|
3818
|
+
}
|
|
3819
|
+
return left;
|
|
3820
|
+
});
|
|
3821
|
+
const stop = (processes) => gen(function* () {
|
|
3822
|
+
yield* forEach(processes, ({ pid }) => table.signal(pid, "SIGTERM"), { discard: true });
|
|
3823
|
+
const stubborn = yield* outlasting(processes, options.termGraceMs ?? 2000);
|
|
3824
|
+
yield* forEach(stubborn, ({ pid }) => table.signal(pid, "SIGKILL"), { discard: true });
|
|
3825
|
+
return yield* outlasting(stubborn, options.killGraceMs ?? 1000);
|
|
3826
|
+
});
|
|
3827
|
+
const reap = (key, find) => gen(function* () {
|
|
3828
|
+
const seen = new Set;
|
|
3829
|
+
let stopped = 0;
|
|
3830
|
+
for (let round = 0;round < reapRounds; round += 1) {
|
|
3831
|
+
const found = (yield* find).filter((candidate) => !seen.has(candidate.pid));
|
|
3832
|
+
if (found.length === 0)
|
|
3833
|
+
continue;
|
|
3834
|
+
for (const candidate of found)
|
|
3835
|
+
seen.add(candidate.pid);
|
|
3836
|
+
const left = yield* stop(found);
|
|
3837
|
+
stopped += found.length - left.length;
|
|
3838
|
+
}
|
|
3839
|
+
const left = yield* running(yield* find);
|
|
3840
|
+
if (seen.size > 0)
|
|
3841
|
+
yield* logInfo("step_processes_reaped", { of: key, stopped, left: left.length });
|
|
3842
|
+
if (left.length > 0) {
|
|
3843
|
+
yield* logWarning("step_processes_unreaped", {
|
|
3844
|
+
of: key,
|
|
3845
|
+
processes: left.map(({ pid, command }) => `${pid} ${command}`)
|
|
3846
|
+
});
|
|
3847
|
+
unreaped.set(key, { find, left });
|
|
3848
|
+
}
|
|
3849
|
+
return left;
|
|
3850
|
+
});
|
|
3851
|
+
const problems = gen(function* () {
|
|
3852
|
+
for (const [key, entry] of unreaped) {
|
|
3853
|
+
entry.left = yield* running(yield* entry.find);
|
|
3854
|
+
if (entry.left.length === 0)
|
|
3855
|
+
unreaped.delete(key);
|
|
3856
|
+
else
|
|
3857
|
+
yield* forEach(entry.left, ({ pid }) => table.signal(pid, "SIGKILL"), { discard: true });
|
|
3858
|
+
}
|
|
3859
|
+
const left = [
|
|
3860
|
+
...new Map([...unreaped.values()].flatMap((entry) => entry.left.map((stuck) => [stuck.pid, stuck]))).values()
|
|
3861
|
+
];
|
|
3862
|
+
if (left.length === 0)
|
|
3863
|
+
return [];
|
|
3864
|
+
return [
|
|
3865
|
+
{
|
|
3866
|
+
code: "processes_unreaped",
|
|
3867
|
+
message: problemText(`${left.length} ${left.length === 1 ? "process" : "processes"} a finished Step started could not be stopped: ${left.map(({ pid, command }) => `${pid} ${command.slice(0, 80)}`).join("; ")}`),
|
|
3868
|
+
fix: problemText(`Find out why ${left.length === 1 ? "it ignores" : "they ignore"} \`SIGKILL\`, such as waiting on a hung disk or network mount, or run by another user, as through \`sudo\`, and stop ${left.length === 1 ? "it" : "them"} on the Runner's host: \`sudo kill -9 ${left.map(({ pid }) => pid).join(" ")}\``)
|
|
3869
|
+
}
|
|
3870
|
+
];
|
|
3871
|
+
});
|
|
3872
|
+
const none = succeed6([]);
|
|
3873
|
+
return {
|
|
3874
|
+
scoped: scopes !== undefined,
|
|
3875
|
+
contain: (runnerId, attemptId, argv) => scopes === undefined ? succeed6(argv) : scopes.contain(runnerId, attemptId, argv),
|
|
3876
|
+
reapAttempt: (runnerId, attemptId) => reap(`attempt ${attemptId}`, finding({ name: stepAttemptVariable, value: attemptId }, scopes === undefined ? none : scopes.processes(runnerId, attemptId))),
|
|
3877
|
+
reapRunner: (runnerId) => reap(`runner ${runnerId}`, finding({ name: stepRunnerVariable, value: runnerId }, scopes === undefined ? none : scopes.processes(runnerId))),
|
|
3878
|
+
problems
|
|
3879
|
+
};
|
|
3880
|
+
};
|
|
3881
|
+
var stepProcessesUncontained = (input) => {
|
|
3882
|
+
const platform = input.platform ?? process.platform;
|
|
3883
|
+
if (input.scoped || input.sandbox === "docker" || input.sandbox === "srt" && platform === "linux")
|
|
3884
|
+
return;
|
|
3885
|
+
return {
|
|
3886
|
+
code: "processes_uncontained",
|
|
3887
|
+
message: `Agents run on \`${input.sandbox}\` without a systemd user scope, so a process one starts in a session of its own with a cleared environment outlives its Step unseen.`,
|
|
3888
|
+
fix: platform === "linux" ? "Run the Runner where `systemd-run --user --scope true` works, such as after `loginctl enable-linger`, or set `KITMAN_RUNNER_SANDBOX=srt` or `docker`." : "Set `KITMAN_RUNNER_SANDBOX=docker`, or run the Runner on Linux."
|
|
3889
|
+
};
|
|
3890
|
+
};
|
|
3891
|
+
|
|
3892
|
+
class StepProcesses extends Service2()("StepProcesses") {
|
|
3893
|
+
}
|
|
3894
|
+
var stepProcessesLayer = effect(StepProcesses, map8(systemProcessTable, (table) => makeStepProcesses(table)));
|
|
3895
|
+
var systemStepProcessesLayer = effect(StepProcesses, gen(function* () {
|
|
3896
|
+
const table = yield* systemProcessTable;
|
|
3897
|
+
return makeStepProcesses(table, { scopes: yield* systemdScopes });
|
|
3898
|
+
}));
|
|
3899
|
+
|
|
3685
3900
|
// packages/agent-runtime/src/herdr-core-agent-backend.ts
|
|
3686
3901
|
var launchTimeout = "120 seconds";
|
|
3687
3902
|
var briefTries = 3;
|
|
@@ -3887,6 +4102,7 @@ var runAttempt = (request, options) => gen(function* () {
|
|
|
3887
4102
|
launch
|
|
3888
4103
|
});
|
|
3889
4104
|
const harnessArgv = [launch.binary, ...launch.args];
|
|
4105
|
+
const marker = stepProcessEnvironment(request.runnerId, attempt.id);
|
|
3890
4106
|
const sandboxed = gen(function* () {
|
|
3891
4107
|
switch (request.sandbox.backend) {
|
|
3892
4108
|
case "srt": {
|
|
@@ -3921,7 +4137,8 @@ var runAttempt = (request, options) => gen(function* () {
|
|
|
3921
4137
|
...yield* inheritedEnvironment2(srtInheritedEnv2),
|
|
3922
4138
|
...loginReferences,
|
|
3923
4139
|
...policy.environment,
|
|
3924
|
-
...srtCacheEnvironment2(`${configDir}/cache`)
|
|
4140
|
+
...srtCacheEnvironment2(`${configDir}/cache`),
|
|
4141
|
+
...marker
|
|
3925
4142
|
};
|
|
3926
4143
|
return {
|
|
3927
4144
|
argv: withOnlyEnvironment2([...Object.keys(env), "TERM", "COLORTERM"], registry === undefined ? srtArgv2(options.srtCommand ?? pinnedSrtCommand2(), settingsFile, harnessArgv) : srtStepArgv2(options.srtStepCommand ?? pinnedSrtStepCommand2(), settingsFile, registry.file, harnessArgv)),
|
|
@@ -3973,15 +4190,12 @@ var runAttempt = (request, options) => gen(function* () {
|
|
|
3973
4190
|
command: ["sh", "-c", 'p=$(command -v -- "$1") && [ -f "$p" ] && [ -x "$p" ]', "sh", command],
|
|
3974
4191
|
timeout: "30 seconds"
|
|
3975
4192
|
}).pipe(map8((result) => result.exitCode === 0), mapError2(() => unavailable)));
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
env: policy.environment,
|
|
3979
|
-
registry
|
|
3980
|
-
};
|
|
4193
|
+
const env = { ...policy.environment, ...marker };
|
|
4194
|
+
return { argv: dockerExecArgv({ container, workspace, env, argv: harnessArgv }), env, registry };
|
|
3981
4195
|
}
|
|
3982
4196
|
default:
|
|
3983
4197
|
yield* requireKitCommands(kitSetup, runsOnHost);
|
|
3984
|
-
const env = { ...yield* inheritedEnvironment2(["SSH_AUTH_SOCK"]), ...policy.environment };
|
|
4198
|
+
const env = { ...yield* inheritedEnvironment2(["SSH_AUTH_SOCK"]), ...policy.environment, ...marker };
|
|
3985
4199
|
return { argv: harnessArgv, env, registry: undefined };
|
|
3986
4200
|
}
|
|
3987
4201
|
});
|
|
@@ -4003,8 +4217,10 @@ var runAttempt = (request, options) => gen(function* () {
|
|
|
4003
4217
|
if (isFailure(command))
|
|
4004
4218
|
return failed(command.failure.reason, command.failure.summary);
|
|
4005
4219
|
const call = requester(options.core, yield* scope2);
|
|
4220
|
+
const argv = yield* options.stepProcesses.contain(request.runnerId, attempt.id, command.success.argv);
|
|
4006
4221
|
const run = (connection) => connection.run({
|
|
4007
4222
|
...command.success,
|
|
4223
|
+
argv,
|
|
4008
4224
|
cwd: workspace,
|
|
4009
4225
|
noParent: true,
|
|
4010
4226
|
labels: {
|
|
@@ -4113,7 +4329,7 @@ var runAttempt = (request, options) => gen(function* () {
|
|
|
4113
4329
|
return yield* judge(ended.value);
|
|
4114
4330
|
});
|
|
4115
4331
|
return yield* ensuring2(drive, stop);
|
|
4116
|
-
}).pipe(ensuring2(request.workspace.cleanup === undefined ? void_3 : ignore(request.workspace.cleanup)), scoped);
|
|
4332
|
+
}).pipe(ensuring2(asVoid(options.stepProcesses.reapAttempt(request.runnerId, request.attempt.attempt.id))), ensuring2(request.workspace.cleanup === undefined ? void_3 : ignore(request.workspace.cleanup)), scoped);
|
|
4117
4333
|
var herdrCoreAgentBackendLayer = (options) => effect(AgentBackend, gen(function* () {
|
|
4118
4334
|
const core = yield* HerdrCore2;
|
|
4119
4335
|
const fs = yield* FileSystem;
|
|
@@ -4133,7 +4349,8 @@ var herdrCoreAgentBackendLayer = (options) => effect(AgentBackend, gen(function*
|
|
|
4133
4349
|
...options.srtStepCommand === undefined ? undefined : { srtStepCommand: options.srtStepCommand },
|
|
4134
4350
|
secretRevocationMs: options.secretRevocationMs ?? 30000,
|
|
4135
4351
|
...options.srtBinaries === undefined ? undefined : { srtBinaries: options.srtBinaries },
|
|
4136
|
-
...options.docker === undefined ? undefined : { docker: options.docker }
|
|
4352
|
+
...options.docker === undefined ? undefined : { docker: options.docker },
|
|
4353
|
+
stepProcesses: yield* StepProcesses
|
|
4137
4354
|
};
|
|
4138
4355
|
return AgentBackend.of({
|
|
4139
4356
|
sandboxBackends,
|
|
@@ -4679,6 +4896,7 @@ function runReplica(control, executor, signals) {
|
|
|
4679
4896
|
})), ensuring2(suspend3(() => completed || leaseLost ? void_3 : call("release", () => control.release(work.id, lease, crashed)).pipe(timeout(releaseTimeout), catch_((error) => logWarning("runner_release_failed", error.message))))), ensuring2(control.finished?.() ?? void_3));
|
|
4680
4897
|
}));
|
|
4681
4898
|
}
|
|
4899
|
+
var IdleRecheck = seconds(60);
|
|
4682
4900
|
var idleBackoff = (idleIterations) => millis(Math.min(1000 * 2 ** idleIterations, 30000));
|
|
4683
4901
|
function superviseReplica(input) {
|
|
4684
4902
|
const { signals } = input;
|
|
@@ -4714,8 +4932,7 @@ function superviseReplica(input) {
|
|
|
4714
4932
|
continue;
|
|
4715
4933
|
}
|
|
4716
4934
|
if (isSuccess2(exit2) && signals !== undefined) {
|
|
4717
|
-
yield* signals.workSignalledAfter(seen);
|
|
4718
|
-
woken = true;
|
|
4935
|
+
woken = isSome(yield* signals.workSignalledAfter(seen).pipe(timeoutOption(IdleRecheck)));
|
|
4719
4936
|
continue;
|
|
4720
4937
|
}
|
|
4721
4938
|
if (isFailure2(exit2)) {
|
|
@@ -6550,7 +6767,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
|
|
|
6550
6767
|
const input = yield* unbounded2();
|
|
6551
6768
|
const pending = new Map;
|
|
6552
6769
|
let lastId = 0;
|
|
6553
|
-
const handle = yield* spawner.spawn(
|
|
6770
|
+
const handle = yield* spawner.spawn(make2(binary, ["app-server"], {
|
|
6554
6771
|
cwd: env.home,
|
|
6555
6772
|
extendEnv: true,
|
|
6556
6773
|
env: { HOME: env.home, CODEX_HOME: env.codexHome },
|
|
@@ -6573,7 +6790,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
|
|
|
6573
6790
|
return {
|
|
6574
6791
|
request: (method, params) => gen(function* () {
|
|
6575
6792
|
const id = ++lastId;
|
|
6576
|
-
const deferred = yield*
|
|
6793
|
+
const deferred = yield* make15();
|
|
6577
6794
|
pending.set(id, deferred);
|
|
6578
6795
|
yield* send({ id, method, params });
|
|
6579
6796
|
return yield* _await(deferred).pipe(mapError2((error) => new CodexAppServerFailed({ reason: `${method}: ${error.message}` })));
|
|
@@ -6713,10 +6930,10 @@ var handshake = [
|
|
|
6713
6930
|
`).join("");
|
|
6714
6931
|
var kitmanMcpPreflight = (mcp) => gen(function* () {
|
|
6715
6932
|
const spawner = yield* ChildProcessSpawner;
|
|
6716
|
-
const server = yield* spawner.spawn(
|
|
6933
|
+
const server = yield* spawner.spawn(make2(mcp.command, [...mcp.args], {
|
|
6717
6934
|
extendEnv: true,
|
|
6718
6935
|
env: mcp.env,
|
|
6719
|
-
stdin: { stream:
|
|
6936
|
+
stdin: { stream: make10(new TextEncoder().encode(handshake)), endOnDone: false },
|
|
6720
6937
|
stderr: "ignore"
|
|
6721
6938
|
}));
|
|
6722
6939
|
const reply = yield* server.stdout.pipe(decodeText, splitLines, map2((line) => getOrUndefined(decodeJsonStringOption(line))), filter((message) => isJsonObject(message) && message.id === 2), runHead);
|
|
@@ -6789,8 +7006,8 @@ var programProcessExecutor = (input) => (work) => gen(function* () {
|
|
|
6789
7006
|
};
|
|
6790
7007
|
const exitCode = sandbox === undefined ? yield* gen(function* () {
|
|
6791
7008
|
const spawner = yield* ChildProcessSpawner;
|
|
6792
|
-
const handle = yield* spawner.spawn(
|
|
6793
|
-
stdin:
|
|
7009
|
+
const handle = yield* spawner.spawn(make2(input.bun ?? process.execPath, [file], {
|
|
7010
|
+
stdin: make10(new TextEncoder().encode(stdin)),
|
|
6794
7011
|
stdout: "inherit",
|
|
6795
7012
|
stderr: "inherit",
|
|
6796
7013
|
extendEnv: false,
|
|
@@ -7556,6 +7773,7 @@ export {
|
|
|
7556
7773
|
SecretProxyUnreachable,
|
|
7557
7774
|
SkillMaterializationRefused2 as SkillMaterializationRefused,
|
|
7558
7775
|
StepAttemptLabel,
|
|
7776
|
+
StepProcesses,
|
|
7559
7777
|
agentStepExecutionLimit,
|
|
7560
7778
|
agentStepExecutor,
|
|
7561
7779
|
agentStepSandboxPolicy,
|
|
@@ -7625,6 +7843,7 @@ export {
|
|
|
7625
7843
|
liveReplicaIds,
|
|
7626
7844
|
loadAgentRuntimeConfig,
|
|
7627
7845
|
makeReplicaSignals,
|
|
7846
|
+
makeStepProcesses,
|
|
7628
7847
|
orphanedCheckDocker,
|
|
7629
7848
|
orphanedCheckPostgres,
|
|
7630
7849
|
pinnedSrtCommand2 as pinnedSrtCommand,
|
|
@@ -7636,8 +7855,10 @@ export {
|
|
|
7636
7855
|
previewAgentEnvironmentMaterialization2 as previewAgentEnvironmentMaterialization,
|
|
7637
7856
|
previewAgentEnvironmentPlan,
|
|
7638
7857
|
probeSandboxHost,
|
|
7858
|
+
procProcessTable,
|
|
7639
7859
|
programProcessExecutor,
|
|
7640
7860
|
providerKeyHosts,
|
|
7861
|
+
psProcessTable,
|
|
7641
7862
|
publishedPort,
|
|
7642
7863
|
readManifestSkillPaths2 as readManifestSkillPaths,
|
|
7643
7864
|
refuseAgentRequest,
|
|
@@ -7677,9 +7898,17 @@ export {
|
|
|
7677
7898
|
srtSettings2 as srtSettings,
|
|
7678
7899
|
srtStepArgv2 as srtStepArgv,
|
|
7679
7900
|
startDockerSandbox,
|
|
7901
|
+
stepAttemptVariable,
|
|
7680
7902
|
stepKitSetup,
|
|
7903
|
+
stepProcessEnvironment,
|
|
7904
|
+
stepProcessesLayer,
|
|
7905
|
+
stepProcessesUncontained,
|
|
7906
|
+
stepRunnerVariable,
|
|
7681
7907
|
stepSandboxPolicy,
|
|
7682
7908
|
superviseReplica,
|
|
7909
|
+
systemProcessTable,
|
|
7910
|
+
systemStepProcessesLayer,
|
|
7911
|
+
systemdScopes,
|
|
7683
7912
|
tomlKeyPath2 as tomlKeyPath,
|
|
7684
7913
|
tomlTableHeader2 as tomlTableHeader,
|
|
7685
7914
|
updateHerdrCore2 as updateHerdrCore,
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
writeSrtSettings2,
|
|
15
15
|
srtStepArgv2,
|
|
16
16
|
srtArgv2
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import"./chunk-
|
|
17
|
+
} from "./chunk-25q7mg6g.js";
|
|
18
|
+
import"./chunk-dstm8aen.js";
|
|
19
19
|
export {
|
|
20
20
|
compiled2 as compiled,
|
|
21
21
|
harnessesUnsupportedInSrt2 as harnessesUnsupportedInSrt,
|
|
@@ -24,11 +24,11 @@ import {
|
|
|
24
24
|
Record,
|
|
25
25
|
Int,
|
|
26
26
|
fromJsonString
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-dstm8aen.js";
|
|
28
28
|
import {
|
|
29
29
|
withDefault,
|
|
30
30
|
String2
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-25q7mg6g.js";
|
|
32
32
|
import {
|
|
33
33
|
digestSha256,
|
|
34
34
|
digestSha512,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
get2,
|
|
39
39
|
layer4,
|
|
40
40
|
KitDigest
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-63mhk3ft.js";
|
|
42
42
|
|
|
43
43
|
// packages/core/src/npm-registry.ts
|
|
44
44
|
var KitManifest = Struct({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-w0sehmpd.js";
|
|
3
3
|
import {
|
|
4
4
|
HERDR_CORE_GENERATION2,
|
|
5
5
|
HERDR_CORE_INSTALL_COMMAND2,
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
herdrCoreLayer2,
|
|
13
13
|
herdrCoreTransportLayer2,
|
|
14
14
|
updateHerdrCore2
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import"./chunk-
|
|
17
|
-
import"./chunk-
|
|
15
|
+
} from "./chunk-63mhk3ft.js";
|
|
16
|
+
import"./chunk-25q7mg6g.js";
|
|
17
|
+
import"./chunk-dstm8aen.js";
|
|
18
18
|
export {
|
|
19
19
|
HERDR_CORE_GENERATION2 as HERDR_CORE_GENERATION,
|
|
20
20
|
HERDR_CORE_INSTALL_COMMAND2 as HERDR_CORE_INSTALL_COMMAND,
|