@kitman-sh/cli 0.10.89 → 0.10.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/{chunk-w9j2yb0n.js → chunk-25q7mg6g.js} +1 -1
  2. package/dist/{chunk-4b1nj0zw.js → chunk-2wsyg2g7.js} +41 -33
  3. package/dist/{chunk-73fw4pgr.js → chunk-5fxxg02f.js} +255 -49
  4. package/dist/{chunk-dmwqvnmb.js → chunk-5tqy48a3.js} +7 -7
  5. package/dist/{chunk-qqzr8ym6.js → chunk-6h0rz0zk.js} +4 -4
  6. package/dist/{chunk-99ad4j9s.js → chunk-947btdv6.js} +3 -3
  7. package/dist/{chunk-vne4rsj0.js → chunk-9m9cv82t.js} +2 -2
  8. package/dist/{chunk-maj4dn1b.js → chunk-c3k32vw4.js} +1 -1
  9. package/dist/{chunk-5dwyvg1z.js → chunk-cmtvcbxr.js} +5 -5
  10. package/dist/{chunk-daycfvkq.js → chunk-d82t42vr.js} +15 -15
  11. package/dist/{chunk-d8tabep6.js → chunk-d9wjvvbc.js} +5 -5
  12. package/dist/{chunk-caqesagt.js → chunk-dstm8aen.js} +2 -1
  13. package/dist/{chunk-phcerzkf.js → chunk-fgnfx5mw.js} +22 -215
  14. package/dist/{chunk-vzq3q5zr.js → chunk-gncygm43.js} +6 -6
  15. package/dist/{chunk-1hqy9g9w.js → chunk-gykt7zjx.js} +7 -7
  16. package/dist/{chunk-aj4ev9v2.js → chunk-hsf2sj69.js} +2 -2
  17. package/dist/{chunk-1mcwey0c.js → chunk-k4fvnphp.js} +1 -1
  18. package/dist/{chunk-p74pmd81.js → chunk-mbqeakm1.js} +1 -1
  19. package/dist/{chunk-yhh9yeqf.js → chunk-r6d67qqa.js} +255 -26
  20. package/dist/{chunk-cw2ghw7n.js → chunk-rmsm8vnc.js} +4 -4
  21. package/dist/{chunk-1whmkfzv.js → chunk-sb8c2sgy.js} +14 -14
  22. package/dist/{chunk-5w8trr75.js → chunk-tmbhak7y.js} +8 -8
  23. package/dist/{chunk-ybp1mwv9.js → chunk-w0sehmpd.js} +2 -2
  24. package/dist/{chunk-5dydsgwg.js → chunk-y1tnxz9f.js} +9 -9
  25. package/dist/index.js +4 -4
  26. package/package.json +1 -1
