@kitman-sh/cli 0.15.1 → 0.16.1

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-zy4sv70r.js → chunk-1r026thg.js} +6 -6
  2. package/dist/{chunk-69xka6ew.js → chunk-3b198ntn.js} +1 -1
  3. package/dist/{chunk-91tmbf95.js → chunk-4yjcehqr.js} +17 -17
  4. package/dist/{chunk-6h70kent.js → chunk-5s4sgrak.js} +7 -7
  5. package/dist/{chunk-wh4bpc4w.js → chunk-8f632x21.js} +4 -4
  6. package/dist/{chunk-tgt9a3yz.js → chunk-9qfyb5r2.js} +6 -6
  7. package/dist/{chunk-fggwdr03.js → chunk-b0b9v7t9.js} +17 -17
  8. package/dist/{chunk-60fhzjx3.js → chunk-bcqqrwsk.js} +114 -26
  9. package/dist/{chunk-vg78dz3w.js → chunk-bkteq6b3.js} +28 -177
  10. package/dist/{chunk-fzaecdgv.js → chunk-djdhep8n.js} +3 -3
  11. package/dist/{chunk-f36s9s1g.js → chunk-dxfab1aj.js} +273 -113
  12. package/dist/{chunk-dv4v0tbn.js → chunk-e42hjb3j.js} +33 -29
  13. package/dist/{chunk-xx711t5r.js → chunk-eavx040m.js} +4 -4
  14. package/dist/{chunk-csxxwscf.js → chunk-f2y0z04q.js} +1 -1
  15. package/dist/{chunk-kskb0hkb.js → chunk-ft3gnwd1.js} +3 -3
  16. package/dist/{chunk-k2wd9r6t.js → chunk-g1f0cjqe.js} +2 -2
  17. package/dist/{chunk-3ns4sbfb.js → chunk-gwzzacep.js} +1 -1
  18. package/dist/{chunk-d40233pm.js → chunk-hwqecp0m.js} +8 -8
  19. package/dist/{chunk-dx792s4w.js → chunk-rfnasm3c.js} +61 -61
  20. package/dist/{chunk-8wpg3rph.js → chunk-scwj3w7m.js} +2 -2
  21. package/dist/{chunk-0ws25xvg.js → chunk-sd8b4k1t.js} +2 -2
  22. package/dist/{chunk-2vxb3q01.js → chunk-tc7td60t.js} +1 -1
  23. package/dist/{chunk-ygx2pda7.js → chunk-tx7et9g7.js} +4 -4
  24. package/dist/{chunk-5hkdgzh4.js → chunk-x83q18w0.js} +1 -1
  25. package/dist/{chunk-39ykbhq8.js → chunk-xy3hcdhr.js} +5 -5
  26. package/dist/{chunk-xrjt25ns.js → chunk-yja59yh8.js} +10 -10
  27. package/dist/index.js +4 -4
  28. package/package.json +1 -1
