@iowarp/clio-coder 0.4.7 → 0.4.9
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/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +111 -0
- package/CONTRIBUTING.md +83 -74
- package/README.md +69 -47
- package/dist/{acp-W3Y3TRHD.js → acp-ZWZCPS2A.js} +15 -15
- package/dist/{agents-J4ICNLQ3.js → agents-LYSOWZUE.js} +61 -59
- package/dist/assets/codewiki.json +1 -1
- package/dist/assets/web-notices/@hono__node-server-LICENSE +21 -0
- package/dist/assets/web-notices/hono-LICENSE +21 -0
- package/dist/{auth-X2UJUMOC.js → auth-WBQGKWQ5.js} +27 -27
- package/dist/background-BUMOBAQN.js +37 -0
- package/dist/{builtins-XLXWWSRF.js → builtins-ODRJOEDI.js} +7 -7
- package/dist/{chunk-C3G5PNUO.js → chunk-2DRRZ57Q.js} +36 -27
- package/dist/chunk-2JBZYUPY.js +105 -0
- package/dist/chunk-2KUBKL63.js +336 -0
- package/dist/chunk-2VBWFXYE.js +198 -0
- package/dist/{chunk-XZ6UFQ52.js → chunk-2X2R3UTH.js} +25 -15
- package/dist/{chunk-M6Z2V6YU.js → chunk-37LW32LZ.js} +5 -5
- package/dist/{chunk-6LRLOJHQ.js → chunk-3AND2EFU.js} +11 -62
- package/dist/{chunk-FQOOGXBH.js → chunk-3RDHGNU7.js} +101 -33
- package/dist/{chunk-D2T66PDV.js → chunk-3SUDBGEI.js} +41 -208
- package/dist/{chunk-5AJPUR72.js → chunk-3TQN67I2.js} +9 -9
- package/dist/{chunk-LBFQMYS3.js → chunk-3U4BL2EV.js} +5 -3
- package/dist/{chunk-UFYNOQK4.js → chunk-3UQADNG2.js} +7 -7
- package/dist/{chunk-V4ZKOKRB.js → chunk-434LRQ6Z.js} +61 -53
- package/dist/{chunk-NO7J45X6.js → chunk-4ATBOFRP.js} +713 -218
- package/dist/{chunk-ECOMVOHP.js → chunk-4DNL43EZ.js} +3 -3
- package/dist/{chunk-WT5TRMO4.js → chunk-4HFJKRGZ.js} +255 -82
- package/dist/{chunk-5A6XR3RJ.js → chunk-555E2WVV.js} +16 -2
- package/dist/{chunk-WURGVOZJ.js → chunk-5RTEFNBP.js} +18 -14
- package/dist/{config-YXARKGTX.js → chunk-64XJW7NT.js} +24 -268
- package/dist/{chunk-24S3DN22.js → chunk-6TKOFFGE.js} +4 -4
- package/dist/{chunk-YKRJTYNP.js → chunk-6UJ7RDI7.js} +4 -4
- package/dist/{chunk-MZNWZUJM.js → chunk-7FBCRWVT.js} +288 -288
- package/dist/{chunk-UA6W4XFJ.js → chunk-7JSOSVLP.js} +2 -2
- package/dist/chunk-7N3OLLSL.js +637 -0
- package/dist/{chunk-KKEYGFX4.js → chunk-7QQRPB2E.js} +11 -11
- package/dist/{chunk-N37QC5FV.js → chunk-A6DULIMH.js} +21 -9
- package/dist/{fleet-decisions-S3PTZV2D.js → chunk-AB3QXXBC.js} +5 -41
- package/dist/chunk-ACCECAH4.js +49 -0
- package/dist/{chunk-CP3HIR5H.js → chunk-AM6CEP2K.js} +20 -19
- package/dist/chunk-AUHVBIDW.js +19 -0
- package/dist/{chunk-BQQ5MXUC.js → chunk-AY4XE6GN.js} +19 -13
- package/dist/{chunk-ISNCCX42.js → chunk-BBA2TAWV.js} +10 -9
- package/dist/chunk-BFPHMSK7.js +169 -0
- package/dist/{chunk-LVFANMOH.js → chunk-BHJMMCXS.js} +4 -4
- package/dist/{chunk-DO7M3LSX.js → chunk-BMNVVKEW.js} +40 -93
- package/dist/{chunk-VTYHHQ57.js → chunk-CTGZCEI6.js} +2 -2
- package/dist/{chunk-RTLNFZMD.js → chunk-DIAJYJYG.js} +3 -3
- package/dist/chunk-EHZRAB4U.js +63 -0
- package/dist/{chunk-KS7ETA3P.js → chunk-EM2DIQAJ.js} +3 -3
- package/dist/{chunk-MNQN3X6Y.js → chunk-ETF4ROKH.js} +5 -5
- package/dist/{chunk-WN552PKN.js → chunk-F2YM3JY4.js} +744 -1134
- package/dist/{chunk-7EEGBKV4.js → chunk-FEBQWHJT.js} +24 -19
- package/dist/{chunk-4QKAITQT.js → chunk-FPS4R2RN.js} +74 -10
- package/dist/chunk-G5R53COU.js +68 -0
- package/dist/chunk-GHXGMFQ5.js +40 -0
- package/dist/{chunk-GFQ7P2UF.js → chunk-GJDRMBDI.js} +10 -10
- package/dist/{chunk-LZBMXNLP.js → chunk-GM4TY6VN.js} +43 -6
- package/dist/{chunk-NCCQ6DVS.js → chunk-GREYLTZ5.js} +8 -8
- package/dist/{chunk-HOX4YZ2K.js → chunk-H2WSCZZT.js} +19 -3
- package/dist/{chunk-3LXJOICS.js → chunk-H6IUCY6Q.js} +2 -2
- package/dist/{chunk-BO4XV5VX.js → chunk-H72DCH3E.js} +95 -206
- package/dist/{chunk-SEDI5K5B.js → chunk-H7TXJR23.js} +20 -20
- package/dist/chunk-HBJQQTKM.js +40 -0
- package/dist/chunk-HCVKSGNZ.js +990 -0
- package/dist/chunk-HVCAY2FH.js +67 -0
- package/dist/{chunk-34XHRVKG.js → chunk-I47EJPYL.js} +3 -3
- package/dist/{chunk-4N2RZ4TO.js → chunk-IALGWTLO.js} +3 -3
- package/dist/{chunk-IQCNVLO6.js → chunk-IALZJE37.js} +10 -7
- package/dist/{chunk-DLIYANB7.js → chunk-IC7JXLOM.js} +16 -11
- package/dist/{chunk-G4LGUTOE.js → chunk-IOSVTTCD.js} +5 -5
- package/dist/{chunk-DBREN25X.js → chunk-IPTPMLA6.js} +8 -3
- package/dist/{chunk-V552WL53.js → chunk-IZZI3SKQ.js} +3 -67
- package/dist/{chunk-TN5FW4XY.js → chunk-JIYWMQZ5.js} +12 -9
- package/dist/{chunk-T7QQBNLH.js → chunk-JKU34ACI.js} +10 -8
- package/dist/chunk-JOBN2YQQ.js +176 -0
- package/dist/chunk-JOL2QRLE.js +152 -0
- package/dist/{chunk-GXIWHXDB.js → chunk-JTR3VSV3.js} +3 -3
- package/dist/{chunk-T334FW2H.js → chunk-JU6MAMRJ.js} +7 -7
- package/dist/chunk-JURMQWVJ.js +15 -0
- package/dist/{chunk-CULVKYTK.js → chunk-K3XN4LZ4.js} +5 -5
- package/dist/{chunk-3T4DXWP6.js → chunk-KIVFXGBM.js} +27 -7
- package/dist/chunk-KKRXONXG.js +43 -0
- package/dist/{chunk-YPRSNUTC.js → chunk-KOAHT3N2.js} +2 -2
- package/dist/chunk-KP5BPXR3.js +73 -0
- package/dist/{chunk-UA3W4FGC.js → chunk-KRJQG47M.js} +6 -6
- package/dist/{chunk-GI5RRMAH.js → chunk-KW6OJ7IY.js} +19 -21
- package/dist/{chunk-A46ILRS2.js → chunk-L3NBWLSN.js} +4 -4
- package/dist/{chunk-MZHXENL7.js → chunk-L4RUTLRL.js} +8 -8
- package/dist/{chunk-P5SC4DLJ.js → chunk-LGTVWPRN.js} +2 -2
- package/dist/{chunk-65BGHOUR.js → chunk-LSQW6KZO.js} +5 -5
- package/dist/{chunk-TZHN5ITX.js → chunk-LWJYOHT3.js} +8 -8
- package/dist/{chunk-U3TPUXOQ.js → chunk-M6YLF66Z.js} +74 -40
- package/dist/chunk-MJ4QEJVT.js +185 -0
- package/dist/{chunk-T4TY5GG3.js → chunk-MO65K5CH.js} +5 -5
- package/dist/{chunk-TZ6UVP2H.js → chunk-MTOZEQHL.js} +8 -8
- package/dist/chunk-MZDPF35R.js +45 -0
- package/dist/{chunk-P4DL2LM5.js → chunk-MZKYVIWW.js} +8 -119
- package/dist/{chunk-KAFMW7WM.js → chunk-NBPA5QM6.js} +2 -2
- package/dist/{chunk-EUEXGXXR.js → chunk-NMBEW4PP.js} +5 -5
- package/dist/{chunk-SELG4SUR.js → chunk-NPLLK3HO.js} +72 -89
- package/dist/{chunk-VCRVEDUC.js → chunk-NSYGPIVW.js} +5 -5
- package/dist/{context-7HJEWTTP.js → chunk-NXTV5OI5.js} +36 -90
- package/dist/{chunk-IMOD2YPV.js → chunk-NYDG4QP4.js} +9 -19
- package/dist/{chunk-6CA2BHOR.js → chunk-OA2GDACN.js} +5 -5
- package/dist/{chunk-A67NR5AT.js → chunk-PJI57EC6.js} +14 -11
- package/dist/{chunk-IJMW64DX.js → chunk-PJJBUGMR.js} +50 -50
- package/dist/{chunk-CPXGJI2A.js → chunk-PNJE7JPS.js} +20 -5
- package/dist/chunk-PP23PZEV.js +1347 -0
- package/dist/chunk-PPIFDSBK.js +409 -0
- package/dist/{chunk-T52TPHYC.js → chunk-PTFISXQO.js} +8 -7
- package/dist/{chunk-C6GEXX4L.js → chunk-QB33Z5S7.js} +5 -5
- package/dist/{chunk-VMATUZB6.js → chunk-QGNII5VC.js} +10 -10
- package/dist/{chunk-TLTGZTXI.js → chunk-QI72X67S.js} +104 -27
- package/dist/chunk-QKHZZFKH.js +98 -0
- package/dist/{chunk-PFLOULP3.js → chunk-RDKX2PME.js} +4 -4
- package/dist/{chunk-B5ZTR6KZ.js → chunk-RL7LJYN4.js} +1 -1
- package/dist/chunk-RPMNIFRY.js +65 -0
- package/dist/{chunk-L3Z5ANCV.js → chunk-RQROVOV3.js} +13 -11
- package/dist/{chunk-6YHPAAZR.js → chunk-S34A7BSP.js} +3 -3
- package/dist/{chunk-5ZSZEYJK.js → chunk-SJETVJHX.js} +2 -2
- package/dist/{chunk-77CZRFTE.js → chunk-SJMNU4ZS.js} +2 -2
- package/dist/chunk-SLLG2G44.js +85 -0
- package/dist/{chunk-GVZFCJHE.js → chunk-SQAZN2V3.js} +48 -22
- package/dist/{chunk-2O2LVQQK.js → chunk-SQBT46OF.js} +2 -2
- package/dist/{chunk-ZGIGW4ZG.js → chunk-TCUOGIL2.js} +5 -5
- package/dist/{chunk-DACXIVVF.js → chunk-TIWPKCVO.js} +5 -5
- package/dist/{chunk-5CMARGPF.js → chunk-UIU7MGZ3.js} +11 -2
- package/dist/chunk-USBBEKHW.js +177 -0
- package/dist/{chunk-WLHX3MM5.js → chunk-V4XJWDHR.js} +21 -11
- package/dist/{chunk-MBJO5VNZ.js → chunk-VPWGADBG.js} +33 -33
- package/dist/{chunk-UUQ5G6EZ.js → chunk-VWFCAK34.js} +6 -6
- package/dist/{chunk-6CB2IL4N.js → chunk-W5RM7YAH.js} +1 -1
- package/dist/{chunk-4MFBBY2Z.js → chunk-W72LLZAV.js} +3 -3
- package/dist/{chunk-4UHVS5T7.js → chunk-WGRDABW7.js} +8 -8
- package/dist/{chunk-XR3XJN2M.js → chunk-WWRV5RJI.js} +4 -4
- package/dist/{chunk-24TOGHPO.js → chunk-X6FLVUM5.js} +4 -4
- package/dist/{chunk-6YA46L5A.js → chunk-XFLSL7BT.js} +2 -2
- package/dist/{chunk-QKWL7SYE.js → chunk-XJZEDCNT.js} +50 -39
- package/dist/{chunk-UWD3JD5X.js → chunk-XLLEL3K7.js} +10 -10
- package/dist/{chunk-2GPGAE5W.js → chunk-XNIZBOFV.js} +15 -1
- package/dist/chunk-XNZWWDC3.js +686 -0
- package/dist/{chunk-WBVKKTUT.js → chunk-XRECG65F.js} +2 -2
- package/dist/chunk-XTQ7MEJG.js +457 -0
- package/dist/{chunk-GEVQNST4.js → chunk-XZWSP67B.js} +2 -2
- package/dist/{chunk-WB7POC6M.js → chunk-Y3M2T5RO.js} +6 -6
- package/dist/{chunk-RXFPB32E.js → chunk-YJCCMYYT.js} +2 -2
- package/dist/{chunk-EUZRMP4Y.js → chunk-YPQOPFP7.js} +20 -20
- package/dist/{chunk-USZA7GWL.js → chunk-YQ3GFEUY.js} +2 -2
- package/dist/{chunk-BAU36233.js → chunk-YQYINEJI.js} +9 -9
- package/dist/{chunk-CE64C5K5.js → chunk-ZF6CV4WZ.js} +1356 -235
- package/dist/{chunk-3XE4NRLF.js → chunk-ZKJU55MX.js} +4 -2
- package/dist/{chunk-IZYTT3CD.js → chunk-ZKQ63XZ5.js} +16 -39
- package/dist/{chunk-6TAATXXH.js → chunk-ZKVMDNAN.js} +7 -7
- package/dist/chunk-ZST3FRCV.js +132 -0
- package/dist/cli/index.js +50 -38
- package/dist/{clio-L2P7S2R2.js → clio-JUDCLNHC.js} +11 -11
- package/dist/clio-context-tools-FT672MNZ.js +136 -0
- package/dist/{code-nav-B5LNX4KU.js → code-nav-7OVCTP2Z.js} +39 -37
- package/dist/{components-63MMQKUT.js → components-OZXZMDWU.js} +11 -11
- package/dist/config-P3ZQVF63.js +275 -0
- package/dist/config-graph-GKAOBAS5.js +160 -0
- package/dist/{configure-LMVQJ46J.js → configure-25LRYZJG.js} +56 -55
- package/dist/context-72VQV7JX.js +73 -0
- package/dist/{context-YG2LZDYZ.js → context-COWRWXP3.js} +89 -83
- package/dist/{context-XSZKKFBW.js → context-WB3D474G.js} +16 -16
- package/dist/{context-clear-AC5NXHM2.js → context-clear-Y4LYMWC6.js} +88 -82
- package/dist/{context-index-KKTPRV5G.js → context-index-W6A4V7OC.js} +4 -4
- package/dist/{context-map-T7ROR5D5.js → context-map-DKL3QT6D.js} +3 -3
- package/dist/{context-working-set-F4Q4J3NS.js → context-working-set-TMZYVC7A.js} +27 -25
- package/dist/data-tool-KMBWKKWR.js +2987 -0
- package/dist/{detail-H73BEF2N.js → detail-4GLROGY5.js} +89 -83
- package/dist/{dispatch-runner-3RY5FSJC.js → dispatch-runner-TR3LBP5P.js} +113 -107
- package/dist/docs-ZK777W2G.js +101 -0
- package/dist/{doctor-EQYJOGUG.js → doctor-WC4OV2OB.js} +76 -73
- package/dist/{eval-4P7O6CCE.js → eval-FUNWJNUJ.js} +88 -73
- package/dist/{eval-inventory-QOYZERXJ.js → eval-inventory-CX24K2JT.js} +5 -60
- package/dist/evals-L73EBHSU.js +104 -0
- package/dist/{evidence-O76QF7TZ.js → evidence-AVJ2RTHX.js} +99 -93
- package/dist/{evidence-D6GUSYJW.js → evidence-P4NZOAK7.js} +88 -82
- package/dist/evidence-Y55WKYHH.js +246 -0
- package/dist/{evolve-H47BCETS.js → evolve-MAWKRYWF.js} +93 -87
- package/dist/{extensions-NNL3ZOCU.js → extensions-PYQH3H47.js} +14 -13
- package/dist/fleet-M4H2QBWT.js +268 -0
- package/dist/{fleet-KMNS6NOM.js → fleet-ULBXXRDR.js} +146 -138
- package/dist/{fleet-commands-DOWSYCBX.js → fleet-commands-7NNC4JZU.js} +18 -17
- package/dist/fleet-decisions-EHEY7KPU.js +52 -0
- package/dist/{fleet-graph-F2DE2TME.js → fleet-graph-LQ2AHZT3.js} +24 -24
- package/dist/{fleet-inspect-EN2Q6IVB.js → fleet-inspect-5IGBIIYZ.js} +98 -258
- package/dist/{fleet-preflight-FRLETDD3.js → fleet-preflight-UTTNOKMG.js} +9 -4
- package/dist/{fleet-validate-B2XDLS57.js → fleet-validate-YGILJKA6.js} +29 -29
- package/dist/{fleet-verify-4JKUWGJ7.js → fleet-verify-AUWTCDKR.js} +88 -82
- package/dist/{fleet-view-BHJFW26B.js → fleet-view-TGUFCY5A.js} +90 -84
- package/dist/{init-XAT5N5YM.js → init-GFN2Z7NF.js} +111 -104
- package/dist/install-6PIF6F6W.js +19 -0
- package/dist/{interop-FVECHFKG.js → interop-EF5JUWWK.js} +29 -29
- package/dist/{inventory-7KFQGLCV.js → inventory-I6VJDDYF.js} +90 -84
- package/dist/library-3J5IO2OJ.js +75 -0
- package/dist/{library-QAPAO23R.js → library-IJTOFTDS.js} +20 -19
- package/dist/{library-NY2XOT75.js → library-Z3KZSHPE.js} +35 -35
- package/dist/{library-import-5Y6MAS3R.js → library-import-IMKFLDHX.js} +29 -29
- package/dist/{library-inventory-JT6HWITQ.js → library-inventory-CQP5D6GU.js} +21 -21
- package/dist/{library-validation-EQUH25DC.js → library-validation-33UTX7AI.js} +19 -19
- package/dist/mcp-5FWZKUS6.js +26 -0
- package/dist/{memory-DYVTTCP6.js → memory-36CWN67Y.js} +93 -87
- package/dist/{models-MASFJ6Y2.js → models-KQ6PQJJQ.js} +57 -56
- package/dist/{monitor-YMP4NXJJ.js → monitor-XX6ZD6KC.js} +98 -91
- package/dist/{orchestrator-AFQRRTEI.js → orchestrator-SK6HDAOP.js} +1537 -832
- package/dist/{panes-NICTHQCV.js → panes-L27QRXUH.js} +14 -14
- package/dist/{panes-D3Y2KFG5.js → panes-LXZIWNOZ.js} +4 -4
- package/dist/{paths-PSFAUIGO.js → paths-7DJDU4P4.js} +6 -6
- package/dist/{preload-5Q7VXRFJ.js → preload-K2TDYI4Y.js} +88 -82
- package/dist/{reset-7NKZK7JN.js → reset-73VU3XNT.js} +13 -13
- package/dist/{resources-NILSIZAT.js → resources-3BYJYVYL.js} +24 -24
- package/dist/{run-BPZGEBZV.js → run-AR7PY6GW.js} +144 -136
- package/dist/run-script-H2KUDIII.js +41 -0
- package/dist/settings-3VMBMWID.js +72 -0
- package/dist/{share-EZ6ERBMH.js → share-HVWH4FPF.js} +30 -30
- package/dist/{skills-BTVVNYVM.js → skills-5TYEY75Q.js} +30 -30
- package/dist/{skills-eval-UY34MNK7.js → skills-eval-CK3MD63Z.js} +114 -103
- package/dist/{skills-inventory-JDHSIA7I.js → skills-inventory-KSFYG3I6.js} +24 -24
- package/dist/{slash-commands-K4FNQ2AT.js → slash-commands-DMVHML7P.js} +60 -57
- package/dist/{steer-2B3EQGFH.js → steer-XCD6V3EW.js} +4 -4
- package/dist/{support-L2SOL3IE.js → support-JAZL6VBR.js} +7 -7
- package/dist/system-3TDQRMZZ.js +116 -0
- package/dist/{targets-44VKGFLN.js → targets-EZKHAYRN.js} +74 -72
- package/dist/{tasks-3KODKFU7.js → tasks-SNEFHWYW.js} +18 -18
- package/dist/{terminal-lease-LXA7MMPO.js → terminal-lease-BNLFA4OF.js} +8 -7
- package/dist/{tools-3UB7TEVR.js → tools-7IM6BDCE.js} +12 -12
- package/dist/{trace-TAMIU4OJ.js → trace-C3MBGD4S.js} +16 -65
- package/dist/{tui-primitives-A6MUW32V.js → tui-primitives-36BY2774.js} +2 -2
- package/dist/{uninstall-QYVRPEM4.js → uninstall-WWLOSZ42.js} +35 -10
- package/dist/{upgrade-7PMKM2JH.js → upgrade-ETK2JNSJ.js} +42 -51
- package/dist/{usage-6EQV7EQK.js → usage-S2HOB7BZ.js} +112 -102
- package/dist/{verifiers-JLITWSHU.js → verifiers-QDTEVH7R.js} +26 -24
- package/dist/{verify-T7NAEVIG.js → verify-SUKUK6XM.js} +16 -15
- package/dist/web/client/THIRD_PARTY_LICENSES.md +1809 -0
- package/dist/web/client/assets/abnfDiagram-VCTEODGH-BznNOe_I.js +1 -0
- package/dist/web/client/assets/arc-Pry-7G1_.js +1 -0
- package/dist/web/client/assets/architecture-7GRP2DOG-BQO9DL_y.js +1 -0
- package/dist/web/client/assets/architectureDiagram-5GKGNRK7-CKPbdvyx.js +36 -0
- package/dist/web/client/assets/array-BifhSqXX.js +1 -0
- package/dist/web/client/assets/atkinson-hyperlegible-next-latin-ext-wght-normal-C6vrW8VD.woff2 +0 -0
- package/dist/web/client/assets/atkinson-hyperlegible-next-latin-wght-normal-BcXVPD7q.woff2 +0 -0
- package/dist/web/client/assets/blockDiagram-I7D4REHJ-prINbpbM.js +129 -0
- package/dist/web/client/assets/c4Diagram-7LVT6UL2-DkVRKtyU.js +38 -0
- package/dist/web/client/assets/channel-c4EeUUqA.js +1 -0
- package/dist/web/client/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
- package/dist/web/client/assets/chunk-4HAMMTFA-CV0Z1ApC.js +62 -0
- package/dist/web/client/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
- package/dist/web/client/assets/chunk-75Z2AOVW-D34Nohxq.js +2 -0
- package/dist/web/client/assets/chunk-DU6HZSFF-Das_cS-O.js +125 -0
- package/dist/web/client/assets/chunk-F27PBJKO-CmRojxkG.js +1 -0
- package/dist/web/client/assets/chunk-FOHPRMQF-CoA4358r.js +161 -0
- package/dist/web/client/assets/chunk-GMAD6QVW-ClYZmc73.js +72 -0
- package/dist/web/client/assets/chunk-GVQU2GXP-B2BiHFt-.js +1 -0
- package/dist/web/client/assets/chunk-IMKFNOWR-BGApZ8nP.js +231 -0
- package/dist/web/client/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
- package/dist/web/client/assets/chunk-L3NEJ4N5-DIzCgpkY.js +1 -0
- package/dist/web/client/assets/chunk-OSK3NFVY-BPT-yePv.js +10 -0
- package/dist/web/client/assets/chunk-P2QGCYS3-BC1WTc2t.js +1 -0
- package/dist/web/client/assets/chunk-POPQ4Y6H-BSjzBmZU.js +1 -0
- package/dist/web/client/assets/chunk-PWAF6VOD-BIjLs86Z.js +1 -0
- package/dist/web/client/assets/chunk-SHT3W25Y-CduDz2cm.js +168 -0
- package/dist/web/client/assets/chunk-SVP7TREG-XUn4pPAP.js +88 -0
- package/dist/web/client/assets/chunk-TICWLB2K-DcBy2DKy.js +206 -0
- package/dist/web/client/assets/chunk-XXDRQBXY-DqAYeljN.js +1 -0
- package/dist/web/client/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
- package/dist/web/client/assets/classDiagram-ZZMXUADV-C0HR7YKN.js +1 -0
- package/dist/web/client/assets/classDiagram-v2-VYDZK3BY-C0HR7YKN.js +1 -0
- package/dist/web/client/assets/commit-mono-latin-400-normal-s0S3qwFW.woff +0 -0
- package/dist/web/client/assets/commit-mono-latin-400-normal-wzhe4RuD.woff2 +0 -0
- package/dist/web/client/assets/cose-bilkent-JH36ORCC-CVh1icwb.js +1 -0
- package/dist/web/client/assets/cynefin-OW5HDTMX-BecPbyM6.js +1 -0
- package/dist/web/client/assets/cynefinDiagram-5FMLGOSQ-BzMzFwyT.js +62 -0
- package/dist/web/client/assets/cytoscape.esm-c2aL46s-.js +321 -0
- package/dist/web/client/assets/dagre-C-rnJpZF.js +1 -0
- package/dist/web/client/assets/dagre-GXQ25YYZ-CAWJmRMG.js +4 -0
- package/dist/web/client/assets/defaultLocale-BFoDCU3G.js +1 -0
- package/dist/web/client/assets/diagram-S7CK7UJ4--lp0ALmn.js +30 -0
- package/dist/web/client/assets/diagram-UQ7AKVKN-gKUnsjcj.js +41 -0
- package/dist/web/client/assets/diagram-VSXAHHWV-BoN5D1Gh.js +3 -0
- package/dist/web/client/assets/diagram-VX7I27RA-BMtuswQ6.js +24 -0
- package/dist/web/client/assets/diagram-Z3DM3KII-DtU8LXrA.js +24 -0
- package/dist/web/client/assets/dist-v5Q1xZ2K.js +1 -0
- package/dist/web/client/assets/ebnfDiagram-PWID7BFC-DDcnv9BH.js +1 -0
- package/dist/web/client/assets/erDiagram-RLTQ6QDP-DvRb4iDL.js +99 -0
- package/dist/web/client/assets/eventmodeling-NTZA5JFV-01h4SbTc.js +1 -0
- package/dist/web/client/assets/flowDiagram-HODETNUW-Bll_YZ6T.js +1 -0
- package/dist/web/client/assets/framework-YGoR34M4.js +9 -0
- package/dist/web/client/assets/ganttDiagram-EL5Y4UJY-DdFZ9hvH.js +292 -0
- package/dist/web/client/assets/gitGraph-4MIJSDKK-DjD_AAMj.js +1 -0
- package/dist/web/client/assets/gitGraphDiagram-WWUBYQGX-CDyN9n2u.js +106 -0
- package/dist/web/client/assets/graphlib-DS17s2tU.js +1 -0
- package/dist/web/client/assets/index-CVcy0FAn.js +75 -0
- package/dist/web/client/assets/index-Dsi52apB.css +1 -0
- package/dist/web/client/assets/info-A6RAGUB7-C_XK8Hq0.js +1 -0
- package/dist/web/client/assets/infoDiagram-27XIBGKW-DIe4tJ1i.js +2 -0
- package/dist/web/client/assets/init-C-OQMol4.js +1 -0
- package/dist/web/client/assets/ishikawaDiagram-5VMMS53U-CVl5unKI.js +70 -0
- package/dist/web/client/assets/journeyDiagram-3NMN7TZE-CPEB1Vt8.js +139 -0
- package/dist/web/client/assets/kanban-definition-UXKFOSKX-j-9WXjYQ.js +89 -0
- package/dist/web/client/assets/katex-ZlcWpGUi.js +257 -0
- package/dist/web/client/assets/line-BIDAcEtX.js +1 -0
- package/dist/web/client/assets/linear-SzVmGSw4.js +1 -0
- package/dist/web/client/assets/mermaid-parser.core-Ux4vssh0.js +7 -0
- package/dist/web/client/assets/mermaid.core-CDuwVKeh.js +44 -0
- package/dist/web/client/assets/mindmap-definition-YA3MSWOX-5MlQEeQ6.js +96 -0
- package/dist/web/client/assets/newsreader-latin-ext-wght-normal-C-3rgBeH.woff2 +0 -0
- package/dist/web/client/assets/newsreader-latin-wght-normal-CCVVNp6i.woff2 +0 -0
- package/dist/web/client/assets/newsreader-vietnamese-wght-normal-Czsa-EzN.woff2 +0 -0
- package/dist/web/client/assets/ordinal-BDEzSJ7C.js +1 -0
- package/dist/web/client/assets/packet-AYTQ26CC-DRO66c9Q.js +1 -0
- package/dist/web/client/assets/path-fybaL0A-.js +1 -0
- package/dist/web/client/assets/pegDiagram-XKGWAZYB-BakZnSjM.js +1 -0
- package/dist/web/client/assets/pie-WAS4IAKB-BEzcmhz8.js +1 -0
- package/dist/web/client/assets/pieDiagram-E7YTZNPT-DpmqgoPt.js +39 -0
- package/dist/web/client/assets/prism-bash-D6zCJ74D.js +1 -0
- package/dist/web/client/assets/prism-c-04YixN25.js +1 -0
- package/dist/web/client/assets/prism-clike-DapgWyxx.js +1 -0
- package/dist/web/client/assets/prism-core-BtsZdCS6.js +1 -0
- package/dist/web/client/assets/prism-cpp-C-lJbC-6.js +1 -0
- package/dist/web/client/assets/prism-css-CPgOzxXp.js +1 -0
- package/dist/web/client/assets/prism-diff-BF8m0_mq.js +3 -0
- package/dist/web/client/assets/prism-docker-DkT6yOFj.js +1 -0
- package/dist/web/client/assets/prism-fortran-Be5x3y1V.js +1 -0
- package/dist/web/client/assets/prism-go-C_8qAH5n.js +1 -0
- package/dist/web/client/assets/prism-ini-BESK3y0r.js +1 -0
- package/dist/web/client/assets/prism-javascript-BnO-swvr.js +1 -0
- package/dist/web/client/assets/prism-json-Dp_-W-Hv.js +1 -0
- package/dist/web/client/assets/prism-jsx-D-D0NWtC.js +1 -0
- package/dist/web/client/assets/prism-julia-DIjOgiAV.js +1 -0
- package/dist/web/client/assets/prism-latex-DNMbqcH_.js +1 -0
- package/dist/web/client/assets/prism-makefile-CRKWLQ8l.js +1 -0
- package/dist/web/client/assets/prism-markdown-C0FPJ1Iz.js +1 -0
- package/dist/web/client/assets/prism-markup-Cp04rIa1.js +1 -0
- package/dist/web/client/assets/prism-matlab-D-nk08al.js +1 -0
- package/dist/web/client/assets/prism-python-CfiSVtM6.js +1 -0
- package/dist/web/client/assets/prism-r-QmNGR8LX.js +1 -0
- package/dist/web/client/assets/prism-rust-Bu9N8X3N.js +1 -0
- package/dist/web/client/assets/prism-shell-session-Be4UuYoM.js +1 -0
- package/dist/web/client/assets/prism-sql-CYhVDMEE.js +1 -0
- package/dist/web/client/assets/prism-toml-DKb54GAT.js +1 -0
- package/dist/web/client/assets/prism-tsx-p6J2Kc_4.js +1 -0
- package/dist/web/client/assets/prism-typescript-BMqONzxf.js +1 -0
- package/dist/web/client/assets/prism-yaml-C0JHu8gr.js +1 -0
- package/dist/web/client/assets/purify.es-ChwZkWde.js +3 -0
- package/dist/web/client/assets/quadrantDiagram-AXDQQJYC-DuMPwwV2.js +7 -0
- package/dist/web/client/assets/radar-RG4KPBEZ-Djm3oXl5.js +1 -0
- package/dist/web/client/assets/railroad-74A4TZTK-Cpvkwsao.js +1 -0
- package/dist/web/client/assets/railroad-abnf-HS5TGJTU-CpRQ3ruG.js +1 -0
- package/dist/web/client/assets/railroad-ebnf-LZEXJU2U-1Rm5a5eJ.js +1 -0
- package/dist/web/client/assets/railroad-peg-WCYAUIDC-C8344cTh.js +1 -0
- package/dist/web/client/assets/railroadDiagram-O6MQD6OU-CgMS4B6R.js +1 -0
- package/dist/web/client/assets/requirementDiagram-BXWQKSXE-CX5eoNdN.js +84 -0
- package/dist/web/client/assets/rolldown-runtime-hePW80VL.js +1 -0
- package/dist/web/client/assets/rough.esm-Dy-Kn_BL.js +1 -0
- package/dist/web/client/assets/sankeyDiagram-P5KCCOFB-CODBX2N3.js +40 -0
- package/dist/web/client/assets/sequenceDiagram-WJ2MYXX4-eUhhF8OR.js +162 -0
- package/dist/web/client/assets/sizeCapture-INFHLROL-B0uUizjq.js +1 -0
- package/dist/web/client/assets/src-B6xuSHsQ.js +1 -0
- package/dist/web/client/assets/stateDiagram-D77RDMKH-vR6l0NC2.js +1 -0
- package/dist/web/client/assets/stateDiagram-v2-MP3YSRHH-BYUm8jLY.js +1 -0
- package/dist/web/client/assets/swimlanes-42K2YHIH-v9Tw_zX7.js +1 -0
- package/dist/web/client/assets/swimlanesDiagram-VR7AAH4N-B2jdCvhD.js +8 -0
- package/dist/web/client/assets/timeline-definition-24CTP7MA-DxianbhU.js +120 -0
- package/dist/web/client/assets/treeView-Q6P3EWNA-DLxnZb9R.js +1 -0
- package/dist/web/client/assets/treemap-WGGIJYW6-I7UnZ6xJ.js +1 -0
- package/dist/web/client/assets/vennDiagram-4TSXK5OY-Ar7M8Mrj.js +34 -0
- package/dist/web/client/assets/wardley-WFR3VGLG-B8ZSHeDu.js +1 -0
- package/dist/web/client/assets/wardleyDiagram-VM6X3IG4-Qks2FmIn.js +78 -0
- package/dist/web/client/assets/xychartDiagram-S5SC5T6Z-BBBjRtiE.js +7 -0
- package/dist/web/client/clio-coder-logo.webp +0 -0
- package/dist/web/client/icon-192.png +0 -0
- package/dist/web/client/icon-512.png +0 -0
- package/dist/web/client/index.html +6 -0
- package/dist/web/client/manifest.webmanifest +15 -0
- package/dist/web/client/offline.css +55 -0
- package/dist/web/client/offline.html +5 -0
- package/dist/web/client/offline.js +27 -0
- package/dist/web/client/sw.js +34 -0
- package/dist/web/ops-worker.js +37 -0
- package/dist/web/reads-worker.js +1726 -0
- package/dist/web/server.js +8499 -0
- package/dist/web-EMGUGGEI.js +13 -0
- package/dist/{web-fetch-W4TNW4Q7.js → web-fetch-6BRRVQON.js} +22 -5
- package/dist/{wiki-generate-T2TJQJUA.js → wiki-generate-XHSJTDOP.js} +120 -113
- package/dist/{with-panes-CHFC7HGI.js → with-panes-Z6BTEHMZ.js} +12 -12
- package/dist/worker/entry.js +113 -99
- package/docs/README.md +28 -27
- package/docs/architecture/acp.md +5 -9
- package/docs/architecture/alcf-provider.md +0 -3
- package/docs/architecture/architecture.md +0 -3
- package/docs/architecture/artifact-placement.md +12 -4
- package/docs/architecture/artifact-versions.md +0 -3
- package/docs/architecture/capacity-and-scheduling.md +0 -3
- package/docs/architecture/context-engine.md +0 -3
- package/docs/architecture/context-working-set.md +0 -3
- package/docs/architecture/dispatch-architecture-rationale.md +0 -3
- package/docs/architecture/dispatch-typed-intent.md +0 -3
- package/docs/architecture/evidence-and-memory.md +0 -3
- package/docs/architecture/library.md +1 -3
- package/docs/architecture/middleware-and-components.md +0 -3
- package/docs/architecture/model-catalog.md +1 -4
- package/docs/architecture/observability.md +0 -3
- package/docs/architecture/pi-boundary.md +6 -9
- package/docs/architecture/prompt-envelope-and-tools.md +37 -30
- package/docs/architecture/provider-adapter-cookbook.md +1 -4
- package/docs/architecture/safety-model.md +19 -9
- package/docs/architecture/session-lifecycle.md +10 -7
- package/docs/architecture/time-conventions.md +0 -3
- package/docs/architecture/trace-store.md +28 -20
- package/docs/architecture/tui-design.md +38 -18
- package/docs/architecture/worker-context.md +1 -3
- package/docs/architecture/worker-dispatch-mechanics.md +1 -4
- package/docs/guide/authoring-plugins.md +1 -3
- package/docs/guide/built-in-agents.md +0 -3
- package/docs/guide/commands-and-modes.md +41 -25
- package/docs/guide/configuration-and-targets.md +204 -9
- package/docs/guide/configuration-reference.md +125 -17
- package/docs/guide/environment-variables.md +2 -8
- package/docs/guide/exit-codes-and-output.md +0 -3
- package/docs/guide/extensions-and-sharing.md +0 -3
- package/docs/guide/fleet-dispatch.md +3 -5
- package/docs/guide/glossary.md +1 -4
- package/docs/guide/harness-extensions.md +0 -2
- package/docs/guide/installation-and-lifecycle.md +3 -6
- package/docs/guide/interop.md +0 -2
- package/docs/guide/panes-and-files.md +0 -3
- package/docs/guide/plugins.md +0 -3
- package/docs/guide/proactive-memory.md +0 -3
- package/docs/guide/resource-library.md +1 -3
- package/docs/guide/skills-marketplace.md +0 -2
- package/docs/guide/tool-usage.md +166 -67
- package/docs/guide/troubleshooting.md +1 -4
- package/docs/history/config-knobs-audit.md +0 -3
- package/docs/history/release-cut-checklist.md +0 -3
- package/docs/process/development-pipeline.md +0 -3
- package/docs/process/documentation-coverage.md +3 -3
- package/docs/process/documentation-guide.md +16 -22
- package/docs/process/eval-runner.md +0 -3
- package/docs/process/evals-internal.md +0 -3
- package/docs/process/evolution.md +0 -3
- package/docs/process/fleet-demo-runbook.md +6 -9
- package/docs/process/git-commit-provenance.md +0 -3
- package/docs/process/performance-methodology.md +1 -4
- package/docs/process/release-cut-checklist.md +114 -221
- package/docs/process/scientific-validation.md +23 -6
- package/docs/process/tool-audit-v0.4.9.md +357 -0
- package/library/registry.yaml +2 -2
- package/library/skills/meta/clio-coder-test/SKILL.md +25 -15
- package/library/skills/meta/clio-coder-test/evals.md +16 -2
- package/library/skills/meta/clio-coder-test/plugin.json +1 -1
- package/library/skills/meta/clio-coder-test/references/test-map.md +19 -18
- package/library/skills/registry.yaml +2 -2
- package/library/skills/skill-marketplace.json +1 -1
- package/package.json +13 -11
- package/src/cli/argv.ts +31 -0
- package/src/cli/clio.ts +17 -13
- package/src/cli/config.ts +4 -0
- package/src/cli/docs.ts +65 -328
- package/src/cli/doctor-panes.ts +1 -1
- package/src/cli/doctor.ts +3 -1
- package/src/cli/index.ts +17 -2
- package/src/cli/mcp.ts +106 -0
- package/src/cli/skills-eval.ts +8 -2
- package/src/cli/trace.ts +4 -65
- package/src/cli/uninstall.ts +26 -0
- package/src/cli/upgrade.ts +34 -38
- package/src/cli/usage.ts +3 -0
- package/src/cli/verifiers.ts +1 -1
- package/src/cli/web.ts +79 -0
- package/src/core/bash-exec.ts +27 -4
- package/src/core/bus-events.ts +3 -4
- package/src/core/config.ts +73 -1
- package/src/core/defaults.ts +10 -1
- package/src/core/domain-loader.ts +37 -28
- package/src/core/event-bus.ts +1 -1
- package/src/core/run-records.ts +438 -0
- package/src/core/safe-exec.ts +506 -56
- package/src/core/skill-activation.ts +5 -3
- package/src/core/termination.ts +16 -12
- package/src/core/tool-names.ts +33 -12
- package/src/domains/agents/contract.ts +1 -1
- package/src/domains/agents/extension.ts +18 -10
- package/src/domains/config/extension.ts +5 -4
- package/src/domains/context/clio-md.ts +1 -1
- package/src/domains/context/worker/pressure.ts +6 -2
- package/src/domains/context/working-set/path-index.ts +7 -2
- package/src/domains/dispatch/code-step.ts +7 -2
- package/src/domains/dispatch/contract.ts +7 -0
- package/src/domains/dispatch/execution-role.ts +3 -3
- package/src/domains/dispatch/execution-scheduler.ts +204 -79
- package/src/domains/dispatch/extension.ts +206 -26
- package/src/domains/dispatch/fleet-preflight.ts +18 -3
- package/src/domains/dispatch/fleet-run.ts +1 -0
- package/src/domains/dispatch/gate-decisions.ts +3 -3
- package/src/domains/dispatch/heartbeat.ts +1 -1
- package/src/domains/dispatch/host-verification.ts +16 -14
- package/src/domains/dispatch/index.ts +1 -0
- package/src/domains/dispatch/orphan-recovery.ts +1 -0
- package/src/domains/dispatch/receipt-findings.ts +3 -4
- package/src/domains/dispatch/receipt-integrity.ts +3 -0
- package/src/domains/dispatch/reservation-store.ts +7 -9
- package/src/domains/dispatch/route-facts.ts +1 -1
- package/src/domains/dispatch/state.ts +4 -5
- package/src/domains/dispatch/types.ts +3 -1
- package/src/domains/eval/metrics/tracked.ts +22 -2
- package/src/domains/evidence/build.ts +35 -7
- package/src/domains/extensions/operator-runtime.ts +3 -1
- package/src/domains/gateway/mcp/client.ts +923 -0
- package/src/domains/gateway/mcp/config.ts +456 -0
- package/src/domains/gateway/mcp/index.ts +88 -0
- package/src/domains/gateway/mcp/protocol.ts +273 -0
- package/src/domains/gateway/mcp/trust.ts +263 -0
- package/src/domains/lifecycle/doctor.ts +17 -3
- package/src/domains/middleware/hooks.ts +2 -2
- package/src/domains/mux/contract.ts +5 -9
- package/src/domains/mux/detect.ts +1 -1
- package/src/domains/mux/extension.ts +1 -1
- package/src/domains/mux/protocol.ts +5 -7
- package/src/domains/mux/socket-client.ts +3 -3
- package/src/domains/observability/accountability.ts +2 -2
- package/src/domains/observability/background-memory-usage.ts +3 -0
- package/src/domains/observability/compaction-usage.ts +2 -0
- package/src/domains/observability/contract.ts +7 -3
- package/src/domains/observability/cost.ts +5 -0
- package/src/domains/observability/evidence-index.ts +2 -2
- package/src/domains/observability/extension.ts +1 -0
- package/src/domains/observability/out-of-turn-usage.ts +2 -0
- package/src/domains/observability/projection.ts +10 -0
- package/src/domains/observability/trace-store.ts +65 -5
- package/src/domains/prompts/compiler.ts +41 -23
- package/src/domains/prompts/extension.ts +4 -17
- package/src/domains/prompts/fragments/identity/docs-routing.md +2 -2
- package/src/domains/prompts/fragments/operating/skills.md +12 -10
- package/src/domains/providers/cache-deployment.ts +147 -0
- package/src/domains/providers/catalog.ts +12 -7
- package/src/domains/providers/extension.ts +27 -5
- package/src/domains/providers/index.ts +6 -1
- package/src/domains/providers/models/local-models/clio-coder-local-coding-targets.yaml +42 -10
- package/src/domains/providers/plugins.ts +3 -13
- package/src/domains/providers/probe/http.ts +44 -59
- package/src/domains/providers/probe/reasoning.ts +2 -0
- package/src/domains/providers/runtimes/common/local-synth.ts +4 -0
- package/src/domains/providers/runtimes/local-native/llamacpp-embed.ts +20 -31
- package/src/domains/providers/runtimes/local-native/llamacpp-rerank.ts +9 -4
- package/src/domains/providers/types/target-descriptor.ts +17 -0
- package/src/domains/safety/action-classifier.ts +17 -1
- package/src/domains/safety/call-target.ts +14 -0
- package/src/domains/safety/contract.ts +1 -1
- package/src/domains/safety/finish-contract.ts +9 -3
- package/src/domains/safety/loop-detector.ts +1 -1
- package/src/domains/safety/policy-engine.ts +7 -0
- package/src/domains/safety/protected-artifacts.ts +3 -4
- package/src/domains/safety/rejection-feedback.ts +1 -1
- package/src/domains/safety/scope.ts +2 -3
- package/src/domains/safety/validation-contract.ts +3 -2
- package/src/domains/scheduling/budget.ts +5 -3
- package/src/domains/scheduling/contract.ts +2 -1
- package/src/domains/scheduling/extension.ts +3 -3
- package/src/domains/session/compaction/branch-summary.ts +1 -1
- package/src/domains/session/compaction/compact.ts +29 -3
- package/src/domains/session/compaction/cut-point.ts +1 -1
- package/src/domains/session/compaction/tokens.ts +5 -10
- package/src/domains/session/contract.ts +1 -1
- package/src/domains/session/cwd-fallback.ts +2 -2
- package/src/domains/session/entries.ts +1 -0
- package/src/domains/session/handoff.ts +5 -1
- package/src/domains/session/history.ts +6 -0
- package/src/domains/session/manager.ts +14 -7
- package/src/domains/session/retry.ts +2 -1
- package/src/domains/session/session-artifacts.ts +12 -7
- package/src/domains/session/task-board.ts +2 -3
- package/src/domains/session/usage.ts +6 -7
- package/src/engine/acp/server.ts +11 -0
- package/src/engine/ai.ts +2 -0
- package/src/engine/apis/openai-completions.ts +17 -4
- package/src/engine/loop-guard.ts +7 -0
- package/src/engine/prewarm.ts +232 -0
- package/src/engine/provider-diagnostics.ts +6 -1
- package/src/engine/provider-error-body.ts +65 -0
- package/src/engine/session.ts +118 -29
- package/src/engine/worker-runtime.ts +3 -0
- package/src/entry/boot-options.ts +2 -0
- package/src/entry/orchestrator.ts +38 -18
- package/src/interactive/chat-loop-messages.ts +3 -0
- package/src/interactive/chat-loop-policy.ts +1 -0
- package/src/interactive/chat-loop.ts +10 -12
- package/src/interactive/chat-panel.ts +23 -9
- package/src/interactive/chat-renderer.ts +33 -11
- package/src/interactive/clio-editor.ts +13 -5
- package/src/interactive/dispatch-board.ts +70 -30
- package/src/interactive/editor-submit.ts +30 -25
- package/src/interactive/footer/widgets.ts +12 -9
- package/src/interactive/interactive-presentation.ts +2 -3
- package/src/interactive/mux-bridge.ts +3 -7
- package/src/interactive/overlay-general-openers.ts +14 -7
- package/src/interactive/overlays/cwd-fallback.ts +1 -1
- package/src/interactive/overlays/library-model.ts +114 -35
- package/src/interactive/overlays/library.ts +52 -5
- package/src/interactive/overlays/list-overlay.ts +4 -1
- package/src/interactive/overlays/session-selector.ts +28 -23
- package/src/interactive/overlays/settings.ts +20 -1
- package/src/interactive/overlays/tree-selector.ts +47 -10
- package/src/interactive/panes-runtime.ts +1 -1
- package/src/interactive/prewarm.ts +11 -197
- package/src/interactive/renderers/compaction-summary.ts +1 -1
- package/src/interactive/renderers/provider-error.ts +118 -0
- package/src/interactive/renderers/retry-status.ts +59 -23
- package/src/interactive/renderers/tool-execution.ts +67 -7
- package/src/interactive/renderers/worker-answer.ts +198 -0
- package/src/interactive/renderers/worker-entry.ts +57 -163
- package/src/interactive/session-usage-reseed.ts +2 -0
- package/src/interactive/side-question.ts +2 -0
- package/src/interactive/slash-commands.ts +26 -1
- package/src/interactive/slash-spec.ts +2 -2
- package/src/interactive/theme/labels.ts +66 -30
- package/src/interactive/turn-context.ts +1 -0
- package/src/interactive/turn-persistence.ts +9 -1
- package/src/interactive/turn-prewarm.ts +126 -19
- package/src/interactive/turn-recovery.ts +2 -1
- package/src/interactive/turn-runtime.ts +36 -5
- package/src/interactive/view/artifacts.ts +3 -2
- package/src/interactive/view/view-overlay.ts +96 -20
- package/src/tools/agent-tools.ts +21 -7
- package/src/tools/artifact.ts +16 -8
- package/src/tools/bash.ts +90 -11
- package/src/tools/bootstrap.ts +42 -4
- package/src/tools/builtin-tool-catalog.ts +80 -11
- package/src/tools/context/index.ts +27 -31
- package/src/tools/context/library.ts +3 -1
- package/src/tools/context/surface.ts +12 -26
- package/src/tools/core-bootstrap.ts +72 -1
- package/src/tools/data/csv.ts +1189 -0
- package/src/tools/data/index.ts +308 -0
- package/src/tools/data/json.ts +1799 -0
- package/src/tools/data/jsonl.ts +561 -0
- package/src/tools/data/shared.ts +452 -0
- package/src/tools/edit-diff.ts +0 -7
- package/src/tools/edit.ts +115 -18
- package/src/tools/file-mutation-queue.ts +114 -4
- package/src/tools/find.ts +108 -29
- package/src/tools/gateway/caps.ts +11 -0
- package/src/tools/gateway/clio-context-surface.ts +41 -0
- package/src/tools/gateway/clio-context-tools.ts +77 -0
- package/src/tools/gateway/data-surface.ts +138 -0
- package/src/tools/gateway/data-tool.ts +201 -0
- package/src/tools/gateway/index.ts +342 -0
- package/src/tools/gateway/mcp-capabilities.ts +469 -0
- package/src/tools/grep.ts +88 -33
- package/src/tools/harness-extensions.ts +3 -0
- package/src/tools/ignore-policy.ts +7 -5
- package/src/tools/ls.ts +111 -20
- package/src/tools/policy.ts +35 -13
- package/src/tools/presentation.ts +6 -0
- package/src/tools/read.ts +634 -156
- package/src/tools/registry.ts +106 -8
- package/src/tools/run-script.ts +997 -0
- package/src/tools/spawn-hygiene.ts +157 -5
- package/src/tools/surface.ts +163 -0
- package/src/tools/verify/authoring.ts +8 -3
- package/src/tools/verify/catalog.ts +14 -1
- package/src/tools/verify/numeric.ts +367 -59
- package/src/tools/verify/perf.ts +171 -9
- package/src/tools/verify/scripts.ts +178 -26
- package/src/tools/web-fetch-surface.ts +22 -0
- package/src/tools/web-fetch.ts +26 -1
- package/src/tools/write.ts +45 -19
- package/src/worker/spec-contract.ts +27 -0
- package/dist/chunk-B6UM3OZC.js +0 -15
- package/dist/chunk-GJ24ODAX.js +0 -196
- package/dist/chunk-HRAKUPIH.js +0 -57
- package/dist/docs-BL7ROUFN.js +0 -292
|
@@ -2,20 +2,6 @@ import { createRequire as __clioCreateRequire } from "node:module"; const requir
|
|
|
2
2
|
import {
|
|
3
3
|
planWikiGeneration
|
|
4
4
|
} from "./chunk-PECBKCDK.js";
|
|
5
|
-
import {
|
|
6
|
-
applyTaskWorktree,
|
|
7
|
-
captureWorkspaceCheckpoint,
|
|
8
|
-
captureWorkspaceSnapshot,
|
|
9
|
-
cleanupTaskWorktree,
|
|
10
|
-
createTaskWorktree,
|
|
11
|
-
createWriteBoundaryEnforcer,
|
|
12
|
-
gitCheckoutRoot,
|
|
13
|
-
workspaceCheckpointRef
|
|
14
|
-
} from "./chunk-UA3W4FGC.js";
|
|
15
|
-
import {
|
|
16
|
-
executionPlanAncestors,
|
|
17
|
-
spliceExecutionPlan
|
|
18
|
-
} from "./chunk-RTLNFZMD.js";
|
|
19
5
|
import {
|
|
20
6
|
decideReviewGate,
|
|
21
7
|
materializePendingGateDecision,
|
|
@@ -23,7 +9,7 @@ import {
|
|
|
23
9
|
readGateDecisionArtifactsForRunIds,
|
|
24
10
|
stagePendingGateDecision,
|
|
25
11
|
verifyGateDecisionArtifact
|
|
26
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-NMBEW4PP.js";
|
|
27
13
|
import {
|
|
28
14
|
RUN_RECEIPT_INTEGRITY_ALGORITHM,
|
|
29
15
|
RUN_RECEIPT_INTEGRITY_VERSION,
|
|
@@ -43,14 +29,32 @@ import {
|
|
|
43
29
|
trustVerdict,
|
|
44
30
|
verifyReceiptIntegrity,
|
|
45
31
|
withReceiptIntegrity
|
|
46
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-IALZJE37.js";
|
|
47
33
|
import {
|
|
48
34
|
protectedArtifactFromSessionEntry,
|
|
49
35
|
protectedArtifactStateFromSessionEntries,
|
|
50
36
|
readAuditRows,
|
|
51
37
|
readSessionEntriesForId,
|
|
52
38
|
responseModelIdObservationFromRecord
|
|
53
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-3SUDBGEI.js";
|
|
40
|
+
import {
|
|
41
|
+
codeStepDir,
|
|
42
|
+
writeCodeStepRecord
|
|
43
|
+
} from "./chunk-LGTVWPRN.js";
|
|
44
|
+
import {
|
|
45
|
+
applyTaskWorktree,
|
|
46
|
+
captureWorkspaceCheckpoint,
|
|
47
|
+
captureWorkspaceSnapshot,
|
|
48
|
+
cleanupTaskWorktree,
|
|
49
|
+
createTaskWorktree,
|
|
50
|
+
createWriteBoundaryEnforcer,
|
|
51
|
+
gitCheckoutRoot,
|
|
52
|
+
workspaceCheckpointRef
|
|
53
|
+
} from "./chunk-KRJQG47M.js";
|
|
54
|
+
import {
|
|
55
|
+
executionPlanAncestors,
|
|
56
|
+
spliceExecutionPlan
|
|
57
|
+
} from "./chunk-DIAJYJYG.js";
|
|
54
58
|
import {
|
|
55
59
|
loadEvalArtifact,
|
|
56
60
|
parseEvalArtifactV4,
|
|
@@ -58,13 +62,34 @@ import {
|
|
|
58
62
|
sumEvalHarnessMetrics
|
|
59
63
|
} from "./chunk-U44YYLVV.js";
|
|
60
64
|
import {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
} from "./chunk-
|
|
65
|
+
parseRigorOverride,
|
|
66
|
+
resolveRigor
|
|
67
|
+
} from "./chunk-GREYLTZ5.js";
|
|
68
|
+
import {
|
|
69
|
+
describeValidationContract,
|
|
70
|
+
loadValidationContract
|
|
71
|
+
} from "./chunk-PTFISXQO.js";
|
|
72
|
+
import {
|
|
73
|
+
filterEntriesToActivePath
|
|
74
|
+
} from "./chunk-O5F25NIE.js";
|
|
64
75
|
import {
|
|
65
76
|
defaultRunEventJournal,
|
|
66
77
|
removeRunEventJournals
|
|
67
78
|
} from "./chunk-UQIVHSE4.js";
|
|
79
|
+
import {
|
|
80
|
+
createTomlFileReader,
|
|
81
|
+
tomlTableAt
|
|
82
|
+
} from "./chunk-LQTKDAUO.js";
|
|
83
|
+
import {
|
|
84
|
+
AdmissionCanceledError,
|
|
85
|
+
EVENT_TEE_LIMIT,
|
|
86
|
+
activeDecisionRefs,
|
|
87
|
+
createWorkerOutputCapture,
|
|
88
|
+
durableAssistantTextFromEvent,
|
|
89
|
+
foldDecisionBoard,
|
|
90
|
+
startDispatchEventPump,
|
|
91
|
+
workerOutputCaptureBytes
|
|
92
|
+
} from "./chunk-K3XN4LZ4.js";
|
|
68
93
|
import {
|
|
69
94
|
changedPathsSince,
|
|
70
95
|
computeWikiContentHash,
|
|
@@ -77,7 +102,7 @@ import {
|
|
|
77
102
|
wikiStaleness,
|
|
78
103
|
writeWikiMeta,
|
|
79
104
|
writeWikiMetaInDir
|
|
80
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-YQ3GFEUY.js";
|
|
81
106
|
import {
|
|
82
107
|
readClioState,
|
|
83
108
|
statePath,
|
|
@@ -88,7 +113,7 @@ import {
|
|
|
88
113
|
coordinateCodewikiExclusive,
|
|
89
114
|
coordinateCodewikiWrite,
|
|
90
115
|
drainCodewikiWrites
|
|
91
|
-
} from "./chunk-
|
|
116
|
+
} from "./chunk-WWRV5RJI.js";
|
|
92
117
|
import {
|
|
93
118
|
WIKI_INDEX,
|
|
94
119
|
WIKI_PLAN_FILE,
|
|
@@ -107,24 +132,17 @@ import {
|
|
|
107
132
|
wikiMarkdownFilesInDir,
|
|
108
133
|
wikiSourcesMatch,
|
|
109
134
|
writeWikiPlanFile
|
|
110
|
-
} from "./chunk-
|
|
111
|
-
import {
|
|
112
|
-
filterEntriesToActivePath
|
|
113
|
-
} from "./chunk-O5F25NIE.js";
|
|
135
|
+
} from "./chunk-BHJMMCXS.js";
|
|
114
136
|
import {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
durableAssistantTextFromEvent,
|
|
120
|
-
foldDecisionBoard,
|
|
121
|
-
startDispatchEventPump,
|
|
122
|
-
workerOutputCaptureBytes
|
|
123
|
-
} from "./chunk-CULVKYTK.js";
|
|
137
|
+
FLEET_COMMAND_BASE_ENV,
|
|
138
|
+
normalizeWriteBoundary,
|
|
139
|
+
validateFleetCommandArgs
|
|
140
|
+
} from "./chunk-7QQRPB2E.js";
|
|
124
141
|
import {
|
|
142
|
+
JUDGED_CHECK_MAX_OUTPUT_BYTES,
|
|
125
143
|
judgeNumericTexts,
|
|
126
144
|
judgePerfTexts
|
|
127
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-QI72X67S.js";
|
|
128
146
|
import {
|
|
129
147
|
LOCAL_NODE_ID,
|
|
130
148
|
computeSettingsFingerprint,
|
|
@@ -135,19 +153,11 @@ import {
|
|
|
135
153
|
receiptAttestationFields,
|
|
136
154
|
routeFactVerdict,
|
|
137
155
|
spawnNativeWorker
|
|
138
|
-
} from "./chunk-
|
|
156
|
+
} from "./chunk-A6DULIMH.js";
|
|
139
157
|
import {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
} from "./chunk-
|
|
143
|
-
import {
|
|
144
|
-
parseRigorOverride,
|
|
145
|
-
resolveRigor
|
|
146
|
-
} from "./chunk-NCCQ6DVS.js";
|
|
147
|
-
import {
|
|
148
|
-
describeValidationContract,
|
|
149
|
-
loadValidationContract
|
|
150
|
-
} from "./chunk-T52TPHYC.js";
|
|
158
|
+
AcpTimeoutError,
|
|
159
|
+
createStdioTransport
|
|
160
|
+
} from "./chunk-XNZWWDC3.js";
|
|
151
161
|
import {
|
|
152
162
|
AGENT_LEDGER_PROMPT_MAX_CHARS,
|
|
153
163
|
COUNCIL_MIN_MEMBERS,
|
|
@@ -189,7 +199,7 @@ import {
|
|
|
189
199
|
serializeWorkerRuntimeDescriptor,
|
|
190
200
|
toolPromptHintsForNames,
|
|
191
201
|
validateJobSpec
|
|
192
|
-
} from "./chunk-
|
|
202
|
+
} from "./chunk-4ATBOFRP.js";
|
|
193
203
|
import {
|
|
194
204
|
WORKER_CONTEXT_MAX_BYTES,
|
|
195
205
|
completeHistoryLength,
|
|
@@ -212,31 +222,29 @@ import {
|
|
|
212
222
|
routingIntentRejection,
|
|
213
223
|
sameRouteIdentity,
|
|
214
224
|
toRouteCandidate
|
|
215
|
-
} from "./chunk-
|
|
225
|
+
} from "./chunk-MO65K5CH.js";
|
|
216
226
|
import {
|
|
217
|
-
|
|
218
|
-
} from "./chunk-
|
|
227
|
+
assessFinishContract
|
|
228
|
+
} from "./chunk-AY4XE6GN.js";
|
|
219
229
|
import {
|
|
220
230
|
isLoadableExtension
|
|
221
231
|
} from "./chunk-OH3YYA3B.js";
|
|
222
232
|
import {
|
|
223
233
|
extensionToolName,
|
|
224
234
|
listInstalledExtensions
|
|
225
|
-
} from "./chunk-
|
|
235
|
+
} from "./chunk-6TKOFFGE.js";
|
|
226
236
|
import {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
normalizeGlobInput
|
|
232
|
-
} from "./chunk-V552WL53.js";
|
|
237
|
+
directSurfaceNames,
|
|
238
|
+
effectiveToolCall,
|
|
239
|
+
withGatewayForCapabilities
|
|
240
|
+
} from "./chunk-2JBZYUPY.js";
|
|
233
241
|
import {
|
|
234
|
-
|
|
235
|
-
} from "./chunk-
|
|
242
|
+
describeCallAction
|
|
243
|
+
} from "./chunk-XNIZBOFV.js";
|
|
236
244
|
import {
|
|
237
245
|
applyToolProfile,
|
|
238
246
|
assertToolProfileEnforceable
|
|
239
|
-
} from "./chunk-
|
|
247
|
+
} from "./chunk-XZWSP67B.js";
|
|
240
248
|
import {
|
|
241
249
|
dispatchResultContract,
|
|
242
250
|
gateRouteCorrelation,
|
|
@@ -244,37 +252,7 @@ import {
|
|
|
244
252
|
requestExecutionRole,
|
|
245
253
|
routeCorrelationFactsForRun,
|
|
246
254
|
withAttemptRole
|
|
247
|
-
} from "./chunk-
|
|
248
|
-
import {
|
|
249
|
-
declaredScopeIntent,
|
|
250
|
-
declaredScopeReplacementDiagnostic,
|
|
251
|
-
declaredScopeReplacementNotice,
|
|
252
|
-
inferredScopeParentTokenDiagnostic,
|
|
253
|
-
inferredScopeParentTokenNotice,
|
|
254
|
-
resolveDispatchPathScope
|
|
255
|
-
} from "./chunk-L4N3DWNW.js";
|
|
256
|
-
import {
|
|
257
|
-
WORKER_STDIN_FRAME_MAX_BYTES,
|
|
258
|
-
canonicalJson,
|
|
259
|
-
endpointIdentityHash,
|
|
260
|
-
parseAgentLedgerBody
|
|
261
|
-
} from "./chunk-VQD7NH7Z.js";
|
|
262
|
-
import {
|
|
263
|
-
createRedactionTally,
|
|
264
|
-
redactSecretsDeep,
|
|
265
|
-
redactSecretsText
|
|
266
|
-
} from "./chunk-O3VV6IVK.js";
|
|
267
|
-
import {
|
|
268
|
-
decisionRef,
|
|
269
|
-
isDecisionRecord,
|
|
270
|
-
isSkillActivation
|
|
271
|
-
} from "./chunk-KAFMW7WM.js";
|
|
272
|
-
import {
|
|
273
|
-
assessFinishContract
|
|
274
|
-
} from "./chunk-BQQ5MXUC.js";
|
|
275
|
-
import {
|
|
276
|
-
WRITE_ROOT_REFUSED_TOOLS
|
|
277
|
-
} from "./chunk-DLIYANB7.js";
|
|
255
|
+
} from "./chunk-H6IUCY6Q.js";
|
|
278
256
|
import {
|
|
279
257
|
canonicalEndpointKey,
|
|
280
258
|
canonicalizeWireModelId,
|
|
@@ -293,59 +271,27 @@ import {
|
|
|
293
271
|
resolveRuntimeTarget,
|
|
294
272
|
runtimeResolutionWarnings,
|
|
295
273
|
runtimeTargetSnapshot
|
|
296
|
-
} from "./chunk-
|
|
274
|
+
} from "./chunk-4HFJKRGZ.js";
|
|
297
275
|
import {
|
|
298
276
|
ceilChars,
|
|
299
277
|
estimateAgentMessageTokens
|
|
300
|
-
} from "./chunk-
|
|
301
|
-
import {
|
|
302
|
-
DEFAULT_AUTONOMY_LEVEL,
|
|
303
|
-
autonomyDenyRejection,
|
|
304
|
-
mapAutonomy
|
|
305
|
-
} from "./chunk-EM2WNQS2.js";
|
|
306
|
-
import {
|
|
307
|
-
atomicWrite
|
|
308
|
-
} from "./chunk-FQOOGXBH.js";
|
|
309
|
-
import {
|
|
310
|
-
assertSafeId
|
|
311
|
-
} from "./chunk-UHW5V7HC.js";
|
|
312
|
-
import {
|
|
313
|
-
compareCodepoints
|
|
314
|
-
} from "./chunk-B6UM3OZC.js";
|
|
315
|
-
import {
|
|
316
|
-
truncateUtf8
|
|
317
|
-
} from "./chunk-MYI32N4R.js";
|
|
318
|
-
import {
|
|
319
|
-
normalizeClioCoderEventRecord,
|
|
320
|
-
normalizeClioCoderEventType
|
|
321
|
-
} from "./chunk-KMF54VH3.js";
|
|
278
|
+
} from "./chunk-SJMNU4ZS.js";
|
|
322
279
|
import {
|
|
323
280
|
BusChannels
|
|
324
|
-
} from "./chunk-
|
|
281
|
+
} from "./chunk-W5RM7YAH.js";
|
|
325
282
|
import {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
} from "./chunk-VHKTOLEW.js";
|
|
329
|
-
import {
|
|
330
|
-
codewikiPath
|
|
331
|
-
} from "./chunk-W2RJEH6Q.js";
|
|
332
|
-
import {
|
|
333
|
-
detectProjectType
|
|
334
|
-
} from "./chunk-CVDAFGPW.js";
|
|
335
|
-
import {
|
|
336
|
-
enumerateWorkspaceFiles
|
|
337
|
-
} from "./chunk-PPEZJWUG.js";
|
|
283
|
+
networkToolsDisabled
|
|
284
|
+
} from "./chunk-SL2RDHKO.js";
|
|
338
285
|
import {
|
|
339
|
-
|
|
340
|
-
|
|
286
|
+
compileGlobRegex,
|
|
287
|
+
normalizeGlobInput
|
|
288
|
+
} from "./chunk-IZZI3SKQ.js";
|
|
341
289
|
import {
|
|
342
|
-
|
|
343
|
-
} from "./chunk-
|
|
290
|
+
WRITE_ROOT_REFUSED_TOOLS
|
|
291
|
+
} from "./chunk-IC7JXLOM.js";
|
|
344
292
|
import {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
validateFleetCommandArgs
|
|
348
|
-
} from "./chunk-KKEYGFX4.js";
|
|
293
|
+
TOOL_RESULT_TRUST_CONTRACT
|
|
294
|
+
} from "./chunk-WXA2CFJO.js";
|
|
349
295
|
import {
|
|
350
296
|
agentSpecFingerprint,
|
|
351
297
|
assertAgentSpecPolicy,
|
|
@@ -355,19 +301,33 @@ import {
|
|
|
355
301
|
resolveAgentToolCompatibility,
|
|
356
302
|
resultContractAuthorship,
|
|
357
303
|
validateRecipeResult
|
|
358
|
-
} from "./chunk-
|
|
304
|
+
} from "./chunk-I47EJPYL.js";
|
|
359
305
|
import {
|
|
360
306
|
INTEROP_AGENT_KINDS
|
|
361
307
|
} from "./chunk-5EQO5NWP.js";
|
|
362
308
|
import {
|
|
363
309
|
classify
|
|
364
|
-
} from "./chunk-
|
|
310
|
+
} from "./chunk-H2WSCZZT.js";
|
|
365
311
|
import {
|
|
366
312
|
detectValidationCommand
|
|
367
|
-
} from "./chunk-
|
|
313
|
+
} from "./chunk-SQBT46OF.js";
|
|
368
314
|
import {
|
|
369
315
|
canonicalizeExistingPath
|
|
370
316
|
} from "./chunk-KQ6IDQIB.js";
|
|
317
|
+
import {
|
|
318
|
+
declaredScopeIntent,
|
|
319
|
+
declaredScopeReplacementDiagnostic,
|
|
320
|
+
declaredScopeReplacementNotice,
|
|
321
|
+
inferredScopeParentTokenDiagnostic,
|
|
322
|
+
inferredScopeParentTokenNotice,
|
|
323
|
+
resolveDispatchPathScope
|
|
324
|
+
} from "./chunk-L4N3DWNW.js";
|
|
325
|
+
import {
|
|
326
|
+
compareCodepoints
|
|
327
|
+
} from "./chunk-2KUBKL63.js";
|
|
328
|
+
import {
|
|
329
|
+
truncateUtf8
|
|
330
|
+
} from "./chunk-MYI32N4R.js";
|
|
371
331
|
import {
|
|
372
332
|
PATH_BOUNDARY_MAX_ENTRIES,
|
|
373
333
|
pathBoundaryCovers,
|
|
@@ -381,25 +341,32 @@ import {
|
|
|
381
341
|
ToolNames,
|
|
382
342
|
isBuiltinToolName,
|
|
383
343
|
isHarnessExtensionToolName
|
|
384
|
-
} from "./chunk-
|
|
385
|
-
import {
|
|
386
|
-
readClioVersion,
|
|
387
|
-
readPiMonoVersion,
|
|
388
|
-
resolvePackageRoot
|
|
389
|
-
} from "./chunk-E3LEPLQ2.js";
|
|
344
|
+
} from "./chunk-V4XJWDHR.js";
|
|
390
345
|
import {
|
|
391
346
|
DEFAULT_DELEGATION_CONNECT_TIMEOUT_MS,
|
|
392
347
|
DEFAULT_DELEGATION_TURN_TIMEOUT_MS,
|
|
393
348
|
DEFAULT_SETTINGS,
|
|
394
349
|
THINKING_LEVELS
|
|
395
|
-
} from "./chunk-
|
|
350
|
+
} from "./chunk-ZKJU55MX.js";
|
|
396
351
|
import {
|
|
397
352
|
GUARDRAIL_DEFAULTS,
|
|
398
353
|
resolveGuardrail
|
|
399
354
|
} from "./chunk-C27U2TYG.js";
|
|
400
355
|
import {
|
|
401
|
-
|
|
402
|
-
} from "./chunk-
|
|
356
|
+
targetRequiresAuth
|
|
357
|
+
} from "./chunk-ZKVMDNAN.js";
|
|
358
|
+
import {
|
|
359
|
+
require_dist
|
|
360
|
+
} from "./chunk-B5GGDIHT.js";
|
|
361
|
+
import {
|
|
362
|
+
resolveEffectivePricing
|
|
363
|
+
} from "./chunk-JIYWMQZ5.js";
|
|
364
|
+
import {
|
|
365
|
+
WORKER_STDIN_FRAME_MAX_BYTES,
|
|
366
|
+
canonicalJson,
|
|
367
|
+
endpointIdentityHash,
|
|
368
|
+
parseAgentLedgerBody
|
|
369
|
+
} from "./chunk-VQD7NH7Z.js";
|
|
403
370
|
import {
|
|
404
371
|
attributeCommitMessage,
|
|
405
372
|
gitCommitAttributionEnabled,
|
|
@@ -407,34 +374,75 @@ import {
|
|
|
407
374
|
withManagedGitCommitAttributionEnvironment
|
|
408
375
|
} from "./chunk-LTR5QCLS.js";
|
|
409
376
|
import {
|
|
410
|
-
MAX_TIMER_DELAY_MS,
|
|
411
377
|
rawDurationMs
|
|
412
378
|
} from "./chunk-6EXUUOSN.js";
|
|
413
379
|
import {
|
|
414
380
|
AI_AGENT_NAME
|
|
415
381
|
} from "./chunk-ZTNFYMIO.js";
|
|
382
|
+
import {
|
|
383
|
+
decisionRef,
|
|
384
|
+
isDecisionRecord,
|
|
385
|
+
isSkillActivation
|
|
386
|
+
} from "./chunk-NBPA5QM6.js";
|
|
387
|
+
import {
|
|
388
|
+
DEFAULT_AUTONOMY_LEVEL,
|
|
389
|
+
autonomyDenyRejection,
|
|
390
|
+
isAutonomyLevel,
|
|
391
|
+
mapAutonomy,
|
|
392
|
+
modelMayActivateSkills
|
|
393
|
+
} from "./chunk-EM2WNQS2.js";
|
|
394
|
+
import {
|
|
395
|
+
createRedactionTally,
|
|
396
|
+
redactSecretsDeep,
|
|
397
|
+
redactSecretsText
|
|
398
|
+
} from "./chunk-O3VV6IVK.js";
|
|
416
399
|
import {
|
|
417
400
|
FILE_LOCK_ACQUIRE_TIMEOUT_MS,
|
|
418
401
|
withStateFileLock,
|
|
419
402
|
withStateFileLockSync
|
|
420
403
|
} from "./chunk-DVJL77SO.js";
|
|
404
|
+
import {
|
|
405
|
+
atomicWrite
|
|
406
|
+
} from "./chunk-3RDHGNU7.js";
|
|
407
|
+
import {
|
|
408
|
+
assertSafeId
|
|
409
|
+
} from "./chunk-UHW5V7HC.js";
|
|
410
|
+
import {
|
|
411
|
+
normalizeClioCoderEventRecord,
|
|
412
|
+
normalizeClioCoderEventType
|
|
413
|
+
} from "./chunk-KMF54VH3.js";
|
|
421
414
|
import {
|
|
422
415
|
BIRTH_TOKEN_SOURCE_AVAILABLE,
|
|
423
416
|
processAlive,
|
|
424
417
|
processBirthToken
|
|
425
418
|
} from "./chunk-TK2BMCBZ.js";
|
|
426
|
-
import {
|
|
427
|
-
require_dist
|
|
428
|
-
} from "./chunk-B5GGDIHT.js";
|
|
429
|
-
import {
|
|
430
|
-
safeResourceWrite
|
|
431
|
-
} from "./chunk-ZZFWWYLX.js";
|
|
432
419
|
import {
|
|
433
420
|
clioDataDir,
|
|
434
421
|
clioStateDir,
|
|
435
422
|
resolveClioDirs,
|
|
436
423
|
stateRootRemoved
|
|
437
424
|
} from "./chunk-CTTI7G3T.js";
|
|
425
|
+
import {
|
|
426
|
+
computeFingerprintCached,
|
|
427
|
+
isStale
|
|
428
|
+
} from "./chunk-VHKTOLEW.js";
|
|
429
|
+
import {
|
|
430
|
+
codewikiPath
|
|
431
|
+
} from "./chunk-W2RJEH6Q.js";
|
|
432
|
+
import {
|
|
433
|
+
detectProjectType
|
|
434
|
+
} from "./chunk-CVDAFGPW.js";
|
|
435
|
+
import {
|
|
436
|
+
enumerateWorkspaceFiles
|
|
437
|
+
} from "./chunk-PPEZJWUG.js";
|
|
438
|
+
import {
|
|
439
|
+
safeResourceWrite
|
|
440
|
+
} from "./chunk-ZZFWWYLX.js";
|
|
441
|
+
import {
|
|
442
|
+
readClioVersion,
|
|
443
|
+
readPiMonoVersion,
|
|
444
|
+
resolvePackageRoot
|
|
445
|
+
} from "./chunk-E3LEPLQ2.js";
|
|
438
446
|
import {
|
|
439
447
|
__toESM,
|
|
440
448
|
init_esm_shims
|
|
@@ -1161,7 +1169,7 @@ function normalizeNestedMarkdown(value) {
|
|
|
1161
1169
|
let cursor = 0;
|
|
1162
1170
|
for (const match of mask.matchAll(/^(#{1,2})(\s+)/gm)) {
|
|
1163
1171
|
if (match.index === void 0) continue;
|
|
1164
|
-
out3 += body.slice(cursor, match.index)
|
|
1172
|
+
out3 += `${body.slice(cursor, match.index)}###${match[2] ?? ""}`;
|
|
1165
1173
|
cursor = match.index + match[0].length;
|
|
1166
1174
|
}
|
|
1167
1175
|
return out3 + body.slice(cursor);
|
|
@@ -5275,7 +5283,7 @@ function persistWorkerContextSeed(input) {
|
|
|
5275
5283
|
import { createHash as createHash13, randomBytes as randomBytes5 } from "node:crypto";
|
|
5276
5284
|
import { readdirSync as readdirSync8, readFileSync as readFileSync22 } from "node:fs";
|
|
5277
5285
|
import { isAbsolute as isAbsolute6, relative as relative6, resolve as resolvePath, sep as sep3 } from "node:path";
|
|
5278
|
-
import { performance as
|
|
5286
|
+
import { performance as performance4 } from "node:perf_hooks";
|
|
5279
5287
|
|
|
5280
5288
|
// src/core/residency-protection.ts
|
|
5281
5289
|
init_esm_shims();
|
|
@@ -5296,72 +5304,7 @@ function protectedResidencyModels(settings) {
|
|
|
5296
5304
|
|
|
5297
5305
|
// src/engine/acp/adapter.ts
|
|
5298
5306
|
init_esm_shims();
|
|
5299
|
-
import { performance as
|
|
5300
|
-
|
|
5301
|
-
// src/engine/acp/errors.ts
|
|
5302
|
-
init_esm_shims();
|
|
5303
|
-
var AcpError = class extends Error {
|
|
5304
|
-
code;
|
|
5305
|
-
data;
|
|
5306
|
-
constructor(code, message, data) {
|
|
5307
|
-
super(message);
|
|
5308
|
-
this.name = "AcpError";
|
|
5309
|
-
this.code = code;
|
|
5310
|
-
this.data = data;
|
|
5311
|
-
}
|
|
5312
|
-
};
|
|
5313
|
-
var AcpProtocolError = class extends AcpError {
|
|
5314
|
-
constructor(message, data) {
|
|
5315
|
-
super("acp_protocol_error", message, data);
|
|
5316
|
-
this.name = "AcpProtocolError";
|
|
5317
|
-
}
|
|
5318
|
-
};
|
|
5319
|
-
var AcpTimeoutError = class extends AcpError {
|
|
5320
|
-
constructor(message, data) {
|
|
5321
|
-
super("acp_timeout", message, data);
|
|
5322
|
-
this.name = "AcpTimeoutError";
|
|
5323
|
-
}
|
|
5324
|
-
};
|
|
5325
|
-
var AcpProcessError = class extends AcpError {
|
|
5326
|
-
constructor(message, data) {
|
|
5327
|
-
super("acp_process_error", message, data);
|
|
5328
|
-
this.name = "AcpProcessError";
|
|
5329
|
-
}
|
|
5330
|
-
};
|
|
5331
|
-
var ACP_MAX_ERROR_MESSAGE_CHARS = 256;
|
|
5332
|
-
var ACP_TURN_FAILED_MESSAGE = "the prompt turn failed";
|
|
5333
|
-
var ACP_INTERNAL_ERROR_MESSAGE = "internal error";
|
|
5334
|
-
var ACP_METHOD_NOT_FOUND_MESSAGE = "method not found";
|
|
5335
|
-
var ACP_ERROR_META_KEY = "clio-coder/error";
|
|
5336
|
-
var ACP_ERROR_META_VERSION = 1;
|
|
5337
|
-
var AcpRequestError = class extends Error {
|
|
5338
|
-
constructor(rpcCode, message, detail) {
|
|
5339
|
-
super(message);
|
|
5340
|
-
this.rpcCode = rpcCode;
|
|
5341
|
-
this.detail = detail;
|
|
5342
|
-
this.name = "AcpRequestError";
|
|
5343
|
-
}
|
|
5344
|
-
rpcCode;
|
|
5345
|
-
detail;
|
|
5346
|
-
};
|
|
5347
|
-
function acpErrorData(detail) {
|
|
5348
|
-
return {
|
|
5349
|
-
_meta: {
|
|
5350
|
-
[ACP_ERROR_META_KEY]: {
|
|
5351
|
-
version: ACP_ERROR_META_VERSION,
|
|
5352
|
-
code: detail.code,
|
|
5353
|
-
...detail.reason !== void 0 ? { reason: detail.reason } : {},
|
|
5354
|
-
...detail.supported !== void 0 ? { supported: [...detail.supported] } : {}
|
|
5355
|
-
}
|
|
5356
|
-
}
|
|
5357
|
-
};
|
|
5358
|
-
}
|
|
5359
|
-
function acpErrorMessage(value) {
|
|
5360
|
-
const raw = value instanceof Error ? value.message : String(value);
|
|
5361
|
-
const collapsed = raw.replace(/\s+/g, " ").trim();
|
|
5362
|
-
if (collapsed.length <= ACP_MAX_ERROR_MESSAGE_CHARS) return collapsed;
|
|
5363
|
-
return `${collapsed.slice(0, ACP_MAX_ERROR_MESSAGE_CHARS - 1)}\u2026`;
|
|
5364
|
-
}
|
|
5307
|
+
import { performance as performance3 } from "node:perf_hooks";
|
|
5365
5308
|
|
|
5366
5309
|
// src/engine/acp/event-mapper.ts
|
|
5367
5310
|
init_esm_shims();
|
|
@@ -5944,677 +5887,84 @@ var AcpToolMediator = class {
|
|
|
5944
5887
|
} else if (this.input.toolGovernance === "deny-all") {
|
|
5945
5888
|
decision = "denied";
|
|
5946
5889
|
reason = "deny-all governance";
|
|
5947
|
-
} else if (!mapped.known) {
|
|
5948
|
-
decision = "denied";
|
|
5949
|
-
reason = `unknown ACP tool: ${mapped.displayTool}`;
|
|
5950
|
-
} else {
|
|
5951
|
-
const safetyDecisions = mapped.evaluations.map(
|
|
5952
|
-
(evaluation) => this.input.safety.evaluate({ tool: evaluation.tool, args: evaluation.args })
|
|
5953
|
-
);
|
|
5954
|
-
const blocking = safetyDecisions.find((candidate) => candidate.kind === "block");
|
|
5955
|
-
const asking = safetyDecisions.find((candidate) => candidate.kind === "ask");
|
|
5956
|
-
safetyDecision = blocking ?? asking ?? safetyDecisions[0];
|
|
5957
|
-
if (blocking !== void 0) {
|
|
5958
|
-
decision = "denied";
|
|
5959
|
-
reason = blocking.policy?.reasonCode ?? blocking.kind;
|
|
5960
|
-
} else if (asking !== void 0) {
|
|
5961
|
-
decision = "denied";
|
|
5962
|
-
reason = "permission_required: denied by non-stall policy (no interactive operator in delegation context)";
|
|
5963
|
-
} else if (safetyDecisions.length > 0) {
|
|
5964
|
-
const level = this.input.autonomy ?? DEFAULT_AUTONOMY_LEVEL;
|
|
5965
|
-
const dispositions = safetyDecisions.map((candidate) => ({
|
|
5966
|
-
candidate,
|
|
5967
|
-
disposition: mapAutonomy(level, candidate.classification.actionClass, {
|
|
5968
|
-
executeRecognized: candidate.policy?.execRecognition !== "unrecognized"
|
|
5969
|
-
})
|
|
5970
|
-
}));
|
|
5971
|
-
const deniedDisposition = dispositions.find((candidate) => candidate.disposition === "deny");
|
|
5972
|
-
const askDisposition = dispositions.find((candidate) => candidate.disposition === "ask");
|
|
5973
|
-
if (deniedDisposition !== void 0) {
|
|
5974
|
-
safetyDecision = deniedDisposition.candidate;
|
|
5975
|
-
decision = "denied";
|
|
5976
|
-
reason = autonomyDenyRejection(level, mapped.tool, deniedDisposition.candidate.classification.actionClass).short;
|
|
5977
|
-
} else if (askDisposition !== void 0) {
|
|
5978
|
-
safetyDecision = askDisposition.candidate;
|
|
5979
|
-
decision = "denied";
|
|
5980
|
-
reason = `permission_required: autonomy ${level} requires approval for ${askDisposition.candidate.classification.actionClass}; denied by non-stall policy (no interactive operator in delegation context)`;
|
|
5981
|
-
} else {
|
|
5982
|
-
decision = "approved";
|
|
5983
|
-
reason = safetyDecision?.policy?.reasonCode ?? "allowed";
|
|
5984
|
-
}
|
|
5985
|
-
} else {
|
|
5986
|
-
decision = "denied";
|
|
5987
|
-
reason = "ACP tool produced no policy-evaluable arguments";
|
|
5988
|
-
}
|
|
5989
|
-
}
|
|
5990
|
-
if (decision === "approved") this.approved += 1;
|
|
5991
|
-
else this.denied += 1;
|
|
5992
|
-
const loggedSafety = logSafety(safetyDecision);
|
|
5993
|
-
const callId = toolCall?.toolCallId ?? `permission-${this.requested}`;
|
|
5994
|
-
this.log.push({
|
|
5995
|
-
callId,
|
|
5996
|
-
tool: mapped.tool,
|
|
5997
|
-
arguments: { ...mapped.args },
|
|
5998
|
-
decision,
|
|
5999
|
-
...reason !== void 0 ? { reason } : {},
|
|
6000
|
-
...loggedSafety !== void 0 ? { safetyDecision: loggedSafety } : {},
|
|
6001
|
-
durationMs: Math.round(performance2.now() - startedAt),
|
|
6002
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
6003
|
-
});
|
|
6004
|
-
if (decision === "denied" && reason?.startsWith("permission_required:")) {
|
|
6005
|
-
this.input.onPermissionResolved?.({
|
|
6006
|
-
requestId: callId,
|
|
6007
|
-
tool: mapped.tool,
|
|
6008
|
-
actionClass: safetyDecision?.classification.actionClass ?? "unknown",
|
|
6009
|
-
mode: "deny",
|
|
6010
|
-
source: "policy",
|
|
6011
|
-
reason
|
|
6012
|
-
});
|
|
6013
|
-
}
|
|
6014
|
-
return responseFor(decision, options);
|
|
6015
|
-
}
|
|
6016
|
-
snapshot() {
|
|
6017
|
-
return {
|
|
6018
|
-
toolCallsRequested: this.requested,
|
|
6019
|
-
toolCallsApproved: this.approved,
|
|
6020
|
-
toolCallsDenied: this.denied,
|
|
6021
|
-
toolCallLog: [...this.log]
|
|
6022
|
-
};
|
|
6023
|
-
}
|
|
6024
|
-
};
|
|
6025
|
-
|
|
6026
|
-
// src/engine/acp/transport.ts
|
|
6027
|
-
init_esm_shims();
|
|
6028
|
-
import { spawn } from "node:child_process";
|
|
6029
|
-
import { performance as performance3 } from "node:perf_hooks";
|
|
6030
|
-
var ACP_MAX_INPUT_LINE_BYTES = 1024 * 1024;
|
|
6031
|
-
function exceedsInputLineBytes(value) {
|
|
6032
|
-
if (value.length <= ACP_MAX_INPUT_LINE_BYTES / 3) return false;
|
|
6033
|
-
return Buffer.byteLength(value, "utf8") > ACP_MAX_INPUT_LINE_BYTES;
|
|
6034
|
-
}
|
|
6035
|
-
function isRecord7(value) {
|
|
6036
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6037
|
-
}
|
|
6038
|
-
function isSuccess(value) {
|
|
6039
|
-
return "id" in value && "result" in value;
|
|
6040
|
-
}
|
|
6041
|
-
function isFailure(value) {
|
|
6042
|
-
return "id" in value && isRecord7(value.error);
|
|
6043
|
-
}
|
|
6044
|
-
function errorMessage(value) {
|
|
6045
|
-
return value instanceof Error ? value.message : String(value);
|
|
6046
|
-
}
|
|
6047
|
-
function errorCode(value) {
|
|
6048
|
-
return isRecord7(value) && typeof value.code === "string" ? value.code : void 0;
|
|
6049
|
-
}
|
|
6050
|
-
function boundedMilliseconds(value, fallback) {
|
|
6051
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : fallback;
|
|
6052
|
-
}
|
|
6053
|
-
function validateRequestTimeout(method, timeoutMs) {
|
|
6054
|
-
if (timeoutMs === void 0) return void 0;
|
|
6055
|
-
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0 || timeoutMs > MAX_TIMER_DELAY_MS) {
|
|
6056
|
-
throw new AcpTimeoutError(`ACP request timeout must be between 1 and ${MAX_TIMER_DELAY_MS} ms: ${method}`);
|
|
6057
|
-
}
|
|
6058
|
-
return timeoutMs;
|
|
6059
|
-
}
|
|
6060
|
-
function jsonRpcError(id, code, message, data) {
|
|
6061
|
-
return {
|
|
6062
|
-
jsonrpc: "2.0",
|
|
6063
|
-
id,
|
|
6064
|
-
error: data === void 0 ? { code, message } : { code, message, data }
|
|
6065
|
-
};
|
|
6066
|
-
}
|
|
6067
|
-
function handlerErrorFrame(id, err, diagnostics) {
|
|
6068
|
-
if (err instanceof AcpRequestError) {
|
|
6069
|
-
const message = err.detail.code === "internal_error" ? ACP_INTERNAL_ERROR_MESSAGE : acpErrorMessage(err.message);
|
|
6070
|
-
return jsonRpcError(id, err.rpcCode, message, acpErrorData(err.detail));
|
|
6071
|
-
}
|
|
6072
|
-
diagnostics?.(`internal error: ${acpErrorMessage(err)}`);
|
|
6073
|
-
return jsonRpcError(id, -32e3, ACP_INTERNAL_ERROR_MESSAGE, acpErrorData({ code: "internal_error" }));
|
|
6074
|
-
}
|
|
6075
|
-
var StdioJsonRpcTransport = class {
|
|
6076
|
-
child;
|
|
6077
|
-
terminationScope = process.platform === "win32" ? "child" : "process-group";
|
|
6078
|
-
nextId = 1;
|
|
6079
|
-
buffer = "";
|
|
6080
|
-
isClosed = false;
|
|
6081
|
-
inputEnded = false;
|
|
6082
|
-
childHandlesClosed = false;
|
|
6083
|
-
forceTermination = null;
|
|
6084
|
-
terminationGraceMs;
|
|
6085
|
-
terminationWaitMs;
|
|
6086
|
-
childClosePromise;
|
|
6087
|
-
resolveChildClose = null;
|
|
6088
|
-
pending = /* @__PURE__ */ new Map();
|
|
6089
|
-
notificationHandlers = /* @__PURE__ */ new Map();
|
|
6090
|
-
requestHandlers = /* @__PURE__ */ new Map();
|
|
6091
|
-
stderrHandlers = /* @__PURE__ */ new Set();
|
|
6092
|
-
constructor(command, args, options = {}) {
|
|
6093
|
-
this.terminationGraceMs = boundedMilliseconds(options.terminationGraceMs, 500);
|
|
6094
|
-
this.terminationWaitMs = boundedMilliseconds(options.terminationWaitMs, 2e3);
|
|
6095
|
-
this.childClosePromise = new Promise((resolve11) => {
|
|
6096
|
-
this.resolveChildClose = resolve11;
|
|
6097
|
-
});
|
|
6098
|
-
const childEnvironment = buildSafeToolEnv(options.env);
|
|
6099
|
-
const attribution = withManagedGitCommitAttributionEnvironment(childEnvironment, {
|
|
6100
|
-
cwd: options.cwd ?? process.cwd(),
|
|
6101
|
-
enabled: gitCommitAttributionEnabled(process.env),
|
|
6102
|
-
evidence: { materiallyAssisted: true }
|
|
6103
|
-
});
|
|
6104
|
-
reportCommitAttributionDiagnostic(attribution.diagnostic);
|
|
6105
|
-
this.child = spawn(command, args, {
|
|
6106
|
-
cwd: options.cwd,
|
|
6107
|
-
env: attribution.env,
|
|
6108
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
6109
|
-
// POSIX detached children lead a new session/process group whose id is
|
|
6110
|
-
// the child pid. That makes negative-pid signaling safe for this owned
|
|
6111
|
-
// group. Windows detached semantics do not provide an equivalent
|
|
6112
|
-
// killable tree, so the explicit fallback there is the direct child.
|
|
6113
|
-
detached: process.platform !== "win32"
|
|
6114
|
-
});
|
|
6115
|
-
this.child.stdout.setEncoding("utf8");
|
|
6116
|
-
this.child.stderr.setEncoding("utf8");
|
|
6117
|
-
this.child.stdout.on("data", (chunk) => this.consumeStdout(chunk));
|
|
6118
|
-
this.child.stderr.on("data", (chunk) => {
|
|
6119
|
-
for (const handler of this.stderrHandlers) handler(chunk);
|
|
6120
|
-
});
|
|
6121
|
-
this.child.on("error", (err) => {
|
|
6122
|
-
this.closeChannel(new AcpProcessError(`ACP process error: ${errorMessage(err)}`));
|
|
6123
|
-
});
|
|
6124
|
-
this.child.on("exit", (code, signal) => {
|
|
6125
|
-
this.isClosed = true;
|
|
6126
|
-
if (this.pending.size === 0) return;
|
|
6127
|
-
const reason = new AcpProcessError(
|
|
6128
|
-
`ACP process exited before replying (code=${code ?? "null"}, signal=${signal ?? "null"})`
|
|
6129
|
-
);
|
|
6130
|
-
this.failAll(reason);
|
|
6131
|
-
});
|
|
6132
|
-
this.child.on("close", () => {
|
|
6133
|
-
this.childHandlesClosed = true;
|
|
6134
|
-
this.isClosed = true;
|
|
6135
|
-
this.resolveChildClose?.();
|
|
6136
|
-
this.resolveChildClose = null;
|
|
6137
|
-
});
|
|
6138
|
-
this.child.stdin.on("error", (err) => {
|
|
6139
|
-
if (!this.isClosed) this.closeChannel(new AcpProcessError(`ACP stdin error: ${errorMessage(err)}`));
|
|
6140
|
-
});
|
|
6141
|
-
}
|
|
6142
|
-
get closed() {
|
|
6143
|
-
return this.isClosed || this.child.exitCode !== null || this.child.signalCode !== null;
|
|
6144
|
-
}
|
|
6145
|
-
get pid() {
|
|
6146
|
-
return this.child.pid ?? null;
|
|
6147
|
-
}
|
|
6148
|
-
request(method, params, timeoutMs) {
|
|
6149
|
-
if (this.closed) throw new AcpProcessError(`ACP process is closed; cannot request ${method}`);
|
|
6150
|
-
const requestTimeoutMs = validateRequestTimeout(method, timeoutMs);
|
|
6151
|
-
const id = this.nextId++;
|
|
6152
|
-
const message = { jsonrpc: "2.0", id, method, params };
|
|
6153
|
-
const promise = new Promise((resolve11, reject) => {
|
|
6154
|
-
const pending = {
|
|
6155
|
-
method,
|
|
6156
|
-
resolve: (value) => resolve11(value),
|
|
6157
|
-
reject
|
|
6158
|
-
};
|
|
6159
|
-
if (requestTimeoutMs !== void 0) {
|
|
6160
|
-
pending.timer = setTimeout(() => {
|
|
6161
|
-
this.pending.delete(id);
|
|
6162
|
-
reject(new AcpTimeoutError(`ACP request timed out after ${requestTimeoutMs}ms: ${method}`));
|
|
6163
|
-
}, requestTimeoutMs);
|
|
6164
|
-
}
|
|
6165
|
-
this.pending.set(id, pending);
|
|
6166
|
-
});
|
|
6167
|
-
this.write(message);
|
|
6168
|
-
return promise;
|
|
6169
|
-
}
|
|
6170
|
-
notify(method, params) {
|
|
6171
|
-
if (this.closed) return;
|
|
6172
|
-
this.write({ jsonrpc: "2.0", method, params });
|
|
6173
|
-
}
|
|
6174
|
-
onNotification(method, handler) {
|
|
6175
|
-
const handlers = this.notificationHandlers.get(method) ?? /* @__PURE__ */ new Set();
|
|
6176
|
-
handlers.add(handler);
|
|
6177
|
-
this.notificationHandlers.set(method, handlers);
|
|
6178
|
-
return () => {
|
|
6179
|
-
handlers.delete(handler);
|
|
6180
|
-
};
|
|
6181
|
-
}
|
|
6182
|
-
onRequest(method, handler) {
|
|
6183
|
-
this.requestHandlers.set(method, handler);
|
|
6184
|
-
return () => {
|
|
6185
|
-
if (this.requestHandlers.get(method) === handler) this.requestHandlers.delete(method);
|
|
6186
|
-
};
|
|
6187
|
-
}
|
|
6188
|
-
onStderr(handler) {
|
|
6189
|
-
this.stderrHandlers.add(handler);
|
|
6190
|
-
return () => {
|
|
6191
|
-
this.stderrHandlers.delete(handler);
|
|
6192
|
-
};
|
|
6193
|
-
}
|
|
6194
|
-
close() {
|
|
6195
|
-
this.closeChannel(new AcpProcessError("ACP transport closed"));
|
|
6196
|
-
}
|
|
6197
|
-
terminate() {
|
|
6198
|
-
this.closeChannel(new AcpProcessError("ACP transport terminated"));
|
|
6199
|
-
this.signalOwnedScope("SIGTERM");
|
|
6200
|
-
}
|
|
6201
|
-
forceTerminate() {
|
|
6202
|
-
if (this.forceTermination !== null) return this.forceTermination;
|
|
6203
|
-
this.forceTermination = this.runForceTermination();
|
|
6204
|
-
return this.forceTermination;
|
|
6205
|
-
}
|
|
6206
|
-
waitForExit(timeoutMs) {
|
|
6207
|
-
return this.waitForTermination(boundedMilliseconds(timeoutMs, 0));
|
|
6208
|
-
}
|
|
6209
|
-
write(message) {
|
|
6210
|
-
if (this.closed || !this.child.stdin.writable || this.child.stdin.destroyed) return;
|
|
6211
|
-
try {
|
|
6212
|
-
this.child.stdin.write(`${JSON.stringify(message)}
|
|
6213
|
-
`);
|
|
6214
|
-
} catch (err) {
|
|
6215
|
-
this.closeChannel(new AcpProcessError(`ACP stdin write failed: ${errorMessage(err)}`));
|
|
6216
|
-
}
|
|
6217
|
-
}
|
|
6218
|
-
consumeStdout(chunk) {
|
|
6219
|
-
this.buffer += chunk;
|
|
6220
|
-
for (; ; ) {
|
|
6221
|
-
const idx = this.buffer.indexOf("\n");
|
|
6222
|
-
if (idx === -1) break;
|
|
6223
|
-
const line = this.buffer.slice(0, idx).trimEnd();
|
|
6224
|
-
this.buffer = this.buffer.slice(idx + 1);
|
|
6225
|
-
if (line.length === 0) continue;
|
|
6226
|
-
this.handleLine(line);
|
|
6227
|
-
}
|
|
6228
|
-
}
|
|
6229
|
-
handleLine(line) {
|
|
6230
|
-
const trimmed = line.trimStart();
|
|
6231
|
-
if (!trimmed.startsWith("{")) {
|
|
6232
|
-
return;
|
|
6233
|
-
}
|
|
6234
|
-
let parsed;
|
|
6235
|
-
try {
|
|
6236
|
-
parsed = JSON.parse(trimmed);
|
|
6237
|
-
} catch (err) {
|
|
6238
|
-
this.failAll(new AcpProtocolError(`ACP stdout contained invalid JSON: ${errorMessage(err)}`, { line }));
|
|
6239
|
-
return;
|
|
6240
|
-
}
|
|
6241
|
-
if (!isRecord7(parsed) || parsed.jsonrpc !== "2.0") {
|
|
6242
|
-
return;
|
|
6243
|
-
}
|
|
6244
|
-
if (isSuccess(parsed) || isFailure(parsed)) {
|
|
6245
|
-
this.handleResponse(parsed);
|
|
6246
|
-
return;
|
|
6247
|
-
}
|
|
6248
|
-
const method = typeof parsed.method === "string" ? parsed.method : "";
|
|
6249
|
-
if (!method) {
|
|
6250
|
-
this.failAll(new AcpProtocolError("ACP request/notification missing method", parsed));
|
|
6251
|
-
return;
|
|
6252
|
-
}
|
|
6253
|
-
if ("id" in parsed) {
|
|
6254
|
-
void this.handleIncomingRequest(parsed.id, method, parsed.params);
|
|
6255
|
-
return;
|
|
6256
|
-
}
|
|
6257
|
-
const handlers = this.notificationHandlers.get(method);
|
|
6258
|
-
if (!handlers) return;
|
|
6259
|
-
for (const handler of handlers) handler(parsed.params);
|
|
6260
|
-
}
|
|
6261
|
-
handleResponse(message) {
|
|
6262
|
-
const pending = this.pending.get(message.id ?? "");
|
|
6263
|
-
if (!pending) return;
|
|
6264
|
-
this.pending.delete(message.id ?? "");
|
|
6265
|
-
if (pending.timer) clearTimeout(pending.timer);
|
|
6266
|
-
if ("error" in message) {
|
|
6267
|
-
pending.reject(new AcpProtocolError(`ACP ${pending.method} failed: ${message.error.message}`, message.error));
|
|
6268
|
-
return;
|
|
6269
|
-
}
|
|
6270
|
-
pending.resolve(message.result);
|
|
6271
|
-
}
|
|
6272
|
-
async handleIncomingRequest(id, method, params) {
|
|
6273
|
-
const handler = this.requestHandlers.get(method);
|
|
6274
|
-
if (!handler) {
|
|
6275
|
-
this.write({
|
|
6276
|
-
jsonrpc: "2.0",
|
|
6277
|
-
id,
|
|
6278
|
-
error: { code: -32601, message: `method not found: ${method}` }
|
|
6279
|
-
});
|
|
6280
|
-
return;
|
|
6281
|
-
}
|
|
6282
|
-
try {
|
|
6283
|
-
const result = await handler(params);
|
|
6284
|
-
this.write({ jsonrpc: "2.0", id, result });
|
|
6285
|
-
} catch (err) {
|
|
6286
|
-
this.write(handlerErrorFrame(id, err));
|
|
6287
|
-
}
|
|
6288
|
-
}
|
|
6289
|
-
closeChannel(reason) {
|
|
6290
|
-
if (!this.isClosed) {
|
|
6291
|
-
this.isClosed = true;
|
|
6292
|
-
this.failAll(reason);
|
|
6293
|
-
}
|
|
6294
|
-
if (this.inputEnded) return;
|
|
6295
|
-
this.inputEnded = true;
|
|
6296
|
-
try {
|
|
6297
|
-
this.child.stdin.end();
|
|
6298
|
-
} catch {
|
|
6299
|
-
}
|
|
6300
|
-
}
|
|
6301
|
-
directChildAlive() {
|
|
6302
|
-
return !this.childHandlesClosed && this.child.exitCode === null && this.child.signalCode === null;
|
|
6303
|
-
}
|
|
6304
|
-
processGroupAlive() {
|
|
6305
|
-
if (this.terminationScope !== "process-group") return this.directChildAlive();
|
|
6306
|
-
const pid = this.pid;
|
|
6307
|
-
if (pid === null) return this.directChildAlive();
|
|
6308
|
-
try {
|
|
6309
|
-
process.kill(-pid, 0);
|
|
6310
|
-
return true;
|
|
6311
|
-
} catch (err) {
|
|
6312
|
-
const code = errorCode(err);
|
|
6313
|
-
if (code === "ESRCH") return false;
|
|
6314
|
-
return true;
|
|
6315
|
-
}
|
|
6316
|
-
}
|
|
6317
|
-
terminationObserved() {
|
|
6318
|
-
return this.childHandlesClosed && !this.processGroupAlive();
|
|
6319
|
-
}
|
|
6320
|
-
signalOwnedScope(signal) {
|
|
6321
|
-
const pid = this.pid;
|
|
6322
|
-
if (this.terminationScope === "process-group" && pid !== null) {
|
|
6323
|
-
try {
|
|
6324
|
-
process.kill(-pid, signal);
|
|
6325
|
-
return true;
|
|
6326
|
-
} catch {
|
|
6327
|
-
}
|
|
6328
|
-
}
|
|
6329
|
-
if (!this.directChildAlive()) return false;
|
|
6330
|
-
try {
|
|
6331
|
-
return this.child.kill(signal);
|
|
6332
|
-
} catch {
|
|
6333
|
-
return false;
|
|
6334
|
-
}
|
|
6335
|
-
}
|
|
6336
|
-
async waitForTermination(timeoutMs) {
|
|
6337
|
-
const deadline = performance3.now() + timeoutMs;
|
|
6338
|
-
while (!this.terminationObserved()) {
|
|
6339
|
-
const remaining = deadline - performance3.now();
|
|
6340
|
-
if (remaining <= 0) return this.terminationObserved();
|
|
6341
|
-
const interval = Math.min(10, remaining);
|
|
6342
|
-
if (this.childHandlesClosed) {
|
|
6343
|
-
await new Promise((resolve11) => setTimeout(resolve11, interval));
|
|
6344
|
-
} else {
|
|
6345
|
-
await Promise.race([this.childClosePromise, new Promise((resolve11) => setTimeout(resolve11, interval))]);
|
|
6346
|
-
}
|
|
6347
|
-
}
|
|
6348
|
-
return true;
|
|
6349
|
-
}
|
|
6350
|
-
async runForceTermination() {
|
|
6351
|
-
this.closeChannel(new AcpProcessError("ACP transport force-terminated"));
|
|
6352
|
-
if (this.terminationObserved()) {
|
|
6353
|
-
return { exited: true, escalated: false, scope: this.terminationScope };
|
|
6354
|
-
}
|
|
6355
|
-
this.signalOwnedScope("SIGTERM");
|
|
6356
|
-
if (await this.waitForExit(this.terminationGraceMs)) {
|
|
6357
|
-
return { exited: true, escalated: false, scope: this.terminationScope };
|
|
6358
|
-
}
|
|
6359
|
-
const escalated = this.signalOwnedScope("SIGKILL");
|
|
6360
|
-
const exited = await this.waitForExit(this.terminationWaitMs);
|
|
6361
|
-
return { exited, escalated, scope: this.terminationScope };
|
|
6362
|
-
}
|
|
6363
|
-
failAll(reason) {
|
|
6364
|
-
for (const [id, pending] of this.pending.entries()) {
|
|
6365
|
-
if (pending.timer) clearTimeout(pending.timer);
|
|
6366
|
-
pending.reject(reason);
|
|
6367
|
-
this.pending.delete(id);
|
|
6368
|
-
}
|
|
6369
|
-
}
|
|
6370
|
-
};
|
|
6371
|
-
function createStdioTransport(command, args = [], options = {}) {
|
|
6372
|
-
if (command.trim().length === 0) {
|
|
6373
|
-
throw new AcpProcessError("ACP stdio command must not be empty");
|
|
6374
|
-
}
|
|
6375
|
-
return new StdioJsonRpcTransport(command, args, options);
|
|
6376
|
-
}
|
|
6377
|
-
var StreamJsonRpcPeerTransport = class {
|
|
6378
|
-
outputPaused = false;
|
|
6379
|
-
queuedOutputBytes = 0;
|
|
6380
|
-
sinkOutputBytes = 0;
|
|
6381
|
-
outputQueue = [];
|
|
6382
|
-
nextId = 1;
|
|
6383
|
-
buffer = "";
|
|
6384
|
-
/** True while the bytes of an oversized line are being dropped up to its terminating newline. */
|
|
6385
|
-
discardingLine = false;
|
|
6386
|
-
isClosed = false;
|
|
6387
|
-
pending = /* @__PURE__ */ new Map();
|
|
6388
|
-
notificationHandlers = /* @__PURE__ */ new Map();
|
|
6389
|
-
requestHandlers = /* @__PURE__ */ new Map();
|
|
6390
|
-
closeHandlers = /* @__PURE__ */ new Set();
|
|
6391
|
-
input;
|
|
6392
|
-
output;
|
|
6393
|
-
writeOverride;
|
|
6394
|
-
diagnostics;
|
|
6395
|
-
constructor(options = {}) {
|
|
6396
|
-
this.input = options.input ?? process.stdin;
|
|
6397
|
-
this.output = options.output ?? process.stdout;
|
|
6398
|
-
if (options.write !== void 0) this.writeOverride = options.write;
|
|
6399
|
-
if (options.diagnostics !== void 0) this.diagnostics = options.diagnostics;
|
|
6400
|
-
this.input.setEncoding("utf8");
|
|
6401
|
-
this.input.on("data", (chunk) => this.consume(chunk));
|
|
6402
|
-
this.input.on("end", () => this.markClosed(new AcpProcessError("ACP input closed")));
|
|
6403
|
-
this.input.on("error", (err) => this.markClosed(new AcpProcessError(`ACP input error: ${errorMessage(err)}`)));
|
|
6404
|
-
this.output.on?.("error", (err) => this.markClosed(new AcpProcessError(`ACP output error: ${errorMessage(err)}`)));
|
|
6405
|
-
}
|
|
6406
|
-
get closed() {
|
|
6407
|
-
return this.isClosed;
|
|
6408
|
-
}
|
|
6409
|
-
request(method, params, timeoutMs) {
|
|
6410
|
-
if (this.closed) throw new AcpProcessError(`ACP transport is closed; cannot request ${method}`);
|
|
6411
|
-
const requestTimeoutMs = validateRequestTimeout(method, timeoutMs);
|
|
6412
|
-
const id = this.nextId++;
|
|
6413
|
-
const message = { jsonrpc: "2.0", id, method, params };
|
|
6414
|
-
const promise = new Promise((resolve11, reject) => {
|
|
6415
|
-
const pending = {
|
|
6416
|
-
method,
|
|
6417
|
-
resolve: (value) => resolve11(value),
|
|
6418
|
-
reject
|
|
6419
|
-
};
|
|
6420
|
-
if (requestTimeoutMs !== void 0) {
|
|
6421
|
-
pending.timer = setTimeout(() => {
|
|
6422
|
-
this.pending.delete(id);
|
|
6423
|
-
reject(new AcpTimeoutError(`ACP request timed out after ${requestTimeoutMs}ms: ${method}`));
|
|
6424
|
-
}, requestTimeoutMs);
|
|
6425
|
-
}
|
|
6426
|
-
this.pending.set(id, pending);
|
|
6427
|
-
});
|
|
6428
|
-
this.write(message);
|
|
6429
|
-
return promise;
|
|
6430
|
-
}
|
|
6431
|
-
notify(method, params) {
|
|
6432
|
-
if (this.closed) return;
|
|
6433
|
-
this.write({ jsonrpc: "2.0", method, params });
|
|
6434
|
-
}
|
|
6435
|
-
onNotification(method, handler) {
|
|
6436
|
-
const handlers = this.notificationHandlers.get(method) ?? /* @__PURE__ */ new Set();
|
|
6437
|
-
handlers.add(handler);
|
|
6438
|
-
this.notificationHandlers.set(method, handlers);
|
|
6439
|
-
return () => {
|
|
6440
|
-
handlers.delete(handler);
|
|
6441
|
-
};
|
|
6442
|
-
}
|
|
6443
|
-
onRequest(method, handler) {
|
|
6444
|
-
this.requestHandlers.set(method, handler);
|
|
6445
|
-
return () => {
|
|
6446
|
-
if (this.requestHandlers.get(method) === handler) this.requestHandlers.delete(method);
|
|
6447
|
-
};
|
|
6448
|
-
}
|
|
6449
|
-
onClose(handler) {
|
|
6450
|
-
this.closeHandlers.add(handler);
|
|
6451
|
-
return () => {
|
|
6452
|
-
this.closeHandlers.delete(handler);
|
|
6453
|
-
};
|
|
6454
|
-
}
|
|
6455
|
-
close() {
|
|
6456
|
-
this.markClosed(new AcpProcessError("ACP transport closed"));
|
|
6457
|
-
}
|
|
6458
|
-
write(message) {
|
|
6459
|
-
if (this.closed) return;
|
|
6460
|
-
const line = `${JSON.stringify(message)}
|
|
6461
|
-
`;
|
|
6462
|
-
if (this.outputPaused) {
|
|
6463
|
-
const bytes = Buffer.byteLength(line, "utf8");
|
|
6464
|
-
if (this.queuedOutputBytes + this.sinkOutputBytes + bytes > ACP_MAX_INPUT_LINE_BYTES) {
|
|
6465
|
-
this.markClosed(new AcpProcessError("ACP output buffer exceeded byte limit"));
|
|
6466
|
-
return;
|
|
6467
|
-
}
|
|
6468
|
-
}
|
|
6469
|
-
this.outputQueue.push(line);
|
|
6470
|
-
this.queuedOutputBytes += Buffer.byteLength(line, "utf8");
|
|
6471
|
-
if (!this.outputPaused) this.flushOutput();
|
|
6472
|
-
}
|
|
6473
|
-
flushOutput = () => {
|
|
6474
|
-
this.outputPaused = false;
|
|
6475
|
-
while (!this.closed && !this.outputPaused && this.outputQueue.length > 0) {
|
|
6476
|
-
const line = this.outputQueue.shift();
|
|
6477
|
-
if (line === void 0) break;
|
|
6478
|
-
this.queuedOutputBytes -= Buffer.byteLength(line, "utf8");
|
|
6479
|
-
try {
|
|
6480
|
-
this.sinkOutputBytes = Math.min(this.sinkOutputBytes, this.output.writableLength * 3);
|
|
6481
|
-
let ready;
|
|
6482
|
-
if (this.writeOverride) {
|
|
6483
|
-
this.writeOverride(line);
|
|
6484
|
-
ready = !this.output.writableNeedDrain;
|
|
5890
|
+
} else if (!mapped.known) {
|
|
5891
|
+
decision = "denied";
|
|
5892
|
+
reason = `unknown ACP tool: ${mapped.displayTool}`;
|
|
5893
|
+
} else {
|
|
5894
|
+
const safetyDecisions = mapped.evaluations.map(
|
|
5895
|
+
(evaluation) => this.input.safety.evaluate({ tool: evaluation.tool, args: evaluation.args })
|
|
5896
|
+
);
|
|
5897
|
+
const blocking = safetyDecisions.find((candidate) => candidate.kind === "block");
|
|
5898
|
+
const asking = safetyDecisions.find((candidate) => candidate.kind === "ask");
|
|
5899
|
+
safetyDecision = blocking ?? asking ?? safetyDecisions[0];
|
|
5900
|
+
if (blocking !== void 0) {
|
|
5901
|
+
decision = "denied";
|
|
5902
|
+
reason = blocking.policy?.reasonCode ?? blocking.kind;
|
|
5903
|
+
} else if (asking !== void 0) {
|
|
5904
|
+
decision = "denied";
|
|
5905
|
+
reason = "permission_required: denied by non-stall policy (no interactive operator in delegation context)";
|
|
5906
|
+
} else if (safetyDecisions.length > 0) {
|
|
5907
|
+
const level = this.input.autonomy ?? DEFAULT_AUTONOMY_LEVEL;
|
|
5908
|
+
const dispositions = safetyDecisions.map((candidate) => ({
|
|
5909
|
+
candidate,
|
|
5910
|
+
disposition: mapAutonomy(level, candidate.classification.actionClass, {
|
|
5911
|
+
executeRecognized: candidate.policy?.execRecognition !== "unrecognized"
|
|
5912
|
+
})
|
|
5913
|
+
}));
|
|
5914
|
+
const deniedDisposition = dispositions.find((candidate) => candidate.disposition === "deny");
|
|
5915
|
+
const askDisposition = dispositions.find((candidate) => candidate.disposition === "ask");
|
|
5916
|
+
if (deniedDisposition !== void 0) {
|
|
5917
|
+
safetyDecision = deniedDisposition.candidate;
|
|
5918
|
+
decision = "denied";
|
|
5919
|
+
reason = autonomyDenyRejection(level, mapped.tool, deniedDisposition.candidate.classification.actionClass).short;
|
|
5920
|
+
} else if (askDisposition !== void 0) {
|
|
5921
|
+
safetyDecision = askDisposition.candidate;
|
|
5922
|
+
decision = "denied";
|
|
5923
|
+
reason = `permission_required: autonomy ${level} requires approval for ${askDisposition.candidate.classification.actionClass}; denied by non-stall policy (no interactive operator in delegation context)`;
|
|
6485
5924
|
} else {
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
this.sinkOutputBytes = this.output.writableLength === 0 ? 0 : this.sinkOutputBytes + Buffer.byteLength(line, "utf8");
|
|
6489
|
-
if (!ready && !this.closed) {
|
|
6490
|
-
if (this.queuedOutputBytes + this.sinkOutputBytes > ACP_MAX_INPUT_LINE_BYTES) {
|
|
6491
|
-
this.markClosed(new AcpProcessError("ACP output buffer exceeded byte limit"));
|
|
6492
|
-
return;
|
|
6493
|
-
}
|
|
6494
|
-
this.outputPaused = true;
|
|
6495
|
-
this.output.once("drain", this.flushOutput);
|
|
5925
|
+
decision = "approved";
|
|
5926
|
+
reason = safetyDecision?.policy?.reasonCode ?? "allowed";
|
|
6496
5927
|
}
|
|
6497
|
-
}
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
}
|
|
6501
|
-
};
|
|
6502
|
-
consume(chunk) {
|
|
6503
|
-
this.buffer += chunk;
|
|
6504
|
-
for (; ; ) {
|
|
6505
|
-
const idx = this.buffer.indexOf("\n");
|
|
6506
|
-
if (idx === -1) break;
|
|
6507
|
-
const line = this.buffer.slice(0, idx).trimEnd();
|
|
6508
|
-
this.buffer = this.buffer.slice(idx + 1);
|
|
6509
|
-
if (this.discardingLine) {
|
|
6510
|
-
this.discardingLine = false;
|
|
6511
|
-
continue;
|
|
6512
|
-
}
|
|
6513
|
-
if (line.length === 0) continue;
|
|
6514
|
-
if (exceedsInputLineBytes(line)) {
|
|
6515
|
-
this.reportOversizedLine();
|
|
6516
|
-
continue;
|
|
6517
|
-
}
|
|
6518
|
-
this.handleLine(line);
|
|
6519
|
-
}
|
|
6520
|
-
if (this.discardingLine) {
|
|
6521
|
-
this.buffer = "";
|
|
6522
|
-
return;
|
|
6523
|
-
}
|
|
6524
|
-
if (exceedsInputLineBytes(this.buffer)) {
|
|
6525
|
-
this.buffer = "";
|
|
6526
|
-
this.discardingLine = true;
|
|
6527
|
-
this.reportOversizedLine();
|
|
6528
|
-
}
|
|
6529
|
-
}
|
|
6530
|
-
/** One error frame per oversized line. The transport stays open and parseable. */
|
|
6531
|
-
reportOversizedLine() {
|
|
6532
|
-
this.write(
|
|
6533
|
-
jsonRpcError(null, -32600, "input line exceeds the maximum size", acpErrorData({ code: "input_line_too_large" }))
|
|
6534
|
-
);
|
|
6535
|
-
}
|
|
6536
|
-
handleLine(line) {
|
|
6537
|
-
let parsed;
|
|
6538
|
-
try {
|
|
6539
|
-
parsed = JSON.parse(line);
|
|
6540
|
-
} catch {
|
|
6541
|
-
this.write(jsonRpcError(null, -32700, "parse error", acpErrorData({ code: "parse_error" })));
|
|
6542
|
-
return;
|
|
6543
|
-
}
|
|
6544
|
-
if (!isRecord7(parsed) || parsed.jsonrpc !== "2.0") {
|
|
6545
|
-
this.write(jsonRpcError(null, -32600, "invalid JSON-RPC message", acpErrorData({ code: "invalid_request" })));
|
|
6546
|
-
return;
|
|
6547
|
-
}
|
|
6548
|
-
if (isSuccess(parsed) || isFailure(parsed)) {
|
|
6549
|
-
this.handleResponse(parsed);
|
|
6550
|
-
return;
|
|
6551
|
-
}
|
|
6552
|
-
const method = typeof parsed.method === "string" ? parsed.method : "";
|
|
6553
|
-
const id = "id" in parsed ? parsed.id : void 0;
|
|
6554
|
-
if (!method) {
|
|
6555
|
-
if (id !== void 0) {
|
|
6556
|
-
this.write(
|
|
6557
|
-
jsonRpcError(id, -32600, "request/notification missing method", acpErrorData({ code: "invalid_request" }))
|
|
6558
|
-
);
|
|
5928
|
+
} else {
|
|
5929
|
+
decision = "denied";
|
|
5930
|
+
reason = "ACP tool produced no policy-evaluable arguments";
|
|
6559
5931
|
}
|
|
6560
|
-
return;
|
|
6561
|
-
}
|
|
6562
|
-
if (id !== void 0) {
|
|
6563
|
-
void this.handleRequest(id, method, parsed.params);
|
|
6564
|
-
return;
|
|
6565
5932
|
}
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
return;
|
|
6590
|
-
}
|
|
6591
|
-
try {
|
|
6592
|
-
const result = await handler(params);
|
|
6593
|
-
this.write({ jsonrpc: "2.0", id, result });
|
|
6594
|
-
} catch (err) {
|
|
6595
|
-
this.write(handlerErrorFrame(id, err, this.diagnostics));
|
|
5933
|
+
if (decision === "approved") this.approved += 1;
|
|
5934
|
+
else this.denied += 1;
|
|
5935
|
+
const loggedSafety = logSafety(safetyDecision);
|
|
5936
|
+
const callId = toolCall?.toolCallId ?? `permission-${this.requested}`;
|
|
5937
|
+
this.log.push({
|
|
5938
|
+
callId,
|
|
5939
|
+
tool: mapped.tool,
|
|
5940
|
+
arguments: { ...mapped.args },
|
|
5941
|
+
decision,
|
|
5942
|
+
...reason !== void 0 ? { reason } : {},
|
|
5943
|
+
...loggedSafety !== void 0 ? { safetyDecision: loggedSafety } : {},
|
|
5944
|
+
durationMs: Math.round(performance2.now() - startedAt),
|
|
5945
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
5946
|
+
});
|
|
5947
|
+
if (decision === "denied" && reason?.startsWith("permission_required:")) {
|
|
5948
|
+
this.input.onPermissionResolved?.({
|
|
5949
|
+
requestId: callId,
|
|
5950
|
+
tool: mapped.tool,
|
|
5951
|
+
actionClass: safetyDecision?.classification.actionClass ?? "unknown",
|
|
5952
|
+
mode: "deny",
|
|
5953
|
+
source: "policy",
|
|
5954
|
+
reason
|
|
5955
|
+
});
|
|
6596
5956
|
}
|
|
5957
|
+
return responseFor(decision, options);
|
|
6597
5958
|
}
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
for (const handler of this.closeHandlers) handler();
|
|
6606
|
-
}
|
|
6607
|
-
failAll(reason) {
|
|
6608
|
-
for (const [id, pending] of this.pending.entries()) {
|
|
6609
|
-
if (pending.timer) clearTimeout(pending.timer);
|
|
6610
|
-
pending.reject(reason);
|
|
6611
|
-
this.pending.delete(id);
|
|
6612
|
-
}
|
|
5959
|
+
snapshot() {
|
|
5960
|
+
return {
|
|
5961
|
+
toolCallsRequested: this.requested,
|
|
5962
|
+
toolCallsApproved: this.approved,
|
|
5963
|
+
toolCallsDenied: this.denied,
|
|
5964
|
+
toolCallLog: [...this.log]
|
|
5965
|
+
};
|
|
6613
5966
|
}
|
|
6614
5967
|
};
|
|
6615
|
-
function createStdioServerTransport(options = {}) {
|
|
6616
|
-
return new StreamJsonRpcPeerTransport(options);
|
|
6617
|
-
}
|
|
6618
5968
|
|
|
6619
5969
|
// src/engine/acp/types.ts
|
|
6620
5970
|
init_esm_shims();
|
|
@@ -6659,22 +6009,22 @@ var AsyncEventQueue = class {
|
|
|
6659
6009
|
}
|
|
6660
6010
|
}
|
|
6661
6011
|
};
|
|
6662
|
-
function
|
|
6012
|
+
function isRecord7(value) {
|
|
6663
6013
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6664
6014
|
}
|
|
6665
6015
|
function sessionIdFrom(value) {
|
|
6666
6016
|
if (typeof value === "string" && value.length > 0) return value;
|
|
6667
|
-
if (!
|
|
6017
|
+
if (!isRecord7(value)) return null;
|
|
6668
6018
|
const sessionId = value.sessionId ?? value.id;
|
|
6669
6019
|
return typeof sessionId === "string" && sessionId.length > 0 ? sessionId : null;
|
|
6670
6020
|
}
|
|
6671
6021
|
function supportsSessionClose(init) {
|
|
6672
6022
|
const caps = init?.agentCapabilities;
|
|
6673
|
-
if (!
|
|
6674
|
-
const meta =
|
|
6675
|
-
if (
|
|
6023
|
+
if (!isRecord7(caps)) return false;
|
|
6024
|
+
const meta = isRecord7(caps._meta) ? caps._meta[ACP_SESSION_META_KEY] : void 0;
|
|
6025
|
+
if (isRecord7(meta) && meta.close === true) return true;
|
|
6676
6026
|
const sessionCaps = caps.sessionCapabilities;
|
|
6677
|
-
return
|
|
6027
|
+
return isRecord7(sessionCaps) && isRecord7(sessionCaps.close);
|
|
6678
6028
|
}
|
|
6679
6029
|
function flattenPrompt(input) {
|
|
6680
6030
|
const parts = [
|
|
@@ -6704,7 +6054,7 @@ function nonnegative(value) {
|
|
|
6704
6054
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
6705
6055
|
}
|
|
6706
6056
|
function mergeUsage(into, raw) {
|
|
6707
|
-
if (!
|
|
6057
|
+
if (!isRecord7(raw)) return;
|
|
6708
6058
|
const tokensReported = [
|
|
6709
6059
|
raw.input,
|
|
6710
6060
|
raw.inputTokens,
|
|
@@ -6736,7 +6086,7 @@ function mergeUsage(into, raw) {
|
|
|
6736
6086
|
into.reasoningTokens += finite(raw.reasoning) + finite(raw.reasoningTokens) + finite(raw.reasoning_tokens);
|
|
6737
6087
|
const explicitTotal = nonnegative(raw.totalTokens) ?? nonnegative(raw.total_tokens);
|
|
6738
6088
|
into.totalTokens += explicitTotal ?? input + output + cacheRead + cacheWrite;
|
|
6739
|
-
const cost = (
|
|
6089
|
+
const cost = (isRecord7(raw.cost) ? nonnegative(raw.cost.total) : void 0) ?? nonnegative(raw.costUsd);
|
|
6740
6090
|
into.costUsd += cost ?? 0;
|
|
6741
6091
|
if (tokensReported || cost !== void 0) {
|
|
6742
6092
|
const provenance = cost === void 0 ? "unknown" : resolveCostProvenance(raw.costProvenance, "unknown");
|
|
@@ -6747,7 +6097,7 @@ function mergeUsage(into, raw) {
|
|
|
6747
6097
|
else into.costProvenance = "known";
|
|
6748
6098
|
}
|
|
6749
6099
|
}
|
|
6750
|
-
function
|
|
6100
|
+
function errorMessage(value) {
|
|
6751
6101
|
return value instanceof Error ? value.message : String(value);
|
|
6752
6102
|
}
|
|
6753
6103
|
function cancelGraceMs(value) {
|
|
@@ -6767,7 +6117,7 @@ function startAcpDelegationRun(input) {
|
|
|
6767
6117
|
const connectTimeoutMs = input.agent.connectTimeoutMs ?? DEFAULT_DELEGATION_CONNECT_TIMEOUT_MS;
|
|
6768
6118
|
const turnTimeoutMs = input.agent.turnTimeoutMs ?? DEFAULT_DELEGATION_TURN_TIMEOUT_MS;
|
|
6769
6119
|
const now = input.now ?? Date.now;
|
|
6770
|
-
const monotonicNow = input.monotonicNow ?? (() =>
|
|
6120
|
+
const monotonicNow = input.monotonicNow ?? (() => performance3.now());
|
|
6771
6121
|
const heartbeatWallAnchor = now();
|
|
6772
6122
|
const heartbeatMonotonicAnchor = monotonicNow();
|
|
6773
6123
|
const heartbeatAt = {
|
|
@@ -6886,7 +6236,7 @@ function startAcpDelegationRun(input) {
|
|
|
6886
6236
|
},
|
|
6887
6237
|
turnTimeoutMs === 0 ? void 0 : turnTimeoutMs
|
|
6888
6238
|
);
|
|
6889
|
-
const metaUsage =
|
|
6239
|
+
const metaUsage = isRecord7(promptResponse?._meta) ? promptResponse._meta[ACP_USAGE_META_KEY] : void 0;
|
|
6890
6240
|
if (metaUsage !== void 0) {
|
|
6891
6241
|
mergeUsage(usage, metaUsage);
|
|
6892
6242
|
} else {
|
|
@@ -6912,7 +6262,7 @@ function startAcpDelegationRun(input) {
|
|
|
6912
6262
|
};
|
|
6913
6263
|
} catch (err) {
|
|
6914
6264
|
const termination = await beginForceTermination();
|
|
6915
|
-
const baseMessage = `ACP delegation failed: ${
|
|
6265
|
+
const baseMessage = `ACP delegation failed: ${errorMessage(err)}`;
|
|
6916
6266
|
const message = termination.exited ? baseMessage : `${baseMessage}; ACP ${termination.scope} exit was not observed within the force-termination bound`;
|
|
6917
6267
|
for (const event of errorEvents(message)) emit(event);
|
|
6918
6268
|
const toolSnapshot = mediator.snapshot();
|
|
@@ -7076,26 +6426,33 @@ function renderToolContractBlock(inputs) {
|
|
|
7076
6426
|
"This target cannot call tools; answer from the visible user request and compact context only."
|
|
7077
6427
|
].join("\n");
|
|
7078
6428
|
}
|
|
7079
|
-
const
|
|
6429
|
+
const capabilityNames = [
|
|
7080
6430
|
...new Set((inputs.toolNames ?? []).map((name2) => name2.trim()).filter((name2) => name2.length > 0))
|
|
7081
6431
|
].sort();
|
|
6432
|
+
const names = directSurfaceNames(capabilityNames).sort();
|
|
7082
6433
|
const canDispatch = sessionCanDispatch(inputs);
|
|
7083
6434
|
const canListSkills = sessionHasContext(inputs);
|
|
7084
6435
|
const admitted = new Set(names);
|
|
6436
|
+
const hasGateway = admitted.has("gateway");
|
|
7085
6437
|
const inventoryGuidance = [
|
|
7086
6438
|
"When asked what tools you have, copy the Direct tools line verbatim and call nothing",
|
|
7087
6439
|
...canDispatch ? [
|
|
7088
6440
|
"dispatch(list:true) answers a question about agents, the fleet, or which target and model run this session and its workers"
|
|
7089
6441
|
] : [],
|
|
7090
|
-
...canListSkills ? ['context(scope="skills")
|
|
6442
|
+
...canListSkills ? ['context(scope="skills") lists skills for discovery or skill questions'] : [],
|
|
6443
|
+
...hasGateway ? ['gateway(op="find") answers a question about secondary capabilities'] : []
|
|
7091
6444
|
].join("; ");
|
|
7092
6445
|
const capabilityKinds = [
|
|
7093
6446
|
"direct tools are attached schemas",
|
|
6447
|
+
...hasGateway ? ["secondary capabilities are reached through gateway find, describe, and call"] : [],
|
|
7094
6448
|
...canDispatch ? ["fleet agents are workers behind dispatch"] : [],
|
|
7095
|
-
...canListSkills ? ["skills are
|
|
6449
|
+
...canListSkills ? ["skills are workflows reached through context"] : []
|
|
7096
6450
|
];
|
|
7097
6451
|
const orientationTools = ["context", "code_nav", "grep", "read"].filter((name2) => admitted.has(name2));
|
|
7098
|
-
const validationTools = [
|
|
6452
|
+
const validationTools = [
|
|
6453
|
+
...admitted.has("verify") ? ["verify"] : [],
|
|
6454
|
+
...admitted.has("git") ? ["git diff"] : hasGateway ? ['gateway(op="call", capability="git") diff'] : []
|
|
6455
|
+
];
|
|
7099
6456
|
const lines = [
|
|
7100
6457
|
"# Tool Contract",
|
|
7101
6458
|
TOOL_RESULT_TRUST_CONTRACT,
|
|
@@ -7112,12 +6469,10 @@ function renderToolContractBlock(inputs) {
|
|
|
7112
6469
|
...orientationTools.length > 0 ? [
|
|
7113
6470
|
`For narrow file or symbol orientation, prefer ${orientationTools.join(", ")} instead of assuming source-tree details were preloaded.`
|
|
7114
6471
|
] : [],
|
|
7115
|
-
...validationTools.length > 0 ? [
|
|
7116
|
-
|
|
7117
|
-
] : [],
|
|
7118
|
-
`When a tool call fails or is rejected, do not retry the same shape blindly: re-read the schema and adjust the arguments${canListSkills ? `, or query context(scope="docs") for that tool's usage` : ""}.`
|
|
6472
|
+
...validationTools.length > 0 ? [`Validate with ${validationTools.join(" or ")} before final claims.`] : [],
|
|
6473
|
+
`When a tool call fails or is rejected, do not retry the same shape blindly: re-read the schema and adjust the arguments${hasGateway ? `, or read that tool's usage with gateway(op="call", capability="clio_docs", args={query})` : ""}.`
|
|
7119
6474
|
];
|
|
7120
|
-
const hints = canonicalToolPromptHints(inputs.toolPromptHints ?? [], new Set(names));
|
|
6475
|
+
const hints = canonicalToolPromptHints(inputs.toolPromptHints ?? [], /* @__PURE__ */ new Set([...capabilityNames, ...names]));
|
|
7121
6476
|
for (const entry of hints) {
|
|
7122
6477
|
lines.push(entry.hint);
|
|
7123
6478
|
}
|
|
@@ -7170,7 +6525,7 @@ function renderWorkerToolContractBlock(inputs) {
|
|
|
7170
6525
|
TOOL_RESULT_TRUST_CONTRACT,
|
|
7171
6526
|
"The attached schemas are this worker's complete canonical tool surface; follow each schema exactly.",
|
|
7172
6527
|
`Admitted canonical tools: ${names.map((name2) => `\`${name2}\``).join(", ")}.`,
|
|
7173
|
-
"This worker surface is distinct from the parent session's tools, fleet agents, and
|
|
6528
|
+
"This worker surface is distinct from the parent session's tools, fleet agents, and skills.",
|
|
7174
6529
|
"Tool authority is limited to this list. Persona and bound-skill instructions never add tools.",
|
|
7175
6530
|
"Call tools only for concrete inspection or changes the assigned task requires. If the task requests an exact or tool-free response, answer without calling tools."
|
|
7176
6531
|
];
|
|
@@ -7273,7 +6628,7 @@ function compile(table, inputs) {
|
|
|
7273
6628
|
};
|
|
7274
6629
|
let identityBody = identity.body;
|
|
7275
6630
|
const selfAwareness = identity.id === "identity.clio" ? table.byId.get("identity.self-awareness") : void 0;
|
|
7276
|
-
const docsRouting = selfAwareness &&
|
|
6631
|
+
const docsRouting = selfAwareness && session.providerSupportsTools !== false && toolSurfaceHasTool(session.toolNames, "gateway") ? table.byId.get("identity.docs-routing") : void 0;
|
|
7277
6632
|
if (selfAwareness) {
|
|
7278
6633
|
const packageRoot = resolvePackageRoot();
|
|
7279
6634
|
const clioDirs = resolveClioDirs();
|
|
@@ -7284,12 +6639,13 @@ function compile(table, inputs) {
|
|
|
7284
6639
|
}
|
|
7285
6640
|
const delegation = sessionCanDispatch(session) ? table.byId.get("operating.delegation") : void 0;
|
|
7286
6641
|
const skills = sessionHasContext(session) ? table.byId.get("operating.skills") : void 0;
|
|
6642
|
+
const skillActivation = isAutonomyLevel(autonomyLevel) && modelMayActivateSkills(autonomyLevel) ? 'Load matching installed skills with context(scope="skills", name="<name>") and continue the task; skill restrictions still apply.' : "Suggest matching skills as /skill <name> (in order when several compose), then continue without them; only the operator activates skills.";
|
|
7287
6643
|
const legacy = inputs.sectionOrder === "legacy-0.3.8";
|
|
7288
6644
|
const rendered = /* @__PURE__ */ new Map([
|
|
7289
6645
|
["identity", identityBody],
|
|
7290
6646
|
["operating-contract", operatingContract.body],
|
|
7291
6647
|
["delegation", delegation?.body ?? ""],
|
|
7292
|
-
["skills", skills?.body ?? ""],
|
|
6648
|
+
["skills", skills?.body.replace("{SKILL_ACTIVATION_POLICY}", skillActivation) ?? ""],
|
|
7293
6649
|
["safety", renderSafetySection(safety, autonomyLevel)],
|
|
7294
6650
|
["runtime", renderRuntimeBlock(session)],
|
|
7295
6651
|
["tool-contract", renderToolContractBlock(session)],
|
|
@@ -9699,7 +9055,7 @@ import { dirname as dirname7, join as join19, resolve as resolve9 } from "node:p
|
|
|
9699
9055
|
|
|
9700
9056
|
// src/domains/dispatch/code-step.ts
|
|
9701
9057
|
init_esm_shims();
|
|
9702
|
-
import { execFileSync as execFileSync2, spawn
|
|
9058
|
+
import { execFileSync as execFileSync2, spawn } from "node:child_process";
|
|
9703
9059
|
import { createHash as createHash8 } from "node:crypto";
|
|
9704
9060
|
import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync3 } from "node:fs";
|
|
9705
9061
|
import { isAbsolute as isAbsolute5, join as join18, resolve as resolve8 } from "node:path";
|
|
@@ -9777,6 +9133,9 @@ function newCodeRunId() {
|
|
|
9777
9133
|
}
|
|
9778
9134
|
async function spawnCommand(input, cwd, argv) {
|
|
9779
9135
|
const command = input.command;
|
|
9136
|
+
const captureMaxBytes = input.maxOutputBytes ?? CODE_STEP_CAPTURE_MAX_BYTES;
|
|
9137
|
+
if (!Number.isSafeInteger(captureMaxBytes) || captureMaxBytes <= 0)
|
|
9138
|
+
throw new Error("code step: maxOutputBytes must be a positive safe integer");
|
|
9780
9139
|
const [executable, ...args] = argv;
|
|
9781
9140
|
if (executable === void 0) throw new Error(`code step: command '${command.id}' has no executable`);
|
|
9782
9141
|
return await new Promise((resolvePromise) => {
|
|
@@ -9793,7 +9152,7 @@ async function spawnCommand(input, cwd, argv) {
|
|
|
9793
9152
|
let settled = false;
|
|
9794
9153
|
let timedOut = false;
|
|
9795
9154
|
let spawnError = null;
|
|
9796
|
-
const child =
|
|
9155
|
+
const child = spawn(executable, args, {
|
|
9797
9156
|
cwd,
|
|
9798
9157
|
env: attribution.env,
|
|
9799
9158
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -9803,8 +9162,8 @@ async function spawnCommand(input, cwd, argv) {
|
|
|
9803
9162
|
});
|
|
9804
9163
|
const collect = (chunk, stdout) => {
|
|
9805
9164
|
outputBytes += chunk.length;
|
|
9806
|
-
if (captured >=
|
|
9807
|
-
const room =
|
|
9165
|
+
if (captured >= captureMaxBytes) return;
|
|
9166
|
+
const room = captureMaxBytes - captured;
|
|
9808
9167
|
const slice = chunk.length <= room ? chunk : chunk.subarray(0, room);
|
|
9809
9168
|
chunks.push(slice);
|
|
9810
9169
|
if (stdout) stdoutChunks.push(slice);
|
|
@@ -9944,7 +9303,7 @@ ${spawned.spawnError}
|
|
|
9944
9303
|
|
|
9945
9304
|
// src/domains/dispatch/host-verification.ts
|
|
9946
9305
|
var OUTPUT_TAIL_BYTES = 2048;
|
|
9947
|
-
var MEMO_VERSION =
|
|
9306
|
+
var MEMO_VERSION = 3;
|
|
9948
9307
|
var HTTP_URL_RE = /\bhttps?:\/\/\S+/gu;
|
|
9949
9308
|
var CHECK_OUTPUT_PATH_RE = /\/?(?:[A-Za-z0-9_.@+-]+\/)+[A-Za-z0-9_.@+-]*\.(?:[cm]?[jt]sx?|json|ya?ml|md|txt|py|go|rs|c|h|cc|cpp|hpp|java|rb|sh|toml|css|html|sql)\b/gu;
|
|
9950
9309
|
var IMPLICATED_PATH_CAP = PATH_BOUNDARY_MAX_ENTRIES;
|
|
@@ -10037,7 +9396,8 @@ function judgeResolvedCheck(resolvedCheck, exitCode, durationMs2, stdout) {
|
|
|
10037
9396
|
stdout,
|
|
10038
9397
|
referenceText,
|
|
10039
9398
|
resolvedCheck.numeric.tolerance,
|
|
10040
|
-
`reference '${resolvedCheck.numeric.reference}'
|
|
9399
|
+
`reference '${resolvedCheck.numeric.reference}'`,
|
|
9400
|
+
resolvedCheck.numeric.reference
|
|
10041
9401
|
);
|
|
10042
9402
|
if (report instanceof Error) return { exitCode: 1, outputTail: `numeric-compare: ${report.message}` };
|
|
10043
9403
|
return { exitCode: report.passed ? 0 : 1, report, outputTail: outputTail(report.summary) };
|
|
@@ -10075,20 +9435,21 @@ async function runResolvedCheck(input) {
|
|
|
10075
9435
|
outputExcerpt: ""
|
|
10076
9436
|
};
|
|
10077
9437
|
}
|
|
9438
|
+
const judged = resolvedCheck.kind === "numeric-compare" || resolvedCheck.kind === "perf-budget";
|
|
9439
|
+
const captureMaxBytes = judged ? JUDGED_CHECK_MAX_OUTPUT_BYTES : CODE_STEP_CAPTURE_MAX_BYTES;
|
|
10078
9440
|
const outcome = await runCodeStep({
|
|
10079
9441
|
stepId: `verification-${input.index + 1}-${resolvedCheck.check.replace(/[^a-z0-9._-]/giu, "_")}`,
|
|
10080
9442
|
command,
|
|
10081
9443
|
workspaceRoot: resolvedCheck.cwd,
|
|
10082
9444
|
artifactDir: join19(input.stateDir, "artifacts", input.runId, "verification"),
|
|
10083
|
-
env: input.env
|
|
9445
|
+
env: input.env,
|
|
9446
|
+
maxOutputBytes: captureMaxBytes
|
|
10084
9447
|
});
|
|
10085
9448
|
const artifactPath = outcome.record.artifactPaths[0];
|
|
10086
|
-
const judgement =
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
outcome.stdout
|
|
10091
|
-
);
|
|
9449
|
+
const judgement = judged && outcome.record.outputTruncated && outcome.record.outputBytes > captureMaxBytes ? {
|
|
9450
|
+
exitCode: 1,
|
|
9451
|
+
outputTail: `verify: ${resolvedCheck.kind} command output exceeded ${captureMaxBytes} bytes before judgement; captured output was truncated`
|
|
9452
|
+
} : judgeResolvedCheck(resolvedCheck, outcome.record.exitCode, outcome.record.durationMs, outcome.stdout);
|
|
10092
9453
|
const check = {
|
|
10093
9454
|
check: resolvedCheck.check,
|
|
10094
9455
|
argv: [...outcome.record.argv],
|
|
@@ -10151,11 +9512,7 @@ function checkDedupeKey(resolvedCheck) {
|
|
|
10151
9512
|
numeric: numeric === void 0 ? void 0 : {
|
|
10152
9513
|
reference: numeric.reference,
|
|
10153
9514
|
referenceDigest: sha2564(JSON.stringify(readSealedFile(numeric.reference) ?? null)),
|
|
10154
|
-
tolerance:
|
|
10155
|
-
absolute: numeric.tolerance.absolute,
|
|
10156
|
-
relative: numeric.tolerance.relative,
|
|
10157
|
-
ulp: numeric.tolerance.ulp
|
|
10158
|
-
}
|
|
9515
|
+
tolerance: numeric.tolerance
|
|
10159
9516
|
},
|
|
10160
9517
|
perf: perf === void 0 ? void 0 : {
|
|
10161
9518
|
budget: perf.budget === void 0 ? void 0 : {
|
|
@@ -10710,6 +10067,7 @@ function envelopeFromReceipt(receipt, status, receiptPath) {
|
|
|
10710
10067
|
};
|
|
10711
10068
|
if (receipt.cacheReadTokenCount !== void 0) envelope.cacheReadTokenCount = receipt.cacheReadTokenCount;
|
|
10712
10069
|
if (receipt.cacheWriteTokenCount !== void 0) envelope.cacheWriteTokenCount = receipt.cacheWriteTokenCount;
|
|
10070
|
+
if (receipt.cacheWrite1hTokenCount !== void 0) envelope.cacheWrite1hTokenCount = receipt.cacheWrite1hTokenCount;
|
|
10713
10071
|
if (receipt.reasoningTokenCount !== void 0) envelope.reasoningTokenCount = receipt.reasoningTokenCount;
|
|
10714
10072
|
if (receipt.inputTokenCount !== void 0) envelope.inputTokenCount = receipt.inputTokenCount;
|
|
10715
10073
|
if (receipt.outputTokenCount !== void 0) envelope.outputTokenCount = receipt.outputTokenCount;
|
|
@@ -11247,7 +10605,7 @@ function compareRecords(left, right) {
|
|
|
11247
10605
|
return left.settledAt.localeCompare(right.settledAt) || left.receiptDigest.localeCompare(right.receiptDigest);
|
|
11248
10606
|
}
|
|
11249
10607
|
function validateRecord(value) {
|
|
11250
|
-
if (!
|
|
10608
|
+
if (!isRecord8(value) || value.version !== ROUTE_HISTORY_VERSION)
|
|
11251
10609
|
throw new Error("route history record has unsupported version");
|
|
11252
10610
|
if (!isDigest(value.receiptDigest)) throw new Error("route history receipt digest invalid");
|
|
11253
10611
|
if (typeof value.assignmentId !== "string" || value.assignmentId.length === 0)
|
|
@@ -11300,7 +10658,7 @@ function readHistory(path2) {
|
|
|
11300
10658
|
} catch (error) {
|
|
11301
10659
|
throw new Error(`route history unreadable: ${error instanceof Error ? error.message : String(error)}`);
|
|
11302
10660
|
}
|
|
11303
|
-
if (!
|
|
10661
|
+
if (!isRecord8(parsed) || !Array.isArray(parsed.records)) throw new Error("route history has unsupported format");
|
|
11304
10662
|
if (parsed.version !== ROUTE_HISTORY_VERSION) {
|
|
11305
10663
|
retireHistory(path2, parsed.version);
|
|
11306
10664
|
return [];
|
|
@@ -11360,14 +10718,14 @@ function createRouteHistoryStore(options = {}) {
|
|
|
11360
10718
|
}
|
|
11361
10719
|
};
|
|
11362
10720
|
}
|
|
11363
|
-
function
|
|
10721
|
+
function isRecord8(value) {
|
|
11364
10722
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11365
10723
|
}
|
|
11366
10724
|
function isDigest(value) {
|
|
11367
10725
|
return typeof value === "string" && /^[0-9a-f]{64}$/u.test(value);
|
|
11368
10726
|
}
|
|
11369
10727
|
function isRouteCandidate(value) {
|
|
11370
|
-
if (!
|
|
10728
|
+
if (!isRecord8(value)) return false;
|
|
11371
10729
|
if (!isExecutionRole(value.executionRole)) return false;
|
|
11372
10730
|
return [
|
|
11373
10731
|
value.agentId,
|
|
@@ -11383,7 +10741,7 @@ function isRouteCandidate(value) {
|
|
|
11383
10741
|
].every((field) => typeof field === "string");
|
|
11384
10742
|
}
|
|
11385
10743
|
function isPhaseTiming(value) {
|
|
11386
|
-
if (!
|
|
10744
|
+
if (!isRecord8(value)) return false;
|
|
11387
10745
|
return [
|
|
11388
10746
|
"requestToDecisionMs",
|
|
11389
10747
|
"decisionMs",
|
|
@@ -11860,15 +11218,15 @@ function receiptGatewayRoutingLabel(receipt) {
|
|
|
11860
11218
|
var RUN_TAIL_ENTRY_LIMIT = 100;
|
|
11861
11219
|
var RUN_TAIL_RUN_LIMIT = 64;
|
|
11862
11220
|
var RUN_TAIL_TEXT_LIMIT = 600;
|
|
11863
|
-
function
|
|
11221
|
+
function isRecord9(value) {
|
|
11864
11222
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11865
11223
|
}
|
|
11866
11224
|
function eventDetail(event) {
|
|
11867
|
-
const normalized =
|
|
11225
|
+
const normalized = isRecord9(event) ? normalizeClioCoderEventRecord(event) : event;
|
|
11868
11226
|
const text = assistantTextFromEvent(normalized);
|
|
11869
11227
|
if (text.length > 0) return truncateUtf8(text, RUN_TAIL_TEXT_LIMIT, "...");
|
|
11870
|
-
if (!
|
|
11871
|
-
if (normalized.type === "clio_coder_tool_finish" &&
|
|
11228
|
+
if (!isRecord9(normalized)) return void 0;
|
|
11229
|
+
if (normalized.type === "clio_coder_tool_finish" && isRecord9(normalized.payload)) {
|
|
11872
11230
|
const tool = typeof normalized.payload.tool === "string" ? normalized.payload.tool : "tool";
|
|
11873
11231
|
const outcome = typeof normalized.payload.outcome === "string" ? normalized.payload.outcome : "";
|
|
11874
11232
|
return `${tool} ${outcome}`.trim();
|
|
@@ -11882,7 +11240,7 @@ function eventDetail(event) {
|
|
|
11882
11240
|
return void 0;
|
|
11883
11241
|
}
|
|
11884
11242
|
function runTailEntryFromEvent(event, at = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
11885
|
-
const type =
|
|
11243
|
+
const type = isRecord9(event) && typeof event.type === "string" ? normalizeClioCoderEventType(event.type) : "unknown";
|
|
11886
11244
|
if (type === "heartbeat" || type === "message_update") return null;
|
|
11887
11245
|
const entry = { at, type };
|
|
11888
11246
|
const detail = eventDetail(event);
|
|
@@ -11900,7 +11258,7 @@ function createDispatchRunEventRegistry(options = {}) {
|
|
|
11900
11258
|
const activeBatches = /* @__PURE__ */ new Set();
|
|
11901
11259
|
const journal = options.journal === void 0 ? defaultRunEventJournal() : options.journal;
|
|
11902
11260
|
const journalSeal = (logicalRunId, receipt) => {
|
|
11903
|
-
if (journal === null || !
|
|
11261
|
+
if (journal === null || !isRecord9(receipt)) return;
|
|
11904
11262
|
const digest = receipt.integrity?.digest;
|
|
11905
11263
|
const outcome = typeof receipt.outcome === "string" ? receipt.outcome : REGISTRY_UNKNOWN_OUTCOME;
|
|
11906
11264
|
journal.receipt(logicalRunId, {
|
|
@@ -11959,7 +11317,7 @@ function createDispatchRunEventRegistry(options = {}) {
|
|
|
11959
11317
|
};
|
|
11960
11318
|
for await (const event of events) {
|
|
11961
11319
|
summary.count += 1;
|
|
11962
|
-
const type =
|
|
11320
|
+
const type = isRecord9(event) && typeof event.type === "string" ? event.type : "unknown";
|
|
11963
11321
|
summary.types.push(type);
|
|
11964
11322
|
if (type === "attempt_start") summary.lastAssistantText = "";
|
|
11965
11323
|
const text = durableAssistantTextFromEvent(event);
|
|
@@ -11972,7 +11330,7 @@ function createDispatchRunEventRegistry(options = {}) {
|
|
|
11972
11330
|
const drainBatch = async (batchId, events, bus) => {
|
|
11973
11331
|
const summaries = /* @__PURE__ */ new Map();
|
|
11974
11332
|
for await (const event of events) {
|
|
11975
|
-
if (!
|
|
11333
|
+
if (!isRecord9(event) || event.type !== "batch_run_event") continue;
|
|
11976
11334
|
const runId = typeof event.runId === "string" ? event.runId : batchId;
|
|
11977
11335
|
const agentId = typeof event.agentId === "string" ? event.agentId : "batch";
|
|
11978
11336
|
const inner = event.event;
|
|
@@ -11983,7 +11341,7 @@ function createDispatchRunEventRegistry(options = {}) {
|
|
|
11983
11341
|
terminalAttemptRunId: runId
|
|
11984
11342
|
};
|
|
11985
11343
|
summary.count += 1;
|
|
11986
|
-
const type =
|
|
11344
|
+
const type = isRecord9(inner) && typeof inner.type === "string" ? inner.type : "unknown";
|
|
11987
11345
|
summary.types.push(type);
|
|
11988
11346
|
const text = durableAssistantTextFromEvent(inner);
|
|
11989
11347
|
if (text.trim().length > 0) summary.lastAssistantText = text;
|
|
@@ -12089,11 +11447,11 @@ function createDispatchRunEventRegistry(options = {}) {
|
|
|
12089
11447
|
|
|
12090
11448
|
// src/domains/dispatch/run-event-journal-bridge.ts
|
|
12091
11449
|
var OPENED_RUN_LIMIT = 512;
|
|
12092
|
-
function
|
|
11450
|
+
function isRecord10(value) {
|
|
12093
11451
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12094
11452
|
}
|
|
12095
11453
|
function runIdentity(payload) {
|
|
12096
|
-
if (!
|
|
11454
|
+
if (!isRecord10(payload)) return null;
|
|
12097
11455
|
if (typeof payload.runId !== "string" || payload.runId.length === 0) return null;
|
|
12098
11456
|
return { runId: payload.runId, agentId: typeof payload.agentId === "string" ? payload.agentId : "unknown" };
|
|
12099
11457
|
}
|
|
@@ -12114,7 +11472,7 @@ function attachRunEventJournalBridge(bus, options = {}) {
|
|
|
12114
11472
|
const identity = runIdentity(payload);
|
|
12115
11473
|
if (identity === null) return;
|
|
12116
11474
|
ensureOpen(identity.runId, identity.agentId);
|
|
12117
|
-
const exitCode =
|
|
11475
|
+
const exitCode = isRecord10(payload) && typeof payload.exitCode === "number" ? payload.exitCode : null;
|
|
12118
11476
|
journal.receipt(identity.runId, { outcome, exitCode });
|
|
12119
11477
|
journal.terminal(identity.runId, outcome, detail ?? void 0);
|
|
12120
11478
|
opened.delete(identity.runId);
|
|
@@ -12126,7 +11484,7 @@ function attachRunEventJournalBridge(bus, options = {}) {
|
|
|
12126
11484
|
const entry = runTailEntryFromEvent(payload.event);
|
|
12127
11485
|
if (entry === null) return;
|
|
12128
11486
|
ensureOpen(identity.runId, identity.agentId);
|
|
12129
|
-
const message =
|
|
11487
|
+
const message = isRecord10(payload.event) && typeof payload.event.message === "string" ? payload.event.message : void 0;
|
|
12130
11488
|
journal.append(
|
|
12131
11489
|
identity.runId,
|
|
12132
11490
|
entry.detail === void 0 && message !== void 0 ? { ...entry, detail: message } : entry
|
|
@@ -12246,7 +11604,7 @@ function listFleetRuns(limit = MAX_FLEET_RUN_SCAN) {
|
|
|
12246
11604
|
records.sort((a, b) => (Date.parse(b.startedAt) || 0) - (Date.parse(a.startedAt) || 0));
|
|
12247
11605
|
return records.slice(0, Math.max(0, limit));
|
|
12248
11606
|
}
|
|
12249
|
-
function
|
|
11607
|
+
function isRecord11(value) {
|
|
12250
11608
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12251
11609
|
}
|
|
12252
11610
|
function readRuns() {
|
|
@@ -12258,7 +11616,7 @@ function readRuns() {
|
|
|
12258
11616
|
if (!Array.isArray(parsed)) return [];
|
|
12259
11617
|
const envelopes = [];
|
|
12260
11618
|
for (const entry of parsed) {
|
|
12261
|
-
if (!
|
|
11619
|
+
if (!isRecord11(entry)) continue;
|
|
12262
11620
|
const version = entry.version === void 0 ? 1 : entry.version;
|
|
12263
11621
|
if (version !== 1) continue;
|
|
12264
11622
|
envelopes.push({ ...entry, version: 1 });
|
|
@@ -12310,7 +11668,6 @@ function capRuns(all, maxRuns) {
|
|
|
12310
11668
|
return kept;
|
|
12311
11669
|
}
|
|
12312
11670
|
function openLedger(opts) {
|
|
12313
|
-
const maxRuns = resolveMaxRuns(opts?.maxRuns);
|
|
12314
11671
|
let runs = readRuns();
|
|
12315
11672
|
const dirty = /* @__PURE__ */ new Set();
|
|
12316
11673
|
function findIndex(id) {
|
|
@@ -12416,7 +11773,7 @@ function openLedger(opts) {
|
|
|
12416
11773
|
if (stateRootRemoved()) return;
|
|
12417
11774
|
const diskRuns = readRuns();
|
|
12418
11775
|
const merged = mergeRunsById(diskRuns, runs, dirty);
|
|
12419
|
-
const capped = capRuns(merged, maxRuns);
|
|
11776
|
+
const capped = capRuns(merged, resolveMaxRuns(opts?.maxRuns));
|
|
12420
11777
|
runs = capped;
|
|
12421
11778
|
atomicWrite(target, JSON.stringify(capped, null, 2));
|
|
12422
11779
|
if (merged.length > capped.length) {
|
|
@@ -12606,9 +11963,30 @@ function sealRouteDecision(draft, decision) {
|
|
|
12606
11963
|
}
|
|
12607
11964
|
var UNKNOWN_PRICING_ADMISSION_ESTIMATE_USD = 1;
|
|
12608
11965
|
function calculateUsageCostUsd(meter, pricing) {
|
|
11966
|
+
if (meter.costUsd !== void 0) return meter.costUsd;
|
|
12609
11967
|
if (pricing === null) return 0;
|
|
12610
11968
|
return (meter.inputTokens * pricing.input + meter.outputTokens * pricing.output + meter.cacheReadTokens * pricing.cacheRead + meter.cacheWriteTokens * pricing.cacheWrite) / 1e6;
|
|
12611
11969
|
}
|
|
11970
|
+
function accumulateNativeUsage(meter, usage, pricing) {
|
|
11971
|
+
const count = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
11972
|
+
const call = {
|
|
11973
|
+
inputTokens: count(usage.input),
|
|
11974
|
+
outputTokens: count(usage.output),
|
|
11975
|
+
cacheReadTokens: count(usage.cacheRead),
|
|
11976
|
+
cacheWriteTokens: count(usage.cacheWrite),
|
|
11977
|
+
reasoningTokens: extractReasoningTokenCount(usage)
|
|
11978
|
+
};
|
|
11979
|
+
const reported = isRecord12(usage.cost) ? usage.cost.total : void 0;
|
|
11980
|
+
const callCost = typeof reported === "number" && Number.isFinite(reported) && reported >= 0 ? reported : calculateUsageCostUsd(call, pricing);
|
|
11981
|
+
meter.costUsd = (meter.costUsd ?? 0) + callCost;
|
|
11982
|
+
meter.inputTokens += call.inputTokens;
|
|
11983
|
+
meter.outputTokens += call.outputTokens;
|
|
11984
|
+
meter.cacheReadTokens += call.cacheReadTokens;
|
|
11985
|
+
meter.cacheWriteTokens += call.cacheWriteTokens;
|
|
11986
|
+
if (typeof usage.cacheWrite1h === "number" && usage.cacheWrite1h >= 0 && usage.cacheWrite1h <= call.cacheWriteTokens)
|
|
11987
|
+
meter.cacheWrite1hTokens = (meter.cacheWrite1hTokens ?? 0) + usage.cacheWrite1h;
|
|
11988
|
+
meter.reasoningTokens += call.reasoningTokens;
|
|
11989
|
+
}
|
|
12612
11990
|
function admissionMaxOutputTokens(settings) {
|
|
12613
11991
|
return settings?.chat.maxOutputTokens ?? DEFAULT_SETTINGS.chat.maxOutputTokens;
|
|
12614
11992
|
}
|
|
@@ -12633,12 +12011,12 @@ function promptCompositionHash(parts) {
|
|
|
12633
12011
|
function toolSignature(tools) {
|
|
12634
12012
|
return sha2566(JSON.stringify([...tools].sort()));
|
|
12635
12013
|
}
|
|
12636
|
-
function
|
|
12014
|
+
function isRecord12(value) {
|
|
12637
12015
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12638
12016
|
}
|
|
12639
12017
|
function eventContainsFirstModelToken(event) {
|
|
12640
12018
|
if (event.type === "message_end") return true;
|
|
12641
|
-
const assistantEvent =
|
|
12019
|
+
const assistantEvent = isRecord12(event.assistantMessageEvent) ? event.assistantMessageEvent : null;
|
|
12642
12020
|
return assistantEvent?.type === "text_delta" || assistantEvent?.type === "thinking_delta" || assistantEvent?.type === "toolcall_start" || assistantEvent?.type === "toolcall_delta";
|
|
12643
12021
|
}
|
|
12644
12022
|
function eventStartsTool(event) {
|
|
@@ -12650,13 +12028,13 @@ function finitePositive(value) {
|
|
|
12650
12028
|
function nestedFinitePositive(record, path2) {
|
|
12651
12029
|
let cursor = record;
|
|
12652
12030
|
for (const key of path2) {
|
|
12653
|
-
if (!
|
|
12031
|
+
if (!isRecord12(cursor)) return void 0;
|
|
12654
12032
|
cursor = cursor[key];
|
|
12655
12033
|
}
|
|
12656
12034
|
return finitePositive(cursor);
|
|
12657
12035
|
}
|
|
12658
12036
|
function extractReasoningTokenCount(usage) {
|
|
12659
|
-
if (!
|
|
12037
|
+
if (!isRecord12(usage)) return 0;
|
|
12660
12038
|
const direct = finitePositive(usage.reasoningTokens) ?? finitePositive(usage.reasoning_tokens) ?? finitePositive(usage.reasoning);
|
|
12661
12039
|
if (direct !== void 0) return direct;
|
|
12662
12040
|
const paths = [
|
|
@@ -12682,14 +12060,14 @@ function readStringArrayOrNull(value) {
|
|
|
12682
12060
|
return strings.length === value.length ? strings : null;
|
|
12683
12061
|
}
|
|
12684
12062
|
function messageText(value) {
|
|
12685
|
-
const record =
|
|
12063
|
+
const record = isRecord12(value) ? value : null;
|
|
12686
12064
|
if (record === null) return "";
|
|
12687
12065
|
const content = record.content;
|
|
12688
12066
|
if (typeof content === "string") return content;
|
|
12689
12067
|
if (Array.isArray(content)) {
|
|
12690
12068
|
return content.map((part) => {
|
|
12691
12069
|
if (typeof part === "string") return part;
|
|
12692
|
-
if (!
|
|
12070
|
+
if (!isRecord12(part)) return "";
|
|
12693
12071
|
const text2 = part.text;
|
|
12694
12072
|
return typeof text2 === "string" ? text2 : "";
|
|
12695
12073
|
}).join("");
|
|
@@ -12731,7 +12109,7 @@ function appendDispatchFinishContractEntry(entries, event) {
|
|
|
12731
12109
|
return null;
|
|
12732
12110
|
}
|
|
12733
12111
|
if (eventType !== "message_end") return null;
|
|
12734
|
-
const message =
|
|
12112
|
+
const message = isRecord12(event.message) ? event.message : null;
|
|
12735
12113
|
if (message === null) return null;
|
|
12736
12114
|
const role = readStringOrNull(message.role);
|
|
12737
12115
|
if (role !== "user" && role !== "assistant") return null;
|
|
@@ -12754,7 +12132,7 @@ function recordWorkerRunEffect(recorder, event) {
|
|
|
12754
12132
|
if (event.type === "tool_execution_start") {
|
|
12755
12133
|
const toolName = readStringOrNull(event.toolName) ?? readStringOrNull(event.tool);
|
|
12756
12134
|
if (toolName === null) return;
|
|
12757
|
-
recorder.start(toolCallId, toolName,
|
|
12135
|
+
recorder.start(toolCallId, toolName, isRecord12(event.args) ? event.args : void 0);
|
|
12758
12136
|
return;
|
|
12759
12137
|
}
|
|
12760
12138
|
if (event.type === "tool_execution_end") recorder.finish(toolCallId, event.isError === true);
|
|
@@ -13209,21 +12587,25 @@ function effectiveToolNames(allowedTools, target, writeConfined = false, denied
|
|
|
13209
12587
|
const networkStripped = networkToolsDisabled();
|
|
13210
12588
|
const harnessTools = target.runtime.kind === "http" && !writeConfined && allowedTools.some(isHarnessExtensionToolName) ? enabledHarnessExtensionToolNames(cwd) : /* @__PURE__ */ new Set();
|
|
13211
12589
|
const names = allowedTools.filter(
|
|
13212
|
-
(tool) => (isBuiltinToolName(tool) || harnessTools.has(tool)) && tool !== ToolNames.AskUser && !(networkStripped && tool === ToolNames.WebFetch) && !denied.has(tool) && !(writeConfined && WRITE_ROOT_REFUSED_TOOLS.has(tool)) && (target.runtime.id !== "claude-sdk" || isClaudeCanonicalTool(tool))
|
|
12590
|
+
(tool) => (isBuiltinToolName(tool) || harnessTools.has(tool)) && tool !== ToolNames.AskUser && !(networkStripped && (tool === ToolNames.WebFetch || tool === ToolNames.WebRead)) && !denied.has(tool) && !(writeConfined && WRITE_ROOT_REFUSED_TOOLS.has(tool)) && (target.runtime.id !== "claude-sdk" || isClaudeCanonicalTool(tool))
|
|
13213
12591
|
);
|
|
13214
|
-
|
|
12592
|
+
const mediated = target.runtime.kind === "http" && target.runtime.id !== "claude-sdk";
|
|
12593
|
+
const surface = mediated ? withGatewayForCapabilities(names) : [...new Set(names)];
|
|
12594
|
+
return surface.sort();
|
|
13215
12595
|
}
|
|
13216
12596
|
function deniedToolNames(req) {
|
|
13217
12597
|
if (!req.denyTools || req.denyTools.length === 0) return /* @__PURE__ */ new Set();
|
|
13218
12598
|
return new Set(req.denyTools.map((tool) => tool.trim().toLowerCase()));
|
|
13219
12599
|
}
|
|
13220
|
-
function assertPostRuntimeToolCompatibility(agentId, spec, effectiveTools, target) {
|
|
12600
|
+
function assertPostRuntimeToolCompatibility(agentId, spec, effectiveTools, target, writeConfined) {
|
|
13221
12601
|
const compatibility = resolveAgentToolCompatibility(spec, effectiveTools, {
|
|
13222
12602
|
mediatesDispatch: WORKER_RUNTIME_MEDIATES_CLIO_DISPATCH
|
|
13223
12603
|
});
|
|
13224
12604
|
if (compatibility.compatible) return;
|
|
12605
|
+
const confined = writeConfined ? compatibility.missingRequired.filter((tool) => WRITE_ROOT_REFUSED_TOOLS.has(tool)) : [];
|
|
12606
|
+
const cause = confined.length > 0 ? `; declared write roots remove ${confined.join(", ")}, so omit write roots (use autonomy: "read-only" or worktree: true) for this agent` : "";
|
|
13225
12607
|
throw new Error(
|
|
13226
|
-
`dispatch: admission denied: agent '${agentId}' is incompatible with runtime '${target.runtime.id}' after tool narrowing; missing required tools: ${compatibility.missingRequired.join(", ")}`
|
|
12608
|
+
`dispatch: admission denied: agent '${agentId}' is incompatible with runtime '${target.runtime.id}' after tool narrowing; missing required tools: ${compatibility.missingRequired.join(", ")}${cause}`
|
|
13227
12609
|
);
|
|
13228
12610
|
}
|
|
13229
12611
|
function workerToolCallHardCap(settings) {
|
|
@@ -13877,7 +13259,7 @@ function createDispatchBundle(context, options) {
|
|
|
13877
13259
|
return DEFAULT_RESILIENCE_COOLDOWN_MS;
|
|
13878
13260
|
};
|
|
13879
13261
|
const now = options?.now ?? (() => Date.now());
|
|
13880
|
-
const monotonicNow = options?.monotonicNow ?? (() =>
|
|
13262
|
+
const monotonicNow = options?.monotonicNow ?? (() => performance4.now());
|
|
13881
13263
|
const routeObserver = options?.routeObserver ?? createRouteObserver({});
|
|
13882
13264
|
let ledger = null;
|
|
13883
13265
|
let heartbeatTimer = null;
|
|
@@ -14080,6 +13462,21 @@ function createDispatchBundle(context, options) {
|
|
|
14080
13462
|
const retryBackoff = /* @__PURE__ */ new Map();
|
|
14081
13463
|
const retryReasons = /* @__PURE__ */ new Map();
|
|
14082
13464
|
const assignmentRootsByAttempt = /* @__PURE__ */ new Map();
|
|
13465
|
+
const controlRootsByAttempt = /* @__PURE__ */ new Map();
|
|
13466
|
+
const controlAttempts = /* @__PURE__ */ new Map();
|
|
13467
|
+
const canceledControlRoots = /* @__PURE__ */ new Set();
|
|
13468
|
+
const memberWork = /* @__PURE__ */ new Map();
|
|
13469
|
+
function trackMemberWork(runId, operation) {
|
|
13470
|
+
const root = controlRootsByAttempt.get(runId) ?? runId;
|
|
13471
|
+
const work = memberWork.get(root) ?? /* @__PURE__ */ new Set();
|
|
13472
|
+
memberWork.set(root, work);
|
|
13473
|
+
work.add(operation);
|
|
13474
|
+
const settled = () => {
|
|
13475
|
+
work.delete(operation);
|
|
13476
|
+
if (work.size === 0) memberWork.delete(root);
|
|
13477
|
+
};
|
|
13478
|
+
operation.then(settled, settled);
|
|
13479
|
+
}
|
|
14083
13480
|
const assignments = new AssignmentRegistry({
|
|
14084
13481
|
onStreamError: (error) => reportDispatchDiagnostic("assignment event stream", error)
|
|
14085
13482
|
});
|
|
@@ -14105,6 +13502,11 @@ function createDispatchBundle(context, options) {
|
|
|
14105
13502
|
function lineageFor(req, runId) {
|
|
14106
13503
|
const lineage = req.lineage ? { ...req.lineage } : { parentRunId: null, rootRunId: runId, attempt: 0, depth: 0 };
|
|
14107
13504
|
assignmentRootsByAttempt.set(runId, lineage.rootRunId);
|
|
13505
|
+
const parent = lineage.parentRunId === null ? void 0 : controlAttempts.get(lineage.parentRunId);
|
|
13506
|
+
const continuesParent = parent !== void 0 && parent.lineage.rootRunId === lineage.rootRunId && parent.lineage.depth === lineage.depth && parent.lineage.attempt + 1 === lineage.attempt && parent.reservation?.ownerId === req.reservation?.ownerId && parent.reservation?.memberId === req.reservation?.memberId;
|
|
13507
|
+
const priorControl = continuesParent && lineage.parentRunId !== null ? controlRootsByAttempt.get(lineage.parentRunId) : void 0;
|
|
13508
|
+
controlRootsByAttempt.set(runId, priorControl ?? runId);
|
|
13509
|
+
controlAttempts.set(runId, { lineage, reservation: req.reservation });
|
|
14108
13510
|
return lineage;
|
|
14109
13511
|
}
|
|
14110
13512
|
function publishedLineage(lineage, hostRun) {
|
|
@@ -14148,7 +13550,8 @@ function createDispatchBundle(context, options) {
|
|
|
14148
13550
|
capacityAdmission.releaseAssignment(rootRunId);
|
|
14149
13551
|
}
|
|
14150
13552
|
function retryChainIsLive(run) {
|
|
14151
|
-
if (run.aborted)
|
|
13553
|
+
if (run.aborted || canceledControlRoots.has(controlRootsByAttempt.get(run.runId) ?? run.lineage.rootRunId))
|
|
13554
|
+
return false;
|
|
14152
13555
|
const reservation = run.req.reservation;
|
|
14153
13556
|
if (reservation === void 0) return assignments.get(run.lineage.rootRunId)?.status === "running";
|
|
14154
13557
|
try {
|
|
@@ -14207,9 +13610,16 @@ function createDispatchBundle(context, options) {
|
|
|
14207
13610
|
const attempt = run.lineage.attempt + 1;
|
|
14208
13611
|
const reason = detail !== null ? `${outcome}: ${detail}` : outcome;
|
|
14209
13612
|
const dueAt = now() + delayMs;
|
|
13613
|
+
let settleCanceled;
|
|
13614
|
+
let rejectContinuation;
|
|
13615
|
+
const continuation = new Promise((resolve11, reject) => {
|
|
13616
|
+
settleCanceled = resolve11;
|
|
13617
|
+
rejectContinuation = reject;
|
|
13618
|
+
});
|
|
13619
|
+
trackMemberWork(run.runId, continuation);
|
|
14210
13620
|
const timer = setTimeout(() => {
|
|
14211
13621
|
retryQueue.delete(run.runId);
|
|
14212
|
-
|
|
13622
|
+
executeRetry(run, attempt, reason, decision).then(settleCanceled, rejectContinuation);
|
|
14213
13623
|
}, delayMs);
|
|
14214
13624
|
retryQueue.set(run.runId, {
|
|
14215
13625
|
runId: run.runId,
|
|
@@ -14221,7 +13631,8 @@ function createDispatchBundle(context, options) {
|
|
|
14221
13631
|
excludedRouteParts: [...decision.excludedRouteParts],
|
|
14222
13632
|
rootRunId,
|
|
14223
13633
|
terminalCandidate: receipt,
|
|
14224
|
-
timer
|
|
13634
|
+
timer,
|
|
13635
|
+
settleCanceled
|
|
14225
13636
|
});
|
|
14226
13637
|
context.bus.emit(BusChannels.DispatchProgress, {
|
|
14227
13638
|
runId: run.runId,
|
|
@@ -14294,6 +13705,7 @@ function createDispatchBundle(context, options) {
|
|
|
14294
13705
|
}
|
|
14295
13706
|
};
|
|
14296
13707
|
delete retryReq.runIdHint;
|
|
13708
|
+
let terminal;
|
|
14297
13709
|
const reasonKey = retryReasonKey(run.lineage.rootRunId, attempt);
|
|
14298
13710
|
retryReasons.set(reasonKey, reason);
|
|
14299
13711
|
try {
|
|
@@ -14357,6 +13769,9 @@ function createDispatchBundle(context, options) {
|
|
|
14357
13769
|
if (decision.excludedRouteParts.includes("runtime")) delete retryReq.workerRuntime;
|
|
14358
13770
|
}
|
|
14359
13771
|
const handle = await dispatch(retryReq, void 0, run.hostRun === void 0 ? void 0 : { hostRun: run.hostRun });
|
|
13772
|
+
if (canceledControlRoots.has(controlRootsByAttempt.get(run.runId) ?? run.lineage.rootRunId)) {
|
|
13773
|
+
contract.abort(handle.runId);
|
|
13774
|
+
}
|
|
14360
13775
|
const marker = {
|
|
14361
13776
|
type: "attempt_start",
|
|
14362
13777
|
attempt,
|
|
@@ -14377,6 +13792,7 @@ function createDispatchBundle(context, options) {
|
|
|
14377
13792
|
runtimeKind: run.runtimeKind,
|
|
14378
13793
|
event: marker
|
|
14379
13794
|
});
|
|
13795
|
+
terminal = handle.finalPromise;
|
|
14380
13796
|
handle.finalPromise.catch((error) => {
|
|
14381
13797
|
assignments.reject(asAssignmentId(run.lineage.rootRunId), error);
|
|
14382
13798
|
reportDispatchDiagnostic(`finalize retry run ${handle.runId}`, error);
|
|
@@ -14407,6 +13823,7 @@ function createDispatchBundle(context, options) {
|
|
|
14407
13823
|
outcomeDetail: denial
|
|
14408
13824
|
});
|
|
14409
13825
|
}
|
|
13826
|
+
await terminal;
|
|
14410
13827
|
}
|
|
14411
13828
|
function requireLedger() {
|
|
14412
13829
|
if (!ledger) throw new Error("dispatch: ledger not initialised");
|
|
@@ -14701,7 +14118,7 @@ function createDispatchBundle(context, options) {
|
|
|
14701
14118
|
),
|
|
14702
14119
|
req
|
|
14703
14120
|
);
|
|
14704
|
-
assertPostRuntimeToolCompatibility(req.agentId, spec, effectiveTools, target);
|
|
14121
|
+
assertPostRuntimeToolCompatibility(req.agentId, spec, effectiveTools, target, pathScope.writeBoundaries.length > 0);
|
|
14705
14122
|
const effectiveAdmission = {
|
|
14706
14123
|
...admission,
|
|
14707
14124
|
allowedTools: effectiveTools
|
|
@@ -14954,7 +14371,13 @@ function createDispatchBundle(context, options) {
|
|
|
14954
14371
|
throw error;
|
|
14955
14372
|
}
|
|
14956
14373
|
timing.workerSpawnedAt = new Date(now()).toISOString();
|
|
14957
|
-
const tokenMeter = {
|
|
14374
|
+
const tokenMeter = {
|
|
14375
|
+
inputTokens: 0,
|
|
14376
|
+
outputTokens: 0,
|
|
14377
|
+
cacheReadTokens: 0,
|
|
14378
|
+
cacheWriteTokens: 0,
|
|
14379
|
+
reasoningTokens: 0
|
|
14380
|
+
};
|
|
14958
14381
|
const safetyDecisionCounts = { allowed: 0, blocked: 0, permissionRequested: 0 };
|
|
14959
14382
|
const blockedAttempts = [];
|
|
14960
14383
|
const toolStats = /* @__PURE__ */ new Map();
|
|
@@ -14987,7 +14410,7 @@ function createDispatchBundle(context, options) {
|
|
|
14987
14410
|
const foldAcpEvent = (raw) => {
|
|
14988
14411
|
outputCapture.observe(raw);
|
|
14989
14412
|
const event = raw;
|
|
14990
|
-
if (
|
|
14413
|
+
if (isRecord12(event)) {
|
|
14991
14414
|
if (eventContainsFirstModelToken(event)) markObservedPhase("firstModelTokenAt");
|
|
14992
14415
|
if (eventStartsTool(event)) markObservedPhase("firstToolAt");
|
|
14993
14416
|
}
|
|
@@ -14998,14 +14421,14 @@ function createDispatchBundle(context, options) {
|
|
|
14998
14421
|
reportedSpoofedOutcome = true;
|
|
14999
14422
|
reportDispatchDiagnostic("ACP outcome event", new Error("ignored untrusted clio_coder_run_outcome assertion"));
|
|
15000
14423
|
}
|
|
15001
|
-
if (
|
|
14424
|
+
if (isRecord12(event)) {
|
|
15002
14425
|
const finishEntry = appendDispatchFinishContractEntry(finishContractEntries, event);
|
|
15003
14426
|
if (finishEntry !== null) {
|
|
15004
14427
|
finishContractAssistantText = finishEntry.assistantText;
|
|
15005
14428
|
finishContractAssistantTurnId = finishEntry.assistantTurnId;
|
|
15006
14429
|
}
|
|
15007
14430
|
}
|
|
15008
|
-
if (event.type === "message_end" && event.message?.role === "assistant" &&
|
|
14431
|
+
if (event.type === "message_end" && event.message?.role === "assistant" && isRecord12(event.message.usage)) {
|
|
15009
14432
|
const u = event.message.usage;
|
|
15010
14433
|
tokenMeter.inputTokens += typeof u.input === "number" ? u.input : 0;
|
|
15011
14434
|
tokenMeter.outputTokens += typeof u.output === "number" ? u.output : 0;
|
|
@@ -15166,7 +14589,7 @@ function createDispatchBundle(context, options) {
|
|
|
15166
14589
|
}
|
|
15167
14590
|
const eventPump = startDispatchEventPump(acp.events, foldAcpEvent, {
|
|
15168
14591
|
onEvent: (event) => {
|
|
15169
|
-
if (
|
|
14592
|
+
if (isRecord12(event) && event.type === "heartbeat") return;
|
|
15170
14593
|
context.bus.emit(BusChannels.DispatchProgress, {
|
|
15171
14594
|
runId: envelope.id,
|
|
15172
14595
|
agentId: req.agentId,
|
|
@@ -15284,6 +14707,7 @@ function createDispatchBundle(context, options) {
|
|
|
15284
14707
|
outputTokenCount: tokenMeter.outputTokens,
|
|
15285
14708
|
cacheReadTokenCount: tokenMeter.cacheReadTokens,
|
|
15286
14709
|
cacheWriteTokenCount: tokenMeter.cacheWriteTokens,
|
|
14710
|
+
...tokenMeter.cacheWrite1hTokens === void 0 ? {} : { cacheWrite1hTokenCount: tokenMeter.cacheWrite1hTokens },
|
|
15287
14711
|
reasoningTokenCount: tokenMeter.reasoningTokens,
|
|
15288
14712
|
...upstreamResponses.length > 0 ? { upstreamResponses: [...upstreamResponses] } : {},
|
|
15289
14713
|
...capturedOutput !== void 0 ? { output: capturedOutput } : {},
|
|
@@ -15368,6 +14792,7 @@ function createDispatchBundle(context, options) {
|
|
|
15368
14792
|
outputTokenCount: receipt.outputTokenCount ?? 0,
|
|
15369
14793
|
cacheReadTokenCount: receipt.cacheReadTokenCount ?? 0,
|
|
15370
14794
|
cacheWriteTokenCount: receipt.cacheWriteTokenCount ?? 0,
|
|
14795
|
+
...receipt.cacheWrite1hTokenCount === void 0 ? {} : { cacheWrite1hTokenCount: receipt.cacheWrite1hTokenCount },
|
|
15371
14796
|
reasoningTokenCount: receipt.reasoningTokenCount ?? 0,
|
|
15372
14797
|
staticShellHash: receipt.staticShellHash ?? null,
|
|
15373
14798
|
sessionShellHash: receipt.sessionShellHash ?? null,
|
|
@@ -15482,6 +14907,7 @@ function createDispatchBundle(context, options) {
|
|
|
15482
14907
|
dynamicHash: receiptDraft.dynamicHash ?? null,
|
|
15483
14908
|
cacheReadTokenCount: receiptDraft.cacheReadTokenCount ?? 0,
|
|
15484
14909
|
cacheWriteTokenCount: receiptDraft.cacheWriteTokenCount ?? 0,
|
|
14910
|
+
...receiptDraft.cacheWrite1hTokenCount === void 0 ? {} : { cacheWrite1hTokenCount: receiptDraft.cacheWrite1hTokenCount },
|
|
15485
14911
|
reasoningTokenCount: receiptDraft.reasoningTokenCount ?? 0,
|
|
15486
14912
|
heartbeatAt: heartbeatIso(acp.heartbeatAt)
|
|
15487
14913
|
};
|
|
@@ -15727,7 +15153,13 @@ function createDispatchBundle(context, options) {
|
|
|
15727
15153
|
throw error;
|
|
15728
15154
|
}
|
|
15729
15155
|
})();
|
|
15730
|
-
const tokenMeter = {
|
|
15156
|
+
const tokenMeter = {
|
|
15157
|
+
inputTokens: 0,
|
|
15158
|
+
outputTokens: 0,
|
|
15159
|
+
cacheReadTokens: 0,
|
|
15160
|
+
cacheWriteTokens: 0,
|
|
15161
|
+
reasoningTokens: 0
|
|
15162
|
+
};
|
|
15731
15163
|
const safetyDecisionCounts = { allowed: 0, blocked: 0, permissionRequested: 0 };
|
|
15732
15164
|
const escalationCounts = { requested: 0, approved: 0, denied: 0, timedOut: 0 };
|
|
15733
15165
|
const blockedAttempts = [];
|
|
@@ -15871,7 +15303,7 @@ function createDispatchBundle(context, options) {
|
|
|
15871
15303
|
const foldWorkerEvent = (raw) => {
|
|
15872
15304
|
outputCapture.observe(raw);
|
|
15873
15305
|
const event = raw;
|
|
15874
|
-
if (
|
|
15306
|
+
if (isRecord12(event)) {
|
|
15875
15307
|
if (eventContainsFirstModelToken(event)) markObservedPhase("firstModelTokenAt");
|
|
15876
15308
|
if (eventStartsTool(event)) markObservedPhase("firstToolAt");
|
|
15877
15309
|
}
|
|
@@ -15890,7 +15322,7 @@ function createDispatchBundle(context, options) {
|
|
|
15890
15322
|
);
|
|
15891
15323
|
}
|
|
15892
15324
|
}
|
|
15893
|
-
if (
|
|
15325
|
+
if (isRecord12(event)) {
|
|
15894
15326
|
const finishEntry = appendDispatchFinishContractEntry(finishContractEntries, event);
|
|
15895
15327
|
if (finishEntry !== null) {
|
|
15896
15328
|
finishContractAssistantText = finishEntry.assistantText;
|
|
@@ -15900,9 +15332,9 @@ function createDispatchBundle(context, options) {
|
|
|
15900
15332
|
}
|
|
15901
15333
|
if (event.type === "clio_coder_permission_escalated" && event.payload && typeof event.payload.requestId === "string") {
|
|
15902
15334
|
escalationCounts.requested += 1;
|
|
15903
|
-
const ctx =
|
|
15904
|
-
const classification = ctx !== null &&
|
|
15905
|
-
const policy = ctx !== null &&
|
|
15335
|
+
const ctx = isRecord12(event.payload.decision) ? event.payload.decision : null;
|
|
15336
|
+
const classification = ctx !== null && isRecord12(ctx.classification) ? ctx.classification : null;
|
|
15337
|
+
const policy = ctx !== null && isRecord12(ctx.policy) ? ctx.policy : null;
|
|
15906
15338
|
const actionClass = readStringOrNull(classification?.actionClass) ?? readStringOrNull(ctx?.actionClass) ?? readStringOrNull(event.payload.actionClass) ?? "unknown";
|
|
15907
15339
|
const reasons = readStringArrayOrNull(ctx?.reasons) ?? readStringArrayOrNull(classification?.reasons);
|
|
15908
15340
|
const reasonCode = readStringOrNull(ctx?.reasonCode) ?? readStringOrNull(policy?.reasonCode);
|
|
@@ -15929,13 +15361,9 @@ function createDispatchBundle(context, options) {
|
|
|
15929
15361
|
escalation: true
|
|
15930
15362
|
});
|
|
15931
15363
|
}
|
|
15932
|
-
if (event.type === "message_end" && event.message?.role === "assistant" &&
|
|
15364
|
+
if (event.type === "message_end" && event.message?.role === "assistant" && isRecord12(event.message.usage)) {
|
|
15933
15365
|
const u = event.message.usage;
|
|
15934
|
-
tokenMeter
|
|
15935
|
-
tokenMeter.outputTokens += typeof u.output === "number" ? u.output : 0;
|
|
15936
|
-
tokenMeter.cacheReadTokens += typeof u.cacheRead === "number" ? u.cacheRead : 0;
|
|
15937
|
-
tokenMeter.cacheWriteTokens += typeof u.cacheWrite === "number" ? u.cacheWrite : 0;
|
|
15938
|
-
tokenMeter.reasoningTokens += extractReasoningTokenCount(u);
|
|
15366
|
+
accumulateNativeUsage(tokenMeter, u, lifecycle.target.effectivePricing.rates);
|
|
15939
15367
|
const requestedModelId = readStringOrNull(event.message.model);
|
|
15940
15368
|
const responseModelIdObservation = responseModelIdObservationFromRecord(event.message, "not-observed");
|
|
15941
15369
|
const differingResponseModelId = readStringOrNull(event.message.responseModel);
|
|
@@ -16287,11 +15715,12 @@ function createDispatchBundle(context, options) {
|
|
|
16287
15715
|
outputTokenCount: tokenMeter.outputTokens,
|
|
16288
15716
|
cacheReadTokenCount: tokenMeter.cacheReadTokens,
|
|
16289
15717
|
cacheWriteTokenCount: tokenMeter.cacheWriteTokens,
|
|
15718
|
+
...tokenMeter.cacheWrite1hTokens === void 0 ? {} : { cacheWrite1hTokenCount: tokenMeter.cacheWrite1hTokens },
|
|
16290
15719
|
reasoningTokenCount: tokenMeter.reasoningTokens,
|
|
16291
15720
|
...upstreamResponses.length > 0 ? { upstreamResponses: [...upstreamResponses] } : {},
|
|
16292
15721
|
...capturedOutput !== void 0 ? { output: capturedOutput } : {},
|
|
16293
15722
|
costUsd,
|
|
16294
|
-
costProvenance: lifecycle.target.effectivePricing.provenance,
|
|
15723
|
+
costProvenance: lifecycle.target.effectivePricing.provenance === "unknown" && costUsd > 0 ? "estimated" : lifecycle.target.effectivePricing.provenance,
|
|
16295
15724
|
compiledPromptHash: lifecycle.compiledPromptHash,
|
|
16296
15725
|
staticCompositionHash: lifecycle.staticCompositionHash,
|
|
16297
15726
|
staticShellHash: lifecycle.staticCompositionHash,
|
|
@@ -16373,6 +15802,7 @@ function createDispatchBundle(context, options) {
|
|
|
16373
15802
|
outputTokenCount: receipt.outputTokenCount ?? 0,
|
|
16374
15803
|
cacheReadTokenCount: receipt.cacheReadTokenCount ?? 0,
|
|
16375
15804
|
cacheWriteTokenCount: receipt.cacheWriteTokenCount ?? 0,
|
|
15805
|
+
...receipt.cacheWrite1hTokenCount === void 0 ? {} : { cacheWrite1hTokenCount: receipt.cacheWrite1hTokenCount },
|
|
16376
15806
|
reasoningTokenCount: receipt.reasoningTokenCount ?? 0,
|
|
16377
15807
|
staticShellHash: receipt.staticShellHash ?? null,
|
|
16378
15808
|
sessionShellHash: receipt.sessionShellHash ?? null,
|
|
@@ -16476,7 +15906,7 @@ function createDispatchBundle(context, options) {
|
|
|
16476
15906
|
output: capturedOutput?.state === "final" ? capturedOutput.text : null,
|
|
16477
15907
|
outputTruncated: capturedOutput?.truncated === true,
|
|
16478
15908
|
cwd: lifecycle.cwd,
|
|
16479
|
-
networkAllowed: lifecycle.admission.allowedTools.includes(ToolNames.WebFetch) || lifecycle.target.runtime.externalAgentLoop?.network === "externally-governed-unobserved",
|
|
15909
|
+
networkAllowed: lifecycle.admission.allowedTools.includes(ToolNames.WebFetch) || lifecycle.admission.allowedTools.includes(ToolNames.WebRead) || lifecycle.target.runtime.externalAgentLoop?.network === "externally-governed-unobserved",
|
|
16480
15910
|
observedRunEffects,
|
|
16481
15911
|
filesystem: nodeResultContractFilesystem()
|
|
16482
15912
|
});
|
|
@@ -16569,6 +15999,7 @@ function createDispatchBundle(context, options) {
|
|
|
16569
15999
|
sessionShellHash: receiptDraft.sessionShellHash ?? null,
|
|
16570
16000
|
dynamicHash: receiptDraft.dynamicHash ?? null,
|
|
16571
16001
|
...receiptDraft.cacheReadTokenCount !== void 0 ? { cacheReadTokenCount: receiptDraft.cacheReadTokenCount } : {},
|
|
16002
|
+
...receiptDraft.cacheWrite1hTokenCount === void 0 ? {} : { cacheWrite1hTokenCount: receiptDraft.cacheWrite1hTokenCount },
|
|
16572
16003
|
...receiptDraft.cacheWriteTokenCount !== void 0 ? { cacheWriteTokenCount: receiptDraft.cacheWriteTokenCount } : {},
|
|
16573
16004
|
...activeRun.heartbeatAt ? { heartbeatAt: heartbeatIso(activeRun.heartbeatAt) } : {}
|
|
16574
16005
|
};
|
|
@@ -16745,7 +16176,11 @@ function createDispatchBundle(context, options) {
|
|
|
16745
16176
|
const release = () => settlement.abandon(handle.runId);
|
|
16746
16177
|
handle.finalPromise.then(release, release);
|
|
16747
16178
|
}
|
|
16748
|
-
if (req.lineage)
|
|
16179
|
+
if (req.lineage) {
|
|
16180
|
+
const finalPromise = handle.finalPromise.finally(() => writerLease?.release());
|
|
16181
|
+
trackMemberWork(handle.runId, finalPromise);
|
|
16182
|
+
return { ...handle, finalPromise };
|
|
16183
|
+
}
|
|
16749
16184
|
const assignment = assignments.open(handle.runId, assignmentPolicyFor(handle.effectiveRequest));
|
|
16750
16185
|
persistAssignment(registerAssignment(assignment.id), `${assignment.id}:open`);
|
|
16751
16186
|
assignments.attachAttempt(assignment.id, handle.events);
|
|
@@ -16832,7 +16267,13 @@ function createDispatchBundle(context, options) {
|
|
|
16832
16267
|
),
|
|
16833
16268
|
req
|
|
16834
16269
|
);
|
|
16835
|
-
assertPostRuntimeToolCompatibility(
|
|
16270
|
+
assertPostRuntimeToolCompatibility(
|
|
16271
|
+
req.agentId,
|
|
16272
|
+
agentSpec,
|
|
16273
|
+
effectiveTools,
|
|
16274
|
+
target,
|
|
16275
|
+
pathScope.writeBoundaries.length > 0
|
|
16276
|
+
);
|
|
16836
16277
|
assertRuntimeCanHonorWorkerPermissionMode(target.runtime, settings?.fleet.permissions.mode ?? "deny");
|
|
16837
16278
|
assertResponseSchemaEnforceable(target.runtime, target.modelCapabilities, req.responseSchema, effectiveTools.length);
|
|
16838
16279
|
assertWriteRootsEnforceable(target.runtime, pathScope.writeBoundaries);
|
|
@@ -17206,7 +16647,11 @@ function createDispatchBundle(context, options) {
|
|
|
17206
16647
|
async start() {
|
|
17207
16648
|
if (options?.journalRunEvents === true) journalBridge = attachRunEventJournalBridge(context.bus);
|
|
17208
16649
|
cleanupDispatchReservations({ startup: true, nowMs: now() });
|
|
17209
|
-
ledger = openLedger(
|
|
16650
|
+
ledger = openLedger({
|
|
16651
|
+
get maxRuns() {
|
|
16652
|
+
return getEffectiveSettings()?.fleet?.history?.maxRuns ?? resolveGuardrail("maxDispatchRuns");
|
|
16653
|
+
}
|
|
16654
|
+
});
|
|
17210
16655
|
try {
|
|
17211
16656
|
const recovery = recoverOrphanReceipts(ledger);
|
|
17212
16657
|
if (recovery.recovered > 0 || recovery.corrupt > 0 || recovery.abandoned > 0 || recovery.sealed > 0) {
|
|
@@ -17315,6 +16760,7 @@ function createDispatchBundle(context, options) {
|
|
|
17315
16760
|
const meter = run.meter;
|
|
17316
16761
|
const totalTokens = meter.inputTokens + meter.outputTokens + meter.cacheReadTokens + meter.cacheWriteTokens;
|
|
17317
16762
|
const costUsd = calculateUsageCostUsd(meter, run.pricing);
|
|
16763
|
+
const costProvenance = run.costProvenance === "unknown" && costUsd > 0 ? "estimated" : run.costProvenance;
|
|
17318
16764
|
const startedMs = Date.parse(run.startedAt);
|
|
17319
16765
|
const elapsedMs = Number.isFinite(startedMs) ? Math.max(0, tickNow - startedMs) : 0;
|
|
17320
16766
|
const timing = deriveRunPhaseDurations(run.timing, run.startedAt, new Date(tickNow).toISOString());
|
|
@@ -17332,14 +16778,14 @@ function createDispatchBundle(context, options) {
|
|
|
17332
16778
|
timing,
|
|
17333
16779
|
tokens: { input: meter.inputTokens, output: meter.outputTokens, total: totalTokens },
|
|
17334
16780
|
costUsd,
|
|
17335
|
-
costProvenance
|
|
16781
|
+
costProvenance,
|
|
17336
16782
|
node: run.node !== null ? { ...run.node } : null
|
|
17337
16783
|
});
|
|
17338
16784
|
totals.inputTokens += meter.inputTokens;
|
|
17339
16785
|
totals.outputTokens += meter.outputTokens;
|
|
17340
16786
|
totals.totalTokens += totalTokens;
|
|
17341
16787
|
totals.costUsd += costUsd;
|
|
17342
|
-
costAmounts.push({ usd: costUsd, provenance:
|
|
16788
|
+
costAmounts.push({ usd: costUsd, provenance: costProvenance });
|
|
17343
16789
|
totals.runtimeSeconds += elapsedMs / 1e3;
|
|
17344
16790
|
}
|
|
17345
16791
|
const retrying = [...retryQueue.values()].map((entry) => ({
|
|
@@ -17370,6 +16816,7 @@ function createDispatchBundle(context, options) {
|
|
|
17370
16816
|
function settleQueuedAssignmentsForShutdown() {
|
|
17371
16817
|
for (const [finishedRunId, entry] of retryQueue) {
|
|
17372
16818
|
clearTimeout(entry.timer);
|
|
16819
|
+
entry.settleCanceled();
|
|
17373
16820
|
if (assignments.get(entry.rootRunId)?.status === "running") {
|
|
17374
16821
|
settleAssignmentDurably(asAssignmentId(entry.rootRunId), entry.terminalCandidate, "canceled");
|
|
17375
16822
|
}
|
|
@@ -17409,11 +16856,25 @@ function createDispatchBundle(context, options) {
|
|
|
17409
16856
|
const stored = listStoredAssignments().find((record) => record.assignmentId === id || record.attempts.includes(id));
|
|
17410
16857
|
return stored?.assignmentId ?? ledger?.get(id)?.lineage?.rootRunId ?? id;
|
|
17411
16858
|
}
|
|
16859
|
+
function controlRootFor(id) {
|
|
16860
|
+
const exact = controlRootsByAttempt.get(id);
|
|
16861
|
+
if (exact !== void 0) return exact;
|
|
16862
|
+
const roots = /* @__PURE__ */ new Set();
|
|
16863
|
+
for (const [attempt, root] of assignmentRootsByAttempt) {
|
|
16864
|
+
if (root === id) roots.add(controlRootsByAttempt.get(attempt) ?? root);
|
|
16865
|
+
}
|
|
16866
|
+
if (roots.size > 1) {
|
|
16867
|
+
throw new Error(`dispatch: '${id}' names multiple fleet members; use a concrete member or assignment id`);
|
|
16868
|
+
}
|
|
16869
|
+
return roots.values().next().value ?? assignmentRootFor(id);
|
|
16870
|
+
}
|
|
17412
16871
|
function currentAssignmentRun(id) {
|
|
17413
|
-
const
|
|
16872
|
+
const exact = active.get(id);
|
|
16873
|
+
if (exact !== void 0) return exact;
|
|
16874
|
+
const rootRunId = controlRootFor(id);
|
|
17414
16875
|
let current = null;
|
|
17415
16876
|
for (const run of active.values()) {
|
|
17416
|
-
if (run.lineage.rootRunId !== rootRunId) continue;
|
|
16877
|
+
if ((controlRootsByAttempt.get(run.runId) ?? run.lineage.rootRunId) !== rootRunId) continue;
|
|
17417
16878
|
if (current === null || run.lineage.attempt > current.lineage.attempt) current = run;
|
|
17418
16879
|
}
|
|
17419
16880
|
return current;
|
|
@@ -17464,8 +16925,25 @@ function createDispatchBundle(context, options) {
|
|
|
17464
16925
|
await Promise.allSettled([...assignmentWrites]);
|
|
17465
16926
|
}
|
|
17466
16927
|
},
|
|
16928
|
+
async drainMember(runId) {
|
|
16929
|
+
const root = controlRootFor(runId);
|
|
16930
|
+
const errors = [];
|
|
16931
|
+
while (true) {
|
|
16932
|
+
const pending = [...memberWork.get(root) ?? []];
|
|
16933
|
+
const live = currentAssignmentRun(runId);
|
|
16934
|
+
if (live !== null) pending.push(live.finalPromise);
|
|
16935
|
+
if (pending.length === 0) break;
|
|
16936
|
+
for (const result of await Promise.allSettled(pending)) {
|
|
16937
|
+
if (result.status === "rejected" && !errors.includes(result.reason)) errors.push(result.reason);
|
|
16938
|
+
}
|
|
16939
|
+
}
|
|
16940
|
+
if (errors.length === 1) throw errors[0];
|
|
16941
|
+
if (errors.length > 1) throw new AggregateError(errors, "dispatch member drain failed", { cause: errors[0] });
|
|
16942
|
+
},
|
|
17467
16943
|
abort(runId, reason) {
|
|
17468
|
-
const rootRunId =
|
|
16944
|
+
const rootRunId = controlRootFor(runId);
|
|
16945
|
+
const run = currentAssignmentRun(runId);
|
|
16946
|
+
canceledControlRoots.add(rootRunId);
|
|
17469
16947
|
const queued = pendingCapacity.get(rootRunId);
|
|
17470
16948
|
if (queued !== void 0 && capacityAdmission.cancel(rootRunId)) {
|
|
17471
16949
|
persistAssignment(cancelStoredAssignment(rootRunId), `${rootRunId}:cancel-queued`);
|
|
@@ -17483,10 +16961,13 @@ function createDispatchBundle(context, options) {
|
|
|
17483
16961
|
persistAssignment(cancelStoredAssignment(rootRunId), `${rootRunId}:cancel`);
|
|
17484
16962
|
}
|
|
17485
16963
|
for (const [finishedRunId, retry] of retryQueue) {
|
|
17486
|
-
if (retry.rootRunId !== rootRunId) continue;
|
|
16964
|
+
if ((controlRootsByAttempt.get(finishedRunId) ?? retry.rootRunId) !== rootRunId) continue;
|
|
17487
16965
|
clearTimeout(retry.timer);
|
|
16966
|
+
retry.settleCanceled();
|
|
17488
16967
|
retryQueue.delete(finishedRunId);
|
|
17489
|
-
|
|
16968
|
+
if (retry.rootRunId === rootRunId) {
|
|
16969
|
+
settleAssignmentDurably(asAssignmentId(rootRunId), retry.terminalCandidate, "canceled");
|
|
16970
|
+
}
|
|
17490
16971
|
context.bus.emit(BusChannels.RunAborted, {
|
|
17491
16972
|
source: "dispatch_abort",
|
|
17492
16973
|
runId: finishedRunId,
|
|
@@ -17501,7 +16982,6 @@ function createDispatchBundle(context, options) {
|
|
|
17501
16982
|
event: { type: "retry_canceled", attempt: retry.attempt }
|
|
17502
16983
|
});
|
|
17503
16984
|
}
|
|
17504
|
-
const run = currentAssignmentRun(rootRunId);
|
|
17505
16985
|
if (!run) return;
|
|
17506
16986
|
emitRunAborted(run, "dispatch_abort");
|
|
17507
16987
|
run.aborted = true;
|
|
@@ -17729,7 +17209,6 @@ async function executePlan(initialPlan, adapter, signal) {
|
|
|
17729
17209
|
}
|
|
17730
17210
|
const ledgerId = agentSteps.length >= 2 ? `ledger-plan-${plan.hash.slice(0, 12)}-${Date.now().toString(36)}` : null;
|
|
17731
17211
|
const ledger = ledgerId === null ? void 0 : { id: ledgerId, sequence: 0 };
|
|
17732
|
-
if (ledgerId !== null) await openAgentLedger(ledgerId);
|
|
17733
17212
|
const admissions = agentSteps.map((step) => adapter.preflight(step));
|
|
17734
17213
|
const reservation = adapter.reserve(plan, admissions);
|
|
17735
17214
|
const reservationOwners = /* @__PURE__ */ new Set([reservation.ownerId]);
|
|
@@ -17739,6 +17218,9 @@ async function executePlan(initialPlan, adapter, signal) {
|
|
|
17739
17218
|
const unneeded = /* @__PURE__ */ new Set();
|
|
17740
17219
|
const needsDecision = [];
|
|
17741
17220
|
const running = /* @__PURE__ */ new Map();
|
|
17221
|
+
const cleanupErrors = [];
|
|
17222
|
+
const memberIds = /* @__PURE__ */ new Set();
|
|
17223
|
+
const canceledSteps = /* @__PURE__ */ new Set();
|
|
17742
17224
|
const checkPassed = /* @__PURE__ */ new Map();
|
|
17743
17225
|
const loopFindings = /* @__PURE__ */ new Map();
|
|
17744
17226
|
const attemptsRun = /* @__PURE__ */ new Map();
|
|
@@ -17751,11 +17233,19 @@ async function executePlan(initialPlan, adapter, signal) {
|
|
|
17751
17233
|
let lastMutationSeq = 0;
|
|
17752
17234
|
let stopped = false;
|
|
17753
17235
|
const codeAbort = new AbortController();
|
|
17236
|
+
const cancelOne = (owned) => {
|
|
17237
|
+
if (owned.assignmentId === null || owned.canceled) return;
|
|
17238
|
+
owned.canceled = true;
|
|
17239
|
+
try {
|
|
17240
|
+
adapter.cancel(owned.assignmentId);
|
|
17241
|
+
} catch (error) {
|
|
17242
|
+
cleanupErrors.push(error);
|
|
17243
|
+
}
|
|
17244
|
+
};
|
|
17754
17245
|
const cancelOwned = () => {
|
|
17755
17246
|
stopped = true;
|
|
17756
|
-
for (const owned of running.values()) if (owned.assignmentId !== null) adapter.cancel(owned.assignmentId);
|
|
17757
17247
|
codeAbort.abort();
|
|
17758
|
-
for (const
|
|
17248
|
+
for (const owned of running.values()) cancelOne(owned);
|
|
17759
17249
|
};
|
|
17760
17250
|
signal?.addEventListener("abort", cancelOwned, { once: true });
|
|
17761
17251
|
const loopOf = (step) => step.loop === void 0 ? null : loopsById.get(step.loop.loopId) ?? null;
|
|
@@ -17766,42 +17256,44 @@ async function executePlan(initialPlan, adapter, signal) {
|
|
|
17766
17256
|
results.set(step.id, result);
|
|
17767
17257
|
if (isWorkspaceMutator(step)) lastMutationSeq = sequence;
|
|
17768
17258
|
};
|
|
17769
|
-
|
|
17770
|
-
const
|
|
17771
|
-
|
|
17772
|
-
|
|
17773
|
-
|
|
17774
|
-
|
|
17775
|
-
recordCompletion(step, result);
|
|
17776
|
-
if (step.loop?.role === "check" && step.kind === "code") {
|
|
17777
|
-
checkPassed.set(step.id, result.succeeded);
|
|
17778
|
-
attemptsRun.set(step.loop.loopId, (attemptsRun.get(step.loop.loopId) ?? 0) + 1);
|
|
17779
|
-
}
|
|
17780
|
-
if (step.loop?.role === "check" && step.kind === "agent") {
|
|
17781
|
-
const loop = loopsById.get(step.loop.loopId);
|
|
17782
|
-
const decide = adapter.decideLoop;
|
|
17783
|
-
if (loop === void 0 || decide === void 0) {
|
|
17784
|
-
throw new Error(`execution plan: replayed loop check '${step.id}' has no decider`);
|
|
17259
|
+
const replayPrefix = async () => {
|
|
17260
|
+
for (const step of plan.steps) {
|
|
17261
|
+
const result = replayed.get(step.id);
|
|
17262
|
+
if (result === void 0) continue;
|
|
17263
|
+
if (!result.succeeded || !result.integrityValid) {
|
|
17264
|
+
throw new Error(`execution plan: replayed step '${step.id}' is not a completed successful step`);
|
|
17785
17265
|
}
|
|
17786
|
-
|
|
17787
|
-
|
|
17788
|
-
step,
|
|
17789
|
-
|
|
17790
|
-
|
|
17791
|
-
|
|
17792
|
-
|
|
17793
|
-
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
|
|
17266
|
+
recordCompletion(step, result);
|
|
17267
|
+
if (step.loop?.role === "check" && step.kind === "code") {
|
|
17268
|
+
checkPassed.set(step.id, result.succeeded);
|
|
17269
|
+
attemptsRun.set(step.loop.loopId, (attemptsRun.get(step.loop.loopId) ?? 0) + 1);
|
|
17270
|
+
}
|
|
17271
|
+
if (step.loop?.role === "check" && step.kind === "agent") {
|
|
17272
|
+
const loop = loopsById.get(step.loop.loopId);
|
|
17273
|
+
const decide = adapter.decideLoop;
|
|
17274
|
+
if (loop === void 0 || decide === void 0) {
|
|
17275
|
+
throw new Error(`execution plan: replayed loop check '${step.id}' has no decider`);
|
|
17276
|
+
}
|
|
17277
|
+
const decision = await decide({
|
|
17278
|
+
loop,
|
|
17279
|
+
step,
|
|
17280
|
+
attempt: step.loop.attempt,
|
|
17281
|
+
terminalAttempt: step.loop.attempt >= loop.maxAttempts,
|
|
17282
|
+
result,
|
|
17283
|
+
priorResults: results
|
|
17284
|
+
});
|
|
17285
|
+
checkPassed.set(step.id, decision.resolved);
|
|
17286
|
+
attemptsRun.set(step.loop.loopId, (attemptsRun.get(step.loop.loopId) ?? 0) + 1);
|
|
17287
|
+
if (decision.findings !== null) loopFindings.set(`${loop.id}:${step.loop.attempt}`, decision.findings);
|
|
17288
|
+
if (decision.needsDecision !== void 0 && decision.needsDecision !== null) {
|
|
17289
|
+
needsDecision.push(decision.needsDecision);
|
|
17290
|
+
}
|
|
17291
|
+
}
|
|
17292
|
+
if (step.loop?.role === "repair") {
|
|
17293
|
+
repairsRun.set(step.loop.loopId, (repairsRun.get(step.loop.loopId) ?? 0) + 1);
|
|
17799
17294
|
}
|
|
17800
17295
|
}
|
|
17801
|
-
|
|
17802
|
-
repairsRun.set(step.loop.loopId, (repairsRun.get(step.loop.loopId) ?? 0) + 1);
|
|
17803
|
-
}
|
|
17804
|
-
}
|
|
17296
|
+
};
|
|
17805
17297
|
const dependencyBlocks = (dependency, dependent) => {
|
|
17806
17298
|
if (unneeded.has(dependency)) return false;
|
|
17807
17299
|
if (skipped.has(dependency)) return true;
|
|
@@ -17842,10 +17334,10 @@ async function executePlan(initialPlan, adapter, signal) {
|
|
|
17842
17334
|
const closeBoundary = async (window, enforced, settled) => {
|
|
17843
17335
|
const verify = adapter.verifyWriteBoundary;
|
|
17844
17336
|
if (enforced === null || verify === void 0) return [...settled];
|
|
17845
|
-
const
|
|
17846
|
-
writeBoundaries.push(
|
|
17847
|
-
if (!
|
|
17848
|
-
const blamed = new Set(
|
|
17337
|
+
const outcome2 = await verify(window, enforced);
|
|
17338
|
+
writeBoundaries.push(outcome2);
|
|
17339
|
+
if (!outcome2.violated) return [...settled];
|
|
17340
|
+
const blamed = new Set(outcome2.failedStepIds);
|
|
17849
17341
|
return settled.map(
|
|
17850
17342
|
({ step, result }) => blamed.has(step.id) ? { step, result: { ...result, succeeded: false, boundaryViolated: true } } : { step, result }
|
|
17851
17343
|
);
|
|
@@ -17853,7 +17345,10 @@ async function executePlan(initialPlan, adapter, signal) {
|
|
|
17853
17345
|
const runCodeStepNode = async (step, handoffs) => {
|
|
17854
17346
|
const runCode = adapter.runCode;
|
|
17855
17347
|
if (runCode === void 0) throw new Error(`execution plan: no runner for code step '${step.id}'`);
|
|
17856
|
-
|
|
17348
|
+
const result = await runCode(step, handoffs, codeAbort.signal, results);
|
|
17349
|
+
if (!codeAbort.signal.aborted) return result;
|
|
17350
|
+
canceledSteps.add(step.id);
|
|
17351
|
+
return { ...result, succeeded: false, failureReason: result.failureReason ?? "execution plan canceled this step" };
|
|
17857
17352
|
};
|
|
17858
17353
|
const revalidateFor = async (wave) => {
|
|
17859
17354
|
const candidates = /* @__PURE__ */ new Set();
|
|
@@ -17871,6 +17366,7 @@ async function executePlan(initialPlan, adapter, signal) {
|
|
|
17871
17366
|
}
|
|
17872
17367
|
let halt = false;
|
|
17873
17368
|
for (const id of [...candidates].sort()) {
|
|
17369
|
+
if (stopped || signal?.aborted) return true;
|
|
17874
17370
|
const step = stepsById.get(id);
|
|
17875
17371
|
if (step?.kind !== "code") continue;
|
|
17876
17372
|
const spent = revalidations.get(id) ?? 0;
|
|
@@ -17896,7 +17392,6 @@ async function executePlan(initialPlan, adapter, signal) {
|
|
|
17896
17392
|
if (plan.onFailure === "stop") {
|
|
17897
17393
|
stopped = true;
|
|
17898
17394
|
codeAbort.abort();
|
|
17899
|
-
for (const ownerId of reservationOwners) adapter.releaseUnconsumed(ownerId);
|
|
17900
17395
|
halt = true;
|
|
17901
17396
|
}
|
|
17902
17397
|
}
|
|
@@ -17956,7 +17451,12 @@ async function executePlan(initialPlan, adapter, signal) {
|
|
|
17956
17451
|
const reason = !brokenMember && ran >= loop.maxAttempts ? "loop_bound_exhausted" : "loop_step_failed";
|
|
17957
17452
|
return { loopId: loop.id, resolved: false, attempts, repairs, reason };
|
|
17958
17453
|
});
|
|
17454
|
+
let outcome;
|
|
17455
|
+
let primaryError;
|
|
17456
|
+
let failed2 = false;
|
|
17959
17457
|
try {
|
|
17458
|
+
if (ledgerId !== null) await openAgentLedger(ledgerId);
|
|
17459
|
+
await replayPrefix();
|
|
17960
17460
|
let waveIndex = 0;
|
|
17961
17461
|
while (waveIndex < plan.waves.length) {
|
|
17962
17462
|
const wave = plan.waves[waveIndex];
|
|
@@ -18000,58 +17500,107 @@ async function executePlan(initialPlan, adapter, signal) {
|
|
|
18000
17500
|
boundaryWindow,
|
|
18001
17501
|
group.map((entry) => entry.step)
|
|
18002
17502
|
);
|
|
18003
|
-
const
|
|
18004
|
-
|
|
18005
|
-
|
|
18006
|
-
|
|
18007
|
-
|
|
18008
|
-
handoffs,
|
|
18009
|
-
{ ownerId: reservationByStep.get(step.id) ?? reservation.ownerId, memberId: step.id },
|
|
18010
|
-
ledger
|
|
18011
|
-
)
|
|
18012
|
-
}))
|
|
18013
|
-
);
|
|
18014
|
-
for (const { step, handle } of started) running.set(step.id, { assignmentId: handle.assignmentId });
|
|
17503
|
+
const failures = [];
|
|
17504
|
+
const fail = (error) => {
|
|
17505
|
+
failures.push(error);
|
|
17506
|
+
cancelOwned();
|
|
17507
|
+
};
|
|
18015
17508
|
const onSettled = (step, result) => {
|
|
18016
|
-
if (isPlanFailure(step, result) && plan.onFailure === "stop")
|
|
18017
|
-
stopped = true;
|
|
18018
|
-
for (const [runningStepId, owned] of running) {
|
|
18019
|
-
if (runningStepId !== step.id && owned.assignmentId !== null) adapter.cancel(owned.assignmentId);
|
|
18020
|
-
}
|
|
18021
|
-
codeAbort.abort();
|
|
18022
|
-
for (const ownerId of reservationOwners) adapter.releaseUnconsumed(ownerId);
|
|
18023
|
-
}
|
|
17509
|
+
if (isPlanFailure(step, result) && plan.onFailure === "stop") cancelOwned();
|
|
18024
17510
|
};
|
|
18025
|
-
const
|
|
18026
|
-
|
|
18027
|
-
|
|
18028
|
-
|
|
18029
|
-
|
|
18030
|
-
|
|
18031
|
-
|
|
17511
|
+
const terminals = [];
|
|
17512
|
+
await Promise.allSettled(
|
|
17513
|
+
launch.map(async ({ step, handoffs }) => {
|
|
17514
|
+
if (stopped || signal?.aborted) return;
|
|
17515
|
+
const owned = { assignmentId: null, canceled: false };
|
|
17516
|
+
running.set(step.id, owned);
|
|
17517
|
+
try {
|
|
17518
|
+
const handle = await adapter.run(
|
|
17519
|
+
step,
|
|
17520
|
+
handoffs,
|
|
17521
|
+
{ ownerId: reservationByStep.get(step.id) ?? reservation.ownerId, memberId: step.id },
|
|
17522
|
+
ledger
|
|
17523
|
+
);
|
|
17524
|
+
owned.assignmentId = handle.assignmentId;
|
|
17525
|
+
memberIds.add(handle.assignmentId);
|
|
17526
|
+
const terminal = handle.result.then(
|
|
17527
|
+
(result) => {
|
|
17528
|
+
if (owned.canceled) canceledSteps.add(step.id);
|
|
17529
|
+
const settled2 = owned.canceled ? { ...result, succeeded: false, failureReason: result.failureReason ?? "execution plan canceled this step" } : result;
|
|
17530
|
+
onSettled(step, settled2);
|
|
17531
|
+
if (settled2.succeeded) running.delete(step.id);
|
|
17532
|
+
return { step, result: settled2 };
|
|
17533
|
+
},
|
|
17534
|
+
(error) => {
|
|
17535
|
+
fail(error);
|
|
17536
|
+
throw error;
|
|
17537
|
+
}
|
|
17538
|
+
);
|
|
17539
|
+
terminals.push(Promise.allSettled([terminal]));
|
|
17540
|
+
if (stopped || signal?.aborted) cancelOne(owned);
|
|
17541
|
+
} catch (error) {
|
|
17542
|
+
running.delete(step.id);
|
|
17543
|
+
fail(error);
|
|
17544
|
+
}
|
|
17545
|
+
return;
|
|
17546
|
+
})
|
|
17547
|
+
);
|
|
17548
|
+
const codeTerminals = stopped || signal?.aborted ? [] : codeWork.map(async ({ step, handoffs }) => {
|
|
17549
|
+
try {
|
|
18032
17550
|
const result = await runCodeStepNode(step, handoffs);
|
|
18033
17551
|
onSettled(step, result);
|
|
18034
17552
|
return { step, result };
|
|
18035
|
-
})
|
|
18036
|
-
|
|
18037
|
-
|
|
17553
|
+
} catch (error) {
|
|
17554
|
+
fail(error);
|
|
17555
|
+
throw error;
|
|
17556
|
+
}
|
|
17557
|
+
});
|
|
17558
|
+
const outcomes = (await Promise.all([...terminals, Promise.allSettled(codeTerminals)])).flat();
|
|
17559
|
+
for (const id of memberIds) {
|
|
17560
|
+
try {
|
|
17561
|
+
await adapter.drainMember?.(id);
|
|
17562
|
+
memberIds.delete(id);
|
|
17563
|
+
} catch (error) {
|
|
17564
|
+
fail(error);
|
|
17565
|
+
}
|
|
17566
|
+
}
|
|
17567
|
+
const ran = outcomes.flatMap((outcome2) => outcome2.status === "fulfilled" ? [outcome2.value] : []);
|
|
17568
|
+
const settlementOrder = [...launch, ...codeWork].map(({ step }) => step.id);
|
|
17569
|
+
ran.sort((a, b) => settlementOrder.indexOf(a.step.id) - settlementOrder.indexOf(b.step.id));
|
|
17570
|
+
let settled;
|
|
17571
|
+
try {
|
|
17572
|
+
settled = await closeBoundary(boundaryWindow, enforced, ran);
|
|
17573
|
+
} catch (error) {
|
|
17574
|
+
if (failures.length === 0) throw error;
|
|
17575
|
+
throw new AggregateError([...failures, error], "execution plan failure and boundary verification failed", {
|
|
17576
|
+
cause: failures[0]
|
|
17577
|
+
});
|
|
17578
|
+
}
|
|
18038
17579
|
for (const { step, result } of settled) {
|
|
18039
|
-
running.set(step.id, { assignmentId: result.assignmentId });
|
|
18040
17580
|
recordCompletion(step, result);
|
|
18041
|
-
|
|
17581
|
+
try {
|
|
17582
|
+
await adapter.onStepSettled?.(step, result);
|
|
17583
|
+
} catch (error) {
|
|
17584
|
+
failures.push(error);
|
|
17585
|
+
cancelOwned();
|
|
17586
|
+
}
|
|
18042
17587
|
if (step.loop?.role === "repair") {
|
|
18043
17588
|
repairsRun.set(step.loop.loopId, (repairsRun.get(step.loop.loopId) ?? 0) + 1);
|
|
18044
17589
|
}
|
|
18045
17590
|
running.delete(step.id);
|
|
18046
17591
|
}
|
|
18047
|
-
|
|
17592
|
+
if (failures.length === 1) throw failures[0];
|
|
17593
|
+
if (failures.length > 1)
|
|
17594
|
+
throw new AggregateError(failures, "execution plan launch or result failed", { cause: failures[0] });
|
|
17595
|
+
for (const { step, result } of settled) {
|
|
17596
|
+
if (!signal?.aborted && !canceledSteps.has(step.id)) await settleCheck(step, result);
|
|
17597
|
+
}
|
|
18048
17598
|
const exhausted = settled.some(({ step }) => {
|
|
18049
17599
|
const loop = step.loop?.role === "check" ? loopOf(step) : null;
|
|
18050
17600
|
return loop !== null && step.loop !== void 0 && step.loop.attempt >= loop.maxAttempts && !loopResolved(loop);
|
|
18051
17601
|
});
|
|
18052
17602
|
if ((exhausted || settled.some(({ step, result }) => isPlanFailure(step, result))) && plan.onFailure === "stop") {
|
|
18053
17603
|
stopped = true;
|
|
18054
|
-
for (const ownerId of reservationOwners) adapter.releaseUnconsumed(ownerId);
|
|
18055
17604
|
}
|
|
18056
17605
|
}
|
|
18057
17606
|
if (!stopped && adapter.spliceAfter !== void 0) {
|
|
@@ -18080,7 +17629,7 @@ async function executePlan(initialPlan, adapter, signal) {
|
|
|
18080
17629
|
}
|
|
18081
17630
|
waveIndex += 1;
|
|
18082
17631
|
}
|
|
18083
|
-
|
|
17632
|
+
outcome = {
|
|
18084
17633
|
planHash: plan.hash,
|
|
18085
17634
|
results,
|
|
18086
17635
|
skipped: [...skipped],
|
|
@@ -18091,13 +17640,50 @@ async function executePlan(initialPlan, adapter, signal) {
|
|
|
18091
17640
|
writeBoundaries: [...writeBoundaries]
|
|
18092
17641
|
};
|
|
18093
17642
|
} catch (error) {
|
|
17643
|
+
failed2 = true;
|
|
17644
|
+
primaryError = error;
|
|
18094
17645
|
cancelOwned();
|
|
18095
|
-
throw error;
|
|
18096
17646
|
} finally {
|
|
18097
17647
|
signal?.removeEventListener("abort", cancelOwned);
|
|
18098
|
-
for (const
|
|
18099
|
-
|
|
17648
|
+
for (const id of memberIds) {
|
|
17649
|
+
try {
|
|
17650
|
+
await adapter.drainMember?.(id);
|
|
17651
|
+
} catch (error) {
|
|
17652
|
+
cleanupErrors.push(error);
|
|
17653
|
+
}
|
|
17654
|
+
}
|
|
17655
|
+
for (const ownerId of reservationOwners) {
|
|
17656
|
+
if (stopped || signal?.aborted) {
|
|
17657
|
+
try {
|
|
17658
|
+
adapter.releaseUnconsumed(ownerId);
|
|
17659
|
+
} catch (error) {
|
|
17660
|
+
cleanupErrors.push(error);
|
|
17661
|
+
}
|
|
17662
|
+
}
|
|
17663
|
+
try {
|
|
17664
|
+
adapter.release(ownerId);
|
|
17665
|
+
} catch (error) {
|
|
17666
|
+
cleanupErrors.push(error);
|
|
17667
|
+
}
|
|
17668
|
+
}
|
|
17669
|
+
if (ledgerId !== null) {
|
|
17670
|
+
try {
|
|
17671
|
+
await closeAgentLedger(ledgerId);
|
|
17672
|
+
} catch (error) {
|
|
17673
|
+
cleanupErrors.push(error);
|
|
17674
|
+
}
|
|
17675
|
+
}
|
|
17676
|
+
}
|
|
17677
|
+
if (cleanupErrors.length > 0) {
|
|
17678
|
+
throw new AggregateError(
|
|
17679
|
+
failed2 ? [primaryError, ...cleanupErrors] : cleanupErrors,
|
|
17680
|
+
"execution plan cleanup failed",
|
|
17681
|
+
failed2 ? { cause: primaryError } : void 0
|
|
17682
|
+
);
|
|
18100
17683
|
}
|
|
17684
|
+
if (failed2) throw primaryError;
|
|
17685
|
+
if (outcome === void 0) throw new Error("execution plan did not produce an outcome");
|
|
17686
|
+
return outcome;
|
|
18101
17687
|
}
|
|
18102
17688
|
|
|
18103
17689
|
// src/domains/dispatch/fleet-gate.ts
|
|
@@ -18195,6 +17781,7 @@ function createCostTracker() {
|
|
|
18195
17781
|
output,
|
|
18196
17782
|
cacheRead,
|
|
18197
17783
|
cacheWrite,
|
|
17784
|
+
...breakdown?.cacheWrite1h === void 0 ? {} : { cacheWrite1h: breakdown.cacheWrite1h },
|
|
18198
17785
|
reasoningTokens,
|
|
18199
17786
|
...apiCalls !== void 0 ? { apiCalls } : {},
|
|
18200
17787
|
...label !== void 0 ? { label } : {}
|
|
@@ -18204,6 +17791,7 @@ function createCostTracker() {
|
|
|
18204
17791
|
totals.output += output;
|
|
18205
17792
|
totals.cacheRead += cacheRead;
|
|
18206
17793
|
totals.cacheWrite += cacheWrite;
|
|
17794
|
+
if (breakdown?.cacheWrite1h !== void 0) totals.cacheWrite1h = (totals.cacheWrite1h ?? 0) + breakdown.cacheWrite1h;
|
|
18207
17795
|
totals.reasoningTokens += reasoningTokens;
|
|
18208
17796
|
totals.totalTokens += tokens2;
|
|
18209
17797
|
return resolvedUsd;
|
|
@@ -18227,6 +17815,7 @@ function createCostTracker() {
|
|
|
18227
17815
|
totals.output = 0;
|
|
18228
17816
|
totals.cacheRead = 0;
|
|
18229
17817
|
totals.cacheWrite = 0;
|
|
17818
|
+
delete totals.cacheWrite1h;
|
|
18230
17819
|
totals.reasoningTokens = 0;
|
|
18231
17820
|
totals.totalTokens = 0;
|
|
18232
17821
|
}
|
|
@@ -18774,6 +18363,7 @@ async function executeFleetRun(input) {
|
|
|
18774
18363
|
beginWriteBoundary: (window, stepIds) => boundaryEnforcer.begin(window, stepIds),
|
|
18775
18364
|
verifyWriteBoundary: (window, stepIds) => boundaryEnforcer.verify(window, stepIds),
|
|
18776
18365
|
cancel: (assignmentId) => dispatch.abort(assignmentId),
|
|
18366
|
+
drainMember: (assignmentId) => dispatch.drainMember?.(assignmentId) ?? Promise.resolve(),
|
|
18777
18367
|
release: (ownerId) => {
|
|
18778
18368
|
if (ownerId === NO_WORKER_RESERVATION) return;
|
|
18779
18369
|
dispatch.reservations?.release(ownerId);
|
|
@@ -18961,7 +18551,7 @@ function hasRunProvenance(view) {
|
|
|
18961
18551
|
return view.pipeline !== void 0 || view.personaOverride !== void 0 || view.escalation !== void 0 || view.autonomyEnforcement !== void 0;
|
|
18962
18552
|
}
|
|
18963
18553
|
function runProvenanceFromUnknown(value) {
|
|
18964
|
-
if (!
|
|
18554
|
+
if (!isRecord13(value)) return {};
|
|
18965
18555
|
const view = {};
|
|
18966
18556
|
const pipeline = pipelineFromUnknown(value.pipeline);
|
|
18967
18557
|
if (pipeline !== null) view.pipeline = pipeline;
|
|
@@ -18973,14 +18563,14 @@ function runProvenanceFromUnknown(value) {
|
|
|
18973
18563
|
if (autonomyEnforcement !== null) view.autonomyEnforcement = autonomyEnforcement;
|
|
18974
18564
|
return view;
|
|
18975
18565
|
}
|
|
18976
|
-
function
|
|
18566
|
+
function isRecord13(value) {
|
|
18977
18567
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18978
18568
|
}
|
|
18979
18569
|
function finiteNumber(value) {
|
|
18980
18570
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
18981
18571
|
}
|
|
18982
18572
|
function pipelineFromUnknown(value) {
|
|
18983
|
-
if (!
|
|
18573
|
+
if (!isRecord13(value)) return null;
|
|
18984
18574
|
const position = finiteNumber(value.position);
|
|
18985
18575
|
const inputBytes = finiteNumber(value.inputBytes);
|
|
18986
18576
|
if (position === null || inputBytes === null) return null;
|
|
@@ -18988,11 +18578,11 @@ function pipelineFromUnknown(value) {
|
|
|
18988
18578
|
return { fromRunId, position, inputBytes, inputTruncated: value.inputTruncated === true };
|
|
18989
18579
|
}
|
|
18990
18580
|
function personaOverrideFromUnknown(value) {
|
|
18991
|
-
if (!
|
|
18581
|
+
if (!isRecord13(value) || typeof value.promptHash !== "string" || value.promptHash.length === 0) return null;
|
|
18992
18582
|
return { promptHash: value.promptHash };
|
|
18993
18583
|
}
|
|
18994
18584
|
function autonomyEnforcementFromUnknown(value) {
|
|
18995
|
-
if (!
|
|
18585
|
+
if (!isRecord13(value)) return null;
|
|
18996
18586
|
if (value.grade !== "mediated" && value.grade !== "approximated" && value.grade !== "bypassed") return null;
|
|
18997
18587
|
if (typeof value.autonomy !== "string" || value.autonomy.length === 0) return null;
|
|
18998
18588
|
const view = { grade: value.grade, autonomy: value.autonomy };
|
|
@@ -19001,9 +18591,9 @@ function autonomyEnforcementFromUnknown(value) {
|
|
|
19001
18591
|
return view;
|
|
19002
18592
|
}
|
|
19003
18593
|
function escalationFromUnknown(safety) {
|
|
19004
|
-
if (!
|
|
18594
|
+
if (!isRecord13(safety)) return null;
|
|
19005
18595
|
const decisions = safety.decisions;
|
|
19006
|
-
if (!
|
|
18596
|
+
if (!isRecord13(decisions)) return null;
|
|
19007
18597
|
const requested = finiteNumber(decisions.escalationRequested);
|
|
19008
18598
|
if (requested === null) return null;
|
|
19009
18599
|
return {
|
|
@@ -19245,7 +18835,7 @@ async function loadEvidenceTrustStatus(dataDir, evidenceId) {
|
|
|
19245
18835
|
}
|
|
19246
18836
|
const source = `${evidenceId}/trust-status.json`;
|
|
19247
18837
|
const parsed = parseJson2(raw, source);
|
|
19248
|
-
if (!
|
|
18838
|
+
if (!isRecord14(parsed)) throw new Error(`${source}: expected object`);
|
|
19249
18839
|
if (parsed.version !== 1) throw new Error(`${source}: expected version 1`);
|
|
19250
18840
|
if (readString2(parsed, source, "evidenceId") !== evidenceId) {
|
|
19251
18841
|
throw new Error(`${source}.evidenceId: expected ${evidenceId}`);
|
|
@@ -19258,7 +18848,7 @@ async function loadEvidenceTrustStatus(dataDir, evidenceId) {
|
|
|
19258
18848
|
projection: "canonical",
|
|
19259
18849
|
runs: parsed.runs.map((entry, index) => {
|
|
19260
18850
|
const entrySource = `${source}.runs[${index}]`;
|
|
19261
|
-
if (!
|
|
18851
|
+
if (!isRecord14(entry)) throw new Error(`${entrySource}: expected object`);
|
|
19262
18852
|
return {
|
|
19263
18853
|
runId: readString2(entry, entrySource, "runId"),
|
|
19264
18854
|
status: normalizeTrustStatus(entry.status)
|
|
@@ -19276,10 +18866,10 @@ async function loadEvidenceRunProvenance(dataDir, evidenceId) {
|
|
|
19276
18866
|
throw error;
|
|
19277
18867
|
}
|
|
19278
18868
|
const parsed = parseJson2(raw, `${evidenceId}/receipt.json`);
|
|
19279
|
-
if (!
|
|
18869
|
+
if (!isRecord14(parsed) || !Array.isArray(parsed.receipts)) return [];
|
|
19280
18870
|
const out3 = [];
|
|
19281
18871
|
for (const entry of parsed.receipts) {
|
|
19282
|
-
if (!
|
|
18872
|
+
if (!isRecord14(entry) || typeof entry.runId !== "string") continue;
|
|
19283
18873
|
const view = runProvenanceFromUnknown(entry);
|
|
19284
18874
|
if (hasRunProvenance(view)) out3.push({ runId: entry.runId, view });
|
|
19285
18875
|
}
|
|
@@ -19295,9 +18885,9 @@ async function loadEvidenceGateDecisions(dataDir, evidenceId) {
|
|
|
19295
18885
|
throw error;
|
|
19296
18886
|
}
|
|
19297
18887
|
const parsed = parseJson2(raw, `${evidenceId}/gate-decisions.json`);
|
|
19298
|
-
if (!
|
|
18888
|
+
if (!isRecord14(parsed) || !Array.isArray(parsed.decisions)) return [];
|
|
19299
18889
|
return parsed.decisions.filter((entry) => {
|
|
19300
|
-
if (!
|
|
18890
|
+
if (!isRecord14(entry)) return false;
|
|
19301
18891
|
return verifyGateDecisionArtifact(entry).ok;
|
|
19302
18892
|
});
|
|
19303
18893
|
}
|
|
@@ -19320,7 +18910,7 @@ async function listEvidenceOverviews(dataDir) {
|
|
|
19320
18910
|
return overviews;
|
|
19321
18911
|
}
|
|
19322
18912
|
function parseOverview(value, source) {
|
|
19323
|
-
if (!
|
|
18913
|
+
if (!isRecord14(value)) throw new Error(`${source}: expected object`);
|
|
19324
18914
|
if (value.version !== 1) throw new Error(`${source}: expected version 1`);
|
|
19325
18915
|
const evidenceId = readString2(value, source, "evidenceId");
|
|
19326
18916
|
const sourceValue = readSource(value.source, `${source}.source`);
|
|
@@ -19364,13 +18954,13 @@ function parseOverview(value, source) {
|
|
|
19364
18954
|
};
|
|
19365
18955
|
}
|
|
19366
18956
|
function parseFindingsFile(value, source) {
|
|
19367
|
-
if (!
|
|
18957
|
+
if (!isRecord14(value)) throw new Error(`${source}: expected object`);
|
|
19368
18958
|
if (value.version !== 1) throw new Error(`${source}: expected version 1`);
|
|
19369
18959
|
if (!Array.isArray(value.findings)) throw new Error(`${source}.findings: expected array`);
|
|
19370
18960
|
return value.findings.map((entry, index) => parseFinding(entry, `${source}.findings[${index}]`));
|
|
19371
18961
|
}
|
|
19372
18962
|
function parseFinding(value, source) {
|
|
19373
|
-
if (!
|
|
18963
|
+
if (!isRecord14(value)) throw new Error(`${source}: expected object`);
|
|
19374
18964
|
const severity = readString2(value, source, "severity");
|
|
19375
18965
|
if (severity !== "info" && severity !== "warn") throw new Error(`${source}.severity: expected info or warn`);
|
|
19376
18966
|
const tag = readString2(value, source, "tag");
|
|
@@ -19383,14 +18973,14 @@ function parseFinding(value, source) {
|
|
|
19383
18973
|
};
|
|
19384
18974
|
}
|
|
19385
18975
|
function readSource(value, source) {
|
|
19386
|
-
if (!
|
|
18976
|
+
if (!isRecord14(value)) throw new Error(`${source}: expected object`);
|
|
19387
18977
|
if (value.kind === "run") return { kind: "run", runId: readString2(value, source, "runId") };
|
|
19388
18978
|
if (value.kind === "session") return { kind: "session", sessionId: readString2(value, source, "sessionId") };
|
|
19389
18979
|
if (value.kind === "eval") return { kind: "eval", evalId: readString2(value, source, "evalId") };
|
|
19390
18980
|
throw new Error(`${source}.kind: expected run, session, or eval`);
|
|
19391
18981
|
}
|
|
19392
18982
|
function readTotals(value, source) {
|
|
19393
|
-
if (!
|
|
18983
|
+
if (!isRecord14(value)) throw new Error(`${source}: expected object`);
|
|
19394
18984
|
return {
|
|
19395
18985
|
runs: readNumber2(value, source, "runs"),
|
|
19396
18986
|
receipts: readNumber2(value, source, "receipts"),
|
|
@@ -19448,7 +19038,7 @@ function parseJson2(raw, source) {
|
|
|
19448
19038
|
throw new Error(`${source}: invalid JSON: ${message}`);
|
|
19449
19039
|
}
|
|
19450
19040
|
}
|
|
19451
|
-
function
|
|
19041
|
+
function isRecord14(value) {
|
|
19452
19042
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19453
19043
|
}
|
|
19454
19044
|
function findingsFile(evidenceId, findings) {
|
|
@@ -19458,7 +19048,7 @@ function readDecisions(value, source) {
|
|
|
19458
19048
|
if (!Array.isArray(value)) throw new Error(`${source}: expected array`);
|
|
19459
19049
|
return value.map((entry, index) => {
|
|
19460
19050
|
const path2 = `${source}[${index}]`;
|
|
19461
|
-
if (!
|
|
19051
|
+
if (!isRecord14(entry) || !isDecisionRecord(entry.record)) throw new Error(`${path2}: expected recorded decision`);
|
|
19462
19052
|
return {
|
|
19463
19053
|
runId: readString2(entry, path2, "runId"),
|
|
19464
19054
|
sessionId: readString2(entry, path2, "sessionId"),
|
|
@@ -19848,7 +19438,10 @@ function isValidationProtectedArtifact(entry) {
|
|
|
19848
19438
|
}
|
|
19849
19439
|
function validationToolCallCandidate(entry, linked, runSources) {
|
|
19850
19440
|
const call = extractSessionToolCall(entry, linked);
|
|
19851
|
-
|
|
19441
|
+
const effective = effectiveToolCall(call.tool, call.args);
|
|
19442
|
+
if (validationToolCallSummary(effective.toolName, effective.viaGateway ? effective.args : call.args) === null) {
|
|
19443
|
+
return null;
|
|
19444
|
+
}
|
|
19852
19445
|
return {
|
|
19853
19446
|
toolCallId: call.id,
|
|
19854
19447
|
runId: validationRunIdFor(linked, runSources),
|
|
@@ -19857,7 +19450,7 @@ function validationToolCallCandidate(entry, linked, runSources) {
|
|
|
19857
19450
|
}
|
|
19858
19451
|
function validationToolCallSummary(toolName, args) {
|
|
19859
19452
|
const parsed = parseMaybeJson(args);
|
|
19860
|
-
const argRecord =
|
|
19453
|
+
const argRecord = isRecord15(parsed) ? parsed : null;
|
|
19861
19454
|
if (toolName === "bash") {
|
|
19862
19455
|
const command = readOptionalString(argRecord?.command);
|
|
19863
19456
|
if (command === null) return null;
|
|
@@ -19879,8 +19472,8 @@ function validationToolCallSummary(toolName, args) {
|
|
|
19879
19472
|
}
|
|
19880
19473
|
function isSuccessfulSessionToolResult(result) {
|
|
19881
19474
|
if (result.isError) return false;
|
|
19882
|
-
const obj =
|
|
19883
|
-
const details =
|
|
19475
|
+
const obj = isRecord15(result.result) ? result.result : null;
|
|
19476
|
+
const details = isRecord15(obj?.details) ? obj.details : null;
|
|
19884
19477
|
return details?.kind !== "error";
|
|
19885
19478
|
}
|
|
19886
19479
|
function finding(index, severity, tag, runId, message) {
|
|
@@ -20055,7 +19648,7 @@ function attributionWindows(ledger, runSources, sessionIds) {
|
|
|
20055
19648
|
}
|
|
20056
19649
|
const linkedSessions = new Set(sessionIds);
|
|
20057
19650
|
for (const row of ledger.rows) {
|
|
20058
|
-
if (!
|
|
19651
|
+
if (!isRecord15(row)) continue;
|
|
20059
19652
|
const id = readOptionalString(row.id);
|
|
20060
19653
|
const startedAt = readOptionalString(row.startedAt);
|
|
20061
19654
|
const sessionId = readOptionalString(row.sessionId);
|
|
@@ -20180,7 +19773,15 @@ function extractSessionToolCall(entry, linked) {
|
|
|
20180
19773
|
const id = readOptionalString(payload?.id) ?? readOptionalString(payload?.toolCallId) ?? readOptionalString(payload?.tool_call_id) ?? readOptionalString(block?.id) ?? entry.turnId;
|
|
20181
19774
|
const tool = readOptionalString(payload?.name) ?? readOptionalString(payload?.toolName) ?? readOptionalString(payload?.tool) ?? readOptionalString(fn?.name) ?? readOptionalString(block?.name) ?? "tool";
|
|
20182
19775
|
const args = payload?.arguments ?? payload?.args ?? payload?.input ?? parseMaybeJson(fn?.arguments) ?? block?.arguments ?? block?.args ?? void 0;
|
|
20183
|
-
|
|
19776
|
+
const effective = effectiveToolCall(tool, args);
|
|
19777
|
+
return {
|
|
19778
|
+
id,
|
|
19779
|
+
tool: effective.toolName,
|
|
19780
|
+
args: effective.args ?? args,
|
|
19781
|
+
timestamp: entry.timestamp,
|
|
19782
|
+
link: linked.link,
|
|
19783
|
+
sessionId: linked.sessionId
|
|
19784
|
+
};
|
|
20184
19785
|
}
|
|
20185
19786
|
function extractSessionToolResult(entry, linked) {
|
|
20186
19787
|
const payload = payloadObject(entry.payload);
|
|
@@ -20188,10 +19789,18 @@ function extractSessionToolResult(entry, linked) {
|
|
|
20188
19789
|
const id = readOptionalString(payload?.toolCallId) ?? readOptionalString(payload?.tool_call_id) ?? readOptionalString(payload?.id) ?? null;
|
|
20189
19790
|
const tool = readOptionalString(payload?.toolName) ?? readOptionalString(payload?.name) ?? readOptionalString(payload?.tool) ?? "tool";
|
|
20190
19791
|
const result = payload?.result ?? payload?.output ?? payload?.out ?? payload?.content ?? (contentText.length > 0 ? contentText : entry.payload);
|
|
19792
|
+
const effective = effectiveToolCall(tool, void 0, payloadObject(result)?.details ?? payload?.details);
|
|
19793
|
+
const resultObject = payloadObject(result);
|
|
19794
|
+
const details = payloadObject(resultObject?.details);
|
|
19795
|
+
let projectedResult = result;
|
|
19796
|
+
if (effective.viaGateway && resultObject && details) {
|
|
19797
|
+
const { capability: _capability, ...innerDetails } = details;
|
|
19798
|
+
projectedResult = { ...resultObject, details: innerDetails };
|
|
19799
|
+
}
|
|
20191
19800
|
return {
|
|
20192
19801
|
id,
|
|
20193
|
-
tool,
|
|
20194
|
-
result,
|
|
19802
|
+
tool: effective.toolName,
|
|
19803
|
+
result: projectedResult,
|
|
20195
19804
|
isError: payload?.isError === true || payload?.error === true,
|
|
20196
19805
|
timestamp: entry.timestamp,
|
|
20197
19806
|
link: linked.link,
|
|
@@ -20439,8 +20048,13 @@ function renderTranscript(overview, runSources, sessionLinks, trustStatus, findi
|
|
|
20439
20048
|
}
|
|
20440
20049
|
if (sessionLinks.entries.length > 0) {
|
|
20441
20050
|
lines.push("", "## Linked Session Transcript");
|
|
20051
|
+
const calls = /* @__PURE__ */ new Map();
|
|
20442
20052
|
for (const linked of sessionLinks.entries) {
|
|
20443
|
-
|
|
20053
|
+
if (linked.entry.kind === "message" && linked.entry.role === "tool_call") {
|
|
20054
|
+
const call = extractSessionToolCall(linked.entry, linked);
|
|
20055
|
+
calls.set(call.id, call.tool);
|
|
20056
|
+
}
|
|
20057
|
+
lines.push(...renderSessionTranscriptEntry(linked, calls));
|
|
20444
20058
|
}
|
|
20445
20059
|
}
|
|
20446
20060
|
lines.push("");
|
|
@@ -20460,7 +20074,7 @@ function transcriptRunLink(link) {
|
|
|
20460
20074
|
}
|
|
20461
20075
|
return "";
|
|
20462
20076
|
}
|
|
20463
|
-
function renderSessionTranscriptEntry(linked) {
|
|
20077
|
+
function renderSessionTranscriptEntry(linked, calls) {
|
|
20464
20078
|
const entry = linked.entry;
|
|
20465
20079
|
const prefix = `- ${entry.timestamp} session=${linked.sessionId}${transcriptRunLink(linked.link)}`;
|
|
20466
20080
|
if (entry.kind === "message") {
|
|
@@ -20472,7 +20086,8 @@ function renderSessionTranscriptEntry(linked) {
|
|
|
20472
20086
|
const result = extractSessionToolResult(entry, linked);
|
|
20473
20087
|
const id = result.id === null ? "" : ` id=${result.id}`;
|
|
20474
20088
|
const error = result.isError ? " error=true" : "";
|
|
20475
|
-
|
|
20089
|
+
const tool = result.id === null ? result.tool : calls.get(result.id) ?? result.tool;
|
|
20090
|
+
return [`${prefix} tool_result ${tool}${id}${error}: ${previewUnknown(result.result)}`];
|
|
20476
20091
|
}
|
|
20477
20092
|
const text = collapseWhitespace(extractTextFromPayload(entry.payload));
|
|
20478
20093
|
const rendered = text.length > 0 ? truncateText(text, TRANSCRIPT_TEXT_MAX_CHARS) : previewUnknown(entry.payload);
|
|
@@ -20623,7 +20238,7 @@ async function readRunLedger(stateDir) {
|
|
|
20623
20238
|
}
|
|
20624
20239
|
function selectRunEnvelopes(ledger, source) {
|
|
20625
20240
|
return ledger.rows.flatMap((entry, index) => {
|
|
20626
|
-
if (!
|
|
20241
|
+
if (!isRecord15(entry)) return [];
|
|
20627
20242
|
const selected = source.kind === "run" ? entry.id === source.runId : entry.sessionId === source.sessionId;
|
|
20628
20243
|
return selected ? [parseRunEnvelope(entry, `${ledger.path}[${index}]`)] : [];
|
|
20629
20244
|
});
|
|
@@ -20664,7 +20279,7 @@ function readExecutionRole(value, source) {
|
|
|
20664
20279
|
return role;
|
|
20665
20280
|
}
|
|
20666
20281
|
function parseRunEnvelope(value, source) {
|
|
20667
|
-
if (!
|
|
20282
|
+
if (!isRecord15(value)) throw new Error(`${source}: expected object`);
|
|
20668
20283
|
const reasoningTokenCount = readOptionalNumber2(value, source, "reasoningTokenCount");
|
|
20669
20284
|
return {
|
|
20670
20285
|
...value,
|
|
@@ -20692,9 +20307,9 @@ function parseRunEnvelope(value, source) {
|
|
|
20692
20307
|
};
|
|
20693
20308
|
}
|
|
20694
20309
|
function parseRunReceipt(value, source) {
|
|
20695
|
-
if (!
|
|
20310
|
+
if (!isRecord15(value)) throw new Error(`${source}: expected object`);
|
|
20696
20311
|
const integrity = value.integrity;
|
|
20697
|
-
if (!
|
|
20312
|
+
if (!isRecord15(integrity)) throw new Error(`${source}.integrity: expected object`);
|
|
20698
20313
|
const reasoningTokenCount = readOptionalNumber2(value, source, "reasoningTokenCount");
|
|
20699
20314
|
const failureMessage = readOptionalString(value.failureMessage);
|
|
20700
20315
|
return {
|
|
@@ -20738,7 +20353,7 @@ function readToolStats(record, source, field) {
|
|
|
20738
20353
|
if (!Array.isArray(value)) throw new Error(`${source}.${field}: expected array`);
|
|
20739
20354
|
return value.map((entry, index) => {
|
|
20740
20355
|
const itemSource = `${source}.${field}[${index}]`;
|
|
20741
|
-
if (!
|
|
20356
|
+
if (!isRecord15(entry)) throw new Error(`${itemSource}: expected object`);
|
|
20742
20357
|
return {
|
|
20743
20358
|
tool: readString3(entry, itemSource, "tool"),
|
|
20744
20359
|
count: readNumber3(entry, itemSource, "count"),
|
|
@@ -20803,11 +20418,11 @@ function parseJson3(raw, source) {
|
|
|
20803
20418
|
throw new Error(`${source}: invalid JSON: ${message}`);
|
|
20804
20419
|
}
|
|
20805
20420
|
}
|
|
20806
|
-
function
|
|
20421
|
+
function isRecord15(value) {
|
|
20807
20422
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20808
20423
|
}
|
|
20809
20424
|
function payloadObject(payload) {
|
|
20810
|
-
return
|
|
20425
|
+
return isRecord15(payload) ? payload : null;
|
|
20811
20426
|
}
|
|
20812
20427
|
function parseMaybeJson(value) {
|
|
20813
20428
|
if (typeof value !== "string") return value;
|
|
@@ -20824,7 +20439,7 @@ function firstContentBlock(payload, type) {
|
|
|
20824
20439
|
const content = obj?.content;
|
|
20825
20440
|
if (!Array.isArray(content)) return null;
|
|
20826
20441
|
for (const block of content) {
|
|
20827
|
-
if (!
|
|
20442
|
+
if (!isRecord15(block)) continue;
|
|
20828
20443
|
if (block.type === type) return block;
|
|
20829
20444
|
}
|
|
20830
20445
|
return null;
|
|
@@ -20837,7 +20452,7 @@ function extractTextFromPayload(payload) {
|
|
|
20837
20452
|
if (Array.isArray(obj.content)) {
|
|
20838
20453
|
const parts = [];
|
|
20839
20454
|
for (const block of obj.content) {
|
|
20840
|
-
if (!
|
|
20455
|
+
if (!isRecord15(block)) continue;
|
|
20841
20456
|
if (block.type === "text" && typeof block.text === "string") parts.push(block.text);
|
|
20842
20457
|
}
|
|
20843
20458
|
return parts.join("\n");
|
|
@@ -21324,7 +20939,7 @@ async function readRunLedger2(stateDir) {
|
|
|
21324
20939
|
try {
|
|
21325
20940
|
const raw = await readFile4(join27(stateDir, "runs.json"), "utf8");
|
|
21326
20941
|
const parsed = JSON.parse(raw);
|
|
21327
|
-
return Array.isArray(parsed) ? parsed.filter(
|
|
20942
|
+
return Array.isArray(parsed) ? parsed.filter(isRecord16) : [];
|
|
21328
20943
|
} catch {
|
|
21329
20944
|
return [];
|
|
21330
20945
|
}
|
|
@@ -21336,7 +20951,7 @@ async function readReceiptForRun(stateDir, envelope) {
|
|
|
21336
20951
|
const path2 = envelope.receiptPath ?? join27(stateDir, "receipts", `${envelope.id}.json`);
|
|
21337
20952
|
try {
|
|
21338
20953
|
const parsed = JSON.parse(await readFile4(path2, "utf8"));
|
|
21339
|
-
return
|
|
20954
|
+
return isRecord16(parsed) ? parsed : null;
|
|
21340
20955
|
} catch {
|
|
21341
20956
|
return null;
|
|
21342
20957
|
}
|
|
@@ -21351,7 +20966,7 @@ async function countSessionEntries(stateDir, sessionIds) {
|
|
|
21351
20966
|
count += raw.split("\n").filter((line) => line.trim().length > 0).filter((line) => {
|
|
21352
20967
|
try {
|
|
21353
20968
|
const parsed = JSON.parse(line);
|
|
21354
|
-
return
|
|
20969
|
+
return isRecord16(parsed) && parsed.type !== "session";
|
|
21355
20970
|
} catch {
|
|
21356
20971
|
return false;
|
|
21357
20972
|
}
|
|
@@ -21400,7 +21015,7 @@ async function linkedEvalAuditRows(stateDir, runIds, artifact) {
|
|
|
21400
21015
|
} catch {
|
|
21401
21016
|
continue;
|
|
21402
21017
|
}
|
|
21403
|
-
if (!
|
|
21018
|
+
if (!isRecord16(parsed)) continue;
|
|
21404
21019
|
const directRunId = typeof parsed.runId === "string" ? parsed.runId : null;
|
|
21405
21020
|
if (directRunId !== null && runIds.has(directRunId)) {
|
|
21406
21021
|
rows.push(evalAuditRow(parsed, directRunId, "run-id", "exact", ["audit runId matched nested eval run"]));
|
|
@@ -21471,7 +21086,7 @@ function sanitizeEvidenceId2(value) {
|
|
|
21471
21086
|
const sanitized = value.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
21472
21087
|
return sanitized.length === 0 ? "unknown" : sanitized;
|
|
21473
21088
|
}
|
|
21474
|
-
function
|
|
21089
|
+
function isRecord16(value) {
|
|
21475
21090
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21476
21091
|
}
|
|
21477
21092
|
|
|
@@ -21753,7 +21368,7 @@ function parseTaskMemoryHandoffSnapshot(text) {
|
|
|
21753
21368
|
} catch {
|
|
21754
21369
|
return null;
|
|
21755
21370
|
}
|
|
21756
|
-
if (!
|
|
21371
|
+
if (!isRecord17(raw) || raw.version !== 1 && raw.version !== TASK_MEMORY_HANDOFF_VERSION) return null;
|
|
21757
21372
|
if (raw.version === 1 && !hasExactKeys(raw, ["version", "knowledge", "procedural"])) return null;
|
|
21758
21373
|
if (raw.version === TASK_MEMORY_HANDOFF_VERSION && !hasExactKeys(raw, ["version", "source", "redaction", "knowledge", "procedural"])) {
|
|
21759
21374
|
return null;
|
|
@@ -21840,7 +21455,7 @@ function parseEntries(value, maxEntries, version) {
|
|
|
21840
21455
|
const entries = [];
|
|
21841
21456
|
for (const raw of value) {
|
|
21842
21457
|
const expectedKeys = version === 1 ? ["id", "content", "injectionCount"] : ["id", "content", "injectionCount", "createdAt", "lastTouchedAt"];
|
|
21843
|
-
if (!
|
|
21458
|
+
if (!isRecord17(raw) || !hasExactKeys(raw, expectedKeys)) return null;
|
|
21844
21459
|
if (!nonEmptyString(raw.id) || !nonEmptyString(raw.content) || raw.content.length > TASK_MEMORY_CONTENT_MAX_CHARS)
|
|
21845
21460
|
return null;
|
|
21846
21461
|
if (!Number.isInteger(raw.injectionCount) || raw.injectionCount < 0) return null;
|
|
@@ -21857,7 +21472,7 @@ function parseEntries(value, maxEntries, version) {
|
|
|
21857
21472
|
return entries;
|
|
21858
21473
|
}
|
|
21859
21474
|
function parseSource(value) {
|
|
21860
|
-
if (!
|
|
21475
|
+
if (!isRecord17(value) || !hasExactKeys(value, ["sessionId", "evidenceRefs", "runtimeIds", "agentIds"])) return null;
|
|
21861
21476
|
if (!validSourceValue2(value.sessionId)) return null;
|
|
21862
21477
|
const evidenceRefs = parseSourceValues(value.evidenceRefs, false);
|
|
21863
21478
|
const runtimeIds = parseNamedIdentities(value.runtimeIds);
|
|
@@ -21866,7 +21481,7 @@ function parseSource(value) {
|
|
|
21866
21481
|
return { sessionId: value.sessionId, evidenceRefs, runtimeIds, agentIds };
|
|
21867
21482
|
}
|
|
21868
21483
|
function parseRedaction(value) {
|
|
21869
|
-
if (!
|
|
21484
|
+
if (!isRecord17(value) || !hasExactKeys(value, ["replacementCount", "sourceFields"])) return null;
|
|
21870
21485
|
if (!Number.isInteger(value.replacementCount) || value.replacementCount < 0) return null;
|
|
21871
21486
|
const sourceFields = parseSourceValues(value.sourceFields, true);
|
|
21872
21487
|
if (sourceFields === null) return null;
|
|
@@ -21913,7 +21528,7 @@ function cloneSource(source) {
|
|
|
21913
21528
|
agentIds: [...source.agentIds]
|
|
21914
21529
|
};
|
|
21915
21530
|
}
|
|
21916
|
-
function
|
|
21531
|
+
function isRecord17(value) {
|
|
21917
21532
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21918
21533
|
}
|
|
21919
21534
|
function hasExactKeys(value, keys) {
|
|
@@ -22815,11 +22430,6 @@ export {
|
|
|
22815
22430
|
buildMemoryPromptSection,
|
|
22816
22431
|
selectWorkerContext,
|
|
22817
22432
|
protectedResidencyModels,
|
|
22818
|
-
AcpTimeoutError,
|
|
22819
|
-
ACP_TURN_FAILED_MESSAGE,
|
|
22820
|
-
AcpRequestError,
|
|
22821
|
-
acpErrorMessage,
|
|
22822
|
-
createStdioServerTransport,
|
|
22823
22433
|
ACP_USAGE_META_KEY,
|
|
22824
22434
|
ACP_SESSION_META_KEY,
|
|
22825
22435
|
ACP_AGENT_META_KEY,
|
|
@@ -22900,4 +22510,4 @@ export {
|
|
|
22900
22510
|
buildWikiPlanPrompt,
|
|
22901
22511
|
buildWikiPagePrompt
|
|
22902
22512
|
};
|
|
22903
|
-
//# sourceMappingURL=chunk-
|
|
22513
|
+
//# sourceMappingURL=chunk-F2YM3JY4.js.map
|