@kitman-sh/cli 0.43.0 → 0.45.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.
Files changed (28) hide show
  1. package/dist/{chunk-8b02x7vv.js → chunk-04wqa07j.js} +1 -1
  2. package/dist/{chunk-27e7m975.js → chunk-0dfg674z.js} +7 -7
  3. package/dist/{chunk-ea29sbaq.js → chunk-4vxbxjf8.js} +1 -1
  4. package/dist/{chunk-91tvnb8f.js → chunk-5gbt1vhm.js} +9 -9
  5. package/dist/{chunk-d4vhrja4.js → chunk-5pjbxhxy.js} +3 -3
  6. package/dist/{chunk-etrfc5cn.js → chunk-5smh4dp2.js} +35 -32
  7. package/dist/{chunk-0qfaf9h3.js → chunk-69y8j7fs.js} +140 -138
  8. package/dist/{chunk-cnryphhh.js → chunk-8gkrs473.js} +7 -7
  9. package/dist/{chunk-b2btevxm.js → chunk-9qvgbp6k.js} +60 -46
  10. package/dist/{chunk-98azvx6g.js → chunk-9ykh05hz.js} +1 -1
  11. package/dist/{chunk-ns26fbmk.js → chunk-a71b15k3.js} +2 -2
  12. package/dist/{chunk-fekh3jwz.js → chunk-e3dv8hzy.js} +1 -1
  13. package/dist/{chunk-7ygg19wj.js → chunk-es6rnmyw.js} +3 -3
  14. package/dist/{chunk-qxpwkb5f.js → chunk-f957cxrx.js} +7 -7
  15. package/dist/{chunk-bbq7q5r6.js → chunk-fmvdwf5h.js} +69 -49
  16. package/dist/{chunk-6x08g7m6.js → chunk-fqh4pj6b.js} +14 -60
  17. package/dist/{chunk-fbddgx6q.js → chunk-g26y214g.js} +4 -4
  18. package/dist/{chunk-bqbfyqx6.js → chunk-k462v2v7.js} +103 -51
  19. package/dist/{chunk-qqc567gx.js → chunk-k7eh8tac.js} +4 -4
  20. package/dist/{chunk-wy6gmtd9.js → chunk-n3jpxd14.js} +2 -2
  21. package/dist/{chunk-rbt72xjw.js → chunk-qzwsh96c.js} +22 -3
  22. package/dist/{chunk-hgvft7vy.js → chunk-tfwgeqx5.js} +4 -4
  23. package/dist/{chunk-bqebfc06.js → chunk-tqv14b4c.js} +12 -12
  24. package/dist/{chunk-jq5h43a4.js → chunk-tx9aey19.js} +287 -59
  25. package/dist/{chunk-wv8kt4rb.js → chunk-yyz9xrc1.js} +6 -6
  26. package/dist/{chunk-jvwjreb0.js → chunk-zx86g3dw.js} +7 -7
  27. package/dist/index.js +4 -4
  28. package/package.json +1 -1
