@dadado/agent-kit-cli 6.25.0 → 6.26.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 (75) hide show
  1. package/dashboard/dashboard.html +3 -3
  2. package/dashboard/lib/guards.mjs +1 -0
  3. package/dist/{add-OYLOMCM6.js → add-G7KEZLWP.js} +7 -6
  4. package/dist/{chunk-7HDQEK6T.js → chunk-2G4K4ZI5.js} +7 -3
  5. package/dist/{chunk-QLTGHJB3.js → chunk-2GXN7HVG.js} +5 -5
  6. package/dist/{chunk-IFBIO7VT.js → chunk-3KFLQE6Y.js} +1533 -52
  7. package/dist/{chunk-GQSSXDDK.js → chunk-ARJRICI2.js} +1 -1
  8. package/dist/{chunk-6WUKLS4D.js → chunk-BIFTTL2O.js} +1 -1
  9. package/dist/{chunk-QACMV46U.js → chunk-BSK6C4UO.js} +19 -12
  10. package/dist/{chunk-NJ2SUSWX.js → chunk-BVZDPVUL.js} +1 -1
  11. package/dist/{chunk-GMG7ZH4E.js → chunk-DOMBVLI4.js} +13 -13
  12. package/dist/{chunk-2F6NMQOA.js → chunk-FB6G6OD6.js} +3 -3
  13. package/dist/{chunk-MFKHIWEL.js → chunk-FOVHFMSH.js} +1 -1
  14. package/dist/{chunk-EO5NGAYV.js → chunk-FUSNEYGU.js} +29 -3
  15. package/dist/{chunk-SAQ3EE5R.js → chunk-HGB4DHXV.js} +3 -3
  16. package/dist/{chunk-6M6UKECW.js → chunk-IHVJTGYR.js} +0 -32
  17. package/dist/chunk-KMK4T4ZM.js +34 -0
  18. package/dist/{chunk-ZMYV6PRE.js → chunk-LEVNLHH3.js} +2 -1
  19. package/dist/{chunk-2XLI7XEY.js → chunk-MGVV6YC4.js} +1 -1
  20. package/dist/{chunk-C7SV7UP5.js → chunk-MWRYQLEG.js} +3 -3
  21. package/dist/{chunk-WKFE3RUC.js → chunk-NHJ4IAVN.js} +5 -3
  22. package/dist/{chunk-HSIHZWFF.js → chunk-NW5SWKJV.js} +7 -7
  23. package/dist/{chunk-C4Q77GGJ.js → chunk-O7VMHCNN.js} +6 -0
  24. package/dist/{chunk-CIV42JGT.js → chunk-PCIYXGB3.js} +2 -2
  25. package/dist/{chunk-7Y74KO7U.js → chunk-PLLXFSN2.js} +12 -12
  26. package/dist/{chunk-XGZOU4DS.js → chunk-QMCBXCP5.js} +4 -4
  27. package/dist/{chunk-QX55T4UX.js → chunk-RJP47EGS.js} +6 -1
  28. package/dist/{chunk-KWYF7QNH.js → chunk-RLVY6YD3.js} +17 -2
  29. package/dist/{chunk-JGG574RK.js → chunk-RRJVC35Y.js} +3 -3
  30. package/dist/{chunk-PIMGV3E5.js → chunk-SWJJW624.js} +1 -1
  31. package/dist/{chunk-G5MQRP6M.js → chunk-SYRJ5TTK.js} +13 -9
  32. package/dist/{chunk-L5V3W3DY.js → chunk-TTUFIE26.js} +60 -14
  33. package/dist/chunk-WOXTL43E.js +248 -0
  34. package/dist/{chunk-JFS4GKP7.js → chunk-XXPI4H4D.js} +2 -2
  35. package/dist/{chunk-M4UL422I.js → chunk-Y5526WCN.js} +6 -6
  36. package/dist/{chunk-CXE6ASSX.js → chunk-Y575INEC.js} +1 -1
  37. package/dist/{chunk-H7RAFRRZ.js → chunk-YFRG3CMS.js} +68 -34
  38. package/dist/{chunk-JG3CNGQM.js → chunk-ZNZHDPS3.js} +6 -4
  39. package/dist/{commands-UW2C2ZN4.js → commands-SCFSX4U4.js} +8 -6
  40. package/dist/{conflicts-RING6AHV.js → conflicts-4GLQOMJF.js} +9 -10
  41. package/dist/{contribute-LSY75JZH.js → contribute-HE4WCBRY.js} +7 -6
  42. package/dist/{countdown-SZ2P4XHB.js → countdown-VXOFV23S.js} +104 -57
  43. package/dist/{dashboard-P65XHYCU.js → dashboard-6V6PCNYF.js} +1 -1
  44. package/dist/{dashboard-broadcast-GYK34QYL.js → dashboard-broadcast-PMVQ7PXU.js} +1 -1
  45. package/dist/{diff-NZVBVQSK.js → diff-3XUZM7ZT.js} +8 -7
  46. package/dist/{doctor-TJSXBVGV.js → doctor-KGUWU5SN.js} +16 -15
  47. package/dist/{engine-info-BBI5QO5Y.js → engine-info-VM4VPGQM.js} +2 -2
  48. package/dist/{ground-control-ZJXPUIQN.js → ground-control-J4AMA4S4.js} +7 -4
  49. package/dist/{handoff-2OZSWGTE.js → handoff-LLT4CI6H.js} +2 -3
  50. package/dist/{hook-3VPKNSOO.js → hook-UPZ3CPYS.js} +22 -22
  51. package/dist/index.js +52 -32
  52. package/dist/{init-UW2BJBO2.js → init-ZHLVXEVT.js} +19 -18
  53. package/dist/{install-RQSI4CHG.js → install-XWOG64W3.js} +19 -18
  54. package/dist/{installs-7TR4H4QH.js → installs-2ROXPO6M.js} +5 -4
  55. package/dist/{mission-control-VSU6NT43.js → mission-control-IGOI3WHS.js} +2 -2
  56. package/dist/models-SNB5Q3YU.js +45 -0
  57. package/dist/paths-JTPV6SXH.js +107 -0
  58. package/dist/pi-DCMDOY65.js +248 -0
  59. package/dist/{plan-index-BNLUU6T5.js → plan-index-5QZJK4AG.js} +2 -3
  60. package/dist/{queue-JHYILLMX.js → queue-HDR5ER25.js} +11 -13
  61. package/dist/{run-CQF5RM5X.js → run-RGIY5JTX.js} +24 -30
  62. package/dist/{run-plan-BEOCOJCF.js → run-plan-DHB3ZXJS.js} +35 -23
  63. package/dist/{session-start-QV7CEFRX.js → session-start-NC2HE5X5.js} +16 -16
  64. package/dist/{sessions-AWAAO3DU.js → sessions-WWWLYPW6.js} +4 -4
  65. package/dist/{setup-global-ST4TT427.js → setup-global-WDMARD4Z.js} +11 -10
  66. package/dist/{status-HUBPBGUU.js → status-2WNJL7PP.js} +12 -11
  67. package/dist/update-OXCWYN3Y.js +32 -0
  68. package/dist/{update-all-YYUTXHGR.js → update-all-E2MV6KME.js} +20 -18
  69. package/package.json +14 -4
  70. package/pi/agent-kit.ts +224 -0
  71. package/dist/chunk-7ABY6DYH.js +0 -89
  72. package/dist/chunk-AQLBEEPD.js +0 -625
  73. package/dist/chunk-MUTTNRX4.js +0 -53
  74. package/dist/chunk-TOSAAQ5A.js +0 -71
  75. package/dist/update-DD5UZPGG.js +0 -31
