@kitman-sh/cli 0.12.0-rc.5 → 0.12.0-rc.7

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-2s4x5t92.js → chunk-0346hwh6.js} +5 -5
  2. package/dist/{chunk-bv9e34qz.js → chunk-0qz10ek8.js} +1 -1
  3. package/dist/{chunk-dd8hae73.js → chunk-15geyg2d.js} +119 -92
  4. package/dist/{chunk-77k89h98.js → chunk-1t12wvv1.js} +117 -264
  5. package/dist/{chunk-x70r99jg.js → chunk-2e91ymwn.js} +1 -1
  6. package/dist/{chunk-nc1rxeav.js → chunk-4w4spvb1.js} +6 -6
  7. package/dist/{chunk-3530xts6.js → chunk-56knbdt6.js} +9 -9
  8. package/dist/{chunk-cegdw7gw.js → chunk-5j848ckb.js} +2 -2
  9. package/dist/{chunk-bbadvwds.js → chunk-8twjqszj.js} +1 -1
  10. package/dist/{chunk-kvm7j3ed.js → chunk-bheg4ybe.js} +17 -17
  11. package/dist/{chunk-xmq9zpr1.js → chunk-c6rbt85q.js} +1 -1
  12. package/dist/{chunk-6x9e1etb.js → chunk-e4an66v2.js} +3 -3
  13. package/dist/{chunk-s661f8p0.js → chunk-ewhzaqp3.js} +2 -2
  14. package/dist/{chunk-5zzfsv07.js → chunk-gspfm7qh.js} +177 -37
  15. package/dist/{chunk-k9jd2dm0.js → chunk-j5t5nye5.js} +4 -4
  16. package/dist/{chunk-bj73db3f.js → chunk-nzjb36ad.js} +1 -1
  17. package/dist/{chunk-gr816kwr.js → chunk-pd2vz4bm.js} +10 -10
  18. package/dist/{chunk-hrds2xy2.js → chunk-qrm334c6.js} +7 -7
  19. package/dist/{chunk-e838cw9z.js → chunk-r5sw3fe0.js} +11 -11
  20. package/dist/{chunk-txyp31q5.js → chunk-vtfwjhzh.js} +60 -60
  21. package/dist/{chunk-s1pjsak4.js → chunk-wc2kba4z.js} +7 -7
  22. package/dist/{chunk-yafg281p.js → chunk-xcf887a4.js} +18 -18
  23. package/dist/{chunk-26mj3vr6.js → chunk-xe8qf2xy.js} +21 -21
  24. package/dist/{chunk-y2mkzww9.js → chunk-xwya1er0.js} +2 -2
  25. package/dist/{chunk-rjdptgqf.js → chunk-z450wa10.js} +4 -4
  26. package/dist/{chunk-31hk2bjb.js → chunk-znar1th3.js} +4 -4
  27. package/dist/index.js +4 -4
  28. package/package.json +1 -1
@@ -7,11 +7,11 @@ import {
7
7
  decoded2,
8
8
  readOpencode2,
9
9
  runOpencodeReader2
10
- } from "./chunk-3530xts6.js";
11
- import"./chunk-y2mkzww9.js";
12
- import"./chunk-xmq9zpr1.js";
13
- import"./chunk-5zzfsv07.js";
14
- import"./chunk-txyp31q5.js";
10
+ } from "./chunk-56knbdt6.js";
11
+ import"./chunk-xwya1er0.js";
12
+ import"./chunk-c6rbt85q.js";
13
+ import"./chunk-gspfm7qh.js";
14
+ import"./chunk-vtfwjhzh.js";
15
15
  export {
16
16
  decoded2 as decoded,
17
17
  decodedOption2 as decodedOption,
@@ -18,7 +18,7 @@ import {
18
18
  isMinLength,
19
19
  isMaxLength,
20
20
  FiniteFromString
21
- } from "./chunk-txyp31q5.js";
21
+ } from "./chunk-vtfwjhzh.js";
22
22
 