@@ -38,31 +38,39 @@ import {
38
38
  isSuccess,
39
39
  getSuccess,
40
40
  chunksOf,
41
+ toPredicate,
42
+ has,
43
+ compose,
41
44
  TaggedError,
45
+ forkUnsafe,
42
46
  succeed3,
43
47
  void_2,
44
48
  isSuccess2,
45
49
  isFailure2,
46
50
  hasInterrupts,
47
51
  makeUnsafe5,
48
- make16,
52
+ make15,
49
53
  _await,
50
54
  fail5,
51
55
  isDoneUnsafe,
52
56
  succeed4,
53
57
  doneUnsafe,
58
+ into,
54
59
  makeUnsafe6,
55
60
  provide,
56
61
  succeed5,
57
62
  effect,
58
63
  mergeAll,
59
64
  die2,
65
+ hasInterruptsOnly,
60
66
  findErrorOption,
67
+ filterInterruptors,
61
68
  pretty,
62
69
  exponential,
63
70
  jittered,
64
71
  spaced,
65
72
  upTo,
73
+ isEffect,
66
74
  all3,
67
75
  validate,
68
76
  findFirst,
@@ -82,6 +90,7 @@ import {
82
90
  die3,
83
91
  try_2,
84
92
  yieldNow,
93
+ withFiber2,
85
94
  flatMap3,
86
95
  andThen2,
87
96
  tap2,
@@ -122,12 +131,14 @@ import {
122
131
  addFinalizer2,
123
132
  ensuring2,
124
133
  onExit,
134
+ interrupt3,
125
135
  uninterruptible,
126
136
  forever,
127
137
  repeat,
128
138
  forkIn,
129
139
  forkScoped,
130
140
  forkDetach,
141
+ runFork,
131
142
  fnUntraced,
132
143
  logWarning,
133
144
  logError,
@@ -175,7 +186,7 @@ import {
175
186
  decodeJsonStringSync,
176
187
  encodeUnknownJsonStringSync,
177
188
  storable
178
- } from "./chunk-bqbfyqx6.js";
189
+ } from "./chunk-k462v2v7.js";
179
190
  import {
180
191
  SecureRandom,
181
192
  layerWebCrypto,
@@ -231,6 +242,7 @@ import {
231
242
  layer4,
232
243
  SetupArchive,
233
244
  kitMcpSecretNames,
245
+ WorkAvailable,
234
246
  RunSettled,
235
247
  UpdateAvailable,
236
248
  HERDR_CORE_GENERATION2,
@@ -264,17 +276,19 @@ import {
264
276
  checkServicesFile,
265
277
  checkServices,
266
278
  serviceChecks
267
- } from "./chunk-0qfaf9h3.js";
279
+ } from "./chunk-69y8j7fs.js";
268
280
  import {
281
+ empty2,
269
282
  currentTimeMillis,
270
283
  join,
271
284
  interrupt,
285
+ interruptAll,
272
286
  unbounded,
273
287
  publishUnsafe,
274
288
  unbounded2,
275
289
  offer,
276
290
  makeUnsafe3,
277
- make11,
291
+ make10,
278
292
  fromQueue,
279
293
  fromPubSub,
280
294
  map2,
@@ -313,7 +327,7 @@ import {
313
327
  writeSrtSettings2,
314
328
  srtStepArgv2,
315
329
  srtArgv2
316
- } from "./chunk-etrfc5cn.js";
330
+ } from "./chunk-5smh4dp2.js";
317
331
  import {
318
332
  writeAgentEnvironmentConfigFile2,
319
333
  readManifestSkillPaths2,
@@ -329,8 +343,8 @@ import {
329
343
  applyAgentEnvironmentMaterialization2,
330
344
  isPathWithin2,
331
345
  skillIdentity2
332
- } from "./chunk-fbddgx6q.js";
333
- import"./chunk-7ygg19wj.js";
346
+ } from "./chunk-g26y214g.js";
347
+ import"./chunk-es6rnmyw.js";
334
348
  import {
335
349
  egressAllowed,
336
350
  writeSecretRegistry,
@@ -340,7 +354,7 @@ import {
340
354
  secretFilter2,
341
355
  opaqueTunnelRefusal2,
342
356
  isOpaqueConnectReason2
343
- } from "./chunk-wy6gmtd9.js";
357
+ } from "./chunk-n3jpxd14.js";
344
358
  import {
345
359
  sliceBytes2,
346
360
  maxLineBytes2,
@@ -350,29 +364,29 @@ import {
350
364
  lookAtOpencode2,
351
365
  readOpencode2,
352
366
  databaseStamp2
353
- } from "./chunk-cnryphhh.js";
367
+ } from "./chunk-8gkrs473.js";
354
368
  import {
355
369
  uploadRunFile,
356
370
  programLease,
357
371
  rpcRunFiles,
358
372
  programHostsEnv,
359
373
  undeclaredHostsEnv
360
- } from "./chunk-91tvnb8f.js";
361
- import"./chunk-27e7m975.js";
374
+ } from "./chunk-5gbt1vhm.js";
375
+ import"./chunk-0dfg674z.js";
362
376
  import {
363
377
  nextInt
364
- } from "./chunk-8b02x7vv.js";
365
- import"./chunk-98azvx6g.js";
378
+ } from "./chunk-04wqa07j.js";
379
+ import"./chunk-9ykh05hz.js";
366
380
  import {
367
381
  ChildProcessSpawner,
368
- make3
369
- } from "./chunk-6x08g7m6.js";
370
- import"./chunk-qxpwkb5f.js";
382
+ make2
383
+ } from "./chunk-fqh4pj6b.js";
384
+ import"./chunk-f957cxrx.js";
371
385
  import {
372
386
  Id,
373
387
  secretReference,
374
388
  secretPlaceholder
375
- } from "./chunk-ea29sbaq.js";
389
+ } from "./chunk-4vxbxjf8.js";
376
390
 
377
391
  // packages/core/src/sync-kit.ts
378
392
  import { createHash } from "crypto";