@@ -1,29 +1,24 @@
1
1
  import {
2
- CLAUDE_SUBAGENT_MODEL_ENV,
2
+ NO_PROGRESS_REASON,
3
3
  armExternalPlanReview,
4
- describeIdenticalReviewModel,
5
- describeResolvedRoles,
6
- describeSameFamilyReviewModel,
7
4
  formatAgentStopLine,
5
+ formatNoProgressLine,
8
6
  formatSentinelLine,
9
7
  isPlanExhaustedReason,
10
- readPlanRoleOverrides,
11
- resolveSubworkerModel,
12
8
  resolveTickResultStatus,
13
9
  resolveTickSentinel,
14
- reviewModelRelation,
15
10
  shouldArmExternalPlanReview
16
- } from "./chunk-AQLBEEPD.js";
11
+ } from "./chunk-WOXTL43E.js";
17
12
  import {
18
13
  REVIEW_BACKENDS,
19
14
  runReviewJob
20
- } from "./chunk-HSIHZWFF.js";
15
+ } from "./chunk-NW5SWKJV.js";
21
16
  import {
22
17
  InputLine,
23
18
  ScrollRegion,
24
19
  renderMcLive,
25
20
  runMcTuiLoop
26
- } from "./chunk-CXE6ASSX.js";
21
+ } from "./chunk-Y575INEC.js";
27
22
  import {
28
23
  DRIVER_PROTOCOL_VERSION,
29
24
  DriverAgentSink,
@@ -32,25 +27,11 @@ import {
32
27
  createDriverEmitter,
33
28
  driverReplies,
34
29
  driverStop
35
- } from "./chunk-6WUKLS4D.js";
36
- import {
37
- countPendingTodos,
38
- findActivePlanFile,
39
- readPlan,
40
- readRunQueueState,
41
- resolveActivePlanFromHandoff,
42
- resolveActivePlanPath
43
- } from "./chunk-7ABY6DYH.js";
44
- import {
45
- detectAgentBackend
46
- } from "./chunk-TOSAAQ5A.js";
30
+ } from "./chunk-BIFTTL2O.js";
47
31
  import {
48
32
  classifyGateExit,
49
33
  landGateExit
50
- } from "./chunk-XGZOU4DS.js";
51
- import {
52
- parsePlanFrontmatter
53
- } from "./chunk-L5V3W3DY.js";
34
+ } from "./chunk-QMCBXCP5.js";
54
35
  import {
55
36
  QUEUE_LEASE_INTERRUPT_WAIT_MS,
56
37
  QUEUE_LEASE_SESSION_ENV,
@@ -59,17 +40,35 @@ import {
59
40
  gateCheckIn,
60
41
  holdQueueStatus,
61
42
  procStart
62
- } from "./chunk-MFKHIWEL.js";
43
+ } from "./chunk-FOVHFMSH.js";
63
44
  import {
45
+ CLAUDE_SUBAGENT_MODEL_ENV,
46
+ INSTALL_HINTS,
47
+ countPendingTodos,
48
+ describeIdenticalReviewModel,
49
+ describeResolvedRoles,
50
+ describeSameFamilyReviewModel,
51
+ detectAgentBackend,
52
+ findActivePlanFile,
64
53
  parseStreamLine,
65
- renderStreamEvent
66
- } from "./chunk-IFBIO7VT.js";
54
+ readPlan,
55
+ readPlanRoleOverrides,
56
+ readRunQueueState,
57
+ renderStreamEvent,
58
+ resolveActivePlanFromHandoff,
59
+ resolveActivePlanPath,
60
+ resolveSubworkerModel,
61
+ reviewModelRelation
62
+ } from "./chunk-3KFLQE6Y.js";
67
63
  import {
68
64
  LineSplitter,
69
65
  formatHitlSummary,
70
66
  operatorQuitStop,
71
67
  sumUsage
72
68
  } from "./chunk-P7732A25.js";
