@kitman-sh/cli 0.12.0-rc.4 → 0.12.0-rc.6

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-b50dvx41.js → chunk-0346hwh6.js} +5 -5
  2. package/dist/{chunk-6b0k02x4.js → chunk-0qz10ek8.js} +1 -1
  3. package/dist/{chunk-nzsrse8d.js → chunk-15geyg2d.js} +87 -59
  4. package/dist/{chunk-r1z41qx6.js → chunk-1t12wvv1.js} +109 -108
  5. package/dist/{chunk-7kjsvwzv.js → chunk-4w4spvb1.js} +5 -5
  6. package/dist/{chunk-k81ay8y5.js → chunk-56knbdt6.js} +8 -8
  7. package/dist/{chunk-xavcp9se.js → chunk-5j848ckb.js} +2 -2
  8. package/dist/{chunk-ydydx55z.js → chunk-bvf6e6yg.js} +1 -1
  9. package/dist/{chunk-c9007k48.js → chunk-c6rbt85q.js} +1 -1
  10. package/dist/{chunk-ezf2myj0.js → chunk-e4an66v2.js} +3 -3
  11. package/dist/{chunk-xy5f2nv9.js → chunk-ewhzaqp3.js} +2 -2
  12. package/dist/{chunk-qjd6w9sw.js → chunk-fxm2jhbd.js} +2 -2
  13. package/dist/{chunk-zmcghp8w.js → chunk-gspfm7qh.js} +17 -17
  14. package/dist/{chunk-e7q2frvs.js → chunk-j5t5nye5.js} +7 -7
  15. package/dist/{chunk-rjasmnav.js → chunk-ktr2smac.js} +41 -28
  16. package/dist/{chunk-bq55md8p.js → chunk-nzjb36ad.js} +1 -1
  17. package/dist/{chunk-w0aj9mkz.js → chunk-pd2vz4bm.js} +5 -5
  18. package/dist/{chunk-ckkpqcfv.js → chunk-qrm334c6.js} +4 -4
  19. package/dist/{chunk-kybp1mkk.js → chunk-r5sw3fe0.js} +8 -8
  20. package/dist/{chunk-t2mr6z38.js → chunk-r7f8tjc8.js} +24 -24
  21. package/dist/{chunk-79gx7ek9.js → chunk-vtfwjhzh.js} +28 -70
  22. package/dist/{chunk-aafxvmj1.js → chunk-wc2kba4z.js} +7 -7
  23. package/dist/{chunk-w6cm939j.js → chunk-x6vj1tf8.js} +12 -12
  24. package/dist/{chunk-jntxtx9j.js → chunk-xwya1er0.js} +60 -14
  25. package/dist/{chunk-pw10mq9e.js → chunk-z450wa10.js} +4 -4
  26. package/dist/{chunk-74txrt4s.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-k81ay8y5.js";
11
- import"./chunk-jntxtx9j.js";
12
- import"./chunk-c9007k48.js";
13
- import"./chunk-zmcghp8w.js";
14
- import"./chunk-79gx7ek9.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-79gx7ek9.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,7 +6,7 @@ import {
6
6
  isObject,
7
7
  isJsonObject,
8
8
  isString
9
- } from "./chunk-c9007k48.js";
9
+ } from "./chunk-c6rbt85q.js";
10
10
  import {
11
11
  pipeArguments,
12
12
  dual,
@@ -49,7 +49,7 @@ import {
49
49
  isFailure2,
50
50
  hasInterrupts,
51
51
  makeUnsafe5,
52
- make15,
52
+ make16,
53
53
  _await,
54
54
  fail5,
55
55
  isDoneUnsafe,
@@ -169,12 +169,12 @@ import {
169
169
  encodePrettyJsonString,
170
170
  decodeJsonStringSync,
171
171
  encodeUnknownJsonStringSync
172
- } from "./chunk-79gx7ek9.js";
172
+ } from "./chunk-vtfwjhzh.js";
173
173
  import {
174
174
  Id,
175
175
  secretReference,
176
176
  secretPlaceholder
177
- } from "./chunk-6b0k02x4.js";
177
+ } from "./chunk-0qz10ek8.js";
178
178
  import {
179
179
  currentTimeMillis,
180
180
  SecureRandom,
@@ -248,7 +248,7 @@ import {
248
248
  installCommand,
249
249
  checkServicesFile,
250
250
  checkServices
251
- } from "./chunk-r1z41qx6.js";
251
+ } from "./chunk-1t12wvv1.js";
252
252
  import {
253
253
  join,
254
254
  interrupt,
@@ -257,7 +257,7 @@ import {
257
257
  unbounded2,
258
258
  offer,
259
259
  makeUnsafe3,
260
- make10,
260
+ make11,
261
261
  fromQueue,
262
262
  fromPubSub,
263
263
  map2,
@@ -289,7 +289,7 @@ import {
289
289
  writeSrtSettings2,
290
290
  srtStepArgv2,
291
291
  srtArgv2
292
- } from "./chunk-zmcghp8w.js";
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-w0aj9mkz.js";
309
- import"./chunk-ezf2myj0.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-xavcp9se.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-k81ay8y5.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-ckkpqcfv.js";
335
- import"./chunk-e7q2frvs.js";
334
+ } from "./chunk-qrm334c6.js";
335
+ import"./chunk-j5t5nye5.js";
336
336
  import {
337
337
  nextInt
338
- } from "./chunk-bq55md8p.js";
338
+ } from "./chunk-nzjb36ad.js";
339
339
  import {
340
340
  ChildProcessSpawner,
341
- make2
342
- } from "./chunk-jntxtx9j.js";
343
- import"./chunk-7kjsvwzv.js";
341
+ make3
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 },
@@ -5966,11 +5993,12 @@ var clearSettledCheckpoints = (rpc, checkouts) => gen(function* () {
5966
5993
  var deleteRef = (checkouts, repoBinding, ref) => gen(function* () {
5967
5994
  const repository = yield* checkouts.clone(repoBinding);
5968
5995
  const env = yield* checkouts.transferEnv(repoBinding);
5969
- if ((yield* runCommand2("git", ["-C", repository, "ls-remote", "origin", ref], { env })).trim() !== "")
5996
+ const onOrigin = map8(runCommand2("git", ["-C", repository, "ls-remote", "origin", ref], { env }), (listed) => listed.trim() !== "");
5997
+ if (yield* onOrigin)
5970
5998
  yield* runCommand2("git", ["-C", repository, ...stallLimit, "push", "origin", "--delete", ref], {
5971
5999
  ...transfer,
5972
6000
  env
5973
- });
6001
+ }).pipe(catch_((failed) => flatMap3(orElseSucceed(onOrigin, () => true), (kept) => kept ? fail7(failed) : void_3)));
5974
6002
  });