@@ -644,6 +658,91 @@ var outputTailWithParallelFailures = (failures, output) => {
644
658
  `);
645
659
  };
646
660
 
661
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/FiberSet.js
662
+ var TypeId = "~effect/FiberSet";
663
+ var isFiberSet = (u) => hasProperty(u, TypeId);
664
+ var Proto = {
665
+ [TypeId]: TypeId,
666
+ [Symbol.iterator]() {
667
+ if (this.state._tag === "Closed") {
668
+ return empty2();
669
+ }
670
+ return this.state.backing[Symbol.iterator]();
671
+ },
672
+ ...PipeInspectableProto,
673
+ toJSON() {
674
+ return {
675
+ _id: "FiberSet",
676
+ state: this.state
677
+ };
678
+ }
679
+ };
680
+ var makeUnsafe = (backing, deferred) => {
681
+ const self = Object.create(Proto);
682
+ self.state = {
683
+ _tag: "Open",
684
+ backing
685
+ };
686
+ self.deferred = deferred;
687
+ return self;
688
+ };
689
+ var make = () => acquireRelease(sync2(() => makeUnsafe(new Set, makeUnsafe5())), (set) => suspend3(() => {
690
+ const state = set.state;
691
+ if (state._tag === "Closed")
692
+ return void_3;
693
+ set.state = {
694
+ _tag: "Closed"
695
+ };
696
+ const fibers = state.backing;
697
+ return interruptAll(fibers).pipe(into(set.deferred));
698
+ }));
699
+ var internalFiberId = -1;
700
+ var isInternalInterruption = /* @__PURE__ */ toPredicate(/* @__PURE__ */ compose(filterInterruptors, /* @__PURE__ */ has(internalFiberId)));
701
+ var addUnsafe = /* @__PURE__ */ dual((args) => isFiberSet(args[0]), (self, fiber, options) => {
702
+ if (self.state._tag === "Closed") {
703
+ fiber.interruptUnsafe(internalFiberId);
704
+ return;
705
+ } else if (self.state.backing.has(fiber)) {
706
+ return;
707
+ }
708
+ self.state.backing.add(fiber);
709
+ fiber.addObserver((exit) => {
710
+ if (self.state._tag === "Closed") {
711
+ return;
712
+ }
713
+ self.state.backing.delete(fiber);
714
+ if (isFailure2(exit) && (options?.propagateInterruption === true ? !isInternalInterruption(exit.cause) : !hasInterruptsOnly(exit.cause))) {
715
+ doneUnsafe(self.deferred, exit);
716
+ }
717
+ });
718
+ });
719
+ var constInterruptedFiber = /* @__PURE__ */ function() {
720
+ let fiber = undefined;
721
+ return () => {
722
+ if (fiber === undefined) {
723
+ fiber = runFork(interrupt3);
724
+ }
725
+ return fiber;
726
+ };
727
+ }();
728
+ var run2 = function() {
729
+ const self = arguments[0];
730
+ if (!isEffect(arguments[1])) {
731
+ const options = arguments[1];
732
+ return (effect) => runImpl(self, effect, options);
733
+ }
734
+ return runImpl(self, arguments[1], arguments[2]);
735
+ };
736
+ var runImpl = (self, effect, options) => withFiber2((parent) => {
737
+ if (self.state._tag === "Closed") {
738
+ return sync2(constInterruptedFiber);
739
+ }
740
+ const fiber = forkUnsafe(parent, effect, options?.startImmediately ?? true, true);
741
+ addUnsafe(self, fiber, options);
742
+ return succeed6(fiber);
743
+ });
744
+ var join2 = (self) => _await(self.deferred);
745
+
647
746
  // packages/agent-runtime/src/agent-environment.ts
648
747
  class AgentEnvironmentResolutionError extends TaggedError("AgentEnvironmentResolutionError") {
649
748
  get message() {
@@ -3220,10 +3319,10 @@ var stepKitSetup = (agent, harness) => gen(function* () {
3220
3319
  import { homedir as homedir2 } from "os";
3221
3320
 
3222
3321
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/SubscriptionRef.js
3223
- var TypeId = "~effect/SubscriptionRef";
3224
- var Proto = {
3322
+ var TypeId2 = "~effect/SubscriptionRef";
3323
+ var Proto2 = {
3225
3324
  ...PipeInspectableProto,
3226
- [TypeId]: {
3325
+ [TypeId2]: {
3227
3326
  _A: identity
3228
3327
  },
3229
3328
  toJSON() {
@@ -3233,10 +3332,10 @@ var Proto = {
3233
3332
  };
3234
3333
  }
3235
3334
  };
3236
- var make = (value) => map9(unbounded({
3335
+ var make3 = (value) => map9(unbounded({
3237
3336
  replay: 1
3238
3337
  }), (pubsub) => {
3239
- const self = Object.create(Proto);
3338
+ const self = Object.create(Proto2);
3240
3339
  self.semaphore = makeUnsafe3(1);
3241
3340
  self.value = value;
3242
3341
  self.pubsub = pubsub;
@@ -4512,17 +4611,46 @@ var cpuQuota = (cpuMax) => {
4512
4611
  const quota = Number(max) / Number(period);
4513
4612
  return Number.isFinite(quota) && quota > 0 ? quota : undefined;
4514
4613
  };
4515
- var readCpuMax = () => {
4614
+ var readText = (file) => {
4516
4615
  try {
4517
- return readFileSync("/sys/fs/cgroup/cpu.max", "utf8");
4616
+ return readFileSync(file, "utf8");
4518
4617
  } catch {
4519
4618
  return;
4520
4619
  }
4521
4620
  };
4522
- var effectiveCores = (cores = availableParallelism(), cpuMax = readCpuMax()) => {
4523
- const quota = cpuQuota(cpuMax);
4524
- return quota === undefined ? cores : Math.max(1, Math.min(cores, Math.ceil(quota)));
4621
+ var readBytes = (file) => {
4622
+ try {
4623
+ return readFileSync(file, "latin1");
4624
+ } catch {
4625
+ return;
4626
+ }
4525
4627
  };
4628
+ var readAtBytePath = (file) => {
4629
+ try {
4630
+ return readFileSync(Buffer.from(file, "latin1"), "utf8");
4631
+ } catch {
4632
+ return;
4633
+ }
4634
+ };
4635
+ var lineAfter = (text, prefix) => text.split(`
4636
+ `).find((line) => line.startsWith(prefix))?.slice(prefix.length);
4637
+ var cpuListSize = (list) => list.trim().split(",").filter((range) => range !== "").reduce((size, range) => {
4638
+ const [first, last = first] = range.split("-").map(Number);
4639
+ return size + (last ?? 0) - (first ?? 0) + 1;
4640
+ }, 0);
4641
+ var affinityCores = (status = readText("/proc/self/status")) => {
4642
+ const list = status === undefined ? undefined : lineAfter(status, "Cpus_allowed_list:")?.trim();
4643
+ const size = list === undefined ? Number.NaN : cpuListSize(list);
4644
+ return Number.isInteger(size) && size > 0 ? size : availableParallelism();
4645
+ };
4646
+ var cgroupCpuQuota = (procCgroup, read) => {
4647
+ const path = procCgroup === undefined ? undefined : lineAfter(procCgroup, "0::/");
4648
+ const named = path === undefined ? [] : path.split("/").filter((part) => part !== "" && part !== ".");
4649
+ const parts = named.includes("..") ? [] : named;
4650
+ const quotas = parts.map((_, depth) => parts.slice(0, parts.length - depth).join("/")).concat("").map((dir) => cpuQuota(read(`/sys/fs/cgroup${dir === "" ? "" : `/${dir}`}/cpu.max`))).filter((quota) => quota !== undefined);
4651
+ return quotas.length === 0 ? undefined : Math.min(...quotas);
4652
+ };
4653
+ var effectiveCores = (affinity = affinityCores(), quota = cgroupCpuQuota(readBytes("/proc/self/cgroup"), readAtBytePath)) => quota === undefined ? affinity : Math.min(affinity, quota);
4526
4654
  var threadBudget = (cores, concurrency) => Math.max(2, Math.floor(cores / concurrency));
4527
4655
  var runnerVerificationCap = (settings, cores = effectiveCores()) => verificationCap(settings, cores);
4528
4656
  var checkThreadBudget = (settings, cores = effectiveCores()) => {
@@ -5037,7 +5165,7 @@ var runAttempt = (request, options) => gen(function* () {
5037
5165
  return isTagged(terminal.failure, "HerdrCoreRpcError") ? failed("harness_launch_failed", `herdr-core refused to start the Harness: ${terminal.failure.message}`) : { status: "unreported", reason: "herdr_unavailable" };
5038
5166
  }
5039
5167
  const { address } = terminal.success;
5040
- const seen = yield* make({ status: null, turn: 0, end: undefined });
5168
+ const seen = yield* make3({ status: null, turn: 0, end: undefined });
5041
5169
  yield* forkScoped(follow(options.core, attempt.id, address, seen));
5042
5170
  const stop = gen(function* () {
5043
5171
  if ((yield* get2(seen)).end === "unreachable")
@@ -5865,9 +5993,9 @@ var needsNothing = (git, input) => gen(function* () {
5865
5993
  });
5866
5994
 
5867
5995
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/matcher.js
5868
- var TypeId2 = "~effect/Match/Matcher";
5996
+ var TypeId3 = "~effect/Match/Matcher";
5869
5997
  var TypeMatcherProto = {
5870
- [TypeId2]: {
5998
+ [TypeId3]: {
5871
5999
  _input: identity,
5872
6000
  _filters: identity,
5873
6001
  _remaining: identity,
@@ -5890,7 +6018,7 @@ function makeTypeMatcher(select, cases) {
5890
6018
  return matcher;
5891
6019
  }
5892
6020
  var ValueMatcherProto = {
5893
- [TypeId2]: {
6021
+ [TypeId3]: {
5894
6022
  _input: identity,
5895
6023
  _filters: identity,
5896
6024
  _result: identity,
@@ -6224,31 +6352,36 @@ function superviseReplica(input) {
6224
6352
  });
6225
6353
  const claimTurn = makeUnsafe3(1);
6226
6354
  let emptyAt = -1;
6227
- const wokenControl = (control, gate, signals) => ({
6228
- ...control,
6229
- claim: (idempotencyKey, options) => claimTurn.withPermit(gen(function* () {
6230
- const generation = yield* signals.generation;
6231
- if (generation <= emptyAt)
6232
- return {};
6233
- const { claimed, asked } = yield* claimThrough(control, gate, idempotencyKey, options);
6234
- if (claimed.workUnit === undefined && asked?.takesVerifications !== false)
6235
- emptyAt = Math.max(emptyAt, generation);
6236
- return claimed;
6237
- }))
6238
- });
6239
- const runSlot = (capacitySlot, index) => gen(function* () {
6355
+ const wokenControl = (control, gate, signals, demand) => {
6356
+ let lastAsked;
6357
+ return {
6358
+ ...control,
6359
+ claim: (idempotencyKey, options) => claimTurn.withPermit(gen(function* () {
6360
+ const generation = yield* signals.generation;
6361
+ const retry = lastAsked === idempotencyKey;
6362
+ lastAsked = idempotencyKey;
6363
+ if (!retry && generation <= emptyAt)
6364
+ return {};
6365
+ const { claimed, asked } = yield* claimThrough(control, gate, idempotencyKey, options);
6366
+ if (claimed.workUnit === undefined && asked?.takesVerifications !== false && (demand === undefined || (yield* demand.offeredNew)))
6367
+ emptyAt = Math.max(emptyAt, generation);
6368
+ return claimed;
6369
+ }))
6370
+ };
6371
+ };
6372
+ const runSlot = (capacitySlot, demand) => gen(function* () {
6240
6373
  let idleIterations = 0;
6241
- let woken = true;
6374
+ let woken = demand === undefined;
6242
6375
  while (true) {
6243
- if (input.concurrency !== undefined && index >= (yield* input.concurrency)) {
6244
- yield* sleep(ConcurrencyRecheck);
6245
- continue;
6246
- }
6376
+ if (demand !== undefined && (yield* demand.past))
6377
+ return;
6247
6378
  const seen = signals === undefined ? 0 : yield* signals.generation;
6248
- const control = input.control(capacitySlot);
6379
+ const control = demand === undefined ? input.control(capacitySlot) : demand.claiming(input.control(capacitySlot));
6249
6380
  const gate = input.verifications === undefined ? undefined : verificationGate(input.verifications);
6250
- const claiming = signals !== undefined && woken ? wokenControl(control, gate, signals) : gatedControl(control, gate);
6381
+ const claiming = signals !== undefined && woken ? wokenControl(control, gate, signals, demand) : gatedControl(control, gate);
6251
6382
  const exit2 = yield* exit(runReplica(claiming, input.executor, signals).pipe(ensuring2(gate?.free ?? void_3)));
6383
+ if (demand !== undefined)
6384
+ yield* demand.free;
6252
6385
  if (isSuccess2(exit2) && exit2.value.status === "completed") {
6253
6386
  idleIterations = 0;
6254
6387
  woken = false;
@@ -6259,6 +6392,8 @@ function superviseReplica(input) {
6259
6392
  woken = true;
6260
6393
  continue;
6261
6394
  }
6395
+ if (isSuccess2(exit2) && demand !== undefined && (yield* demand.spare))
6396
+ return;
6262
6397
  if (isSuccess2(exit2) && signals !== undefined) {
6263
6398
  woken = isSome(yield* signals.workSignalledAfter(seen).pipe(timeoutOption(IdleRecheck)));
6264
6399
  continue;
@@ -6272,10 +6407,17 @@ function superviseReplica(input) {
6272
6407
  yield* sleep(idleBackoff(idleIterations++));
6273
6408
  }
6274
6409
  });
6275
- const heartbeat = input.control(input.slots[0] ?? "slot-1").heartbeatReplica;
6410
+ const slotName = (index) => input.slots?.[index] ?? `slot-${index + 1}`;
6411
+ const heartbeat = input.control(slotName(0)).heartbeatReplica;
6412
+ let wakeAfterHeartbeat = false;
6413
+ const wake = signals === undefined ? void_3 : signals.push(WorkAvailable.make({}));
6276
6414
  const replicaHeartbeat = gen(function* () {
6277
6415
  while (true) {
6278
6416
  const exit2 = yield* exit(retryTransient(heartbeatCall(heartbeat)));
6417
+ if (isSuccess2(exit2) && wakeAfterHeartbeat) {
6418
+ wakeAfterHeartbeat = false;
6419
+ yield* wake;
6420
+ }
6279
6421
  if (isFailure2(exit2)) {
6280
6422
  const error = findErrorOption(exit2.cause);
6281
6423
  if (isSome(error) && error.value.kind === "unauthorized")
@@ -6285,7 +6427,88 @@ function superviseReplica(input) {
6285
6427
  yield* sleep(ReplicaHeartbeatInterval);
6286
6428
  }
6287
6429
  });
6288
- return all3([replicaHeartbeat, forEach(input.slots, runSlot, { concurrency: "unbounded", discard: true })], {
6430
+ const slots = input.concurrency === undefined ? forEach(input.slots, (slot) => runSlot(slot), { concurrency: "unbounded", discard: true }) : slotsOnDemand(input.concurrency);
6431
+ function slotsOnDemand(concurrency) {
6432
+ return scoped(gen(function* () {
6433
+ const fibers = yield* make();
6434
+ const started = new Set;
6435
+ let idle = 0;
6436
+ let busySlots = 0;
6437
+ let claimsInFlight = 0;
6438
+ let lastConcurrency = 0;
6439
+ const startSpare = gen(function* () {
6440
+ if (idle > 0 || started.size >= (yield* concurrency))
6441
+ return;
6442
+ let index = 0;
6443
+ while (started.has(index))
6444
+ index += 1;
6445
+ started.add(index);
6446
+ idle += 1;
6447
+ yield* run2(fibers, runSlot(slotName(index), slotDemand(index)).pipe(ensuring2(sync2(() => started.delete(index)))));
6448
+ });
6449
+ const slotDemand = (index) => {
6450
+ let busy = false;
6451
+ const claimed = suspend3(() => {
6452
+ if (busy)
6453
+ return void_3;
6454
+ busy = true;
6455
+ busySlots += 1;
6456
+ idle -= 1;
6457
+ return startSpare;
6458
+ });
6459
+ const stop = () => {
6460
+ idle -= 1;
6461
+ return true;
6462
+ };
6463
+ let lastAsked;
6464
+ let offeredNew = false;
6465
+ const claimWithin = (control, idempotencyKey, options) => gen(function* () {
6466
+ const full = busySlots + claimsInFlight >= (yield* concurrency);
6467
+ const retry = lastAsked === idempotencyKey;
6468
+ lastAsked = idempotencyKey;
6469
+ offeredNew = !full;
6470
+ if (full && !retry)
6471
+ return {};
6472
+ let reserved = !full;
6473
+ if (reserved)
6474
+ claimsInFlight += 1;
6475
+ const unreserve = sync2(() => {
6476
+ if (reserved)
6477
+ claimsInFlight -= 1;
6478
+ reserved = false;
6479
+ });
6480
+ return yield* control.claim(idempotencyKey, full ? { ...options, heldOnly: true } : options).pipe(tap2((result) => result.workUnit === undefined ? void_3 : andThen2(unreserve, claimed)), ensuring2(unreserve));
6481
+ });
6482
+ return {
6483
+ claiming: (control) => ({
6484
+ ...control,
6485
+ claim: (idempotencyKey, options) => claimWithin(control, idempotencyKey, options)
6486
+ }),
6487
+ free: sync2(() => {
6488
+ if (!busy)
6489
+ return;
6490
+ busy = false;
6491
+ busySlots -= 1;
6492
+ idle += 1;
6493
+ }),
6494
+ past: map9(concurrency, (limit) => (index >= limit || busySlots >= limit) && stop()),
6495
+ spare: sync2(() => idle > 1 && stop()),
6496
+ offeredNew: sync2(() => offeredNew)
6497
+ };
6498
+ };
6499
+ const wakeOnRise = flatMap3(concurrency, (now) => {
6500
+ const rose = lastConcurrency > 0 && now > lastConcurrency;
6501
+ lastConcurrency = now;
6502
+ if (!rose)
6503
+ return void_3;
6504
+ wakeAfterHeartbeat = true;
6505
+ return wake;
6506
+ });
6507
+ const keepSpare = forever(andThen2(wakeOnRise, andThen2(startSpare, sleep(ConcurrencyRecheck))));
6508
+ return yield* raceFirst(keepSpare, join2(fibers));
6509
+ }));
6510
+ }
6511
+ return all3([replicaHeartbeat, slots], {
6289
6512
  concurrency: "unbounded",
6290
6513
  discard: true
6291
6514
  }).pipe(andThen2(never));
@@ -8683,7 +8906,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
8683
8906
  const input = yield* unbounded2();
8684
8907
  const pending = new Map;
8685
8908
  let lastId = 0;
8686
- const handle = yield* spawner.spawn(make3(binary, ["app-server"], {
8909
+ const handle = yield* spawner.spawn(make2(binary, ["app-server"], {
8687
8910
  cwd: env.home,
8688
8911
  extendEnv: true,
8689
8912
  env: { HOME: env.home, CODEX_HOME: env.codexHome },
@@ -8706,7 +8929,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
8706
8929
  return {
8707
8930
  request: (method, params) => gen(function* () {
8708
8931
  const id = ++lastId;
8709
- const deferred = yield* make16();
8932
+ const deferred = yield* make15();
8710
8933
  pending.set(id, deferred);
8711
8934
  yield* send({ id, method, params });
8712
8935
  return yield* _await(deferred).pipe(mapError2((error) => new CodexAppServerFailed({ reason: `${method}: ${error.message}` })));
@@ -8846,10 +9069,10 @@ var handshake = [
8846
9069
  `).join("");
