@ensocode/server 0.3.11 → 0.3.13
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/LICENSE +679 -19
- package/out/phone/assets/EditDiff-B3HxLrbF.js +28 -0
- package/out/phone/assets/ReadFileView-BFpGH-kK.js +7 -0
- package/out/phone/assets/{abnfDiagram-VCTEODGH-DeKO4j9Y.js → abnfDiagram-VCTEODGH-BNvyPGoF.js} +1 -1
- package/out/phone/assets/architecture-7GRP2DOG-Duql1LsL.js +1 -0
- package/out/phone/assets/{architectureDiagram-5GKGNRK7-DhPgDhMQ.js → architectureDiagram-5GKGNRK7-1bhpTEFA.js} +1 -1
- package/out/phone/assets/{blockDiagram-I7D4REHJ-CHjEV4S2.js → blockDiagram-I7D4REHJ-Bo9UMudu.js} +1 -1
- package/out/phone/assets/{c4Diagram-7LVT6UL2-C_w2ZiGg.js → c4Diagram-7LVT6UL2-YS11cig2.js} +1 -1
- package/out/phone/assets/channel-BPoIHov1.js +1 -0
- package/out/phone/assets/{chunk-4HAMMTFA-DsFB5306.js → chunk-4HAMMTFA-gA-CzNGD.js} +1 -1
- package/out/phone/assets/{chunk-75Z2AOVW-D-GYq_Mf.js → chunk-75Z2AOVW-BL_5b1Dw.js} +1 -1
- package/out/phone/assets/{chunk-DU6HZSFF-CfnOn1uu.js → chunk-DU6HZSFF-BpNlAs9R.js} +1 -1
- package/out/phone/assets/{chunk-F27PBJKO-DFQr9a2N.js → chunk-F27PBJKO-lsKx96Nt.js} +1 -1
- package/out/phone/assets/{chunk-GMAD6QVW--AoHkXxN.js → chunk-GMAD6QVW-CxbljbtE.js} +1 -1
- package/out/phone/assets/{chunk-GVQU2GXP-CzbFqhoi.js → chunk-GVQU2GXP-CTO3kTOF.js} +1 -1
- package/out/phone/assets/{chunk-IMKFNOWR-DT26rqUA.js → chunk-IMKFNOWR-Cq8XlkcB.js} +1 -1
- package/out/phone/assets/{chunk-L3NEJ4N5-CvadXD9U.js → chunk-L3NEJ4N5-CvIm0JX7.js} +1 -1
- package/out/phone/assets/{chunk-OSK3NFVY-DROHZT6z.js → chunk-OSK3NFVY-Cj3ilTL-.js} +1 -1
- package/out/phone/assets/{chunk-P2QGCYS3-BcsvTFQT.js → chunk-P2QGCYS3-B-twI_Fz.js} +1 -1
- package/out/phone/assets/{chunk-POPQ4Y6H-Bib7YUpn.js → chunk-POPQ4Y6H-lPQttJ5s.js} +1 -1
- package/out/phone/assets/{chunk-PWAF6VOD-CrsdfQvi.js → chunk-PWAF6VOD-DjwqZuIR.js} +1 -1
- package/out/phone/assets/{chunk-SHT3W25Y-BSSsjkbn.js → chunk-SHT3W25Y-BWRVin1H.js} +1 -1
- package/out/phone/assets/{chunk-SVP7TREG-BorYBfcS.js → chunk-SVP7TREG-CGLhvnsS.js} +1 -1
- package/out/phone/assets/{chunk-TICWLB2K-DwWprz_z.js → chunk-TICWLB2K-DkFUa03q.js} +1 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-CIR76lHP.js +1 -0
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-CIR76lHP.js +1 -0
- package/out/phone/assets/codeHighlighter-jQti-W31.js +1346 -0
- package/out/phone/assets/{cynefin-OW5HDTMX-UxW1ctBn.js → cynefin-OW5HDTMX-L8oWVu5S.js} +1 -1
- package/out/phone/assets/{cynefinDiagram-5FMLGOSQ-3xyjt_Zk.js → cynefinDiagram-5FMLGOSQ-DH8-4p4N.js} +1 -1
- package/out/phone/assets/{dagre-GXQ25YYZ-BA8g5sNo.js → dagre-GXQ25YYZ-HhLDmcu9.js} +1 -1
- package/out/phone/assets/desk-CixRGdTk.js +52 -0
- package/out/phone/assets/{diagram-S7CK7UJ4-CqaAk0xY.js → diagram-S7CK7UJ4-CeIbR3Ir.js} +1 -1
- package/out/phone/assets/{diagram-UQ7AKVKN-BJs2alr_.js → diagram-UQ7AKVKN-BQ84Qnq6.js} +1 -1
- package/out/phone/assets/{diagram-VSXAHHWV-goFBlClH.js → diagram-VSXAHHWV-aF_J57fD.js} +1 -1
- package/out/phone/assets/{diagram-VX7I27RA-NC_soOMz.js → diagram-VX7I27RA-Bg1ZqM4Y.js} +1 -1
- package/out/phone/assets/{diagram-Z3DM3KII-CPBmdhd-.js → diagram-Z3DM3KII-DjTkPAqa.js} +1 -1
- package/out/phone/assets/{ebnfDiagram-PWID7BFC-e_KXtWp1.js → ebnfDiagram-PWID7BFC-DPsH5Eky.js} +1 -1
- package/out/phone/assets/{erDiagram-RLTQ6QDP-BV3oU6Yk.js → erDiagram-RLTQ6QDP-ExvY7e6T.js} +1 -1
- package/out/phone/assets/eventmodeling-NTZA5JFV-DYp-zWcL.js +1 -0
- package/out/phone/assets/flowDiagram-HODETNUW-CIU32By5.js +1 -0
- package/out/phone/assets/{ganttDiagram-EL5Y4UJY-DOtr1Ilh.js → ganttDiagram-EL5Y4UJY-hCe06ucl.js} +1 -1
- package/out/phone/assets/{gitGraph-4MIJSDKK-D0CbVtzh.js → gitGraph-4MIJSDKK-BuZ6lDat.js} +1 -1
- package/out/phone/assets/{gitGraphDiagram-WWUBYQGX-C6wXAX8a.js → gitGraphDiagram-WWUBYQGX-D-8aVxvj.js} +1 -1
- package/out/phone/assets/{info-A6RAGUB7-BLbppMXJ.js → info-A6RAGUB7-CrZtdoYs.js} +1 -1
- package/out/phone/assets/{infoDiagram-27XIBGKW-DOlhaNYG.js → infoDiagram-27XIBGKW-BLRFHxtO.js} +1 -1
- package/out/phone/assets/{ishikawaDiagram-5VMMS53U-BtaSUSnr.js → ishikawaDiagram-5VMMS53U-D7SYWKoj.js} +1 -1
- package/out/phone/assets/{journeyDiagram-3NMN7TZE-C6DElK_Y.js → journeyDiagram-3NMN7TZE-BPsg7CQD.js} +1 -1
- package/out/phone/assets/{kanban-definition-UXKFOSKX-WqCAwlkm.js → kanban-definition-UXKFOSKX-CbPuNr-E.js} +1 -1
- package/out/phone/assets/{line-CvY1fizC.js → line-CkpKMiqK.js} +1 -1
- package/out/phone/assets/main-BCnf7dVM.js +264 -0
- package/out/phone/assets/main-nqB-uD3v.css +2 -0
- package/out/phone/assets/{mermaid-parser.core-BNyl33x8.js → mermaid-parser.core-RTq_mEm1.js} +3 -3
- package/out/phone/assets/{mermaid.core-BnUF0ZCX.js → mermaid.core-D9LtIKua.js} +4 -4
- package/out/phone/assets/{mindmap-definition-YA3MSWOX-CsORTLIm.js → mindmap-definition-YA3MSWOX-8cGgRiRD.js} +1 -1
- package/out/phone/assets/{packet-AYTQ26CC-CoxwVVdp.js → packet-AYTQ26CC-D9-eSn0v.js} +1 -1
- package/out/phone/assets/{pegDiagram-XKGWAZYB-BI2W6aLH.js → pegDiagram-XKGWAZYB-DztU_rIE.js} +1 -1
- package/out/phone/assets/{pie-WAS4IAKB-CQD3JNcj.js → pie-WAS4IAKB-Bk2Tqaq_.js} +1 -1
- package/out/phone/assets/{pieDiagram-E7YTZNPT-aLnzVgco.js → pieDiagram-E7YTZNPT-Dm_3mJ9_.js} +1 -1
- package/out/phone/assets/{quadrantDiagram-AXDQQJYC-Cbl0x-Id.js → quadrantDiagram-AXDQQJYC-lKskzjzu.js} +1 -1
- package/out/phone/assets/{radar-RG4KPBEZ-Bu2EN1RM.js → radar-RG4KPBEZ-B2z8Txd8.js} +1 -1
- package/out/phone/assets/{railroad-74A4TZTK-DiiOMWSM.js → railroad-74A4TZTK-11VmdALq.js} +1 -1
- package/out/phone/assets/railroad-abnf-HS5TGJTU-BkSycwye.js +1 -0
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-BsPIU3iV.js +1 -0
- package/out/phone/assets/railroad-peg-WCYAUIDC-Cy8G7u5C.js +1 -0
- package/out/phone/assets/{railroadDiagram-O6MQD6OU-r5JJp9nP.js → railroadDiagram-O6MQD6OU-Dr0NTIA6.js} +1 -1
- package/out/phone/assets/{requirementDiagram-BXWQKSXE-Bh86zb_w.js → requirementDiagram-BXWQKSXE-C0W6h_5I.js} +1 -1
- package/out/phone/assets/{sankeyDiagram-P5KCCOFB-CykRlthT.js → sankeyDiagram-P5KCCOFB-CVJDathY.js} +1 -1
- package/out/phone/assets/{sequenceDiagram-WJ2MYXX4-BPLcD6MF.js → sequenceDiagram-WJ2MYXX4-BxHQTG6x.js} +1 -1
- package/out/phone/assets/shellUpdate-DPSfgHG3.js +36 -0
- package/out/phone/assets/{stateDiagram-D77RDMKH-DWXApcUM.js → stateDiagram-D77RDMKH-BO5MAjhs.js} +1 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-B8IHc2bm.js +1 -0
- package/out/phone/assets/{swimlanes-42K2YHIH-BVi6IPTq.js → swimlanes-42K2YHIH-DnhDPyy6.js} +1 -1
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-dmSDAN2F.js +8 -0
- package/out/phone/assets/{timeline-definition-24CTP7MA-xf--BXjO.js → timeline-definition-24CTP7MA-bLEjS7re.js} +1 -1
- package/out/phone/assets/{treeView-Q6P3EWNA-DzJs7PRI.js → treeView-Q6P3EWNA-Ci-sA9wK.js} +1 -1
- package/out/phone/assets/{treemap-WGGIJYW6-AXb7EeRP.js → treemap-WGGIJYW6-BXCjzK65.js} +1 -1
- package/out/phone/assets/{vennDiagram-4TSXK5OY-CXDX5KG5.js → vennDiagram-4TSXK5OY-DHsj5dRx.js} +1 -1
- package/out/phone/assets/{wardley-WFR3VGLG-DrSIz3RL.js → wardley-WFR3VGLG-d8TdCu-H.js} +1 -1
- package/out/phone/assets/{wardleyDiagram-VM6X3IG4-DFL8ndUf.js → wardleyDiagram-VM6X3IG4-DQFVP9qu.js} +1 -1
- package/out/phone/assets/{xychartDiagram-S5SC5T6Z-CZZX0maW.js → xychartDiagram-S5SC5T6Z-Dni2Y0ov.js} +1 -1
- package/out/phone/desk.html +81 -2
- package/out/phone/index.html +51 -3
- package/out/phone/manifest.webmanifest +1 -0
- package/out/phone/splash/1125x2436-dark.png +0 -0
- package/out/phone/splash/1125x2436-light.png +0 -0
- package/out/phone/splash/1170x2532-dark.png +0 -0
- package/out/phone/splash/1170x2532-light.png +0 -0
- package/out/phone/splash/1179x2556-dark.png +0 -0
- package/out/phone/splash/1179x2556-light.png +0 -0
- package/out/phone/splash/1206x2622-dark.png +0 -0
- package/out/phone/splash/1206x2622-light.png +0 -0
- package/out/phone/splash/1242x2208-dark.png +0 -0
- package/out/phone/splash/1242x2208-light.png +0 -0
- package/out/phone/splash/1242x2688-dark.png +0 -0
- package/out/phone/splash/1242x2688-light.png +0 -0
- package/out/phone/splash/1260x2736-dark.png +0 -0
- package/out/phone/splash/1260x2736-light.png +0 -0
- package/out/phone/splash/1284x2778-dark.png +0 -0
- package/out/phone/splash/1284x2778-light.png +0 -0
- package/out/phone/splash/1290x2796-dark.png +0 -0
- package/out/phone/splash/1290x2796-light.png +0 -0
- package/out/phone/splash/1320x2868-dark.png +0 -0
- package/out/phone/splash/1320x2868-light.png +0 -0
- package/out/phone/splash/750x1334-dark.png +0 -0
- package/out/phone/splash/750x1334-light.png +0 -0
- package/out/phone/splash/828x1792-dark.png +0 -0
- package/out/phone/splash/828x1792-light.png +0 -0
- package/out/phone/sw.js +219 -6
- package/out/renderer/assets/EditDiff-DxxLuCEI.js +1 -0
- package/out/renderer/assets/File-Tz3MUtN6.js +1 -0
- package/out/renderer/assets/ReadFileView-DFoLPU04.js +4 -0
- package/out/renderer/assets/SidePanel-CL40W2RY.js +47 -0
- package/out/renderer/assets/SidePanel-D0m4IYxS.css +1 -0
- package/out/renderer/assets/Virtualizer-B0uwx_XV.js +1345 -0
- package/out/renderer/assets/{abnfDiagram-VCTEODGH-C03tURh9.js → abnfDiagram-VCTEODGH-CJ9nn9eH.js} +1 -1
- package/out/renderer/assets/{arc-B9ePZBoh.js → arc-B8im8n0O.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-5GKGNRK7-xqG-LPqx.js → architectureDiagram-5GKGNRK7-BRSi5FBk.js} +1 -1
- package/out/renderer/assets/{blockDiagram-I7D4REHJ-BJCB1uWW.js → blockDiagram-I7D4REHJ-CQ1wirIl.js} +1 -1
- package/out/renderer/assets/{c4Diagram-7LVT6UL2-B8YiLE3O.js → c4Diagram-7LVT6UL2-9HyLIioe.js} +1 -1
- package/out/renderer/assets/channel-DjB0ww6b.js +1 -0
- package/out/renderer/assets/{chunk-2Q5K7J3B-BfCgzuF1.js → chunk-2Q5K7J3B-BwC9g3bx.js} +1 -1
- package/out/renderer/assets/{chunk-5VM5RSS4-j2RDggaS.js → chunk-5VM5RSS4-DMtgxPBL.js} +1 -1
- package/out/renderer/assets/{chunk-F27PBJKO-D1w1G98C.js → chunk-F27PBJKO-DSi_XV5v.js} +1 -1
- package/out/renderer/assets/{chunk-IMKFNOWR-HX7TqjEn.js → chunk-IMKFNOWR-Dctc6Apj.js} +1 -1
- package/out/renderer/assets/{chunk-JWPE2WC7-Ee_2ucfe.js → chunk-JWPE2WC7-I2BD5qM7.js} +1 -1
- package/out/renderer/assets/{chunk-POPQ4Y6H-DuxBT9GV.js → chunk-POPQ4Y6H-k60pc4eT.js} +1 -1
- package/out/renderer/assets/{chunk-SVP7TREG-DFjkSsO8.js → chunk-SVP7TREG-zCGemfqm.js} +1 -1
- package/out/renderer/assets/{chunk-TICWLB2K-1B31w-4D.js → chunk-TICWLB2K-CdDiHIq-.js} +1 -1
- package/out/renderer/assets/{chunk-XXDRQBXY-DZ7nGbEc.js → chunk-XXDRQBXY-GYVDxVfN.js} +1 -1
- package/out/renderer/assets/classDiagram-ZZMXUADV-6SiAw1np.js +1 -0
- package/out/renderer/assets/classDiagram-v2-VYDZK3BY-6SiAw1np.js +1 -0
- package/out/renderer/assets/{cose-bilkent-JH36ORCC-k2aKhVw_.js → cose-bilkent-JH36ORCC-BnSAtUh-.js} +1 -1
- package/out/renderer/assets/{cynefin-OW5HDTMX-xPUo1qjT.js → cynefin-OW5HDTMX-DnQaS9VN.js} +1 -1
- package/out/renderer/assets/{cynefinDiagram-5FMLGOSQ-KbWg9eRv.js → cynefinDiagram-5FMLGOSQ-BNQdw0PV.js} +1 -1
- package/out/renderer/assets/{cytoscape-fcose-CLBXU3_O.js → cytoscape-fcose-CzkrRInm.js} +1 -1
- package/out/renderer/assets/{dagre-GXQ25YYZ-ilq61to2.js → dagre-GXQ25YYZ-fG1vMsyn.js} +1 -1
- package/out/renderer/assets/{diagram-S7CK7UJ4-DsRzYvTT.js → diagram-S7CK7UJ4-BcfAFVc2.js} +1 -1
- package/out/renderer/assets/{diagram-UQ7AKVKN-nE6Ly2i6.js → diagram-UQ7AKVKN-D8f3Tsx9.js} +1 -1
- package/out/renderer/assets/{diagram-VSXAHHWV-B9Crbma_.js → diagram-VSXAHHWV-B-U9CIWt.js} +1 -1
- package/out/renderer/assets/{diagram-VX7I27RA-Bm5JhnFh.js → diagram-VX7I27RA-CX6ifTkJ.js} +1 -1
- package/out/renderer/assets/{diagram-Z3DM3KII-ZD7ANoYg.js → diagram-Z3DM3KII-49dS9s3L.js} +1 -1
- package/out/renderer/assets/{ebnfDiagram-PWID7BFC-CT3pW9tk.js → ebnfDiagram-PWID7BFC-CraGJRI7.js} +1 -1
- package/out/renderer/assets/{erDiagram-RLTQ6QDP-D0ikskdu.js → erDiagram-RLTQ6QDP-CfMNvEoW.js} +1 -1
- package/out/renderer/assets/{flowDiagram-HODETNUW-BOF_JMXY.js → flowDiagram-HODETNUW-C8XM3p4T.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-EL5Y4UJY-BCEnP39-.js → ganttDiagram-EL5Y4UJY-DlJBMKFX.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-WWUBYQGX-WpPHHkc3.js → gitGraphDiagram-WWUBYQGX-DvEzDsKF.js} +1 -1
- package/out/renderer/assets/globals-BFf1P-Y5.js +715 -0
- package/out/renderer/assets/globals-DUBhAVpU.css +1 -0
- package/out/renderer/assets/index-L4TTIP10.js +89 -0
- package/out/renderer/assets/{infoDiagram-27XIBGKW-nRW-sje9.js → infoDiagram-27XIBGKW-CckfBO-R.js} +1 -1
- package/out/renderer/assets/{ishikawaDiagram-5VMMS53U-CEfZo_k8.js → ishikawaDiagram-5VMMS53U-mUoXchkB.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-3NMN7TZE-C5hopb9Y.js → journeyDiagram-3NMN7TZE-zzLL0HFW.js} +1 -1
- package/out/renderer/assets/{kanban-definition-UXKFOSKX-D9XV2n-x.js → kanban-definition-UXKFOSKX-BJ_9aIhB.js} +1 -1
- package/out/renderer/assets/{layout-t2tiRL7x.js → layout-3SRMHY7n.js} +1 -1
- package/out/renderer/assets/{linear-DJLwPmUz.js → linear-CWpclK_R.js} +1 -1
- package/out/renderer/assets/manifest-DOzTaB8J.js +525 -0
- package/out/renderer/assets/{mermaid.core-C0XHWibr.js → mermaid.core-DORpmVi3.js} +5 -5
- package/out/renderer/assets/{mindmap-definition-YA3MSWOX-DD-erShR.js → mindmap-definition-YA3MSWOX-CYBlCqIB.js} +1 -1
- package/out/renderer/assets/{pegDiagram-XKGWAZYB-DZ0Jk0gq.js → pegDiagram-XKGWAZYB-DhWwLs4v.js} +1 -1
- package/out/renderer/assets/{pieDiagram-E7YTZNPT-E7wG7xIV.js → pieDiagram-E7YTZNPT-Bzpc57-A.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-AXDQQJYC-iyjmw417.js → quadrantDiagram-AXDQQJYC-spKXEbds.js} +1 -1
- package/out/renderer/assets/{railroadDiagram-O6MQD6OU-vCkzrMpv.js → railroadDiagram-O6MQD6OU-Br553px3.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-BXWQKSXE-DJ7nU4ps.js → requirementDiagram-BXWQKSXE-CX-Dqij_.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-P5KCCOFB-1TKFsYjQ.js → sankeyDiagram-P5KCCOFB-Bgx1W6B9.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-WJ2MYXX4-C3ajyWo7.js → sequenceDiagram-WJ2MYXX4-CKQv6pcU.js} +1 -1
- package/out/renderer/assets/sessionChanges-BLzNhRuv.js +31 -0
- package/out/renderer/assets/settings-Bsrw4ERp.js +25 -0
- package/out/renderer/assets/{sizeCapture-INFHLROL-BKripAfM.js → sizeCapture-INFHLROL-DtRedfRe.js} +1 -1
- package/out/renderer/assets/{stateDiagram-D77RDMKH-DSqc4avN.js → stateDiagram-D77RDMKH-CMP5owem.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-6-731AqJ.js +1 -0
- package/out/renderer/assets/{swimlanes-42K2YHIH-C2Jeg683.js → swimlanes-42K2YHIH-D30AvvmW.js} +1 -1
- package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-B8KijqIT.js +8 -0
- package/out/renderer/assets/{timeline-definition-24CTP7MA-rvOKRLqz.js → timeline-definition-24CTP7MA-CsZAMmMZ.js} +1 -1
- package/out/renderer/assets/{vennDiagram-4TSXK5OY-Cig1eOav.js → vennDiagram-4TSXK5OY-COQ7L1f7.js} +1 -1
- package/out/renderer/assets/{wardleyDiagram-VM6X3IG4-C8spX5XL.js → wardleyDiagram-VM6X3IG4-dqMWLTCs.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-S5SC5T6Z-DHQsGiFY.js → xychartDiagram-S5SC5T6Z-DX4clIYP.js} +1 -1
- package/out/renderer/index.html +3 -4
- package/out/renderer/plugin-view.html +37 -0
- package/out/renderer/settings.html +7 -4
- package/out/renderer/web-preload.js +40 -40
- package/out/server/agent.js +915 -606
- package/out/server/chunks/{agent-BbLTL3oo.js → agent-BbNq8i9j.js} +987 -689
- package/out/server/chunks/conversationsMove-CvFPFHaa.js +587 -0
- package/out/server/chunks/dispatchModel-CsfmL396.js +20 -0
- package/out/server/chunks/gpuBackendInstall-jAzoFq7U.js +237 -0
- package/out/server/chunks/{loadProvider-ff0h4G9y.js → loadProvider-NdOVbsHi.js} +2 -2
- package/out/server/chunks/{manifest-DjsZzZuh.js → manifest-BPXFscqI.js} +9 -3
- package/out/server/chunks/registry-BhoHPSKn.js +3353 -0
- package/out/server/chunks/{resources-DmaKIeBc.js → resources-BfbTkFP0.js} +23 -12
- package/out/server/chunks/sendImage-BCNW9JRV.js +418 -0
- package/out/server/chunks/{storageScanWorker-Bebego8l.js → storageScanWorker-CR7HbOWG.js} +2 -2
- package/out/server/chunks/{storageScanWorker-BQ1LXUu7.js → storageScanWorker-DjFyHTye.js} +2 -2
- package/out/server/chunks/{workflowPresets-XbQNDJh1.js → workflowPresets-C2T1BzA2.js} +1725 -720
- package/out/server/index.js +14387 -16832
- package/out/server/memory-service.js +5008 -0
- package/out/server/plugin-host.js +2 -2
- package/package.json +2 -3
- package/out/phone/assets/EnsoNerdSymbolsMono-Regular-TdeMQojc.ttf +0 -0
- package/out/phone/assets/architecture-7GRP2DOG-C-qor9pl.js +0 -1
- package/out/phone/assets/channel-X_IbcoWa.js +0 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-BM8gYXGQ.js +0 -1
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-BM8gYXGQ.js +0 -1
- package/out/phone/assets/desk-BNoyCelL.js +0 -2
- package/out/phone/assets/eventmodeling-NTZA5JFV-BdEBApKV.js +0 -1
- package/out/phone/assets/flowDiagram-HODETNUW-OPg41_ia.js +0 -1
- package/out/phone/assets/main-BU1pbfVw.css +0 -1
- package/out/phone/assets/main-ZLMPRLjZ.js +0 -1658
- package/out/phone/assets/railroad-abnf-HS5TGJTU-BoQXwOPL.js +0 -1
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-1G126duh.js +0 -1
- package/out/phone/assets/railroad-peg-WCYAUIDC-C7pIuHge.js +0 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-BMZswIYt.js +0 -1
- package/out/phone/assets/storage-dUWOZ2xo.js +0 -36
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-RYt3eASc.js +0 -8
- package/out/renderer/assets/channel-DwCSANyp.js +0 -1
- package/out/renderer/assets/classDiagram-ZZMXUADV-BT-9dtRl.js +0 -1
- package/out/renderer/assets/classDiagram-v2-VYDZK3BY-BT-9dtRl.js +0 -1
- package/out/renderer/assets/globals-DWAN16wT.js +0 -2603
- package/out/renderer/assets/globals-DoPyZAQo.css +0 -1
- package/out/renderer/assets/index-DOUivox4.js +0 -133
- package/out/renderer/assets/index-F_0FxVZ_.css +0 -1
- package/out/renderer/assets/settings-BmMFkVO5.js +0 -27
- package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-JOz8ISDT.js +0 -1
- package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-Km8IGI0J.js +0 -8
- package/out/server/chunks/conversationsMove-CJZfkj55.js +0 -57
- package/out/server/chunks/engine-IZbRceya.js +0 -70
- package/out/server/chunks/engineWorker-CQxNRdLD.js +0 -6
- package/out/server/chunks/engineWorker-CrUIcXCt.js +0 -73
- package/out/server/chunks/gpuBackendInstall-COO4pT2M.js +0 -158
- package/out/server/chunks/hanbao-_aDjow_f.js +0 -187
- package/out/server/chunks/speech-CqK6_tIR.js +0 -25
- package/out/server/chunks/wetype-CR0YLhHP.js +0 -677
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import fs, { existsSync, renameSync, readFileSync, writeFileSync, statSync, appendFileSync, mkdirSync, realpathSync, constants, lstatSync, readdirSync, openSync, closeSync, readSync, rmSync, truncateSync, createWriteStream } from "node:fs";
|
|
2
|
+
import { T as THINKING_LEVELS$1, a8 as APPROVAL_MODES, g as MODEL_REASONING_OVERRIDES, h as MODEL_THINKING_LEVEL_OVERRIDES, b9 as splitPlanPrefix, bG as DEFAULT_BASE_URLS, $ as isClassifierOnlyProvider, bL as PROJECTED_FILE_TEXT_LIMIT, bA as SHELL_LIMITS, bM as imageGenerationPreviewPaths, bN as parseGeneratedImagePaths, bO as parseMaskReport, P as PLUGIN_MESSAGE_TYPE, bP as parsePluginMessageSource, bQ as parseRtkToolStats, bR as isBackgroundTaskId, bS as parseShellFailure, aq as parsePluginToolName, bT as pluginArtifactsFromToolDetails, bU as parseApprovalReviewRecord, bV as PROJECTED_FILE_CHANGE_LIMIT, bW as PROJECTED_APPLY_PATCH_PATH_TEXT_LIMIT, bX as PROJECTED_APPLY_PATCH_PATH_COUNT_LIMIT, a4 as PRIVACY_MASK_ENTRY, aD as parsePrivacyMaskRecord, a3 as mergeMaskReports, bY as foldPlanState, bZ as PLAN_MODE_ON_NOTE, b_ as PLAN_MODE_OFF_NOTE, b$ as planFeedbackText, c0 as planKickoffText, c1 as activePlanNote, c2 as PLAN_TITLE_MAX, c3 as PLAN_TEXT_MAX, c4 as planPhase, L as PLAN_ENTRY_TYPE, c5 as parsePlanEntry, aW as AGENT_TASK_MAX_RESUMES, aX as AGENT_WAIT_DEFAULT_MS, aY as AGENT_WAIT_MAX_MS, c6 as parseAgentControlToolRequest, bc as TURN_REPORT_MAX_CHARS, c7 as nativeSearchKindFor, c8 as isWorkflowPresetId } from "./agent-BbNq8i9j.js";
|
|
3
3
|
import { readFile, writeFile, rename, rm, unlink, open, lstat, chmod, realpath, access, mkdir } from "node:fs/promises";
|
|
4
|
-
import os, { homedir } from "node:os";
|
|
4
|
+
import os, { constants as constants$1, homedir } from "node:os";
|
|
5
5
|
import path, { join, dirname } from "node:path";
|
|
6
6
|
import crypto, { randomBytes, createHash, randomUUID } from "node:crypto";
|
|
7
7
|
import { gzipSync, gunzipSync } from "node:zlib";
|
|
8
8
|
import * as PiAi from "@earendil-works/pi-ai";
|
|
9
9
|
import { getCurrentSystemPrompt, getCurrentTools, clampThinkingLevel } from "@earendil-works/pi-ai";
|
|
10
|
-
import { withFileMutationQueue, getPowerShellConfig, createCodemodeExtension, createToolSearchExtension, sessionEntryToContextMessages, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
10
|
+
import { withFileMutationQueue, getShellConfig, getPowerShellConfig, createCodemodeExtension, createToolSearchExtension, sessionEntryToContextMessages, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
11
11
|
import { parse, stringify } from "yaml";
|
|
12
|
-
import { spawn } from "node:child_process";
|
|
12
|
+
import { spawn, execFileSync, execFile } from "node:child_process";
|
|
13
13
|
import { StringDecoder } from "node:string_decoder";
|
|
14
14
|
import { stripVTControlCharacters } from "node:util";
|
|
15
15
|
import { fileURLToPath } from "node:url";
|
|
16
16
|
import { isUtf8 } from "node:buffer";
|
|
17
|
+
import { Q as normalizeMemorySearchParams, U as normalizeMemoryCaptureParams, V as normalizeMemoryCrystallizeParams, C as CRYSTAL_MIN_SOURCES, W as normalizeMemoryDeleteParams, X as MEMORY_SEARCH_MODES, Y as MEMORY_SEARCH_SPACES, Z as MEMORY_SEARCH_MAX_LIMIT, _ as EVOLVES_RELATIONS, $ as MEMORY_CAPTURE_SPACES, a0 as UNIT_TYPES } from "./sendImage-BCNW9JRV.js";
|
|
17
18
|
import { lookup } from "node:dns/promises";
|
|
18
19
|
import { isIP, BlockList } from "node:net";
|
|
19
20
|
import { Readability } from "@mozilla/readability";
|
|
@@ -22,6 +23,57 @@ import TurndownService from "turndown";
|
|
|
22
23
|
import { ProxyAgent, fetch as fetch$1, Agent } from "undici";
|
|
23
24
|
import { transformMessages } from "@earendil-works/pi-ai/api/transform-messages";
|
|
24
25
|
import http from "node:http";
|
|
26
|
+
const RESTART_CHECKPOINT_FILE = "restart-checkpoint.json";
|
|
27
|
+
const RESTART_CHECKPOINT_ARCHIVE = "restart-checkpoint.consumed.json";
|
|
28
|
+
const RESTART_CHECKPOINT_ENV = "ENSO_AGENT_RESTART_CHECKPOINT";
|
|
29
|
+
function restartGate(input) {
|
|
30
|
+
if (input.toolsInFlight.length > 0) return { ready: false, reason: "tool-in-flight" };
|
|
31
|
+
if (input.atModelRequestBoundary) return { ready: true, nextStep: "model-request" };
|
|
32
|
+
if (input.turnActive) return { ready: false, reason: "turn-in-progress" };
|
|
33
|
+
return { ready: true, nextStep: "await-user" };
|
|
34
|
+
}
|
|
35
|
+
const isString = (value) => typeof value === "string";
|
|
36
|
+
const isNonEmpty = (value) => isString(value) && value.length > 0;
|
|
37
|
+
const isCount = (value) => Number.isInteger(value) && value >= 0;
|
|
38
|
+
const ENTRY_KEYS = [
|
|
39
|
+
"sessionId",
|
|
40
|
+
"generation",
|
|
41
|
+
"sessionFile",
|
|
42
|
+
"seq",
|
|
43
|
+
"nextStep",
|
|
44
|
+
"turnId",
|
|
45
|
+
"lastCompletedToolCallId",
|
|
46
|
+
"messageCount",
|
|
47
|
+
"toolsInFlight"
|
|
48
|
+
];
|
|
49
|
+
function parseEntry$1(value) {
|
|
50
|
+
if (typeof value !== "object" || value === null) return null;
|
|
51
|
+
const entry = value;
|
|
52
|
+
const keys = Object.keys(entry);
|
|
53
|
+
if (keys.length !== ENTRY_KEYS.length || !ENTRY_KEYS.every((key) => key in entry)) return null;
|
|
54
|
+
return isNonEmpty(entry.sessionId) && isNonEmpty(entry.generation) && isNonEmpty(entry.sessionFile) && isCount(entry.seq) && (entry.nextStep === "model-request" || entry.nextStep === "await-user") && (entry.turnId === null || isNonEmpty(entry.turnId)) && (entry.lastCompletedToolCallId === null || isNonEmpty(entry.lastCompletedToolCallId)) && isCount(entry.messageCount) && Array.isArray(entry.toolsInFlight) && entry.toolsInFlight.every(isNonEmpty) ? entry : null;
|
|
55
|
+
}
|
|
56
|
+
function parseRestartCheckpoint(value) {
|
|
57
|
+
if (typeof value !== "object" || value === null) return null;
|
|
58
|
+
const record = value;
|
|
59
|
+
if (record.version !== 1 || !isCount(record.pid) || !isCount(record.writtenAt)) return null;
|
|
60
|
+
if (!Array.isArray(record.sessions)) return null;
|
|
61
|
+
const sessions = record.sessions.map(parseEntry$1);
|
|
62
|
+
return sessions.every((entry) => entry !== null) ? record : null;
|
|
63
|
+
}
|
|
64
|
+
function writeRestartCheckpoint(file, checkpoint) {
|
|
65
|
+
writeFileSync(`${file}.tmp`, JSON.stringify(checkpoint));
|
|
66
|
+
renameSync(`${file}.tmp`, file);
|
|
67
|
+
}
|
|
68
|
+
function takeRestartCheckpoint(file, archive) {
|
|
69
|
+
if (!existsSync(file)) return null;
|
|
70
|
+
renameSync(file, archive);
|
|
71
|
+
try {
|
|
72
|
+
return parseRestartCheckpoint(JSON.parse(readFileSync(archive, "utf8")));
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
25
77
|
const OAUTH_LABEL_MAX_LENGTH = 32;
|
|
26
78
|
function sanitizeOauthLabel(value) {
|
|
27
79
|
let out = "";
|
|
@@ -489,7 +541,7 @@ const MODELS_DEV_URL = "https://models.dev/api.json";
|
|
|
489
541
|
const MODELS_DEV_TTL_MS = 4 * 60 * 60 * 1e3;
|
|
490
542
|
const MODELS_DEV_SCHEMA_VERSION = 1;
|
|
491
543
|
const MODELS_DEV_CACHE_NAME = "models-dev-cache.json";
|
|
492
|
-
function asRecord$
|
|
544
|
+
function asRecord$5(value) {
|
|
493
545
|
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
494
546
|
return value;
|
|
495
547
|
}
|
|
@@ -501,12 +553,12 @@ function nonNegative(value) {
|
|
|
501
553
|
}
|
|
502
554
|
function isTextChat(model) {
|
|
503
555
|
if (model.tool_call !== true) return false;
|
|
504
|
-
const output = asRecord$
|
|
556
|
+
const output = asRecord$5(model.modalities)?.output;
|
|
505
557
|
if (output === void 0) return true;
|
|
506
558
|
return Array.isArray(output) && output.includes("text");
|
|
507
559
|
}
|
|
508
560
|
function parseCost(value) {
|
|
509
|
-
const record = asRecord$
|
|
561
|
+
const record = asRecord$5(value);
|
|
510
562
|
if (!record) return void 0;
|
|
511
563
|
const input = nonNegative(record.input);
|
|
512
564
|
const output = nonNegative(record.output);
|
|
@@ -524,11 +576,11 @@ function parseCost(value) {
|
|
|
524
576
|
return cost.input || cost.output || cost.cacheRead || cost.cacheWrite ? cost : void 0;
|
|
525
577
|
}
|
|
526
578
|
function parseLiveModel(provider, key, value) {
|
|
527
|
-
const model = asRecord$
|
|
579
|
+
const model = asRecord$5(value);
|
|
528
580
|
if (!model || !isTextChat(model)) return void 0;
|
|
529
581
|
const id = typeof model.id === "string" && model.id.trim() ? model.id.trim() : key.trim();
|
|
530
582
|
if (!id) return void 0;
|
|
531
|
-
const limit = asRecord$
|
|
583
|
+
const limit = asRecord$5(model.limit);
|
|
532
584
|
const contextWindow = positiveInt(limit?.context) ?? positiveInt(limit?.input);
|
|
533
585
|
const maxTokens = positiveInt(limit?.output);
|
|
534
586
|
const name = typeof model.name === "string" && model.name.trim() ? model.name.trim() : void 0;
|
|
@@ -544,11 +596,11 @@ function parseLiveModel(provider, key, value) {
|
|
|
544
596
|
};
|
|
545
597
|
}
|
|
546
598
|
function parseModelsDevPayload(raw, fetchedAt, source = MODELS_DEV_URL) {
|
|
547
|
-
const root = asRecord$
|
|
599
|
+
const root = asRecord$5(raw);
|
|
548
600
|
if (!root || !Number.isFinite(fetchedAt)) return void 0;
|
|
549
601
|
const models = [];
|
|
550
602
|
for (const [provider, value] of Object.entries(root)) {
|
|
551
|
-
const modelsRecord = asRecord$
|
|
603
|
+
const modelsRecord = asRecord$5(asRecord$5(value)?.models);
|
|
552
604
|
if (!provider || !modelsRecord) continue;
|
|
553
605
|
for (const [key, model] of Object.entries(modelsRecord)) {
|
|
554
606
|
const parsed = parseLiveModel(provider, key, model);
|
|
@@ -559,7 +611,7 @@ function parseModelsDevPayload(raw, fetchedAt, source = MODELS_DEV_URL) {
|
|
|
559
611
|
return { schemaVersion: MODELS_DEV_SCHEMA_VERSION, source, fetchedAt, models };
|
|
560
612
|
}
|
|
561
613
|
function parseCachedModel(value) {
|
|
562
|
-
const model = asRecord$
|
|
614
|
+
const model = asRecord$5(value);
|
|
563
615
|
if (!model || typeof model.id !== "string" || !model.id || typeof model.provider !== "string" || !model.provider) {
|
|
564
616
|
return void 0;
|
|
565
617
|
}
|
|
@@ -578,7 +630,7 @@ function parseCachedModel(value) {
|
|
|
578
630
|
};
|
|
579
631
|
}
|
|
580
632
|
function parseCachedCost(value) {
|
|
581
|
-
const record = asRecord$
|
|
633
|
+
const record = asRecord$5(value);
|
|
582
634
|
if (!record) return void 0;
|
|
583
635
|
const input = nonNegative(record.input);
|
|
584
636
|
const output = nonNegative(record.output);
|
|
@@ -596,7 +648,7 @@ function parseCachedCost(value) {
|
|
|
596
648
|
return cost.input || cost.output || cost.cacheRead || cost.cacheWrite ? cost : void 0;
|
|
597
649
|
}
|
|
598
650
|
function parseModelsDevCache(raw) {
|
|
599
|
-
const record = asRecord$
|
|
651
|
+
const record = asRecord$5(raw);
|
|
600
652
|
if (!record || record.schemaVersion !== MODELS_DEV_SCHEMA_VERSION) return void 0;
|
|
601
653
|
if (typeof record.source !== "string" || !record.source) return void 0;
|
|
602
654
|
if (typeof record.fetchedAt !== "number" || !Number.isFinite(record.fetchedAt)) return void 0;
|
|
@@ -995,7 +1047,7 @@ function parseAntigravityApiKey(apiKeyRaw) {
|
|
|
995
1047
|
};
|
|
996
1048
|
}
|
|
997
1049
|
const UPSTREAM_BODY_LIMIT = 2e3;
|
|
998
|
-
const SECRET_PATTERNS = [
|
|
1050
|
+
const SECRET_PATTERNS$1 = [
|
|
999
1051
|
[/\b(Bearer|Basic)\s+[\w\-._~+/]+=*/gi, "$1 [已脱敏]"],
|
|
1000
1052
|
[
|
|
1001
1053
|
/"(access_token|refresh_token|id_token|client_secret|authorization|api_key|apikey)"\s*:\s*"[^"]*"/gi,
|
|
@@ -1014,7 +1066,7 @@ function sanitizeUpstreamBody(text2) {
|
|
|
1014
1066
|
}
|
|
1015
1067
|
function redactUpstreamBody(text2) {
|
|
1016
1068
|
let safe = text2;
|
|
1017
|
-
for (const [pattern, replacement] of SECRET_PATTERNS) safe = safe.replace(pattern, replacement);
|
|
1069
|
+
for (const [pattern, replacement] of SECRET_PATTERNS$1) safe = safe.replace(pattern, replacement);
|
|
1018
1070
|
return safe.replace(/\s+/g, " ").trim();
|
|
1019
1071
|
}
|
|
1020
1072
|
async function fetchWithTimeout(url, init, signal, timeoutMs = REQUEST_TIMEOUT_MS) {
|
|
@@ -1107,16 +1159,16 @@ async function loadCodeAssist(accessToken, signal) {
|
|
|
1107
1159
|
}
|
|
1108
1160
|
return payload;
|
|
1109
1161
|
}
|
|
1110
|
-
function asRecord$
|
|
1162
|
+
function asRecord$4(value) {
|
|
1111
1163
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
1112
1164
|
}
|
|
1113
1165
|
function extractAntigravityProjectId(data) {
|
|
1114
|
-
const record = asRecord$
|
|
1166
|
+
const record = asRecord$4(data);
|
|
1115
1167
|
if (!record) return void 0;
|
|
1116
1168
|
const direct = record.antigravityProjectId ?? record.projectId ?? record.backendProjectId ?? record.userDefinedCloudaicompanionProject ?? record.cloudaicompanionProject ?? record.project;
|
|
1117
1169
|
const directId = optionalString(direct);
|
|
1118
1170
|
if (directId) return directId;
|
|
1119
|
-
const nestedId = optionalString(asRecord$
|
|
1171
|
+
const nestedId = optionalString(asRecord$4(direct)?.id);
|
|
1120
1172
|
if (nestedId) return nestedId;
|
|
1121
1173
|
for (const key of ["projects", "projectIds", "cloudaicompanionProjects"]) {
|
|
1122
1174
|
const value = record[key];
|
|
@@ -1124,7 +1176,7 @@ function extractAntigravityProjectId(data) {
|
|
|
1124
1176
|
for (const item of value) {
|
|
1125
1177
|
const fromItem = extractAntigravityProjectId(item);
|
|
1126
1178
|
if (fromItem) return fromItem;
|
|
1127
|
-
const itemId = optionalString(item) ?? optionalString(asRecord$
|
|
1179
|
+
const itemId = optionalString(item) ?? optionalString(asRecord$4(item)?.id);
|
|
1128
1180
|
if (itemId) return itemId;
|
|
1129
1181
|
}
|
|
1130
1182
|
}
|
|
@@ -1133,9 +1185,9 @@ function extractAntigravityProjectId(data) {
|
|
|
1133
1185
|
function planAntigravityProjectDiscovery(payload) {
|
|
1134
1186
|
const projectId = extractAntigravityProjectId(payload);
|
|
1135
1187
|
if (projectId) return { action: "use-project", projectId };
|
|
1136
|
-
const record = asRecord$
|
|
1188
|
+
const record = asRecord$4(payload) ?? {};
|
|
1137
1189
|
const allowed = Array.isArray(record.allowedTiers) ? record.allowedTiers : [];
|
|
1138
|
-
const freeAllowed = allowed.some((tier) => asRecord$
|
|
1190
|
+
const freeAllowed = allowed.some((tier) => asRecord$4(tier)?.id === FREE_TIER_ID);
|
|
1139
1191
|
if (freeAllowed && (record.currentTier === void 0 || record.currentTier === null)) {
|
|
1140
1192
|
return { action: "onboard" };
|
|
1141
1193
|
}
|
|
@@ -1419,6 +1471,12 @@ function normalizeToolSchema(value) {
|
|
|
1419
1471
|
}
|
|
1420
1472
|
return out;
|
|
1421
1473
|
}
|
|
1474
|
+
function cleanGeminiToolSchema(schema2) {
|
|
1475
|
+
return normalizeToolSchema(expandSchemaRefs(schema2));
|
|
1476
|
+
}
|
|
1477
|
+
function toolSchemaForModel(modelId, schema2) {
|
|
1478
|
+
return modelId.toLowerCase().startsWith("gemini") ? cleanGeminiToolSchema(schema2) : schema2;
|
|
1479
|
+
}
|
|
1422
1480
|
const EFFORT_LADDER = [
|
|
1423
1481
|
"off",
|
|
1424
1482
|
"minimal",
|
|
@@ -1819,7 +1877,7 @@ function convertTools(tools) {
|
|
|
1819
1877
|
functionDeclarations: tools.map((tool) => ({
|
|
1820
1878
|
name: tool.name,
|
|
1821
1879
|
description: tool.description || "",
|
|
1822
|
-
parameters:
|
|
1880
|
+
parameters: cleanGeminiToolSchema(tool.parameters)
|
|
1823
1881
|
}))
|
|
1824
1882
|
}
|
|
1825
1883
|
];
|
|
@@ -3947,7 +4005,7 @@ function buildDevinChatRequest(model, context, options, apiKey, userJwt) {
|
|
|
3947
4005
|
(tool) => create(ChatToolDefinitionSchema, {
|
|
3948
4006
|
name: tool.name,
|
|
3949
4007
|
description: tool.description || "",
|
|
3950
|
-
jsonSchemaString: JSON.stringify(tool.parameters ?? {}),
|
|
4008
|
+
jsonSchemaString: JSON.stringify(toolSchemaForModel(model.id, tool.parameters ?? {})),
|
|
3951
4009
|
strict: "strict" in tool && tool.strict === true
|
|
3952
4010
|
})
|
|
3953
4011
|
)
|
|
@@ -5420,7 +5478,7 @@ function normalizeBaseUrl(url) {
|
|
|
5420
5478
|
const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
5421
5479
|
return withScheme.endsWith("/") ? withScheme : `${withScheme}/`;
|
|
5422
5480
|
}
|
|
5423
|
-
function asRecord$
|
|
5481
|
+
function asRecord$3(value) {
|
|
5424
5482
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
5425
5483
|
}
|
|
5426
5484
|
function stringArray(value) {
|
|
@@ -5434,9 +5492,9 @@ function stringArray(value) {
|
|
|
5434
5492
|
return out;
|
|
5435
5493
|
}
|
|
5436
5494
|
function parseQoderRegionEndpoints(payload) {
|
|
5437
|
-
const root = asRecord$
|
|
5495
|
+
const root = asRecord$3(payload);
|
|
5438
5496
|
if (!root) return void 0;
|
|
5439
|
-
const dataNodes = asRecord$
|
|
5497
|
+
const dataNodes = asRecord$3(root.dataNodeMap) ?? {};
|
|
5440
5498
|
const endpoints = {
|
|
5441
5499
|
inferNodes: stringArray(root.inferNodes),
|
|
5442
5500
|
remoteAgentNodes: stringArray(dataNodes.remote_agent),
|
|
@@ -6741,10 +6799,10 @@ function streamQoder(model, context, options) {
|
|
|
6741
6799
|
return;
|
|
6742
6800
|
}
|
|
6743
6801
|
output.stopReason = aborted ? "aborted" : "error";
|
|
6744
|
-
let
|
|
6745
|
-
if (secretToken)
|
|
6746
|
-
if (options?.apiKey)
|
|
6747
|
-
output.errorMessage =
|
|
6802
|
+
let errorMessage2 = e instanceof Error ? e.message : String(e);
|
|
6803
|
+
if (secretToken) errorMessage2 = errorMessage2.replaceAll(secretToken, "[redacted]");
|
|
6804
|
+
if (options?.apiKey) errorMessage2 = errorMessage2.replaceAll(options.apiKey, "[redacted]");
|
|
6805
|
+
output.errorMessage = errorMessage2;
|
|
6748
6806
|
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
6749
6807
|
try {
|
|
6750
6808
|
stream.end();
|
|
@@ -6804,12 +6862,12 @@ function qoderProviderConfig(mode = "global") {
|
|
|
6804
6862
|
}
|
|
6805
6863
|
};
|
|
6806
6864
|
}
|
|
6807
|
-
function shellQuote(value) {
|
|
6865
|
+
function shellQuote$1(value) {
|
|
6808
6866
|
return `'${value.replaceAll("'", `'\\''`)}'`;
|
|
6809
6867
|
}
|
|
6810
6868
|
function buildRemoteCommand(command, options = {}) {
|
|
6811
|
-
const body = Array.isArray(command) ? command.map(shellQuote).join(" ") : `bash -lc ${shellQuote(command)}`;
|
|
6812
|
-
return options.cwd ? `cd ${shellQuote(options.cwd)} && ${body}` : body;
|
|
6869
|
+
const body = Array.isArray(command) ? command.map(shellQuote$1).join(" ") : `bash -lc ${shellQuote$1(command)}`;
|
|
6870
|
+
return options.cwd ? `cd ${shellQuote$1(options.cwd)} && ${body}` : body;
|
|
6813
6871
|
}
|
|
6814
6872
|
function resolveSshTarget(conn) {
|
|
6815
6873
|
return conn.user ? `${conn.user}@${conn.host}` : conn.host;
|
|
@@ -6817,11 +6875,11 @@ function resolveSshTarget(conn) {
|
|
|
6817
6875
|
function buildSshShellCommand(host, script, options = {}) {
|
|
6818
6876
|
const remoteCommand = buildRemoteCommand(script, { cwd: options.cwd });
|
|
6819
6877
|
const args = buildSshExecArgs(host, remoteCommand, options);
|
|
6820
|
-
return `ssh ${args.map(shellQuote).join(" ")}`;
|
|
6878
|
+
return `ssh ${args.map(shellQuote$1).join(" ")}`;
|
|
6821
6879
|
}
|
|
6822
6880
|
function buildSshPtyRemoteCommand(cwd) {
|
|
6823
6881
|
const shell = 'exec "${SHELL:-/bin/bash}" -l';
|
|
6824
|
-
return cwd ? `cd ${shellQuote(cwd)} && ${shell}` : shell;
|
|
6882
|
+
return cwd ? `cd ${shellQuote$1(cwd)} && ${shell}` : shell;
|
|
6825
6883
|
}
|
|
6826
6884
|
function buildSshPtyArgs(host, options = {}) {
|
|
6827
6885
|
return ["-tt", ...buildSshExecArgs(host, buildSshPtyRemoteCommand(options.cwd), options)];
|
|
@@ -6866,10 +6924,34 @@ function splitUnattendedPrefix(text2) {
|
|
|
6866
6924
|
rest: text2.slice(match[0].length)
|
|
6867
6925
|
};
|
|
6868
6926
|
}
|
|
6869
|
-
|
|
6927
|
+
const TASK_WRAP_UP_TAG = "background-tasks-wrap-up";
|
|
6928
|
+
const TASK_WRAP_UP_PREFIX = new RegExp(
|
|
6929
|
+
`^<${TASK_WRAP_UP_TAG}>\\n[\\s\\S]*?\\n</${TASK_WRAP_UP_TAG}>(?:\\n\\n|$)`
|
|
6930
|
+
);
|
|
6931
|
+
const TASK_LINE = /^- (\S+?): (.*?)(?: \(running ([^()]+)\))?$/;
|
|
6932
|
+
function parseTaskWrapUp(block) {
|
|
6933
|
+
const items = [];
|
|
6934
|
+
for (const line of block.split("\n")) {
|
|
6935
|
+
const match = TASK_LINE.exec(line);
|
|
6936
|
+
if (!match?.[1]) continue;
|
|
6937
|
+
items.push({
|
|
6938
|
+
taskId: match[1],
|
|
6939
|
+
command: match[2] ?? "",
|
|
6940
|
+
...match[3] ? { ran: match[3] } : {}
|
|
6941
|
+
});
|
|
6942
|
+
}
|
|
6943
|
+
return items;
|
|
6944
|
+
}
|
|
6945
|
+
function splitTaskWrapUpPrefix(text2) {
|
|
6946
|
+
const match = TASK_WRAP_UP_PREFIX.exec(text2);
|
|
6947
|
+
if (!match) return null;
|
|
6948
|
+
return { items: parseTaskWrapUp(match[0]), rest: text2.slice(match[0].length) };
|
|
6949
|
+
}
|
|
6950
|
+
function peelTurnNotes(text2) {
|
|
6870
6951
|
let rest = text2;
|
|
6871
6952
|
let plan;
|
|
6872
6953
|
let unattended;
|
|
6954
|
+
let wrapUp;
|
|
6873
6955
|
for (; ; ) {
|
|
6874
6956
|
const p = plan ? { rest } : splitPlanPrefix(rest);
|
|
6875
6957
|
if (p.note) {
|
|
@@ -6877,11 +6959,22 @@ function splitTurnNotes(text2) {
|
|
|
6877
6959
|
rest = p.rest;
|
|
6878
6960
|
continue;
|
|
6879
6961
|
}
|
|
6962
|
+
const found = wrapUp ? null : splitTaskWrapUpPrefix(rest);
|
|
6963
|
+
if (found) {
|
|
6964
|
+
const start = text2.length - rest.length;
|
|
6965
|
+
wrapUp = { items: found.items, start, end: start + rest.length - found.rest.length };
|
|
6966
|
+
rest = found.rest;
|
|
6967
|
+
continue;
|
|
6968
|
+
}
|
|
6880
6969
|
const u = unattended ? { rest } : splitUnattendedPrefix(rest);
|
|
6881
6970
|
if (!u.note) break;
|
|
6882
6971
|
unattended = u.note;
|
|
6883
6972
|
rest = u.rest;
|
|
6884
6973
|
}
|
|
6974
|
+
return { ...plan ? { plan } : {}, ...unattended ? { unattended } : {}, wrapUp, rest };
|
|
6975
|
+
}
|
|
6976
|
+
function splitTurnNotes(text2) {
|
|
6977
|
+
const { plan, unattended, rest } = peelTurnNotes(text2);
|
|
6885
6978
|
return { ...plan ? { plan } : {}, ...unattended ? { unattended } : {}, rest };
|
|
6886
6979
|
}
|
|
6887
6980
|
function prependTurnNote(note, text2) {
|
|
@@ -9316,10 +9409,10 @@ class AskManager {
|
|
|
9316
9409
|
this.pending.get(requestId)?.expire();
|
|
9317
9410
|
}
|
|
9318
9411
|
/** abort/dismiss 时取消全部挂起提问(fail-closed) */
|
|
9319
|
-
cancelAll() {
|
|
9412
|
+
cancelAll(reason = "question cancelled") {
|
|
9320
9413
|
for (const [requestId, entry] of this.pending) {
|
|
9321
9414
|
this.onResolved(requestId);
|
|
9322
|
-
entry.reject(new Error(
|
|
9415
|
+
entry.reject(new Error(reason));
|
|
9323
9416
|
}
|
|
9324
9417
|
this.pending.clear();
|
|
9325
9418
|
}
|
|
@@ -9373,6 +9466,606 @@ function createAskTool(manager) {
|
|
|
9373
9466
|
const SHELL_READ_HINT = "Shell read-only shortcut: prefer read (offset/limit) for files, grep for content, find for paths — the dedicated tools handle line ranges and stream far less output.";
|
|
9374
9467
|
const SHELL_SLEEP_HINT = "Sleep-waiting in a foreground command costs a model round per check. Put the whole wait in one command that exits when the condition holds (e.g. `until <check>; do sleep 10; done; <report>`) and run it with background: true — you are notified when it finishes, then end your turn.";
|
|
9375
9468
|
const SHELL_TIMEOUT_HINT = "timeout only kills the process; it does not keep this call in the foreground. If the command may outlast the yield, set background: true and end your turn — completion wakes you. Do not poll with sleep, ps, pgrep, or task_output loops.";
|
|
9469
|
+
const SECRET_PATTERNS = [
|
|
9470
|
+
/\bBearer\s+[A-Za-z0-9._~+/-]+=*/gi,
|
|
9471
|
+
/\b(?:api[_-]?key|access[_-]?token|refresh[_-]?token|client[_-]?secret)\s*[:=]\s*[^\s,;]+/gi,
|
|
9472
|
+
/https?:\/\/[^\s/@:]+:[^\s/@]+@/gi,
|
|
9473
|
+
/\b(?:sk|ghp|xox[baprs])-[-A-Za-z0-9_]{12,}\b/g
|
|
9474
|
+
];
|
|
9475
|
+
function redactSafeText(text2) {
|
|
9476
|
+
return SECRET_PATTERNS.reduce(
|
|
9477
|
+
(value, pattern) => value.replace(pattern, "[REDACTED]"),
|
|
9478
|
+
text2
|
|
9479
|
+
).slice(0, 1e5);
|
|
9480
|
+
}
|
|
9481
|
+
class EnsoSafeJournal {
|
|
9482
|
+
sessionFile;
|
|
9483
|
+
constructor(sessionDir, child, cwd, resumeFile) {
|
|
9484
|
+
mkdirSync(sessionDir, { recursive: true });
|
|
9485
|
+
this.sessionFile = resumeFile ?? path.join(
|
|
9486
|
+
sessionDir,
|
|
9487
|
+
`enso-${child.sessionId.replace(/[^A-Za-z0-9._-]/g, "_")}-${child.generation}.jsonl`
|
|
9488
|
+
);
|
|
9489
|
+
if (!resumeFile) {
|
|
9490
|
+
const header = {
|
|
9491
|
+
type: "enso-safe-session",
|
|
9492
|
+
version: 1,
|
|
9493
|
+
child,
|
|
9494
|
+
cwd,
|
|
9495
|
+
createdAt: Date.now()
|
|
9496
|
+
};
|
|
9497
|
+
writeFileSync(this.sessionFile, `${JSON.stringify(header)}
|
|
9498
|
+
`, {
|
|
9499
|
+
encoding: "utf8",
|
|
9500
|
+
mode: 384,
|
|
9501
|
+
flag: "wx"
|
|
9502
|
+
});
|
|
9503
|
+
}
|
|
9504
|
+
}
|
|
9505
|
+
append(record) {
|
|
9506
|
+
appendFileSync(this.sessionFile, `${JSON.stringify(this.sanitize(record))}
|
|
9507
|
+
`, "utf8");
|
|
9508
|
+
}
|
|
9509
|
+
appendUserText(text2) {
|
|
9510
|
+
this.append({ type: "safe-user-text", text: redactSafeText(text2), at: Date.now() });
|
|
9511
|
+
}
|
|
9512
|
+
appendAssistantText(text2) {
|
|
9513
|
+
this.append({ type: "safe-assistant-text", text: redactSafeText(text2), at: Date.now() });
|
|
9514
|
+
}
|
|
9515
|
+
appendCapabilityResult(toolCallId, envelope) {
|
|
9516
|
+
this.append({
|
|
9517
|
+
type: "safe-model-result",
|
|
9518
|
+
toolCallId,
|
|
9519
|
+
modelResult: envelope.modelResult,
|
|
9520
|
+
at: Date.now()
|
|
9521
|
+
});
|
|
9522
|
+
this.append({ type: "capability-receipt", receipt: envelope.receipt, at: Date.now() });
|
|
9523
|
+
}
|
|
9524
|
+
static async restore(sessionFile) {
|
|
9525
|
+
const records2 = [];
|
|
9526
|
+
let partial = false;
|
|
9527
|
+
let lines;
|
|
9528
|
+
try {
|
|
9529
|
+
lines = (await readFile(sessionFile, "utf8")).split("\n").filter(Boolean);
|
|
9530
|
+
} catch {
|
|
9531
|
+
return { records: records2, partial: true };
|
|
9532
|
+
}
|
|
9533
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
9534
|
+
try {
|
|
9535
|
+
const value = JSON.parse(lines[index]);
|
|
9536
|
+
if (index === 0 && value.type === "enso-safe-session" && value.version === 1) continue;
|
|
9537
|
+
const parsed = parseRecord(value);
|
|
9538
|
+
if (parsed) records2.push(parsed);
|
|
9539
|
+
else partial = true;
|
|
9540
|
+
} catch {
|
|
9541
|
+
partial = true;
|
|
9542
|
+
}
|
|
9543
|
+
}
|
|
9544
|
+
return { records: records2, partial };
|
|
9545
|
+
}
|
|
9546
|
+
sanitize(record) {
|
|
9547
|
+
if (record.type === "safe-user-text" || record.type === "safe-assistant-text") {
|
|
9548
|
+
return { ...record, text: redactSafeText(record.text) };
|
|
9549
|
+
}
|
|
9550
|
+
return record;
|
|
9551
|
+
}
|
|
9552
|
+
}
|
|
9553
|
+
function parseRecord(value) {
|
|
9554
|
+
if ((value.type === "safe-user-text" || value.type === "safe-assistant-text") && typeof value.text === "string" && typeof value.at === "number") {
|
|
9555
|
+
return value;
|
|
9556
|
+
}
|
|
9557
|
+
if (value.type === "enso-operation" && typeof value.operationId === "string" && typeof value.capabilityId === "string" && typeof value.toolCallId === "string" && typeof value.at === "number") {
|
|
9558
|
+
return value;
|
|
9559
|
+
}
|
|
9560
|
+
if (value.type === "safe-model-result" && typeof value.toolCallId === "string" && value.modelResult && typeof value.modelResult === "object" && typeof value.at === "number") {
|
|
9561
|
+
return value;
|
|
9562
|
+
}
|
|
9563
|
+
if (value.type === "capability-receipt" && value.receipt && typeof value.receipt === "object" && typeof value.at === "number") {
|
|
9564
|
+
return value;
|
|
9565
|
+
}
|
|
9566
|
+
return null;
|
|
9567
|
+
}
|
|
9568
|
+
const RUN_ID_ENV = "ENSO_RUN_ID";
|
|
9569
|
+
const START_TOLERANCE_MS = 3e3;
|
|
9570
|
+
const RUN_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
9571
|
+
const LIVE_POLL_MIN_MS = 15;
|
|
9572
|
+
const LIVE_POLL_MAX_MS = 250;
|
|
9573
|
+
const ATTACH_POLL_MS = 250;
|
|
9574
|
+
const IDENTITY_EVERY = 40;
|
|
9575
|
+
const READ_CHUNK = 64 * 1024;
|
|
9576
|
+
const TRUNCATE_AT = 8 * 1024 * 1024;
|
|
9577
|
+
function isRunId(value) {
|
|
9578
|
+
return typeof value === "string" && RUN_ID.test(value);
|
|
9579
|
+
}
|
|
9580
|
+
function runFiles(dir, runId) {
|
|
9581
|
+
return {
|
|
9582
|
+
outputFile: path.join(dir, `run-${runId}.out`),
|
|
9583
|
+
exitFile: path.join(dir, `run-${runId}.exit`),
|
|
9584
|
+
metaFile: path.join(dir, `run-${runId}.json`)
|
|
9585
|
+
};
|
|
9586
|
+
}
|
|
9587
|
+
function removeRunFiles(dir, runId) {
|
|
9588
|
+
for (const file of Object.values(runFiles(dir, runId))) rmSync(file, { force: true });
|
|
9589
|
+
}
|
|
9590
|
+
function shellQuote(value) {
|
|
9591
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
9592
|
+
}
|
|
9593
|
+
function withExitTrap(command, exitFile) {
|
|
9594
|
+
return `trap ${shellQuote(`printf %s "$?" > ${shellQuote(exitFile)}`)} EXIT; ${command}`;
|
|
9595
|
+
}
|
|
9596
|
+
function readExitCode(file) {
|
|
9597
|
+
try {
|
|
9598
|
+
const text2 = readFileSync(file, "utf8").trim();
|
|
9599
|
+
return /^\d{1,3}$/.test(text2) ? Number(text2) : null;
|
|
9600
|
+
} catch {
|
|
9601
|
+
return null;
|
|
9602
|
+
}
|
|
9603
|
+
}
|
|
9604
|
+
function processAlive(pid) {
|
|
9605
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
9606
|
+
try {
|
|
9607
|
+
process.kill(pid, 0);
|
|
9608
|
+
return true;
|
|
9609
|
+
} catch (error) {
|
|
9610
|
+
return error.code !== "ESRCH";
|
|
9611
|
+
}
|
|
9612
|
+
}
|
|
9613
|
+
function processCommandLine(pid) {
|
|
9614
|
+
if (!Number.isInteger(pid) || pid <= 0) return null;
|
|
9615
|
+
try {
|
|
9616
|
+
if (process.platform === "linux") {
|
|
9617
|
+
return readFileSync(`/proc/${pid}/cmdline`, "utf8").replace(/\0/g, " ");
|
|
9618
|
+
}
|
|
9619
|
+
return execFileSync(
|
|
9620
|
+
existsSync("/bin/ps") ? "/bin/ps" : "ps",
|
|
9621
|
+
["-ww", "-o", "command=", "-p", String(pid)],
|
|
9622
|
+
{
|
|
9623
|
+
encoding: "utf8",
|
|
9624
|
+
timeout: 2e3,
|
|
9625
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
9626
|
+
}
|
|
9627
|
+
);
|
|
9628
|
+
} catch {
|
|
9629
|
+
return null;
|
|
9630
|
+
}
|
|
9631
|
+
}
|
|
9632
|
+
function parseElapsed(text2) {
|
|
9633
|
+
const match = /^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)$/.exec(text2.trim());
|
|
9634
|
+
if (!match) return null;
|
|
9635
|
+
const [, days, hours, minutes, seconds] = match;
|
|
9636
|
+
return (((Number(days ?? 0) * 24 + Number(hours ?? 0)) * 60 + Number(minutes)) * 60 + Number(seconds)) * 1e3;
|
|
9637
|
+
}
|
|
9638
|
+
function processStartedAt(pid) {
|
|
9639
|
+
if (!Number.isInteger(pid) || pid <= 0) return null;
|
|
9640
|
+
try {
|
|
9641
|
+
const elapsed = parseElapsed(
|
|
9642
|
+
execFileSync(existsSync("/bin/ps") ? "/bin/ps" : "ps", ["-o", "etime=", "-p", String(pid)], {
|
|
9643
|
+
encoding: "utf8",
|
|
9644
|
+
timeout: 2e3,
|
|
9645
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
9646
|
+
})
|
|
9647
|
+
);
|
|
9648
|
+
return elapsed === null ? null : Date.now() - elapsed;
|
|
9649
|
+
} catch {
|
|
9650
|
+
return null;
|
|
9651
|
+
}
|
|
9652
|
+
}
|
|
9653
|
+
function environHas(pid, entry) {
|
|
9654
|
+
try {
|
|
9655
|
+
return readFileSync(`/proc/${pid}/environ`, "utf8").split("\0").includes(entry);
|
|
9656
|
+
} catch {
|
|
9657
|
+
return false;
|
|
9658
|
+
}
|
|
9659
|
+
}
|
|
9660
|
+
function runIdentityMatches(pid, run) {
|
|
9661
|
+
if (processCommandLine(pid)?.includes(run.runId)) return true;
|
|
9662
|
+
if (process.platform === "linux" && environHas(pid, `${RUN_ID_ENV}=${run.runId}`)) return true;
|
|
9663
|
+
const startedAt = processStartedAt(pid);
|
|
9664
|
+
return startedAt !== null && Math.abs(startedAt - run.startedAt) <= START_TOLERANCE_MS;
|
|
9665
|
+
}
|
|
9666
|
+
const defaultRunProbe = {
|
|
9667
|
+
alive: processAlive,
|
|
9668
|
+
matches: runIdentityMatches
|
|
9669
|
+
};
|
|
9670
|
+
function killRunGroup(pid, signal) {
|
|
9671
|
+
if (process.platform === "darwin" && signal === "SIGKILL") {
|
|
9672
|
+
try {
|
|
9673
|
+
process.kill(-pid, "SIGSTOP");
|
|
9674
|
+
} catch {
|
|
9675
|
+
}
|
|
9676
|
+
}
|
|
9677
|
+
try {
|
|
9678
|
+
process.kill(-pid, signal);
|
|
9679
|
+
} catch {
|
|
9680
|
+
try {
|
|
9681
|
+
process.kill(pid, signal);
|
|
9682
|
+
} catch {
|
|
9683
|
+
}
|
|
9684
|
+
}
|
|
9685
|
+
}
|
|
9686
|
+
class FileTail {
|
|
9687
|
+
constructor(file, offset) {
|
|
9688
|
+
this.file = file;
|
|
9689
|
+
this.offset = offset;
|
|
9690
|
+
try {
|
|
9691
|
+
this.fd = openSync(file, "r");
|
|
9692
|
+
if (statSync(file).size < offset) this.offset = 0;
|
|
9693
|
+
} catch (error) {
|
|
9694
|
+
this.fd = null;
|
|
9695
|
+
this.error = errorMessage(error);
|
|
9696
|
+
}
|
|
9697
|
+
}
|
|
9698
|
+
file;
|
|
9699
|
+
offset;
|
|
9700
|
+
fd = null;
|
|
9701
|
+
onData = () => {
|
|
9702
|
+
};
|
|
9703
|
+
error = null;
|
|
9704
|
+
sink(onData) {
|
|
9705
|
+
this.onData = onData;
|
|
9706
|
+
}
|
|
9707
|
+
/** 读到末尾;返回这次有没有读到新输出 */
|
|
9708
|
+
drain() {
|
|
9709
|
+
if (this.fd === null) return false;
|
|
9710
|
+
const buffer = Buffer.allocUnsafe(READ_CHUNK);
|
|
9711
|
+
let any = false;
|
|
9712
|
+
for (; ; ) {
|
|
9713
|
+
let read;
|
|
9714
|
+
try {
|
|
9715
|
+
read = readSync(this.fd, buffer, 0, READ_CHUNK, this.offset);
|
|
9716
|
+
} catch (error) {
|
|
9717
|
+
this.error = errorMessage(error);
|
|
9718
|
+
return any;
|
|
9719
|
+
}
|
|
9720
|
+
this.error = null;
|
|
9721
|
+
if (read <= 0) break;
|
|
9722
|
+
any = true;
|
|
9723
|
+
this.offset += read;
|
|
9724
|
+
this.onData(Buffer.from(buffer.subarray(0, read)));
|
|
9725
|
+
}
|
|
9726
|
+
if (this.offset >= TRUNCATE_AT) {
|
|
9727
|
+
try {
|
|
9728
|
+
truncateSync(this.file, 0);
|
|
9729
|
+
this.offset = 0;
|
|
9730
|
+
} catch {
|
|
9731
|
+
}
|
|
9732
|
+
}
|
|
9733
|
+
return any;
|
|
9734
|
+
}
|
|
9735
|
+
close() {
|
|
9736
|
+
if (this.fd !== null) closeSync(this.fd);
|
|
9737
|
+
this.fd = null;
|
|
9738
|
+
}
|
|
9739
|
+
}
|
|
9740
|
+
const errorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
9741
|
+
function writeRunMeta(dir, run) {
|
|
9742
|
+
try {
|
|
9743
|
+
writeFileSync(
|
|
9744
|
+
runFiles(dir, run.runId).metaFile,
|
|
9745
|
+
JSON.stringify({
|
|
9746
|
+
version: 1,
|
|
9747
|
+
runId: run.runId,
|
|
9748
|
+
ownerPid: process.pid,
|
|
9749
|
+
pid: run.pid,
|
|
9750
|
+
startedAt: run.startedAt
|
|
9751
|
+
})
|
|
9752
|
+
);
|
|
9753
|
+
} catch {
|
|
9754
|
+
}
|
|
9755
|
+
}
|
|
9756
|
+
function spawnFileBacked(input) {
|
|
9757
|
+
mkdirSync(input.dir, { recursive: true });
|
|
9758
|
+
const runId = randomUUID();
|
|
9759
|
+
const { outputFile, exitFile } = runFiles(input.dir, runId);
|
|
9760
|
+
const out = openSync(outputFile, "a");
|
|
9761
|
+
let child;
|
|
9762
|
+
try {
|
|
9763
|
+
child = spawn(input.shell, [...input.args, withExitTrap(input.command, exitFile)], {
|
|
9764
|
+
cwd: input.cwd,
|
|
9765
|
+
detached: true,
|
|
9766
|
+
env: { ...input.env ?? process.env, [RUN_ID_ENV]: runId },
|
|
9767
|
+
stdio: ["ignore", out, out]
|
|
9768
|
+
});
|
|
9769
|
+
} finally {
|
|
9770
|
+
closeSync(out);
|
|
9771
|
+
}
|
|
9772
|
+
const files = {
|
|
9773
|
+
runId,
|
|
9774
|
+
pid: child.pid ?? -1,
|
|
9775
|
+
startedAt: Date.now(),
|
|
9776
|
+
cwd: input.cwd,
|
|
9777
|
+
outputFile,
|
|
9778
|
+
exitFile
|
|
9779
|
+
};
|
|
9780
|
+
if (child.pid !== void 0) writeRunMeta(input.dir, files);
|
|
9781
|
+
const tail = new FileTail(outputFile, 0);
|
|
9782
|
+
let released = false;
|
|
9783
|
+
let stopped = false;
|
|
9784
|
+
let timer;
|
|
9785
|
+
const poll = (delay) => {
|
|
9786
|
+
timer = setTimeout(() => {
|
|
9787
|
+
if (stopped) return;
|
|
9788
|
+
poll(tail.drain() ? LIVE_POLL_MIN_MS : Math.min(LIVE_POLL_MAX_MS, delay * 2));
|
|
9789
|
+
}, delay);
|
|
9790
|
+
timer.unref?.();
|
|
9791
|
+
};
|
|
9792
|
+
poll(LIVE_POLL_MIN_MS);
|
|
9793
|
+
const finish = () => {
|
|
9794
|
+
stopped = true;
|
|
9795
|
+
clearTimeout(timer);
|
|
9796
|
+
tail.drain();
|
|
9797
|
+
tail.close();
|
|
9798
|
+
removeRunFiles(input.dir, runId);
|
|
9799
|
+
};
|
|
9800
|
+
const done = new Promise(
|
|
9801
|
+
(resolve, reject) => {
|
|
9802
|
+
child.once("error", (error) => {
|
|
9803
|
+
if (released) return;
|
|
9804
|
+
finish();
|
|
9805
|
+
reject(error);
|
|
9806
|
+
});
|
|
9807
|
+
child.once("exit", (code, signal) => {
|
|
9808
|
+
if (released) return;
|
|
9809
|
+
finish();
|
|
9810
|
+
resolve({ code, signal });
|
|
9811
|
+
});
|
|
9812
|
+
}
|
|
9813
|
+
);
|
|
9814
|
+
return {
|
|
9815
|
+
...files,
|
|
9816
|
+
sink: (onData) => tail.sink(onData),
|
|
9817
|
+
flush: () => {
|
|
9818
|
+
if (!stopped) tail.drain();
|
|
9819
|
+
},
|
|
9820
|
+
readError: () => tail.error,
|
|
9821
|
+
done,
|
|
9822
|
+
kill: (signal) => {
|
|
9823
|
+
if (child.pid !== void 0) killRunGroup(child.pid, signal);
|
|
9824
|
+
},
|
|
9825
|
+
release: () => {
|
|
9826
|
+
if (!released) {
|
|
9827
|
+
released = true;
|
|
9828
|
+
stopped = true;
|
|
9829
|
+
clearTimeout(timer);
|
|
9830
|
+
tail.drain();
|
|
9831
|
+
tail.close();
|
|
9832
|
+
child.unref();
|
|
9833
|
+
}
|
|
9834
|
+
return tail.offset;
|
|
9835
|
+
}
|
|
9836
|
+
};
|
|
9837
|
+
}
|
|
9838
|
+
function attachFileBacked(dir, run, offset, probe = defaultRunProbe) {
|
|
9839
|
+
const tail = new FileTail(run.outputFile, offset);
|
|
9840
|
+
writeRunMeta(dir, run);
|
|
9841
|
+
let released = false;
|
|
9842
|
+
let ticks = 0;
|
|
9843
|
+
let timer;
|
|
9844
|
+
let ended = false;
|
|
9845
|
+
const done = new Promise((resolve) => {
|
|
9846
|
+
const check = () => {
|
|
9847
|
+
tail.drain();
|
|
9848
|
+
ticks += 1;
|
|
9849
|
+
ended = readExitCode(run.exitFile) !== null || !probe.alive(run.pid) || ticks % IDENTITY_EVERY === 0 && !probe.matches(run.pid, run);
|
|
9850
|
+
if (!ended) return;
|
|
9851
|
+
clearInterval(timer);
|
|
9852
|
+
tail.drain();
|
|
9853
|
+
tail.close();
|
|
9854
|
+
const code = readExitCode(run.exitFile);
|
|
9855
|
+
removeRunFiles(dir, run.runId);
|
|
9856
|
+
resolve({ code, signal: null });
|
|
9857
|
+
};
|
|
9858
|
+
timer = setInterval(() => {
|
|
9859
|
+
if (!released) check();
|
|
9860
|
+
}, ATTACH_POLL_MS);
|
|
9861
|
+
timer.unref?.();
|
|
9862
|
+
});
|
|
9863
|
+
return {
|
|
9864
|
+
...run,
|
|
9865
|
+
sink: (onData) => tail.sink(onData),
|
|
9866
|
+
flush: () => {
|
|
9867
|
+
if (!released && !ended) tail.drain();
|
|
9868
|
+
},
|
|
9869
|
+
readError: () => tail.error,
|
|
9870
|
+
done,
|
|
9871
|
+
kill: (signal) => {
|
|
9872
|
+
if (probe.matches(run.pid, run)) killRunGroup(run.pid, signal);
|
|
9873
|
+
},
|
|
9874
|
+
release: () => {
|
|
9875
|
+
if (!released) {
|
|
9876
|
+
released = true;
|
|
9877
|
+
clearInterval(timer);
|
|
9878
|
+
tail.drain();
|
|
9879
|
+
tail.close();
|
|
9880
|
+
}
|
|
9881
|
+
return tail.offset;
|
|
9882
|
+
}
|
|
9883
|
+
};
|
|
9884
|
+
}
|
|
9885
|
+
function readRunOutput(file, offset) {
|
|
9886
|
+
const chunks = [];
|
|
9887
|
+
const tail = new FileTail(file, offset);
|
|
9888
|
+
tail.sink((chunk) => chunks.push(chunk));
|
|
9889
|
+
tail.drain();
|
|
9890
|
+
tail.close();
|
|
9891
|
+
return Buffer.concat(chunks);
|
|
9892
|
+
}
|
|
9893
|
+
function readFileTail(file, max) {
|
|
9894
|
+
let fd;
|
|
9895
|
+
try {
|
|
9896
|
+
fd = openSync(file, "r");
|
|
9897
|
+
const size = statSync(file).size;
|
|
9898
|
+
const length = Math.min(size, max);
|
|
9899
|
+
const buffer = Buffer.alloc(length);
|
|
9900
|
+
const read = readSync(fd, buffer, 0, length, size - length);
|
|
9901
|
+
const tail = buffer.subarray(0, read);
|
|
9902
|
+
if (length === size) return tail;
|
|
9903
|
+
const newline = tail.indexOf(10);
|
|
9904
|
+
if (newline !== -1) return tail.subarray(newline + 1);
|
|
9905
|
+
let start = 0;
|
|
9906
|
+
while (start < tail.length && (tail[start] & 192) === 128) start += 1;
|
|
9907
|
+
return tail.subarray(start);
|
|
9908
|
+
} catch {
|
|
9909
|
+
return Buffer.alloc(0);
|
|
9910
|
+
} finally {
|
|
9911
|
+
if (fd !== void 0) closeSync(fd);
|
|
9912
|
+
}
|
|
9913
|
+
}
|
|
9914
|
+
function sweepOrphanRuns(dir, keep, probe = defaultRunProbe) {
|
|
9915
|
+
let names;
|
|
9916
|
+
try {
|
|
9917
|
+
names = readdirSync(dir);
|
|
9918
|
+
} catch {
|
|
9919
|
+
return [];
|
|
9920
|
+
}
|
|
9921
|
+
const killed = [];
|
|
9922
|
+
for (const name of names) {
|
|
9923
|
+
const match = /^run-(.+)\.json$/.exec(name);
|
|
9924
|
+
const runId = match?.[1];
|
|
9925
|
+
if (!runId || !isRunId(runId) || keep.has(runId)) continue;
|
|
9926
|
+
let meta;
|
|
9927
|
+
try {
|
|
9928
|
+
meta = JSON.parse(readFileSync(path.join(dir, name), "utf8"));
|
|
9929
|
+
} catch {
|
|
9930
|
+
continue;
|
|
9931
|
+
}
|
|
9932
|
+
const ownerPid = typeof meta.ownerPid === "number" ? meta.ownerPid : -1;
|
|
9933
|
+
const pid = typeof meta.pid === "number" ? meta.pid : -1;
|
|
9934
|
+
const startedAt = typeof meta.startedAt === "number" ? meta.startedAt : Number.NaN;
|
|
9935
|
+
if (ownerPid === process.pid || probe.alive(ownerPid)) continue;
|
|
9936
|
+
if (probe.alive(pid)) {
|
|
9937
|
+
if (!probe.matches(pid, { runId, startedAt })) {
|
|
9938
|
+
removeRunFiles(dir, runId);
|
|
9939
|
+
continue;
|
|
9940
|
+
}
|
|
9941
|
+
killRunGroup(pid, "SIGKILL");
|
|
9942
|
+
killed.push(runId);
|
|
9943
|
+
}
|
|
9944
|
+
removeRunFiles(dir, runId);
|
|
9945
|
+
}
|
|
9946
|
+
return killed;
|
|
9947
|
+
}
|
|
9948
|
+
const requests = /* @__PURE__ */ new WeakMap();
|
|
9949
|
+
function requestFileBackedRun(signal, request) {
|
|
9950
|
+
requests.set(signal, request);
|
|
9951
|
+
}
|
|
9952
|
+
function withFileBackedExec(inner, resolveShell = () => getShellConfig()) {
|
|
9953
|
+
return {
|
|
9954
|
+
async exec(command, cwd, options) {
|
|
9955
|
+
const request = options.signal ? requests.get(options.signal) : void 0;
|
|
9956
|
+
const shell = request ? resolveShell() : void 0;
|
|
9957
|
+
if (!request || !shell || shell.commandTransport === "stdin" || options.timeout !== void 0)
|
|
9958
|
+
return inner.exec(command, cwd, options);
|
|
9959
|
+
const { onData, signal, env } = options;
|
|
9960
|
+
if (signal?.aborted) throw new Error("aborted");
|
|
9961
|
+
try {
|
|
9962
|
+
await access(cwd);
|
|
9963
|
+
} catch {
|
|
9964
|
+
throw new Error(`Working directory does not exist: ${cwd}
|
|
9965
|
+
Cannot execute bash commands.`);
|
|
9966
|
+
}
|
|
9967
|
+
const run = spawnFileBacked({
|
|
9968
|
+
shell: shell.shell,
|
|
9969
|
+
args: shell.args,
|
|
9970
|
+
command,
|
|
9971
|
+
cwd,
|
|
9972
|
+
env,
|
|
9973
|
+
dir: request.dir
|
|
9974
|
+
});
|
|
9975
|
+
run.sink(onData);
|
|
9976
|
+
request.onSpawn(run);
|
|
9977
|
+
const onAbort = () => run.kill("SIGKILL");
|
|
9978
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
9979
|
+
try {
|
|
9980
|
+
const result2 = await run.done;
|
|
9981
|
+
if (signal?.aborted) throw new Error("aborted");
|
|
9982
|
+
const exitCode = result2.code ?? (result2.signal ? 128 + (constants$1.signals[result2.signal] ?? 0) : 1);
|
|
9983
|
+
return { exitCode };
|
|
9984
|
+
} finally {
|
|
9985
|
+
signal?.removeEventListener("abort", onAbort);
|
|
9986
|
+
}
|
|
9987
|
+
}
|
|
9988
|
+
};
|
|
9989
|
+
}
|
|
9990
|
+
const DETACHED_TASKS_FILE = "restart-background-tasks.json";
|
|
9991
|
+
const INTERRUPTED_TASKS_FILE = "restart-interrupted-tasks.json";
|
|
9992
|
+
const COMMAND_SUMMARY_LIMIT = 300;
|
|
9993
|
+
const TASK_ID = /^task-\d+-[0-9a-z]+$/;
|
|
9994
|
+
const SECRET_ASSIGNMENT = /\b([A-Za-z0-9_]*?(?:key|token|secret|passw(?:or)?d|pwd|auth|credential)[A-Za-z0-9_]*)=("[^"]*"|'[^']*'|\S+)/gi;
|
|
9995
|
+
const SECRET_FLAG = /(--?[A-Za-z0-9-]*?(?:key|token|secret|passw(?:or)?d|auth|credential)[A-Za-z0-9-]*)(=|\s+)("[^"]*"|'[^']*'|[^\s-]\S*)/gi;
|
|
9996
|
+
function commandSummary(command) {
|
|
9997
|
+
const redacted = redactSafeText(
|
|
9998
|
+
command.replace(SECRET_ASSIGNMENT, "$1=[REDACTED]").replace(SECRET_FLAG, "$1$2[REDACTED]")
|
|
9999
|
+
).trim();
|
|
10000
|
+
return redacted.length > COMMAND_SUMMARY_LIMIT ? `${redacted.slice(0, COMMAND_SUMMARY_LIMIT)}…` : redacted;
|
|
10001
|
+
}
|
|
10002
|
+
function commandKey(command, cwd) {
|
|
10003
|
+
return createHash("sha256").update(`${path.resolve(cwd)}\0${command.trim()}`).digest("hex");
|
|
10004
|
+
}
|
|
10005
|
+
function writeDetachedTasksManifest(file, manifest) {
|
|
10006
|
+
if (manifest.tasks.length === 0) {
|
|
10007
|
+
rmSync(file, { force: true });
|
|
10008
|
+
return;
|
|
10009
|
+
}
|
|
10010
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
10011
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
10012
|
+
writeFileSync(tmp, JSON.stringify(manifest, null, 2));
|
|
10013
|
+
renameSync(tmp, file);
|
|
10014
|
+
}
|
|
10015
|
+
const isNum = (value) => typeof value === "number" && Number.isFinite(value);
|
|
10016
|
+
const isStr = (value) => typeof value === "string" && value.length > 0;
|
|
10017
|
+
const numOrNull = (value) => value === null || isNum(value);
|
|
10018
|
+
function takeDetachedTasksManifest(file, logDir) {
|
|
10019
|
+
let raw;
|
|
10020
|
+
try {
|
|
10021
|
+
raw = readFileSync(file, "utf8");
|
|
10022
|
+
} catch {
|
|
10023
|
+
return [];
|
|
10024
|
+
}
|
|
10025
|
+
rmSync(file, { force: true });
|
|
10026
|
+
let parsed;
|
|
10027
|
+
try {
|
|
10028
|
+
parsed = JSON.parse(raw);
|
|
10029
|
+
} catch {
|
|
10030
|
+
return [];
|
|
10031
|
+
}
|
|
10032
|
+
const record = parsed;
|
|
10033
|
+
if (record?.version !== 1 || !Array.isArray(record.tasks)) return [];
|
|
10034
|
+
const same = (a, b) => path.resolve(a) === path.resolve(b);
|
|
10035
|
+
return record.tasks.filter((task) => {
|
|
10036
|
+
const t = task;
|
|
10037
|
+
return !!t && isStr(t.taskId) && TASK_ID.test(t.taskId) && isStr(t.sessionId) && typeof t.command === "string" && (t.commandKey === null || isStr(t.commandKey)) && isStr(t.cwd) && isNum(t.pid) && Number.isInteger(t.pid) && t.pid > 0 && isRunId(t.runId) && isNum(t.startedAt) && (t.runStartedAt === void 0 || isNum(t.runStartedAt)) && numOrNull(t.yieldedAt) && numOrNull(t.deadlineAt) && isNum(t.outputOffset) && t.outputOffset >= 0 && isStr(t.outputFile) && same(t.outputFile, path.join(logDir, `run-${t.runId}.out`)) && isStr(t.exitCodeFile) && same(t.exitCodeFile, path.join(logDir, `run-${t.runId}.exit`)) && isStr(t.logPath) && same(t.logPath, path.join(logDir, `${t.taskId}.log`));
|
|
10038
|
+
});
|
|
10039
|
+
}
|
|
10040
|
+
function appendInterruptedTasks(file, records2) {
|
|
10041
|
+
if (records2.length === 0) return;
|
|
10042
|
+
const merged = /* @__PURE__ */ new Map();
|
|
10043
|
+
for (const record of [...readInterrupted(file, null), ...records2])
|
|
10044
|
+
merged.set(record.taskId, record);
|
|
10045
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
10046
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
10047
|
+
writeFileSync(tmp, JSON.stringify({ version: 1, tasks: [...merged.values()] }, null, 2));
|
|
10048
|
+
renameSync(tmp, file);
|
|
10049
|
+
}
|
|
10050
|
+
function takeInterruptedTasks(file, logDir) {
|
|
10051
|
+
const records2 = readInterrupted(file, logDir);
|
|
10052
|
+
rmSync(file, { force: true });
|
|
10053
|
+
return records2;
|
|
10054
|
+
}
|
|
10055
|
+
function readInterrupted(file, logDir) {
|
|
10056
|
+
let parsed;
|
|
10057
|
+
try {
|
|
10058
|
+
parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
10059
|
+
} catch {
|
|
10060
|
+
return [];
|
|
10061
|
+
}
|
|
10062
|
+
const tasks = parsed?.tasks;
|
|
10063
|
+
if (parsed.version !== 1 || !Array.isArray(tasks)) return [];
|
|
10064
|
+
return tasks.filter((task) => {
|
|
10065
|
+
const t = task;
|
|
10066
|
+
return !!t && isStr(t.taskId) && TASK_ID.test(t.taskId) && isStr(t.sessionId) && typeof t.command === "string" && isNum(t.startedAt) && isNum(t.stoppedAt) && typeof t.resident === "boolean" && isStr(t.logPath) && (logDir === null || path.resolve(t.logPath) === path.resolve(logDir, `${t.taskId}.log`));
|
|
10067
|
+
});
|
|
10068
|
+
}
|
|
9376
10069
|
class ForegroundDetachedError extends Error {
|
|
9377
10070
|
constructor(taskId, reason, output, owner) {
|
|
9378
10071
|
super(`Command moved to background task ${taskId}`);
|
|
@@ -9407,12 +10100,14 @@ class ForegroundYieldError extends Error {
|
|
|
9407
10100
|
}
|
|
9408
10101
|
const MAX_TIMER_MS = 2147483647;
|
|
9409
10102
|
class ForegroundCommand {
|
|
9410
|
-
constructor(owner, yieldMs) {
|
|
10103
|
+
constructor(owner, yieldMs, spawnDir) {
|
|
9411
10104
|
this.owner = owner;
|
|
9412
10105
|
this.yieldMs = yieldMs;
|
|
10106
|
+
this.spawnDir = spawnDir;
|
|
9413
10107
|
}
|
|
9414
10108
|
owner;
|
|
9415
10109
|
yieldMs;
|
|
10110
|
+
spawnDir;
|
|
9416
10111
|
running;
|
|
9417
10112
|
adoptError;
|
|
9418
10113
|
/** 本次调用被截止时间(模型显式 timeout)杀掉 */
|
|
@@ -9433,6 +10128,15 @@ class ForegroundCommand {
|
|
|
9433
10128
|
run(inner, command, cwd, options, timeoutMs, yieldMs) {
|
|
9434
10129
|
const { onData, signal, env, timeout } = options;
|
|
9435
10130
|
const controller = new AbortController();
|
|
10131
|
+
let detachable;
|
|
10132
|
+
if (this.spawnDir) {
|
|
10133
|
+
requestFileBackedRun(controller.signal, {
|
|
10134
|
+
dir: this.spawnDir,
|
|
10135
|
+
onSpawn: (run) => {
|
|
10136
|
+
detachable = run;
|
|
10137
|
+
}
|
|
10138
|
+
});
|
|
10139
|
+
}
|
|
9436
10140
|
let sink = onData;
|
|
9437
10141
|
let capture = true;
|
|
9438
10142
|
let output = "";
|
|
@@ -9445,13 +10149,18 @@ class ForegroundCommand {
|
|
|
9445
10149
|
env
|
|
9446
10150
|
}).then((result2) => result2.exitCode);
|
|
9447
10151
|
const proc = {
|
|
9448
|
-
|
|
10152
|
+
// 文件直写的进程按间隔跟读:取输出前先把已落盘的读进来
|
|
10153
|
+
output: () => {
|
|
10154
|
+
if (capture) detachable?.flush();
|
|
10155
|
+
return output;
|
|
10156
|
+
},
|
|
9449
10157
|
pipe: (next) => {
|
|
9450
10158
|
capture = false;
|
|
9451
10159
|
sink = next;
|
|
9452
10160
|
},
|
|
9453
10161
|
done,
|
|
9454
|
-
kill: () => controller.abort()
|
|
10162
|
+
kill: () => controller.abort(),
|
|
10163
|
+
detachable: () => detachable
|
|
9455
10164
|
};
|
|
9456
10165
|
return new Promise((resolve, reject) => {
|
|
9457
10166
|
let timedOut = false;
|
|
@@ -9657,9 +10366,10 @@ function normalizeSegment(segment) {
|
|
|
9657
10366
|
}
|
|
9658
10367
|
}
|
|
9659
10368
|
const INFO_FLAG = /(?:^|\s)(?:--help|-h|--version|-V)(?:\s|$)/;
|
|
10369
|
+
const FINITE_WATCH = /^gh\s+(?:pr\s+checks|run\s+watch)\b/;
|
|
9660
10370
|
function segmentClass(segment) {
|
|
9661
10371
|
const program = normalizeSegment(segment);
|
|
9662
|
-
if (!program || INFO_FLAG.test(program)) return "default";
|
|
10372
|
+
if (!program || INFO_FLAG.test(program) || FINITE_WATCH.test(program)) return "default";
|
|
9663
10373
|
if (SERVER_PATTERNS.some((pattern) => pattern.test(program))) return "server";
|
|
9664
10374
|
if (BUILD_PATTERNS.some((pattern) => pattern.test(program))) return "build";
|
|
9665
10375
|
return "default";
|
|
@@ -9912,11 +10622,182 @@ function classifyFailure(input) {
|
|
|
9912
10622
|
}
|
|
9913
10623
|
return verdict("none", true, "");
|
|
9914
10624
|
}
|
|
10625
|
+
const IDLE_QUIET_MS = 30 * 6e4;
|
|
10626
|
+
const KEEP_RECHECK_MS = 60 * 6e4;
|
|
10627
|
+
const IDLE_SAMPLE_INTERVAL_MS = 6e4;
|
|
10628
|
+
const IDLE_CPU_RATIO = 0.01;
|
|
10629
|
+
function judgeIdle(input) {
|
|
10630
|
+
const { sample } = input;
|
|
10631
|
+
if (input.now - input.lastOutputAt < IDLE_QUIET_MS) return false;
|
|
10632
|
+
if (sample?.cpuRatio === void 0 || sample.cpuRatio >= IDLE_CPU_RATIO) return false;
|
|
10633
|
+
if (!sample.sockets) return false;
|
|
10634
|
+
return sample.sockets.listening.length === 0 || sample.sockets.established === 0;
|
|
10635
|
+
}
|
|
10636
|
+
function keepSuppressesIdle(keep, now) {
|
|
10637
|
+
return keep !== void 0 && now < keep.at + KEEP_RECHECK_MS;
|
|
10638
|
+
}
|
|
10639
|
+
function cpuSeconds(text2) {
|
|
10640
|
+
const match = /^(?:(\d+)-)?(\d+(?::\d+){0,2}(?:\.\d+)?)$/.exec(text2);
|
|
10641
|
+
if (!match) return void 0;
|
|
10642
|
+
const parts = (match[2] ?? "").split(":").map(Number);
|
|
10643
|
+
if (parts.some((part) => !Number.isFinite(part))) return void 0;
|
|
10644
|
+
const seconds = parts.reduce((sum, part) => sum * 60 + part, 0);
|
|
10645
|
+
return Number(match[1] ?? 0) * 86400 + seconds;
|
|
10646
|
+
}
|
|
10647
|
+
function parsePsTable(stdout) {
|
|
10648
|
+
const table = /* @__PURE__ */ new Map();
|
|
10649
|
+
for (const line of stdout.split("\n")) {
|
|
10650
|
+
const [pid, ppid, time] = line.trim().split(/\s+/);
|
|
10651
|
+
const cpuSec = time === void 0 ? void 0 : cpuSeconds(time);
|
|
10652
|
+
if (!pid || !ppid || cpuSec === void 0 || !/^\d+$/.test(pid) || !/^\d+$/.test(ppid))
|
|
10653
|
+
continue;
|
|
10654
|
+
table.set(Number(pid), { ppid: Number(ppid), cpuSec });
|
|
10655
|
+
}
|
|
10656
|
+
return table;
|
|
10657
|
+
}
|
|
10658
|
+
function parseLsofTcp(stdout) {
|
|
10659
|
+
const result2 = /* @__PURE__ */ new Map();
|
|
10660
|
+
let current;
|
|
10661
|
+
let name = "";
|
|
10662
|
+
for (const line of stdout.split("\n")) {
|
|
10663
|
+
const tag = line[0];
|
|
10664
|
+
const value = line.slice(1);
|
|
10665
|
+
if (tag === "p") {
|
|
10666
|
+
const pid = Number(value);
|
|
10667
|
+
current = result2.get(pid) ?? { listening: [], established: 0 };
|
|
10668
|
+
result2.set(pid, current);
|
|
10669
|
+
} else if (tag === "f") name = "";
|
|
10670
|
+
else if (tag === "n") name = value;
|
|
10671
|
+
else if (tag === "T" && current) {
|
|
10672
|
+
if (value === "ST=LISTEN") {
|
|
10673
|
+
const port = Number(name.slice(name.lastIndexOf(":") + 1));
|
|
10674
|
+
if (Number.isInteger(port) && port > 0 && !current.listening.includes(port))
|
|
10675
|
+
current.listening.push(port);
|
|
10676
|
+
} else if (value === "ST=ESTABLISHED") current.established += 1;
|
|
10677
|
+
}
|
|
10678
|
+
}
|
|
10679
|
+
return result2;
|
|
10680
|
+
}
|
|
10681
|
+
const defaultExec = (file, args) => new Promise((resolve) => {
|
|
10682
|
+
execFile(file, args, { timeout: 1e4, maxBuffer: 8 * 1024 * 1024 }, (error, stdout) => {
|
|
10683
|
+
const code = error?.code;
|
|
10684
|
+
resolve({
|
|
10685
|
+
ok: !error,
|
|
10686
|
+
stdout: String(stdout ?? ""),
|
|
10687
|
+
...typeof code === "number" ? { code } : {}
|
|
10688
|
+
});
|
|
10689
|
+
});
|
|
10690
|
+
});
|
|
10691
|
+
function treeOf(table, root) {
|
|
10692
|
+
if (!table.has(root)) return [];
|
|
10693
|
+
const children = /* @__PURE__ */ new Map();
|
|
10694
|
+
for (const [pid, { ppid }] of table) children.set(ppid, [...children.get(ppid) ?? [], pid]);
|
|
10695
|
+
const tree = [root];
|
|
10696
|
+
for (let index = 0; index < tree.length; index++)
|
|
10697
|
+
for (const child of children.get(tree[index] ?? -1) ?? [])
|
|
10698
|
+
if (!tree.includes(child)) tree.push(child);
|
|
10699
|
+
return tree;
|
|
10700
|
+
}
|
|
10701
|
+
class ActivitySampler {
|
|
10702
|
+
constructor(exec = defaultExec) {
|
|
10703
|
+
this.exec = exec;
|
|
10704
|
+
}
|
|
10705
|
+
exec;
|
|
10706
|
+
baseline = /* @__PURE__ */ new Map();
|
|
10707
|
+
async sample(tasks, now) {
|
|
10708
|
+
const result2 = /* @__PURE__ */ new Map();
|
|
10709
|
+
for (const key of this.baseline.keys())
|
|
10710
|
+
if (!tasks.some((task) => task.key === key)) this.baseline.delete(key);
|
|
10711
|
+
if (tasks.length === 0) return result2;
|
|
10712
|
+
const ps = await this.exec("ps", ["-A", "-o", "pid=,ppid=,time="]);
|
|
10713
|
+
if (!ps.ok) return result2;
|
|
10714
|
+
const table = parsePsTable(ps.stdout);
|
|
10715
|
+
const trees = new Map(tasks.map((task) => [task.key, treeOf(table, task.pid)]));
|
|
10716
|
+
const pids = [...new Set([...trees.values()].flat())];
|
|
10717
|
+
if (pids.length === 0) return result2;
|
|
10718
|
+
const lsof = await this.exec("lsof", [
|
|
10719
|
+
"-nP",
|
|
10720
|
+
"-a",
|
|
10721
|
+
"-iTCP",
|
|
10722
|
+
"-p",
|
|
10723
|
+
pids.join(","),
|
|
10724
|
+
"-F",
|
|
10725
|
+
"pfnT",
|
|
10726
|
+
"-Ts"
|
|
10727
|
+
]);
|
|
10728
|
+
const sockets = lsof.ok || lsof.code === 1 && !lsof.stdout.trim() ? parseLsofTcp(lsof.stdout) : void 0;
|
|
10729
|
+
for (const task of tasks) {
|
|
10730
|
+
const tree = trees.get(task.key) ?? [];
|
|
10731
|
+
if (tree.length === 0) {
|
|
10732
|
+
this.baseline.delete(task.key);
|
|
10733
|
+
continue;
|
|
10734
|
+
}
|
|
10735
|
+
const cpuSec = tree.reduce((sum, pid) => sum + (table.get(pid)?.cpuSec ?? 0), 0);
|
|
10736
|
+
const base = this.baseline.get(task.key);
|
|
10737
|
+
this.baseline.set(task.key, { at: now, cpuSec });
|
|
10738
|
+
const sample = {};
|
|
10739
|
+
if (base && now > base.at)
|
|
10740
|
+
sample.cpuRatio = Math.max(0, cpuSec - base.cpuSec) / ((now - base.at) / 1e3);
|
|
10741
|
+
if (sockets) {
|
|
10742
|
+
const merged = { listening: [], established: 0 };
|
|
10743
|
+
for (const pid of tree) {
|
|
10744
|
+
const own = sockets.get(pid);
|
|
10745
|
+
if (!own) continue;
|
|
10746
|
+
for (const port of own.listening)
|
|
10747
|
+
if (!merged.listening.includes(port)) merged.listening.push(port);
|
|
10748
|
+
merged.established += own.established;
|
|
10749
|
+
}
|
|
10750
|
+
sample.sockets = merged;
|
|
10751
|
+
}
|
|
10752
|
+
result2.set(task.key, sample);
|
|
10753
|
+
}
|
|
10754
|
+
return result2;
|
|
10755
|
+
}
|
|
10756
|
+
}
|
|
10757
|
+
function ranText(ms) {
|
|
10758
|
+
const minutes = Math.max(0, Math.floor(ms / 6e4));
|
|
10759
|
+
return minutes < 60 ? `${minutes}m` : `${Math.floor(minutes / 60)}h ${minutes % 60}m`;
|
|
10760
|
+
}
|
|
10761
|
+
function taskLines(tasks, now) {
|
|
10762
|
+
return tasks.map(
|
|
10763
|
+
(task) => `- ${task.taskId}: ${task.command.replace(/\s+/g, " ").slice(0, 160)} (running ${ranText(now - task.startedAt)})`
|
|
10764
|
+
);
|
|
10765
|
+
}
|
|
10766
|
+
function settleChecklist(tasks, now) {
|
|
10767
|
+
const open2 = tasks.filter((task) => task.status === "running" && !task.keep);
|
|
10768
|
+
if (open2.length === 0) return void 0;
|
|
10769
|
+
return [
|
|
10770
|
+
`<${TASK_WRAP_UP_TAG}>`,
|
|
10771
|
+
"These background tasks are still running and you have not said what happens to them:",
|
|
10772
|
+
...taskLines(open2, now),
|
|
10773
|
+
"Call task_settle once for all of them: stop each one you no longer need, or keep it with a one-line reason the user will see. Do not leave them undeclared.",
|
|
10774
|
+
`</${TASK_WRAP_UP_TAG}>`
|
|
10775
|
+
].join("\n");
|
|
10776
|
+
}
|
|
10777
|
+
function awaitChecklist(tasks, now) {
|
|
10778
|
+
return [
|
|
10779
|
+
"These background tasks you started are still running:",
|
|
10780
|
+
...taskLines(tasks, now),
|
|
10781
|
+
"Your Run waits for them before it reports back. If you need their results, end your turn; each completion wakes you. Keep tasks that should run on after your report (such as servers) with task_settle keep, and stop the ones you no longer need."
|
|
10782
|
+
].join("\n");
|
|
10783
|
+
}
|
|
9915
10784
|
const MAX_BUFFER = 2e5;
|
|
9916
10785
|
const COMPLETION_OUTPUT_LIMIT = 4e3;
|
|
9917
10786
|
const HEAD_KEEP = Math.floor(COMPLETION_OUTPUT_LIMIT * 0.2);
|
|
9918
10787
|
const TASK_OUTPUT_LIMIT = 3e4;
|
|
9919
10788
|
const EMIT_INTERVAL_MS = 500;
|
|
10789
|
+
const RECOVER_TAIL_BYTES = 64 * 1024;
|
|
10790
|
+
function restartInterruptedNotice(record, tail) {
|
|
10791
|
+
const ranMin = Math.max(0, Math.round((record.stoppedAt - record.startedAt) / 6e4));
|
|
10792
|
+
const lines = [
|
|
10793
|
+
`Background task ${record.taskId} was terminated because the app restarted (status: interrupted-by-restart). It had run about ${ranMin} min.`,
|
|
10794
|
+
`Command: ${record.command}`,
|
|
10795
|
+
`Its output up to the restart is in ${record.logPath}${tail ? "; the last lines were:" : " (no output yet)."}`,
|
|
10796
|
+
...tail ? [tail] : [],
|
|
10797
|
+
record.resident ? "It was a long-running service. It was not restarted automatically; start it again only if you still need it." : "Its result is lost. If you still need it, run the command again; continue with any goal you were working on."
|
|
10798
|
+
];
|
|
10799
|
+
return lines.join("\n");
|
|
10800
|
+
}
|
|
9920
10801
|
const BACKGROUND_COMMAND_HOOKS = /* @__PURE__ */ Symbol("enso.background-command-hooks");
|
|
9921
10802
|
function attachBackgroundCommandHooks(definition, hooks) {
|
|
9922
10803
|
return Object.assign(definition, { [BACKGROUND_COMMAND_HOOKS]: hooks });
|
|
@@ -9932,19 +10813,27 @@ function detachedWaitNote(reason, subject) {
|
|
|
9932
10813
|
return reason === "steer" ? `Stopped waiting because the user sent a new message. The ${subject} keeps running and you will be notified automatically when it finishes — read and answer the user's message first.` : `The user chose to stop waiting. The ${subject} keeps running and you will be notified automatically when it finishes; do not wait for it again unless the user asks.`;
|
|
9933
10814
|
}
|
|
9934
10815
|
class BackgroundTaskManager {
|
|
9935
|
-
constructor(events, logDir, currentLimits = SHELL_LIMITS) {
|
|
10816
|
+
constructor(events, logDir, currentLimits = SHELL_LIMITS, sampler = new ActivitySampler()) {
|
|
9936
10817
|
this.events = events;
|
|
9937
10818
|
this.logDir = logDir;
|
|
9938
10819
|
this.currentLimits = currentLimits;
|
|
10820
|
+
this.sampler = sampler;
|
|
9939
10821
|
}
|
|
9940
10822
|
events;
|
|
9941
10823
|
logDir;
|
|
9942
10824
|
currentLimits;
|
|
10825
|
+
sampler;
|
|
9943
10826
|
tasks = /* @__PURE__ */ new Map();
|
|
9944
10827
|
/** sessionId → toolCallId → 在跑的前台命令(可移交后台)或阻塞等待(可提前结束) */
|
|
9945
10828
|
foreground = /* @__PURE__ */ new Map();
|
|
9946
10829
|
counter = 0;
|
|
9947
10830
|
timer = null;
|
|
10831
|
+
idleTimer = null;
|
|
10832
|
+
sampling = false;
|
|
10833
|
+
/** 任务日志与文件直写输出所在目录 */
|
|
10834
|
+
get outputDir() {
|
|
10835
|
+
return this.logDir;
|
|
10836
|
+
}
|
|
9948
10837
|
/** 当前生效的命令时限;全局 settings.shell 变更时由 setLimits 整体替换,执行路径每次现读 */
|
|
9949
10838
|
get limits() {
|
|
9950
10839
|
return this.currentLimits;
|
|
@@ -9954,6 +10843,36 @@ class BackgroundTaskManager {
|
|
|
9954
10843
|
}
|
|
9955
10844
|
start(sessionId, command, cwd, spawnOpts) {
|
|
9956
10845
|
const taskId = this.reserveId(sessionId);
|
|
10846
|
+
const run = spawnOpts?.detachable && !spawnOpts.file && process.platform !== "win32" ? spawnFileBacked({
|
|
10847
|
+
// 与 spawn(command, { shell: true }) 同一个 shell
|
|
10848
|
+
shell: "/bin/sh",
|
|
10849
|
+
args: ["-c"],
|
|
10850
|
+
command,
|
|
10851
|
+
cwd,
|
|
10852
|
+
env: spawnOpts.env,
|
|
10853
|
+
dir: this.logDir
|
|
10854
|
+
}) : void 0;
|
|
10855
|
+
if (run) {
|
|
10856
|
+
const task2 = this.register(sessionId, taskId, spawnOpts?.displayCommand ?? command, {
|
|
10857
|
+
details: spawnOpts?.details,
|
|
10858
|
+
finalize: spawnOpts?.finalize,
|
|
10859
|
+
kill: (signal) => run.kill(signal)
|
|
10860
|
+
});
|
|
10861
|
+
task2.run = run;
|
|
10862
|
+
task2.cwd = cwd;
|
|
10863
|
+
task2.commandKey = spawnOpts?.commandKey;
|
|
10864
|
+
run.sink((chunk) => this.append(task2, chunk));
|
|
10865
|
+
run.done.then(
|
|
10866
|
+
({ code, signal }) => this.exited(task2, code, signal),
|
|
10867
|
+
(error) => {
|
|
10868
|
+
task2.output += `
|
|
10869
|
+
[spawn error] ${error instanceof Error ? error.message : String(error)}`;
|
|
10870
|
+
if (task2.info.status === "running" && !task2.settling) void this.settle(task2, "failed");
|
|
10871
|
+
}
|
|
10872
|
+
);
|
|
10873
|
+
this.announce(task2);
|
|
10874
|
+
return taskId;
|
|
10875
|
+
}
|
|
9957
10876
|
const child = spawnBackground(command, cwd, spawnOpts);
|
|
9958
10877
|
const task = this.register(sessionId, taskId, spawnOpts?.displayCommand ?? command, {
|
|
9959
10878
|
details: spawnOpts?.details,
|
|
@@ -9980,6 +10899,11 @@ class BackgroundTaskManager {
|
|
|
9980
10899
|
kill: () => proc.kill()
|
|
9981
10900
|
});
|
|
9982
10901
|
task.yieldedAt = Date.now();
|
|
10902
|
+
task.run = proc.detachable?.();
|
|
10903
|
+
if (opts.cwd !== void 0) {
|
|
10904
|
+
task.cwd = opts.cwd;
|
|
10905
|
+
task.commandKey = commandKey(opts.command, opts.cwd);
|
|
10906
|
+
}
|
|
9983
10907
|
this.append(task, Buffer.from(proc.output()));
|
|
9984
10908
|
this.takeUnread(task);
|
|
9985
10909
|
proc.pipe((chunk) => this.append(task, chunk));
|
|
@@ -10074,25 +10998,37 @@ class BackgroundTaskManager {
|
|
|
10074
10998
|
register(sessionId, taskId, command, opts) {
|
|
10075
10999
|
const logPath = path.join(this.logDir, `${taskId}.log`);
|
|
10076
11000
|
let logStream = null;
|
|
11001
|
+
let logBytes = 0;
|
|
11002
|
+
let seed = "";
|
|
10077
11003
|
try {
|
|
10078
11004
|
mkdirSync(this.logDir, { recursive: true });
|
|
10079
|
-
|
|
11005
|
+
if (opts.appendLog) {
|
|
11006
|
+
try {
|
|
11007
|
+
logBytes = statSync(logPath).size;
|
|
11008
|
+
} catch {
|
|
11009
|
+
}
|
|
11010
|
+
seed = new StringDecoder("utf8").end(readFileTail(logPath, RECOVER_TAIL_BYTES));
|
|
11011
|
+
}
|
|
11012
|
+
logStream = createWriteStream(logPath, { flags: opts.appendLog ? "a" : "w" });
|
|
10080
11013
|
} catch {
|
|
10081
11014
|
}
|
|
10082
11015
|
const task = {
|
|
10083
11016
|
sessionId,
|
|
10084
11017
|
kill: opts.kill,
|
|
10085
|
-
output:
|
|
11018
|
+
output: seed,
|
|
10086
11019
|
droppedChars: 0,
|
|
10087
|
-
droppedMemBytes: 0,
|
|
10088
|
-
|
|
10089
|
-
|
|
11020
|
+
droppedMemBytes: Math.max(0, logBytes - Buffer.byteLength(seed)),
|
|
11021
|
+
// 上一代的输出模型已按它自己的游标读过/通知过,不再当作新输出重放
|
|
11022
|
+
readChars: seed.length,
|
|
11023
|
+
readBytes: Math.max(logBytes, Buffer.byteLength(seed)),
|
|
10090
11024
|
head: "",
|
|
10091
11025
|
dirty: false,
|
|
10092
11026
|
logPath,
|
|
10093
11027
|
logStream,
|
|
10094
|
-
logBytes
|
|
11028
|
+
logBytes,
|
|
10095
11029
|
logDroppedBytes: 0,
|
|
11030
|
+
outputBytes: logBytes,
|
|
11031
|
+
lastOutputAt: Date.now(),
|
|
10096
11032
|
decoder: new StringDecoder("utf8"),
|
|
10097
11033
|
consumed: false,
|
|
10098
11034
|
killedByUser: false,
|
|
@@ -10105,7 +11041,7 @@ class BackgroundTaskManager {
|
|
|
10105
11041
|
taskId,
|
|
10106
11042
|
command,
|
|
10107
11043
|
status: "running",
|
|
10108
|
-
tail:
|
|
11044
|
+
tail: seed.slice(-8e3),
|
|
10109
11045
|
startedAt: opts.startedAt ?? Date.now()
|
|
10110
11046
|
}
|
|
10111
11047
|
};
|
|
@@ -10114,6 +11050,12 @@ class BackgroundTaskManager {
|
|
|
10114
11050
|
}
|
|
10115
11051
|
append(task, chunk) {
|
|
10116
11052
|
if (chunk.length === 0) return;
|
|
11053
|
+
task.outputBytes += chunk.length;
|
|
11054
|
+
task.lastOutputAt = Date.now();
|
|
11055
|
+
if (task.info.idle) {
|
|
11056
|
+
delete task.info.idle;
|
|
11057
|
+
this.emitLevel(task.sessionId);
|
|
11058
|
+
}
|
|
10117
11059
|
this.writeLog(task, chunk);
|
|
10118
11060
|
const text2 = task.decoder.write(chunk);
|
|
10119
11061
|
if (!text2) return;
|
|
@@ -10178,9 +11120,98 @@ class BackgroundTaskManager {
|
|
|
10178
11120
|
void this.settle(task, code === 0 ? "done" : "failed", code ?? void 0);
|
|
10179
11121
|
}
|
|
10180
11122
|
announce(task) {
|
|
10181
|
-
this.events.onStarted(task.sessionId,
|
|
11123
|
+
this.events.onStarted(task.sessionId, this.infoOf(task));
|
|
10182
11124
|
this.emitLevel(task.sessionId);
|
|
10183
11125
|
this.ensureTimer();
|
|
11126
|
+
if (process.platform !== "win32") {
|
|
11127
|
+
this.idleTimer ??= setInterval(() => void this.sampleIdle(), IDLE_SAMPLE_INTERVAL_MS);
|
|
11128
|
+
this.idleTimer.unref?.();
|
|
11129
|
+
}
|
|
11130
|
+
}
|
|
11131
|
+
/**
|
|
11132
|
+
* 闲置采样:只看已安静接近阈值的任务(提前一个周期取 CPU 基线),一轮一次 ps + 一次 lsof。
|
|
11133
|
+
* 状态变了才发全量快照;保留未满 1 小时的不判,到点后仍闲置就撤掉保留、重新标闲置。
|
|
11134
|
+
*/
|
|
11135
|
+
async sampleIdle(now = Date.now()) {
|
|
11136
|
+
if (this.sampling) return;
|
|
11137
|
+
const running = [...this.tasks.values()].filter(
|
|
11138
|
+
(task) => task.info.status === "running" && !task.settling
|
|
11139
|
+
);
|
|
11140
|
+
if (running.length === 0) {
|
|
11141
|
+
if (this.idleTimer) clearInterval(this.idleTimer);
|
|
11142
|
+
this.idleTimer = null;
|
|
11143
|
+
return;
|
|
11144
|
+
}
|
|
11145
|
+
const candidates = running.flatMap((task) => {
|
|
11146
|
+
const pid = task.pid ?? task.run?.pid;
|
|
11147
|
+
return pid !== void 0 && !keepSuppressesIdle(task.info.keep, now + IDLE_SAMPLE_INTERVAL_MS) && now - task.lastOutputAt >= IDLE_QUIET_MS - IDLE_SAMPLE_INTERVAL_MS ? [{ key: task.info.taskId, pid }] : [];
|
|
11148
|
+
});
|
|
11149
|
+
this.sampling = true;
|
|
11150
|
+
let samples;
|
|
11151
|
+
try {
|
|
11152
|
+
samples = await this.sampler.sample(candidates, now);
|
|
11153
|
+
} catch {
|
|
11154
|
+
samples = /* @__PURE__ */ new Map();
|
|
11155
|
+
} finally {
|
|
11156
|
+
this.sampling = false;
|
|
11157
|
+
}
|
|
11158
|
+
const touched = /* @__PURE__ */ new Set();
|
|
11159
|
+
for (const task of running) {
|
|
11160
|
+
if (task.info.status !== "running") continue;
|
|
11161
|
+
const idle = !keepSuppressesIdle(task.info.keep, now) && judgeIdle({ now, lastOutputAt: task.lastOutputAt, sample: samples.get(task.info.taskId) });
|
|
11162
|
+
if (idle) {
|
|
11163
|
+
const ports = samples.get(task.info.taskId)?.sockets?.listening ?? [];
|
|
11164
|
+
const changed = !task.info.idle || task.info.idle.since !== task.lastOutputAt || task.info.idle.ports.join() !== ports.join() || task.info.keep !== void 0;
|
|
11165
|
+
task.info.idle = { since: task.lastOutputAt, ports };
|
|
11166
|
+
delete task.info.keep;
|
|
11167
|
+
if (changed) touched.add(task.sessionId);
|
|
11168
|
+
} else if (task.info.idle && samples.has(task.info.taskId)) {
|
|
11169
|
+
delete task.info.idle;
|
|
11170
|
+
touched.add(task.sessionId);
|
|
11171
|
+
}
|
|
11172
|
+
}
|
|
11173
|
+
for (const sessionId of touched) this.emitLevel(sessionId);
|
|
11174
|
+
}
|
|
11175
|
+
/** 留下运行(agent 表态或用户手动保留):清掉闲置标记,1 小时后重新检查 */
|
|
11176
|
+
keep(taskId, keep, now = Date.now()) {
|
|
11177
|
+
const task = this.tasks.get(taskId);
|
|
11178
|
+
if (task?.info.status !== "running") return false;
|
|
11179
|
+
const reason = keep.reason?.trim().slice(0, 200);
|
|
11180
|
+
task.info.keep = { by: keep.by, ...reason ? { reason } : {}, at: now };
|
|
11181
|
+
delete task.info.idle;
|
|
11182
|
+
this.emitLevel(task.sessionId);
|
|
11183
|
+
return true;
|
|
11184
|
+
}
|
|
11185
|
+
/** 取消保留:下一轮采样重新判定 */
|
|
11186
|
+
unkeep(taskId) {
|
|
11187
|
+
const task = this.tasks.get(taskId);
|
|
11188
|
+
if (!task?.info.keep) return false;
|
|
11189
|
+
delete task.info.keep;
|
|
11190
|
+
this.emitLevel(task.sessionId);
|
|
11191
|
+
return true;
|
|
11192
|
+
}
|
|
11193
|
+
/** 会话自己起的、还在跑、没表态(没保留、也没在停)的任务;子代理起的归子代理,不算在内 */
|
|
11194
|
+
undeclared(sessionId) {
|
|
11195
|
+
return [...this.tasks.values()].filter(
|
|
11196
|
+
(task) => task.info.status === "running" && !task.info.keep && !task.killedByUser && !task.stoppedByModel && task.sessionId === sessionId
|
|
11197
|
+
).map((task) => this.infoOf(task));
|
|
11198
|
+
}
|
|
11199
|
+
taskInfo(taskId) {
|
|
11200
|
+
const task = this.tasks.get(taskId);
|
|
11201
|
+
return task ? this.infoOf(task) : void 0;
|
|
11202
|
+
}
|
|
11203
|
+
infoOf(task) {
|
|
11204
|
+
return { ...task.info, tail: task.output.slice(-8e3), outputBytes: task.outputBytes };
|
|
11205
|
+
}
|
|
11206
|
+
/** 输出文件读不到时把原因写进输出:面板和 task_output 看到的是失败原因,不是「暂无输出」 */
|
|
11207
|
+
noteReadError(task) {
|
|
11208
|
+
const error = task.run?.readError() ?? void 0;
|
|
11209
|
+
if (!error || error === task.readError) return;
|
|
11210
|
+
task.readError = error;
|
|
11211
|
+
task.output += `
|
|
11212
|
+
[cannot read command output: ${error}]
|
|
11213
|
+
`;
|
|
11214
|
+
task.dirty = true;
|
|
10184
11215
|
}
|
|
10185
11216
|
pruneFinished() {
|
|
10186
11217
|
const touched = /* @__PURE__ */ new Set();
|
|
@@ -10217,11 +11248,23 @@ class BackgroundTaskManager {
|
|
|
10217
11248
|
const hadWaiters = task.waiters.length > 0;
|
|
10218
11249
|
if (hadWaiters) task.consumed = true;
|
|
10219
11250
|
for (const wake of task.waiters.splice(0)) wake();
|
|
10220
|
-
this.events.onOutput(
|
|
11251
|
+
this.events.onOutput(
|
|
11252
|
+
task.sessionId,
|
|
11253
|
+
task.info.taskId,
|
|
11254
|
+
task.info.tail,
|
|
11255
|
+
status,
|
|
11256
|
+
task.outputBytes
|
|
11257
|
+
);
|
|
10221
11258
|
this.events.onEnded(task.sessionId, task.info.taskId, status, exitCode);
|
|
10222
11259
|
this.emitLevel(task.sessionId);
|
|
10223
11260
|
if (!task.consumed) {
|
|
10224
|
-
|
|
11261
|
+
const text2 = task.restartNotice ?? this.completionText(task);
|
|
11262
|
+
if (task.recovered)
|
|
11263
|
+
this.events.onCompletionNotify(task.sessionId, text2, {
|
|
11264
|
+
durable: true,
|
|
11265
|
+
...task.restartResident ? { quiet: true } : {}
|
|
11266
|
+
});
|
|
11267
|
+
else this.events.onCompletionNotify(task.sessionId, text2);
|
|
10225
11268
|
}
|
|
10226
11269
|
}
|
|
10227
11270
|
async settle(task, status, exitCode) {
|
|
@@ -10260,10 +11303,17 @@ class BackgroundTaskManager {
|
|
|
10260
11303
|
let anyRunning = false;
|
|
10261
11304
|
for (const task of this.tasks.values()) {
|
|
10262
11305
|
if (task.info.status === "running") anyRunning = true;
|
|
11306
|
+
this.noteReadError(task);
|
|
10263
11307
|
if (!task.dirty) continue;
|
|
10264
11308
|
task.dirty = false;
|
|
10265
11309
|
task.info.tail = task.output.slice(-8e3);
|
|
10266
|
-
this.events.onOutput(
|
|
11310
|
+
this.events.onOutput(
|
|
11311
|
+
task.sessionId,
|
|
11312
|
+
task.info.taskId,
|
|
11313
|
+
task.info.tail,
|
|
11314
|
+
task.info.status,
|
|
11315
|
+
task.outputBytes
|
|
11316
|
+
);
|
|
10267
11317
|
}
|
|
10268
11318
|
if (!anyRunning && this.timer) {
|
|
10269
11319
|
clearInterval(this.timer);
|
|
@@ -10373,13 +11423,176 @@ class BackgroundTaskManager {
|
|
|
10373
11423
|
);
|
|
10374
11424
|
}
|
|
10375
11425
|
snapshot(sessionId) {
|
|
10376
|
-
return [...this.tasks.values()].filter((task) => task.sessionId === sessionId).map((task) => (
|
|
11426
|
+
return [...this.tasks.values()].filter((task) => task.sessionId === sessionId).map((task) => this.infoOf(task));
|
|
11427
|
+
}
|
|
11428
|
+
/** 名下还有任务(含已结束、尚未清理的)的会话 */
|
|
11429
|
+
sessionIds() {
|
|
11430
|
+
return [...new Set([...this.tasks.values()].map((task) => task.sessionId))];
|
|
11431
|
+
}
|
|
11432
|
+
/**
|
|
11433
|
+
* 前台命令转后台(adopt,有 yieldedAt)后还没结束的任务:优雅重启把它们当作在跑的工具。
|
|
11434
|
+
* exceptDetachable:重启会把能脱离的交给下一代,只剩脱离不了的需要等
|
|
11435
|
+
*/
|
|
11436
|
+
runningYielded(sessionId, opts) {
|
|
11437
|
+
return [...this.tasks.values()].filter(
|
|
11438
|
+
(task) => task.sessionId === sessionId && task.yieldedAt !== void 0 && task.info.status === "running" && !(opts?.exceptDetachable && task.run)
|
|
11439
|
+
).map((task) => task.info.taskId);
|
|
10377
11440
|
}
|
|
10378
11441
|
stopAll() {
|
|
10379
11442
|
for (const task of this.tasks.values()) {
|
|
10380
11443
|
if (task.info.status === "running") this.stop(task.info.taskId, true);
|
|
10381
11444
|
}
|
|
10382
11445
|
}
|
|
11446
|
+
/**
|
|
11447
|
+
* worker 收尾前:还在跑、即将被停掉的任务(含空闲会话的)。记进台账后调 handOverNotices,
|
|
11448
|
+
* 本代不再发完成通知,由下一代在任务表留下「因重启中断」并通知一次。子代理的任务记到根会话:子会话不随换代恢复。
|
|
11449
|
+
*/
|
|
11450
|
+
interruptedOnShutdown(now = Date.now()) {
|
|
11451
|
+
const records2 = [];
|
|
11452
|
+
for (const task of this.tasks.values()) {
|
|
11453
|
+
if (task.info.status !== "running" || task.settling) continue;
|
|
11454
|
+
records2.push({
|
|
11455
|
+
taskId: task.info.taskId,
|
|
11456
|
+
sessionId: task.sessionId.split("::")[0] ?? task.sessionId,
|
|
11457
|
+
command: commandSummary(task.info.command),
|
|
11458
|
+
startedAt: task.info.startedAt,
|
|
11459
|
+
stoppedAt: now,
|
|
11460
|
+
logPath: task.logPath,
|
|
11461
|
+
resident: task.info.keep !== void 0 || classifyCommand(task.info.command).class === "server"
|
|
11462
|
+
});
|
|
11463
|
+
}
|
|
11464
|
+
return records2;
|
|
11465
|
+
}
|
|
11466
|
+
handOverNotices(taskIds) {
|
|
11467
|
+
for (const taskId of taskIds) {
|
|
11468
|
+
const task = this.tasks.get(taskId);
|
|
11469
|
+
if (task) task.consumed = true;
|
|
11470
|
+
}
|
|
11471
|
+
}
|
|
11472
|
+
/** 新一代:上一代收尾时停掉的任务按原 taskId 留在任务表(failed + interrupted),通知所属会话一次 */
|
|
11473
|
+
recoverInterrupted(records2) {
|
|
11474
|
+
for (const record of records2) {
|
|
11475
|
+
if (this.tasks.has(record.taskId)) continue;
|
|
11476
|
+
const task = this.register(record.sessionId, record.taskId, record.command, {
|
|
11477
|
+
startedAt: record.startedAt,
|
|
11478
|
+
kill: () => {
|
|
11479
|
+
},
|
|
11480
|
+
appendLog: true
|
|
11481
|
+
});
|
|
11482
|
+
task.recovered = true;
|
|
11483
|
+
task.info.interrupted = "restart";
|
|
11484
|
+
task.restartResident = record.resident;
|
|
11485
|
+
task.restartNotice = restartInterruptedNotice(
|
|
11486
|
+
record,
|
|
11487
|
+
stripVTControlCharacters(task.output.slice(-1500)).trim()
|
|
11488
|
+
);
|
|
11489
|
+
this.announce(task);
|
|
11490
|
+
this.finish(task, "failed");
|
|
11491
|
+
}
|
|
11492
|
+
}
|
|
11493
|
+
/**
|
|
11494
|
+
* 重启前把能脱离的在跑任务交出去:读完已有输出、停止跟读,进程不动,从本代移除,返回恢复清单条目。
|
|
11495
|
+
* 脱离不了的(管道进程)留在原处,worker 收尾时照常停掉。
|
|
11496
|
+
*/
|
|
11497
|
+
detachForRestart() {
|
|
11498
|
+
const records2 = [];
|
|
11499
|
+
for (const task of [...this.tasks.values()]) {
|
|
11500
|
+
const run = task.run;
|
|
11501
|
+
if (!run || task.info.status !== "running" || task.settling) continue;
|
|
11502
|
+
const outputOffset = run.release();
|
|
11503
|
+
if (task.deadlineTimer) clearTimeout(task.deadlineTimer);
|
|
11504
|
+
task.logStream?.end();
|
|
11505
|
+
this.tasks.delete(task.info.taskId);
|
|
11506
|
+
records2.push({
|
|
11507
|
+
taskId: task.info.taskId,
|
|
11508
|
+
sessionId: task.sessionId,
|
|
11509
|
+
command: commandSummary(task.info.command),
|
|
11510
|
+
commandKey: task.commandKey ?? null,
|
|
11511
|
+
cwd: task.cwd ?? run.cwd,
|
|
11512
|
+
pid: run.pid,
|
|
11513
|
+
runId: run.runId,
|
|
11514
|
+
startedAt: task.info.startedAt,
|
|
11515
|
+
runStartedAt: run.startedAt,
|
|
11516
|
+
yieldedAt: task.yieldedAt ?? null,
|
|
11517
|
+
deadlineAt: task.info.deadlineAt ?? null,
|
|
11518
|
+
outputFile: run.outputFile,
|
|
11519
|
+
outputOffset,
|
|
11520
|
+
exitCodeFile: run.exitFile,
|
|
11521
|
+
logPath: task.logPath
|
|
11522
|
+
});
|
|
11523
|
+
}
|
|
11524
|
+
return records2;
|
|
11525
|
+
}
|
|
11526
|
+
/**
|
|
11527
|
+
* 冷启动认回上一代交出的任务,同一个 taskId 重新登记:
|
|
11528
|
+
* - pid 在、认得出是原进程(命令行 / 环境变量带着 runId,或启动时间对得上):running,按偏移接着读输出文件;
|
|
11529
|
+
* - pid 不在:读完剩余输出,按退出码文件标 done / failed,照常发完成通知;
|
|
11530
|
+
* - pid 在但对不上(被复用):不认、不发任何信号,标 failed 并说明找不到原进程。
|
|
11531
|
+
* 返回处理过的 runId(孤儿清理跳过它们)。
|
|
11532
|
+
*/
|
|
11533
|
+
recover(records2, probe = defaultRunProbe) {
|
|
11534
|
+
const handled = /* @__PURE__ */ new Set();
|
|
11535
|
+
for (const record of records2) {
|
|
11536
|
+
if (this.tasks.has(record.taskId)) continue;
|
|
11537
|
+
handled.add(record.runId);
|
|
11538
|
+
const files = runFiles(this.logDir, record.runId);
|
|
11539
|
+
const identity = { runId: record.runId, startedAt: record.runStartedAt ?? record.startedAt };
|
|
11540
|
+
const state = !probe.alive(record.pid) ? "gone" : probe.matches(record.pid, identity) ? "alive" : "reused";
|
|
11541
|
+
const task = this.register(record.sessionId, record.taskId, record.command, {
|
|
11542
|
+
startedAt: record.startedAt,
|
|
11543
|
+
kill: () => {
|
|
11544
|
+
},
|
|
11545
|
+
appendLog: true
|
|
11546
|
+
});
|
|
11547
|
+
task.recovered = true;
|
|
11548
|
+
task.cwd = record.cwd;
|
|
11549
|
+
if (record.commandKey) task.commandKey = record.commandKey;
|
|
11550
|
+
if (record.yieldedAt !== null) task.yieldedAt = record.yieldedAt;
|
|
11551
|
+
if (state === "alive") {
|
|
11552
|
+
const run = attachFileBacked(
|
|
11553
|
+
this.logDir,
|
|
11554
|
+
{
|
|
11555
|
+
runId: record.runId,
|
|
11556
|
+
pid: record.pid,
|
|
11557
|
+
startedAt: identity.startedAt,
|
|
11558
|
+
cwd: record.cwd,
|
|
11559
|
+
outputFile: files.outputFile,
|
|
11560
|
+
exitFile: files.exitFile
|
|
11561
|
+
},
|
|
11562
|
+
record.outputOffset,
|
|
11563
|
+
probe
|
|
11564
|
+
);
|
|
11565
|
+
task.run = run;
|
|
11566
|
+
task.kill = (signal) => run.kill(signal);
|
|
11567
|
+
run.sink((chunk) => this.append(task, chunk));
|
|
11568
|
+
void run.done.then(({ code: code2 }) => {
|
|
11569
|
+
if (code2 === null) task.output += "\n[process ended; exit code unavailable]";
|
|
11570
|
+
this.exited(task, code2, null);
|
|
11571
|
+
});
|
|
11572
|
+
this.announce(task);
|
|
11573
|
+
if (record.deadlineAt !== null)
|
|
11574
|
+
this.armDeadline(task, (record.deadlineAt - Date.now()) / 1e3);
|
|
11575
|
+
continue;
|
|
11576
|
+
}
|
|
11577
|
+
this.append(task, readRunOutput(files.outputFile, record.outputOffset));
|
|
11578
|
+
const code = state === "gone" ? readExitCode(files.exitFile) : null;
|
|
11579
|
+
removeRunFiles(this.logDir, record.runId);
|
|
11580
|
+
task.output += state === "gone" ? code === null ? "\n[process ended while the app was restarting; exit code unavailable]" : "" : `
|
|
11581
|
+
[original process not found after restart: pid ${record.pid} now belongs to another process; the task was not reattached and nothing was killed]`;
|
|
11582
|
+
this.announce(task);
|
|
11583
|
+
this.exited(task, code, null);
|
|
11584
|
+
}
|
|
11585
|
+
return handled;
|
|
11586
|
+
}
|
|
11587
|
+
/** 认回的、同一会话树里还在跑的同一命令(同 cwd);没有返回 undefined */
|
|
11588
|
+
recoveredDuplicate(sessionId, key) {
|
|
11589
|
+
const root = sessionId.split("::")[0] ?? sessionId;
|
|
11590
|
+
for (const task of this.tasks.values()) {
|
|
11591
|
+
if (task.recovered && task.info.status === "running" && !task.settling && task.commandKey === key && inSessionTree(task.sessionId, root))
|
|
11592
|
+
return task.info.taskId;
|
|
11593
|
+
}
|
|
11594
|
+
return void 0;
|
|
11595
|
+
}
|
|
10383
11596
|
}
|
|
10384
11597
|
const QUOTED_SEGMENT = /'[^']*'|"(?:[^"\\]|\\.)*"/g;
|
|
10385
11598
|
const HEREDOC_BODY = /<<-?\s*(['"]?)([A-Za-z_]\w*)\1[ \t]*\n[\s\S]*?\n[ \t]*\2[ \t]*(?=\n|$)/g;
|
|
@@ -10414,12 +11627,17 @@ function shellSleepHint(command) {
|
|
|
10414
11627
|
return SHELL_SLEEP_HINT;
|
|
10415
11628
|
}
|
|
10416
11629
|
const TIMEOUT_HINT_MIN_SEC = SHELL_LIMITS.yieldDefaultMs / 1e3;
|
|
10417
|
-
|
|
11630
|
+
const TIMEOUT_HINT_SLOW_MS = SHELL_LIMITS.yieldDefaultMs * 2 / 3;
|
|
11631
|
+
function shellTimeoutHint(timeoutSec, run) {
|
|
10418
11632
|
if (timeoutSec === void 0 || timeoutSec < TIMEOUT_HINT_MIN_SEC) return "";
|
|
11633
|
+
if (!run.detached && run.elapsedMs < TIMEOUT_HINT_SLOW_MS) return "";
|
|
10419
11634
|
return SHELL_TIMEOUT_HINT;
|
|
10420
11635
|
}
|
|
10421
|
-
function withCommandHints(result2, command,
|
|
10422
|
-
const hint = [shellReadHint(command), shellSleepHint(command),
|
|
11636
|
+
function withCommandHints(result2, command, timeoutHint) {
|
|
11637
|
+
const hint = [shellReadHint(command), shellSleepHint(command), timeoutHint].filter(Boolean).join("\n");
|
|
11638
|
+
return prependHint(result2, hint);
|
|
11639
|
+
}
|
|
11640
|
+
function prependHint(result2, hint) {
|
|
10423
11641
|
if (!hint) return result2;
|
|
10424
11642
|
const content = result2.content;
|
|
10425
11643
|
if (!Array.isArray(content)) return result2;
|
|
@@ -10447,15 +11665,6 @@ function spawnBackground(command, cwd, spawnOpts) {
|
|
|
10447
11665
|
}
|
|
10448
11666
|
return spawn(command, { shell: true, cwd, env, ...mode, stdio });
|
|
10449
11667
|
}
|
|
10450
|
-
function processAlive(pid) {
|
|
10451
|
-
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
10452
|
-
try {
|
|
10453
|
-
process.kill(pid, 0);
|
|
10454
|
-
return true;
|
|
10455
|
-
} catch (error) {
|
|
10456
|
-
return error.code !== "ESRCH";
|
|
10457
|
-
}
|
|
10458
|
-
}
|
|
10459
11668
|
function resolveBackgroundLaunch(toolName2, command, cwd, transform, resolvePowerShell) {
|
|
10460
11669
|
if (transform) return transform(command, cwd);
|
|
10461
11670
|
if (toolName2 === "powershell") {
|
|
@@ -10464,7 +11673,7 @@ function resolveBackgroundLaunch(toolName2, command, cwd, transform, resolvePowe
|
|
|
10464
11673
|
}
|
|
10465
11674
|
return { command, cwd };
|
|
10466
11675
|
}
|
|
10467
|
-
const asRecord$
|
|
11676
|
+
const asRecord$2 = (params) => params && typeof params === "object" && !Array.isArray(params) ? params : {};
|
|
10468
11677
|
function explicitTimeoutSec(record) {
|
|
10469
11678
|
return typeof record.timeout === "number" && Number.isFinite(record.timeout) && record.timeout > 0 ? record.timeout : void 0;
|
|
10470
11679
|
}
|
|
@@ -10509,7 +11718,7 @@ function detachedResult(error, context) {
|
|
|
10509
11718
|
};
|
|
10510
11719
|
}
|
|
10511
11720
|
function exitCodeOf(result2, text2) {
|
|
10512
|
-
const structured = asRecord$
|
|
11721
|
+
const structured = asRecord$2(result2.structuredContent).exit_code;
|
|
10513
11722
|
if (typeof structured === "number" && Number.isInteger(structured)) return structured;
|
|
10514
11723
|
const match = /Command exited with code (\d+)\s*$/.exec(text2);
|
|
10515
11724
|
return match ? Number(match[1]) : void 0;
|
|
@@ -10529,14 +11738,14 @@ ${failureLine(verdict2)}`;
|
|
|
10529
11738
|
return {
|
|
10530
11739
|
...result2,
|
|
10531
11740
|
details: {
|
|
10532
|
-
...asRecord$
|
|
11741
|
+
...asRecord$2(record.details),
|
|
10533
11742
|
shellFailure: { kind: verdict2.kind, retryable: verdict2.retryable, exitCode }
|
|
10534
11743
|
}
|
|
10535
11744
|
};
|
|
10536
11745
|
}
|
|
10537
11746
|
function foregroundCommandTimeoutMs(toolName2, args, limits = SHELL_LIMITS) {
|
|
10538
11747
|
if (toolName2 !== "bash" && toolName2 !== "powershell") return void 0;
|
|
10539
|
-
const record = asRecord$
|
|
11748
|
+
const record = asRecord$2(args);
|
|
10540
11749
|
if (record.background === true) return void 0;
|
|
10541
11750
|
const command = typeof record.command === "string" ? record.command : "";
|
|
10542
11751
|
const yieldMs = classifyCommand(command, limits).yieldMs;
|
|
@@ -10575,6 +11784,18 @@ function withBackground(definition, manager, sessionId, cwd, transform, foregrou
|
|
|
10575
11784
|
],
|
|
10576
11785
|
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
10577
11786
|
const record = params;
|
|
11787
|
+
const duplicate = typeof record.command === "string" && !transform ? manager.recoveredDuplicate(sessionId, commandKey(record.command, cwd)) : void 0;
|
|
11788
|
+
if (duplicate) {
|
|
11789
|
+
return {
|
|
11790
|
+
content: [
|
|
11791
|
+
{
|
|
11792
|
+
type: "text",
|
|
11793
|
+
text: `Not started: this command is already running as background task ${duplicate}. It kept running through the app restart and was reattached, so starting it again would collide with it (ports, files). task_output("${duplicate}") shows its output; task_stop("${duplicate}") stops it if a fresh run is really needed.`
|
|
11794
|
+
}
|
|
11795
|
+
],
|
|
11796
|
+
details: { backgroundTaskId: duplicate }
|
|
11797
|
+
};
|
|
11798
|
+
}
|
|
10578
11799
|
if (record.background && typeof record.command === "string") {
|
|
10579
11800
|
const hooks = definition[BACKGROUND_COMMAND_HOOKS];
|
|
10580
11801
|
const prepared = hooks ? await hooks.prepare(toolCallId, record.command, signal) : { command: record.command };
|
|
@@ -10592,7 +11813,9 @@ function withBackground(definition, manager, sessionId, cwd, transform, foregrou
|
|
|
10592
11813
|
...transform ? {} : {
|
|
10593
11814
|
env: hardenedEnv(process.env, {
|
|
10594
11815
|
shell: definition.name === "powershell" ? "powershell" : "bash"
|
|
10595
|
-
})
|
|
11816
|
+
}),
|
|
11817
|
+
detachable: definition.name === "bash",
|
|
11818
|
+
commandKey: commandKey(record.command, cwd)
|
|
10596
11819
|
}
|
|
10597
11820
|
});
|
|
10598
11821
|
} catch (error) {
|
|
@@ -10625,31 +11848,37 @@ function withBackground(definition, manager, sessionId, cwd, transform, foregrou
|
|
|
10625
11848
|
const callSignal = signal ? AbortSignal.any([signal]) : new AbortController().signal;
|
|
10626
11849
|
const startedAt = Date.now();
|
|
10627
11850
|
const policy = classifyCommand(command, manager.limits);
|
|
10628
|
-
const deadlineSec = explicitTimeoutSec(asRecord$
|
|
11851
|
+
const deadlineSec = explicitTimeoutSec(asRecord$2(params));
|
|
10629
11852
|
const foreground = new ForegroundCommand(
|
|
10630
11853
|
{
|
|
10631
11854
|
adopt: (proc) => manager.adopt(sessionId, proc, {
|
|
10632
11855
|
command,
|
|
10633
11856
|
startedAt,
|
|
11857
|
+
cwd,
|
|
10634
11858
|
...deadlineSec === void 0 ? {} : { deadlineSec: Math.max(0, deadlineSec - (Date.now() - startedAt) / 1e3) }
|
|
10635
11859
|
}),
|
|
10636
11860
|
attachFinalize: (taskId, details, finalize) => manager.attachFinalize(taskId, details, finalize)
|
|
10637
11861
|
},
|
|
10638
|
-
policy.yieldMs
|
|
11862
|
+
policy.yieldMs,
|
|
11863
|
+
transform ? void 0 : manager.outputDir
|
|
10639
11864
|
);
|
|
10640
11865
|
bindForegroundCommand(callSignal, foreground);
|
|
10641
11866
|
const untrack = manager.trackForeground(foregroundSessionId, toolCallId, foreground);
|
|
10642
11867
|
try {
|
|
10643
11868
|
const result2 = await definition.execute(toolCallId, params, callSignal, onUpdate, ctx);
|
|
10644
|
-
|
|
11869
|
+
const timeoutHint = shellTimeoutHint(deadlineSec, { elapsedMs: Date.now() - startedAt });
|
|
11870
|
+
return withCommandHints(withFailureNote(result2), command, timeoutHint);
|
|
10645
11871
|
} catch (error) {
|
|
10646
11872
|
if (error instanceof ForegroundDetachedError) {
|
|
10647
|
-
return
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
11873
|
+
return prependHint(
|
|
11874
|
+
detachedResult(error, {
|
|
11875
|
+
commandClass: policy.class,
|
|
11876
|
+
startedAt,
|
|
11877
|
+
logPath: manager.logPathOf(error.taskId) ?? "",
|
|
11878
|
+
waitCapSec: yieldSec(manager.limits.taskWaitMaxMs)
|
|
11879
|
+
}),
|
|
11880
|
+
shellTimeoutHint(deadlineSec, { elapsedMs: Date.now() - startedAt, detached: true })
|
|
11881
|
+
);
|
|
10653
11882
|
}
|
|
10654
11883
|
if (error instanceof ForegroundYieldError) {
|
|
10655
11884
|
return {
|
|
@@ -10765,9 +11994,85 @@ ${shown.text}` : ""}${hint}${failure}`
|
|
|
10765
11994
|
details: void 0
|
|
10766
11995
|
};
|
|
10767
11996
|
}
|
|
11997
|
+
},
|
|
11998
|
+
{
|
|
11999
|
+
name: "task_settle",
|
|
12000
|
+
label: "Task settle",
|
|
12001
|
+
description: "Declare what happens to background tasks that are still running when you wrap up, all in one call: stop the ones you no longer need, keep the rest with a one-line reason the user will see. Kept tasks are not flagged as idle for an hour.",
|
|
12002
|
+
promptSnippet: "task_settle: when wrapping up, stop or keep (with a reason) each still-running background task",
|
|
12003
|
+
parameters: {
|
|
12004
|
+
type: "object",
|
|
12005
|
+
properties: {
|
|
12006
|
+
tasks: {
|
|
12007
|
+
type: "array",
|
|
12008
|
+
description: "One entry per running background task",
|
|
12009
|
+
items: {
|
|
12010
|
+
type: "object",
|
|
12011
|
+
properties: {
|
|
12012
|
+
taskId: { type: "string", description: "Background task id" },
|
|
12013
|
+
action: { type: "string", enum: ["stop", "keep"], description: "stop or keep" },
|
|
12014
|
+
reason: {
|
|
12015
|
+
type: "string",
|
|
12016
|
+
description: "One short sentence: why it is no longer needed, or why it must keep running"
|
|
12017
|
+
}
|
|
12018
|
+
},
|
|
12019
|
+
required: ["taskId", "action", "reason"]
|
|
12020
|
+
}
|
|
12021
|
+
}
|
|
12022
|
+
},
|
|
12023
|
+
required: ["tasks"]
|
|
12024
|
+
},
|
|
12025
|
+
prepareArguments: (args) => normalizeSettleArgs(args),
|
|
12026
|
+
async execute(_id, params) {
|
|
12027
|
+
const entries = settleEntries(params.tasks);
|
|
12028
|
+
if (entries.length === 0)
|
|
12029
|
+
throw new Error("tasks must list at least one { taskId, action, reason }");
|
|
12030
|
+
const settled = entries.map((entry) => {
|
|
12031
|
+
const command = owned(entry.taskId) ? manager.taskInfo(entry.taskId)?.command : void 0;
|
|
12032
|
+
const ok = owned(entry.taskId) && (entry.action === "stop" ? manager.stop(entry.taskId) : manager.keep(entry.taskId, { by: "agent", reason: entry.reason }));
|
|
12033
|
+
return { ...entry, ...command ? { command } : {}, ok };
|
|
12034
|
+
});
|
|
12035
|
+
const stillOpen = sessionId ? manager.undeclared(sessionId).map((task) => task.taskId) : [];
|
|
12036
|
+
return {
|
|
12037
|
+
content: [
|
|
12038
|
+
{
|
|
12039
|
+
type: "text",
|
|
12040
|
+
text: JSON.stringify({
|
|
12041
|
+
settled,
|
|
12042
|
+
...stillOpen.length > 0 ? { stillUndeclared: stillOpen } : {}
|
|
12043
|
+
})
|
|
12044
|
+
}
|
|
12045
|
+
],
|
|
12046
|
+
details: void 0
|
|
12047
|
+
};
|
|
12048
|
+
}
|
|
10768
12049
|
}
|
|
10769
12050
|
];
|
|
10770
12051
|
}
|
|
12052
|
+
function normalizeSettleArgs(args) {
|
|
12053
|
+
if (!args || typeof args !== "object") return args;
|
|
12054
|
+
let tasks = args.tasks;
|
|
12055
|
+
if (typeof tasks === "string") {
|
|
12056
|
+
try {
|
|
12057
|
+
tasks = JSON.parse(tasks);
|
|
12058
|
+
} catch {
|
|
12059
|
+
}
|
|
12060
|
+
}
|
|
12061
|
+
if (tasks && typeof tasks === "object" && !Array.isArray(tasks)) tasks = [tasks];
|
|
12062
|
+
return { ...args, tasks };
|
|
12063
|
+
}
|
|
12064
|
+
function settleEntries(value) {
|
|
12065
|
+
if (!Array.isArray(value)) return [];
|
|
12066
|
+
return value.flatMap((item) => {
|
|
12067
|
+
if (!item || typeof item !== "object") return [];
|
|
12068
|
+
const { taskId, action, reason } = item;
|
|
12069
|
+
if (typeof taskId !== "string" || !taskId || action !== "stop" && action !== "keep")
|
|
12070
|
+
return [];
|
|
12071
|
+
return [
|
|
12072
|
+
{ taskId, action, reason: typeof reason === "string" ? reason.trim().slice(0, 200) : "" }
|
|
12073
|
+
];
|
|
12074
|
+
});
|
|
12075
|
+
}
|
|
10771
12076
|
const CHILD_THINKING_LEVELS = ["off", ...THINKING_LEVELS$1];
|
|
10772
12077
|
function isChildThinkingLevel(value) {
|
|
10773
12078
|
return CHILD_THINKING_LEVELS.includes(value);
|
|
@@ -10799,22 +12104,34 @@ function thinkingToOverride(thinking) {
|
|
|
10799
12104
|
if (thinking === "off") return { reasoning: "off" };
|
|
10800
12105
|
return { reasoning: "on", thinkingLevel: thinking };
|
|
10801
12106
|
}
|
|
10802
|
-
function pickChildReasoningOverride(dispatched, agentTypeOverride
|
|
12107
|
+
function pickChildReasoningOverride(dispatched, agentTypeOverride) {
|
|
10803
12108
|
if (dispatched) return thinkingToOverride(dispatched);
|
|
10804
|
-
const reasoning = agentTypeOverride?.reasoning
|
|
10805
|
-
const thinkingLevel = agentTypeOverride?.thinkingLevel
|
|
12109
|
+
const reasoning = agentTypeOverride?.reasoning;
|
|
12110
|
+
const thinkingLevel = agentTypeOverride?.thinkingLevel;
|
|
10806
12111
|
return {
|
|
10807
12112
|
...reasoning ? { reasoning } : {},
|
|
10808
12113
|
...thinkingLevel ? { thinkingLevel } : {}
|
|
10809
12114
|
};
|
|
10810
12115
|
}
|
|
10811
|
-
function resolveChildReasoning(override, parentEnabled, parentLevel) {
|
|
10812
|
-
const enabled = override?.reasoning ? override.reasoning === "on" : parentEnabled;
|
|
12116
|
+
function resolveChildReasoning(override, parentEnabled, parentLevel, modelOverride) {
|
|
12117
|
+
const enabled = override?.reasoning ? override.reasoning === "on" : parentEnabled || modelOverride?.reasoning === "on";
|
|
12118
|
+
if (!enabled) return { enabled, level: "off" };
|
|
10813
12119
|
return {
|
|
10814
12120
|
enabled,
|
|
10815
|
-
level:
|
|
12121
|
+
level: override?.thinkingLevel ?? (parentEnabled ? parentLevel : void 0) ?? modelOverride?.thinkingLevel ?? "medium"
|
|
10816
12122
|
};
|
|
10817
12123
|
}
|
|
12124
|
+
function fitChildReasoningToModel(decision, model) {
|
|
12125
|
+
if (!decision.enabled || decision.level === "off" || model.reasoning === false) {
|
|
12126
|
+
return { enabled: false, level: "off" };
|
|
12127
|
+
}
|
|
12128
|
+
if (!model.thinkingLevelMap) return decision;
|
|
12129
|
+
const supported = supportedProjectThinkingLevels({
|
|
12130
|
+
reasoning: true,
|
|
12131
|
+
thinkingLevelMap: model.thinkingLevelMap
|
|
12132
|
+
});
|
|
12133
|
+
return { enabled: true, level: clampProjectThinkingLevel(decision.level, supported) };
|
|
12134
|
+
}
|
|
10818
12135
|
const MAX_TOOL_NAME_LENGTH = 64;
|
|
10819
12136
|
const shortHash = (value) => createHash("sha256").update(value).digest("hex").slice(0, 8);
|
|
10820
12137
|
const serverSlug = (serverName) => serverName.replace(/[^A-Za-z0-9_]+/g, "_").replace(/^_+|_+$/g, "") || `server_${shortHash(serverName)}`;
|
|
@@ -10890,6 +12207,7 @@ const CODEMODE_FORBIDDEN_TOOLS = /* @__PURE__ */ new Set([
|
|
|
10890
12207
|
"todo",
|
|
10891
12208
|
"task_output",
|
|
10892
12209
|
"task_stop",
|
|
12210
|
+
"task_settle",
|
|
10893
12211
|
"computer",
|
|
10894
12212
|
"send_image",
|
|
10895
12213
|
"report_blocked"
|
|
@@ -11423,7 +12741,7 @@ function parseDirectoryProvider(value) {
|
|
|
11423
12741
|
}
|
|
11424
12742
|
return provider;
|
|
11425
12743
|
}
|
|
11426
|
-
const version = "0.3.
|
|
12744
|
+
const version = "0.3.13";
|
|
11427
12745
|
function readModelsDevCache(file) {
|
|
11428
12746
|
try {
|
|
11429
12747
|
if (!existsSync(file)) return void 0;
|
|
@@ -11641,6 +12959,9 @@ function projectMessage(value) {
|
|
|
11641
12959
|
if (value.role === "user" && typeof value.entryId === "string" && value.entryId.trim()) {
|
|
11642
12960
|
projected.entryId = value.entryId;
|
|
11643
12961
|
}
|
|
12962
|
+
if (typeof value.messageId === "string" && value.messageId.trim()) {
|
|
12963
|
+
projected.messageId = value.messageId;
|
|
12964
|
+
}
|
|
11644
12965
|
if (typeof value.toolName === "string") projected.toolName = value.toolName;
|
|
11645
12966
|
if (typeof value.toolCallId === "string") projected.toolCallId = value.toolCallId;
|
|
11646
12967
|
if (typeof value.isError === "boolean") projected.isError = value.isError;
|
|
@@ -11654,6 +12975,7 @@ function projectMessage(value) {
|
|
|
11654
12975
|
if (typeof value.errorMessage === "string") projected.errorMessage = value.errorMessage;
|
|
11655
12976
|
if (typeof value.timestamp === "number") projected.timestamp = value.timestamp;
|
|
11656
12977
|
if (value.role === "assistant" && typeof value.model === "string") projected.model = value.model;
|
|
12978
|
+
if (value.role === "assistant" && value.restartResumed === true) projected.restartResumed = true;
|
|
11657
12979
|
if (value.role === "assistant" && value.privacyMask !== void 0) {
|
|
11658
12980
|
const privacyMask = parseMaskReport(value.privacyMask);
|
|
11659
12981
|
if (privacyMask) projected.privacyMask = privacyMask;
|
|
@@ -11903,7 +13225,7 @@ ${persona}`;
|
|
|
11903
13225
|
}
|
|
11904
13226
|
const COMPUTER_DEFAULT_TIMEOUT_SEC = 60;
|
|
11905
13227
|
const COMPUTER_MAX_TIMEOUT_SEC = 120;
|
|
11906
|
-
function asRecord$
|
|
13228
|
+
function asRecord$1(value) {
|
|
11907
13229
|
if (typeof value === "string") {
|
|
11908
13230
|
const trimmed = value.trim();
|
|
11909
13231
|
if (!trimmed.startsWith("{")) return null;
|
|
@@ -11925,7 +13247,7 @@ function asTimeoutSec(value) {
|
|
|
11925
13247
|
return Math.min(Math.floor(n), COMPUTER_MAX_TIMEOUT_SEC);
|
|
11926
13248
|
}
|
|
11927
13249
|
function normalizeComputerParams(value) {
|
|
11928
|
-
const record = asRecord$
|
|
13250
|
+
const record = asRecord$1(value);
|
|
11929
13251
|
if (!record) return null;
|
|
11930
13252
|
const code = typeof record.code === "string" ? record.code : "";
|
|
11931
13253
|
if (!code.trim()) return null;
|
|
@@ -12094,6 +13416,10 @@ function withPlanGate(definition, deps) {
|
|
|
12094
13416
|
throw denied(
|
|
12095
13417
|
`spawn requires a read-only agent_type (${[...readonlyAgentTypes].join(", ") || "none available"})`
|
|
12096
13418
|
);
|
|
13419
|
+
} else if (operation === "resume") {
|
|
13420
|
+
const type = typeof record.agentId === "string" ? deps.agentTypeOf?.(record.agentId) : void 0;
|
|
13421
|
+
if (type === void 0 || !readonlyAgentTypes.has(type))
|
|
13422
|
+
throw denied("resume only continues read-only agent_type subagents while planning");
|
|
12097
13423
|
} else if (!SUBAGENT_PASSIVE_OPS.has(String(operation))) {
|
|
12098
13424
|
throw denied(`subagent ${String(operation)} is disabled while planning`);
|
|
12099
13425
|
}
|
|
@@ -12227,15 +13553,19 @@ function createProjectSettingsManager(cwd, agentDir, trusted) {
|
|
|
12227
13553
|
}
|
|
12228
13554
|
const SNAPSHOT_TAIL_MESSAGES = 60;
|
|
12229
13555
|
const SNAPSHOT_BYTE_BUDGET = 6e5;
|
|
12230
|
-
|
|
13556
|
+
const OVERVIEW_TAIL_MESSAGES = 10;
|
|
13557
|
+
const OVERVIEW_BYTE_BUDGET = 64e3;
|
|
13558
|
+
function takeSnapshotTail(messages, endIndex, limits = {}) {
|
|
13559
|
+
const maxMessages = limits.messages ?? SNAPSHOT_TAIL_MESSAGES;
|
|
13560
|
+
const budget = limits.bytes ?? SNAPSHOT_BYTE_BUDGET;
|
|
12231
13561
|
let bytes = 0;
|
|
12232
13562
|
let start = endIndex;
|
|
12233
|
-
while (start > 0 && endIndex - start <
|
|
13563
|
+
while (start > 0 && endIndex - start < maxMessages) {
|
|
12234
13564
|
const size = Buffer.byteLength(JSON.stringify(messages[start - 1]), "utf8");
|
|
12235
|
-
if (bytes + size >
|
|
13565
|
+
if (bytes + size > budget && start < endIndex) break;
|
|
12236
13566
|
bytes += size;
|
|
12237
13567
|
start--;
|
|
12238
|
-
if (bytes >
|
|
13568
|
+
if (bytes > budget) break;
|
|
12239
13569
|
}
|
|
12240
13570
|
return { messages: messages.slice(start, endIndex), baseIndex: start };
|
|
12241
13571
|
}
|
|
@@ -12245,7 +13575,7 @@ const ELEVATE_UNAVAILABLE_MARKER = "ENSO_ELEVATE_UNAVAILABLE";
|
|
|
12245
13575
|
const ELEVATE_TIMEOUT_MS = 12e4;
|
|
12246
13576
|
const ELEVATE_ASKPASS_ENV = "ENSO_ELEVATE_ASKPASS";
|
|
12247
13577
|
function buildElevatedCommand(command, options) {
|
|
12248
|
-
return `SUDO_ASKPASS=${shellQuote(options.askpassPath)} ${shellQuote(options.sudoPath)} -k -A -- /bin/bash -c ${shellQuote(command)}`;
|
|
13578
|
+
return `SUDO_ASKPASS=${shellQuote$1(options.askpassPath)} ${shellQuote$1(options.sudoPath)} -k -A -- /bin/bash -c ${shellQuote$1(command)}`;
|
|
12249
13579
|
}
|
|
12250
13580
|
const SUDO_ARGS = /^\S*sudo -k -A -- \/bin\/bash -c /;
|
|
12251
13581
|
function elevatedCommandOf(sudoArgs) {
|
|
@@ -12613,6 +13943,34 @@ function withAgentRead(definition, getStore) {
|
|
|
12613
13943
|
})
|
|
12614
13944
|
};
|
|
12615
13945
|
}
|
|
13946
|
+
function toolParameters(schema2) {
|
|
13947
|
+
return schema2;
|
|
13948
|
+
}
|
|
13949
|
+
const PORTABLE_KEYS = /* @__PURE__ */ new Set([
|
|
13950
|
+
"type",
|
|
13951
|
+
"anyOf",
|
|
13952
|
+
"description",
|
|
13953
|
+
"title",
|
|
13954
|
+
"enum",
|
|
13955
|
+
"const",
|
|
13956
|
+
"default",
|
|
13957
|
+
"nullable",
|
|
13958
|
+
"minimum",
|
|
13959
|
+
"maximum",
|
|
13960
|
+
"minLength",
|
|
13961
|
+
"maxLength",
|
|
13962
|
+
"minItems",
|
|
13963
|
+
"maxItems",
|
|
13964
|
+
"pattern",
|
|
13965
|
+
"format",
|
|
13966
|
+
"properties",
|
|
13967
|
+
"required",
|
|
13968
|
+
"additionalProperties",
|
|
13969
|
+
"items"
|
|
13970
|
+
]);
|
|
13971
|
+
new Set(
|
|
13972
|
+
[...PORTABLE_KEYS].filter((key) => key !== "additionalProperties" && key !== "const")
|
|
13973
|
+
);
|
|
12616
13974
|
const WAIT_TIMEOUT_NOTE = "The wait timed out; this is not a failure. Pending Runs keep going and you will be notified automatically when each finishes — continue other work instead of waiting again.";
|
|
12617
13975
|
const BACKGROUND_RECEIPT_NOTE = "The subagent is working in the background. You will be notified automatically when the Run completes. You know nothing about its results until that notification arrives — do not report, assume, or predict them; continue other work or respond to the user in the meantime. If the user asks for progress, say it is still running. Do not duplicate its work on the same files or topics. agentId and runId are internal ids — do not mention them to the user.";
|
|
12618
13976
|
function normalizeSubagentArgs(params) {
|
|
@@ -12653,13 +14011,15 @@ const SUBAGENT_OPERATIONS = [
|
|
|
12653
14011
|
"list",
|
|
12654
14012
|
"message",
|
|
12655
14013
|
"stop",
|
|
12656
|
-
"dismiss"
|
|
14014
|
+
"dismiss",
|
|
14015
|
+
"resume"
|
|
12657
14016
|
];
|
|
12658
14017
|
const REQUIRED_FIELDS = {
|
|
12659
14018
|
send: ["agentId", "message"],
|
|
12660
14019
|
report: ["runId"],
|
|
12661
14020
|
stop: ["runId"],
|
|
12662
14021
|
dismiss: ["agentId"],
|
|
14022
|
+
resume: ["agentId"],
|
|
12663
14023
|
message: ["to", "text"]
|
|
12664
14024
|
};
|
|
12665
14025
|
const SCHEMA_GATE_HINT = "schema: object, gate: {commandRef: string}";
|
|
@@ -12765,7 +14125,7 @@ function createUnifiedSubagentTool(deps) {
|
|
|
12765
14125
|
if (operation === "report" || operation === "stop") {
|
|
12766
14126
|
return parseAgentControlToolRequest({ operation, runId: params.runId });
|
|
12767
14127
|
}
|
|
12768
|
-
if (operation === "dismiss") {
|
|
14128
|
+
if (operation === "dismiss" || operation === "resume") {
|
|
12769
14129
|
return parseAgentControlToolRequest({ operation, agentId: params.agentId });
|
|
12770
14130
|
}
|
|
12771
14131
|
if (operation === "list") {
|
|
@@ -12784,12 +14144,13 @@ function createUnifiedSubagentTool(deps) {
|
|
|
12784
14144
|
return {
|
|
12785
14145
|
name: "subagent",
|
|
12786
14146
|
label: "Subagent",
|
|
12787
|
-
description: 'Every call must pass operation, including operation:"spawn". Spawn requires non-empty description and prompt parameters; omit both for every other operation. Create and control delegated agents. mode=task is one-shot; mode=coworker preserves context for multiple Runs. All operations are Main-authorized. Spawning and sending are asynchronous unless wait:true; you are notified automatically when a Run finishes.',
|
|
12788
|
-
promptSnippet: 'subagent: always pass operation (operation:"spawn" to spawn). spawn requires non-empty description and prompt. Other operations omit both. Spawn task/coworker agents, list owned agents, send Runs or bound messages, wait/report/stop a Run, or
|
|
14147
|
+
description: 'Every call must pass operation, including operation:"spawn". Spawn requires non-empty description and prompt parameters; omit both for every other operation. Create and control delegated agents. mode=task is one-shot; mode=coworker preserves context for multiple Runs. All operations are Main-authorized. Spawning and sending are asynchronous unless wait:true; you are notified automatically when a Run finishes. A task interrupted before it finished keeps its progress: continue it with operation:"resume" and its agentId — do not spawn it again.',
|
|
14148
|
+
promptSnippet: 'subagent: always pass operation (operation:"spawn" to spawn). spawn requires non-empty description and prompt. Other operations omit both. Spawn task/coworker agents, list owned agents, send Runs or bound messages, wait/report/stop a Run, dismiss an Agent, or resume an interrupted task. Default spawn mode=task and wait=false; finished Runs notify you automatically.',
|
|
12789
14149
|
promptGuidelines: [
|
|
12790
14150
|
'Every subagent call must pass operation; to spawn, pass operation:"spawn". spawn requires non-empty description and prompt. Omit both for every other operation.',
|
|
12791
14151
|
"On spawn, description is the title the user sees in subagent history. Write a short human-readable label of the work, not an id or slug. name is an optional internal handle and is not the title.",
|
|
12792
|
-
"Agent and Run are different identities: use runId for wait/report/stop and agentId for send/dismiss.",
|
|
14152
|
+
"Agent and Run are different identities: use runId for wait/report/stop and agentId for send/dismiss/resume.",
|
|
14153
|
+
`When a task Run is interrupted by something recoverable — a network or provider error that persisted through automatic retries, or an agent worker crash — its Agent is parked with its progress saved and the completion notice says so. Call resume with that agentId to continue from where it stopped (at most ${AGENT_TASK_MAX_RESUMES} times per task) — do not spawn the same task again, which starts over from scratch. If you lost the agentId, list with status:"parked" finds it. Failures that retrying cannot fix (bad request, auth, request budget) close the task instead.`,
|
|
12793
14154
|
"Delegate when the work matches an available agent type, when two independent investigations can run in parallel, when answering needs broad exploration across several files, or when a long-running job can proceed in the background. For a known file, symbol, or single fact, use the direct tool (read for a known path, grep for a specific symbol) instead, and do not repeat work you delegated. Once you've delegated a search, don't also run it yourself.",
|
|
12794
14155
|
"Treat the delivered report as your source of record: do not re-read files it covered unless you are about to edit them or the report is incomplete.",
|
|
12795
14156
|
"Default to doing the work yourself in this thread: a few reads, one search, a short edit, or a single check is faster inline than delegating. Do not fan out several subagents for one small task, do not spawn a subagent to review or re-check work you can verify yourself, and keep the count low — one well-briefed subagent beats several thin ones. When independent subagents should run in parallel, spawn them all in the same message.",
|
|
@@ -12806,7 +14167,7 @@ function createUnifiedSubagentTool(deps) {
|
|
|
12806
14167
|
`model must be copied exactly from the model enum: ${modelNames.join(", ")}. Short names are rejected.${modelNotes ? ` ${modelNotes}.` : ""}`
|
|
12807
14168
|
] : []
|
|
12808
14169
|
],
|
|
12809
|
-
parameters: {
|
|
14170
|
+
parameters: toolParameters({
|
|
12810
14171
|
type: "object",
|
|
12811
14172
|
properties: {
|
|
12812
14173
|
operation: {
|
|
@@ -12875,7 +14236,7 @@ function createUnifiedSubagentTool(deps) {
|
|
|
12875
14236
|
},
|
|
12876
14237
|
required: ["operation"],
|
|
12877
14238
|
additionalProperties: false
|
|
12878
|
-
},
|
|
14239
|
+
}),
|
|
12879
14240
|
prepareArguments: normalizeSubagentArgs,
|
|
12880
14241
|
async execute(toolCallId, params, signal) {
|
|
12881
14242
|
const input = normalizeSubagentArgs(params);
|
|
@@ -12895,7 +14256,7 @@ function createUnifiedSubagentTool(deps) {
|
|
|
12895
14256
|
if (!response.ok) throw new Error(`${response.code}: ${response.error}`);
|
|
12896
14257
|
const receipt = waits ? waitReceiptOf(response.value) : void 0;
|
|
12897
14258
|
const detachedBy = blocking?.reason();
|
|
12898
|
-
const background = !waits && (request.operation === "spawn" || request.operation === "send") && response.value?.status !== void 0;
|
|
14259
|
+
const background = !waits && (request.operation === "spawn" || request.operation === "send" || request.operation === "resume") && response.value?.status !== void 0;
|
|
12899
14260
|
const note = receipt?.interrupted && detachedBy ? detachedWaitNote(detachedBy, "subagent") : receipt?.timedOut ? WAIT_TIMEOUT_NOTE : background ? BACKGROUND_RECEIPT_NOTE : void 0;
|
|
12900
14261
|
const modelNote = defaultedModel ? `No model was given; used ${defaultedModel}, the first configured subagent model. Pass model to choose another.` : void 0;
|
|
12901
14262
|
const value = (note || modelNote) && response.value && typeof response.value === "object" ? {
|
|
@@ -13157,12 +14518,31 @@ function buildTurnDigest(messages, fromIndex) {
|
|
|
13157
14518
|
userParts = fallback ? [fallback] : [];
|
|
13158
14519
|
}
|
|
13159
14520
|
const userText = userParts.join("\n").slice(0, TURN_DIGEST_USER_MAX);
|
|
13160
|
-
const conclusion =
|
|
14521
|
+
const conclusion = turnConclusion(turn);
|
|
14522
|
+
const assistantText = conclusion ? textOf(conclusion).slice(-1500) : "";
|
|
14523
|
+
const lastTool = conclusion ? void 0 : lastToolOf(turn);
|
|
14524
|
+
if (!userText && !assistantText && !lastTool) return null;
|
|
14525
|
+
return { firstUserText, userText, assistantText, ...lastTool ? { lastTool } : {} };
|
|
14526
|
+
}
|
|
14527
|
+
function lastToolOf(turn) {
|
|
14528
|
+
for (let index = turn.length - 1; index >= 0; index -= 1) {
|
|
14529
|
+
const message = turn[index];
|
|
14530
|
+
if (message.role !== "toolResult" || !message.toolName) continue;
|
|
14531
|
+
return { name: message.toolName, ok: message.isError !== true };
|
|
14532
|
+
}
|
|
14533
|
+
return void 0;
|
|
14534
|
+
}
|
|
14535
|
+
function turnConclusion(turn) {
|
|
14536
|
+
return [...turn].reverse().find(
|
|
13161
14537
|
(message) => message.role === "assistant" && message.stopReason !== "error" && message.stopReason !== "aborted" && textOf(message).length > 0
|
|
13162
14538
|
);
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
14539
|
+
}
|
|
14540
|
+
function buildTurnReport(messages, fromIndex) {
|
|
14541
|
+
const conclusion = turnConclusion(messages.slice(Math.max(0, fromIndex)));
|
|
14542
|
+
if (!conclusion) return void 0;
|
|
14543
|
+
const text2 = textOf(conclusion);
|
|
14544
|
+
const omitted = text2.length - TURN_REPORT_MAX_CHARS;
|
|
14545
|
+
return omitted > 0 ? { text: text2.slice(-TURN_REPORT_MAX_CHARS), omitted } : { text: text2 };
|
|
13166
14546
|
}
|
|
13167
14547
|
const SPECIAL_TOKEN = /<\|[^|>]*\|>/g;
|
|
13168
14548
|
const QUOTE_PAIRS = [
|
|
@@ -13308,7 +14688,7 @@ function isLoopbackHost(hostname) {
|
|
|
13308
14688
|
if (host === "[::1]" || host === "::1") return true;
|
|
13309
14689
|
return /^127(?:\.\d{1,3}){3}$/.test(host);
|
|
13310
14690
|
}
|
|
13311
|
-
const DEFAULT_TIMEOUT_MS$
|
|
14691
|
+
const DEFAULT_TIMEOUT_MS$1 = 6e4;
|
|
13312
14692
|
class BrowserInvoker {
|
|
13313
14693
|
constructor(identity, emit, options = {}) {
|
|
13314
14694
|
this.identity = identity;
|
|
@@ -13323,7 +14703,7 @@ class BrowserInvoker {
|
|
|
13323
14703
|
if (signal?.aborted) return Promise.reject(new Error("Browser action aborted"));
|
|
13324
14704
|
const requestId = randomUUID();
|
|
13325
14705
|
const { promise, resolve, reject } = Promise.withResolvers();
|
|
13326
|
-
const timeoutMs = this.options.timeoutMs ?? DEFAULT_TIMEOUT_MS$
|
|
14706
|
+
const timeoutMs = this.options.timeoutMs ?? DEFAULT_TIMEOUT_MS$1;
|
|
13327
14707
|
const timer = setTimeout(
|
|
13328
14708
|
() => settle(new Error(`Browser action ${op} timed out after ${timeoutMs}ms`)),
|
|
13329
14709
|
timeoutMs
|
|
@@ -13680,7 +15060,7 @@ function pixelFingerprint(data) {
|
|
|
13680
15060
|
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
13681
15061
|
}
|
|
13682
15062
|
const COMPUTER_INVOKE_GRACE_MS = 3e4;
|
|
13683
|
-
const DEFAULT_TIMEOUT_MS
|
|
15063
|
+
const DEFAULT_TIMEOUT_MS = 15e4;
|
|
13684
15064
|
class ComputerInvoker {
|
|
13685
15065
|
constructor(identity, emit, options = {}) {
|
|
13686
15066
|
this.identity = identity;
|
|
@@ -13691,7 +15071,7 @@ class ComputerInvoker {
|
|
|
13691
15071
|
emit;
|
|
13692
15072
|
options;
|
|
13693
15073
|
pending = /* @__PURE__ */ new Map();
|
|
13694
|
-
invoke(op, params, signal, timeoutMs = this.options.timeoutMs ?? DEFAULT_TIMEOUT_MS
|
|
15074
|
+
invoke(op, params, signal, timeoutMs = this.options.timeoutMs ?? DEFAULT_TIMEOUT_MS) {
|
|
13695
15075
|
if (signal?.aborted) return Promise.reject(new Error("Computer action aborted"));
|
|
13696
15076
|
const requestId = randomUUID();
|
|
13697
15077
|
const { promise, resolve, reject } = Promise.withResolvers();
|
|
@@ -14416,260 +15796,8 @@ async function readImageView(deps, requested) {
|
|
|
14416
15796
|
data: Buffer.from(bytes).toString("base64")
|
|
14417
15797
|
};
|
|
14418
15798
|
}
|
|
14419
|
-
const
|
|
14420
|
-
|
|
14421
|
-
"preference",
|
|
14422
|
-
"decision",
|
|
14423
|
-
"plan",
|
|
14424
|
-
"procedure",
|
|
14425
|
-
"learning",
|
|
14426
|
-
"context",
|
|
14427
|
-
"event"
|
|
14428
|
-
];
|
|
14429
|
-
function isUnitType(value) {
|
|
14430
|
-
return UNIT_TYPES.includes(value);
|
|
14431
|
-
}
|
|
14432
|
-
const DEFAULT_UNIT_TYPE = "fact";
|
|
14433
|
-
const DEFAULT_IMPORTANCE = 0.5;
|
|
14434
|
-
const AGENT_CREATE_IMPORTANCE = 0.6;
|
|
14435
|
-
const HALF_LIFE_DAYS = 30;
|
|
14436
|
-
const RECENCY_W = 0.7;
|
|
14437
|
-
const FREQUENCY_W = 0.3;
|
|
14438
|
-
const FREQUENCY_MAX_COUNT = 100;
|
|
14439
|
-
const MIN_FLOOR = 0.3;
|
|
14440
|
-
const IMP_MULT = 0.2;
|
|
14441
|
-
const DECAY_WEIGHT = 0.15;
|
|
14442
|
-
const FORGETTING_DEFAULT_STALE_DAYS = 90;
|
|
14443
|
-
const FORGETTING_DEFAULT_MAX_IMPORTANCE = 0.5;
|
|
14444
|
-
const FORGETTING_DEFAULT_INTERVAL_DAYS = 7;
|
|
14445
|
-
const FORGETTING_STALE_DAYS_MIN = 7;
|
|
14446
|
-
const FORGETTING_STALE_DAYS_MAX = 3650;
|
|
14447
|
-
const FORGETTING_MAX_IMPORTANCE_MIN = 0.1;
|
|
14448
|
-
const FORGETTING_MAX_IMPORTANCE_MAX = 0.9;
|
|
14449
|
-
const FORGETTING_INTERVAL_DAYS_MIN = 1;
|
|
14450
|
-
const FORGETTING_INTERVAL_DAYS_MAX = 90;
|
|
14451
|
-
const TEMPORAL_YEAR_BOOST = 0.1;
|
|
14452
|
-
const RRF_K = 60;
|
|
14453
|
-
const MMR_LAMBDA = 0.7;
|
|
14454
|
-
const DEDUP_VECTOR = 0.8;
|
|
14455
|
-
const DEDUP_MAX = 3;
|
|
14456
|
-
const DEDUP_MIN_CHARS = 100;
|
|
14457
|
-
const EVOLVES_RELATIONS = ["replaces", "enriches", "confirms", "challenges"];
|
|
14458
|
-
function isEvolvesRelation(value) {
|
|
14459
|
-
return EVOLVES_RELATIONS.includes(value);
|
|
14460
|
-
}
|
|
14461
|
-
const CRYSTAL_MIN_SOURCES = 3;
|
|
14462
|
-
const CRYSTAL_BOOST = 1.25;
|
|
14463
|
-
const DISTILL_MAX_CHUNK_CHARS = 4e3;
|
|
14464
|
-
const DISTILL_SINGLE_EXTRACT_MAX_TOKENS = 1536;
|
|
14465
|
-
const DISTILL_EXTRACT_MAX_TOKENS = 1536;
|
|
14466
|
-
const DISTILL_CONSOLIDATE_MAX_TOKENS = 1536;
|
|
14467
|
-
const DISTILL_MAX_OUTPUT_TOKENS = 3072;
|
|
14468
|
-
const DISTILL_MIN_IMPORTANCE = 0.5;
|
|
14469
|
-
const DISTILL_MAX_ATTEMPTS = 3;
|
|
14470
|
-
const KG_MAX_ENTITIES = 10;
|
|
14471
|
-
const KG_MAX_RELATIONS = 20;
|
|
14472
|
-
const KG_MAX_ENTITY_NAME_CHARS = 100;
|
|
14473
|
-
const KG_MAX_DESCRIPTION_CHARS = 300;
|
|
14474
|
-
const KG_MAX_LABEL_CHARS = 40;
|
|
14475
|
-
const KG_MAX_ATTEMPTS = 3;
|
|
14476
|
-
const KG_EXTRACT_MAX_TOKENS = 4096;
|
|
14477
|
-
const KG_DEFAULT_ENTITY_TYPE = "CONCEPT";
|
|
14478
|
-
const KG_DEFAULT_RELATION_TYPE = "RELATED_TO";
|
|
14479
|
-
const MEMORY_SEARCH_SPACES = ["all", "global", "project", "bot", "chat"];
|
|
14480
|
-
const MEMORY_CAPTURE_SPACES = ["global", "project", "bot", "chat"];
|
|
14481
|
-
const MEMORY_SEARCH_MODES = ["fast", "deep"];
|
|
14482
|
-
const MEMORY_SEARCH_DEFAULT_LIMIT = 10;
|
|
14483
|
-
const MEMORY_SEARCH_MAX_LIMIT = 50;
|
|
14484
|
-
const MEMORY_SEARCH_DATE_KEYS = [
|
|
14485
|
-
"eventDateFrom",
|
|
14486
|
-
"eventDateTo",
|
|
14487
|
-
"recordedDateFrom",
|
|
14488
|
-
"recordedDateTo"
|
|
14489
|
-
];
|
|
14490
|
-
function asRecord$1(value) {
|
|
14491
|
-
if (typeof value === "string") {
|
|
14492
|
-
const trimmed = value.trim();
|
|
14493
|
-
if (!trimmed.startsWith("{")) return null;
|
|
14494
|
-
try {
|
|
14495
|
-
const parsed = JSON.parse(trimmed);
|
|
14496
|
-
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
14497
|
-
} catch {
|
|
14498
|
-
return null;
|
|
14499
|
-
}
|
|
14500
|
-
}
|
|
14501
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
14502
|
-
}
|
|
14503
|
-
function asNumber(value) {
|
|
14504
|
-
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
14505
|
-
if (typeof value === "string" && value.trim()) {
|
|
14506
|
-
const n = Number(value);
|
|
14507
|
-
return Number.isFinite(n) ? n : null;
|
|
14508
|
-
}
|
|
14509
|
-
return null;
|
|
14510
|
-
}
|
|
14511
|
-
function optionalText$1(value) {
|
|
14512
|
-
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
14513
|
-
}
|
|
14514
|
-
function normalizeMemorySearchParams(raw) {
|
|
14515
|
-
const record = asRecord$1(raw);
|
|
14516
|
-
if (!record) return raw;
|
|
14517
|
-
const limit = asNumber(record.limit);
|
|
14518
|
-
const space = typeof record.spaceId === "string" ? record.spaceId.trim() : "";
|
|
14519
|
-
const mode = typeof record.mode === "string" ? record.mode.trim().toLowerCase() : "";
|
|
14520
|
-
const dates = {};
|
|
14521
|
-
for (const key of MEMORY_SEARCH_DATE_KEYS) {
|
|
14522
|
-
const v = optionalText$1(record[key]);
|
|
14523
|
-
if (v) dates[key] = v;
|
|
14524
|
-
}
|
|
14525
|
-
return {
|
|
14526
|
-
query: typeof record.query === "string" ? record.query : record.query,
|
|
14527
|
-
limit: limit === null ? MEMORY_SEARCH_DEFAULT_LIMIT : Math.min(MEMORY_SEARCH_MAX_LIMIT, Math.max(1, Math.floor(limit))),
|
|
14528
|
-
spaceId: MEMORY_SEARCH_SPACES.includes(space) ? space : "all",
|
|
14529
|
-
mode: MEMORY_SEARCH_MODES.includes(mode) ? mode : "fast",
|
|
14530
|
-
...dates
|
|
14531
|
-
};
|
|
14532
|
-
}
|
|
14533
|
-
function normalizeMemoryCaptureParams(raw) {
|
|
14534
|
-
const record = asRecord$1(raw);
|
|
14535
|
-
if (!record) return raw;
|
|
14536
|
-
const unitType = optionalText$1(record.unitType)?.toLowerCase();
|
|
14537
|
-
const importance = asNumber(record.importance);
|
|
14538
|
-
const space = typeof record.spaceId === "string" ? record.spaceId.trim() : "";
|
|
14539
|
-
const title = optionalText$1(record.title);
|
|
14540
|
-
const eventStart = optionalText$1(record.eventStart);
|
|
14541
|
-
const eventEnd = optionalText$1(record.eventEnd);
|
|
14542
|
-
const force = record.force === true || record.force === "true";
|
|
14543
|
-
const evolvesFromId = optionalText$1(record.evolvesFromId);
|
|
14544
|
-
const evolvesRelation = optionalText$1(record.evolvesRelation)?.toLowerCase();
|
|
14545
|
-
const evolvesReason = optionalText$1(record.evolvesReason);
|
|
14546
|
-
const emptyEvolutionTarget = typeof record.evolvesFromId === "string" && !evolvesFromId && isEvolvesRelation(evolvesRelation);
|
|
14547
|
-
return {
|
|
14548
|
-
content: record.content,
|
|
14549
|
-
...title ? { title } : {},
|
|
14550
|
-
...unitType ? { unitType } : {},
|
|
14551
|
-
importance: importance !== null && importance >= 0 && importance <= 1 ? importance : AGENT_CREATE_IMPORTANCE,
|
|
14552
|
-
// 缺省 / 非法不产出:worker 不知道会话是否 Bot 模式,由 Main 决定缺省 space
|
|
14553
|
-
...MEMORY_CAPTURE_SPACES.includes(space) ? { spaceId: space } : {},
|
|
14554
|
-
...eventStart ? { eventStart } : {},
|
|
14555
|
-
...eventEnd ? { eventEnd } : {},
|
|
14556
|
-
...force ? { force } : {},
|
|
14557
|
-
...evolvesFromId ? { evolvesFromId } : {},
|
|
14558
|
-
...evolvesRelation && !emptyEvolutionTarget ? { evolvesRelation } : {},
|
|
14559
|
-
// 理由只跟着关系走:没有关系的理由没有意义,别写进库
|
|
14560
|
-
...evolvesReason && evolvesRelation && !emptyEvolutionTarget ? { evolvesReason } : {}
|
|
14561
|
-
};
|
|
14562
|
-
}
|
|
14563
|
-
function asIdList(value) {
|
|
14564
|
-
let list = value;
|
|
14565
|
-
if (typeof value === "string") {
|
|
14566
|
-
const trimmed = value.trim();
|
|
14567
|
-
if (trimmed.startsWith("[")) {
|
|
14568
|
-
try {
|
|
14569
|
-
list = JSON.parse(trimmed);
|
|
14570
|
-
} catch {
|
|
14571
|
-
return value;
|
|
14572
|
-
}
|
|
14573
|
-
} else {
|
|
14574
|
-
list = trimmed.split(",");
|
|
14575
|
-
}
|
|
14576
|
-
}
|
|
14577
|
-
if (!Array.isArray(list)) return value;
|
|
14578
|
-
return [
|
|
14579
|
-
...new Set(
|
|
14580
|
-
list.filter((x) => typeof x === "string").map((x) => x.trim()).filter(Boolean)
|
|
14581
|
-
)
|
|
14582
|
-
];
|
|
14583
|
-
}
|
|
14584
|
-
function normalizeMemoryCrystallizeParams(raw) {
|
|
14585
|
-
const record = asRecord$1(raw);
|
|
14586
|
-
if (!record) return raw;
|
|
14587
|
-
const title = optionalText$1(record.title);
|
|
14588
|
-
const force = record.force === true || record.force === "true";
|
|
14589
|
-
return {
|
|
14590
|
-
content: record.content,
|
|
14591
|
-
title: title ?? record.title,
|
|
14592
|
-
sourceIds: asIdList(record.sourceIds),
|
|
14593
|
-
...force ? { force } : {}
|
|
14594
|
-
};
|
|
14595
|
-
}
|
|
14596
|
-
const hasOnlyKeys = (value, allowed) => Object.keys(value).every((key) => allowed.includes(key));
|
|
14597
|
-
function normalizeMemoryDeleteParams(raw) {
|
|
14598
|
-
const record = asRecord$1(raw);
|
|
14599
|
-
if (!record) return raw;
|
|
14600
|
-
return { id: optionalText$1(record.id) ?? record.id };
|
|
14601
|
-
}
|
|
14602
|
-
function parseMemoryDeleteRequest(value) {
|
|
14603
|
-
const record = asRecord$1(value);
|
|
14604
|
-
if (!record || typeof value === "string" || !hasOnlyKeys(record, ["id"]) || typeof record.id !== "string" || !record.id.trim()) {
|
|
14605
|
-
return null;
|
|
14606
|
-
}
|
|
14607
|
-
return { id: record.id };
|
|
14608
|
-
}
|
|
14609
|
-
function parseMemorySearchRequest(value) {
|
|
14610
|
-
const record = asRecord$1(value);
|
|
14611
|
-
if (!record || typeof value === "string" || !hasOnlyKeys(record, ["query", "limit", "spaceId", "mode", ...MEMORY_SEARCH_DATE_KEYS]) || typeof record.query !== "string" || !record.query.trim() || typeof record.limit !== "number" || !Number.isInteger(record.limit) || record.limit < 1 || record.limit > MEMORY_SEARCH_MAX_LIMIT || !MEMORY_SEARCH_SPACES.includes(record.spaceId) || record.mode !== void 0 && !MEMORY_SEARCH_MODES.includes(record.mode) || MEMORY_SEARCH_DATE_KEYS.some(
|
|
14612
|
-
(k) => record[k] !== void 0 && (typeof record[k] !== "string" || !record[k].trim())
|
|
14613
|
-
)) {
|
|
14614
|
-
return null;
|
|
14615
|
-
}
|
|
14616
|
-
const out = {
|
|
14617
|
-
query: record.query,
|
|
14618
|
-
limit: record.limit,
|
|
14619
|
-
spaceId: record.spaceId,
|
|
14620
|
-
mode: record.mode === "deep" ? "deep" : "fast"
|
|
14621
|
-
};
|
|
14622
|
-
for (const k of MEMORY_SEARCH_DATE_KEYS) if (typeof record[k] === "string") out[k] = record[k];
|
|
14623
|
-
return out;
|
|
14624
|
-
}
|
|
14625
|
-
function parseMemoryCrystallizeRequest(value) {
|
|
14626
|
-
const record = asRecord$1(value);
|
|
14627
|
-
if (!record || typeof value === "string" || !hasOnlyKeys(record, ["content", "title", "sourceIds", "force"]) || typeof record.content !== "string" || !record.content.trim() || typeof record.title !== "string" || !record.title.trim() || !Array.isArray(record.sourceIds) || record.sourceIds.length < CRYSTAL_MIN_SOURCES || !record.sourceIds.every((id) => typeof id === "string" && id.trim()) || record.force !== void 0 && typeof record.force !== "boolean") {
|
|
14628
|
-
return null;
|
|
14629
|
-
}
|
|
14630
|
-
return {
|
|
14631
|
-
content: record.content,
|
|
14632
|
-
title: record.title,
|
|
14633
|
-
sourceIds: record.sourceIds,
|
|
14634
|
-
...record.force !== void 0 ? { force: record.force } : {}
|
|
14635
|
-
};
|
|
14636
|
-
}
|
|
14637
|
-
function parseMemoryCaptureRequest(value) {
|
|
14638
|
-
const record = asRecord$1(value);
|
|
14639
|
-
if (!record || typeof value === "string" || !hasOnlyKeys(record, [
|
|
14640
|
-
"content",
|
|
14641
|
-
"title",
|
|
14642
|
-
"unitType",
|
|
14643
|
-
"importance",
|
|
14644
|
-
"spaceId",
|
|
14645
|
-
"eventStart",
|
|
14646
|
-
"eventEnd",
|
|
14647
|
-
"force",
|
|
14648
|
-
"evolvesFromId",
|
|
14649
|
-
"evolvesRelation",
|
|
14650
|
-
"evolvesReason"
|
|
14651
|
-
]) || typeof record.content !== "string" || !record.content.trim() || record.title !== void 0 && typeof record.title !== "string" || record.unitType !== void 0 && typeof record.unitType !== "string" || typeof record.importance !== "number" || record.importance < 0 || record.importance > 1 || record.spaceId !== void 0 && !MEMORY_CAPTURE_SPACES.includes(record.spaceId) || record.eventStart !== void 0 && typeof record.eventStart !== "string" || record.eventEnd !== void 0 && typeof record.eventEnd !== "string" || record.force !== void 0 && typeof record.force !== "boolean" || record.evolvesReason !== void 0 && typeof record.evolvesReason !== "string" || // 关系与目标必须成对,关系限闭集
|
|
14652
|
-
record.evolvesFromId === void 0 !== (record.evolvesRelation === void 0) || record.evolvesFromId !== void 0 && (typeof record.evolvesFromId !== "string" || !record.evolvesFromId.trim() || !isEvolvesRelation(record.evolvesRelation))) {
|
|
14653
|
-
return null;
|
|
14654
|
-
}
|
|
14655
|
-
const rawUnit = record.unitType?.trim().toLowerCase() ?? "";
|
|
14656
|
-
const unitType = isUnitType(rawUnit) ? rawUnit : DEFAULT_UNIT_TYPE;
|
|
14657
|
-
const unitTypeSource = !rawUnit ? "default" : isUnitType(rawUnit) ? "explicit" : "fallback";
|
|
14658
|
-
return {
|
|
14659
|
-
content: record.content,
|
|
14660
|
-
...record.title !== void 0 ? { title: record.title } : {},
|
|
14661
|
-
unitType,
|
|
14662
|
-
unitTypeSource,
|
|
14663
|
-
importance: record.importance,
|
|
14664
|
-
...record.spaceId !== void 0 ? { spaceId: record.spaceId } : {},
|
|
14665
|
-
...record.eventStart !== void 0 ? { eventStart: record.eventStart } : {},
|
|
14666
|
-
...record.eventEnd !== void 0 ? { eventEnd: record.eventEnd } : {},
|
|
14667
|
-
...record.force !== void 0 ? { force: record.force } : {},
|
|
14668
|
-
...typeof record.evolvesFromId === "string" && isEvolvesRelation(record.evolvesRelation) ? { evolvesFromId: record.evolvesFromId, evolvesRelation: record.evolvesRelation } : {},
|
|
14669
|
-
...typeof record.evolvesReason === "string" && record.evolvesReason.trim() ? { evolvesReason: record.evolvesReason.trim() } : {}
|
|
14670
|
-
};
|
|
14671
|
-
}
|
|
14672
|
-
const DEFAULT_TIMEOUT_MS = 15e3;
|
|
15799
|
+
const SEARCH_TIMEOUT_MS = 15e3;
|
|
15800
|
+
const WRITE_TIMEOUT_MS = 3e4;
|
|
14673
15801
|
class MemoryInvoker {
|
|
14674
15802
|
constructor(identity, emit, options = {}) {
|
|
14675
15803
|
this.identity = identity;
|
|
@@ -14685,7 +15813,7 @@ class MemoryInvoker {
|
|
|
14685
15813
|
if (signal?.aborted) return Promise.reject(new Error("Memory action aborted"));
|
|
14686
15814
|
const requestId = randomUUID();
|
|
14687
15815
|
const { promise, resolve, reject } = Promise.withResolvers();
|
|
14688
|
-
const waitMs = timeoutMs ?? this.options.timeoutMs ??
|
|
15816
|
+
const waitMs = timeoutMs ?? this.options.timeoutMs ?? (op === "search" ? SEARCH_TIMEOUT_MS : WRITE_TIMEOUT_MS);
|
|
14689
15817
|
const timer = setTimeout(
|
|
14690
15818
|
() => settle(new Error(`Memory action ${op} timed out after ${waitMs}ms`)),
|
|
14691
15819
|
waitMs
|
|
@@ -14909,96 +16037,6 @@ function createMemoryTools(invoker, opts = {}) {
|
|
|
14909
16037
|
)
|
|
14910
16038
|
];
|
|
14911
16039
|
}
|
|
14912
|
-
const READABLE_MESSAGE_MAX_CHARS = 2e3;
|
|
14913
|
-
const MESSAGE_CHUNK_MAX = 3e4;
|
|
14914
|
-
const END_TAG = "</untrusted-content";
|
|
14915
|
-
function wrapUntrusted(source, text2) {
|
|
14916
|
-
const escaped = text2.split(END_TAG).join("<\\/untrusted-content");
|
|
14917
|
-
return `<untrusted-content source="${source}">${escaped}</untrusted-content>`;
|
|
14918
|
-
}
|
|
14919
|
-
function readableText(message) {
|
|
14920
|
-
return message.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("\n").trim();
|
|
14921
|
-
}
|
|
14922
|
-
function chunkMessageText(text2, offset = 0) {
|
|
14923
|
-
const totalChars = text2.length;
|
|
14924
|
-
const start = Number.isFinite(offset) ? Math.min(Math.max(0, Math.floor(offset)), totalChars) : 0;
|
|
14925
|
-
const end = Math.min(start + MESSAGE_CHUNK_MAX, totalChars);
|
|
14926
|
-
return {
|
|
14927
|
-
text: text2.slice(start, end),
|
|
14928
|
-
offset: start,
|
|
14929
|
-
totalChars,
|
|
14930
|
-
...end < totalChars ? { nextOffset: end } : {}
|
|
14931
|
-
};
|
|
14932
|
-
}
|
|
14933
|
-
function projectReadableMessages(messages, options) {
|
|
14934
|
-
const baseIndex = options.baseIndex ?? 0;
|
|
14935
|
-
const maxChars = options.maxChars ?? READABLE_MESSAGE_MAX_CHARS;
|
|
14936
|
-
const readable = [];
|
|
14937
|
-
messages.forEach((message, offset) => {
|
|
14938
|
-
if (message.role !== "user" && message.role !== "assistant") return;
|
|
14939
|
-
const text2 = readableText(message);
|
|
14940
|
-
if (!text2) return;
|
|
14941
|
-
const truncated = text2.length > maxChars;
|
|
14942
|
-
readable.push({
|
|
14943
|
-
index: baseIndex + offset,
|
|
14944
|
-
role: message.role,
|
|
14945
|
-
text: truncated ? `${text2.slice(0, maxChars)}…` : text2,
|
|
14946
|
-
...truncated ? { truncated: true } : {}
|
|
14947
|
-
});
|
|
14948
|
-
});
|
|
14949
|
-
const kept = readable.slice(-Math.max(0, options.limit));
|
|
14950
|
-
const firstIndex = kept[0]?.index ?? baseIndex;
|
|
14951
|
-
return { messages: kept, hasMore: firstIndex > 0 };
|
|
14952
|
-
}
|
|
14953
|
-
const SEND_IMAGE_PER_REPLY = 4;
|
|
14954
|
-
const SEND_IMAGE_CAPTION_MAX = 200;
|
|
14955
|
-
const MEDIA_ID_RE = /^[a-f0-9]{64}\.(?:png|jpg|gif|webp)$/;
|
|
14956
|
-
const SOURCES = ["file", "web", "desktop"];
|
|
14957
|
-
const ERRORS = ["too-large", "quota"];
|
|
14958
|
-
const isMediaId = (value) => typeof value === "string" && MEDIA_ID_RE.test(value);
|
|
14959
|
-
const optionalText = (value, max) => typeof value === "string" && value.trim() ? value.trim().slice(0, max) : void 0;
|
|
14960
|
-
function parseSendImageResult(text2) {
|
|
14961
|
-
let value;
|
|
14962
|
-
try {
|
|
14963
|
-
value = JSON.parse(text2.split("\n", 1)[0]);
|
|
14964
|
-
} catch {
|
|
14965
|
-
return null;
|
|
14966
|
-
}
|
|
14967
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
14968
|
-
const raw = value;
|
|
14969
|
-
if (typeof raw.source !== "string" || !SOURCES.includes(raw.source)) return null;
|
|
14970
|
-
const source = raw.source;
|
|
14971
|
-
const name = optionalText(raw.name, 1024);
|
|
14972
|
-
const caption = optionalText(raw.caption, SEND_IMAGE_CAPTION_MAX);
|
|
14973
|
-
const extra = { ...name ? { name } : {}, ...caption ? { caption } : {} };
|
|
14974
|
-
if (raw.ok === true && isMediaId(raw.mediaId))
|
|
14975
|
-
return { ok: true, mediaId: raw.mediaId, source, ...extra };
|
|
14976
|
-
if (raw.ok === false && typeof raw.error === "string" && ERRORS.includes(raw.error))
|
|
14977
|
-
return { ok: false, error: raw.error, source, ...extra };
|
|
14978
|
-
return null;
|
|
14979
|
-
}
|
|
14980
|
-
function resultText(message) {
|
|
14981
|
-
if (!Array.isArray(message.content)) return "";
|
|
14982
|
-
return message.content.map(
|
|
14983
|
-
(part) => part?.type === "text" && typeof part.text === "string" ? part.text : ""
|
|
14984
|
-
).join("");
|
|
14985
|
-
}
|
|
14986
|
-
function sendImageItems(messages) {
|
|
14987
|
-
const out = [];
|
|
14988
|
-
const seen = /* @__PURE__ */ new Set();
|
|
14989
|
-
for (const message of messages) {
|
|
14990
|
-
if (out.length >= SEND_IMAGE_PER_REPLY) break;
|
|
14991
|
-
if (message.role !== "toolResult" || message.toolName !== "send_image") continue;
|
|
14992
|
-
const item = parseSendImageResult(resultText(message));
|
|
14993
|
-
if (!item) continue;
|
|
14994
|
-
if (item.ok) {
|
|
14995
|
-
if (seen.has(item.mediaId)) continue;
|
|
14996
|
-
seen.add(item.mediaId);
|
|
14997
|
-
}
|
|
14998
|
-
out.push(item);
|
|
14999
|
-
}
|
|
15000
|
-
return out;
|
|
15001
|
-
}
|
|
15002
16040
|
const NATIVE_TIMEOUT_MS = 9e4;
|
|
15003
16041
|
const EXA_TIMEOUT_MS = 3e4;
|
|
15004
16042
|
const EXA_MCP_URL = "https://mcp.exa.ai/mcp?tools=web_search_exa";
|
|
@@ -15989,73 +17027,73 @@ function builtinPresets() {
|
|
|
15989
17027
|
return builtinCache;
|
|
15990
17028
|
}
|
|
15991
17029
|
export {
|
|
15992
|
-
|
|
17030
|
+
replacePersonaParagraph as $,
|
|
15993
17031
|
AGENT_WORKER_CRASH_FILE as A,
|
|
15994
|
-
|
|
15995
|
-
|
|
15996
|
-
|
|
15997
|
-
|
|
15998
|
-
|
|
15999
|
-
|
|
16000
|
-
|
|
16001
|
-
|
|
16002
|
-
|
|
16003
|
-
|
|
16004
|
-
|
|
16005
|
-
|
|
16006
|
-
|
|
17032
|
+
buildReflectionsRecordedData as B,
|
|
17033
|
+
buildReflectionsConsolidatedData as C,
|
|
17034
|
+
buildObservationsDroppedData as D,
|
|
17035
|
+
readModelsDevCache as E,
|
|
17036
|
+
version as F,
|
|
17037
|
+
parseModelDirectorySnapshot as G,
|
|
17038
|
+
findCatalogModelById as H,
|
|
17039
|
+
findModelsDevModel as I,
|
|
17040
|
+
mergeCatalogEntry as J,
|
|
17041
|
+
resolveCustomModelCapabilities as K,
|
|
17042
|
+
closestMatchHint as L,
|
|
17043
|
+
mcpTimeoutMsOrDefault as M,
|
|
17044
|
+
oneLine as N,
|
|
16007
17045
|
OM_OBSERVATIONS_RECORDED as O,
|
|
16008
17046
|
PatchMutationUncertainError as P,
|
|
16009
|
-
|
|
16010
|
-
|
|
16011
|
-
|
|
16012
|
-
|
|
16013
|
-
|
|
17047
|
+
mcpNamespaceName as Q,
|
|
17048
|
+
assignMcpToolNames as R,
|
|
17049
|
+
MCP_OAUTH_REFRESH_SKEW_MS as S,
|
|
17050
|
+
mcpOAuthFingerprint as T,
|
|
17051
|
+
DEFAULT_MCP_CONNECT_TIMEOUT_MS as U,
|
|
16014
17052
|
VIRTUAL_PROVIDER_ID as V,
|
|
16015
|
-
|
|
16016
|
-
|
|
16017
|
-
|
|
16018
|
-
|
|
16019
|
-
|
|
17053
|
+
DEFAULT_MCP_CALL_TIMEOUT_MS as W,
|
|
17054
|
+
isXaiChatModelId as X,
|
|
17055
|
+
transcriptMessages as Y,
|
|
17056
|
+
projectMessage as Z,
|
|
17057
|
+
ensureAccountProvider as _,
|
|
16020
17058
|
APPLY_PATCH_PROMPT_GUIDELINES as a,
|
|
16021
|
-
|
|
16022
|
-
|
|
16023
|
-
|
|
16024
|
-
|
|
16025
|
-
|
|
17059
|
+
positiveContextWindow as a$,
|
|
17060
|
+
takeSnapshotTail as a0,
|
|
17061
|
+
attachBackgroundCommandHooks as a1,
|
|
17062
|
+
ForegroundDetachedError as a2,
|
|
17063
|
+
withFileBackedExec as a3,
|
|
16026
17064
|
withHardenedEnv as a4,
|
|
16027
17065
|
withDetachableExec as a5,
|
|
16028
17066
|
ELEVATE_ASKPASS_ENV as a6,
|
|
16029
17067
|
buildElevatedCommand as a7,
|
|
16030
17068
|
ELEVATE_DECLINED_MARKER as a8,
|
|
16031
17069
|
ELEVATE_TIMED_OUT_MARKER as a9,
|
|
16032
|
-
|
|
16033
|
-
|
|
16034
|
-
|
|
16035
|
-
|
|
16036
|
-
|
|
16037
|
-
|
|
16038
|
-
|
|
16039
|
-
|
|
16040
|
-
|
|
16041
|
-
|
|
16042
|
-
|
|
16043
|
-
|
|
16044
|
-
|
|
16045
|
-
|
|
16046
|
-
|
|
16047
|
-
|
|
16048
|
-
|
|
16049
|
-
|
|
16050
|
-
|
|
16051
|
-
|
|
16052
|
-
|
|
16053
|
-
|
|
16054
|
-
|
|
16055
|
-
|
|
16056
|
-
|
|
16057
|
-
|
|
16058
|
-
|
|
17070
|
+
resolveOauthCatalogModel as aA,
|
|
17071
|
+
createSshExecutor as aB,
|
|
17072
|
+
partitionMcpNamespaces as aC,
|
|
17073
|
+
CodemodeHost as aD,
|
|
17074
|
+
ApprovalGate as aE,
|
|
17075
|
+
HUMAN_REQUEST_TIMEOUT_MS as aF,
|
|
17076
|
+
TodoStaleReminder as aG,
|
|
17077
|
+
CoworkerIdleReminder as aH,
|
|
17078
|
+
createUnifiedSubagentTool as aI,
|
|
17079
|
+
workflowPresetRoots as aJ,
|
|
17080
|
+
withMandatoryApproval as aK,
|
|
17081
|
+
createBrowserTools as aL,
|
|
17082
|
+
withNavigateApproval as aM,
|
|
17083
|
+
createMemoryTools as aN,
|
|
17084
|
+
withComputerApproval as aO,
|
|
17085
|
+
createComputerTool as aP,
|
|
17086
|
+
withApproval as aQ,
|
|
17087
|
+
listWorkflowPresets as aR,
|
|
17088
|
+
createTaskTools as aS,
|
|
17089
|
+
BrowserInvoker as aT,
|
|
17090
|
+
MemoryInvoker as aU,
|
|
17091
|
+
PlanController as aV,
|
|
17092
|
+
ComputerInvoker as aW,
|
|
17093
|
+
AskManager as aX,
|
|
17094
|
+
createAskTool as aY,
|
|
17095
|
+
snapshotMainConversation as aZ,
|
|
17096
|
+
lastAssistantText as a_,
|
|
16059
17097
|
ELEVATE_TIMEOUT_MS as aa,
|
|
16060
17098
|
ELEVATE_UNAVAILABLE_MARKER as ab,
|
|
16061
17099
|
expandSkillCommands as ac,
|
|
@@ -16067,222 +17105,189 @@ export {
|
|
|
16067
17105
|
readImageView as ai,
|
|
16068
17106
|
resolveRoots as aj,
|
|
16069
17107
|
systemImageRoots as ak,
|
|
16070
|
-
|
|
16071
|
-
|
|
16072
|
-
|
|
16073
|
-
|
|
16074
|
-
|
|
16075
|
-
|
|
16076
|
-
|
|
16077
|
-
|
|
16078
|
-
|
|
16079
|
-
|
|
16080
|
-
|
|
16081
|
-
|
|
16082
|
-
|
|
16083
|
-
|
|
16084
|
-
|
|
17108
|
+
prependTurnNote as al,
|
|
17109
|
+
describeSubagentModels as am,
|
|
17110
|
+
resolveWorkflowPresetArgs as an,
|
|
17111
|
+
extractWriteTargetPaths as ao,
|
|
17112
|
+
programTokens as ap,
|
|
17113
|
+
RESTART_CHECKPOINT_ARCHIVE as aq,
|
|
17114
|
+
takeRestartCheckpoint as ar,
|
|
17115
|
+
BackgroundTaskManager as as,
|
|
17116
|
+
takeDetachedTasksManifest as at,
|
|
17117
|
+
DETACHED_TASKS_FILE as au,
|
|
17118
|
+
sweepOrphanRuns as av,
|
|
17119
|
+
takeInterruptedTasks as aw,
|
|
17120
|
+
INTERRUPTED_TASKS_FILE as ax,
|
|
17121
|
+
isDeferredMcp as ay,
|
|
17122
|
+
providerIdOfAccountKey as az,
|
|
16085
17123
|
emptyUsage as b,
|
|
16086
|
-
|
|
16087
|
-
|
|
16088
|
-
|
|
16089
|
-
|
|
16090
|
-
|
|
16091
|
-
|
|
16092
|
-
|
|
16093
|
-
|
|
16094
|
-
|
|
16095
|
-
|
|
16096
|
-
|
|
16097
|
-
|
|
16098
|
-
|
|
16099
|
-
|
|
16100
|
-
|
|
16101
|
-
|
|
16102
|
-
|
|
16103
|
-
|
|
16104
|
-
|
|
16105
|
-
|
|
16106
|
-
|
|
16107
|
-
|
|
16108
|
-
|
|
16109
|
-
|
|
16110
|
-
|
|
16111
|
-
|
|
16112
|
-
|
|
16113
|
-
|
|
16114
|
-
|
|
16115
|
-
|
|
16116
|
-
|
|
16117
|
-
|
|
16118
|
-
|
|
16119
|
-
|
|
16120
|
-
|
|
16121
|
-
|
|
16122
|
-
|
|
16123
|
-
|
|
16124
|
-
|
|
16125
|
-
|
|
16126
|
-
|
|
16127
|
-
|
|
16128
|
-
|
|
16129
|
-
|
|
16130
|
-
|
|
16131
|
-
|
|
16132
|
-
|
|
16133
|
-
|
|
16134
|
-
|
|
16135
|
-
|
|
16136
|
-
|
|
16137
|
-
|
|
16138
|
-
|
|
16139
|
-
|
|
16140
|
-
|
|
16141
|
-
|
|
16142
|
-
|
|
16143
|
-
|
|
16144
|
-
|
|
16145
|
-
|
|
16146
|
-
|
|
16147
|
-
|
|
16148
|
-
|
|
16149
|
-
|
|
17124
|
+
OVERVIEW_TAIL_MESSAGES as b$,
|
|
17125
|
+
foregroundCommandTimeoutMs as b0,
|
|
17126
|
+
buildTurnDigest as b1,
|
|
17127
|
+
buildTurnReport as b2,
|
|
17128
|
+
awaitChecklist as b3,
|
|
17129
|
+
settleChecklist as b4,
|
|
17130
|
+
parseJsonFromAssistant as b5,
|
|
17131
|
+
validateAgainstSchema as b6,
|
|
17132
|
+
appendYieldJson as b7,
|
|
17133
|
+
appendCappedLog as b8,
|
|
17134
|
+
AGENT_COMPACTION_LOG as b9,
|
|
17135
|
+
CODEMODE_TOOL_NAME as bA,
|
|
17136
|
+
prepareCodemodeInput as bB,
|
|
17137
|
+
ANTIGRAVITY_PROVIDER_ID as bC,
|
|
17138
|
+
antigravityProviderConfig as bD,
|
|
17139
|
+
DEVIN_PROVIDER_ID as bE,
|
|
17140
|
+
devinProviderConfig as bF,
|
|
17141
|
+
QODER_PROVIDER_ID as bG,
|
|
17142
|
+
qoderProviderConfig as bH,
|
|
17143
|
+
QODER_CN_PROVIDER_ID as bI,
|
|
17144
|
+
installCodexLinkedRefresh as bJ,
|
|
17145
|
+
isHeadlessRun as bK,
|
|
17146
|
+
withBackground as bL,
|
|
17147
|
+
withProtectedFloor as bM,
|
|
17148
|
+
loadWorkflowPreset as bN,
|
|
17149
|
+
cloneModelsDevOauthModel as bO,
|
|
17150
|
+
withWriteScope as bP,
|
|
17151
|
+
withWritePreflight as bQ,
|
|
17152
|
+
validateApplyPatchTargets as bR,
|
|
17153
|
+
withAgentRead as bS,
|
|
17154
|
+
extractEditTargetPath as bT,
|
|
17155
|
+
buildSshShellCommand as bU,
|
|
17156
|
+
resolveSshControlPath as bV,
|
|
17157
|
+
sshPasswordEnv as bW,
|
|
17158
|
+
getApplyPatchPaths as bX,
|
|
17159
|
+
RESTART_CHECKPOINT_ENV as bY,
|
|
17160
|
+
isVirtualRef as bZ,
|
|
17161
|
+
findVirtualModel as b_,
|
|
17162
|
+
restartGate as ba,
|
|
17163
|
+
writeRestartCheckpoint as bb,
|
|
17164
|
+
RESTART_CHECKPOINT_FILE as bc,
|
|
17165
|
+
writeDetachedTasksManifest as bd,
|
|
17166
|
+
killRunGroup as be,
|
|
17167
|
+
appendInterruptedTasks as bf,
|
|
17168
|
+
describeTitleModel as bg,
|
|
17169
|
+
buildRollingTitleUserText as bh,
|
|
17170
|
+
buildInitialTitleUserText as bi,
|
|
17171
|
+
ROLLING_TITLE_SYSTEM_PROMPT as bj,
|
|
17172
|
+
TITLE_SYSTEM_PROMPT as bk,
|
|
17173
|
+
extractTitle as bl,
|
|
17174
|
+
titleRejectReason as bm,
|
|
17175
|
+
resolveChildReasoning as bn,
|
|
17176
|
+
pickChildReasoningOverride as bo,
|
|
17177
|
+
fitChildReasoningToModel as bp,
|
|
17178
|
+
createWebTools as bq,
|
|
17179
|
+
createTodoTool as br,
|
|
17180
|
+
withPlanGate as bs,
|
|
17181
|
+
createSubmitPlanTool as bt,
|
|
17182
|
+
titleSummaryTimeoutMs as bu,
|
|
17183
|
+
splitTurnNotes as bv,
|
|
17184
|
+
resolveHarnessSkillRoots as bw,
|
|
17185
|
+
approvalReviewResultExtension as bx,
|
|
17186
|
+
readHarnessRuleFiles as by,
|
|
17187
|
+
createProjectSettingsManager as bz,
|
|
16150
17188
|
charsToTokens as c,
|
|
16151
|
-
|
|
16152
|
-
|
|
16153
|
-
|
|
16154
|
-
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
|
|
16159
|
-
|
|
16160
|
-
|
|
16161
|
-
|
|
16162
|
-
|
|
16163
|
-
|
|
16164
|
-
|
|
16165
|
-
|
|
16166
|
-
|
|
16167
|
-
|
|
16168
|
-
|
|
16169
|
-
|
|
16170
|
-
|
|
16171
|
-
|
|
16172
|
-
|
|
16173
|
-
|
|
16174
|
-
|
|
16175
|
-
|
|
16176
|
-
|
|
16177
|
-
|
|
16178
|
-
|
|
16179
|
-
|
|
16180
|
-
|
|
16181
|
-
|
|
16182
|
-
|
|
16183
|
-
|
|
16184
|
-
|
|
16185
|
-
|
|
16186
|
-
|
|
16187
|
-
|
|
16188
|
-
|
|
16189
|
-
|
|
16190
|
-
|
|
16191
|
-
|
|
16192
|
-
|
|
16193
|
-
|
|
16194
|
-
|
|
16195
|
-
|
|
16196
|
-
|
|
16197
|
-
|
|
16198
|
-
|
|
16199
|
-
|
|
16200
|
-
|
|
16201
|
-
|
|
16202
|
-
|
|
16203
|
-
|
|
16204
|
-
|
|
16205
|
-
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
|
|
16212
|
-
|
|
16213
|
-
|
|
16214
|
-
|
|
17189
|
+
deleteCustomWorkflowPreset as c$,
|
|
17190
|
+
OVERVIEW_BYTE_BUDGET as c0,
|
|
17191
|
+
syncAccountProviders as c1,
|
|
17192
|
+
expandOauthCatalog as c2,
|
|
17193
|
+
supportsMultipleAccounts as c3,
|
|
17194
|
+
parseCodexAuthJson as c4,
|
|
17195
|
+
CODEX_PROVIDER_ID as c5,
|
|
17196
|
+
nextAccountKey as c6,
|
|
17197
|
+
sanitizeUpstreamBody as c7,
|
|
17198
|
+
defaultCodexAuthPath as c8,
|
|
17199
|
+
ordinalOfAccountKey as c9,
|
|
17200
|
+
withPrivacyMask as cA,
|
|
17201
|
+
withUserEntryIds as cB,
|
|
17202
|
+
SNAPSHOT_TAIL_MESSAGES as cC,
|
|
17203
|
+
splitUnattendedPrefix as cD,
|
|
17204
|
+
userTextWithoutSkills as cE,
|
|
17205
|
+
defaultImageRoots as cF,
|
|
17206
|
+
classifyCommand as cG,
|
|
17207
|
+
probeImageView as cH,
|
|
17208
|
+
inImageViewScope as cI,
|
|
17209
|
+
IMAGE_VIEW_MAX_BYTES as cJ,
|
|
17210
|
+
validateScopedFile as cK,
|
|
17211
|
+
readImageFacts as cL,
|
|
17212
|
+
resolveSshTarget as cM,
|
|
17213
|
+
checkPassed as cN,
|
|
17214
|
+
checkFailureText as cO,
|
|
17215
|
+
parseVirtualClassifier as cP,
|
|
17216
|
+
VIRTUAL_CLASSIFIER_DEFAULT_TIMEOUT_MS as cQ,
|
|
17217
|
+
EnsoSafeJournal as cR,
|
|
17218
|
+
isSecretFilePath as cS,
|
|
17219
|
+
isUnderSecretDirectory as cT,
|
|
17220
|
+
codemodeToolSnapshot as cU,
|
|
17221
|
+
estimateToolsTotal as cV,
|
|
17222
|
+
listCustomWorkflowPresets as cW,
|
|
17223
|
+
listBuiltinWorkflowPresets as cX,
|
|
17224
|
+
readCustomWorkflowPreset as cY,
|
|
17225
|
+
parseWorkflowPresetDraft as cZ,
|
|
17226
|
+
saveCustomWorkflowPreset as c_,
|
|
17227
|
+
sanitizeOauthLabel as ca,
|
|
17228
|
+
parseAntigravityApiKey as cb,
|
|
17229
|
+
fetchAntigravityUsage as cc,
|
|
17230
|
+
fetchDevinUsage as cd,
|
|
17231
|
+
DEFAULT_PERSONA_PROMPT as ce,
|
|
17232
|
+
parseAgentWorkerCrash as cf,
|
|
17233
|
+
AGENT_WORKER_EXIT_LOG as cg,
|
|
17234
|
+
elevatedCommandOf as ch,
|
|
17235
|
+
parseRestartCheckpoint as ci,
|
|
17236
|
+
startOauthCallbackServer as cj,
|
|
17237
|
+
MODELS_DEV_URL as ck,
|
|
17238
|
+
writeModelsDevCache as cl,
|
|
17239
|
+
parseModelsDevPayload as cm,
|
|
17240
|
+
MODELS_DEV_CACHE_NAME as cn,
|
|
17241
|
+
modelsDevIsFresh as co,
|
|
17242
|
+
withModelsDevOauthModels as cp,
|
|
17243
|
+
appUserImageDirs as cq,
|
|
17244
|
+
describeAgentWorkerExit as cr,
|
|
17245
|
+
directMemberRef as cs,
|
|
17246
|
+
materializeProviders as ct,
|
|
17247
|
+
parseVirtualModels as cu,
|
|
17248
|
+
classifierProviderFor as cv,
|
|
17249
|
+
classifierBaseUrlFor as cw,
|
|
17250
|
+
pickModelCapabilityOverrides as cx,
|
|
17251
|
+
canBeVirtualMember as cy,
|
|
17252
|
+
mcpTimeoutsForSpawn as cz,
|
|
16215
17253
|
skillOccupancyText as d,
|
|
16216
|
-
|
|
16217
|
-
|
|
16218
|
-
|
|
16219
|
-
|
|
16220
|
-
|
|
16221
|
-
|
|
16222
|
-
|
|
16223
|
-
|
|
16224
|
-
|
|
16225
|
-
|
|
16226
|
-
|
|
16227
|
-
|
|
16228
|
-
|
|
16229
|
-
|
|
16230
|
-
|
|
16231
|
-
|
|
16232
|
-
buildRemoteCommand as dG,
|
|
16233
|
-
listProjectCodeSources as dH,
|
|
16234
|
-
positiveFiniteNumber as dI,
|
|
16235
|
-
mergeFetchedOauthModels as dJ,
|
|
16236
|
-
supportedProjectThinkingLevels as dK,
|
|
16237
|
-
buildSshPtyArgs as dL,
|
|
16238
|
-
ENSO_HEADLESS_RUN_ENV as dM,
|
|
16239
|
-
projection as dN,
|
|
16240
|
-
classifyCommand as da,
|
|
16241
|
-
chunkMessageText as db,
|
|
16242
|
-
readableText as dc,
|
|
16243
|
-
projectReadableMessages as dd,
|
|
16244
|
-
probeImageView as de,
|
|
16245
|
-
validateScopedFile as df,
|
|
16246
|
-
IMAGE_VIEW_MAX_BYTES as dg,
|
|
16247
|
-
readImageFacts as dh,
|
|
16248
|
-
resolveSshTarget as di,
|
|
16249
|
-
checkPassed as dj,
|
|
16250
|
-
checkFailureText as dk,
|
|
16251
|
-
parseVirtualClassifier as dl,
|
|
16252
|
-
VIRTUAL_CLASSIFIER_DEFAULT_TIMEOUT_MS as dm,
|
|
16253
|
-
isSecretFilePath as dn,
|
|
16254
|
-
isUnderSecretDirectory as dp,
|
|
16255
|
-
codemodeToolSnapshot as dq,
|
|
16256
|
-
estimateToolsTotal as dr,
|
|
16257
|
-
listCustomWorkflowPresets as ds,
|
|
16258
|
-
listBuiltinWorkflowPresets as dt,
|
|
16259
|
-
readCustomWorkflowPreset as du,
|
|
16260
|
-
parseWorkflowPresetDraft as dv,
|
|
16261
|
-
saveCustomWorkflowPreset as dw,
|
|
16262
|
-
deleteCustomWorkflowPreset as dx,
|
|
16263
|
-
parseBtwPromptRequest as dy,
|
|
16264
|
-
btwModelCandidates as dz,
|
|
17254
|
+
parseBtwPromptRequest as d0,
|
|
17255
|
+
btwModelCandidates as d1,
|
|
17256
|
+
parseBtwAbortRequest as d2,
|
|
17257
|
+
parseBtwSpawnRequest as d3,
|
|
17258
|
+
BTW_DISABLED_TOOLS as d4,
|
|
17259
|
+
parseBtwDisposeRequest as d5,
|
|
17260
|
+
isHumanRequestTimeout as d6,
|
|
17261
|
+
buildSshExecArgs as d7,
|
|
17262
|
+
buildRemoteCommand as d8,
|
|
17263
|
+
listProjectCodeSources as d9,
|
|
17264
|
+
positiveFiniteNumber as da,
|
|
17265
|
+
mergeFetchedOauthModels as db,
|
|
17266
|
+
supportedProjectThinkingLevels as dc,
|
|
17267
|
+
buildSshPtyArgs as dd,
|
|
17268
|
+
ENSO_HEADLESS_RUN_ENV as de,
|
|
17269
|
+
projection as df,
|
|
16265
17270
|
executeApplyPatch as e,
|
|
16266
17271
|
estimateToolTokens as f,
|
|
16267
17272
|
estimateSkillTokens as g,
|
|
16268
17273
|
estimateInstructionTokens as h,
|
|
16269
17274
|
OM_REFLECTIONS_RECORDED as i,
|
|
16270
17275
|
isObservationsRecordedData as j,
|
|
16271
|
-
|
|
16272
|
-
|
|
16273
|
-
|
|
17276
|
+
isReflectionsRecordedData as k,
|
|
17277
|
+
isReflectionsConsolidatedData as l,
|
|
17278
|
+
isObservationsDroppedData as m,
|
|
16274
17279
|
normalizeApplyPatchArguments as n,
|
|
16275
|
-
|
|
17280
|
+
OM_REFLECTIONS_CONSOLIDATED as o,
|
|
16276
17281
|
providerKeyFor as p,
|
|
16277
|
-
|
|
16278
|
-
|
|
16279
|
-
shellQuote as s,
|
|
17282
|
+
OM_OBSERVATIONS_DROPPED as q,
|
|
17283
|
+
OM_FOLDED as r,
|
|
17284
|
+
shellQuote$1 as s,
|
|
16280
17285
|
toolOccupancyText as t,
|
|
16281
|
-
|
|
16282
|
-
|
|
16283
|
-
|
|
16284
|
-
|
|
16285
|
-
|
|
16286
|
-
|
|
17286
|
+
isMemoryDetails as u,
|
|
17287
|
+
isObservationsRecordedEntry as v,
|
|
17288
|
+
isReflectionsRecordedEntry as w,
|
|
17289
|
+
isReflectionsConsolidatedEntry as x,
|
|
17290
|
+
isObservationsDroppedEntry as y,
|
|
17291
|
+
buildObservationsRecordedData as z
|
|
16287
17292
|
};
|
|
16288
|
-
//# sourceMappingURL=workflowPresets-
|
|
17293
|
+
//# sourceMappingURL=workflowPresets-C2T1BzA2.js.map
|