@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
@@ -2,14 +2,10 @@ import {
2
2
  collectLiveRoster,
3
3
  formatRosterLease,
4
4
  formatRosterRow
5
- } from "./chunk-JFS4GKP7.js";
5
+ } from "./chunk-XXPI4H4D.js";
6
6
  import {
7
7
  validateHandoffText
8
8
  } from "./chunk-2YU2H7I6.js";
9
- import {
10
- formatPlanIndexSection,
11
- writePlanIndex
12
- } from "./chunk-L5V3W3DY.js";
13
9
  import {
14
10
  CHANGELOG_FETCH_TIMEOUT_MS,
15
11
  resolveInventoryRoot,
@@ -19,23 +15,27 @@ import {
19
15
  shouldEmitPublicInboundNudge,
20
16
  stampPublicInboundCheck
21
17
  } from "./chunk-4CRBUEJ6.js";
18
+ import {
19
+ formatPlanIndexSection,
20
+ writePlanIndex
21
+ } from "./chunk-TTUFIE26.js";
22
22
  import {
23
23
  READINESS_SNAPSHOT_RELATIVE_PATH,
24
24
  UPDATE_NOTICE_SESSION_FETCH_TIMEOUT_MS,
25
25
  computeUpdateNotice
26
- } from "./chunk-2F6NMQOA.js";
26
+ } from "./chunk-FB6G6OD6.js";
27
27
  import {
28
28
  stampLastCheckedAt
29
- } from "./chunk-M4UL422I.js";
29
+ } from "./chunk-Y5526WCN.js";
30
30
  import {
31
31
  loadContextConfig
32
32
  } from "./chunk-PFEUZXVT.js";
33
33
  import {
34
34
  MANIFEST_RELATIVE_PATH
35
- } from "./chunk-6M6UKECW.js";
35
+ } from "./chunk-KMK4T4ZM.js";
36
36
  import {
37
37
  HANDOFF_REL
38
- } from "./chunk-C4Q77GGJ.js";
38
+ } from "./chunk-O7VMHCNN.js";
39
39
  import {
40
40
  fileExists
41
41
  } from "./chunk-5B4DVO6C.js";
@@ -302,6 +302,9 @@ var HARD_RULES = `# Agent Kit session hard rules (manual mode default)
302
302
  10. **Backlog CRUD never activates.** \`/backlog-add\` enqueues (Broad Intake + write Ask + plan file + HANDOFF Backlog) without park, activate, or Gate B. \`/backlog-edit\` / \`/backlog-delete\` / \`/backlog-cancel\` require Ask confirm before mutate; delete archives from Backlog, cancel is soft in place. No Field Report cards for routine backlog CRUD.
303
303
  11. **HANDOFF machine fields are bullet fields, not \`##\` headings.** Mission Control parses \`- **Plan:**\`, \`- **Backlog plans:**\`, \`- **Parked plans:**\`, \`- **Run queue:**\` (etc.). Canonical Plan: \`- **Plan:** \\\`name.plan.md\\\`\` or \`none\`. Nested backlog/parked rows: \`- \\\`other.plan.md\\\`\`. Never invent \`## Backlog plans\` / \`## Parked plans\` / \`## Run queue\` headings in place of those fields (Checklist / Current mission go empty or idle).
304
304
  12. **Plans inventory is index + HANDOFF.** \`/continue-plan\`, \`/run-plan-all\`, and Broad Intake read \`.cursor/context/plan-index.json\` and \`.cursor/HANDOFF.md\` only. Do not glob \`.cursor/plans/*.plan.md\`. Named single-file reads of a known basename remain OK. Delegation stays (ADR \`decisions/2026-07-26_command-orchestration-delegation-pattern.md\`).`;
