@ensocode/server 0.3.2 → 0.3.3
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/out/phone/assets/{abnfDiagram-VCTEODGH-7wNFPVNX.js → abnfDiagram-VCTEODGH-CLgfII9z.js} +1 -1
- package/out/phone/assets/architecture-7GRP2DOG-CQOPTv6S.js +1 -0
- package/out/phone/assets/{architectureDiagram-5GKGNRK7-CnuIop2x.js → architectureDiagram-5GKGNRK7-I2RDn32D.js} +1 -1
- package/out/phone/assets/{blockDiagram-I7D4REHJ-JVET2iOX.js → blockDiagram-I7D4REHJ-D5xNQZkS.js} +1 -1
- package/out/phone/assets/{c4Diagram-7LVT6UL2-BLFmpm8Y.js → c4Diagram-7LVT6UL2-CRKpzdlA.js} +1 -1
- package/out/phone/assets/channel-DdXebl9x.js +1 -0
- package/out/phone/assets/{chunk-4HAMMTFA-t_CWzvX0.js → chunk-4HAMMTFA-CcezrqKz.js} +1 -1
- package/out/phone/assets/{chunk-75Z2AOVW-Ck9s4XbN.js → chunk-75Z2AOVW-DDCXp4y1.js} +1 -1
- package/out/phone/assets/{chunk-DU6HZSFF-Clg-W8ZP.js → chunk-DU6HZSFF-CjWveEkB.js} +1 -1
- package/out/phone/assets/{chunk-F27PBJKO-Dg6DF7tm.js → chunk-F27PBJKO-Bgl_xI02.js} +1 -1
- package/out/phone/assets/{chunk-GMAD6QVW-tyN1lr56.js → chunk-GMAD6QVW-EmL8nOme.js} +1 -1
- package/out/phone/assets/{chunk-GVQU2GXP-Cp6zlp3q.js → chunk-GVQU2GXP-Dox_nphF.js} +1 -1
- package/out/phone/assets/{chunk-IMKFNOWR-DivN0qgp.js → chunk-IMKFNOWR-BapGpI4S.js} +1 -1
- package/out/phone/assets/{chunk-L3NEJ4N5-H6AVmtE_.js → chunk-L3NEJ4N5-Cq_UZI8A.js} +1 -1
- package/out/phone/assets/{chunk-OSK3NFVY-D8Gtw0_S.js → chunk-OSK3NFVY-2VVlErAd.js} +1 -1
- package/out/phone/assets/{chunk-P2QGCYS3-RZSHAUZq.js → chunk-P2QGCYS3-Cci-G-p1.js} +1 -1
- package/out/phone/assets/{chunk-POPQ4Y6H-BVS8pZqz.js → chunk-POPQ4Y6H-CJ47EOfE.js} +1 -1
- package/out/phone/assets/{chunk-PWAF6VOD-D7FryQWf.js → chunk-PWAF6VOD-D9dLdFqC.js} +1 -1
- package/out/phone/assets/{chunk-SHT3W25Y-DGdqMpPQ.js → chunk-SHT3W25Y-BlGSiWZn.js} +1 -1
- package/out/phone/assets/{chunk-SVP7TREG-BwyiT08_.js → chunk-SVP7TREG-C0zdsa_A.js} +1 -1
- package/out/phone/assets/{chunk-TICWLB2K-CY7mq27-.js → chunk-TICWLB2K-DAQW8nQU.js} +1 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-BCctWEp1.js +1 -0
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-BCctWEp1.js +1 -0
- package/out/phone/assets/{cynefin-OW5HDTMX-ep90c-ad.js → cynefin-OW5HDTMX-_zsx5mdV.js} +1 -1
- package/out/phone/assets/{cynefinDiagram-5FMLGOSQ-M8djyXi6.js → cynefinDiagram-5FMLGOSQ-Cww-w0ex.js} +1 -1
- package/out/phone/assets/{dagre-GXQ25YYZ-Qp6_rUFB.js → dagre-GXQ25YYZ-C0i7DPqX.js} +1 -1
- package/out/phone/assets/desk-mfuEW2n4.js +2 -0
- package/out/phone/assets/{diagram-S7CK7UJ4-78nJmih8.js → diagram-S7CK7UJ4-Bx-G5hYz.js} +1 -1
- package/out/phone/assets/{diagram-UQ7AKVKN-DK3Lux6Z.js → diagram-UQ7AKVKN-DaTblkjV.js} +1 -1
- package/out/phone/assets/{diagram-VSXAHHWV-8uHrV5vL.js → diagram-VSXAHHWV-gmN2e1b4.js} +1 -1
- package/out/phone/assets/{diagram-VX7I27RA-DM2jP_ep.js → diagram-VX7I27RA-WYtRtOo8.js} +1 -1
- package/out/phone/assets/{diagram-Z3DM3KII-Dk6weE7F.js → diagram-Z3DM3KII-Cr6uUB5B.js} +1 -1
- package/out/phone/assets/{ebnfDiagram-PWID7BFC-CcOU0Q-s.js → ebnfDiagram-PWID7BFC-BCicfvpA.js} +1 -1
- package/out/phone/assets/{erDiagram-RLTQ6QDP-Cv4zHR88.js → erDiagram-RLTQ6QDP-B3QlJvfQ.js} +1 -1
- package/out/phone/assets/eventmodeling-NTZA5JFV-BtfapP6M.js +1 -0
- package/out/phone/assets/flowDiagram-HODETNUW-BsyiyBtD.js +1 -0
- package/out/phone/assets/{ganttDiagram-EL5Y4UJY-DpMAd_jd.js → ganttDiagram-EL5Y4UJY-LYy2mfCh.js} +1 -1
- package/out/phone/assets/{gitGraph-4MIJSDKK-CeZWGC9r.js → gitGraph-4MIJSDKK-dT22Z2jG.js} +1 -1
- package/out/phone/assets/{gitGraphDiagram-WWUBYQGX-6QsSrkNy.js → gitGraphDiagram-WWUBYQGX-DHNdY57l.js} +1 -1
- package/out/phone/assets/{info-A6RAGUB7-C-8QwtyE.js → info-A6RAGUB7-nIu8NSOs.js} +1 -1
- package/out/phone/assets/{infoDiagram-27XIBGKW-BEywxx6y.js → infoDiagram-27XIBGKW-DGkWZIMT.js} +1 -1
- package/out/phone/assets/{ishikawaDiagram-5VMMS53U-Dv5MWe8O.js → ishikawaDiagram-5VMMS53U-C8EPXru-.js} +1 -1
- package/out/phone/assets/{journeyDiagram-3NMN7TZE-rZqFk8KG.js → journeyDiagram-3NMN7TZE-Dyd9L3l3.js} +1 -1
- package/out/phone/assets/{kanban-definition-UXKFOSKX-Vbp8P778.js → kanban-definition-UXKFOSKX-DehTYcsL.js} +1 -1
- package/out/phone/assets/{line-DtO-RzWq.js → line-Db4SulF4.js} +1 -1
- package/out/phone/assets/main-Dv9ve8mT.css +1 -0
- package/out/phone/assets/main-uMMbioCA.js +1638 -0
- package/out/phone/assets/{mermaid-parser.core-CZ9_GWM0.js → mermaid-parser.core-D7h_8WV8.js} +3 -3
- package/out/phone/assets/{mermaid.core-B15T44DF.js → mermaid.core-Dw_E5kj4.js} +4 -4
- package/out/phone/assets/{mindmap-definition-YA3MSWOX-BgFUJmH3.js → mindmap-definition-YA3MSWOX-_5Mxqxsy.js} +1 -1
- package/out/phone/assets/{packet-AYTQ26CC--RETlRVk.js → packet-AYTQ26CC-_cgeMDdN.js} +1 -1
- package/out/phone/assets/{pegDiagram-XKGWAZYB-D7jmN93W.js → pegDiagram-XKGWAZYB-BhBwaNEr.js} +1 -1
- package/out/phone/assets/{pie-WAS4IAKB-CxG1AbYJ.js → pie-WAS4IAKB-BepY80_0.js} +1 -1
- package/out/phone/assets/{pieDiagram-E7YTZNPT-CHxSdknk.js → pieDiagram-E7YTZNPT-CQQgqmI8.js} +1 -1
- package/out/phone/assets/{quadrantDiagram-AXDQQJYC-707LGShZ.js → quadrantDiagram-AXDQQJYC-DEEatC1J.js} +1 -1
- package/out/phone/assets/{radar-RG4KPBEZ-BBg9aR2Q.js → radar-RG4KPBEZ-BqsiI_qQ.js} +1 -1
- package/out/phone/assets/{railroad-74A4TZTK-BvqQaIGQ.js → railroad-74A4TZTK-C_2pEUjD.js} +1 -1
- package/out/phone/assets/railroad-abnf-HS5TGJTU-TmODpceI.js +1 -0
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-BTCjNR9u.js +1 -0
- package/out/phone/assets/railroad-peg-WCYAUIDC-DjhKNo8j.js +1 -0
- package/out/phone/assets/{railroadDiagram-O6MQD6OU-BQUOk6Jm.js → railroadDiagram-O6MQD6OU-B7786u7W.js} +1 -1
- package/out/phone/assets/{requirementDiagram-BXWQKSXE-ByuJLR7x.js → requirementDiagram-BXWQKSXE-Ci3b5uwm.js} +1 -1
- package/out/phone/assets/{sankeyDiagram-P5KCCOFB-CaWA3qV1.js → sankeyDiagram-P5KCCOFB-PwT2gJjH.js} +1 -1
- package/out/phone/assets/{sequenceDiagram-WJ2MYXX4--wDiyJo9.js → sequenceDiagram-WJ2MYXX4-H6sgB5RI.js} +1 -1
- package/out/phone/assets/{stateDiagram-D77RDMKH-ScVywISP.js → stateDiagram-D77RDMKH-BxyRe7OB.js} +1 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-Cncmf_cL.js +1 -0
- package/out/phone/assets/{storage-DBoRTPSQ.js → storage-D9RW_4__.js} +1 -1
- package/out/phone/assets/{swimlanes-42K2YHIH-Da4TbCnQ.js → swimlanes-42K2YHIH-DWT3f1Hk.js} +1 -1
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-DAahG4fH.js +8 -0
- package/out/phone/assets/{timeline-definition-24CTP7MA-Csp8wyPz.js → timeline-definition-24CTP7MA-D67esSVY.js} +1 -1
- package/out/phone/assets/{treeView-Q6P3EWNA-DP_TpAnB.js → treeView-Q6P3EWNA-BTIfu3Qr.js} +1 -1
- package/out/phone/assets/{treemap-WGGIJYW6-CDX7X9Iz.js → treemap-WGGIJYW6-DkPf6LQc.js} +1 -1
- package/out/phone/assets/{vennDiagram-4TSXK5OY-DU4FDr9s.js → vennDiagram-4TSXK5OY-DRMRxJ4f.js} +1 -1
- package/out/phone/assets/{wardley-WFR3VGLG-DJY3i8km.js → wardley-WFR3VGLG-hOvC_8-W.js} +1 -1
- package/out/phone/assets/{wardleyDiagram-VM6X3IG4-CDWkRMg4.js → wardleyDiagram-VM6X3IG4-a5aYRgrw.js} +1 -1
- package/out/phone/assets/{xychartDiagram-S5SC5T6Z-DAWohWCi.js → xychartDiagram-S5SC5T6Z-DXjoRFDL.js} +1 -1
- package/out/phone/desk.html +2 -2
- package/out/phone/index.html +3 -3
- package/out/renderer/assets/{abnfDiagram-VCTEODGH-CyBOQPqT.js → abnfDiagram-VCTEODGH-DhskujJf.js} +1 -1
- package/out/renderer/assets/{arc-JLdYPu0k.js → arc-BcW67t47.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-5GKGNRK7-Bq5gy8K8.js → architectureDiagram-5GKGNRK7-D-x057Ia.js} +1 -1
- package/out/renderer/assets/{blockDiagram-I7D4REHJ-Bno0lw2B.js → blockDiagram-I7D4REHJ-DR3sZkhW.js} +1 -1
- package/out/renderer/assets/{c4Diagram-7LVT6UL2-BC6INPz6.js → c4Diagram-7LVT6UL2-CQ4lScWs.js} +1 -1
- package/out/renderer/assets/channel-CudRig7z.js +1 -0
- package/out/renderer/assets/{chunk-2Q5K7J3B-CcyqDHha.js → chunk-2Q5K7J3B-CtT0yqF3.js} +1 -1
- package/out/renderer/assets/{chunk-5VM5RSS4-QSbyABj3.js → chunk-5VM5RSS4-DlCfddrY.js} +1 -1
- package/out/renderer/assets/{chunk-F27PBJKO-4574JVSg.js → chunk-F27PBJKO-BAJ5dGzo.js} +1 -1
- package/out/renderer/assets/{chunk-IMKFNOWR-DCaKjC49.js → chunk-IMKFNOWR-Dlah_YbP.js} +1 -1
- package/out/renderer/assets/{chunk-JWPE2WC7-CbFsKOIM.js → chunk-JWPE2WC7-BiXd3nUZ.js} +1 -1
- package/out/renderer/assets/{chunk-POPQ4Y6H-B6j8RfR6.js → chunk-POPQ4Y6H-Ch86i4EJ.js} +1 -1
- package/out/renderer/assets/{chunk-SVP7TREG-kRAl0a5G.js → chunk-SVP7TREG-z3inDV-H.js} +1 -1
- package/out/renderer/assets/{chunk-TICWLB2K-BgG8vTk6.js → chunk-TICWLB2K-B34A2AKD.js} +1 -1
- package/out/renderer/assets/{chunk-XXDRQBXY-DdqB8mBq.js → chunk-XXDRQBXY-Do_L0wRR.js} +1 -1
- package/out/renderer/assets/classDiagram-ZZMXUADV-DL20WkD0.js +1 -0
- package/out/renderer/assets/classDiagram-v2-VYDZK3BY-DL20WkD0.js +1 -0
- package/out/renderer/assets/{cose-bilkent-JH36ORCC-HfctEoii.js → cose-bilkent-JH36ORCC-BQraKmgl.js} +1 -1
- package/out/renderer/assets/{cynefin-OW5HDTMX-BNigpbGU.js → cynefin-OW5HDTMX-BwixoR4r.js} +1 -1
- package/out/renderer/assets/{cynefinDiagram-5FMLGOSQ-CL-lRXZ7.js → cynefinDiagram-5FMLGOSQ-BLTBma3J.js} +1 -1
- package/out/renderer/assets/{cytoscape-fcose-B40eUKiT.js → cytoscape-fcose-BRpJ5tyq.js} +1 -1
- package/out/renderer/assets/{dagre-GXQ25YYZ-D7VwJTHe.js → dagre-GXQ25YYZ-aWsjA_wn.js} +1 -1
- package/out/renderer/assets/{diagram-S7CK7UJ4-CAp3JWMB.js → diagram-S7CK7UJ4-Cur2zK4q.js} +1 -1
- package/out/renderer/assets/{diagram-UQ7AKVKN-H_c4KXAy.js → diagram-UQ7AKVKN-DlrY8YcD.js} +1 -1
- package/out/renderer/assets/{diagram-VSXAHHWV-CsEX84Cq.js → diagram-VSXAHHWV-BBdjreqR.js} +1 -1
- package/out/renderer/assets/{diagram-VX7I27RA-ebIy3O1D.js → diagram-VX7I27RA-XiWMdc8S.js} +1 -1
- package/out/renderer/assets/{diagram-Z3DM3KII-BtVfEzv9.js → diagram-Z3DM3KII-CBB5leat.js} +1 -1
- package/out/renderer/assets/{ebnfDiagram-PWID7BFC-C25YK-UV.js → ebnfDiagram-PWID7BFC-nl8RPo8j.js} +1 -1
- package/out/renderer/assets/{erDiagram-RLTQ6QDP-1imAb8Go.js → erDiagram-RLTQ6QDP-C_oaG80x.js} +1 -1
- package/out/renderer/assets/{flowDiagram-HODETNUW-OwceYbhd.js → flowDiagram-HODETNUW-nDoVZFS7.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-EL5Y4UJY-DDoN4Uki.js → ganttDiagram-EL5Y4UJY-DOrcuM3Q.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-WWUBYQGX-yrrX43-g.js → gitGraphDiagram-WWUBYQGX-D_DB3jro.js} +1 -1
- package/out/renderer/assets/globals-Bkw7iiQG.css +1 -0
- package/out/renderer/assets/globals-D1ocHHQV.js +2533 -0
- package/out/renderer/assets/index-Cm5iq85v.js +117 -0
- package/out/renderer/assets/{infoDiagram-27XIBGKW-BoYY6yGv.js → infoDiagram-27XIBGKW-BbBrANxo.js} +1 -1
- package/out/renderer/assets/{ishikawaDiagram-5VMMS53U-BbtGOrLg.js → ishikawaDiagram-5VMMS53U-7UlfWlWV.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-3NMN7TZE-BWTb58Kr.js → journeyDiagram-3NMN7TZE-CJP9bosH.js} +1 -1
- package/out/renderer/assets/{kanban-definition-UXKFOSKX-BSN2oIEH.js → kanban-definition-UXKFOSKX-D772kW7T.js} +1 -1
- package/out/renderer/assets/{layout-k2BpK8-6.js → layout-BzVfJEvx.js} +1 -1
- package/out/renderer/assets/{linear-DFArNkXT.js → linear-DBjhr05m.js} +1 -1
- package/out/renderer/assets/{mermaid.core-DthanE8x.js → mermaid.core-CJpNSowm.js} +5 -5
- package/out/renderer/assets/{mindmap-definition-YA3MSWOX-BhETDMxE.js → mindmap-definition-YA3MSWOX-C2oqlH5E.js} +1 -1
- package/out/renderer/assets/{pegDiagram-XKGWAZYB-B9w_o-Iv.js → pegDiagram-XKGWAZYB-CcZ8Hae-.js} +1 -1
- package/out/renderer/assets/{pieDiagram-E7YTZNPT-klH2bEkC.js → pieDiagram-E7YTZNPT-DTw-_k2D.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-AXDQQJYC-DerYxAqw.js → quadrantDiagram-AXDQQJYC-D5eX0DO7.js} +1 -1
- package/out/renderer/assets/{railroadDiagram-O6MQD6OU-D4EFSRd0.js → railroadDiagram-O6MQD6OU-DzpBB_Re.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-BXWQKSXE-C4O9MABZ.js → requirementDiagram-BXWQKSXE-UbOUXLgl.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-P5KCCOFB-ILgR3far.js → sankeyDiagram-P5KCCOFB-jRbXLLsa.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-WJ2MYXX4-SHHY6jka.js → sequenceDiagram-WJ2MYXX4-s0WBQQPf.js} +1 -1
- package/out/renderer/assets/settings-DxYo7s4h.js +34 -0
- package/out/renderer/assets/{sizeCapture-INFHLROL-CX9hC7Eu.js → sizeCapture-INFHLROL-DvUs5rDx.js} +1 -1
- package/out/renderer/assets/{stateDiagram-D77RDMKH-CZ1zq3yT.js → stateDiagram-D77RDMKH-C1_V497y.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-C9dfLXR8.js +1 -0
- package/out/renderer/assets/{swimlanes-42K2YHIH-BxCpUxk0.js → swimlanes-42K2YHIH-BulPeZ6y.js} +1 -1
- package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-LXwy6qGO.js +8 -0
- package/out/renderer/assets/{timeline-definition-24CTP7MA-BZrSf5qo.js → timeline-definition-24CTP7MA-gQ5OygZn.js} +1 -1
- package/out/renderer/assets/{vennDiagram-4TSXK5OY-g01Cyb5O.js → vennDiagram-4TSXK5OY-A8QyA5Ix.js} +1 -1
- package/out/renderer/assets/{wardleyDiagram-VM6X3IG4-Bt_RS10y.js → wardleyDiagram-VM6X3IG4-CfP6E41T.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-S5SC5T6Z-DuwmVyP6.js → xychartDiagram-S5SC5T6Z-DTG5UHh7.js} +1 -1
- package/out/renderer/index.html +3 -3
- package/out/renderer/plugin-view.html +27 -0
- package/out/renderer/settings.html +4 -4
- package/out/renderer/web-preload.js +1 -1
- package/out/server/agent.js +831 -77
- package/out/server/chunks/{agent-D37_gFfr.js → agent-BhQn6jGA.js} +330 -137
- package/out/server/chunks/{gpuBackendInstall-FekvL7Rv.js → gpuBackendInstall-CdExgjGi.js} +4 -4
- package/out/server/chunks/{loadProvider-CSeEHHnd.js → loadProvider-BnkyjMSW.js} +2 -2
- package/out/server/chunks/{manifest-Bj0K5UgY.js → manifest-2odvnxjZ.js} +97 -19
- package/out/server/chunks/{workflowPresets-DBDQwf8e.js → workflowPresets-DqSsjOj6.js} +725 -460
- package/out/server/index.js +2958 -554
- package/out/server/plugin-host.js +38 -6
- package/package.json +1 -1
- package/out/phone/assets/architecture-7GRP2DOG-_byK4-L4.js +0 -1
- package/out/phone/assets/channel-Dgd_LVvp.js +0 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-C83rE770.js +0 -1
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-C83rE770.js +0 -1
- package/out/phone/assets/desk-DOJjOIls.js +0 -2
- package/out/phone/assets/eventmodeling-NTZA5JFV-7mnBgbcg.js +0 -1
- package/out/phone/assets/flowDiagram-HODETNUW-sLsydHyr.js +0 -1
- package/out/phone/assets/main-CX13EK2l.js +0 -1636
- package/out/phone/assets/main-DZEEX8Mv.css +0 -1
- package/out/phone/assets/railroad-abnf-HS5TGJTU-Cm1qeEMZ.js +0 -1
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-MFhpnZ_W.js +0 -1
- package/out/phone/assets/railroad-peg-WCYAUIDC-DCsilESk.js +0 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-D1LtnHXy.js +0 -1
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-C2SWpfVX.js +0 -8
- package/out/renderer/assets/channel-C0GtgNRj.js +0 -1
- package/out/renderer/assets/classDiagram-ZZMXUADV-DUyds1A3.js +0 -1
- package/out/renderer/assets/classDiagram-v2-VYDZK3BY-DUyds1A3.js +0 -1
- package/out/renderer/assets/globals-C6gFTVZy.css +0 -1
- package/out/renderer/assets/globals-CYDlkaHa.js +0 -2509
- package/out/renderer/assets/index-D1rFnBbz.js +0 -116
- package/out/renderer/assets/settings-DB_fAikP.js +0 -33
- package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-NCbr7wNQ.js +0 -1
- package/out/renderer/assets/swimlanesDiagram-VR7AAH4N--ymqRTT2.js +0 -8
package/out/server/agent.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import path, { join, posix, dirname } from "node:path";
|
|
2
|
-
import { i as isApprovalReviewReason, p as parseApprovalAllowThreshold, a as isProbability, C as CONTEXT_OCCUPANCY_BUCKETS, b as CONTEXT_PART_ITEMS, M as MODEL_API_KINDS, c as MODEL_REASONING_OVERRIDES, d as MODEL_THINKING_LEVEL_OVERRIDES, e as isCodexAccountKey, f as classifyCodexPoolFailure, g as isUuid, h as isChildInterceptEvent, P as PLUGIN_MESSAGE_TYPE, j as CONTEXT_USAGE_BUCKETS, A as AGENT_END_TEXT_MAX, k as MaskReportBuilder, l as PRODUCT_SURFACE_INVENTORY, w as workspaceBranchChangedNote, D as DEFAULT_MAX_ACTIVE_COWORKERS, m as DEFAULT_AUTO_RETRY_LIMIT, n as isSameChildSessionIdentity,
|
|
3
|
-
import { i as isCursorModel, a as attachCursorBridgeToSession, b as indexCursorTools, l as loadCursorProvider, C as CURSOR_PROVIDER_ID, c as installPiCursorExecHook } from "./chunks/loadProvider-
|
|
4
|
-
import { setGlobalDispatcher, EnvHttpProxyAgent, Agent } from "undici";
|
|
2
|
+
import { i as isApprovalReviewReason, p as parseApprovalAllowThreshold, a as isProbability, C as CONTEXT_OCCUPANCY_BUCKETS, b as CONTEXT_PART_ITEMS, M as MODEL_API_KINDS, r as resolvePiProviderBaseUrl, c as MODEL_REASONING_OVERRIDES, d as MODEL_THINKING_LEVEL_OVERRIDES, e as isCodexAccountKey, f as classifyCodexPoolFailure, g as isUuid, h as isChildInterceptEvent, P as PLUGIN_MESSAGE_TYPE, j as CONTEXT_USAGE_BUCKETS, A as AGENT_END_TEXT_MAX, k as MaskReportBuilder, l as PRODUCT_SURFACE_INVENTORY, w as workspaceBranchChangedNote, D as DEFAULT_MAX_ACTIVE_COWORKERS, m as DEFAULT_AUTO_RETRY_LIMIT, n as isSameChildSessionIdentity, o as resolveCompactStrategy, q as DEFAULT_SSH_TIMEOUT_SECONDS, s as PLAN_ENTRY_TYPE, t as autoRetryOverrides, u as parseAgentSessionCustomEntry, E as ENSO_LOCKED_PROFILE, S as STALE_SESSION_ERROR, v as splitPlanPrefix, x as parsePlanMessage, y as isClassifierOnlyProvider, z as isOauthAccountPool, B as resolveEditMode, F as EMPTY_PLAN_STATE, G as mergeMaskReports, H as PRIVACY_MASK_ENTRY, I as parseAgentCommand } from "./chunks/agent-BhQn6jGA.js";
|
|
3
|
+
import { i as isCursorModel, a as attachCursorBridgeToSession, b as indexCursorTools, l as loadCursorProvider, C as CURSOR_PROVIDER_ID, c as installPiCursorExecHook } from "./chunks/loadProvider-BnkyjMSW.js";
|
|
4
|
+
import { setGlobalDispatcher, EnvHttpProxyAgent, Agent, Pool, FormData as FormData$1, fetch as fetch$1 } from "undici";
|
|
5
5
|
import { spawn, execFile } from "node:child_process";
|
|
6
6
|
import { createHash, randomUUID, createHmac, randomBytes } from "node:crypto";
|
|
7
|
-
import fs, { statSync, mkdirSync, existsSync, readFileSync, appendFileSync, unlinkSync, renameSync, rmSync, writeFileSync, realpathSync } from "node:fs";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import fs, { statSync, mkdirSync, existsSync, readFileSync, appendFileSync, unlinkSync, renameSync, rmSync, writeFileSync, constants, realpathSync } from "node:fs";
|
|
8
|
+
import { getSupportedThinkingLevels, clampThinkingLevel, createAssistantMessageEventStream, isRetryableAssistantError } from "@earendil-works/pi-ai";
|
|
9
|
+
import { estimateTokens, serializeConversation as serializeConversation$1, convertToLlm, buildSessionContext, getAgentDir, defineTool, createEditToolDefinition, VIRTUAL_MODEL_STATE_ENTRY, createPowerShellToolDefinition, createBashToolDefinition, createLocalPowerShellOperations, createLocalBashOperations, stripFrontmatter, createGrepToolDefinition, createAgentSession, SessionManager, ModelRuntime, DefaultResourceLoader, createWriteToolDefinition, createReadToolDefinition, createFindToolDefinition, createLsToolDefinition, createSyntheticSourceInfo } from "@earendil-works/pi-coding-agent";
|
|
10
|
+
import { P as PatchMutationUncertainError, n as normalizeApplyPatchArguments, A as APPLY_PATCH_PROMPT_GUIDELINES, e as executeApplyPatch, a as emptyUsage, s as shellQuote, k as killProcessTree, c as charsToTokens, t as toolOccupancyText, b as skillOccupancyText, d as estimateToolTokens, f as estimateSkillTokens, g as estimateInstructionTokens, V as VIRTUAL_PROVIDER_ID, p as providerKeyFor, O as OM_OBSERVATIONS_RECORDED, h as OM_REFLECTIONS_RECORDED, i as isObservationsRecordedData, j as isReflectionsRecordedData, l as isReflectionsConsolidatedData, m as isObservationsDroppedData, o as OM_REFLECTIONS_CONSOLIDATED, q as OM_OBSERVATIONS_DROPPED, r as OM_FOLDED, u as isMemoryDetails, v as isObservationsRecordedEntry, w as isReflectionsRecordedEntry, x as isReflectionsConsolidatedEntry, y as isObservationsDroppedEntry, z as buildObservationsRecordedData, B as buildReflectionsRecordedData, C as buildReflectionsConsolidatedData, D as buildObservationsDroppedData, E as version, F as parseModelDirectorySnapshot, G as findCatalogModelById, H as resolveCustomModelCapabilities, I as closestMatchHint, J as mcpTimeoutMsOrDefault, K as oneLine$1, L as mcpNamespaceName, M as assignMcpToolNames, N as MCP_OAUTH_REFRESH_SKEW_MS, Q as mcpOAuthFingerprint, R as DEFAULT_MCP_CONNECT_TIMEOUT_MS, S as DEFAULT_MCP_CALL_TIMEOUT_MS, T as isXaiChatModelId, U as transcriptMessages, W as projectMessage, X as ensureAccountProvider, Y as takeSnapshotTail, Z as attachBackgroundCommandHooks, _ as ForegroundDetachedError, $ as withHardenedEnv, a0 as childProfileShell, a1 as withDetachableExec, a2 as expandSkillCommands, a3 as CODEMODE_FORBIDDEN_TOOLS, a4 as normalizeTaskCheck, a5 as CAPABILITY_CATALOG, a6 as validateFetchUrl, a7 as isPublicAddress, a8 as throwUnlessAllowed, a9 as SEND_IMAGE_CAPTION_MAX, aa as SEND_IMAGE_PER_REPLY, ab as sendImageItems, ac as prependTurnNote, ad as describeSubagentModels, ae as resolveWorkflowPresetArgs, af as extractWriteTargetPaths, ag as programTokens, ah as BackgroundTaskManager, ai as isDeferredMcp, aj as providerIdOfAccountKey, ak as resolveOauthCatalogModel, al as createSshExecutor, am as partitionMcpNamespaces, an as CodemodeHost, ao as ApprovalGate, ap as HUMAN_REQUEST_TIMEOUT_MS, aq as TodoStaleReminder, ar as CoworkerIdleReminder, as as createUnifiedSubagentTool, at as workflowPresetRoots, au as createBrowserTools, av as withNavigateApproval, aw as createMemoryTools, ax as withComputerApproval, ay as createComputerTool, az as withApproval, aA as listWorkflowPresets, aB as createTaskTools, aC as BrowserInvoker, aD as MemoryInvoker, aE as PlanController, aF as ComputerInvoker, aG as AskManager, aH as createAskTool, aI as lastAssistantText$1, aJ as positiveContextWindow, aK as foregroundCommandTimeoutMs, aL as buildTurnDigest, aM as parseJsonFromAssistant, aN as validateAgainstSchema, aO as appendYieldJson, aP as describeTitleModel, aQ as buildRollingTitleUserText, aR as buildInitialTitleUserText, aS as ROLLING_TITLE_SYSTEM_PROMPT, aT as TITLE_SYSTEM_PROMPT, aU as extractTitle, aV as titleRejectReason, aW as WORKSPACE_WRITE_TOOL_ID, aX as resolveChildReasoning, aY as pickChildReasoningOverride, aZ as EnsoSafeJournal, a_ as createWebTools, a$ as createTodoTool, b0 as withPlanGate, b1 as createSubmitPlanTool, b2 as titleSummaryTimeoutMs, b3 as splitUnattendedPrefix, b4 as resolveHarnessSkillRoots, b5 as approvalReviewResultExtension, b6 as readHarnessRuleFiles, b7 as replacePersonaParagraph, b8 as createProjectSettingsManager, b9 as ANTIGRAVITY_PROVIDER_ID, ba as antigravityProviderConfig, bb as DEVIN_PROVIDER_ID, bc as devinProviderConfig, bd as installCodexLinkedRefresh, be as withBackground, bf as withProtectedFloor, bg as ENSO_SYSTEM_PROMPT, bh as loadWorkflowPreset, bi as withWriteScope, bj as withWritePreflight, bk as validateApplyPatchTargets, bl as withAgentRead, bm as buildSshShellCommand, bn as resolveSshControlPath, bo as sshPasswordEnv } from "./chunks/workflowPresets-DqSsjOj6.js";
|
|
11
|
+
import { rm, mkdtemp, readFile, stat, readdir, mkdir, lstat, realpath, open, unlink } from "node:fs/promises";
|
|
11
12
|
import "node:buffer";
|
|
12
|
-
import { tmpdir, homedir } from "node:os";
|
|
13
|
-
import { getSupportedThinkingLevels, clampThinkingLevel, createAssistantMessageEventStream } from "@earendil-works/pi-ai";
|
|
13
|
+
import os, { tmpdir, homedir } from "node:os";
|
|
14
14
|
import { agentLoop } from "@earendil-works/pi-agent-core";
|
|
15
15
|
import { Type } from "typebox";
|
|
16
16
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -21,6 +21,8 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
|
21
21
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
22
22
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
23
23
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
24
|
+
import { lookup } from "node:dns/promises";
|
|
25
|
+
import { isIP, BlockList } from "node:net";
|
|
24
26
|
import { createRequire } from "node:module";
|
|
25
27
|
import { QuickJS, JSException } from "quickjs-wasi";
|
|
26
28
|
import "node:events";
|
|
@@ -29,8 +31,6 @@ import "node:stream";
|
|
|
29
31
|
import "node:zlib";
|
|
30
32
|
import "yaml";
|
|
31
33
|
import "node:util";
|
|
32
|
-
import "node:dns/promises";
|
|
33
|
-
import "node:net";
|
|
34
34
|
import "@mozilla/readability";
|
|
35
35
|
import "linkedom";
|
|
36
36
|
import "turndown";
|
|
@@ -775,6 +775,7 @@ function ensureAssistantUsage(messages) {
|
|
|
775
775
|
return patched;
|
|
776
776
|
}
|
|
777
777
|
const HOT_BUILTIN_TOOL_IDS = [
|
|
778
|
+
"image_generation",
|
|
778
779
|
"subagent",
|
|
779
780
|
"workflow",
|
|
780
781
|
"todo",
|
|
@@ -6888,12 +6889,12 @@ function pathOfCall(call) {
|
|
|
6888
6889
|
return typeof path2 === "string" && path2.length > 0 ? path2 : void 0;
|
|
6889
6890
|
}
|
|
6890
6891
|
function imagePlaceholder(block, source) {
|
|
6891
|
-
const
|
|
6892
|
+
const mime2 = block.mimeType ?? "image";
|
|
6892
6893
|
const recapture = /\bcomputer\b/i.test(source) || /screenshot/i.test(source);
|
|
6893
6894
|
const hint = recapture ? "already seen earlier; take a new screenshot if you need the pixels — click coordinates belong to the latest screenshot" : "already seen earlier in this conversation; re-read the file if you need it again";
|
|
6894
6895
|
return {
|
|
6895
6896
|
type: "text",
|
|
6896
|
-
text: `[image omitted from context: ${
|
|
6897
|
+
text: `[image omitted from context: ${mime2}${source ? `, ${source}` : ""} — ${hint}]`
|
|
6897
6898
|
};
|
|
6898
6899
|
}
|
|
6899
6900
|
function replaceImages(message, source) {
|
|
@@ -6984,13 +6985,16 @@ function pruneHistoricalImages(messages) {
|
|
|
6984
6985
|
if ((m.toolName ?? call?.name) === "computer") computerHits.push(i);
|
|
6985
6986
|
}
|
|
6986
6987
|
const keepComputer = new Set(computerHits.slice(-1));
|
|
6988
|
+
const latestGenerated = messages.findLastIndex(
|
|
6989
|
+
(message) => message.role === "toolResult" && hasImage(message) && (message.toolName === "ImageGen" || message.toolName === "codemode" && isRecord$2(message.details) && Array.isArray(message.details.generatedImages) && message.details.generatedImages.length > 0)
|
|
6990
|
+
);
|
|
6987
6991
|
let out;
|
|
6988
6992
|
for (let i = 0; i < lastUserIndex; i++) {
|
|
6989
6993
|
const m = messages[i];
|
|
6990
6994
|
if (!m || !hasImage(m)) continue;
|
|
6991
6995
|
let replaced;
|
|
6992
6996
|
if (m.role === "toolResult") {
|
|
6993
|
-
if (keepComputer.has(i)) continue;
|
|
6997
|
+
if (keepComputer.has(i) || i === latestGenerated) continue;
|
|
6994
6998
|
const call = typeof m.toolCallId === "string" ? calls.get(m.toolCallId) : void 0;
|
|
6995
6999
|
const tool = m.toolName ?? call?.name ?? "tool";
|
|
6996
7000
|
const path2 = pathOfCall(call);
|
|
@@ -7545,9 +7549,33 @@ function normalizeEditArguments(input) {
|
|
|
7545
7549
|
rejectUnparsedEditsJson(next);
|
|
7546
7550
|
return next === args.edits ? args : { ...args, edits: next };
|
|
7547
7551
|
}
|
|
7552
|
+
const NOT_FOUND = /Could not find (?:edits\[(\d+)\]|the exact text) in /;
|
|
7553
|
+
const NOT_UNIQUE = /Found \d+ occurrences of (?:edits\[(\d+)\]|the text) in /;
|
|
7554
|
+
function lineNumbersOf(text, needle) {
|
|
7555
|
+
const lines = [];
|
|
7556
|
+
for (let index = text.indexOf(needle); index !== -1; index = text.indexOf(needle, index + 1)) {
|
|
7557
|
+
lines.push(text.slice(0, index).split("\n").length);
|
|
7558
|
+
if (lines.length >= 10) break;
|
|
7559
|
+
}
|
|
7560
|
+
return lines;
|
|
7561
|
+
}
|
|
7562
|
+
async function editFailureHint(error, params, cwd, read) {
|
|
7563
|
+
const match = NOT_FOUND.exec(error.message) ?? NOT_UNIQUE.exec(error.message);
|
|
7564
|
+
const args = params;
|
|
7565
|
+
const oldText = args?.edits?.[Number(match?.[1] ?? 0)]?.oldText;
|
|
7566
|
+
if (!match || typeof args?.path !== "string" || typeof oldText !== "string") return "";
|
|
7567
|
+
const requested = args.path.replace(/^@/, "").replace(/^~(?=$|\/)/, os.homedir());
|
|
7568
|
+
const text = (await read(path.resolve(cwd, requested))).toString("utf8").replace(/\r\n/g, "\n");
|
|
7569
|
+
if (NOT_FOUND.test(error.message)) {
|
|
7570
|
+
return closestMatchHint(text.split("\n"), oldText.replace(/\r\n/g, "\n").split("\n"));
|
|
7571
|
+
}
|
|
7572
|
+
const lines = lineNumbersOf(text, oldText.replace(/\r\n/g, "\n"));
|
|
7573
|
+
return lines.length > 1 ? `It occurs at lines ${lines.join(", ")}; include neighbouring lines to pick one.` : "";
|
|
7574
|
+
}
|
|
7548
7575
|
function createNormalizedEditTool(cwd, options) {
|
|
7549
7576
|
const base = createEditToolDefinition(cwd, options);
|
|
7550
7577
|
const prepareBase = base.prepareArguments;
|
|
7578
|
+
const read = options?.operations?.readFile ?? ((absolutePath) => readFile(absolutePath));
|
|
7551
7579
|
return {
|
|
7552
7580
|
...base,
|
|
7553
7581
|
description: `${base.description} ${EDIT_REPLACE_GUIDELINE}${EDIT_REPLACE_EXAMPLES}`,
|
|
@@ -7563,7 +7591,16 @@ function createNormalizedEditTool(cwd, options) {
|
|
|
7563
7591
|
}),
|
|
7564
7592
|
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
7565
7593
|
const prepared = prepareBase ? prepareBase(normalizeEditArguments(params)) : normalizeEditArguments(params);
|
|
7566
|
-
|
|
7594
|
+
try {
|
|
7595
|
+
return await base.execute(toolCallId, prepared, signal, onUpdate, ctx);
|
|
7596
|
+
} catch (error) {
|
|
7597
|
+
if (!(error instanceof Error)) throw error;
|
|
7598
|
+
const hint = await editFailureHint(error, prepared, ctx?.cwd || cwd, read).catch(() => "");
|
|
7599
|
+
if (!hint) throw error;
|
|
7600
|
+
throw new Error(`${error.message}
|
|
7601
|
+
|
|
7602
|
+
${hint}`);
|
|
7603
|
+
}
|
|
7567
7604
|
}
|
|
7568
7605
|
};
|
|
7569
7606
|
}
|
|
@@ -8642,13 +8679,26 @@ function silentTurnRecoveryExtension(onRecovery) {
|
|
|
8642
8679
|
}
|
|
8643
8680
|
};
|
|
8644
8681
|
}
|
|
8645
|
-
function
|
|
8682
|
+
function latestVisibleAssistant(session) {
|
|
8646
8683
|
const projection = session.sessionManager.buildSessionProjection();
|
|
8647
8684
|
const latestVisible = [...projection.entries].reverse().find((entry) => entry.messages.length > 0);
|
|
8648
8685
|
if (latestVisible?.sourceEntry.type !== "message" || latestVisible.sourceEntry.message.role !== "assistant" || latestVisible.messages.at(-1)?.role !== "assistant") {
|
|
8649
|
-
return
|
|
8686
|
+
return void 0;
|
|
8650
8687
|
}
|
|
8651
|
-
|
|
8688
|
+
return { id: latestVisible.sourceEntry.id, message: latestVisible.sourceEntry.message };
|
|
8689
|
+
}
|
|
8690
|
+
function editLatestAssistantForRetry(session) {
|
|
8691
|
+
const latest = latestVisibleAssistant(session);
|
|
8692
|
+
if (!latest) return false;
|
|
8693
|
+
session.sessionManager.appendContextEdit(latest.id, null);
|
|
8694
|
+
session.refreshContext();
|
|
8695
|
+
return true;
|
|
8696
|
+
}
|
|
8697
|
+
const UNFINISHED_STOP_REASONS = /* @__PURE__ */ new Set(["error", "aborted", "toolUse"]);
|
|
8698
|
+
function editUnfinishedAssistantForResume(session) {
|
|
8699
|
+
const latest = latestVisibleAssistant(session);
|
|
8700
|
+
if (!latest || !UNFINISHED_STOP_REASONS.has(String(latest.message.stopReason))) return false;
|
|
8701
|
+
session.sessionManager.appendContextEdit(latest.id, null);
|
|
8652
8702
|
session.refreshContext();
|
|
8653
8703
|
return true;
|
|
8654
8704
|
}
|
|
@@ -9066,6 +9116,107 @@ function oauthPoolRecoveryExtension(select, onSelected) {
|
|
|
9066
9116
|
}
|
|
9067
9117
|
};
|
|
9068
9118
|
}
|
|
9119
|
+
const SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist", "out", "build", "coverage", "target"]);
|
|
9120
|
+
const MAX_DIRS = 3e3;
|
|
9121
|
+
const MAX_DEPTH = 10;
|
|
9122
|
+
const MAX_HINTS = 5;
|
|
9123
|
+
const exists = (target) => stat(target).then(
|
|
9124
|
+
() => true,
|
|
9125
|
+
() => false
|
|
9126
|
+
);
|
|
9127
|
+
const listDir = (dir) => readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
9128
|
+
function distance(left, right) {
|
|
9129
|
+
const row = Array.from({ length: right.length + 1 }, (_, index) => index);
|
|
9130
|
+
for (let i = 1; i <= left.length; i++) {
|
|
9131
|
+
let previous = row[0];
|
|
9132
|
+
row[0] = i;
|
|
9133
|
+
for (let j = 1; j <= right.length; j++) {
|
|
9134
|
+
const current = row[j];
|
|
9135
|
+
row[j] = Math.min(
|
|
9136
|
+
row[j] + 1,
|
|
9137
|
+
row[j - 1] + 1,
|
|
9138
|
+
previous + (left[i - 1] === right[j - 1] ? 0 : 1)
|
|
9139
|
+
);
|
|
9140
|
+
previous = current;
|
|
9141
|
+
}
|
|
9142
|
+
}
|
|
9143
|
+
return row[right.length];
|
|
9144
|
+
}
|
|
9145
|
+
function similar(wanted, name) {
|
|
9146
|
+
const a = wanted.toLowerCase();
|
|
9147
|
+
const b = name.toLowerCase();
|
|
9148
|
+
if (a === b) return true;
|
|
9149
|
+
if (a.length >= 3 && (b.includes(a) || a.includes(b)) && Math.abs(a.length - b.length) <= 3)
|
|
9150
|
+
return true;
|
|
9151
|
+
return distance(a, b) <= Math.max(1, Math.floor(a.length / 4));
|
|
9152
|
+
}
|
|
9153
|
+
async function findByName(root, name) {
|
|
9154
|
+
const found = [];
|
|
9155
|
+
let queue = [root];
|
|
9156
|
+
let visited = 0;
|
|
9157
|
+
for (let depth = 0; depth <= MAX_DEPTH && queue.length > 0; depth++) {
|
|
9158
|
+
const next = [];
|
|
9159
|
+
for (const dir of queue) {
|
|
9160
|
+
if (++visited > MAX_DIRS) return found;
|
|
9161
|
+
for (const entry of await listDir(dir)) {
|
|
9162
|
+
const full = path.join(dir, entry.name);
|
|
9163
|
+
if (entry.name === name) found.push(full);
|
|
9164
|
+
if (entry.isDirectory() && !entry.name.startsWith(".") && !SKIP_DIRS.has(entry.name))
|
|
9165
|
+
next.push(full);
|
|
9166
|
+
}
|
|
9167
|
+
if (found.length >= MAX_HINTS) return found;
|
|
9168
|
+
}
|
|
9169
|
+
queue = next;
|
|
9170
|
+
}
|
|
9171
|
+
return found;
|
|
9172
|
+
}
|
|
9173
|
+
async function suggestPaths(requested, cwd) {
|
|
9174
|
+
const target = path.resolve(cwd, requested);
|
|
9175
|
+
let base = path.dirname(target);
|
|
9176
|
+
while (!await exists(base)) {
|
|
9177
|
+
const parent = path.dirname(base);
|
|
9178
|
+
if (parent === base) return [];
|
|
9179
|
+
base = parent;
|
|
9180
|
+
}
|
|
9181
|
+
const remaining = path.relative(base, target).split(path.sep);
|
|
9182
|
+
const hints = [];
|
|
9183
|
+
for (const entry of await listDir(base)) {
|
|
9184
|
+
if (!similar(remaining[0], entry.name)) continue;
|
|
9185
|
+
const candidate = path.join(base, entry.name, ...remaining.slice(1));
|
|
9186
|
+
if (remaining.length === 1 || await exists(candidate)) hints.push(candidate);
|
|
9187
|
+
}
|
|
9188
|
+
const within = (dir) => {
|
|
9189
|
+
const relative = path.relative(cwd, dir);
|
|
9190
|
+
return !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
9191
|
+
};
|
|
9192
|
+
hints.push(...await findByName(within(target) ? cwd : base, path.basename(target)));
|
|
9193
|
+
return [...new Set(hints)].slice(0, MAX_HINTS).map((hint) => within(hint) ? path.relative(cwd, hint) || "." : hint);
|
|
9194
|
+
}
|
|
9195
|
+
const MISSING = /ENOENT|Path not found|no such file or directory/;
|
|
9196
|
+
function withPathHints(definition, cwd) {
|
|
9197
|
+
return {
|
|
9198
|
+
...definition,
|
|
9199
|
+
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
9200
|
+
try {
|
|
9201
|
+
return await definition.execute(toolCallId, params, signal, onUpdate, ctx);
|
|
9202
|
+
} catch (error) {
|
|
9203
|
+
const requested = params?.path;
|
|
9204
|
+
if (!(error instanceof Error) || typeof requested !== "string" || !requested) throw error;
|
|
9205
|
+
if (error.message.includes("EISDIR")) {
|
|
9206
|
+
throw new Error(
|
|
9207
|
+
`${error.message}
|
|
9208
|
+
${requested} is a directory: list it with ls, or read a file inside it.`
|
|
9209
|
+
);
|
|
9210
|
+
}
|
|
9211
|
+
if (!MISSING.test(error.message)) throw error;
|
|
9212
|
+
const hints = await suggestPaths(requested, ctx?.cwd || cwd).catch(() => []);
|
|
9213
|
+
if (hints.length === 0) throw error;
|
|
9214
|
+
throw new Error(`${error.message}
|
|
9215
|
+
Similar existing paths: ${hints.join(", ")}`);
|
|
9216
|
+
}
|
|
9217
|
+
}
|
|
9218
|
+
};
|
|
9219
|
+
}
|
|
9069
9220
|
function pendingNotificationFile(dir, sessionId) {
|
|
9070
9221
|
return path.join(dir, `${encodeURIComponent(sessionId)}.json`);
|
|
9071
9222
|
}
|
|
@@ -11257,17 +11408,33 @@ ${firstText.text}`;
|
|
|
11257
11408
|
}
|
|
11258
11409
|
return { ...result, content };
|
|
11259
11410
|
}
|
|
11411
|
+
function withPendingReminders(result, registry2) {
|
|
11412
|
+
const pending = registry2.takePending();
|
|
11413
|
+
if (pending.length === 0) return void 0;
|
|
11414
|
+
const tagged = pending.map(
|
|
11415
|
+
(block) => block.includes("<system-reminder>") || block.includes("<background-task-update>") ? block : systemReminderBlock(block)
|
|
11416
|
+
);
|
|
11417
|
+
return prependToolText(result, tagged.join("\n\n"));
|
|
11418
|
+
}
|
|
11260
11419
|
function withSystemReminders(definition, registry2) {
|
|
11261
11420
|
return {
|
|
11262
11421
|
...definition,
|
|
11263
11422
|
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
11264
11423
|
const result = await definition.execute(toolCallId, params, signal, onUpdate, ctx);
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11424
|
+
return withPendingReminders(result, registry2) ?? result;
|
|
11425
|
+
}
|
|
11426
|
+
};
|
|
11427
|
+
}
|
|
11428
|
+
function systemReminderExtension(registry2) {
|
|
11429
|
+
return {
|
|
11430
|
+
name: "system-reminders",
|
|
11431
|
+
hidden: true,
|
|
11432
|
+
factory: (pi) => {
|
|
11433
|
+
pi.on("tool_result", (event) => {
|
|
11434
|
+
if (event.parentToolCallId) return;
|
|
11435
|
+
const next = withPendingReminders({ content: event.content, details: void 0 }, registry2);
|
|
11436
|
+
return next ? { content: next.content } : void 0;
|
|
11437
|
+
});
|
|
11271
11438
|
}
|
|
11272
11439
|
};
|
|
11273
11440
|
}
|
|
@@ -11428,6 +11595,23 @@ function createSessionCommandTool(input) {
|
|
|
11428
11595
|
const options = { operations: withDetachableExec(operations) };
|
|
11429
11596
|
return kind === "powershell" ? createPowerShellToolDefinition(input.cwd, options) : createBashToolDefinition(input.cwd, options);
|
|
11430
11597
|
}
|
|
11598
|
+
function skillChainExtension(skills) {
|
|
11599
|
+
return {
|
|
11600
|
+
name: "skill-chain",
|
|
11601
|
+
hidden: true,
|
|
11602
|
+
factory: (pi) => {
|
|
11603
|
+
pi.on("input", (event) => {
|
|
11604
|
+
if (!event.text.startsWith("/skill:")) return;
|
|
11605
|
+
const text = expandSkillCommands(
|
|
11606
|
+
event.text,
|
|
11607
|
+
(name) => skills().find((skill) => skill.name === name),
|
|
11608
|
+
(filePath) => stripFrontmatter(readFileSync(filePath, "utf-8"))
|
|
11609
|
+
);
|
|
11610
|
+
return text === event.text ? void 0 : { action: "transform", text };
|
|
11611
|
+
});
|
|
11612
|
+
}
|
|
11613
|
+
};
|
|
11614
|
+
}
|
|
11431
11615
|
const IMAGE_MIME_BY_EXTENSION = {
|
|
11432
11616
|
png: "image/png",
|
|
11433
11617
|
jpg: "image/jpeg",
|
|
@@ -11501,7 +11685,7 @@ function createRemoteOperations(executor) {
|
|
|
11501
11685
|
throw new Error(`${remotePath} is not readable/writable on remote host`);
|
|
11502
11686
|
}
|
|
11503
11687
|
};
|
|
11504
|
-
const
|
|
11688
|
+
const exists2 = async (absolutePath) => {
|
|
11505
11689
|
const result = await executor.exec(["test", "-e", toPosixRemotePath(absolutePath)]);
|
|
11506
11690
|
return result.code === 0;
|
|
11507
11691
|
};
|
|
@@ -11514,7 +11698,7 @@ function createRemoteOperations(executor) {
|
|
|
11514
11698
|
write: { writeFile, mkdir: mkdir2 },
|
|
11515
11699
|
edit: { readFile: readFile2, writeFile, access: accessReadWrite },
|
|
11516
11700
|
ls: {
|
|
11517
|
-
exists,
|
|
11701
|
+
exists: exists2,
|
|
11518
11702
|
stat: async (absolutePath) => {
|
|
11519
11703
|
const remotePath = toPosixRemotePath(absolutePath);
|
|
11520
11704
|
const result = await executor.exec(
|
|
@@ -11532,7 +11716,7 @@ function createRemoteOperations(executor) {
|
|
|
11532
11716
|
}
|
|
11533
11717
|
},
|
|
11534
11718
|
find: {
|
|
11535
|
-
exists,
|
|
11719
|
+
exists: exists2,
|
|
11536
11720
|
glob: async (pattern, cwd, options) => {
|
|
11537
11721
|
const root = toPosixRemotePath(cwd);
|
|
11538
11722
|
const result = await executor.exec(buildRemoteFindScript(pattern, root, options));
|
|
@@ -12024,12 +12208,9 @@ function withToolOutputBudget(definition, budget) {
|
|
|
12024
12208
|
}
|
|
12025
12209
|
function decorateSessionTools(tools, options) {
|
|
12026
12210
|
return tools.map((tool) => {
|
|
12027
|
-
const decorated =
|
|
12028
|
-
|
|
12029
|
-
|
|
12030
|
-
options.runaway
|
|
12031
|
-
),
|
|
12032
|
-
options.reminders
|
|
12211
|
+
const decorated = withRunawayGuard(
|
|
12212
|
+
withToolOutputBudget(withSourceReference(tool), options.budget),
|
|
12213
|
+
options.runaway
|
|
12033
12214
|
);
|
|
12034
12215
|
return {
|
|
12035
12216
|
...decorated,
|
|
@@ -12047,8 +12228,22 @@ function decorateSessionTools(tools, options) {
|
|
|
12047
12228
|
function normalizeDelegationParams(raw) {
|
|
12048
12229
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
12049
12230
|
const params = { ...raw };
|
|
12050
|
-
for (const key of [
|
|
12231
|
+
for (const key of [
|
|
12232
|
+
"id",
|
|
12233
|
+
"context",
|
|
12234
|
+
"cancel",
|
|
12235
|
+
"taskId",
|
|
12236
|
+
"deadlineMinutes",
|
|
12237
|
+
"keep",
|
|
12238
|
+
"waitFor",
|
|
12239
|
+
"note"
|
|
12240
|
+
])
|
|
12051
12241
|
if (params[key] === null) delete params[key];
|
|
12242
|
+
if (typeof params.note === "string") {
|
|
12243
|
+
const note = params.note.trim();
|
|
12244
|
+
if (note) params.note = note;
|
|
12245
|
+
else delete params.note;
|
|
12246
|
+
}
|
|
12052
12247
|
for (const key of ["cancel", "keep"]) {
|
|
12053
12248
|
if (params[key] === "true") params[key] = true;
|
|
12054
12249
|
if (params[key] === "false") params[key] = false;
|
|
@@ -12102,7 +12297,7 @@ function createDelegationTools(invoker, options = {}) {
|
|
|
12102
12297
|
return [
|
|
12103
12298
|
define(
|
|
12104
12299
|
"delegate",
|
|
12105
|
-
"Delegate a task to another member by name or id. Returns immediately; results arrive asynchronously. Context is truncated to 8000 characters. The delegation fails with a timeout after deadlineMinutes (capped by the member's own limit, 240 minutes by default). If the user stops or interrupts your current turn, delegations started in it are canceled unless keep is true. With check, the delegation passes only if one of the member's final tool outputs contains check.text; otherwise it ends as failed with 'acceptance check failed'." + (options.groupTasks ? ' Pass taskId (e.g. "#3") to hand a group board task to the member: the task becomes doing with them as assignee; when the delegation succeeds it goes to review (done directly only if the member created the task) for the task creator or a human to accept or reject with group_tasks; on cancel it returns to todo. If the run fails (error, timeout, interrupted, denied or check failed) the task becomes blocked (run failed) with the same assignee: delegate the same taskId to them again to retry, or to another member to hand it over. If the member reports they are blocked, the result has status="blocked" and says what they need; the task becomes blocked. Answer by delegating the same taskId to them again with the answer (they continue in the same session); if you are not sure of the answer, ask the human in the group instead of guessing. After 3 blocked reports in a row from the same member on a task, only a human can answer it (on the task card). The same member keeps one session per task: delegating a taskId they worked on before (retry, or adding to a task awaiting review) continues that session, so send only what is new; another member starts fresh with a summary of the earlier runs. Delegating a taskId that the same member is still queued on or running from this conversation appends to that run instead of starting a new one: the result returns once (with your latest turn; keep applies if either call set it), the deadline becomes the later of the two, check is ignored, and the reply has merged:true with delivery accepted (reached the member), deferred (runs later in the same run, or not confirmed within 10 seconds) or failed. Appends that do not finish before the run ends are listed in its result. From another conversation it is queued as the next run instead. Without taskId, a new board task is created for each delegate call (titled from the first line of task, created by you) and handled the same way; the result includes its taskId.' : ""),
|
|
12300
|
+
"Delegate a task to another member by name or id. Returns immediately; results arrive asynchronously. Context is truncated to 8000 characters. The delegation fails with a timeout after deadlineMinutes (capped by the member's own limit, 240 minutes by default). If the user stops or interrupts your current turn, delegations started in it are canceled unless keep is true. With check, the delegation passes only if one of the member's final tool outputs contains check.text; otherwise it ends as failed with 'acceptance check failed'." + (options.groupTasks ? (options.discussMode === true ? " In a group chat, handle discussion openly in the group with @mentions; delegate only long-running execution tasks that need a separate session." : "") + ' Pass taskId (e.g. "#3") to hand a group board task to the member: the task becomes doing with them as assignee; when the delegation succeeds it goes to review (done directly only if the member created the task) for the task creator or a human to accept or reject with group_tasks; on cancel it returns to todo. If the run fails (error, timeout, interrupted, denied or check failed) the task becomes blocked (run failed) with the same assignee: delegate the same taskId to them again to retry, or to another member to hand it over. If the member reports they are blocked, the result has status="blocked" and says what they need; the task becomes blocked. Answer by delegating the same taskId to them again with the answer (they continue in the same session); if you are not sure of the answer, ask the human in the group instead of guessing. After 3 blocked reports in a row from the same member on a task, only a human can answer it (on the task card). The same member keeps one session per task: delegating a taskId they worked on before (retry, or adding to a task awaiting review) continues that session, so send only what is new; another member starts fresh with a summary of the earlier runs. Delegating a taskId that the same member is still queued on or running from this conversation appends to that run instead of starting a new one: the result returns once (with your latest turn; keep applies if either call set it), the deadline becomes the later of the two, check is ignored, and the reply has merged:true with delivery accepted (reached the member), deferred (runs later in the same run, or not confirmed within 10 seconds) or failed. Appends that do not finish before the run ends are listed in its result. From another conversation it is queued as the next run instead. Without taskId, a new board task is created for each delegate call (titled from the first line of task, created by you) and handled the same way; the result includes its taskId.' : ""),
|
|
12106
12301
|
{
|
|
12107
12302
|
to: { type: "string", minLength: 1 },
|
|
12108
12303
|
task: { type: "string", minLength: 1 },
|
|
@@ -12130,7 +12325,16 @@ function createDelegationTools(invoker, options = {}) {
|
|
|
12130
12325
|
},
|
|
12131
12326
|
["need"]
|
|
12132
12327
|
)
|
|
12133
|
-
] : []
|
|
12328
|
+
] : [],
|
|
12329
|
+
define(
|
|
12330
|
+
"retry_delegation",
|
|
12331
|
+
"Retry one of your own failed or canceled delegations after its final failure was reported to you. It resumes on the original child session from where it stopped (the member keeps its context); pass note to add instructions for this attempt. Only if that session cannot be resumed does it start the task over in a new session (the note is included). You can retry the same delegation chain at most 3 times; after that, delegate to another member, skip it, or end the work explicitly. Returns the new delegationId and retriesLeft; the result arrives later like any delegation.",
|
|
12332
|
+
{
|
|
12333
|
+
id: { type: "string", minLength: 1 },
|
|
12334
|
+
note: { type: "string", minLength: 1, maxLength: 2e3 }
|
|
12335
|
+
},
|
|
12336
|
+
["id"]
|
|
12337
|
+
)
|
|
12134
12338
|
];
|
|
12135
12339
|
}
|
|
12136
12340
|
const isCapabilityId$1 = (value) => Object.hasOwn(CAPABILITY_CATALOG, value);
|
|
@@ -12501,6 +12705,483 @@ function createGroupTasksTool(invoker) {
|
|
|
12501
12705
|
}
|
|
12502
12706
|
};
|
|
12503
12707
|
}
|
|
12708
|
+
function imageDownloadDispatcher(url, addresses) {
|
|
12709
|
+
const hostname = url.hostname.replace(/^\[|\]$/g, "");
|
|
12710
|
+
const lookup2 = ((_host, options, callback) => {
|
|
12711
|
+
const entries = addresses.map((address) => ({ address, family: isIP(address) }));
|
|
12712
|
+
if (options.all) callback(null, entries);
|
|
12713
|
+
else callback(null, entries[0].address, entries[0].family);
|
|
12714
|
+
});
|
|
12715
|
+
const proxy = process.env.HTTP_PROXY ?? process.env.http_proxy;
|
|
12716
|
+
if (!proxy) return new Agent({ connect: { lookup: lookup2 } });
|
|
12717
|
+
return new EnvHttpProxyAgent({
|
|
12718
|
+
httpProxy: proxy,
|
|
12719
|
+
httpsProxy: process.env.HTTPS_PROXY ?? process.env.https_proxy ?? proxy,
|
|
12720
|
+
noProxy: process.env.NO_PROXY ?? process.env.no_proxy ?? "",
|
|
12721
|
+
connect: { lookup: lookup2 },
|
|
12722
|
+
requestTls: { servername: isIP(hostname) ? void 0 : hostname },
|
|
12723
|
+
// 保持 URL/Host 不变供 NO_PROXY 匹配;只改隧道连接目标,阻止代理再次解析目标域名。
|
|
12724
|
+
proxyTunnel: true,
|
|
12725
|
+
factory(origin, options) {
|
|
12726
|
+
const poolOptions = options;
|
|
12727
|
+
const connect = poolOptions.connect;
|
|
12728
|
+
if (typeof connect !== "function") return new Pool(origin, poolOptions);
|
|
12729
|
+
return new Pool(origin, {
|
|
12730
|
+
...poolOptions,
|
|
12731
|
+
connect(connection, callback) {
|
|
12732
|
+
const address = addresses[0];
|
|
12733
|
+
const ip = isIP(address) === 6 ? `[${address}]` : address;
|
|
12734
|
+
const port2 = connection.port || (url.protocol === "https:" ? "443" : "80");
|
|
12735
|
+
connect({ ...connection, port: port2, hostname: address, host: `${ip}:${port2}` }, callback);
|
|
12736
|
+
}
|
|
12737
|
+
});
|
|
12738
|
+
}
|
|
12739
|
+
});
|
|
12740
|
+
}
|
|
12741
|
+
const imageFetch = (url, init) => {
|
|
12742
|
+
const options = { ...init };
|
|
12743
|
+
if (init.body instanceof FormData) {
|
|
12744
|
+
const form = new FormData$1();
|
|
12745
|
+
for (const [name, value] of init.body.entries()) {
|
|
12746
|
+
if (typeof value === "string") form.append(name, value);
|
|
12747
|
+
else form.append(name, value, value.name);
|
|
12748
|
+
}
|
|
12749
|
+
if (options) options.body = form;
|
|
12750
|
+
}
|
|
12751
|
+
return fetch$1(url, options);
|
|
12752
|
+
};
|
|
12753
|
+
const MAX_IMAGE = 20 * 1024 * 1024;
|
|
12754
|
+
const MAX_RESPONSE = 280 * 1024 * 1024;
|
|
12755
|
+
const RESERVED = new BlockList();
|
|
12756
|
+
for (const [address, prefix] of [
|
|
12757
|
+
["192.0.2.0", 24],
|
|
12758
|
+
["192.88.99.0", 24],
|
|
12759
|
+
["198.51.100.0", 24],
|
|
12760
|
+
["203.0.113.0", 24]
|
|
12761
|
+
])
|
|
12762
|
+
RESERVED.addSubnet(address, prefix, "ipv4");
|
|
12763
|
+
for (const [address, prefix] of [
|
|
12764
|
+
["2001:db8::", 32],
|
|
12765
|
+
["2001:2::", 48],
|
|
12766
|
+
["2001:10::", 28]
|
|
12767
|
+
])
|
|
12768
|
+
RESERVED.addSubnet(address, prefix, "ipv6");
|
|
12769
|
+
function publicAddress(address) {
|
|
12770
|
+
const family = isIP(address);
|
|
12771
|
+
return isPublicAddress(address) && !RESERVED.check(address, family === 4 ? "ipv4" : "ipv6");
|
|
12772
|
+
}
|
|
12773
|
+
class ImageFailure extends Error {
|
|
12774
|
+
}
|
|
12775
|
+
class HttpFailure extends Error {
|
|
12776
|
+
constructor(status) {
|
|
12777
|
+
super("HTTP failure");
|
|
12778
|
+
this.status = status;
|
|
12779
|
+
}
|
|
12780
|
+
status;
|
|
12781
|
+
}
|
|
12782
|
+
const generated = /* @__PURE__ */ new Map();
|
|
12783
|
+
function mime(bytes) {
|
|
12784
|
+
if (bytes.length >= 8 && bytes.subarray(0, 8).equals(Buffer.from("89504e470d0a1a0a", "hex")))
|
|
12785
|
+
return "image/png";
|
|
12786
|
+
if (bytes.length >= 3 && bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255)
|
|
12787
|
+
return "image/jpeg";
|
|
12788
|
+
if (bytes.length >= 12 && bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WEBP")
|
|
12789
|
+
return "image/webp";
|
|
12790
|
+
throw new ImageFailure("Unsupported image format (expected PNG, JPEG or WebP)");
|
|
12791
|
+
}
|
|
12792
|
+
function decoded(value, declared) {
|
|
12793
|
+
if (typeof value !== "string" || value.length > Math.ceil(MAX_IMAGE / 3) * 4 || value.length % 4 !== 0 || /[^A-Za-z0-9+/=]/.test(value))
|
|
12794
|
+
throw new ImageFailure("Invalid or oversized Base64 image");
|
|
12795
|
+
const bytes = Buffer.from(value, "base64");
|
|
12796
|
+
if (!bytes.length || bytes.length > MAX_IMAGE || bytes.toString("base64") !== value)
|
|
12797
|
+
throw new ImageFailure("Invalid or oversized Base64 image");
|
|
12798
|
+
const mimeType = mime(bytes);
|
|
12799
|
+
if (declared !== void 0 && declared !== mimeType)
|
|
12800
|
+
throw new ImageFailure("Image MIME type does not match its bytes");
|
|
12801
|
+
return { bytes, mimeType };
|
|
12802
|
+
}
|
|
12803
|
+
function inside(root, file) {
|
|
12804
|
+
const rel = path.relative(root, file);
|
|
12805
|
+
return rel !== "" && rel !== ".." && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel);
|
|
12806
|
+
}
|
|
12807
|
+
async function capped(response, limit) {
|
|
12808
|
+
if (Number(response.headers.get("content-length")) > limit) {
|
|
12809
|
+
await response.body?.cancel().catch(() => {
|
|
12810
|
+
});
|
|
12811
|
+
throw new ImageFailure("Image API response exceeds the size limit");
|
|
12812
|
+
}
|
|
12813
|
+
if (!response.body) throw new ImageFailure("Image API returned an empty response");
|
|
12814
|
+
const reader = response.body.getReader();
|
|
12815
|
+
const chunks = [];
|
|
12816
|
+
let size = 0;
|
|
12817
|
+
try {
|
|
12818
|
+
for (; ; ) {
|
|
12819
|
+
const { value, done } = await reader.read();
|
|
12820
|
+
if (done) break;
|
|
12821
|
+
size += value.length;
|
|
12822
|
+
if (size > limit) throw new ImageFailure("Image API response exceeds the size limit");
|
|
12823
|
+
chunks.push(value);
|
|
12824
|
+
}
|
|
12825
|
+
} catch (e) {
|
|
12826
|
+
await reader.cancel().catch(() => {
|
|
12827
|
+
});
|
|
12828
|
+
throw e;
|
|
12829
|
+
}
|
|
12830
|
+
return Buffer.concat(chunks);
|
|
12831
|
+
}
|
|
12832
|
+
async function download(input, deps, signal) {
|
|
12833
|
+
let url = validateFetchUrl(input);
|
|
12834
|
+
const lookup$1 = deps.lookup ?? (async (host) => (await lookup(host, { all: true, verbatim: true })).map((x) => x.address));
|
|
12835
|
+
for (let hop = 0; hop <= 5; hop++) {
|
|
12836
|
+
const host = url.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
12837
|
+
const addresses = isIP(host) ? [host] : await lookup$1(host);
|
|
12838
|
+
if (host === "localhost" || host.endsWith(".localhost") || !addresses.length || !addresses.every(publicAddress))
|
|
12839
|
+
throw new ImageFailure("Image download URL resolves to a non-public address");
|
|
12840
|
+
const agent = deps.fetch ? void 0 : imageDownloadDispatcher(url, addresses);
|
|
12841
|
+
try {
|
|
12842
|
+
const init = { redirect: "manual", signal, ...agent ? { dispatcher: agent } : {} };
|
|
12843
|
+
const response = await (deps.fetch ?? imageFetch)(url.href, init);
|
|
12844
|
+
if (response.status >= 300 && response.status < 400) {
|
|
12845
|
+
const location = response.headers.get("location");
|
|
12846
|
+
await response.body?.cancel().catch(() => {
|
|
12847
|
+
});
|
|
12848
|
+
if (!location || hop === 5)
|
|
12849
|
+
throw new ImageFailure("Invalid or excessive image download redirects");
|
|
12850
|
+
url = validateFetchUrl(new URL(location, url).href);
|
|
12851
|
+
continue;
|
|
12852
|
+
}
|
|
12853
|
+
if (!response.ok) {
|
|
12854
|
+
await response.body?.cancel().catch(() => {
|
|
12855
|
+
});
|
|
12856
|
+
throw new ImageFailure(`Image download HTTP ${response.status}`);
|
|
12857
|
+
}
|
|
12858
|
+
const bytes = await capped(response, MAX_IMAGE);
|
|
12859
|
+
const mimeType = mime(bytes);
|
|
12860
|
+
const declared = response.headers.get("content-type")?.split(";")[0].trim().toLowerCase();
|
|
12861
|
+
if (declared && declared !== mimeType && declared !== "application/octet-stream")
|
|
12862
|
+
throw new ImageFailure("Downloaded image MIME type does not match its bytes");
|
|
12863
|
+
return { bytes, mimeType };
|
|
12864
|
+
} finally {
|
|
12865
|
+
await agent?.close();
|
|
12866
|
+
}
|
|
12867
|
+
}
|
|
12868
|
+
throw new ImageFailure("Too many image download redirects");
|
|
12869
|
+
}
|
|
12870
|
+
async function scratch(home, session, create = true) {
|
|
12871
|
+
if (!/^[A-Za-z0-9_-]{1,128}$/.test(session)) throw new ImageFailure("Invalid session ID");
|
|
12872
|
+
let current = await realpath(home);
|
|
12873
|
+
for (const segment of [".pi", "scratch", session]) {
|
|
12874
|
+
current = path.join(current, segment);
|
|
12875
|
+
if (create) {
|
|
12876
|
+
await mkdir(current).catch((e) => {
|
|
12877
|
+
if (e.code !== "EEXIST") throw e;
|
|
12878
|
+
});
|
|
12879
|
+
}
|
|
12880
|
+
const entry = await lstat(current);
|
|
12881
|
+
if (entry.isSymbolicLink() || !entry.isDirectory() || await realpath(current) !== current)
|
|
12882
|
+
throw new ImageFailure("Session scratch directory is not a safe local directory");
|
|
12883
|
+
}
|
|
12884
|
+
return current;
|
|
12885
|
+
}
|
|
12886
|
+
async function save(dir, picture, signal, assertScratch) {
|
|
12887
|
+
const ext = picture.mimeType === "image/png" ? "png" : picture.mimeType === "image/jpeg" ? "jpg" : "webp";
|
|
12888
|
+
const file = path.join(dir, `imagegen-${randomUUID()}.${ext}`);
|
|
12889
|
+
let created = false;
|
|
12890
|
+
try {
|
|
12891
|
+
signal.throwIfAborted();
|
|
12892
|
+
await assertScratch();
|
|
12893
|
+
const handle = await open(file, "wx", 384);
|
|
12894
|
+
created = true;
|
|
12895
|
+
try {
|
|
12896
|
+
const opened = await handle.stat();
|
|
12897
|
+
await assertScratch();
|
|
12898
|
+
await handle.writeFile(picture.bytes);
|
|
12899
|
+
signal.throwIfAborted();
|
|
12900
|
+
await assertScratch();
|
|
12901
|
+
const saved = await lstat(file);
|
|
12902
|
+
if (saved.isSymbolicLink() || saved.dev !== opened.dev || saved.ino !== opened.ino || saved.size !== picture.bytes.length)
|
|
12903
|
+
throw new ImageFailure("Generated image changed while saving");
|
|
12904
|
+
} finally {
|
|
12905
|
+
await handle.close();
|
|
12906
|
+
}
|
|
12907
|
+
return file;
|
|
12908
|
+
} catch (error) {
|
|
12909
|
+
if (created) await unlink(file).catch(() => {
|
|
12910
|
+
});
|
|
12911
|
+
throw error;
|
|
12912
|
+
}
|
|
12913
|
+
}
|
|
12914
|
+
async function generate(config, args, deps, session, toolCallId, externalSignal) {
|
|
12915
|
+
const signal = externalSignal ? AbortSignal.any([externalSignal, AbortSignal.timeout(12e4)]) : AbortSignal.timeout(12e4);
|
|
12916
|
+
const items = [];
|
|
12917
|
+
const diagnostics = [];
|
|
12918
|
+
const images = [];
|
|
12919
|
+
try {
|
|
12920
|
+
signal.throwIfAborted();
|
|
12921
|
+
const home = deps.homeDir ?? homedir();
|
|
12922
|
+
const dir = await scratch(home, session);
|
|
12923
|
+
const originalDir = await lstat(dir);
|
|
12924
|
+
const assertScratch = async () => {
|
|
12925
|
+
await scratch(home, session, false);
|
|
12926
|
+
const current = await lstat(dir);
|
|
12927
|
+
if (current.dev !== originalDir.dev || current.ino !== originalDir.ino || current.birthtimeMs !== originalDir.birthtimeMs)
|
|
12928
|
+
throw new ImageFailure("Session scratch directory was replaced during generation");
|
|
12929
|
+
};
|
|
12930
|
+
const workspace = args.referenceImages.length && !deps.remote ? await realpath(deps.cwd).catch(() => null) : null;
|
|
12931
|
+
const refs = [];
|
|
12932
|
+
for (const input of args.referenceImages) {
|
|
12933
|
+
signal.throwIfAborted();
|
|
12934
|
+
const expanded = input === "~" || input.startsWith("~/") || input.startsWith("~\\") ? path.join(deps.homeDir ?? homedir(), input.slice(1)) : input;
|
|
12935
|
+
const file = await realpath(path.resolve(deps.cwd, expanded));
|
|
12936
|
+
const info = await stat(file);
|
|
12937
|
+
const saved = generated.get(dir)?.get(file);
|
|
12938
|
+
const own = saved && saved.dev === info.dev && saved.ino === info.ino && saved.size === info.size && saved.mtimeMs === info.mtimeMs && saved.ctimeMs === info.ctimeMs;
|
|
12939
|
+
if ((!workspace || !inside(workspace, file)) && !own) {
|
|
12940
|
+
try {
|
|
12941
|
+
await deps.confirmOutside(file, signal, toolCallId);
|
|
12942
|
+
} catch {
|
|
12943
|
+
signal.throwIfAborted();
|
|
12944
|
+
throw new ImageFailure("Reference image access was not approved");
|
|
12945
|
+
}
|
|
12946
|
+
}
|
|
12947
|
+
if (!info.isFile() || info.size > MAX_IMAGE)
|
|
12948
|
+
throw new ImageFailure("Reference image is not a regular file or exceeds 20 MiB");
|
|
12949
|
+
const handle = await open(file, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
12950
|
+
let bytes;
|
|
12951
|
+
try {
|
|
12952
|
+
const opened = await handle.stat();
|
|
12953
|
+
if (opened.dev !== info.dev || opened.ino !== info.ino || opened.size !== info.size || opened.mtimeMs !== info.mtimeMs || opened.ctimeMs !== info.ctimeMs)
|
|
12954
|
+
throw new Error("Reference changed");
|
|
12955
|
+
const buffer = Buffer.alloc(info.size + 1);
|
|
12956
|
+
let offset = 0;
|
|
12957
|
+
while (offset < buffer.length) {
|
|
12958
|
+
const read = await handle.read(buffer, offset, buffer.length - offset, offset);
|
|
12959
|
+
if (!read.bytesRead) break;
|
|
12960
|
+
offset += read.bytesRead;
|
|
12961
|
+
}
|
|
12962
|
+
if (offset !== info.size) throw new Error("Reference changed");
|
|
12963
|
+
const after = await handle.stat();
|
|
12964
|
+
if (after.size !== info.size || after.mtimeMs !== info.mtimeMs || after.ctimeMs !== info.ctimeMs)
|
|
12965
|
+
throw new Error("Reference changed");
|
|
12966
|
+
bytes = buffer.subarray(0, offset);
|
|
12967
|
+
} finally {
|
|
12968
|
+
await handle.close();
|
|
12969
|
+
}
|
|
12970
|
+
if (bytes.length > MAX_IMAGE) throw new ImageFailure("Reference image exceeds 20 MiB");
|
|
12971
|
+
refs.push({ bytes, mimeType: mime(bytes) });
|
|
12972
|
+
}
|
|
12973
|
+
const base = config.baseUrl.replace(/\/+$/, "");
|
|
12974
|
+
const jsonRequest = async (url, init) => {
|
|
12975
|
+
const response = await (deps.fetch ?? imageFetch)(url, {
|
|
12976
|
+
...init,
|
|
12977
|
+
signal,
|
|
12978
|
+
redirect: "error"
|
|
12979
|
+
});
|
|
12980
|
+
if (!response.ok) {
|
|
12981
|
+
await response.body?.cancel().catch(() => {
|
|
12982
|
+
});
|
|
12983
|
+
throw new HttpFailure(response.status);
|
|
12984
|
+
}
|
|
12985
|
+
return JSON.parse((await capped(response, MAX_RESPONSE)).toString("utf8"));
|
|
12986
|
+
};
|
|
12987
|
+
let openaiData = [];
|
|
12988
|
+
if (config.protocol !== "gemini") {
|
|
12989
|
+
let body;
|
|
12990
|
+
let headers = { Authorization: `Bearer ${config.apiKey}` };
|
|
12991
|
+
if (refs.length) {
|
|
12992
|
+
const form = new FormData();
|
|
12993
|
+
form.append("model", config.modelId);
|
|
12994
|
+
form.append("prompt", args.prompt);
|
|
12995
|
+
form.append("n", String(args.count));
|
|
12996
|
+
for (const ref of refs)
|
|
12997
|
+
form.append(
|
|
12998
|
+
"image[]",
|
|
12999
|
+
new Blob([new Uint8Array(ref.bytes)], { type: ref.mimeType }),
|
|
13000
|
+
`reference.${ref.mimeType.split("/")[1]}`
|
|
13001
|
+
);
|
|
13002
|
+
body = form;
|
|
13003
|
+
} else {
|
|
13004
|
+
body = JSON.stringify({ model: config.modelId, prompt: args.prompt, n: args.count });
|
|
13005
|
+
headers = { ...headers, "content-type": "application/json" };
|
|
13006
|
+
}
|
|
13007
|
+
const result = await jsonRequest(`${base}/images/${refs.length ? "edits" : "generations"}`, {
|
|
13008
|
+
method: "POST",
|
|
13009
|
+
headers,
|
|
13010
|
+
body
|
|
13011
|
+
});
|
|
13012
|
+
openaiData = Array.isArray(result.data) ? result.data : [];
|
|
13013
|
+
}
|
|
13014
|
+
for (let index = 1; index <= args.count; index++) {
|
|
13015
|
+
try {
|
|
13016
|
+
signal.throwIfAborted();
|
|
13017
|
+
let picture;
|
|
13018
|
+
if (config.protocol === "gemini") {
|
|
13019
|
+
const parts = [
|
|
13020
|
+
{ text: args.prompt },
|
|
13021
|
+
...refs.map((ref) => ({
|
|
13022
|
+
inlineData: { mimeType: ref.mimeType, data: ref.bytes.toString("base64") }
|
|
13023
|
+
}))
|
|
13024
|
+
];
|
|
13025
|
+
const result = await jsonRequest(
|
|
13026
|
+
`${base}/models/${encodeURIComponent(config.modelId)}:generateContent`,
|
|
13027
|
+
{
|
|
13028
|
+
method: "POST",
|
|
13029
|
+
headers: { "content-type": "application/json", "x-goog-api-key": config.apiKey },
|
|
13030
|
+
body: JSON.stringify({
|
|
13031
|
+
contents: [{ parts }],
|
|
13032
|
+
generationConfig: { responseModalities: ["TEXT", "IMAGE"] }
|
|
13033
|
+
})
|
|
13034
|
+
}
|
|
13035
|
+
);
|
|
13036
|
+
const part = result.candidates?.flatMap((c) => c?.content?.parts ?? []).find((p) => !p.thought && p.inlineData?.data);
|
|
13037
|
+
if (typeof part?.inlineData?.mimeType !== "string")
|
|
13038
|
+
throw new ImageFailure(
|
|
13039
|
+
"Gemini returned no image; the response may be text-only or safety-blocked"
|
|
13040
|
+
);
|
|
13041
|
+
picture = decoded(part?.inlineData?.data, part?.inlineData?.mimeType);
|
|
13042
|
+
} else {
|
|
13043
|
+
const entry = openaiData[index - 1];
|
|
13044
|
+
if (entry?.b64_json) picture = decoded(entry.b64_json);
|
|
13045
|
+
else if (typeof entry?.url === "string")
|
|
13046
|
+
picture = await download(entry.url, deps, signal);
|
|
13047
|
+
else
|
|
13048
|
+
throw new ImageFailure(
|
|
13049
|
+
"Image API returned fewer images than requested or an unsupported response"
|
|
13050
|
+
);
|
|
13051
|
+
}
|
|
13052
|
+
const file = await save(dir, picture, signal, assertScratch);
|
|
13053
|
+
if (!generated.has(dir)) generated.set(dir, /* @__PURE__ */ new Map());
|
|
13054
|
+
const info = await stat(file);
|
|
13055
|
+
generated.get(dir)?.set(file, {
|
|
13056
|
+
dev: info.dev,
|
|
13057
|
+
ino: info.ino,
|
|
13058
|
+
size: info.size,
|
|
13059
|
+
mtimeMs: info.mtimeMs,
|
|
13060
|
+
ctimeMs: info.ctimeMs
|
|
13061
|
+
});
|
|
13062
|
+
items.push({ index, status: "success", path: file, mimeType: picture.mimeType });
|
|
13063
|
+
images.push({
|
|
13064
|
+
type: "image",
|
|
13065
|
+
data: picture.bytes.toString("base64"),
|
|
13066
|
+
mimeType: picture.mimeType
|
|
13067
|
+
});
|
|
13068
|
+
} catch (error) {
|
|
13069
|
+
const status = signal.aborted ? "cancelled" : "error";
|
|
13070
|
+
items.push({ index, status, path: null, mimeType: null });
|
|
13071
|
+
diagnostics.push(
|
|
13072
|
+
`Image ${index}: ${status === "cancelled" ? "cancelled or timed out" : error instanceof HttpFailure ? `image API HTTP ${error.status}` : error instanceof ImageFailure ? error.message : "generation or save failed"}`
|
|
13073
|
+
);
|
|
13074
|
+
}
|
|
13075
|
+
}
|
|
13076
|
+
} catch (error) {
|
|
13077
|
+
for (let index = items.length + 1; index <= args.count; index++)
|
|
13078
|
+
items.push({
|
|
13079
|
+
index,
|
|
13080
|
+
status: signal.aborted ? "cancelled" : "error",
|
|
13081
|
+
path: null,
|
|
13082
|
+
mimeType: null
|
|
13083
|
+
});
|
|
13084
|
+
diagnostics.push(
|
|
13085
|
+
signal.aborted ? "Cancelled or timed out" : error instanceof HttpFailure ? `Image API HTTP ${error.status}` : error instanceof ImageFailure ? error.message : "Image generation failed"
|
|
13086
|
+
);
|
|
13087
|
+
}
|
|
13088
|
+
return { items, diagnostics, images };
|
|
13089
|
+
}
|
|
13090
|
+
function confirmImageReference(gate, remote) {
|
|
13091
|
+
return async (file, signal, toolCallId) => {
|
|
13092
|
+
if (!remote && !gate.needsApproval("command", "ImageGen")) return;
|
|
13093
|
+
throwUnlessAllowed(
|
|
13094
|
+
await gate.ask(
|
|
13095
|
+
"ImageGen",
|
|
13096
|
+
"command",
|
|
13097
|
+
`Upload a reference image from outside the workspace: ${file}`,
|
|
13098
|
+
signal,
|
|
13099
|
+
toolCallId,
|
|
13100
|
+
void 0,
|
|
13101
|
+
remote ? "external-send" : void 0
|
|
13102
|
+
)
|
|
13103
|
+
);
|
|
13104
|
+
};
|
|
13105
|
+
}
|
|
13106
|
+
function normalize(raw) {
|
|
13107
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
13108
|
+
const args = { ...raw };
|
|
13109
|
+
if (typeof args.prompt === "string") args.prompt = args.prompt.trim();
|
|
13110
|
+
if (typeof args.count === "string" && /^\d+$/.test(args.count.trim()))
|
|
13111
|
+
args.count = Number(args.count.trim());
|
|
13112
|
+
if (Array.isArray(args.referenceImages))
|
|
13113
|
+
args.referenceImages = args.referenceImages.map((v) => typeof v === "string" ? v.trim() : v);
|
|
13114
|
+
return args;
|
|
13115
|
+
}
|
|
13116
|
+
function validate(raw) {
|
|
13117
|
+
const v = normalize(raw);
|
|
13118
|
+
if (!v || typeof v !== "object" || Array.isArray(v)) throw new Error("Invalid arguments");
|
|
13119
|
+
const a = v;
|
|
13120
|
+
if (Object.keys(a).some((k) => !["prompt", "count", "referenceImages"].includes(k)))
|
|
13121
|
+
throw new Error("Unexpected argument");
|
|
13122
|
+
if (typeof a.prompt !== "string" || !a.prompt) throw new Error("Invalid prompt");
|
|
13123
|
+
if (a.count !== void 0 && (typeof a.count !== "number" || !Number.isInteger(a.count) || a.count < 1 || a.count > 10))
|
|
13124
|
+
throw new Error("Invalid count");
|
|
13125
|
+
if (a.referenceImages !== void 0 && (!Array.isArray(a.referenceImages) || a.referenceImages.length > 10 || a.referenceImages.some((v2) => typeof v2 !== "string" || !v2)))
|
|
13126
|
+
throw new Error("Invalid references");
|
|
13127
|
+
return {
|
|
13128
|
+
prompt: a.prompt,
|
|
13129
|
+
count: a.count ?? 1,
|
|
13130
|
+
referenceImages: a.referenceImages ?? []
|
|
13131
|
+
};
|
|
13132
|
+
}
|
|
13133
|
+
function createImageGenTool(deps) {
|
|
13134
|
+
return {
|
|
13135
|
+
name: "ImageGen",
|
|
13136
|
+
label: "ImageGen",
|
|
13137
|
+
description: "Generate and save images using the independent default image-generation model configured in settings. Only call when the user requests image generation or editing. Parameters: prompt, optional referenceImages (local workspace-relative, absolute or ~/ image paths), count (1–10, default 1). References outside the workspace may require approval. Even in SSH sessions, references and saved files are on the EnsoCode host. Saves under ~/.pi/scratch/<Pi Session ID>/ and returns each image index/status/path/mimeType; files are available only for success items. Successful images are automatically displayed to the user and attached to the conversation for you to see, including calls inside codemode; no read or image link is needed to display or inspect them. The latest generated batch stays in subsequent model context until replaced by a newer batch or removed by context compaction. Do not repeat a partially successful request automatically: it may charge again.",
|
|
13138
|
+
parameters: {
|
|
13139
|
+
type: "object",
|
|
13140
|
+
properties: {
|
|
13141
|
+
prompt: { type: "string", minLength: 1 },
|
|
13142
|
+
referenceImages: { type: "array", maxItems: 10, items: { type: "string", minLength: 1 } },
|
|
13143
|
+
count: { type: "integer", minimum: 1, maximum: 10 }
|
|
13144
|
+
},
|
|
13145
|
+
required: ["prompt"],
|
|
13146
|
+
additionalProperties: false
|
|
13147
|
+
},
|
|
13148
|
+
prepareArguments: normalize,
|
|
13149
|
+
async execute(toolCallId, raw, signal, _onUpdate, ctx) {
|
|
13150
|
+
const fail = (message) => ({
|
|
13151
|
+
content: [
|
|
13152
|
+
{ type: "text", text: JSON.stringify({ items: [], diagnostics: [message] }) }
|
|
13153
|
+
],
|
|
13154
|
+
details: void 0,
|
|
13155
|
+
isError: true
|
|
13156
|
+
});
|
|
13157
|
+
let state;
|
|
13158
|
+
try {
|
|
13159
|
+
state = deps.getConfig();
|
|
13160
|
+
} catch {
|
|
13161
|
+
return fail("Image generation configuration is unavailable");
|
|
13162
|
+
}
|
|
13163
|
+
const config = state.config ? { ...state.config } : null;
|
|
13164
|
+
if (!config)
|
|
13165
|
+
return fail(
|
|
13166
|
+
state.error ? "The selected image generation model is unavailable. Check its enabled state, image-generation flag, API key and protocol in Settings." : "Select a default image generation model in Settings first."
|
|
13167
|
+
);
|
|
13168
|
+
let args;
|
|
13169
|
+
try {
|
|
13170
|
+
args = validate(raw);
|
|
13171
|
+
} catch {
|
|
13172
|
+
return fail("Invalid ImageGen arguments");
|
|
13173
|
+
}
|
|
13174
|
+
const session = ctx?.sessionManager?.getSessionId?.();
|
|
13175
|
+
if (typeof session !== "string") return fail("Missing session ID");
|
|
13176
|
+
const { images, ...result } = await generate(config, args, deps, session, toolCallId, signal);
|
|
13177
|
+
return {
|
|
13178
|
+
content: [{ type: "text", text: JSON.stringify(result) }, ...images],
|
|
13179
|
+
details: void 0,
|
|
13180
|
+
...result.items.some((item) => item.status === "success") ? {} : { isError: true }
|
|
13181
|
+
};
|
|
13182
|
+
}
|
|
13183
|
+
};
|
|
13184
|
+
}
|
|
12504
13185
|
const DEFAULT_TIMEOUT_MS$1 = 7e4;
|
|
12505
13186
|
const TOOL_TIMEOUT_SLACK_MS = 1e4;
|
|
12506
13187
|
function pluginToolLocalTimeoutMs(timeoutMs) {
|
|
@@ -12784,7 +13465,7 @@ const errorResult = (text) => ({
|
|
|
12784
13465
|
isError: true
|
|
12785
13466
|
});
|
|
12786
13467
|
function createSendImageTool(invoker, cwd, confirmOutside) {
|
|
12787
|
-
const
|
|
13468
|
+
const normalize2 = (raw) => normalizeSendImageParams(raw, cwd);
|
|
12788
13469
|
let inflight = 0;
|
|
12789
13470
|
return {
|
|
12790
13471
|
name: "send_image",
|
|
@@ -12810,9 +13491,9 @@ function createSendImageTool(invoker, cwd, confirmOutside) {
|
|
|
12810
13491
|
required: [],
|
|
12811
13492
|
additionalProperties: false
|
|
12812
13493
|
},
|
|
12813
|
-
prepareArguments:
|
|
13494
|
+
prepareArguments: normalize2,
|
|
12814
13495
|
async execute(toolCallId, raw, signal, _onUpdate, ctx) {
|
|
12815
|
-
const params =
|
|
13496
|
+
const params = normalize2(raw);
|
|
12816
13497
|
if (params.path === void 0 === (params.screenshot === void 0))
|
|
12817
13498
|
return errorResult("Pass exactly one of path or screenshot.");
|
|
12818
13499
|
const branch = ctx?.sessionManager?.getBranch?.() ?? [];
|
|
@@ -12862,9 +13543,7 @@ function consumeUnattendedNote(state, text) {
|
|
|
12862
13543
|
const note = state.unattendedNote;
|
|
12863
13544
|
if (!note) return text;
|
|
12864
13545
|
state.unattendedNote = void 0;
|
|
12865
|
-
return
|
|
12866
|
-
|
|
12867
|
-
${text}`;
|
|
13546
|
+
return prependTurnNote(note, text);
|
|
12868
13547
|
}
|
|
12869
13548
|
const INPUT_MAX_CHARS = 4e3;
|
|
12870
13549
|
const DOWNGRADE_STREAK = 2;
|
|
@@ -13822,6 +14501,7 @@ function withExclusiveCommand(def, claims, context) {
|
|
|
13822
14501
|
const WORKSPACE_POLICY_PROMPT = `# Working in the workspace
|
|
13823
14502
|
- When the user asks for an explanation, review, or investigation, answer it; do not change files unless they ask for changes.
|
|
13824
14503
|
- Once you have enough information to act, act; do not re-derive what you already established.
|
|
14504
|
+
- Every response is a model round: issue independent tool calls (reads, searches, checks) together in one response instead of one per round, and when a call fails, fix it from the error message instead of probing again.
|
|
13825
14505
|
- Verify a change with the narrowest relevant check first; broaden to wider suites only when the change warrants it.
|
|
13826
14506
|
- Treat uncommitted and untracked changes you did not make as the user's work: do not revert, overwrite, or delete them unless asked.
|
|
13827
14507
|
- Never invent repository or task state (branches, commits, test results, command output); check it.
|
|
@@ -13969,7 +14649,7 @@ function createSessionResourceLoader(options) {
|
|
|
13969
14649
|
const persona = options.persona;
|
|
13970
14650
|
const pluginCommands = options.pluginCommands ?? [];
|
|
13971
14651
|
const pluginHooks = options.pluginHooks;
|
|
13972
|
-
|
|
14652
|
+
const loader = new DefaultResourceLoader({
|
|
13973
14653
|
cwd: options.cwd,
|
|
13974
14654
|
agentDir: options.agentDir,
|
|
13975
14655
|
settingsManager: createProjectSettingsManager(
|
|
@@ -14001,6 +14681,7 @@ function createSessionResourceLoader(options) {
|
|
|
14001
14681
|
}
|
|
14002
14682
|
},
|
|
14003
14683
|
...options.exploreFold ? [exploreFoldExtension(options.exploreFold)] : [],
|
|
14684
|
+
...options.reminders ? [systemReminderExtension(options.reminders)] : [],
|
|
14004
14685
|
...options.remoteSsh ? [
|
|
14005
14686
|
{
|
|
14006
14687
|
name: "ssh-cwd-prompt",
|
|
@@ -14042,6 +14723,7 @@ function createSessionResourceLoader(options) {
|
|
|
14042
14723
|
})
|
|
14043
14724
|
] : [],
|
|
14044
14725
|
...options.pluginEvents ? [createPluginEventsExtension(options.pluginEvents.invoker)] : [],
|
|
14726
|
+
skillChainExtension(() => loader.getSkills().skills),
|
|
14045
14727
|
options.silentTurnRecovery,
|
|
14046
14728
|
appendSystemPromptExtension("workspace-policy", WORKSPACE_POLICY_PROMPT),
|
|
14047
14729
|
...options.childContract ? [appendSystemPromptExtension("subagent-contract", SUBAGENT_CONTRACT_PROMPT)] : [],
|
|
@@ -14069,6 +14751,7 @@ function createSessionResourceLoader(options) {
|
|
|
14069
14751
|
...harness ? readHarnessRuleFiles(options.cwd) : []
|
|
14070
14752
|
])
|
|
14071
14753
|
});
|
|
14754
|
+
return loader;
|
|
14072
14755
|
}
|
|
14073
14756
|
async function emitSessionShutdown(session) {
|
|
14074
14757
|
try {
|
|
@@ -14350,6 +15033,7 @@ class SessionSupervisor {
|
|
|
14350
15033
|
disabledWorkflowPresets = [];
|
|
14351
15034
|
/** undefined 跟随会话;空数组表示已配置但全部不可用,直接走 Exa。 */
|
|
14352
15035
|
webSearchChain;
|
|
15036
|
+
imageGeneration = { config: null };
|
|
14353
15037
|
/**
|
|
14354
15038
|
* Main 推送的统一模型目录。revision 与自定义 provider 语义都没变时不再注册。
|
|
14355
15039
|
* 当前消费者是自定义 provider 预注册;快照本体由后续的全局 web_search
|
|
@@ -14516,7 +15200,8 @@ ${text}
|
|
|
14516
15200
|
type: "parent-ended",
|
|
14517
15201
|
identity: managed.identity,
|
|
14518
15202
|
seq: managed.seq + 1,
|
|
14519
|
-
reason
|
|
15203
|
+
reason,
|
|
15204
|
+
...managed.instanceId ? { instanceId: managed.instanceId } : {}
|
|
14520
15205
|
});
|
|
14521
15206
|
}
|
|
14522
15207
|
handleCommand(command2) {
|
|
@@ -14690,6 +15375,13 @@ ${text}
|
|
|
14690
15375
|
}
|
|
14691
15376
|
return;
|
|
14692
15377
|
}
|
|
15378
|
+
if (command2.type === "set-image-generation-config") {
|
|
15379
|
+
this.imageGeneration = {
|
|
15380
|
+
config: command2.config ? { ...command2.config } : null,
|
|
15381
|
+
...command2.error ? { error: command2.error } : {}
|
|
15382
|
+
};
|
|
15383
|
+
return;
|
|
15384
|
+
}
|
|
14693
15385
|
if (command2.type === "set-web-search-config") {
|
|
14694
15386
|
this.webSearchChain = command2.configured ?? command2.chain.length > 0 ? command2.chain : void 0;
|
|
14695
15387
|
void this.getRuntime().then((runtime) => {
|
|
@@ -14767,7 +15459,8 @@ ${text}
|
|
|
14767
15459
|
type: "parent-rejected",
|
|
14768
15460
|
identity: command2.identity,
|
|
14769
15461
|
seq: 0,
|
|
14770
|
-
reason: message
|
|
15462
|
+
reason: message,
|
|
15463
|
+
...command2.instanceId ? { instanceId: command2.instanceId } : {}
|
|
14771
15464
|
});
|
|
14772
15465
|
return;
|
|
14773
15466
|
}
|
|
@@ -14786,10 +15479,17 @@ ${text}
|
|
|
14786
15479
|
}
|
|
14787
15480
|
const managed = this.sessions.get(identity.sessionId);
|
|
14788
15481
|
if (!managed || !isSameGeneration(managed.identity, identity)) {
|
|
14789
|
-
if (command2.type === "prompt" || command2.type === "steer") {
|
|
15482
|
+
if (command2.type === "prompt" || command2.type === "steer" || command2.type === "retry") {
|
|
14790
15483
|
const target = command2.identity;
|
|
14791
15484
|
this.options.emit(
|
|
14792
|
-
"parent" in target ? { type: "child-rejected", identity: target, seq: 0, reason: message } : {
|
|
15485
|
+
"parent" in target ? { type: "child-rejected", identity: target, seq: 0, reason: message } : {
|
|
15486
|
+
type: "parent-rejected",
|
|
15487
|
+
identity: target,
|
|
15488
|
+
seq: 0,
|
|
15489
|
+
reason: message,
|
|
15490
|
+
// 回显这条命令自己带的实例号:Main 只把发给当前实例的命令被拒算作当前实例结束
|
|
15491
|
+
...command2.instanceId ? { instanceId: command2.instanceId } : {}
|
|
15492
|
+
}
|
|
14793
15493
|
);
|
|
14794
15494
|
}
|
|
14795
15495
|
return;
|
|
@@ -14851,7 +15551,9 @@ ${text}
|
|
|
14851
15551
|
command2.pluginTools,
|
|
14852
15552
|
command2.pluginEvents,
|
|
14853
15553
|
command2.dcgPath,
|
|
14854
|
-
command2.autoRejectApprovals ?? false
|
|
15554
|
+
command2.autoRejectApprovals ?? false,
|
|
15555
|
+
command2.botDiscussMode,
|
|
15556
|
+
command2.instanceId
|
|
14855
15557
|
);
|
|
14856
15558
|
return;
|
|
14857
15559
|
case "spawn-child":
|
|
@@ -14865,7 +15567,11 @@ ${text}
|
|
|
14865
15567
|
case "dismiss-child": {
|
|
14866
15568
|
this.must(command2.parent);
|
|
14867
15569
|
const child = this.sessions.get(command2.child.sessionId);
|
|
14868
|
-
if (!child
|
|
15570
|
+
if (!child) {
|
|
15571
|
+
await this.dismissCoworker(command2.parent.sessionId, command2.child.sessionId);
|
|
15572
|
+
return;
|
|
15573
|
+
}
|
|
15574
|
+
if (!child.childIdentity || !isSameChildSessionIdentity(command2.child, child.childIdentity)) {
|
|
14869
15575
|
return;
|
|
14870
15576
|
}
|
|
14871
15577
|
const name = await this.dismissCoworker(command2.parent.sessionId, command2.child.sessionId);
|
|
@@ -14926,7 +15632,7 @@ ${text}
|
|
|
14926
15632
|
managed.plan?.supersede();
|
|
14927
15633
|
const images = command2.images?.map((image) => ({ type: "image", ...image }));
|
|
14928
15634
|
if (await this.interruptRetryIfAny(managed)) {
|
|
14929
|
-
this.promptFresh(managed, command2.text, images, command2.deliveryId);
|
|
15635
|
+
this.promptFresh(managed, command2.text, images, command2.deliveryId, command2.resume);
|
|
14930
15636
|
return;
|
|
14931
15637
|
}
|
|
14932
15638
|
if (managed.status === "running") {
|
|
@@ -14942,7 +15648,7 @@ ${text}
|
|
|
14942
15648
|
);
|
|
14943
15649
|
return;
|
|
14944
15650
|
}
|
|
14945
|
-
this.promptFresh(managed, command2.text, images, command2.deliveryId);
|
|
15651
|
+
this.promptFresh(managed, command2.text, images, command2.deliveryId, command2.resume);
|
|
14946
15652
|
return;
|
|
14947
15653
|
}
|
|
14948
15654
|
case "steer": {
|
|
@@ -14966,10 +15672,17 @@ ${text}
|
|
|
14966
15672
|
return;
|
|
14967
15673
|
case "retry": {
|
|
14968
15674
|
const managed = this.must(command2.identity);
|
|
14969
|
-
if (!managed.session.isIdle || managed.status === "running")
|
|
15675
|
+
if (!managed.session.isIdle || managed.status === "running") {
|
|
15676
|
+
this.emitRetrySkipped(managed, "busy");
|
|
15677
|
+
return;
|
|
15678
|
+
}
|
|
14970
15679
|
const agent = managed.session.agent;
|
|
14971
|
-
|
|
14972
|
-
|
|
15680
|
+
if (command2.unfinishedOnly) editUnfinishedAssistantForResume(managed.session);
|
|
15681
|
+
else editLatestAssistantForRetry(managed.session);
|
|
15682
|
+
if (agent.state.messages.at(-1)?.role === "assistant") {
|
|
15683
|
+
this.emitRetrySkipped(managed, "nothing-to-retry");
|
|
15684
|
+
return;
|
|
15685
|
+
}
|
|
14973
15686
|
ensureAssistantUsage(agent.state.messages);
|
|
14974
15687
|
managed.currentTurnId = randomUUID();
|
|
14975
15688
|
resetOauthPoolActivity(managed.session);
|
|
@@ -15303,6 +16016,7 @@ ${text}
|
|
|
15303
16016
|
if (retrying) {
|
|
15304
16017
|
this.failTurn(managed, managed.lastRetryError ?? "Auto-retry cancelled.");
|
|
15305
16018
|
} else {
|
|
16019
|
+
managed.turnRetried = false;
|
|
15306
16020
|
managed.status = "idle";
|
|
15307
16021
|
this.emitStatus(managed);
|
|
15308
16022
|
}
|
|
@@ -15322,7 +16036,7 @@ ${text}
|
|
|
15322
16036
|
console.warn("[compact] summary model unavailable:", toErrorMessage(error));
|
|
15323
16037
|
});
|
|
15324
16038
|
}
|
|
15325
|
-
async spawn(identity, cwd, model, resumeFile, reasoningEnabled = false, thinkingLevel, loadLocalSkills = true, skillPaths = [], mcpServers = [], approvalMode = "full", approvalReviewer, agentTypes = [], disabledTools = [], instruction, subagentModels = [], remote, loadHarnessAssets = false, windowsLocalShell, exploreFoldEnabled = false, hashlineEditEnabled = false, compactStrategy = "standard", smartCompactSummaryModel, smartCompactMode, memoryLanguage, requestedEditMode, rolePrompt, systemPrompt, systemPromptAppend, systemPromptBoost, refusalRetryPrompt, rtkEnabled = true, planMode, trustedProjectCode = [], pluginCommands = [], pluginHooks = [], botMode = false, botGroupTasks = false, protectedActions = false, botRoutines = false, botWriteLock, botDelegationTask = false, pluginToolDescriptors = [], pluginEvents, dcgPath, autoRejectApprovals = false) {
|
|
16039
|
+
async spawn(identity, cwd, model, resumeFile, reasoningEnabled = false, thinkingLevel, loadLocalSkills = true, skillPaths = [], mcpServers = [], approvalMode = "full", approvalReviewer, agentTypes = [], disabledTools = [], instruction, subagentModels = [], remote, loadHarnessAssets = false, windowsLocalShell, exploreFoldEnabled = false, hashlineEditEnabled = false, compactStrategy = "standard", smartCompactSummaryModel, smartCompactMode, memoryLanguage, requestedEditMode, rolePrompt, systemPrompt, systemPromptAppend, systemPromptBoost, refusalRetryPrompt, rtkEnabled = true, planMode, trustedProjectCode = [], pluginCommands = [], pluginHooks = [], botMode = false, botGroupTasks = false, protectedActions = false, botRoutines = false, botWriteLock, botDelegationTask = false, pluginToolDescriptors = [], pluginEvents, dcgPath, autoRejectApprovals = false, botDiscussMode = false, instanceId) {
|
|
15326
16040
|
const sessionId = identity.sessionId;
|
|
15327
16041
|
const sessionEditMode = resolveEditMode(requestedEditMode);
|
|
15328
16042
|
const toolEnabled = (id) => !disabledTools.includes(id);
|
|
@@ -15332,6 +16046,7 @@ ${text}
|
|
|
15332
16046
|
if (!isSameGeneration(existing.identity, identity) || existing.childIdentity) {
|
|
15333
16047
|
throw new Error("Parent session identity is already reserved by another generation.");
|
|
15334
16048
|
}
|
|
16049
|
+
existing.instanceId = instanceId;
|
|
15335
16050
|
this.options.emit({
|
|
15336
16051
|
type: "parent-ready",
|
|
15337
16052
|
identity,
|
|
@@ -15390,6 +16105,7 @@ ${text}
|
|
|
15390
16105
|
seq: ++managed2.seq
|
|
15391
16106
|
});
|
|
15392
16107
|
}) : void 0;
|
|
16108
|
+
const reminders = new SystemReminderRegistry();
|
|
15393
16109
|
const resourceLoader = createSessionResourceLoader({
|
|
15394
16110
|
branchContext: this.branchContextExtension(() => managedRef),
|
|
15395
16111
|
oauthPoolRecovery: this.oauthPoolRecovery(),
|
|
@@ -15411,6 +16127,7 @@ ${text}
|
|
|
15411
16127
|
pluginHooks: { hooks: pluginHooks, role: { kind: "parent" }, resumed: Boolean(resumeFile) },
|
|
15412
16128
|
...pluginEventInvoker ? { pluginEvents: { invoker: pluginEventInvoker } } : {},
|
|
15413
16129
|
exploreFold,
|
|
16130
|
+
reminders,
|
|
15414
16131
|
codemode: codemodeHost.extension,
|
|
15415
16132
|
persona: systemPrompt,
|
|
15416
16133
|
systemPromptAppend,
|
|
@@ -15478,7 +16195,6 @@ ${text}
|
|
|
15478
16195
|
this.persistPendingReminders(managedRef);
|
|
15479
16196
|
return taken;
|
|
15480
16197
|
};
|
|
15481
|
-
const reminders = new SystemReminderRegistry();
|
|
15482
16198
|
reminders.register("unattended", () => {
|
|
15483
16199
|
const managed2 = managedRef ?? this.sessions.get(sessionId);
|
|
15484
16200
|
const note = managed2?.unattendedNote;
|
|
@@ -15509,8 +16225,8 @@ ${text}
|
|
|
15509
16225
|
),
|
|
15510
16226
|
grep: createRemoteGrepToolDefinition(cwd, sshExecutor)
|
|
15511
16227
|
} : {
|
|
15512
|
-
read: wrapRead(createReadToolDefinition(cwd)),
|
|
15513
|
-
grep: createGrepToolDefinition(cwd)
|
|
16228
|
+
read: withPathHints(wrapRead(createReadToolDefinition(cwd)), cwd),
|
|
16229
|
+
grep: withPathHints(createGrepToolDefinition(cwd), cwd)
|
|
15514
16230
|
};
|
|
15515
16231
|
const { grep } = stock;
|
|
15516
16232
|
const read = withProtectedFloor(toolGate, "read", stock.read);
|
|
@@ -15522,8 +16238,8 @@ ${text}
|
|
|
15522
16238
|
] : [
|
|
15523
16239
|
read,
|
|
15524
16240
|
grep,
|
|
15525
|
-
createFindToolDefinition(cwd),
|
|
15526
|
-
createLsToolDefinition(cwd)
|
|
16241
|
+
withPathHints(createFindToolDefinition(cwd), cwd),
|
|
16242
|
+
withPathHints(createLsToolDefinition(cwd), cwd)
|
|
15527
16243
|
];
|
|
15528
16244
|
};
|
|
15529
16245
|
const writeLock = botWriteLock && !remote ? botWriteLock : void 0;
|
|
@@ -15683,6 +16399,7 @@ ${text}
|
|
|
15683
16399
|
managed2.silentTurnNudgeUsed = true;
|
|
15684
16400
|
managed2.silentTurnKind = kind;
|
|
15685
16401
|
});
|
|
16402
|
+
const childReminders = new SystemReminderRegistry();
|
|
15686
16403
|
const subLoader = isLockedEnso ? createEnsoResourceLoader(
|
|
15687
16404
|
cwd,
|
|
15688
16405
|
this.options.agentDir,
|
|
@@ -15714,6 +16431,7 @@ ${text}
|
|
|
15714
16431
|
},
|
|
15715
16432
|
...childPlugins?.events ? { pluginEvents: { invoker: childPlugins.events } } : {},
|
|
15716
16433
|
...childExploreFold ? { exploreFold: childExploreFold } : {},
|
|
16434
|
+
reminders: childReminders,
|
|
15717
16435
|
codemode: childCodemode.extension,
|
|
15718
16436
|
childContract: true,
|
|
15719
16437
|
autoRejectApprovals: childGate.autoReject,
|
|
@@ -15767,7 +16485,6 @@ ${text}
|
|
|
15767
16485
|
...childExploreFold ? createExploreFoldTools(childExploreFold) : []
|
|
15768
16486
|
];
|
|
15769
16487
|
const childRunaway = new RunawayGuard();
|
|
15770
|
-
const childReminders = new SystemReminderRegistry();
|
|
15771
16488
|
const requestBudget = new RequestBudget();
|
|
15772
16489
|
if (!isLockedEnso) {
|
|
15773
16490
|
childReminders.register("request-budget", () => {
|
|
@@ -15784,7 +16501,6 @@ ${text}
|
|
|
15784
16501
|
});
|
|
15785
16502
|
const rawSubTools = childTools;
|
|
15786
16503
|
const decorateChild = (tools) => decorateSessionTools(tools, {
|
|
15787
|
-
reminders: childReminders,
|
|
15788
16504
|
runaway: childRunaway,
|
|
15789
16505
|
budget: childBudget
|
|
15790
16506
|
});
|
|
@@ -15815,7 +16531,11 @@ ${text}
|
|
|
15815
16531
|
sessionManager
|
|
15816
16532
|
});
|
|
15817
16533
|
const childExtraTools = childCodemode.activeToolNames();
|
|
15818
|
-
const childCursor = isCursorModel(subModel) ? attachCursorBridgeToSession(
|
|
16534
|
+
const childCursor = isCursorModel(subModel) ? attachCursorBridgeToSession(
|
|
16535
|
+
session2,
|
|
16536
|
+
subTools.map((tool) => withSystemReminders(tool, childReminders)),
|
|
16537
|
+
cwd
|
|
16538
|
+
) : void 0;
|
|
15819
16539
|
if (childIdentity && !isLockedEnso) {
|
|
15820
16540
|
const childServers = typed ? selectedMcp : directMcp.filter((server) => !isDeferredMcp(server));
|
|
15821
16541
|
this.rememberMcpHotplug(
|
|
@@ -15826,7 +16546,8 @@ ${text}
|
|
|
15826
16546
|
childCodemode,
|
|
15827
16547
|
childIdentity.sessionId,
|
|
15828
16548
|
decorateChild(tools.map((tool) => withApproval(childGate, "mcp", tool))),
|
|
15829
|
-
childCursor
|
|
16549
|
+
childCursor,
|
|
16550
|
+
childReminders
|
|
15830
16551
|
);
|
|
15831
16552
|
}
|
|
15832
16553
|
);
|
|
@@ -15995,7 +16716,8 @@ ${text}
|
|
|
15995
16716
|
...builtin("memory", createMemoryTools(memory, { language: memoryLanguage })),
|
|
15996
16717
|
...delegation ? createDelegationTools(delegation, {
|
|
15997
16718
|
groupTasks: botGroupTasks,
|
|
15998
|
-
delegationTask: botDelegationTask
|
|
16719
|
+
delegationTask: botDelegationTask,
|
|
16720
|
+
discussMode: botDiscussMode
|
|
15999
16721
|
}) : [],
|
|
16000
16722
|
...delegation && botGroupTasks ? [createGroupTasksTool(delegation), createGroupHistoryTool(delegation)] : [],
|
|
16001
16723
|
...delegation && botRoutines ? [
|
|
@@ -16003,6 +16725,14 @@ ${text}
|
|
|
16003
16725
|
createSendImageTool(delegation, cwd, confirmOutsideImage(gate))
|
|
16004
16726
|
] : [],
|
|
16005
16727
|
...builtin("web", createWebTools({ chain: () => this.webSearchChain })),
|
|
16728
|
+
...builtin("image_generation", [
|
|
16729
|
+
createImageGenTool({
|
|
16730
|
+
getConfig: () => this.imageGeneration,
|
|
16731
|
+
cwd,
|
|
16732
|
+
remote: !!remote,
|
|
16733
|
+
confirmOutside: confirmImageReference(gate, !!remote)
|
|
16734
|
+
})
|
|
16735
|
+
]),
|
|
16006
16736
|
...builtin("todo", [createTodoTool((todos) => todoReminder.update(todos))]),
|
|
16007
16737
|
...computer ? builtin("computer", [withComputerApproval(gate, createComputerTool(computer))]) : [],
|
|
16008
16738
|
...pluginTools ? createPluginTools([...pluginToolDescriptors], pluginTools).map(
|
|
@@ -16060,12 +16790,12 @@ ${text}
|
|
|
16060
16790
|
...planGated(sessionTools),
|
|
16061
16791
|
...builtin("plan", [createSubmitPlanTool(planHost, randomUUID)])
|
|
16062
16792
|
],
|
|
16063
|
-
{
|
|
16793
|
+
{ runaway, budget }
|
|
16064
16794
|
);
|
|
16065
16795
|
codemodeHost.bindDeferredTools(
|
|
16066
16796
|
deferredMcpLoader(
|
|
16067
16797
|
gate,
|
|
16068
|
-
(tools) => decorateSessionTools(planGated(tools), {
|
|
16798
|
+
(tools) => decorateSessionTools(planGated(tools), { runaway, budget })
|
|
16069
16799
|
)
|
|
16070
16800
|
);
|
|
16071
16801
|
const { session } = await createAgentSession({
|
|
@@ -16080,7 +16810,11 @@ ${text}
|
|
|
16080
16810
|
sessionManager: resumeFile ? SessionManager.open(resumeFile, this.options.sessionDir, cwd) : SessionManager.create(cwd, this.options.sessionDir)
|
|
16081
16811
|
});
|
|
16082
16812
|
const codemodeTools = codemodeHost.activeToolNames();
|
|
16083
|
-
const cursorBridge = isCursorModel(piModel) ? attachCursorBridgeToSession(
|
|
16813
|
+
const cursorBridge = isCursorModel(piModel) ? attachCursorBridgeToSession(
|
|
16814
|
+
session,
|
|
16815
|
+
customTools.map((tool) => withSystemReminders(tool, reminders)),
|
|
16816
|
+
cwd
|
|
16817
|
+
) : void 0;
|
|
16084
16818
|
if (!cursorBridge) ensureAssistantUsage(session.messages);
|
|
16085
16819
|
console.log(
|
|
16086
16820
|
`[spawn] ${sessionId.slice(0, 8)} total ${Date.now() - spawnStart}ms (tools ${toolsMs}ms, mcp ${mcpTools.length} tools + ${deferredMcp.length} deferred servers, cwd ${cwd})`
|
|
@@ -16104,14 +16838,15 @@ ${text}
|
|
|
16104
16838
|
codemodeHost,
|
|
16105
16839
|
sessionId,
|
|
16106
16840
|
decorateSessionTools(planGated(tools.map((tool) => withApproval(gate, "mcp", tool))), {
|
|
16107
|
-
reminders,
|
|
16108
16841
|
runaway,
|
|
16109
16842
|
budget
|
|
16110
16843
|
}),
|
|
16111
|
-
cursorBridge
|
|
16844
|
+
cursorBridge,
|
|
16845
|
+
reminders
|
|
16112
16846
|
);
|
|
16113
16847
|
}
|
|
16114
16848
|
);
|
|
16849
|
+
if (instanceId) managedRef.instanceId = instanceId;
|
|
16115
16850
|
managedRef.agentControl = agentControl;
|
|
16116
16851
|
managedRef.workflowRuns = workflowRuns;
|
|
16117
16852
|
if (rolePrompt && !resumeFile) managedRef.pendingRole = rolePrompt;
|
|
@@ -16873,13 +17608,15 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
16873
17608
|
managed.pendingBuiltinTools = void 0;
|
|
16874
17609
|
managed.applyBuiltinTools(disabled);
|
|
16875
17610
|
}
|
|
16876
|
-
installAdoptedMcpTools(host, sessionId, tools, cursor) {
|
|
17611
|
+
installAdoptedMcpTools(host, sessionId, tools, cursor, reminders) {
|
|
16877
17612
|
const added = new Set(host.adoptDirectTools(tools));
|
|
16878
17613
|
if (added.size === 0) return;
|
|
16879
17614
|
if (cursor) {
|
|
16880
17615
|
for (const tool of tools) {
|
|
16881
17616
|
if (!added.has(tool.name)) continue;
|
|
16882
|
-
const bridgeTool = indexCursorTools([
|
|
17617
|
+
const bridgeTool = indexCursorTools([
|
|
17618
|
+
reminders ? withSystemReminders(tool, reminders) : tool
|
|
17619
|
+
]).get(tool.name);
|
|
16883
17620
|
if (bridgeTool) cursor.tools.set(tool.name, bridgeTool);
|
|
16884
17621
|
}
|
|
16885
17622
|
}
|
|
@@ -16978,6 +17715,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
16978
17715
|
}
|
|
16979
17716
|
case "auto_retry_start":
|
|
16980
17717
|
managed.lastRetryError = event.errorMessage || "Unknown error";
|
|
17718
|
+
managed.turnRetried = true;
|
|
16981
17719
|
this.options.emit({
|
|
16982
17720
|
type: "turn-retry",
|
|
16983
17721
|
identity: managed.identity,
|
|
@@ -17129,7 +17867,11 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
17129
17867
|
return;
|
|
17130
17868
|
}
|
|
17131
17869
|
if (lastAssistant?.stopReason === "error") {
|
|
17132
|
-
|
|
17870
|
+
const exhausted = managed.turnRetried === true && isRetryableAssistantError({
|
|
17871
|
+
stopReason: "error",
|
|
17872
|
+
errorMessage: lastAssistant.errorMessage
|
|
17873
|
+
});
|
|
17874
|
+
this.failTurn(managed, lastAssistant.errorMessage ?? "Turn failed.", false, exhausted);
|
|
17133
17875
|
return;
|
|
17134
17876
|
}
|
|
17135
17877
|
if (this.tryRefusalRetry(managed, lastAssistant)) return;
|
|
@@ -17145,6 +17887,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
17145
17887
|
completeTurn(managed, budget) {
|
|
17146
17888
|
const turnId = managed.currentTurnId ?? randomUUID();
|
|
17147
17889
|
managed.currentTurnId = void 0;
|
|
17890
|
+
managed.turnRetried = false;
|
|
17148
17891
|
managed.requestBudget?.disarm();
|
|
17149
17892
|
managed.status = "idle";
|
|
17150
17893
|
this.emitStatus(managed);
|
|
@@ -17369,7 +18112,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
17369
18112
|
await managed.session.waitForIdle();
|
|
17370
18113
|
return true;
|
|
17371
18114
|
}
|
|
17372
|
-
promptFresh(managed, text, images, deliveryId) {
|
|
18115
|
+
promptFresh(managed, text, images, deliveryId, resume) {
|
|
17373
18116
|
this.flushPendingMcpTools(managed);
|
|
17374
18117
|
this.flushPendingBuiltinTools(managed);
|
|
17375
18118
|
if (managed.session.isStreaming) {
|
|
@@ -17378,6 +18121,7 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
17378
18121
|
});
|
|
17379
18122
|
return;
|
|
17380
18123
|
}
|
|
18124
|
+
if (resume) editUnfinishedAssistantForResume(managed.session);
|
|
17381
18125
|
managed.currentTurnId = randomUUID();
|
|
17382
18126
|
ensureAssistantUsage(managed.session.messages);
|
|
17383
18127
|
void this.promptTracked(
|
|
@@ -17481,9 +18225,18 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
17481
18225
|
});
|
|
17482
18226
|
}
|
|
17483
18227
|
}
|
|
17484
|
-
|
|
18228
|
+
emitRetrySkipped(managed, reason) {
|
|
18229
|
+
this.options.emit({
|
|
18230
|
+
type: "retry-skipped",
|
|
18231
|
+
identity: managed.identity,
|
|
18232
|
+
seq: ++managed.seq,
|
|
18233
|
+
reason
|
|
18234
|
+
});
|
|
18235
|
+
}
|
|
18236
|
+
failTurn(managed, error, undelivered = false, retryExhausted = false) {
|
|
17485
18237
|
const turnId = managed.currentTurnId ?? randomUUID();
|
|
17486
18238
|
managed.currentTurnId = void 0;
|
|
18239
|
+
managed.turnRetried = false;
|
|
17487
18240
|
managed.settlePending = false;
|
|
17488
18241
|
managed.requestBudget?.disarm();
|
|
17489
18242
|
managed.contextUsage.setPendingSnapshot(void 0);
|
|
@@ -17509,7 +18262,8 @@ ${await this.runParentGate(managed, gateCommand)}` : base;
|
|
|
17509
18262
|
seq: ++managed.seq,
|
|
17510
18263
|
turnId,
|
|
17511
18264
|
error,
|
|
17512
|
-
...undelivered ? { undelivered: true } : {}
|
|
18265
|
+
...undelivered ? { undelivered: true } : {},
|
|
18266
|
+
...retryExhausted ? { retryExhausted: true } : {}
|
|
17513
18267
|
});
|
|
17514
18268
|
this.flushPendingReminders(managed);
|
|
17515
18269
|
}
|
|
@@ -18195,7 +18949,7 @@ function planFreeEditorText(text) {
|
|
|
18195
18949
|
function withPendingPlanNote(managed, text) {
|
|
18196
18950
|
text = consumeUnattendedNote(managed, text);
|
|
18197
18951
|
const note = managed.plan?.takeNote();
|
|
18198
|
-
return note ?
|
|
18952
|
+
return note ? prependTurnNote(note, text) : text;
|
|
18199
18953
|
}
|
|
18200
18954
|
function consumeRole(managed, text) {
|
|
18201
18955
|
if (!managed.pendingRole) return text;
|