23
23
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/JsonSchema.js
24
24
  var PRE_2020_TO_2020_COLLISIONS = ["$anchor", "$defs", "$dynamicAnchor", "$dynamicRef", "$vocabulary", "contentSchema", "dependentRequired", "dependentSchemas", "maxContains", "minContains", "prefixItems", "unevaluatedItems", "unevaluatedProperties"];
@@ -6,48 +6,7 @@ import {
6
6
  isObject,
7
7
  isJsonObject,
8
8
  isString
9
- } from "./chunk-xmq9zpr1.js";
10
- import {
11
- join,
12
- interrupt,
13
- unbounded,
14
- publishUnsafe,
15
- unbounded2,
16
- offer,
17
- makeUnsafe3,
18
- make10,
19
- fromQueue,
20
- fromPubSub,
21
- map2,
22
- filter,
23
- decodeText,
24
- encodeText,
25
- splitLines,
26
- run,
27
- runHead,
28
- runForEach,
29
- FileSystem,
30
- Path,
31
- embeddedFile,
32
- extractEmbeddedFile,
33
- optionalEnv,
34
- operatorConfigHome,
35
- tempDirectoryScoped,
36
- harnessesUnsupportedInSrt2,
37
- compiled2,
38
- pinnedSrtCommand2,
39
- pinnedSrtStepCommand2,
40
- runSrtCli2,
41
- kitmanCacheDirectory2,
42
- srtSettings2,
43
- srtCacheEnvironment2,
44
- srtInheritedEnv2,
45
- inheritedEnvironment2,
46
- withOnlyEnvironment2,
47
- writeSrtSettings2,
48
- srtStepArgv2,
49
- srtArgv2
50
- } from "./chunk-5zzfsv07.js";
9
+ } from "./chunk-c6rbt85q.js";
51
10
  import {
52
11
  pipeArguments,
53
12
  dual,
@@ -90,7 +49,7 @@ import {
90
49
  isFailure2,
91
50
  hasInterrupts,
92
51
  makeUnsafe5,
93
- make15,
52
+ make16,
94
53
  _await,
95
54
  fail5,
96
55
  isDoneUnsafe,
@@ -210,12 +169,12 @@ import {
210
169
  encodePrettyJsonString,
211
170
  decodeJsonStringSync,
212
171
  encodeUnknownJsonStringSync
213
- } from "./chunk-txyp31q5.js";
172
+ } from "./chunk-vtfwjhzh.js";
214
173
  import {
215
174
  Id,
216
175
  secretReference,
217
176
  secretPlaceholder
218
- } from "./chunk-bv9e34qz.js";
177
+ } from "./chunk-0qz10ek8.js";
219
178
  import {
220
179
  currentTimeMillis,
221
180
  SecureRandom,
@@ -289,7 +248,48 @@ import {
289
248
  installCommand,
290
249
  checkServicesFile,
291
250
  checkServices
292
- } from "./chunk-77k89h98.js";
251
+ } from "./chunk-1t12wvv1.js";
252
+ import {
253
+ join,
254
+ interrupt,
255
+ unbounded,
256
+ publishUnsafe,
257
+ unbounded2,
258
+ offer,
259
+ makeUnsafe3,
260
+ make11,
261
+ fromQueue,
262
+ fromPubSub,
263
+ map2,
264
+ filter,
265
+ decodeText,
266
+ encodeText,
267
+ splitLines,
268
+ run,
269
+ runHead,
270
+ runForEach,
271
+ FileSystem,
272
+ Path,
273
+ embeddedFile,
274
+ extractEmbeddedFile,
275
+ optionalEnv,
276
+ operatorConfigHome,
277
+ tempDirectoryScoped,
278
+ harnessesUnsupportedInSrt2,
279
+ compiled2,
280
+ pinnedSrtCommand2,
281
+ pinnedSrtStepCommand2,
282
+ runSrtCli2,
283
+ kitmanCacheDirectory2,
284
+ srtSettings2,
285
+ srtCacheEnvironment2,
286
+ srtInheritedEnv2,
287
+ inheritedEnvironment2,
288
+ withOnlyEnvironment2,
289
+ writeSrtSettings2,
290
+ srtStepArgv2,
291
+ srtArgv2
292
+ } from "./chunk-gspfm7qh.js";
293
293
  import {
294
294
  writeAgentEnvironmentConfigFile2,
295
295
  readManifestSkillPaths2,
@@ -305,8 +305,8 @@ import {
305
305
  applyAgentEnvironmentMaterialization2,
306
306
  isPathWithin2,
307
307
  skillIdentity2
308
- } from "./chunk-gr816kwr.js";
309
- import"./chunk-6x9e1etb.js";
308
+ } from "./chunk-pd2vz4bm.js";
309
+ import"./chunk-e4an66v2.js";
310
310
  import {
311
311
  egressAllowed,
312
312
  writeSecretRegistry,
@@ -316,7 +316,7 @@ import {
316
316
  secretFilter2,
317
317
  opaqueTunnelRefusal2,
318
318
  isOpaqueConnectReason2
319
- } from "./chunk-cegdw7gw.js";
319
+ } from "./chunk-5j848ckb.js";
320
320
  import {
321
321
  sliceBytes2,
322
322
  maxLineBytes2,
@@ -324,23 +324,23 @@ import {
324
324
  decodedOption2,
325
325
  decoded2,
326
326
  readOpencode2
327
- } from "./chunk-3530xts6.js";
327
+ } from "./chunk-56knbdt6.js";
328
328
  import {
329
329
  uploadRunFile,
330
330
  programLease,
331
331
  rpcRunFiles,
332
332
  programHostsEnv,
333
333
  undeclaredHostsEnv
334
- } from "./chunk-hrds2xy2.js";
335
- import"./chunk-k9jd2dm0.js";
334
+ } from "./chunk-qrm334c6.js";
335
+ import"./chunk-j5t5nye5.js";
336
336
  import {
337
337
  nextInt
338
- } from "./chunk-bj73db3f.js";
338
+ } from "./chunk-nzjb36ad.js";
339
339
  import {
340
340
  ChildProcessSpawner,
341
341
  make3
342
- } from "./chunk-y2mkzww9.js";
343
- import"./chunk-nc1rxeav.js";
342
+ } from "./chunk-xwya1er0.js";
343
+ import"./chunk-4w4spvb1.js";
344
344
 
