frizz-server 0.15.48 → 0.15.50

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 (156) hide show
  1. package/dist/acp-daemon.js +39 -5
  2. package/dist/claude-agent-broker.js +55 -17
  3. package/dist/codex-app-server-daemon.js +43 -9
  4. package/dist/dev-child.js +11174 -3664
  5. package/package.json +15 -8
  6. package/runtime/board/agent-status.mjs +3 -3
  7. package/runtime/cc-worker/DECISIONS.md +19 -0
  8. package/runtime/cc-worker/bin/frizz-mcp.mjs +4 -2
  9. package/runtime/cc-worker/bin/frizzctl.mjs +26 -3
  10. package/runtime/cc-worker/hooks/deny-plan.mjs +4 -3
  11. package/runtime/cc-worker/hooks/hooks.json +18 -18
  12. package/runtime/cc-worker/hooks/scratchpad.mjs +10 -6
  13. package/runtime/cc-worker/lib/frizz-tools.mjs +156 -77
  14. package/web-dist/assets/{abnfDiagram-VRR7QNED-B13Nf5uG.js → abnfDiagram-VCTEODGH-CSl-iUaD.js} +1 -1
  15. package/web-dist/assets/{arc-tjQgP-a1.js → arc-BSyeo0Gb.js} +1 -1
  16. package/web-dist/assets/architecture-7GRP2DOG-jYpGgJVJ.js +1 -0
  17. package/web-dist/assets/architectureDiagram-5GKGNRK7-Bo_gyMVC.js +36 -0
  18. package/web-dist/assets/blockDiagram-I7D4REHJ-9EtOS1Y1.js +129 -0
  19. package/web-dist/assets/c4Diagram-7LVT6UL2-CE1hW3oj.js +38 -0
  20. package/web-dist/assets/channel-CC-n29cI.js +1 -0
  21. package/web-dist/assets/chunk-2E4U76K2-QqOdoNOR.js +2 -0
  22. package/web-dist/assets/chunk-4HAMMTFA-Df2uLm9r.js +62 -0
  23. package/web-dist/assets/{chunk-ICXQ74PX-CUDlgeXU.js → chunk-75Z2AOVW-DF1G6d8q.js} +1 -1
  24. package/web-dist/assets/{chunk-VAUOI2AC-DpbSQ-0T.js → chunk-CLGD4ZFX-CMAQm7EJ.js} +1 -1
  25. package/web-dist/assets/chunk-DU6HZSFF-UWY5hXXp.js +127 -0
  26. package/web-dist/assets/{chunk-32BRIVSS-DCVxFWaV.js → chunk-F27PBJKO-C59uYSbj.js} +1 -1
  27. package/web-dist/assets/{chunk-KEIR6QF5-BfrZ3jm6.js → chunk-FOHPRMQF-CyTuVbu3.js} +2 -2
  28. package/web-dist/assets/chunk-GMAD6QVW-BsJsQjY4.js +72 -0
  29. package/web-dist/assets/chunk-GVQU2GXP-BuITwr9r.js +1 -0
  30. package/web-dist/assets/{chunk-EX3LRPZG-C57JKsUG.js → chunk-IMKFNOWR-5Ui4f5l4.js} +2 -2
  31. package/web-dist/assets/chunk-L3NEJ4N5-BISBblwX.js +1 -0
  32. package/web-dist/assets/chunk-LNGE3PJU-DNNNwF8Y.js +34 -0
  33. package/web-dist/assets/chunk-OSK3NFVY-CZl3XlkY.js +10 -0
  34. package/web-dist/assets/chunk-P2QGCYS3-DoytbW1J.js +1 -0
  35. package/web-dist/assets/{chunk-VR4S4FIN-BW2QJzbp.js → chunk-POPQ4Y6H-D28hnSIy.js} +1 -1
  36. package/web-dist/assets/{chunk-HOUHSVGY-rlZvVAjI.js → chunk-PWAF6VOD-CbZvnkji.js} +1 -1
  37. package/web-dist/assets/chunk-SHT3W25Y-DM4ozJwj.js +168 -0
  38. package/web-dist/assets/{chunk-MOJQB5TN-BGaw_67a.js → chunk-SVP7TREG-m6oapxSg.js} +1 -1
  39. package/web-dist/assets/{chunk-V7JOEXUC-kdk1Kj1f.js → chunk-TICWLB2K-Ochfyos9.js} +1 -1
  40. package/web-dist/assets/chunk-TLUHSLCS-iM7uiuAo.js +2 -0
  41. package/web-dist/assets/{chunk-XXDRQBXY-DISoSt1F.js → chunk-XXDRQBXY-DYlTP5J-.js} +1 -1
  42. package/web-dist/assets/classDiagram-ZZMXUADV-CXJ9OBBD.js +1 -0
  43. package/web-dist/assets/classDiagram-v2-VYDZK3BY-CXJ9OBBD.js +1 -0
  44. package/web-dist/assets/cose-bilkent-JH36ORCC-BUIsLrGc.js +1 -0
  45. package/web-dist/assets/cynefin-OW5HDTMX-XtTYGcIH.js +1 -0
  46. package/web-dist/assets/{cynefinDiagram-TSTJHNR4-D1KgH5Uh.js → cynefinDiagram-5FMLGOSQ--ClxINOZ.js} +1 -1
  47. package/web-dist/assets/dagre-BJJUWK_n.js +1 -0
  48. package/web-dist/assets/dagre-GXQ25YYZ-CupZ_9Gq.js +4 -0
  49. package/web-dist/assets/{diagram-OA4YK3LP-DQZYQQmQ.js → diagram-S7CK7UJ4-BlF7gkGi.js} +4 -4
  50. package/web-dist/assets/diagram-UQ7AKVKN-BMXRmU5D.js +41 -0
  51. package/web-dist/assets/{diagram-FQU43EPY-DJLjwc2E.js → diagram-VSXAHHWV-r5DJsSB3.js} +1 -1
  52. package/web-dist/assets/{diagram-G47NLZAW-R_nxXPm1.js → diagram-VX7I27RA-DxGq7Ln7.js} +1 -1
  53. package/web-dist/assets/{diagram-NH7WQ7WH-BgEKOFUU.js → diagram-Z3DM3KII-DqXtb_id.js} +1 -1
  54. package/web-dist/assets/dist-DoH_9pyS.js +1 -0
  55. package/web-dist/assets/{ebnfDiagram-CCIWWBDH-DwgS-ruz.js → ebnfDiagram-PWID7BFC-BV_AT7TD.js} +1 -1
  56. package/web-dist/assets/erDiagram-RLTQ6QDP-BV70EqG9.js +99 -0
  57. package/web-dist/assets/eventmodeling-NTZA5JFV-Cw8GwV1a.js +1 -0
  58. package/web-dist/assets/flowDiagram-HODETNUW-B0Q6ZSg0.js +1 -0
  59. package/web-dist/assets/ganttDiagram-EL5Y4UJY-Cvkf14ib.js +292 -0
  60. package/web-dist/assets/gitGraph-4MIJSDKK-XBlZCz1U.js +1 -0
  61. package/web-dist/assets/{gitGraphDiagram-IHSO6WYX-CZd5jqgf.js → gitGraphDiagram-WWUBYQGX-vDyL82tj.js} +1 -1
  62. package/web-dist/assets/index-D-pcMA7P.js +242 -0
  63. package/web-dist/assets/index-DqckQXcp.css +2 -0
  64. package/web-dist/assets/info-A6RAGUB7-DfR7iRgc.js +1 -0
  65. package/web-dist/assets/{infoDiagram-FWYZ7A6U-C2fsvj8W.js → infoDiagram-27XIBGKW-BT4k6N6o.js} +1 -1
  66. package/web-dist/assets/{ishikawaDiagram-FXEZZL3T-DDputQI8.js → ishikawaDiagram-5VMMS53U-BJIdMG0T.js} +1 -1
  67. package/web-dist/assets/{journeyDiagram-5HDEW3XC-CiwOnh1u.js → journeyDiagram-3NMN7TZE-CUGzIF61.js} +2 -2
  68. package/web-dist/assets/{kanban-definition-HUTT4EX6-P8OTxob-.js → kanban-definition-UXKFOSKX-DIPC4kv7.js} +2 -2
  69. package/web-dist/assets/{line-Kk41edHq.js → line-CJKCWj73.js} +1 -1
  70. package/web-dist/assets/{linear-CCCAZbB0.js → linear-z2V0wJk9.js} +1 -1
  71. package/web-dist/assets/{mermaid-parser.core-BIyJ5CJF.js → mermaid-parser.core-BH-fcjsB.js} +3 -3
  72. package/web-dist/assets/mermaid.core-BSdNmJCs.js +11 -0
  73. package/web-dist/assets/{mindmap-definition-LN4V7U3C-CbKVoOZ5.js → mindmap-definition-YA3MSWOX-CJC3zMDF.js} +1 -1
  74. package/web-dist/assets/packet-AYTQ26CC-BET157L_.js +1 -0
  75. package/web-dist/assets/{pegDiagram-2B236MQR-DImDz479.js → pegDiagram-XKGWAZYB-Du8ALEoR.js} +1 -1
  76. package/web-dist/assets/pie-WAS4IAKB-CDs5cIGi.js +1 -0
  77. package/web-dist/assets/{pieDiagram-ENE6RG2P-C2e3M1_h.js → pieDiagram-E7YTZNPT-BX88bIIM.js} +1 -1
  78. package/web-dist/assets/{quadrantDiagram-ABIIQ3AL-Dt3f_lrO.js → quadrantDiagram-AXDQQJYC-BkGxldmI.js} +1 -1
  79. package/web-dist/assets/radar-RG4KPBEZ-FMcFyhAF.js +1 -0
  80. package/web-dist/assets/railroad-74A4TZTK-Du0SbLQI.js +1 -0
  81. package/web-dist/assets/railroad-abnf-HS5TGJTU-DRi4RhLb.js +1 -0
  82. package/web-dist/assets/railroad-ebnf-LZEXJU2U-BmBkdsnK.js +1 -0
  83. package/web-dist/assets/railroad-peg-WCYAUIDC-CydTrmQm.js +1 -0
  84. package/web-dist/assets/{railroadDiagram-RFXS5EU6-CBZHt0Mo.js → railroadDiagram-O6MQD6OU-CYqN0dL6.js} +1 -1
  85. package/web-dist/assets/{requirementDiagram-TGXJPOKE-BxSs_q3D.js → requirementDiagram-BXWQKSXE-ClpQ_sLR.js} +2 -2
  86. package/web-dist/assets/rolldown-runtime-Bh1tDfsg.js +1 -0
  87. package/web-dist/assets/{sankeyDiagram-HTMAVEWB-DeJR64nI.js → sankeyDiagram-P5KCCOFB-CEJUF8o9.js} +1 -1
  88. package/web-dist/assets/{sequenceDiagram-DBY2YBRQ-oOI0fQW_.js → sequenceDiagram-WJ2MYXX4-BpJYUJhB.js} +1 -1
  89. package/web-dist/assets/src-C4XfhTaE.js +1 -0
  90. package/web-dist/assets/{stateDiagram-2N3HPSRC-C0geqCc2.js → stateDiagram-D77RDMKH-BmKLEj9Q.js} +1 -1
  91. package/web-dist/assets/stateDiagram-v2-MP3YSRHH-D_c6vvvW.js +1 -0
  92. package/web-dist/assets/swimlanes-42K2YHIH-CyJxVets.js +1 -0
  93. package/web-dist/assets/swimlanesDiagram-VR7AAH4N-BcVx8rdP.js +8 -0
  94. package/web-dist/assets/threadSurfaces-CYpFDk_e.js +143 -0
  95. package/web-dist/assets/{timeline-definition-FHXFAJF6-CCY_OuVM.js → timeline-definition-24CTP7MA-ChEqw_62.js} +1 -1
  96. package/web-dist/assets/treeView-Q6P3EWNA-l1PaAwLT.js +1 -0
  97. package/web-dist/assets/treemap-WGGIJYW6-CxvHcEiT.js +1 -0
  98. package/web-dist/assets/{vennDiagram-L72KCM5P-OGzW7d1w.js → vennDiagram-4TSXK5OY-DF-yXPNP.js} +1 -1
  99. package/web-dist/assets/wardley-WFR3VGLG-BqkX6NQy.js +1 -0
  100. package/web-dist/assets/{wardleyDiagram-EHGQE667-CJKRWMOx.js → wardleyDiagram-VM6X3IG4-B9LU1bxh.js} +1 -1
  101. package/web-dist/assets/{xychartDiagram-FW5EYKEG-biGPRYAN.js → xychartDiagram-S5SC5T6Z-Zt_ZqCWS.js} +3 -3
  102. package/web-dist/index.html +3 -2
  103. package/runtime/board/agent-liveness.mjs +0 -367
  104. package/runtime/board/notify-shared.mjs +0 -90
  105. package/runtime/board/notify.mjs +0 -81
  106. package/runtime/board/rest-detect.mjs +0 -213
  107. package/runtime/board/thread-excerpt.mjs +0 -162
  108. package/web-dist/assets/architecture-TIHT7OUA-cscbyVpp.js +0 -1
  109. package/web-dist/assets/architectureDiagram-ZJ3FMSHR-Bse2UXVn.js +0 -36
  110. package/web-dist/assets/blockDiagram-677ZJIJ3-BLJZnqTz.js +0 -132
  111. package/web-dist/assets/c4Diagram-LMCZKHZV-DO7oo4h9.js +0 -10
  112. package/web-dist/assets/channel-ChsreyIE.js +0 -1
  113. package/web-dist/assets/chunk-52WLFC77-Cg3jpJ_e.js +0 -10
  114. package/web-dist/assets/chunk-7BUUIJ7U-Bb538aSH.js +0 -1
  115. package/web-dist/assets/chunk-C7G6YPKG-Cb_zdGzQ.js +0 -1
  116. package/web-dist/assets/chunk-FWX5IMBZ-2PvmKNIs.js +0 -2
  117. package/web-dist/assets/chunk-OGEWGWER-CEeg8UMh.js +0 -1
  118. package/web-dist/assets/chunk-PUDLZKDR-xwNSwwyn.js +0 -156
  119. package/web-dist/assets/chunk-Q4XR5HBZ-msU0GK4L.js +0 -70
  120. package/web-dist/assets/chunk-RYQCIY6F-BBiFFmSH.js +0 -1
  121. package/web-dist/assets/chunk-WYO6CB5R-BouXl6Ea.js +0 -127
  122. package/web-dist/assets/chunk-ZGVPDNZ5-C7QT30bj.js +0 -62
  123. package/web-dist/assets/chunk-ZIRB5QZD-C6fEPe3t.js +0 -32
  124. package/web-dist/assets/classDiagram-OUVF2IWQ-DzRcM19r.js +0 -1
  125. package/web-dist/assets/classDiagram-v2-EOCWNBFH-DzRcM19r.js +0 -1
  126. package/web-dist/assets/cose-bilkent-JH36ORCC-B4uC0Pku.js +0 -1
  127. package/web-dist/assets/cynefin-VYW2F7L2-KGwY_f6i.js +0 -1
  128. package/web-dist/assets/dagre-CXRCoUWR.js +0 -1
  129. package/web-dist/assets/dagre-VKFMJZFB-CpBkJUGX.js +0 -4
  130. package/web-dist/assets/diagram-WEI45ONY-BPJydYC6.js +0 -41
  131. package/web-dist/assets/dist-KklTF2b-.js +0 -1
  132. package/web-dist/assets/erDiagram-Q63AITRT-CpxSzpX_.js +0 -85
  133. package/web-dist/assets/eventmodeling-45OFAUF4-pAxX2kmp.js +0 -1
  134. package/web-dist/assets/flowDiagram-23GEKE2U-CNUJOYgE.js +0 -1
  135. package/web-dist/assets/ganttDiagram-NO4QXBWP-DKV9dDLx.js +0 -292
  136. package/web-dist/assets/gitGraph-TEB2WS4Q-Di3-VfYF.js +0 -1
  137. package/web-dist/assets/index-CnoKcjA-.css +0 -2
  138. package/web-dist/assets/index-dgMYbeEx.js +0 -378
  139. package/web-dist/assets/info-DKCQHKI2-zUEOPGRX.js +0 -1
  140. package/web-dist/assets/map-DsCK-0Cs.js +0 -1
  141. package/web-dist/assets/mermaid.core-CrqCm1sE.js +0 -11
  142. package/web-dist/assets/packet-7NZHBO7P-Dk5Sv2nR.js +0 -1
  143. package/web-dist/assets/pie-RZYD4A2V-D4HndtMy.js +0 -1
  144. package/web-dist/assets/radar-I7S5WNFK-Bgms7oi0.js +0 -1
  145. package/web-dist/assets/railroad-3IZDKUUU-BZvaJJq3.js +0 -1
  146. package/web-dist/assets/railroad-abnf-AHOZXSZD-BaE30t8x.js +0 -1
  147. package/web-dist/assets/railroad-ebnf-EBAXGLYW-Cuetb6tx.js +0 -1
  148. package/web-dist/assets/railroad-peg-LSFZ7HO6-DDs0AouG.js +0 -1
  149. package/web-dist/assets/src-DLhDEMjC.js +0 -1
  150. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-l7nncg_Z.js +0 -1
  151. package/web-dist/assets/swimlanes-5IMT3BWC-BABUQ-Hv.js +0 -2
  152. package/web-dist/assets/swimlanesDiagram-G3AALYLV-BAhikHjx.js +0 -8
  153. package/web-dist/assets/treeView-QDETBFTQ-CjszFvr3.js +0 -1
  154. package/web-dist/assets/treemap-6X3UGDF4-BbdOWC-4.js +0 -1
  155. package/web-dist/assets/wardley-OPB4EBWU-GgVEIZwC.js +0 -1
  156. /package/web-dist/assets/{sizeCapture-X5ZJPWSS-B0uUizjq.js → sizeCapture-INFHLROL-B0uUizjq.js} +0 -0