69
+ import {
70
+ parsePlanFrontmatter
71
+ } from "./chunk-TTUFIE26.js";
73
72
  import {
74
73
  TtySpinner,
75
74
  shouldUseVisualMotion,
@@ -84,7 +83,7 @@ import {
84
83
  STATE_ROOT_ENV,
85
84
  ensureLoopLogsDir,
86
85
  runnerStatePaths
87
- } from "./chunk-C4Q77GGJ.js";
86
+ } from "./chunk-O7VMHCNN.js";
88
87
  import {
89
88
  fileExists,
90
89
  readJson
@@ -469,6 +468,7 @@ async function withLiveTui(opts, run) {
469
468
  }
470
469
 
471
470
  // src/plan-loop/run-loop.ts
471
+ import { createHash } from "crypto";
472
472
  import { readFile as readFile2, rm, unlink } from "fs/promises";
473
473
  import path3 from "path";
474
474
 
@@ -694,6 +694,13 @@ function stamp() {
694
694
  function sleep(ms) {
695
695
  return new Promise((r) => setTimeout(r, ms));
696
696
  }
697
+ async function contentHash(file) {
698
+ try {
699
+ return createHash("sha256").update(await readFile2(file)).digest("hex");
700
+ } catch {
701
+ return "absent";
702
+ }
703
+ }
697
704
  async function runPlanLoop(opts) {
698
705
  const statePaths = runnerStatePaths(opts.root);
699
706
  const stopFile = statePaths.stopFile;
@@ -776,6 +783,8 @@ async function runPlanLoop(opts) {
776
783
  return finishRun(1, "no active plan", null);
777
784
  }
778
785
  const pending = async () => countPendingTodos(await readPlan(planPath));
786
+ const handoffPath = path3.join(opts.root, HANDOFF_REL);
787
+ const fingerprint = async () => `${await contentHash(planPath)}:${await contentHash(handoffPath)}`;
779
788
  landPlan = path3.basename(planPath);
780
789
  if (statePaths.invalid !== void 0) {
781
790
  say(
@@ -869,8 +878,9 @@ async function runPlanLoop(opts) {
869
878
  }
870
879
  const binary = await opts.backend.resolve();
871
880
  if (!binary) {
872
- say(`${opts.backend.id} not found on PATH`, "error");
873
- return finishRun(1, `${opts.backend.id} not found on PATH`, pendingAtStart);
881
+ const missing = opts.backend.id === "local" ? `local backend: pi not found on PATH. ${INSTALL_HINTS.local}` : `${opts.backend.id} not found on PATH`;
882
+ say(missing, "error");
883
+ return finishRun(1, missing, pendingAtStart);
874
884
  }
875
885
  const writer = acquirePlanWriterLease(opts.root, "agent-kit run-plan", {
876
886
  ...opts.lease,
@@ -927,6 +937,12 @@ async function runPlanLoop(opts) {
927
937
  rolesWarned.add(line);
928
938
  say(`roles: ${line}`, "warn");
929
939
  };
940
+ if (tickBackend === "local" && (!reviewer.backend || reviewer.backend === "auto")) {
941
+ warnOnce(
942
+ "post-tick review skipped: the tick ran on the local backend and roles.reviewer.backend is not set (set it to claude or cursor-agent to review local ticks on that engine)"
943
+ );
944
+ return proceed;
945
+ }
930
946
  const relation = reviewModelRelation(tickModel, reviewer.model);
931
947
  if (relation === "identical") {
932
948
  warnOnce(
@@ -1014,6 +1030,7 @@ async function runPlanLoop(opts) {
1014
1030
  endReason = "plan exhausted";
1015
1031
  break;
1016
1032
  }
1033
+ const beforeFingerprint = await fingerprint();
1017
1034
  const logPath = path3.join(logDir, `tick-${stamp()}.log`);
1018
1035
  landLogPath = logPath;
1019
1036
  landBackend = backend.id;
@@ -1105,7 +1122,16 @@ async function runPlanLoop(opts) {
1105
1122
  onSpawn: (info) => {
1106
1123
  lease?.setAgent(info.pid);
1107
1124
  tickAgent = info.pid === void 0 ? null : { pid: info.pid, start: procStart(info.pid) };
1108
- }
1125
+ },
1126
+ onProgress: (p) => emit({
1127
+ type: "model_loading",
1128
+ tick,
1129
+ backend: backend.id,
1130
+ model: p.model,
1131
+ phase: p.phase,
1132
+ elapsedMs: p.elapsedMs,
1133
+ ...p.detail ? { detail: p.detail } : {}
1134
+ })
1109
1135
  }) : await runTickWithSpinner(`tick ${tick}`, backend, runOpts, opts.plain === true);
1110
1136
  tickAgent = null;
1111
1137
  agentExit = result.exitCode;
@@ -1146,7 +1172,7 @@ async function runPlanLoop(opts) {
1146
1172
  logText = await readFile2(logPath, "utf8");
1147
1173
  } catch {
1148
1174
  }
1149
- limit = detectUsageLimit(logText);
1175
+ limit = backend.id === "local" ? null : detectUsageLimit(logText);
1150
1176
  if (limit) {
1151
1177
  const hit = limit;
1152
1178
  const fallback = opts.onLimit && !limitSwitched && opts.onLimit.id !== backend.id ? opts.onLimit : null;
@@ -1214,6 +1240,14 @@ async function runPlanLoop(opts) {
1214
1240
  banners.tickEnd(`pending: ${after}`);
1215
1241
  }
1216
1242
  endTick(after, sentinel);
1243
+ if (sentinel.kind === "continue" && after >= before && await fingerprint() === beforeFingerprint) {
1244
+ if (banners) banners.stop(NO_PROGRESS_REASON);
1245
+ say(formatNoProgressLine({ before, after, log: relLog }));
1246
+ exitCode = 1;
1247
+ endReason = NO_PROGRESS_REASON;
1248
+ landFailed = true;
1249
+ break;
1250
+ }
1217
1251
  const review = await reviewAfterTick(backend.id, implementerModel);
1218
1252
  if (review.stop) {
1219
1253
  const msg = `Post-tick review landed a gate exit after tick ${tick} - stopping. Read the ticket before the next tick.`;
@@ -8,14 +8,16 @@ import {
8
8
  saveManagedHashLedger,
9
9
  shouldPreserveCustomizedOverlay,
10
10
  toPosixRel
11
- } from "./chunk-QX55T4UX.js";
11
+ } from "./chunk-RJP47EGS.js";
12
+ import {
13
+ acquireDirLock
14
+ } from "./chunk-IHVJTGYR.js";
12
15
  import {
13
16
  DEFAULT_PROTECTED_PATHS,
14
17
  LEGACY_CONTEXT_PROTECTED_GLOB,
15
18
  MANIFEST_RELATIVE_PATH,
16
- MANIFEST_SCHEMA_VERSION,
17
- acquireDirLock
18
- } from "./chunk-6M6UKECW.js";
19
+ MANIFEST_SCHEMA_VERSION
20
+ } from "./chunk-KMK4T4ZM.js";
19
21
  import {
20
22
  fileExists,
21
23
  readJson,
@@ -1,24 +1,26 @@
1
1
  import {
2
2
  RUN_CATALOG,
3
3
  RUN_PROMOTE_BLOCKED
4
- } from "./chunk-KWYF7QNH.js";
5
- import "./chunk-IFBIO7VT.js";
4
+ } from "./chunk-RLVY6YD3.js";
5
+ import "./chunk-3KFLQE6Y.js";
6
6
  import "./chunk-P7732A25.js";
7
+ import "./chunk-TTUFIE26.js";
7
8
  import {
8
9
  CURSOR_COMMANDS_DIR_REL,
9
10
  discoverInstalledCommands
10
- } from "./chunk-EO5NGAYV.js";
11
+ } from "./chunk-FUSNEYGU.js";
11
12
  import "./chunk-WGLPZXNU.js";
12
13
  import "./chunk-Q35TWISF.js";
13
14
  import "./chunk-QTON2GQX.js";
14
15
  import {
15
16
  L0_ARTIFACTS
16
17
  } from "./chunk-CGXLR77R.js";
17
- import "./chunk-QX55T4UX.js";
18
+ import "./chunk-PFEUZXVT.js";
19
+ import "./chunk-RJP47EGS.js";
18
20
  import {
19
21
  KIT_VERSION
20
- } from "./chunk-7HDQEK6T.js";
21
- import "./chunk-C4Q77GGJ.js";
22
+ } from "./chunk-2G4K4ZI5.js";
23
+ import "./chunk-O7VMHCNN.js";
22
24
  import "./chunk-5B4DVO6C.js";
23
25
 
24
26
  // src/commands/commands.ts
@@ -1,33 +1,32 @@
1
1
  import {
2
2
  REVIEW_PACK_DEFAULT_MAX_BYTES
3
- } from "./chunk-HSIHZWFF.js";
4
- import "./chunk-GQSSXDDK.js";
5
- import {
6
- detectAgentBackend
7
- } from "./chunk-TOSAAQ5A.js";
3
+ } from "./chunk-NW5SWKJV.js";
4
+ import "./chunk-ARJRICI2.js";
8
5
  import {
9
6
  defaultExec,
10
7
  gateExitRedactions,
11
8
  isOutside
12
- } from "./chunk-XGZOU4DS.js";
13
- import "./chunk-MUTTNRX4.js";
9
+ } from "./chunk-QMCBXCP5.js";
14
10
  import {
15
11
  ensureDispatchLogPath,
16
12
  readCommandFile,
17
13
  runHeadlessDispatch
18
- } from "./chunk-KWYF7QNH.js";
14
+ } from "./chunk-RLVY6YD3.js";
19
15
  import {
20
16
  createStreamRenderer,
17
+ detectAgentBackend,
21
18
  redactSecrets
22
- } from "./chunk-IFBIO7VT.js";
19
+ } from "./chunk-3KFLQE6Y.js";
23
20
  import "./chunk-P7732A25.js";
21
+ import "./chunk-TTUFIE26.js";
24
22
  import "./chunk-WGLPZXNU.js";
25
23
  import "./chunk-Q35TWISF.js";
26
24
  import "./chunk-QTON2GQX.js";
27
25
  import {
28
26
  logger
29
27
  } from "./chunk-ZB43YMHW.js";
30
- import "./chunk-C4Q77GGJ.js";
28
+ import "./chunk-PFEUZXVT.js";
29
+ import "./chunk-O7VMHCNN.js";
31
30
  import "./chunk-5B4DVO6C.js";
32
31
 
33
32
  // src/commands/conflicts.ts
@@ -1,23 +1,24 @@
1
1
  import {
2
2
  REGISTRY_CLI_ARGS,
3
3
  resolveRegistryFromCli
4
- } from "./chunk-PIMGV3E5.js";
4
+ } from "./chunk-SWJJW624.js";
5
5
  import {
6
6
  logger
7
7
  } from "./chunk-ZB43YMHW.js";