345
345
  // packages/core/src/sync-kit.ts
346
346
  import { createHash } from "crypto";
@@ -4063,30 +4063,48 @@ var lastingStatus = (seen, status, graceMs) => gen(function* () {
4063
4063
  return entered;
4064
4064
  }
4065
4065
  });
4066
+ var signalled2 = (signal) => (seen) => ({ seen, signal });
4067
+ var submittedAndGraced = (input) => gen(function* () {
4068
+ while (!(yield* input.outputSubmitted))
4069
+ yield* sleep(input.outputPollMs);
4070
+ yield* sleep(input.graceMs);
4071
+ return signalled2("output_submitted")(yield* input.latest);
4072
+ });
4066
4073
  var lastingStop = (input) => gen(function* () {
4067
4074
  let reminders = idleReminders;
4068
4075
  let remindedTurn = -1;
4069
- while (true) {
4070
- const stopped = yield* raceAllFirst([
4071
- until(input.seen, (last) => last.end !== undefined || last.turn > input.promptTurn && !["blocked", "working", "error"].includes(last.status ?? "")),
4072
- lastingStatus(input.seen, "blocked", input.blockedGraceMs),
4073
- lastingStatus(input.seen, "error", input.idleGraceMs)
4074
- ]);
4075
- if (stopped.end !== undefined || stopped.status === "blocked" || stopped.status === "error" || (yield* input.outputSubmitted))
4076
- return stopped;
4077
- const stirred = stirredSince(stopped.turn);
4078
- const waited = yield* until(input.seen, stirred).pipe(timeoutOption(input.idleGraceMs));
4079
- const last = isSome(waited) ? waited.value : yield* input.latest;
4080
- if (stirred(last))
4081
- continue;
4082
- const lastWorkedTurn = last.turn - 1;
4083
- if (lastWorkedTurn > remindedTurn)
4084
- reminders = idleReminders;
4085
- if (reminders === 0 || (yield* input.outputSubmitted))
4086
- return stopped;
4087
- reminders -= 1;
4088
- remindedTurn = (yield* input.remind) ?? Math.max(remindedTurn, lastWorkedTurn);
4089
- }
4076
+ const watch = gen(function* () {
4077
+ while (true) {
4078
+ const stopped = yield* raceAllFirst([
4079
+ map8(until(input.seen, (last) => last.end !== undefined || last.turn > input.promptTurn && !["blocked", "working", "error"].includes(last.status ?? "")), (seen) => signalled2(seen.end === undefined ? "turn_ended" : "terminal_ended")(seen)),
4080
+ map8(lastingStatus(input.seen, "blocked", input.blockedGraceMs), signalled2("blocked")),
4081
+ map8(lastingStatus(input.seen, "error", input.idleGraceMs), signalled2("error"))
4082
+ ]);
4083
+ if (stopped.signal !== "turn_ended" || (yield* input.outputSubmitted))
4084
+ return stopped;
4085
+ const stirred = stirredSince(stopped.seen.turn);
4086
+ const waited = yield* until(input.seen, stirred).pipe(timeoutOption(input.idleGraceMs));
4087
+ const last = isSome(waited) ? waited.value : yield* input.latest;
4088
+ if (stirred(last))
4089
+ continue;
4090
+ const lastWorkedTurn = last.turn - 1;
4091
+ if (lastWorkedTurn > remindedTurn)
4092
+ reminders = idleReminders;
4093
+ if (yield* input.outputSubmitted)
4094
+ return stopped;
4095
+ if (reminders === 0)
4096
+ return signalled2("idle")(stopped.seen);
4097
+ reminders -= 1;
4098
+ remindedTurn = (yield* input.remind) ?? Math.max(remindedTurn, lastWorkedTurn);
4099
+ }
4100
+ });
4101
+ const accepted = submittedAndGraced({
4102
+ outputSubmitted: input.outputSubmitted,
4103
+ outputPollMs: input.outputPollMs,
4104
+ graceMs: input.idleGraceMs,
4105
+ latest: input.latest
4106
+ });
4107
+ return yield* raceFirst(watch, accepted);
4090
4108
  });