@@ -43,7 +43,7 @@ import {
43
43
  isFailure2,
44
44
  hasInterrupts,
45
45
  makeUnsafe5,
46
- make16,
46
+ make15,
47
47
  _await,
48
48
  fail5,
49
49
  isDoneUnsafe,
@@ -170,7 +170,7 @@ import {
170
170
  decodeJsonStringSync,
171
171
  encodeUnknownJsonStringSync,
172
172
  storable
173
- } from "./chunk-dx792s4w.js";
173
+ } from "./chunk-rfnasm3c.js";
174
174
  import {
175
175
  currentTimeMillis,
176
176
  SecureRandom,
@@ -200,9 +200,11 @@ import {
200
200
  failedTestsOf,
201
201
  testOutcomes,
202
202
  checkTests,
203
+ loopSafeTextMaxLength,
203
204
  reportedModelName,
204
205
  calverNumbers,
205
206
  compareCalver,
207
+ defaultDeployCommand,
206
208
  MeasureSample,
207
209
  compareCommitMax,
208
210
  commitMessageMax,
@@ -257,7 +259,7 @@ import {
257
259
  checkServicesFile,
258
260
  checkServices,
259
261
  serviceChecks
260
- } from "./chunk-f36s9s1g.js";
262
+ } from "./chunk-dxfab1aj.js";
261
263
  import {
262
264
  join,
263
265
  interrupt,
@@ -266,7 +268,7 @@ import {
266
268
  unbounded2,
267
269
  offer,
268
270
  makeUnsafe3,
269
- make11,
271
+ make10,
270
272
  fromQueue,
271
273
  fromPubSub,
272
274
  map2,
@@ -303,7 +305,7 @@ import {
303
305
  writeSrtSettings2,
304
306
  srtStepArgv2,
305
307
  srtArgv2
306
- } from "./chunk-vg78dz3w.js";
308
+ } from "./chunk-bkteq6b3.js";
307
309
  import {
308
310
  writeAgentEnvironmentConfigFile2,
309
311
  readManifestSkillPaths2,
@@ -319,8 +321,8 @@ import {
319
321
  applyAgentEnvironmentMaterialization2,
320
322
  isPathWithin2,
321
323
  skillIdentity2
322
- } from "./chunk-ygx2pda7.js";
323
- import"./chunk-kskb0hkb.js";
324
+ } from "./chunk-tx7et9g7.js";
325
+ import"./chunk-ft3gnwd1.js";
324
326
  import {
325
327
  egressAllowed,
326
328
  writeSecretRegistry,
@@ -330,7 +332,7 @@ import {
330
332
  secretFilter2,
331
333
  opaqueTunnelRefusal2,
332
334
  isOpaqueConnectReason2
333
- } from "./chunk-0ws25xvg.js";
335
+ } from "./chunk-sd8b4k1t.js";
334
336
  import {
335
337
  sliceBytes2,
336
338
  maxLineBytes2,
@@ -338,29 +340,29 @@ import {
338
340
  decodedOption2,
339
341
  decoded2,
340
342
  readOpencode2
341
- } from "./chunk-39ykbhq8.js";
343
+ } from "./chunk-xy3hcdhr.js";
342
344
  import {
343
345
  uploadRunFile,
344
346
  programLease,
345
347
  rpcRunFiles,
346
348
  programHostsEnv,
347
349
  undeclaredHostsEnv
348
- } from "./chunk-d40233pm.js";
349
- import"./chunk-zy4sv70r.js";
350
+ } from "./chunk-hwqecp0m.js";
351
+ import"./chunk-1r026thg.js";
350
352
  import {
351
353
  nextInt
352
- } from "./chunk-3ns4sbfb.js";
353
- import"./chunk-csxxwscf.js";
354
+ } from "./chunk-gwzzacep.js";
355
+ import"./chunk-f2y0z04q.js";
354
356
  import {
355
357
  ChildProcessSpawner,
356
358
  make3
357
- } from "./chunk-k2wd9r6t.js";
358
- import"./chunk-91tmbf95.js";
359
+ } from "./chunk-g1f0cjqe.js";
360
+ import"./chunk-4yjcehqr.js";
359
361
  import {
360
362
  Id,
361
363
  secretReference,
362
364
  secretPlaceholder
363
- } from "./chunk-5hkdgzh4.js";
365
+ } from "./chunk-x83q18w0.js";
364
366
 
365
367
  // packages/core/src/sync-kit.ts
366
368
  import { createHash } from "crypto";
@@ -5904,12 +5906,22 @@ var antigravityWait = (said) => {
5904
5906
  const [, hours, minutes, seconds] = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+(?:\.\d+)?)s)?$/.exec(span) ?? [];
5905
5907
  return (Number(hours ?? 0) * 3600 + Number(minutes ?? 0) * 60 + Number(seconds ?? 0)) * 1000;
5906
5908
  };
