frizz-server 0.15.49 → 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.
- package/dist/acp-daemon.js +39 -5
- package/dist/claude-agent-broker.js +55 -17
- package/dist/codex-app-server-daemon.js +43 -9
- package/dist/dev-child.js +7015 -3069
- package/package.json +15 -8
- package/runtime/board/agent-status.mjs +3 -3
- package/runtime/cc-worker/DECISIONS.md +19 -0
- package/runtime/cc-worker/bin/frizz-mcp.mjs +4 -2
- package/runtime/cc-worker/bin/frizzctl.mjs +26 -3
- package/runtime/cc-worker/hooks/deny-plan.mjs +4 -3
- package/runtime/cc-worker/hooks/hooks.json +18 -18
- package/runtime/cc-worker/hooks/scratchpad.mjs +10 -6
- package/runtime/cc-worker/lib/frizz-tools.mjs +156 -77
- package/web-dist/assets/{abnfDiagram-VRR7QNED-J7b3ICAw.js → abnfDiagram-VCTEODGH-CSl-iUaD.js} +1 -1
- package/web-dist/assets/{arc-D0znEGMI.js → arc-BSyeo0Gb.js} +1 -1
- package/web-dist/assets/architecture-7GRP2DOG-jYpGgJVJ.js +1 -0
- package/web-dist/assets/architectureDiagram-5GKGNRK7-Bo_gyMVC.js +36 -0
- package/web-dist/assets/blockDiagram-I7D4REHJ-9EtOS1Y1.js +129 -0
- package/web-dist/assets/c4Diagram-7LVT6UL2-CE1hW3oj.js +38 -0
- package/web-dist/assets/channel-CC-n29cI.js +1 -0
- package/web-dist/assets/chunk-2E4U76K2-QqOdoNOR.js +2 -0
- package/web-dist/assets/chunk-4HAMMTFA-Df2uLm9r.js +62 -0
- package/web-dist/assets/{chunk-ICXQ74PX-Cj1B4Mt1.js → chunk-75Z2AOVW-DF1G6d8q.js} +1 -1
- package/web-dist/assets/{chunk-VAUOI2AC-DYUbCOm7.js → chunk-CLGD4ZFX-CMAQm7EJ.js} +1 -1
- package/web-dist/assets/chunk-DU6HZSFF-UWY5hXXp.js +127 -0
- package/web-dist/assets/{chunk-32BRIVSS-DrQoYPLw.js → chunk-F27PBJKO-C59uYSbj.js} +1 -1
- package/web-dist/assets/{chunk-KEIR6QF5-BfrZ3jm6.js → chunk-FOHPRMQF-CyTuVbu3.js} +2 -2
- package/web-dist/assets/chunk-GMAD6QVW-BsJsQjY4.js +72 -0
- package/web-dist/assets/chunk-GVQU2GXP-BuITwr9r.js +1 -0
- package/web-dist/assets/{chunk-EX3LRPZG-CInw3Q3F.js → chunk-IMKFNOWR-5Ui4f5l4.js} +2 -2
- package/web-dist/assets/chunk-L3NEJ4N5-BISBblwX.js +1 -0
- package/web-dist/assets/chunk-LNGE3PJU-DNNNwF8Y.js +34 -0
- package/web-dist/assets/chunk-OSK3NFVY-CZl3XlkY.js +10 -0
- package/web-dist/assets/chunk-P2QGCYS3-DoytbW1J.js +1 -0
- package/web-dist/assets/{chunk-VR4S4FIN-WE1RlWzZ.js → chunk-POPQ4Y6H-D28hnSIy.js} +1 -1
- package/web-dist/assets/{chunk-HOUHSVGY-DozQYa90.js → chunk-PWAF6VOD-CbZvnkji.js} +1 -1
- package/web-dist/assets/chunk-SHT3W25Y-DM4ozJwj.js +168 -0
- package/web-dist/assets/{chunk-MOJQB5TN-dwysbljv.js → chunk-SVP7TREG-m6oapxSg.js} +1 -1
- package/web-dist/assets/{chunk-V7JOEXUC-PEaKX4p_.js → chunk-TICWLB2K-Ochfyos9.js} +1 -1
- package/web-dist/assets/chunk-TLUHSLCS-iM7uiuAo.js +2 -0
- package/web-dist/assets/{chunk-XXDRQBXY-CuNd86yu.js → chunk-XXDRQBXY-DYlTP5J-.js} +1 -1
- package/web-dist/assets/classDiagram-ZZMXUADV-CXJ9OBBD.js +1 -0
- package/web-dist/assets/classDiagram-v2-VYDZK3BY-CXJ9OBBD.js +1 -0
- package/web-dist/assets/cose-bilkent-JH36ORCC-BUIsLrGc.js +1 -0
- package/web-dist/assets/cynefin-OW5HDTMX-XtTYGcIH.js +1 -0
- package/web-dist/assets/{cynefinDiagram-TSTJHNR4-BlQjapzH.js → cynefinDiagram-5FMLGOSQ--ClxINOZ.js} +1 -1
- package/web-dist/assets/dagre-BJJUWK_n.js +1 -0
- package/web-dist/assets/dagre-GXQ25YYZ-CupZ_9Gq.js +4 -0
- package/web-dist/assets/{diagram-OA4YK3LP-CaTIfXcU.js → diagram-S7CK7UJ4-BlF7gkGi.js} +4 -4
- package/web-dist/assets/diagram-UQ7AKVKN-BMXRmU5D.js +41 -0
- package/web-dist/assets/{diagram-FQU43EPY-BOlJtvyz.js → diagram-VSXAHHWV-r5DJsSB3.js} +1 -1
- package/web-dist/assets/{diagram-G47NLZAW-DPbXRY-S.js → diagram-VX7I27RA-DxGq7Ln7.js} +1 -1
- package/web-dist/assets/{diagram-NH7WQ7WH-B1Nl4A7D.js → diagram-Z3DM3KII-DqXtb_id.js} +1 -1
- package/web-dist/assets/dist-DoH_9pyS.js +1 -0
- package/web-dist/assets/{ebnfDiagram-CCIWWBDH-BIW4rAiN.js → ebnfDiagram-PWID7BFC-BV_AT7TD.js} +1 -1
- package/web-dist/assets/erDiagram-RLTQ6QDP-BV70EqG9.js +99 -0
- package/web-dist/assets/eventmodeling-NTZA5JFV-Cw8GwV1a.js +1 -0
- package/web-dist/assets/flowDiagram-HODETNUW-B0Q6ZSg0.js +1 -0
- package/web-dist/assets/ganttDiagram-EL5Y4UJY-Cvkf14ib.js +292 -0
- package/web-dist/assets/gitGraph-4MIJSDKK-XBlZCz1U.js +1 -0
- package/web-dist/assets/{gitGraphDiagram-IHSO6WYX-CpPGTKWr.js → gitGraphDiagram-WWUBYQGX-vDyL82tj.js} +1 -1
- package/web-dist/assets/index-D-pcMA7P.js +242 -0
- package/web-dist/assets/index-DqckQXcp.css +2 -0
- package/web-dist/assets/info-A6RAGUB7-DfR7iRgc.js +1 -0
- package/web-dist/assets/{infoDiagram-FWYZ7A6U-DUZecEP8.js → infoDiagram-27XIBGKW-BT4k6N6o.js} +1 -1
- package/web-dist/assets/{ishikawaDiagram-FXEZZL3T-XAAQSfxB.js → ishikawaDiagram-5VMMS53U-BJIdMG0T.js} +1 -1
- package/web-dist/assets/{journeyDiagram-5HDEW3XC-BzWg86Rn.js → journeyDiagram-3NMN7TZE-CUGzIF61.js} +2 -2
- package/web-dist/assets/{kanban-definition-HUTT4EX6-B_OPyRDu.js → kanban-definition-UXKFOSKX-DIPC4kv7.js} +2 -2
- package/web-dist/assets/{line-MIBXaWt1.js → line-CJKCWj73.js} +1 -1
- package/web-dist/assets/{linear-uglE5t1T.js → linear-z2V0wJk9.js} +1 -1
- package/web-dist/assets/{mermaid-parser.core-J0F3kyQU.js → mermaid-parser.core-BH-fcjsB.js} +3 -3
- package/web-dist/assets/mermaid.core-BSdNmJCs.js +11 -0
- package/web-dist/assets/{mindmap-definition-LN4V7U3C-C6t1sDuH.js → mindmap-definition-YA3MSWOX-CJC3zMDF.js} +1 -1
- package/web-dist/assets/packet-AYTQ26CC-BET157L_.js +1 -0
- package/web-dist/assets/{pegDiagram-2B236MQR-DUx_k0xu.js → pegDiagram-XKGWAZYB-Du8ALEoR.js} +1 -1
- package/web-dist/assets/pie-WAS4IAKB-CDs5cIGi.js +1 -0
- package/web-dist/assets/{pieDiagram-ENE6RG2P-44mApnR1.js → pieDiagram-E7YTZNPT-BX88bIIM.js} +1 -1
- package/web-dist/assets/{quadrantDiagram-ABIIQ3AL-Bt2Yzr6E.js → quadrantDiagram-AXDQQJYC-BkGxldmI.js} +1 -1
- package/web-dist/assets/radar-RG4KPBEZ-FMcFyhAF.js +1 -0
- package/web-dist/assets/railroad-74A4TZTK-Du0SbLQI.js +1 -0
- package/web-dist/assets/railroad-abnf-HS5TGJTU-DRi4RhLb.js +1 -0
- package/web-dist/assets/railroad-ebnf-LZEXJU2U-BmBkdsnK.js +1 -0
- package/web-dist/assets/railroad-peg-WCYAUIDC-CydTrmQm.js +1 -0
- package/web-dist/assets/{railroadDiagram-RFXS5EU6-d8BSz3zX.js → railroadDiagram-O6MQD6OU-CYqN0dL6.js} +1 -1
- package/web-dist/assets/{requirementDiagram-TGXJPOKE-DNAaYt1Y.js → requirementDiagram-BXWQKSXE-ClpQ_sLR.js} +2 -2
- package/web-dist/assets/rolldown-runtime-Bh1tDfsg.js +1 -0
- package/web-dist/assets/{sankeyDiagram-HTMAVEWB-R_lnknB4.js → sankeyDiagram-P5KCCOFB-CEJUF8o9.js} +1 -1
- package/web-dist/assets/{sequenceDiagram-DBY2YBRQ-Ba-X-mCo.js → sequenceDiagram-WJ2MYXX4-BpJYUJhB.js} +1 -1
- package/web-dist/assets/src-C4XfhTaE.js +1 -0
- package/web-dist/assets/{stateDiagram-2N3HPSRC-C51RHuJf.js → stateDiagram-D77RDMKH-BmKLEj9Q.js} +1 -1
- package/web-dist/assets/stateDiagram-v2-MP3YSRHH-D_c6vvvW.js +1 -0
- package/web-dist/assets/swimlanes-42K2YHIH-CyJxVets.js +1 -0
- package/web-dist/assets/swimlanesDiagram-VR7AAH4N-BcVx8rdP.js +8 -0
- package/web-dist/assets/threadSurfaces-CYpFDk_e.js +143 -0
- package/web-dist/assets/{timeline-definition-FHXFAJF6-DnfNzZjg.js → timeline-definition-24CTP7MA-ChEqw_62.js} +1 -1
- package/web-dist/assets/treeView-Q6P3EWNA-l1PaAwLT.js +1 -0
- package/web-dist/assets/treemap-WGGIJYW6-CxvHcEiT.js +1 -0
- package/web-dist/assets/{vennDiagram-L72KCM5P-b9DhO8LT.js → vennDiagram-4TSXK5OY-DF-yXPNP.js} +1 -1
- package/web-dist/assets/wardley-WFR3VGLG-BqkX6NQy.js +1 -0
- package/web-dist/assets/{wardleyDiagram-EHGQE667-cCbiyTUT.js → wardleyDiagram-VM6X3IG4-B9LU1bxh.js} +1 -1
- package/web-dist/assets/{xychartDiagram-FW5EYKEG-BO5JrKdd.js → xychartDiagram-S5SC5T6Z-Zt_ZqCWS.js} +3 -3
- package/web-dist/index.html +3 -2
- package/runtime/board/agent-liveness.mjs +0 -367
- package/runtime/board/notify-shared.mjs +0 -90
- package/runtime/board/notify.mjs +0 -81
- package/runtime/board/rest-detect.mjs +0 -213
- package/runtime/board/thread-excerpt.mjs +0 -162
- package/web-dist/assets/architecture-TIHT7OUA-BZjpcwN0.js +0 -1
- package/web-dist/assets/architectureDiagram-ZJ3FMSHR-BLoL7eps.js +0 -36
- package/web-dist/assets/blockDiagram-677ZJIJ3-BOiZIgfH.js +0 -132
- package/web-dist/assets/c4Diagram-LMCZKHZV-DaL-micl.js +0 -10
- package/web-dist/assets/channel-BOY_EM0_.js +0 -1
- package/web-dist/assets/chunk-52WLFC77-Bl9DYslI.js +0 -10
- package/web-dist/assets/chunk-7BUUIJ7U-Bb538aSH.js +0 -1
- package/web-dist/assets/chunk-C7G6YPKG-C8ZxUisf.js +0 -1
- package/web-dist/assets/chunk-FWX5IMBZ-Bb3cN9tF.js +0 -2
- package/web-dist/assets/chunk-OGEWGWER-BIXFK2Kz.js +0 -1
- package/web-dist/assets/chunk-PUDLZKDR-zTbgLDMj.js +0 -156
- package/web-dist/assets/chunk-Q4XR5HBZ-BPeZU3L1.js +0 -70
- package/web-dist/assets/chunk-RYQCIY6F-B2AmSBtU.js +0 -1
- package/web-dist/assets/chunk-WYO6CB5R-Cptxef_j.js +0 -127
- package/web-dist/assets/chunk-ZGVPDNZ5-nKibxQuS.js +0 -62
- package/web-dist/assets/chunk-ZIRB5QZD-C6fEPe3t.js +0 -32
- package/web-dist/assets/classDiagram-OUVF2IWQ-rW3mcevY.js +0 -1
- package/web-dist/assets/classDiagram-v2-EOCWNBFH-rW3mcevY.js +0 -1
- package/web-dist/assets/cose-bilkent-JH36ORCC-BHapvkAQ.js +0 -1
- package/web-dist/assets/cynefin-VYW2F7L2-BefSX6Er.js +0 -1
- package/web-dist/assets/dagre-CXRCoUWR.js +0 -1
- package/web-dist/assets/dagre-VKFMJZFB-BnFClfBQ.js +0 -4
- package/web-dist/assets/diagram-WEI45ONY-CcXbcxic.js +0 -41
- package/web-dist/assets/dist-Bsb4JJAO.js +0 -1
- package/web-dist/assets/erDiagram-Q63AITRT-BpObPW4X.js +0 -85
- package/web-dist/assets/eventmodeling-45OFAUF4-BBdu_FMe.js +0 -1
- package/web-dist/assets/flowDiagram-23GEKE2U-JCnBd218.js +0 -1
- package/web-dist/assets/ganttDiagram-NO4QXBWP-D6POggnD.js +0 -292
- package/web-dist/assets/gitGraph-TEB2WS4Q-YCEfMCFc.js +0 -1
- package/web-dist/assets/index-CFXWSXTQ.css +0 -2
- package/web-dist/assets/index-CjwFZh5G.js +0 -380
- package/web-dist/assets/info-DKCQHKI2-SyitzjWc.js +0 -1
- package/web-dist/assets/map-DsCK-0Cs.js +0 -1
- package/web-dist/assets/mermaid.core-CJriGaX1.js +0 -11
- package/web-dist/assets/packet-7NZHBO7P-BP5kC3mk.js +0 -1
- package/web-dist/assets/pie-RZYD4A2V-ehviwJKF.js +0 -1
- package/web-dist/assets/radar-I7S5WNFK-DW4R66e1.js +0 -1
- package/web-dist/assets/railroad-3IZDKUUU-D08S7ovl.js +0 -1
- package/web-dist/assets/railroad-abnf-AHOZXSZD-C9qettXj.js +0 -1
- package/web-dist/assets/railroad-ebnf-EBAXGLYW-DJWltGwI.js +0 -1
- package/web-dist/assets/railroad-peg-LSFZ7HO6-tqNP6Nvp.js +0 -1
- package/web-dist/assets/src-_ShgCKEo.js +0 -1
- package/web-dist/assets/stateDiagram-v2-6OUMAXLB-BdAiMi1e.js +0 -1
- package/web-dist/assets/swimlanes-5IMT3BWC-6s8xokkg.js +0 -2
- package/web-dist/assets/swimlanesDiagram-G3AALYLV-CXOHMq1K.js +0 -8
- package/web-dist/assets/treeView-QDETBFTQ-vUI6BtZi.js +0 -1
- package/web-dist/assets/treemap-6X3UGDF4-DXAQ9FfS.js +0 -1
- package/web-dist/assets/wardley-OPB4EBWU-DcnZYvgN.js +0 -1
- /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-J0F3kyQU.js";export{e as createArchitectureServices};
|