305
+ var PI_HOST_HITL = `## Host: pi (HITL is the numbered list)
306
+
307
+ This session runs in pi, which has no structured question tool. Wherever these rules, a slash command, a skill, AGENTS.md or CLAUDE.md say to confirm or ask through Ask questions, an Ask or a question tool, use the numbered-list fallback instead: print one line \`HITL_GATE: <ask-id> | <label 1> | <label 2> | ...\` immediately followed by the same labels as one numbered list, one list per message, then WAIT for the operator's answer (ask-id and labels: \`.cursor/skills/core/hitl-gates/SKILL.md\`). Skip or cancel means stop. Never \`/git-prod\` without the operator's explicit yes.`;
305
308
  var DOGFOOD_INBOX_HINT = `## Dogfood inbox
306
309
 
307
310
  Unprocessed files are listed under \`dogfood/README.md\` (factory) or \`.cursor/dogfood/README.md\` (consumer). To file a new note, use \`/dogfood <topic> [summary]\`. Follow the ingest ritual (detect \u2192 analyze \u2192 memory WRITE \u2192 triage). Do not auto-start analysis unless the user asks.`;
@@ -962,6 +965,7 @@ async function buildSessionStartAdditionalContext(rootDir, _payload = {}, deps =
962
965
  const handoffFull = await readFull(handoffPath);
963
966
  const handoff = capHandoffExcerpt(handoffFull);
964
967
  const parts = [HARD_RULES];
968
+ if (deps.host === "pi") parts.push(PI_HOST_HITL);
965
969
  if (await l0Present(root)) {
966
970
  const readiness = await readinessSection(root);
967
971
  if (readiness) parts.push(readiness);
@@ -1,17 +1,62 @@
1
- import {
2
- ensurePathIgnored,
3
- gitAt
4
- } from "./chunk-MUTTNRX4.js";
5
1
  import {
6
2
  HANDOFF_REL
7
- } from "./chunk-C4Q77GGJ.js";
3
+ } from "./chunk-O7VMHCNN.js";
8
4
  import {
9
5
  ensureDir
10
6
  } from "./chunk-5B4DVO6C.js";
11
7
 
12
- // src/plan-index/plan-index.ts
13
- import { readFile, writeFile } from "fs/promises";
8
+ // src/utils/git-local-exclude.ts
9
+ import { execFile } from "child_process";
10
+ import { appendFile, mkdir, readFile } from "fs/promises";
14
11
  import path from "path";
12
+ function gitAt(cwd) {
13
+ return (args) => new Promise((resolve) => {
14
+ execFile(
15
+ "git",
16
+ [...args],
17
+ {
18
+ cwd,
19
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
20
+ encoding: "utf8",
21
+ timeout: 3e4
22
+ },
23
+ (err, stdout, stderr) => {
24
+ resolve({
25
+ code: err ? typeof err.code === "number" ? err.code : 1 : 0,
26
+ stdout: String(stdout ?? ""),
27
+ stderr: String(stderr ?? err?.message ?? "")
28
+ });
29
+ }
30
+ );
31
+ });
32
+ }
33
+ async function ensurePathIgnored(git, root, relPath) {
34
+ try {
35
+ const check = () => git(["check-ignore", "-q", "--", relPath]);
36
+ const first = await check();
37
+ if (first.code === 0) return true;
38
+ if (first.code !== 1) return false;
39
+ const prefix = await git(["rev-parse", "--show-prefix"]);
40
+ const where = await git(["rev-parse", "--git-path", "info/exclude"]);
41
+ if (prefix.code !== 0 || where.code !== 0 || !where.stdout.trim()) return false;
42
+ const line = `/${prefix.stdout.trim()}${relPath}`;
43
+ const exclude = path.resolve(root, where.stdout.trim());
44
+ const current = await readFile(exclude, "utf8").catch(() => "");
45
+ if (!current.split("\n").some((l) => l.trim() === line)) {
46
+ await mkdir(path.dirname(exclude), { recursive: true });
47
+ const sep = current && !current.endsWith("\n") ? "\n" : "";
48
+ await appendFile(exclude, `${sep}${line}
49
+ `, "utf8");
50
+ }
51
+ return (await check()).code === 0;
52
+ } catch {
53
+ return false;
54
+ }
55
+ }
56
+
57
+ // src/plan-index/plan-index.ts
58
+ import { readFile as readFile2, writeFile } from "fs/promises";
59
+ import path2 from "path";
15
60
  var PLAN_INDEX_REL = ".cursor/context/plan-index.json";
16
61
  var NONE = /^(none|n\/a|empty|nil)$/i;
17
62
  var OPEN_STATUSES = /* @__PURE__ */ new Set(["pending", "in_progress"]);
@@ -20,13 +65,13 @@ function defaultPlanIndexIo() {
20
65
  return {
21
66
  async readFile(absPath) {
22
67
  try {
23
- return await readFile(absPath, "utf8");
68
+ return await readFile2(absPath, "utf8");
24
69
  } catch {
25
70
  return null;
26
71
  }
27
72
  },
28
73
  async writeFile(absPath, body) {
29
- await ensureDir(path.dirname(absPath));
74
+ await ensureDir(path2.dirname(absPath));
30
75
  await writeFile(absPath, body, "utf8");
31
76
  },
32
77
  ensureIgnored(root, relPath) {
@@ -55,11 +100,11 @@ function collectNamedPlanBasenames(named) {
55
100
  return out;
56
101
  }
57
102
  function namedPlanCandidatePaths(root, basename) {
58
- const safe = path.basename(basename);
103
+ const safe = path2.basename(basename);
59
104
  if (!/^[A-Za-z0-9._-]+\.plan\.md$/i.test(safe)) return [];
60
105
  return [
61
- path.join(root, ".cursor", "plans", safe),
62
- path.join(root, ".cursor", "plans", "archive", safe)
106
+ path2.join(root, ".cursor", "plans", safe),
107
+ path2.join(root, ".cursor", "plans", "archive", safe)
63
108
  ];
64
109
  }
65
110
  function classifyPlanRole(file, named, openTodos) {
@@ -101,7 +146,7 @@ function parsePlanFrontmatter(raw) {
101
146
  return { name, todos };
102
147
  }
103
148
  async function buildPlanIndex(root, io = defaultPlanIndexIo(), now = () => /* @__PURE__ */ new Date()) {
104
- const handoffPath = path.join(root, HANDOFF_REL);
149
+ const handoffPath = path2.join(root, HANDOFF_REL);
105
150
  const handoffText = await io.readFile(handoffPath) ?? "";
106
151
  const named = extractHandoffNamedPlans(handoffText);
107
152
  const plans = [];
@@ -132,7 +177,7 @@ async function buildPlanIndex(root, io = defaultPlanIndexIo(), now = () => /* @_
132
177
  }
133
178
  async function writePlanIndex(root, io = defaultPlanIndexIo(), now = () => /* @__PURE__ */ new Date()) {
134
179
  const index = await buildPlanIndex(root, io, now);
135
- const dest = path.join(root, PLAN_INDEX_REL);
180
+ const dest = path2.join(root, PLAN_INDEX_REL);
136
181
  const write = io.writeFile ?? defaultPlanIndexIo().writeFile;
137
182
  const ensureIgnored = io.ensureIgnored ?? (io.writeFile ? void 0 : defaultPlanIndexIo().ensureIgnored);
138
183
  if (write) {
@@ -215,6 +260,7 @@ function extractPlanBasenames(raw) {
215
260
  }
216
261
 
217
262
  export {
263
+ ensurePathIgnored,
218
264
  extractHandoffNamedPlans,
219
265
  namedPlanCandidatePaths,
220
266
  parsePlanFrontmatter,
@@ -0,0 +1,248 @@
1
+ import {
2
+ RedactingStreamBuffer,
3
+ claudeRedactions,
4
+ redactSecrets
5
+ } from "./chunk-3KFLQE6Y.js";
6
+ import {
7
+ fileExists
8
+ } from "./chunk-5B4DVO6C.js";
9
+
10
+ // src/plan-loop/external-review.ts
11
+ import { spawn } from "child_process";
12
+ import path from "path";
13
+ var CANONICAL_REL = path.join(".cursor", "scripts", "plan-external-review.sh");
14
+ var FALLBACK_REL = path.join("scripts", "plan-external-review.sh");
15
+ function isPlanExhaustedReason(reason) {
16
+ const r = reason.trim().toLowerCase();
17
+ if (!r) return false;
18
+ if (r.includes("plan exhausted")) return true;
19
+ if (r.includes("nothing to do")) return true;
20
+ if (r.includes("no implementable")) return true;
21
+ if (/\ball\s+(implementable\s+)?to-?dos?\b/.test(r) && (r.includes("completed") || r.includes("done") || r.includes("exhausted"))) {
22
+ return true;
23
+ }
24
+ return false;
25
+ }
26
+ function shouldArmExternalPlanReview(input) {
27
+ if (input.pending === 0) return true;
28
+ if (input.stopReason && isPlanExhaustedReason(input.stopReason)) return true;
29
+ return false;
30
+ }
31
+ async function armExternalPlanReview(root, options = {}) {
32
+ const spawnFn = options.spawnFn ?? spawn;
33
+ const existsFn = options.existsFn ?? fileExists;
34
+ const log = options.log ?? ((line) => console.log(line));
35
+ const force = options.force === true;
36
+ const canonicalPath = path.join(root, CANONICAL_REL);
37
+ const fallbackPath = path.join(root, FALLBACK_REL);
38
+ let scriptPath = null;
39
+ let scriptRel = CANONICAL_REL;
40
+ if (await existsFn(canonicalPath)) {
41
+ scriptPath = canonicalPath;
42
+ scriptRel = CANONICAL_REL;
43
+ } else if (await existsFn(fallbackPath)) {
44
+ scriptPath = fallbackPath;
45
+ scriptRel = FALLBACK_REL;
46
+ }
47
+ if (!scriptPath) {
48
+ log(
49
+ `tip: ${CANONICAL_REL} missing (optional wrapper: ${FALLBACK_REL}). Manual: /plan-external-review (enable externalPlanReview in .cursor/context/config.json).`
50
+ );
51
+ return { invoked: false, exitCode: null, output: "" };
52
+ }
53
+ log("Plan exhausted: arming optional external plan review (opt-in handled by script)...");
54
+ const args = force ? [scriptPath, "--force", "--print"] : [scriptPath, "--print"];
55
+ const implementerModel = options.implementerModel?.trim();
56
+ if (implementerModel) args.push("--implementer-model", implementerModel);
57
+ return new Promise((resolve) => {
58
+ const child = spawnFn("bash", args, {
59
+ cwd: root,
60
+ env: { ...process.env, AGENT_KIT_HEADLESS: "1" }
61
+ });
62
+ const redact = claudeRedactions(process.env);
63
+ const outBuffer = new RedactingStreamBuffer(redact);
64
+ const errBuffer = new RedactingStreamBuffer(redact);
65
+ let output = "";
66
+ const emitOut = (s) => {
67
+ if (!s) return;
68
+ output += s;
69
+ if (options.writeOut) options.writeOut(s);
70
+ else process.stdout.write(s);
71
+ };
72
+ const emitErr = (s) => {
73
+ if (!s) return;
74
+ output += s;
75
+ process.stderr.write(s);
76
+ };
77
+ let flushed = false;
78
+ const flush = () => {
79
+ if (flushed) return;
80
+ flushed = true;
81
+ emitOut(outBuffer.flush());
82
+ emitErr(errBuffer.flush());
83
+ };
84
+ child.stdout?.on("data", (chunk) => emitOut(outBuffer.push(chunk)));
85
+ child.stderr?.on("data", (chunk) => emitErr(errBuffer.push(chunk)));
86
+ child.on("error", (err) => {
87
+ flush();
88
+ log(
89
+ `tip: external plan review launcher failed (${redactSecrets(err.message, redact)}). Manual: ${scriptRel} or /plan-external-review`
90
+ );
91
+ resolve({ invoked: true, exitCode: null, output });
92
+ });
93
+ child.on("close", (code) => {
94
+ flush();
95
+ if (code !== 0 && code !== null) {
96
+ log(
97
+ `tip: external plan review exited ${code} (ignored; does not fail the loop). Manual: ${scriptRel} or /plan-external-review`
98
+ );
99
+ }
100
+ resolve({ invoked: true, exitCode: code, output });
101
+ });
102
+ });
103
+ }
104
+
105
+ // src/plan-loop/sentinel.ts
106
+ import { readFile } from "fs/promises";
107
+ var SENTINEL_RE = /LOOP_TICK_RESULT:\s*(continue|stop(?:\s*[—-].*)?)/i;
108
+ function takeFromText(text) {
109
+ if (!text) return null;
110
+ const m = SENTINEL_RE.exec(text);
111
+ if (!m?.[1]) return null;
112
+ const raw = m[1].trim();
113
+ if (raw.toLowerCase().startsWith("stop")) {
114
+ const reason = raw.slice(4).replace(/^[—\-\s]+/, "").trim() || "requested by agent";
115
+ return { kind: "stop", reason };
116
+ }
117
+ return { kind: "continue" };
118
+ }
119
+ function parseSentinelFromLog(content) {
120
+ let lastJson = null;
121
+ let lastText = null;
122
+ let sawJson = false;
123
+ for (const line of content.split(/\r?\n/)) {
124
+ const trimmed = line.trim();
125
+ if (!trimmed) continue;
126
+ if (!trimmed.startsWith("{")) {
127
+ const hit = takeFromText(trimmed);
128
+ if (hit) lastText = hit;
129
+ continue;
130
+ }
131
+ try {
132
+ const ev = JSON.parse(trimmed);
133
+ sawJson = true;
134
+ if (ev.type === "result" && typeof ev.result === "string") {
135
+ const hit = takeFromText(ev.result);
136
+ if (hit) lastJson = hit;
137
+ }
138
+ const parts = ev.type === "assistant" ? ev.message?.content : void 0;
139
+ if (Array.isArray(parts)) {
140
+ for (const part of parts) {
141
+ if (part && typeof part === "object" && part.type === "text" && typeof part.text === "string") {
142
+ const hit = takeFromText(part.text);
143
+ if (hit) lastJson = hit;
144
+ }
145
+ }
146
+ }
147
+ } catch {
148
+ const hit = takeFromText(trimmed);
149
+ if (hit) lastText = hit;
150
+ }
151
+ }
152
+ return (sawJson ? lastJson : lastText) ?? { kind: "missing" };
153
+ }
154
+ function parseTickResultStatus(content) {
155
+ let last = null;
156
+ for (const line of content.split(/\r?\n/)) {
157
+ const trimmed = line.trim();
158
+ if (!trimmed.startsWith("{")) continue;
159
+ try {
160
+ const ev = JSON.parse(trimmed);
161
+ if (ev.type !== "result") continue;
162
+ const errors = Array.isArray(ev.errors) ? ev.errors.filter((e) => typeof e === "string") : [];
163
+ last = {
164
+ isError: ev.is_error === true,
165
+ ...typeof ev.subtype === "string" ? { subtype: ev.subtype } : {},
166
+ errors
167
+ };
168
+ } catch {
169
+ }
170
+ }
171
+ return last;
172
+ }
173
+ async function parseTickResultStatusFromLogFile(logPath) {
174
+ try {
175
+ return parseTickResultStatus(await readFile(logPath, "utf8"));
176
+ } catch {
177
+ return null;
178
+ }
179
+ }
180
+ async function parseSentinelFromLogFile(logPath) {
181
+ try {
182
+ const content = await readFile(logPath, "utf8");
183
+ return parseSentinelFromLog(content);
184
+ } catch {
185
+ return { kind: "missing" };
186
+ }
187
+ }
188
+ function formatSentinelLine(sentinel) {
189
+ if (sentinel.kind === "continue") return "LOOP_TICK_RESULT: continue";
190
+ if (sentinel.kind === "stop") return `LOOP_TICK_RESULT: stop - ${sentinel.reason}`;
191
+ return "";
192
+ }
193
+ var AGENT_STOP_LINE_PREFIX = "Agent requested stop: ";
194
+ function formatAgentStopLine(sentinel) {
195
+ return `${AGENT_STOP_LINE_PREFIX}${formatSentinelLine(sentinel)}`;
196
+ }
197
+ var AGENT_STOP_LINE_RE = /^Agent requested stop: LOOP_TICK_RESULT: stop - (.*)$/;
198
+ function parseAgentStopLine(line) {
199
+ const m = AGENT_STOP_LINE_RE.exec(line.replace(/\r$/, ""));
200
+ if (!m) return null;
201
+ return m[1]?.trim() || "requested by agent";
202
+ }
203
+ var NO_PROGRESS_REASON = "tick reported continue without progress";
204
+ function formatNoProgressLine(input) {
205
+ return `Tick reported continue without progress (pending ${input.before} -> ${input.after}; plan and HANDOFF unchanged) - stopping for safety. See log: ${input.log}`;
206
+ }
207
+ var NO_PROGRESS_LINE_RE = /^Tick reported continue without progress \(pending \d+ -> \d+; plan and HANDOFF unchanged\) - stopping for safety\./;
208
+ function isNoProgressLine(line) {
209
+ return NO_PROGRESS_LINE_RE.test(line.replace(/\r$/, ""));
210
+ }
211
+ function sentinelFromTurn(turn) {
212
+ const fromResult = takeFromText(turn.resultText);
213
+ if (fromResult) return fromResult;
214
+ for (let i = turn.assistantTexts.length - 1; i >= 0; i--) {
215
+ const hit = takeFromText(turn.assistantTexts[i] ?? "");
216
+ if (hit) return hit;
217
+ }
218
+ return null;
219
+ }
220
+ function tickResultStatusFromTurn(turn) {
221
+ return {
222
+ isError: turn.isError,
223
+ ...turn.subtype !== null ? { subtype: turn.subtype } : {},
224
+ errors: turn.errors
225
+ };
226
+ }
227
+ async function resolveTickResultStatus(lastResult, logPath, fromFile = parseTickResultStatusFromLogFile) {
228
+ if (lastResult) return tickResultStatusFromTurn(lastResult);
229
+ return fromFile(logPath);
230
+ }
231
+ async function resolveTickSentinel(lastResult, logPath, fromFile = parseSentinelFromLogFile) {
232
+ const fromTurn = lastResult ? sentinelFromTurn(lastResult) : null;
233
+ return fromTurn ?? fromFile(logPath);
234
+ }
235
+
236
+ export {
237
+ isPlanExhaustedReason,
238
+ shouldArmExternalPlanReview,
239
+ armExternalPlanReview,
240
+ formatSentinelLine,
241
+ formatAgentStopLine,
242
+ parseAgentStopLine,
243
+ NO_PROGRESS_REASON,
244
+ formatNoProgressLine,
245
+ isNoProgressLine,
246
+ resolveTickResultStatus,
247
+ resolveTickSentinel
248
+ };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  inspectQueueLease
3
- } from "./chunk-MFKHIWEL.js";
3
+ } from "./chunk-FOVHFMSH.js";
4
4
  import {
5
5
  HANDOFF_REL
6
- } from "./chunk-C4Q77GGJ.js";
6
+ } from "./chunk-O7VMHCNN.js";
7
7
 
8
8
  // ../../dashboard/lib/chat-sessions.mjs
9
9
  import {
@@ -1,22 +1,22 @@
1
+ import {
2
+ diffAgainstRegistry,
3
+ summarizeDiff
4
+ } from "./chunk-MWRYQLEG.js";
1
5
  import {
2
6
  contextConfigPath,
3
7
  intervalElapsed,
4
8
  loadContextConfig
5
9
  } from "./chunk-PFEUZXVT.js";
6
- import {
7
- diffAgainstRegistry,
8
- summarizeDiff
9
- } from "./chunk-C7SV7UP5.js";
10
10
  import {
11
11
  DEFAULT_REGISTRY_URL,
12
12
  assertSafeRegistrySource,
13
13
  loadAgentKitManifest,
14
14
  resolveRegistryRoot
15
- } from "./chunk-JG3CNGQM.js";
15
+ } from "./chunk-ZNZHDPS3.js";
16
16
  import {
17
17
  KIT_PACKAGE_SPEC,
18
18
  KIT_VERSION
19
- } from "./chunk-7HDQEK6T.js";
19
+ } from "./chunk-2G4K4ZI5.js";
20
20
  import {
21
21
  readJson,
22
22
  writeJson
@@ -2,7 +2,7 @@ import {
2
2
  REPO_ROOT_ENV,
3
3
  bundledDashboardCandidates,
4
4
  findDashboardStart
5
- } from "./chunk-ZMYV6PRE.js";
5
+ } from "./chunk-LEVNLHH3.js";
6
6
  import {
7
7
  HELMET_ACCENT,
8
8
  HELMET_FILL,