5907
- var antigravityProviderRefusal = (line) => {
5909
+ var antigravityErrorSaid = (line) => {
5908
5910
  if (!isJsonObject(line) || line.source === "USER_EXPLICIT")
5909
5911
  return;
5910
5912
  if (line.type !== "ERROR_MESSAGE" && (line.status !== "ERROR" || line.type === "GENERIC"))
5911
5913
  return;
5912
- const said = [line.error, line.content].find(isString2) ?? "";
5914
+ return [line.error, line.content].find((said) => isString2(said) && said.trim() !== "") ?? "";
5915
+ };
5916
+ var antigravityError = (line) => {
5917
+ const said = antigravityErrorSaid(line)?.trim();
5918
+ return said === undefined || said === "" ? undefined : said;
5919
+ };
5920
+ var antigravityWentOn = (line) => isJsonObject(line) && (line.source === "USER_EXPLICIT" || line.source === "MODEL" && line.type === "PLANNER_RESPONSE");
5921
+ var antigravityProviderRefusal = (line) => {
5922
+ const said = antigravityErrorSaid(line);
5923
+ if (!isJsonObject(line) || said === undefined)
5924
+ return;
5913
5925
  const summary = bounded(said);
5914
5926
  if (quotaError.test(said)) {
5915
5927
  const wait = antigravityWait(said);
@@ -5931,6 +5943,7 @@ var sessionRefusals = new Map([
5931
5943
  ["pi", piProviderRefusal],
5932
5944
  ["antigravity", antigravityProviderRefusal]
5933
5945
  ]);
5946
+ var sessionErrors = new Map([["antigravity", { said: antigravityError, wentOn: antigravityWentOn }]]);
5934
5947
  var count = (value) => isNumber2(value) && value > 0 ? Math.floor(value) : 0;
5935
5948
  var tokenCounter = (harness) => {
5936
5949
  const counted = { input: 0, output: 0, cached: 0 };
@@ -6273,6 +6286,7 @@ var transcriptRelay = (input) => {
6273
6286
  const asking = new Set;
6274
6287
  let loginLost;
6275
6288
  let refusal;
6289
+ let harnessError;
6276
6290
  let codexLimits;
6277
6291
  let errorReadAt;
6278
6292
  let opencodeModel;
@@ -6379,6 +6393,12 @@ var transcriptRelay = (input) => {
6379
6393
  heard(refused);
6380
6394
  else if (events.length > 0 || input.harness === "pi" && piReplied(value))
6381
6395
  refusal = undefined;
6396
+ const errors = sessionErrors.get(input.harness);
6397
+ const errored = errors?.said(value);
6398
+ if (errored !== undefined)
6399
+ harnessError = errored;
6400
+ else if (errors?.wentOn(value) === true)
6401
+ harnessError = undefined;
6382
6402
  return events.slice(0, maxEventsPerLine);
6383
6403
  }))).pipe(uninterruptible);
6384
6404
  yield* yieldNow;
@@ -6496,6 +6516,7 @@ var transcriptRelay = (input) => {
6496
6516
  asking: sync2(() => asking.size > 0),
6497
6517
  loginLost: sync2(() => loginLost),
6498
6518
  refusal: sync2(() => refusal),
6519
+ harnessError: sync2(() => harnessError),
6499
6520
  ranModel: sync2(() => opencodeModel ?? tokens.model()),
6500
6521
  tokens: (source) => gen(function* () {
6501
6522
  const own = tokens.tokens();
@@ -6564,6 +6585,55 @@ var sessionLines = (file) => gen(function* () {
6564
6585
  }
6565
6586
  });
6566
6587
 
6588
+ // packages/agent-runtime/src/harness-error-diagnosis.ts
6589
+ var harnessLogs = new Map([["antigravity", ".gemini/antigravity-cli/log"]]);
6590
+ var logTailBytes = 256 * 1024;
6591
+ var loggedErrorsKept = 8;
6592
+ var glogLine = /^([IWEF])\d{4} \d{2}:\d{2}:\d{2}\.\d+\s+\d+ [^\]]+\] (.+)$/;
6593
+ var loggedErrors = (log) => {
6594
+ const errors = log.split(`
6595
+ `).flatMap((line) => {
6596
+ const [, level, said] = glogLine.exec(line.trim()) ?? [];
6597
+ return said !== undefined && (level === "E" || level === "F" || /error ID:/i.test(said)) ? [said.trim()] : [];
6598
+ });
6599
+ return [...new Set(errors.toReversed())].slice(0, loggedErrorsKept).toReversed();
6600
+ };
6601
+ var pieceChars = 2000;
6602
+ var diagnosisChars = 8000;
6603
+ var whole = (said) => {
6604
+ const redacted = redactCredentials(said);
6605
+ return redacted.length <= pieceChars ? redacted : `[${redacted.length} characters left out]`;
6606
+ };
6607
+ var harnessErrorDiagnosis = (said) => {
6608
+ const session = said.sessionError === undefined ? [] : [`Its session's last error: ${whole(said.sessionError)}`];
6609
+ const logged = said.loggedErrors.map((error) => `- ${whole(error)}`);
6610
+ while (logged.length > 0 && [...session, "Its log ended with these errors:", ...logged].join(`
6611
+ `).length > diagnosisChars)
6612
+ logged.shift();
6613
+ const lines = [...session, ...logged.length === 0 ? [] : ["Its log ended with these errors:", ...logged]];
6614
+ return lines.length === 0 ? undefined : lines.join(`
6615
+ `);
6616
+ };
6617
+ var harnessLogErrors = (harness, home) => gen(function* () {
6618
+ const directory = harnessLogs.get(harness);
6619
+ if (directory === undefined)
6620
+ return [];
6621
+ const fs = yield* FileSystem;
6622
+ const path = yield* Path;
6623
+ const logs = path.join(home, directory);
6624
+ if (!(yield* fs.exists(logs)))
6625
+ return [];
6626
+ const latest = (yield* fs.readDirectory(logs)).filter((name) => name.endsWith(".log")).toSorted().at(-1);
6627
+ if (latest === undefined)
6628
+ return [];
6629
+ const place = { path: path.join(logs, latest), confinedTo: home };
6630
+ const size = yield* sessionFileSize(place);
6631
+ const from = Math.max(0, size - logTailBytes);
6632
+ const text = new TextDecoder().decode(yield* readSessionRange(place, from, logTailBytes));
6633
+ return loggedErrors(from === 0 ? text : text.slice(text.indexOf(`
6634
+ `) + 1));
6635
+ }).pipe(catch_((error) => as(logWarning("runner_harness_log_unread", error.message), Array.of())));
6636
+
6567
6637
  // packages/agent-runtime/src/agent-step-executor.ts
6568
6638
  import { DANGEROUS_DIRECTORIES, DANGEROUS_FILES } from "@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-utils.js";
6569
6639
  var newSessionId = SecureRandom.pipe(flatMap3((random) => random.uuidV4()), provide3(layerWebCrypto));
@@ -7157,6 +7227,7 @@ ${afterMergeFailed}`];
7157
7227
  let tokens;
7158
7228
  let ranModel;
7159
7229
  let launched = false;
7230
+ let harnessErrorSaid;
7160
7231
  const attemptScope = yield* scope2;
7161
7232
  const relayed = relay === undefined || adapter === undefined ? void_3 : gen(function* () {
7162
7233
  source ??= yield* transcriptSource(adapter, {
@@ -7261,6 +7332,18 @@ ${afterMergeFailed}`];
7261
7332
  yield* interrupt(relaying);
7262
7333
  const state = isSuccess2(exit) ? exit.value.status : hasInterrupts(exit) ? "canceled" : "failed";
7263
7334
  yield* relayed.pipe(timeout("5 seconds"), ignore);
7335
+ if (isSuccess2(exit) && "restart" in exit.value && exit.value.restart?.reason === "harness_error") {
7336
+ const sessionError = yield* relay.harnessError;
7337
+ const logged = yield* harnessLogErrors(adapter?.id ?? "", sessions.home);
7338
+ harnessErrorSaid = harnessErrorDiagnosis({
7339
+ ...sessionError === undefined ? undefined : { sessionError },
7340
+ loggedErrors: logged
7341
+ });
7342
+ if (harnessErrorSaid !== undefined) {
7343
+ yield* logWarning("agent_harness_error", { attempt: work.id, said: harnessErrorSaid });
7344
+ yield* relay.record([{ kind: "harness_error", text: harnessErrorSaid }]);
7345
+ }
7346
+ }
7264
7347
  const spentNow = yield* relay.tokens(source).pipe(timeoutOrElse({ duration: "5 seconds", orElse: () => relay.tokens(undefined) }));
7265
7348
  tokens = spentNow;
7266
7349
  ranModel = yield* relay.ranModel;
@@ -7291,16 +7374,17 @@ ${afterMergeFailed}`];
7291
7374
  harnessHold: refusalHold(refused),
7292
7375
  ...spent
7293
7376
  };
7294
- if (backend === "docker" && "restart" in ran && ran.restart !== undefined)
7377
+ if (backend === "docker" && "restart" in ran && ran.restart?.reason === "login_revoked")
7295
7378
  return {
7296
7379
  status: "failed",
7297
7380
  failureSummary: ran.summary,
7298
7381
  harnessHold: refusalHold({ summary: ran.summary, kind: "login_refused" }),
7299
7382
  ...spent
7300
7383
  };
7384
+ const recordedWhy = " Its Transcript records what the Harness said of the error.";
7301
7385
  return {
7302
7386
  status: ran.status,
7303
- failureSummary: ran.summary,
7387
+ failureSummary: harnessErrorSaid === undefined || ran.summary.length + recordedWhy.length > loopSafeTextMaxLength ? ran.summary : `${ran.summary}${recordedWhy}`,
7304
7388
  ..."harnessHold" in ran && ran.harnessHold !== undefined ? { harnessHold: ran.harnessHold } : undefined,
7305
7389
  ..."restart" in ran && ran.restart !== undefined ? { restart: ran.restart } : undefined,
7306
7390
  ...spent
@@ -7927,7 +8011,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
7927
8011
  return {
7928
8012
  request: (method, params) => gen(function* () {
7929
8013
  const id = ++lastId;
7930
- const deferred = yield* make16();
8014
+ const deferred = yield* make15();
7931
8015
  pending.set(id, deferred);
7932
8016
  yield* send({ id, method, params });
7933
8017
  return yield* _await(deferred).pipe(mapError2((error) => new CodexAppServerFailed({ reason: `${method}: ${error.message}` })));
@@ -8070,7 +8154,7 @@ var kitmanMcpPreflight = (mcp) => gen(function* () {
8070
8154
  const server = yield* spawner.spawn(make3(mcp.command, [...mcp.args], {
8071
8155
  extendEnv: true,
8072
8156
  env: mcp.env,
8073
- stdin: { stream: make11(new TextEncoder().encode(handshake)), endOnDone: false },
8157
+ stdin: { stream: make10(new TextEncoder().encode(handshake)), endOnDone: false },
8074
8158
  stderr: "ignore"
8075
8159
  }));
8076
8160
  const reply = yield* server.stdout.pipe(decodeText, splitLines, map2((line) => getOrUndefined(decodeJsonStringOption(line))), filter((message) => isJsonObject(message) && message.id === 2), runHead);
@@ -8144,7 +8228,7 @@ var programProcessExecutor = (input) => (work) => gen(function* () {
8144
8228
  const exitCode = sandbox === undefined ? yield* gen(function* () {
8145
8229
  const spawner = yield* ChildProcessSpawner;
8146
8230
  const handle = yield* spawner.spawn(make3(input.bun ?? process.execPath, [file], {
8147
- stdin: make11(new TextEncoder().encode(stdin)),
8231
+ stdin: make10(new TextEncoder().encode(stdin)),
8148
8232
  stdout: "inherit",
8149
8233
  stderr: "inherit",
8150
8234
  extendEnv: false,
@@ -8580,9 +8664,11 @@ var checkRunner = (work, sandbox, cache, inherited) => (checkout) => ({
8580
8664
  secretRegistry,
8581
8665
  onOutput,
8582
8666
  postgres,
8583
- docker
8667
+ docker,
8668
+ runnerGitConfig
8584
8669
  }) => {
8585
- const env = { ...added, ...checkGitEnvironment, KITMAN_RUN_FILES_DIR: filesDir };
8670
+ const gitEnvironment = runnerGitConfig === true ? { GIT_TERMINAL_PROMPT: "0" } : checkGitEnvironment;
8671
+ const env = { ...added, ...gitEnvironment, KITMAN_RUN_FILES_DIR: filesDir };
8586
8672
  const output = onOutput === undefined ? undefined : { onOutput };
8587
8673
  if (sandbox === undefined || sandbox.backend === undefined) {
8588
8674
  return runShell2(command, {
@@ -9432,7 +9518,9 @@ var verificationExecutor = (input) => (work) => gen(function* () {
9432
9518
  };
9433
9519
  const sandboxed = input.sandbox?.backend !== undefined;
9434
9520
  const revocations = input.revokedSecrets === undefined ? undefined : { revoked: input.revokedSecrets, every: input.revocationEvery ?? "30 seconds" };
9435
- const commanded = yield* runApprovedCommand(work, command, head, sandboxed, runIn(head), input.runFiles, revocations);
9521
+ const deploysAsOwner = input.runsDeployScripts === true && command.run === defaultDeployCommand.name;
9522
+ const run = runIn(head);
9523
+ const commanded = yield* runApprovedCommand(work, command, head, sandboxed, deploysAsOwner ? (call) => run({ ...call, runnerGitConfig: true }) : run, input.runFiles, revocations);
9436
9524
  if ("failed" in commanded)
9437
9525
  return { status: "failed", failureSummary: commanded.failed };
9438
9526
  const pushed = command.branch === undefined || commanded.result.status !== "exited" || commanded.result.exitCode !== 0 ? undefined : yield* result(pushCommandChange(checkouts, work, head, command.branch));