5975
6003
  var listenForSignals = (input) => gen(function* () {
5976
6004
  const services = yield* context();
@@ -7013,7 +7041,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
7013
7041
  const input = yield* unbounded2();
7014
7042
  const pending = new Map;
7015
7043
  let lastId = 0;
7016
- const handle = yield* spawner.spawn(make2(binary, ["app-server"], {
7044
+ const handle = yield* spawner.spawn(make3(binary, ["app-server"], {
7017
7045
  cwd: env.home,
7018
7046
  extendEnv: true,
7019
7047
  env: { HOME: env.home, CODEX_HOME: env.codexHome },
@@ -7036,7 +7064,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
7036
7064
  return {
7037
7065
  request: (method, params) => gen(function* () {
7038
7066
  const id = ++lastId;
7039
- const deferred = yield* make15();
7067
+ const deferred = yield* make16();
7040
7068
  pending.set(id, deferred);
7041
7069
  yield* send({ id, method, params });
7042
7070
  return yield* _await(deferred).pipe(mapError2((error) => new CodexAppServerFailed({ reason: `${method}: ${error.message}` })));
@@ -7176,10 +7204,10 @@ var handshake = [
7176
7204
  `).join("");
7177
7205
  var kitmanMcpPreflight = (mcp) => gen(function* () {
7178
7206
  const spawner = yield* ChildProcessSpawner;
7179
- const server = yield* spawner.spawn(make2(mcp.command, [...mcp.args], {
7207
+ const server = yield* spawner.spawn(make3(mcp.command, [...mcp.args], {
7180
7208
  extendEnv: true,
7181
7209
  env: mcp.env,
7182
- stdin: { stream: make10(new TextEncoder().encode(handshake)), endOnDone: false },
7210
+ stdin: { stream: make11(new TextEncoder().encode(handshake)), endOnDone: false },
7183
7211
  stderr: "ignore"
7184
7212
  }));
7185
7213
  const reply = yield* server.stdout.pipe(decodeText, splitLines, map2((line) => getOrUndefined(decodeJsonStringOption(line))), filter((message) => isJsonObject(message) && message.id === 2), runHead);
@@ -7252,8 +7280,8 @@ var programProcessExecutor = (input) => (work) => gen(function* () {
7252
7280
  };
7253
7281
  const exitCode = sandbox === undefined ? yield* gen(function* () {
7254
7282
  const spawner = yield* ChildProcessSpawner;
7255
- const handle = yield* spawner.spawn(make2(input.bun ?? process.execPath, [file], {
7256
- stdin: make10(new TextEncoder().encode(stdin)),
7283
+ const handle = yield* spawner.spawn(make3(input.bun ?? process.execPath, [file], {
7284
+ stdin: make11(new TextEncoder().encode(stdin)),
7257
7285
  stdout: "inherit",
7258
7286
  stderr: "inherit",
7259
7287
  extendEnv: false,