8847
9070
  var kitmanMcpPreflight = (mcp) => gen(function* () {
8848
9071
  const spawner = yield* ChildProcessSpawner;
8849
- const server = yield* spawner.spawn(make3(mcp.command, [...mcp.args], {
9072
+ const server = yield* spawner.spawn(make2(mcp.command, [...mcp.args], {
8850
9073
  extendEnv: true,
8851
9074
  env: mcp.env,
8852
- stdin: { stream: make11(new TextEncoder().encode(handshake)), endOnDone: false },
9075
+ stdin: { stream: make10(new TextEncoder().encode(handshake)), endOnDone: false },
8853
9076
  stderr: "ignore"
8854
9077
  }));
8855
9078
  const reply = yield* server.stdout.pipe(decodeText, splitLines, map2((line) => getOrUndefined(decodeJsonStringOption(line))), filter((message) => isJsonObject(message) && message.id === 2), runHead);
@@ -8922,8 +9145,8 @@ var programProcessExecutor = (input) => (work) => gen(function* () {
8922
9145
  };
8923
9146
  const exitCode = sandbox === undefined ? yield* gen(function* () {
8924
9147
  const spawner = yield* ChildProcessSpawner;
8925
- const handle = yield* spawner.spawn(make3(input.bun ?? process.execPath, [file], {
8926
- stdin: make11(new TextEncoder().encode(stdin)),
9148
+ const handle = yield* spawner.spawn(make2(input.bun ?? process.execPath, [file], {
9149
+ stdin: make10(new TextEncoder().encode(stdin)),
8927
9150
  stdout: "inherit",
8928
9151
  stderr: "inherit",
8929
9152
  extendEnv: false,
@@ -10417,6 +10640,7 @@ export {
10417
10640
  SkillMaterializationRefused2 as SkillMaterializationRefused,
10418
10641
  StepAttemptLabel,
10419
10642
  StepProcesses,
10643
+ affinityCores,
10420
10644
  afterFreshService,
10421
10645
  afterMergeRunner,
10422
10646
  agentStepExecutionLimit,
@@ -10429,6 +10653,7 @@ export {
10429
10653
  attemptTempDirectory,
10430
10654
  carriedLoginHosts,
10431
10655
  carriedProviderHosts,
10656
+ cgroupCpuQuota,
10432
10657
  checkDockerAlias,
10433
10658
  checkDockerClientConfig,
10434
10659
  checkDockerDaemonArgs,
@@ -10449,6 +10674,7 @@ export {
10449
10674
  compiled2 as compiled,
10450
10675
  composeAgentEnvironmentSyncPlan,
10451
10676
  controlFailureKind,
10677
+ cpuListSize,
10452
10678
  cpuQuota,
10453
10679
  defaultAgentRuntimeUserConfigPath,
10454
10680
  detectHarnesses2 as detectHarnesses,
@@ -10521,6 +10747,8 @@ export {
10521
10747
  psProcessTable,
10522
10748
  publishedPort,
10523
10749
  pushWork,
10750
+ readAtBytePath,
10751
+ readBytes,
10524
10752
  readManifestSkillPaths2 as readManifestSkillPaths,
10525
10753
  redactedWith,
10526
10754
  redactingSecrets,
@@ -4,12 +4,12 @@ import {
4
4
  runnerRpcUrl2,
5
5
  makeRunnerRpcClient2,
6
6
  makeProgramRpcClient2
7
- } from "./chunk-27e7m975.js";
8
- import"./chunk-qxpwkb5f.js";
9
- import"./chunk-0qfaf9h3.js";
10
- import"./chunk-ea29sbaq.js";
11
- import"./chunk-etrfc5cn.js";
12
- import"./chunk-bqbfyqx6.js";
7
+ } from "./chunk-0dfg674z.js";
8
+ import"./chunk-f957cxrx.js";
9
+ import"./chunk-69y8j7fs.js";
10
+ import"./chunk-4vxbxjf8.js";
11
+ import"./chunk-5smh4dp2.js";
12
+ import"./chunk-k462v2v7.js";
13
13
  export {
14
14
  makeProgramRpcClient2 as makeProgramRpcClient,
15
15
  makeRunnerRpcClient2 as makeRunnerRpcClient,
@@ -13,17 +13,17 @@ import {
13
13
  isJsonObject,
14
14
  decodeJsonString,
15
15
  encodePrettyJsonString
16
- } from "./chunk-bqbfyqx6.js";
16
+ } from "./chunk-k462v2v7.js";
17
17
  import {
18
18
  FileSystem,
19
19
  Path
20
- } from "./chunk-etrfc5cn.js";
20
+ } from "./chunk-5smh4dp2.js";
21
21
  import {
22
22
  tomlTableHeader2,
23
23
  tomlKeyPath2,
24
24
  kitmanSkillEntry,
25
25
  isPathWithin2
26
- } from "./chunk-fbddgx6q.js";
26
+ } from "./chunk-g26y214g.js";
27
27
  import {
28
28
  instructionsStart,
29
29
  instructionsEnd,
@@ -31,10 +31,10 @@ import {
31
31
  antigravityPlugins,
32
32
  materializeKitSetup,
33
33
  tomlInline
34
- } from "./chunk-0qfaf9h3.js";
35
- import"./chunk-7ygg19wj.js";
36
- import"./chunk-6x08g7m6.js";
37
- import"./chunk-ea29sbaq.js";
34
+ } from "./chunk-69y8j7fs.js";
35
+ import"./chunk-es6rnmyw.js";
36
+ import"./chunk-fqh4pj6b.js";
37
+ import"./chunk-4vxbxjf8.js";
38
38
 
39
39
  // packages/agent-runtime/src/kit-setup-sync.ts
40
40
  class KitSyncError extends TaggedError("KitSyncError") {
package/dist/index.js CHANGED
@@ -5,15 +5,15 @@
5
5
  var args = process.argv.slice(2);
6
6
  if (args[0] === "srt") {
7
7
  process.argv.splice(2, 1);
8
- const { runSrtCli } = await import("./chunk-ns26fbmk.js");
8
+ const { runSrtCli } = await import("./chunk-a71b15k3.js");
9
9
  await runSrtCli();
10
10
  } else if (args[0] === "srt-step") {
11
- const { runSrtStep } = await import("./chunk-d4vhrja4.js");
11
+ const { runSrtStep } = await import("./chunk-5pjbxhxy.js");
12
12
  await runSrtStep(args.slice(1));
13
13
  } else if (args[0] === "opencode-read") {
14
- const { runOpencodeReader } = await import("./chunk-hgvft7vy.js");
14
+ const { runOpencodeReader } = await import("./chunk-tfwgeqx5.js");
15
15
  runOpencodeReader();
16
16
  } else {
17
- const { runCli } = await import("./chunk-b2btevxm.js");
17
+ const { runCli } = await import("./chunk-9qvgbp6k.js");
18
18
  runCli(args);
19
19
  }