8
8
  import {
9
9
  managedPairs
10
- } from "./chunk-SAQ3EE5R.js";
10
+ } from "./chunk-HGB4DHXV.js";
11
11
  import "./chunk-CGXLR77R.js";
12
12
  import {
13
13
  loadAgentKitManifest,
14
14
  normalizeRelPath
15
- } from "./chunk-JG3CNGQM.js";
15
+ } from "./chunk-ZNZHDPS3.js";
16
16
  import {
17
17
  resolveContained
18
- } from "./chunk-QX55T4UX.js";
19
- import "./chunk-6M6UKECW.js";
20
- import "./chunk-C4Q77GGJ.js";
18
+ } from "./chunk-RJP47EGS.js";
19
+ import "./chunk-IHVJTGYR.js";
20
+ import "./chunk-KMK4T4ZM.js";
21
+ import "./chunk-O7VMHCNN.js";
21
22
  import "./chunk-5B4DVO6C.js";
22
23
 
23
24
  // src/commands/contribute.ts
@@ -1,27 +1,17 @@
1
1
  import {
2
+ NO_PROGRESS_REASON,
3
+ isNoProgressLine,
2
4
  isPlanExhaustedReason,
3
- loadRolesContext,
4
- parseAgentStopLine,
5
- resolveReviewJobRole,
6
- resolveWorkerRole
7
- } from "./chunk-AQLBEEPD.js";
5
+ parseAgentStopLine
6
+ } from "./chunk-WOXTL43E.js";
8
7
  import {
9
8
  REVIEW_BACKENDS,
10
9
  REVIEW_PACK_DEFAULT_MAX_BYTES,
11
10
  REVIEW_PACK_SLASH,
12
11
  parseReviewPackMaxBytes,
13
12
  reviewBackendMessage
14
- } from "./chunk-HSIHZWFF.js";
15
- import "./chunk-GQSSXDDK.js";
16
- import {
17
- countPendingTodos,
18
- readPlan,
19
- resolveActivePlanPath
20
- } from "./chunk-7ABY6DYH.js";
21
- import {
22
- detectAgentBackend,
23
- listDetectBackendIds
24
- } from "./chunk-TOSAAQ5A.js";
13
+ } from "./chunk-NW5SWKJV.js";
14
+ import "./chunk-ARJRICI2.js";
25
15
  import {
26
16
  GATE_EXIT_MARKER_RELPATH,
27
17
  defaultExec,
@@ -32,30 +22,38 @@ import {
32
22
  readGateExitMarker,
33
23
  resolveGateExitRefs,
34
24
  writeGateExitMarker
35
- } from "./chunk-XGZOU4DS.js";
36
- import {
37
- parsePlanFrontmatter
38
- } from "./chunk-L5V3W3DY.js";
39
- import {
40
- ensurePathIgnored
41
- } from "./chunk-MUTTNRX4.js";
25
+ } from "./chunk-QMCBXCP5.js";
42
26
  import {
43
27
  classifySlash,
44
28
  normalizeSlashName,
45
29
  promoteBlockedMessage,
46
30
  unknownSlashMessage
47
- } from "./chunk-KWYF7QNH.js";
31
+ } from "./chunk-RLVY6YD3.js";
48
32
  import {
49
33
  CLAUDE_MAX_BUDGET_USD_ENV,
50
34
  CLAUDE_MAX_TURNS_ENV,
35
+ RESULT_NONCE_STDIN_ENV,
51
36
  RedactingStreamBuffer,
52
37
  claudeRunCaps,
38
+ countPendingTodos,
39
+ createNonceStripper,
40
+ detectAgentBackend,
41
+ listDetectBackendIds,
42
+ loadRolesContext,
53
43
  parseResultLine,
54
- redactSecrets
55
- } from "./chunk-IFBIO7VT.js";
44
+ readPlan,
45
+ redactSecrets,
46
+ resolveActivePlanPath,
47
+ resolveReviewJobRole,
48
+ resolveWorkerRole
49
+ } from "./chunk-3KFLQE6Y.js";
56
50
  import {
57
51
  HITL_UNANSWERED_EXIT_CODE
58
52
  } from "./chunk-P7732A25.js";