4091
4109
  var aborted = (signal) => signal === undefined ? never : callback3((resume) => {
4092
4110
  const abort = () => resume(void_3);
@@ -4323,7 +4341,8 @@ var runAttempt = (request, options) => gen(function* () {
4323
4341
  return;
4324
4342
  yield* stopTerminal(call, address, options.teardownDelayMs);
4325
4343
  });
4326
- const outputSubmitted = request.settled.pipe(orElseSucceed(() => false));
4344
+ let accepted = false;
4345
+ const outputSubmitted = suspend3(() => accepted ? succeed6(true) : request.settled.pipe(orElseSucceed(() => false), tap2((settled) => sync2(() => accepted ||= settled))));
4327
4346
  const readScreen = map8(option2(call((connection) => connection.read(address))), (screen) => isSome(screen) ? redactCredentials(screen.value).trim() : "");
4328
4347
  const judge = (last) => gen(function* () {
4329
4348
  if (yield* outputSubmitted)
@@ -4353,15 +4372,16 @@ var runAttempt = (request, options) => gen(function* () {
4353
4372
  }
4354
4373
  }
4355
4374
  });
4356
- const drive = gen(function* () {
4375
+ const ended = (signal) => (outcome) => ({ signal, outcome });
4376
+ const ending = gen(function* () {
4357
4377
  const ready = yield* until(seen, (last) => last.end !== undefined || last.status !== null && last.status !== "working").pipe(timeoutOption(launchTimeout));
4358
4378
  if (isNone(ready)) {
4359
4379
  const shown = yield* readScreen;
4360
4380
  yield* logWarning("agent_launch_timeout", { attempt: attempt.id, address, screen: shown });
4361
- return failed("harness_launch_timeout", `The Harness reported no status within 120 s of its launch.${shown === "" ? " Its screen was empty." : ` Its screen ended: ${shown.slice(-blockedScreenChars)}`}`);
4381
+ return ended("launch_timeout")(failed("harness_launch_timeout", `The Harness reported no status within 120 s of its launch.${shown === "" ? " Its screen was empty." : ` Its screen ended: ${shown.slice(-blockedScreenChars)}`}`));
4362
4382
  }
4363
4383
  if (ready.value.end !== undefined)
4364
- return yield* judge(ready.value);
4384
+ return ended("terminal_ended")(yield* judge(ready.value));
4365
4385
  const brief = firstMessage(request.launch, workspace, launch.systemBrief === true);
4366
4386
  const readyTurn = ready.value.turn;
4367
4387
  const deliver = (tries) => gen(function* () {
@@ -4378,10 +4398,10 @@ var runAttempt = (request, options) => gen(function* () {
4378
4398
  if (isFailure(sent)) {
4379
4399
  const last = yield* get2(seen);
4380
4400
  if (isTagged(sent.failure, "HerdrCoreConnectionLost"))
4381
- return yield* judge({ ...last, end: "unreachable" });
4401
+ return ended("connection_lost")(yield* judge({ ...last, end: "unreachable" }));
4382
4402
  if (isTagged(sent.failure, "HerdrCoreRpcError") && sent.failure.kind === "blocked")
4383
- return yield* judge({ ...last, status: "blocked" });
4384
- return failed("harness_prompt_failed", `The brief could not be sent: ${sent.failure.message}`);
4403
+ return ended("blocked")(yield* judge({ ...last, status: "blocked" }));
4404
+ return ended("prompt_failed")(failed("harness_prompt_failed", `The brief could not be sent: ${sent.failure.message}`));
4385
4405
  }
4386
4406
  const steering = request.steering;
4387
4407
  const deliveries = steering === undefined ? undefined : yield* forkScoped(forever(flatMap3(steering.next, (note) => call((connection) => connection.send(address, note.text), "fail").pipe(matchEffect2({
@@ -4399,19 +4419,25 @@ var runAttempt = (request, options) => gen(function* () {
4399
4419
  blockedGraceMs: options.blockedGraceMs,
4400
4420
  idleGraceMs: options.idleGraceMs,
4401
4421
  outputSubmitted,
4422
+ outputPollMs: options.outputPollMs,
4402
4423
  latest,
4403
4424
  remind
4404
4425
  });
4405
- const ended = yield* raceFirst(request.executionTimeoutMs === undefined ? asSome2(stop) : stop.pipe(timeoutOption(request.executionTimeoutMs)), as(aborted(request.signal), undefined));
4426
+ const stopped = yield* raceFirst(request.executionTimeoutMs === undefined ? asSome2(stop) : stop.pipe(timeoutOption(request.executionTimeoutMs)), as(aborted(request.signal), undefined));
4406
4427
  if (steering !== undefined && deliveries !== undefined) {
4407
4428
  yield* interrupt(deliveries);
4408
4429
  yield* forEach(yield* steering.undelivered, (note) => steering.report(note, false), { discard: true });
4409
4430
  }
4410
- if (ended === undefined)
4411
- return canceled;
4412
- if (isNone(ended))
4413
- return (yield* outputSubmitted) ? { status: "settled" } : failed("timeout", "The agent did not submit its Output before the Step timed out.");
4414
- return yield* judge(ended.value);
4431
+ if (stopped === undefined)
4432
+ return ended("canceled")(canceled);
4433
+ if (isNone(stopped))
4434
+ return ended("step_timeout")((yield* outputSubmitted) ? { status: "settled" } : failed("timeout", "The agent did not submit its Output before the Step timed out."));
4435
+ return ended(stopped.value.signal)(yield* judge(stopped.value.seen));
4436
+ });
4437
+ const drive = gen(function* () {
4438
+ const { signal, outcome } = yield* ending;
4439
+ yield* logInfo("agent_step_ended", { attempt: attempt.id, address, signal, status: outcome.status });
4440
+ return outcome;
4415
4441
  });
4416
4442
  return yield* ensuring2(drive, stop);
4417
4443
  }).pipe(ensuring2(asVoid(options.stepProcesses.reapAttempt(request.runnerId, request.attempt.attempt.id))), ensuring2(request.workspace.cleanup === undefined ? void_3 : ignore(request.workspace.cleanup)), scoped);
@@ -4429,6 +4455,7 @@ var herdrCoreAgentBackendLayer = (options) => effect(AgentBackend, gen(function*
4429
4455
  briefAckMs: options.briefAckMs ?? 30000,
4430
4456
  blockedGraceMs: options.blockedGraceMs ?? 180000,
4431
4457
  idleGraceMs: options.idleGraceMs ?? 60000,
4458
+ outputPollMs: options.outputPollMs ?? 1e4,
4432
4459
  home: options.home ?? homedir2(),
4433
4460
  ...options.srtCommand === undefined ? undefined : { srtCommand: options.srtCommand },
4434
4461
  ...options.srtStepCommand === undefined ? undefined : { srtStepCommand: options.srtStepCommand },
@@ -7037,7 +7064,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
7037
7064
  return {
7038
7065
  request: (method, params) => gen(function* () {
7039
7066
  const id = ++lastId;
7040
- const deferred = yield* make15();
7067
+ const deferred = yield* make16();
7041
7068
  pending.set(id, deferred);
7042
7069
  yield* send({ id, method, params });
7043
7070
  return yield* _await(deferred).pipe(mapError2((error) => new CodexAppServerFailed({ reason: `${method}: ${error.message}` })));
@@ -7180,7 +7207,7 @@ var kitmanMcpPreflight = (mcp) => gen(function* () {
7180
7207
  const server = yield* spawner.spawn(make3(mcp.command, [...mcp.args], {
7181
7208
  extendEnv: true,
7182
7209
  env: mcp.env,
7183
- stdin: { stream: make10(new TextEncoder().encode(handshake)), endOnDone: false },
7210
+ stdin: { stream: make11(new TextEncoder().encode(handshake)), endOnDone: false },
7184
7211
  stderr: "ignore"
7185
7212
  }));
7186
7213
  const reply = yield* server.stdout.pipe(decodeText, splitLines, map2((line) => getOrUndefined(decodeJsonStringOption(line))), filter((message) => isJsonObject(message) && message.id === 2), runHead);
@@ -7254,7 +7281,7 @@ var programProcessExecutor = (input) => (work) => gen(function* () {
7254
7281
  const exitCode = sandbox === undefined ? yield* gen(function* () {
7255
7282
  const spawner = yield* ChildProcessSpawner;
7256
7283
  const handle = yield* spawner.spawn(make3(input.bun ?? process.execPath, [file], {
7257
- stdin: make10(new TextEncoder().encode(stdin)),
7284
+ stdin: make11(new TextEncoder().encode(stdin)),
7258
7285
  stdout: "inherit",
7259
7286
  stderr: "inherit",
7260
7287
  extendEnv: false,