@@ -1,213 +0,0 @@
1
- // @ts-check
2
- /**
3
- * frizz — "rest-on-waiter" detection. PURE, dependency-free, and unit-tested
4
- * (rest-detect.test.mjs) so the SubagentStop guard (hooks/frizz-rest-guard.mjs)
5
- * can stay a thin I/O shell around this judgment.
6
- *
7
- * THE PROBLEM it detects: a background sub-agent backgrounds a long op (a build, a
8
- * test run, a CI watch, an install) and then RESTS — going idle and handing control
9
- * back — instead of running the op to completion. That strands the task: the
10
- * orchestrator must manually resume it. The guard BLOCKS that stop and redirects the
11
- * agent to poll the op inline and finish.
12
- *
13
- * TWO SIGNALS, OR-ed (defense in depth). A stop is blocked if EITHER fires:
14
- *
15
- * 1. STRUCTURAL (primary, high-confidence) — {@link detectStructuralRest}: keyed on
16
- * what the agent DID, not how it phrased it. The agent's LAST meaningful tool_use
17
- * in the transcript was a BACKGROUND-LAUNCH (a `run_in_background` Bash/Agent/Task,
18
- * or a Monitor/ScheduleWakeup waiter/timer) and nothing substantive ran after it —
19
- * i.e. it kicked off a background op and ended its turn. This keys on the tool name
20
- * + the `run_in_background` param, so it is immune to phrasing drift (the failure
21
- * mode of the prose matcher below). See `isBackgroundLaunch`.
22
- *
23
- * 2. PROSE (fallback) — {@link detectWaiterRest}: the original phrasing matcher on the
24
- * final assistant TEXT. Catches a waiter-rest the structural signal misses (e.g. the
25
- * bg-launch was an earlier turn, or the harness shape changed). Demoted to secondary
26
- * because string-matching the prose is fragile; kept because it costs nothing and the
27
- * two signals fail in different directions.
28
- *
29
- * Why structural beats prose: the prose matcher hinges on the agent SAYING "I'll await
30
- * the monitor"; an agent that backgrounds-and-rests SILENTLY (no tell) slips it, and a
31
- * reworded tell slips it. The structural signal sees the bg-launch tool call regardless.
32
- *
33
- * (A fully-deterministic "is the launched bg task STILL RUNNING?" signal was investigated
34
- * and is NOT feasible from a hook: the harness `tasks/<id>.output` files are raw stdout
35
- * streams / jsonl symlinks with no authoritative running-vs-terminal status or exit-code
36
- * sidecar, and the SubagentStop stdin carries no task registry. mtime-liveness is
37
- * load-dependent and non-deterministic. So we rely on the tool-use structure, which is
38
- * deterministic from the transcript the hook already reads.)
39
- */
40
- import { readFileSync } from 'node:fs';
41
-
42
- /**
43
- * FUTURE/ONGOING parking intent — the agent declaring it will idle and be woken.
44
- * Deliberately excludes bare "complete"/"waited for" (past tense = done, not parking).
45
- */
46
- const PARK =
47
- /\b(?:await(?:ing)?|waiting for|i'?ll wait|i'?ll await|holding(?: here)?|pausing|paused here|standing by|letting it (?:complete|finish|run)|will notify me|notify me when|re-?invoke(?:s|d)? me|holding until|until then|rather than poll(?:ing)?)\b/i;
48
-
49
- /** BACKGROUND-MECHANISM noun — the thing it's resting ON. */
50
- const MECH =
51
- /\b(?:monitor|waiter|watcher|background(?:ed)?|completion notification|notify(?:ing)? me|re-?invoke)\b/i;
52
-
53
- /**
54
- * High-confidence single phrases that ALONE prove a waiter-rest (so a message that
55
- * trips only one of PARK/MECH but contains one of these still blocks). Kept tight.
56
- */
57
- const STRONG = [
58
- /\bthe (?:background )?(?:waiter|monitor|watcher)\b[^.]*\b(?:will|to) (?:notify|re-?invoke|wake)\b/i,
59
- /\brather than poll(?:ing)?\b/i,
60
- /\bstanding by\b/i,
61
- /\bwill (?:notify|re-?invoke|ping|wake) me\b/i,
62
- ];
63
-
64
- /**
65
- * Does this final-assistant text read as RESTING ON A WAITER/MONITOR (a false rest
66
- * that should be blocked) rather than a genuine deliverable?
67
- * @param {string|null|undefined} text the agent's last assistant message text
68
- * @returns {boolean} true ONLY on a high-confidence waiter-rest match
69
- */
70
- export function detectWaiterRest(text) {
71
- if (!text || typeof text !== 'string') return false;
72
- // Scan a bounded tail — the parking tell is always at the END of the message, and
73
- // scanning the whole of a long report risks a stray match in earlier narration.
74
- const tail = text.length > 1200 ? text.slice(-1200) : text;
75
- if (STRONG.some((re) => re.test(tail))) return true;
76
- return PARK.test(tail) && MECH.test(tail);
77
- }
78
-
79
- /**
80
- * Extract the LAST assistant message's joined text from a transcript .jsonl.
81
- * Each line is a JSON event; an assistant turn has `type:"assistant"` and
82
- * `message.content` is an array of blocks; text blocks are `{type:"text", text}`.
83
- * Returns the joined text of the latest assistant turn that HAS any text block, or
84
- * null if none/unreadable (→ caller fails open).
85
- * @param {string|null|undefined} transcriptPath
86
- * @returns {string|null}
87
- */
88
- export function lastAssistantText(transcriptPath) {
89
- try {
90
- if (!transcriptPath || typeof transcriptPath !== 'string') return null;
91
- const raw = readFileSync(transcriptPath, 'utf8');
92
- const lines = raw.split('\n');
93
- for (let i = lines.length - 1; i >= 0; i--) {
94
- const line = lines[i].trim();
95
- if (!line) continue;
96
- let o;
97
- try {
98
- o = JSON.parse(line);
99
- } catch {
100
- continue;
101
- }
102
- if (!o || o.type !== 'assistant' || !o.message || !Array.isArray(o.message.content)) continue;
103
- const texts = o.message.content
104
- .filter((b) => b && b.type === 'text' && typeof b.text === 'string')
105
- .map((b) => b.text);
106
- if (texts.length) return texts.join('\n').trim();
107
- }
108
- return null;
109
- } catch {
110
- return null;
111
- }
112
- }
113
-
114
- // ─────────────────────────────────────────────────────────────────────────────
115
- // STRUCTURAL SIGNAL — key on the agent's TOOL-USE history, not its prose.
116
- // ─────────────────────────────────────────────────────────────────────────────
117
-
118
- /**
119
- * BACKGROUND-LAUNCH tool names that are ALWAYS a waiter/timer launch by their very
120
- * nature — no parameter check needed. A Monitor (poll-until loop) or a ScheduleWakeup
121
- * (timer) IS, definitionally, "kick off a background wait." (Verified against real
122
- * transcripts: `{name:"Monitor", input:{command,timeout_ms,persistent}}` and
123
- * `{name:"ScheduleWakeup", input:{delaySeconds,reason,prompt}}`.)
124
- * @type {ReadonlySet<string>}
125
- */
126
- const ALWAYS_BG_TOOLS = new Set(['Monitor', 'ScheduleWakeup']);
127
-
128
- /**
129
- * Is this content block a BACKGROUND-LAUNCH tool_use — the structural tell that the
130
- * agent kicked off a background op rather than running it to completion inline?
131
- *
132
- * Two ways a tool_use qualifies:
133
- * - it is an ALWAYS_BG tool (Monitor / ScheduleWakeup), OR
134
- * - it carries `input.run_in_background === true` (the param real Bash/Agent/Task
135
- * background launches set — verified against transcripts: a backgrounded `Bash`
136
- * has `input.run_in_background:true`, and a backgrounded `Agent` dispatch likewise).
137
- *
138
- * The `run_in_background` check is GENERIC (any tool name) so a future background-capable
139
- * tool is covered without a code change; the named set covers the waiter/timer tools that
140
- * take no such flag.
141
- * @param {any} block a transcript content block
142
- * @returns {boolean}
143
- */
144
- export function isBackgroundLaunch(block) {
145
- if (!block || block.type !== 'tool_use' || typeof block.name !== 'string') return false;
146
- if (ALWAYS_BG_TOOLS.has(block.name)) return true;
147
- const input = block && typeof block.input === 'object' && block.input ? block.input : {};
148
- return input.run_in_background === true;
149
- }
150
-
151
- /**
152
- * The STRUCTURAL waiter-rest judgment, as a PURE function of the agent's ordered
153
- * tool_use blocks (so it is unit-testable with synthetic inputs, no transcript file).
154
- *
155
- * Fires when the LAST tool_use the agent made was a background-launch. Because it is the
156
- * LAST tool_use, nothing substantive ran after it — the agent kicked off a background op
157
- * and then ended its turn (emitting at most a final text message). That is exactly the
158
- * "backgrounded-and-rested" pathology. A genuine finish polls the op inline first, so its
159
- * last tool_use is a FOREGROUND read/commit (run_in_background falsy) — not a bg-launch —
160
- * and this returns false.
161
- *
162
- * @param {any[]} toolUseBlocks ordered (transcript-order) list of tool_use content blocks
163
- * @returns {boolean} true ONLY when the last tool_use is a background-launch
164
- */
165
- export function detectStructuralRestFromToolUses(toolUseBlocks) {
166
- if (!Array.isArray(toolUseBlocks) || toolUseBlocks.length === 0) return false;
167
- return isBackgroundLaunch(toolUseBlocks[toolUseBlocks.length - 1]);
168
- }
169
-
170
- /**
171
- * Read a transcript .jsonl and return the LAST tool_use content block the agent made
172
- * (across the whole transcript), or null when there is none / it is unreadable. Scans
173
- * from the END backward for efficiency (we only need the final tool_use) and stops at
174
- * the first assistant turn that carries any tool_use, returning that turn's LAST
175
- * tool_use block (a turn may batch several). Fail-CLOSED to null on any error so the
176
- * caller fails open (no block).
177
- * @param {string|null|undefined} transcriptPath
178
- * @returns {any|null}
179
- */
180
- export function lastToolUse(transcriptPath) {
181
- try {
182
- if (!transcriptPath || typeof transcriptPath !== 'string') return null;
183
- const raw = readFileSync(transcriptPath, 'utf8');
184
- const lines = raw.split('\n');
185
- for (let i = lines.length - 1; i >= 0; i--) {
186
- const line = lines[i].trim();
187
- if (!line) continue;
188
- let o;
189
- try {
190
- o = JSON.parse(line);
191
- } catch {
192
- continue;
193
- }
194
- if (!o || o.type !== 'assistant' || !o.message || !Array.isArray(o.message.content)) continue;
195
- const tus = o.message.content.filter((b) => b && b.type === 'tool_use');
196
- if (tus.length) return tus[tus.length - 1];
197
- }
198
- return null;
199
- } catch {
200
- return null;
201
- }
202
- }
203
-
204
- /**
205
- * STRUCTURAL waiter-rest detection straight from a transcript path: true when the agent's
206
- * last tool_use was a background-launch. Fail-open (false) on any read/parse failure.
207
- * @param {string|null|undefined} transcriptPath
208
- * @returns {boolean}
209
- */
210
- export function detectStructuralRest(transcriptPath) {
211
- const last = lastToolUse(transcriptPath);
212
- return isBackgroundLaunch(last);
213
- }
@@ -1,162 +0,0 @@
1
- // @ts-check
2
- /**
3
- * frizz — thread-excerpt: read a `.frizz/<slug>.md` and render a capped, key-section
4
- * excerpt for the ORCHESTRATOR to read.
5
- *
6
- * WHY THIS EXISTS / where it's used. When a dispatched sub-agent FINISHES and the
7
- * orchestrator goes idle, the Stop hook (frizz-stop-reminder.mjs) rest-reconciliation
8
- * guard hands the orchestrator the CONTENTS of that agent's bound thread — so it can
9
- * square the agent's REPORTED results (the task return) against what the thread now
10
- * SAYS (the agent should have updated its own thread before resting; this is the
11
- * orchestrator's verification surface). We surface the thread HERE rather than via a
12
- * SubagentStop hook because a SubagentStop hook's additionalContext continues the
13
- * SUB-AGENT's turn, not the orchestrator's — the orchestrator's own Stop hook is the
14
- * only channel that actually lands thread text in the orchestrator's context.
15
- *
16
- * WHAT IT EXTRACTS — the at-a-glance current-truth of a thread, not the whole file:
17
- * the frontmatter status line (status + status_text + title) plus the `## Status`,
18
- * `## Decisions`, and `## Next step` sections (the single-voice current state). The
19
- * rest of the file (Steps checklists, long write-ups) stays behind the path pointer.
20
- *
21
- * CAPPING — a huge thread must never blow up the orchestrator's context: each thread
22
- * is capped to PER_THREAD_CAP chars and the combined surface to TOTAL_CAP; on either
23
- * cap we truncate and note the `.frizz/<slug>.md` path for the full read.
24
- *
25
- * FAIL-OPEN ABSOLUTELY: a missing/unreadable file, an unresolved slug, or any parse
26
- * error yields no excerpt for that thread (the caller degrades to the bare pointer).
27
- * Never throws.
28
- */
29
- import { readFileSync } from 'node:fs';
30
- import { join } from 'node:path';
31
-
32
- const PER_THREAD_CAP = 1200; // max chars of excerpt body per thread
33
- const TOTAL_CAP = 4000; // max chars across ALL just-finished threads combined
34
-
35
- // The body sections that carry a thread's single-voice CURRENT truth — the same set
36
- // the dispatch epilogue tells an agent to keep current. Order is the surfaced order.
37
- const KEY_SECTIONS = ['Status', 'Decisions', 'Next step'];
38
-
39
- /**
40
- * Pull the content under a `## <name>` heading up to the next h1/h2 (h3+ stays in the
41
- * section). Case-insensitive on the heading text; trailing blank lines trimmed.
42
- * @param {string} src
43
- * @param {string} name
44
- * @returns {string} the section body (no heading line), or '' if absent/empty
45
- */
46
- function section(src, name) {
47
- const lines = src.split('\n');
48
- const esc = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
49
- const head = new RegExp(`^##\\s+${esc}\\s*$`, 'i');
50
- const i = lines.findIndex((l) => head.test(l));
51
- if (i === -1) return '';
52
- const body = [];
53
- for (let j = i + 1; j < lines.length; j++) {
54
- if (/^#{1,2}\s/.test(lines[j])) break; // next h1/h2 ends the section
55
- body.push(lines[j]);
56
- }
57
- return body.join('\n').replace(/\s+$/, '').replace(/^\s*\n/, '');
58
- }
59
-
60
- /**
61
- * Parse the leading `--- … ---` frontmatter into a flat scalar map (same shape the
62
- * board parser reads). Returns {} when there's no frontmatter.
63
- * @param {string} src
64
- * @returns {Record<string,string>}
65
- */
66
- function frontmatter(src) {
67
- /** @type {Record<string,string>} */
68
- const out = {};
69
- const m = src.match(/^---\n([\s\S]*?)\n---/);
70
- if (!m) return out;
71
- for (const line of m[1].split('\n')) {
72
- const kv = line.match(/^(\w[\w-]*):\s*(.*)$/);
73
- if (kv) out[kv[1]] = kv[2].trim().replace(/^["']|["']$/g, '');
74
- }
75
- return out;
76
- }
77
-
78
- /**
79
- * Build a capped excerpt of one thread's current truth, or null if the file can't be
80
- * read / has no useful content. The returned string is the BODY only (the caller adds
81
- * the `--- .frizz/<slug>.md ---` banner) so callers can frame it uniformly.
82
- * @param {string} projectDir
83
- * @param {string} slug
84
- * @returns {string|null}
85
- */
86
- export function threadExcerpt(projectDir, slug) {
87
- if (!slug || typeof slug !== 'string') return null;
88
- const rel = `.frizz/${slug}.md`;
89
- let src;
90
- try {
91
- src = readFileSync(join(projectDir, '.frizz', `${slug}.md`), 'utf8');
92
- } catch {
93
- return null; // missing/unreadable → caller degrades to the bare pointer
94
- }
95
-
96
- const fm = frontmatter(src);
97
- const parts = [];
98
- // Compact frontmatter header — the at-a-glance status, never the whole block.
99
- const statusLine = [
100
- fm.status ? `status: ${fm.status}` : null,
101
- fm.status_text ? `status_text: ${fm.status_text}` : null,
102
- ]
103
- .filter(Boolean)
104
- .join('\n');
105
- if (statusLine) parts.push(statusLine);
106
-
107
- for (const name of KEY_SECTIONS) {
108
- const body = section(src, name);
109
- if (body) parts.push(`## ${name}\n${body}`);
110
- }
111
-
112
- if (!parts.length) return null; // nothing useful to surface
113
-
114
- let body = parts.join('\n\n');
115
- if (body.length > PER_THREAD_CAP) {
116
- body = body.slice(0, PER_THREAD_CAP).replace(/\s+\S*$/, '') + `\n… [truncated — full thread at ${rel}]`;
117
- }
118
- return body;
119
- }
120
-
121
- /**
122
- * Render the combined "thread contents for the agent(s) that just finished" block for a
123
- * set of just-completed thread slugs — the orchestrator's verification surface. Dedupes
124
- * slugs, skips any that can't be excerpted, and caps the COMBINED size at TOTAL_CAP
125
- * (threads past the cap are listed by path only). Returns '' when nothing surfaces, so
126
- * the caller can append it unconditionally and degrade to the bare rest pointer.
127
- * @param {string} projectDir
128
- * @param {string[]} slugs
129
- * @returns {string}
130
- */
131
- export function threadExcerptsBlock(projectDir, slugs) {
132
- try {
133
- const seen = new Set();
134
- /** @type {string[]} */
135
- const blocks = [];
136
- /** @type {string[]} */
137
- const overflow = [];
138
- let used = 0;
139
- for (const slug of slugs || []) {
140
- if (!slug || seen.has(slug)) continue;
141
- seen.add(slug);
142
- const ex = threadExcerpt(projectDir, slug);
143
- const rel = `.frizz/${slug}.md`;
144
- if (!ex) continue; // unreadable/empty → silently skip (bare pointer still names the thread)
145
- const rendered = `--- ${rel} ---\n${ex}`;
146
- if (used + rendered.length > TOTAL_CAP && blocks.length) {
147
- overflow.push(rel); // already surfaced at least one; defer the rest to a path list
148
- continue;
149
- }
150
- blocks.push(rendered);
151
- used += rendered.length;
152
- }
153
- if (!blocks.length) return '';
154
- let out =
155
- '\n\nfrizz — thread contents for the agent(s) that just finished (the agent should have updated its thread before resting; square its reported results against what the thread now says):\n\n' +
156
- blocks.join('\n\n');
157
- if (overflow.length) out += `\n\n… also finished (read in full): ${overflow.join(', ')}`;
158
- return out;
159
- } catch {
160
- return ''; // fail-open — never break the Stop hook over an excerpt
161
- }
162
- }
@@ -1 +0,0 @@
1
- import"./chunk-KEIR6QF5-BfrZ3jm6.js";import{M as e}from"./mermaid-parser.core-BIyJ5CJF.js";export{e as createArchitectureServices};