@@ -6,11 +6,12 @@ import {
6
6
  isObject,
7
7
  isJsonObject,
8
8
  isString
9
- } from "./chunk-1mcwey0c.js";
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,
@@ -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-caqesagt.js";
170
+ } from "./chunk-dstm8aen.js";
169
171
  import {
170
172
  Id,
171
173
  secretReference,
172
174
  secretPlaceholder
173
- } from "./chunk-p74pmd81.js";
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-73fw4pgr.js";
248
+ } from "./chunk-5fxxg02f.js";
247
249
  import {
248
250
  join,
249
251
  interrupt,
@@ -283,7 +285,7 @@ import {
283
285
  writeSrtSettings2,
284
286
  srtStepArgv2,
285
287
  srtArgv2
286
- } from "./chunk-w9j2yb0n.js";
288
+ } from "./chunk-25q7mg6g.js";
287
289
  import {
288
290
  writeAgentEnvironmentConfigFile2,
289
291
  readManifestSkillPaths2,
@@ -299,8 +301,12 @@ import {
299
301
  applyAgentEnvironmentMaterialization2,
300
302
  isPathWithin2,
301
303
  skillIdentity2
302
- } from "./chunk-d8tabep6.js";
303
- import"./chunk-99ad4j9s.js";
304
+ } from "./chunk-d9wjvvbc.js";
305
+ import"./chunk-947btdv6.js";
306
+ import {
307
+ ChildProcessSpawner,
308
+ make2
309
+ } from "./chunk-w0sehmpd.js";
304
310
  import {
305
311
  egressAllowed,
306
312
  writeSecretRegistry,
@@ -310,7 +316,7 @@ import {
310
316
  secretFilter2,
311
317
  opaqueTunnelRefusal2,
312
318
  isOpaqueConnectReason2
313
- } from "./chunk-aj4ev9v2.js";
319
+ } from "./chunk-hsf2sj69.js";
314
320
  import {
315
321
  sliceBytes2,
316
322
  maxLineBytes2,
@@ -318,23 +324,19 @@ import {
318
324
  decodedOption2,
319
325
  decoded2,
320
326
  readOpencode2
321
- } from "./chunk-dmwqvnmb.js";
327
+ } from "./chunk-5tqy48a3.js";
322
328
  import {
323
329
  uploadRunFile,
324
330
  programLease,
325
331
  rpcRunFiles,
326
332
  programHostsEnv,
327
333
  undeclaredHostsEnv
328
- } from "./chunk-phcerzkf.js";
329
- import"./chunk-vzq3q5zr.js";
334
+ } from "./chunk-fgnfx5mw.js";
335
+ import"./chunk-gncygm43.js";
330
336
  import {
331
337
  nextInt
332
- } from "./chunk-maj4dn1b.js";
333
- import {
334
- ChildProcessSpawner,
335
- make2
336
- } from "./chunk-ybp1mwv9.js";
337
- import"./chunk-1whmkfzv.js";
338
+ } from "./chunk-c3k32vw4.js";
339
+ import"./chunk-sb8c2sgy.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
- return {
3977
- argv: dockerExecArgv({ container, workspace, env: policy.environment, argv: harnessArgv }),
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,
@@ -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,
@@ -4,10 +4,10 @@ import {
4
4
  opaqueTunnelRefusal2,
5
5
  isOpaqueConnectReason2,
6
6
  runSrtStep2
7
- } from "./chunk-aj4ev9v2.js";
8
- import"./chunk-p74pmd81.js";
9
- import"./chunk-1mcwey0c.js";
10
- import"./chunk-caqesagt.js";
7
+ } from "./chunk-hsf2sj69.js";
8
+ import"./chunk-mbqeakm1.js";
9
+ import"./chunk-k4fvnphp.js";
10
+ import"./chunk-dstm8aen.js";
11
11
  export {
12
12
  isOpaqueConnectReason2 as isOpaqueConnectReason,
13
13
  opaqueTunnelRefusal2 as opaqueTunnelRefusal,
@@ -96,19 +96,7 @@ import {
96
96
  Defect,
97
97
  Exit,
98
98
  toCodecJson
99
- } from "./chunk-caqesagt.js";
100
- import {
101
- interrupt,
102
- getCurrent,
103
- makeUnsafe2,
104
- bounded,
105
- offerAll,
106
- failCause,
107
- end,
108
- shutdownUnsafe,
109
- fromQueue,
110
- unwrap
111
- } from "./chunk-w9j2yb0n.js";
99
+ } from "./chunk-dstm8aen.js";
112
100
  import {
113
101
  Clock,
114
102
  empty,
@@ -123,7 +111,19 @@ import {
123
111
  ParseOptions,
124
112
  RpcClientDefect,
125
113
  RpcClientError
126
- } from "./chunk-73fw4pgr.js";
114
+ } from "./chunk-5fxxg02f.js";
115
+ import {
116
+ interrupt,
117
+ getCurrent,
118
+ makeUnsafe2,
119
+ bounded,
120
+ offerAll,
121
+ failCause,
122
+ end,
123
+ shutdownUnsafe,
124
+ fromQueue,
125
+ unwrap
126
+ } from "./chunk-25q7mg6g.js";
127
127
 
128
128
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/workers/Transferable.js
129
129
  class Collector extends (/* @__PURE__ */ Service2()("effect/workers/Transferable/Collector")) {
@@ -12,30 +12,30 @@ import {
12
12
  orElseSucceed,
13
13
  decodeJsonString,
14
14
  encodePrettyJsonString
15
- } from "./chunk-caqesagt.js";
16
- import"./chunk-p74pmd81.js";
15
+ } from "./chunk-dstm8aen.js";
16
+ import"./chunk-mbqeakm1.js";
17
17
  import {
18
18
  isJsonObject
19
- } from "./chunk-1mcwey0c.js";
19
+ } from "./chunk-k4fvnphp.js";
20
20
  import {
21
21
  FileSystem,
22
22
  Path
23
- } from "./chunk-w9j2yb0n.js";
23
+ } from "./chunk-25q7mg6g.js";
24
24
  import {
25
25
  tomlTableHeader2,
26
26
  tomlKeyPath2,
27
27
  kitmanSkillEntry,
28
28
  isPathWithin2
29
- } from "./chunk-d8tabep6.js";
29
+ } from "./chunk-d9wjvvbc.js";
30
30
  import {
31
31
  instructionsStart,
32
32
  instructionsEnd,
33
33
  renderMcpServer,
34
34
  materializeKitSetup,
35
35
  tomlInline
36
- } from "./chunk-73fw4pgr.js";
37
- import"./chunk-99ad4j9s.js";
38
- import"./chunk-ybp1mwv9.js";
36
+ } from "./chunk-5fxxg02f.js";
37
+ import"./chunk-w0sehmpd.js";
38
+ import"./chunk-947btdv6.js";
39
39
 
40
40
  // packages/agent-runtime/src/kit-setup-sync.ts
41
41
  class KitSyncError extends TaggedError("KitSyncError") {
@@ -18,7 +18,7 @@ import {
18
18
  isRedacted,
19
19
  make16,
20
20
  value
21
- } from "./chunk-caqesagt.js";
21
+ } from "./chunk-dstm8aen.js";
22
22
  import {
23
23
  unwrap,
24
24
  drainFork,
@@ -27,7 +27,7 @@ import {
27
27
  runCollect,
28
28
  runDrain,
29
29
  mkString
30
- } from "./chunk-w9j2yb0n.js";
30
+ } from "./chunk-25q7mg6g.js";
31
31
 
32
32
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Brand.js
33
33
  function nominal() {