53
+ import {
54
+ ensurePathIgnored,
55
+ parsePlanFrontmatter
56
+ } from "./chunk-TTUFIE26.js";
59
57
  import "./chunk-WGLPZXNU.js";
60
58
  import "./chunk-Q35TWISF.js";
61
59
  import "./chunk-QTON2GQX.js";
@@ -66,11 +64,12 @@ import "./chunk-PFEUZXVT.js";
66
64
  import {
67
65
  ensureLoopLogsDir,
68
66
  runnerStatePaths
69
- } from "./chunk-C4Q77GGJ.js";
67
+ } from "./chunk-O7VMHCNN.js";
70
68
  import "./chunk-5B4DVO6C.js";
71
69
 
72
70
  // src/commands/countdown.ts
73
71
  import { spawn } from "child_process";
72
+ import { randomBytes } from "crypto";
74
73
  import { appendFile, mkdir } from "fs/promises";
75
74
  import path from "path";
76
75
  import { defineCommand } from "citty";
@@ -82,7 +81,10 @@ var COUNTDOWN_EXIT = {
82
81
  * does not cover the job: waits for the operator.
83
82
  */
84
83
  pending: 2,
85
- /** Circuit's Dead: failed, stalled, over the window, dirty tree, fetch failed. */
84
+ /**
85
+ * Circuit's Dead: failed, stalled, over the window, dirty tree, fetch
86
+ * failed, or a tick that reported `continue` without progress.
87
+ */
86
88
  circuitsDead: 3,
87
89
  /**
88
90
  * Needs operator: the tick ended because the agent requested a stop (a
@@ -120,32 +122,57 @@ function createAgentStopWatcher() {
120
122
  }
121
123
  };
122
124
  }
123
- function createCostWatcher() {
125
+ function createCostWatcher(nonce) {
124
126
  let total = 0;
125
127
  let seen = false;
128
+ let unpriced = false;
126
129
  let last = null;
127
130
  let partial = "";
128
131
  const take = (line) => {
129
- const hit = parseResultLine(line);
130
- if (hit === null || hit.costUsd === null) return;
131
- const replaces = hit.sessionTotal && last !== null && hit.costUsd >= last;
132
- total += replaces && last !== null ? hit.costUsd - last : hit.costUsd;
133
- last = hit.costUsd;
132
+ const at = nonce ? line.indexOf(nonce) : -1;
133
+ if (at === -1) return;
134
+ const hit = parseResultLine(line.slice(at + nonce.length));
135
+ if (hit === null) return;
136
+ if (hit.costBasis === "unknown") unpriced = true;
137
+ const figure = hit.reportedUsd;
138
+ if (figure === null) return;
139
+ const replaces = hit.sessionTotal && last !== null && figure >= last;
140
+ total += replaces && last !== null ? figure - last : figure;
141
+ last = figure;
134
142
  seen = true;
135
143
  };
144
+ const cost = () => {
145
+ if (partial) {
146
+ take(partial);
147
+ partial = "";
148
+ }
149
+ const reportedUsd = seen ? Math.round(total * 1e6) / 1e6 : null;
150
+ return {
151
+ costUsd: unpriced ? null : reportedUsd,
152
+ reportedUsd,
153
+ costBasis: unpriced ? "unknown" : null
154
+ };
155
+ };
136
156
  return {
137
157
  push(text) {
138
158
  const lines = (partial + text).split("\n");
139
159
  partial = lines.pop() ?? "";
140
160
  for (const line of lines) take(line);
141
161
  },
142
- costUsd() {
143
- if (partial) {
144
- take(partial);
145
- partial = "";
146
- }
147
- return seen ? Math.round(total * 1e6) / 1e6 : null;
148
- }
162
+ costUsd: () => cost().costUsd,
163
+ cost
164
+ };
165
+ }
166
+ function createNoProgressWatcher() {
167
+ let hit = false;
168
+ let partial = "";
169
+ return {
170
+ push(text) {
171
+ const lines = (partial + text).split("\n");
172
+ partial = lines.pop() ?? "";
173
+ if (lines.some(isNoProgressLine)) hit = true;
174
+ },
175
+ seen: () => hit || partial !== "" && isNoProgressLine(partial)
149
176
  };
150
177
  }
151
178
  var COST_LEDGER_RELPATH = ".cursor/context/cost-ledger.ndjson";
@@ -197,8 +224,12 @@ var defaultSpawnJob = (args, opts) => {
197
224
  cwd: opts.cwd,
198
225
  env: opts.env,
199
226
  detached: group,
200
- stdio: ["ignore", "pipe", "pipe"]
227
+ stdio: ["pipe", "pipe", "pipe"]
201
228
  });
229
+ child.stdin?.on("error", () => {
230
+ });
231
+ child.stdin?.end(`${opts.resultNonce}
232
+ `);
202
233
  const listeners = [];
203
234
  const emit = (text) => {
204
235
  for (const l of listeners) l(text);
@@ -371,7 +402,9 @@ async function executeCountdown(input) {
371
402
  plan: end.plan ?? null,
372
403
  todo: end.todo ?? null,
373
404
  exit: end.exitCode,
374
- cost_usd: end.costUsd ?? null
405
+ cost_usd: end.cost?.costUsd ?? null,
406
+ cost_usd_reported: end.cost?.reportedUsd ?? null,
407
+ cost_basis: end.cost?.costBasis ?? null
375
408
  };
376
409
  if (end.exitCode !== COUNTDOWN_EXIT.usage && end.job) {
377
410
  const failed = await appendCostLedger({
@@ -390,7 +423,9 @@ async function executeCountdown(input) {
390
423
  input_tokens: null,
391
424
  output_tokens: null,
392
425
  exit: result.exit,
393
- outcome: result.outcome
426
+ outcome: result.outcome,
427
+ cost_usd_reported: result.cost_usd_reported,
428
+ cost_basis: result.cost_basis
394
429
  }
395
430
  });
396
431
  if (failed !== null) {
@@ -549,7 +584,6 @@ async function runCountdown(input) {
549
584
  reason: refusal,
550
585
  plan,
551
586
  ...ledger,
552
- costUsd: null,
553
587
  ...logPath ? { logPath } : {}
554
588
  };
555
589
  }
@@ -583,7 +617,12 @@ async function runCountdown(input) {
583
617
  ...job === "review" && input.includeReviewed ? { includeReviewed: true } : {}
584
618
  });
585
619
  say(`starting: agent-kit ${args.join(" ")}`);
586
- const handle = (input.spawnJob ?? defaultSpawnJob)(args, { cwd: root, env });
620
+ const nonce = randomBytes(16).toString("hex");
621
+ const handle = (input.spawnJob ?? defaultSpawnJob)(args, {
622
+ cwd: root,
623
+ env: { ...env, [RESULT_NONCE_STDIN_ENV]: "1" },
624
+ resultNonce: nonce
625
+ });
587
626
  const forward = (signal) => handle.kill(signal);
588
627
  const onSigint = () => forward("SIGINT");
589
628
  const onSigterm = () => forward("SIGTERM");
@@ -593,13 +632,19 @@ async function runCountdown(input) {
593
632
  }
594
633
  const jobOut = new RedactingStreamBuffer(redactions);
595
634
  const stopWatch = runsTick ? createAgentStopWatcher() : null;
596
- const costWatch = createCostWatcher();
597
- const emitJob = (out) => {
598
- if (!out) return;
599
- stopWatch?.push(out);
600
- costWatch.push(out);
601
- write(out);
602
- toLog(out);
635
+ const noProgressWatch = runsTick ? createNoProgressWatcher() : null;
636
+ const costWatch = createCostWatcher(nonce);
637
+ const hideNonce = createNonceStripper(nonce);
638
+ const emitJob = (out, last = false) => {
639
+ if (out) {
640
+ stopWatch?.push(out);
641
+ noProgressWatch?.push(out);
642
+ costWatch.push(out);
643
+ }
644
+ const shown = hideNonce.push(out) + (last ? hideNonce.flush() : "");
645
+ if (!shown) return;
646
+ write(shown);
647
+ toLog(shown);
603
648
  };
604
649
  let end;
605
650
  try {
@@ -617,7 +662,7 @@ async function runCountdown(input) {
617
662
  process.off("SIGINT", onSigint);
618
663
  process.off("SIGTERM", onSigterm);
619
664
  }
620
- emitJob(jobOut.flush());
665
+ emitJob(jobOut.flush(), true);
621
666
  }
622
667
  const after = await readGateExitMarker(root);
623
668
  const pendingAfter = after.kind === "ok" ? after.marker.pending.length : preflight.pendingBefore;
@@ -633,7 +678,8 @@ async function runCountdown(input) {
633
678
  pendingGrew,
634
679
  needsOperator: stopReason !== null && !planExhausted
635
680
  });
636
- const deadReason = end.circuitsDead ? `Circuit's Dead: ${end.circuitsDead === "window" ? `window of ${windowMin} min exceeded` : `no stream event for ${stallMin} min`}` : `Circuit's Dead: job exited with ${end.code === null ? `signal ${end.signal ?? "unknown"}` : `code ${end.code}`}`;
681
+ const noProgress = end.code === 1 && noProgressWatch?.seen() === true;
682
+ const deadReason = end.circuitsDead ? `Circuit's Dead: ${end.circuitsDead === "window" ? `window of ${windowMin} min exceeded` : `no stream event for ${stallMin} min`}` : noProgress ? `Circuit's Dead: ${NO_PROGRESS_REASON} (job exited with code 1)` : `Circuit's Dead: job exited with ${end.code === null ? `signal ${end.signal ?? "unknown"}` : `code ${end.code}`}`;
637
683
  if (exitCode === COUNTDOWN_EXIT.circuitsDead && !pendingGrew) {
638
684
  const reason2 = deadReason;
639
685
  const outcome = {
@@ -660,14 +706,14 @@ async function runCountdown(input) {
660
706
  plan,
661
707
  todo,
662
708
  ...ledger,
663
- costUsd: costWatch.costUsd(),
709
+ cost: costWatch.cost(),
664
710
  ...logPath ? { logPath } : {}
665
711
  };
666
712
  }
667
713
  var countdownCommand = defineCommand({
668
714
  meta: {
669
715
  name: "countdown",
670
- description: "Countdown: one-shot launcher for a cron/systemd timer. Runs one headless job (tick, dispatch or review) with --no-hitl --land-on-gate; refused while a gate exit is pending or when --budget-remaining does not cover it. Exit 0 done, 2 gate, findings or budget pending, 3 Circuit's Dead, 5 the agent requested a stop (needs operator). Each fire appends one line to .cursor/context/cost-ledger.ndjson; the last stdout line is AGENT_KIT_RESULT {json}. Never git-prod."
716
+ description: "Countdown: one-shot launcher for a cron/systemd timer. Runs one headless job (tick, dispatch or review) with --no-hitl --land-on-gate; refused while a gate exit is pending or when --budget-remaining does not cover it. Exit 0 done, 2 gate, findings or budget pending, 3 Circuit's Dead (failed, stalled, or a tick that reported continue without progress), 5 the agent requested a stop (needs operator). Each fire appends one line to .cursor/context/cost-ledger.ndjson (cost_usd null when the model could not be priced; cost_usd_reported keeps the reported figure); the last stdout line is AGENT_KIT_RESULT {json}. Never git-prod."
671
717
  },
672
718
  args: {
673
719
  cwd: {
@@ -762,6 +808,7 @@ export {
762
808
  countdownPreflight,
763
809
  createAgentStopWatcher,
764
810
  createCostWatcher,
811
+ createNoProgressWatcher,
765
812
  defaultSpawnJob,
766
813
  executeCountdown,
767
814
  formatCostLedgerLine,
@@ -7,7 +7,7 @@ import {
7
7
  findDashboardStart,
8
8
  readPreferredBrowserFromWorkspace,
9
9
  resolveDashboardSnapshotRoot
10
- } from "./chunk-ZMYV6PRE.js";
10
+ } from "./chunk-LEVNLHH3.js";
11
11
  import "./chunk-ZB43YMHW.js";
12
12
  export {
13
13
  applyDashboardOpenEnv,
@@ -5,7 +5,7 @@ import {
5
5
  findDashboardStart,
6
6
  negatedFlag,
7
7
  resolveDashboardSnapshotRoot
8
- } from "./chunk-ZMYV6PRE.js";
8
+ } from "./chunk-LEVNLHH3.js";
9
9
  import {
10
10
  logger
11
11
  } from "./chunk-ZB43YMHW.js";