@qwen-code/qwen-code 0.21.10 → 0.21.11-nightly.20260815.c396fe3d12
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/bundled/coordinate/SKILL.md +52 -0
- package/bundled/qc-helper/docs/configuration/model-providers.md +10 -8
- package/bundled/qc-helper/docs/configuration/settings.md +10 -0
- package/bundled/qc-helper/docs/extension/_meta.ts +1 -0
- package/bundled/qc-helper/docs/extension/agent-plugins.md +50 -0
- package/bundled/qc-helper/docs/extension/extension-releasing.md +3 -3
- package/bundled/qc-helper/docs/extension/introduction.md +17 -3
- package/bundled/qc-helper/docs/features/_meta.ts +1 -0
- package/bundled/qc-helper/docs/features/arena.md +4 -3
- package/bundled/qc-helper/docs/features/channels/overview.md +1 -1
- package/bundled/qc-helper/docs/features/channels/plugins.md +11 -11
- package/bundled/qc-helper/docs/features/code-review.md +1 -1
- package/bundled/qc-helper/docs/features/commands.md +7 -6
- package/bundled/qc-helper/docs/features/dual-output.md +5 -0
- package/bundled/qc-helper/docs/features/headless.md +8 -0
- package/bundled/qc-helper/docs/features/multi-agent-coordination.md +30 -0
- package/bundled/qc-helper/docs/qwen-serve.md +105 -40
- package/bundled/review/SKILL.md +72 -43
- package/chunks/{MaxSizedBox-FKXYULMW.js → MaxSizedBox-RRYY7LE5.js} +45 -44
- package/chunks/{StandaloneSessionPicker-OQS3M7AY.js → StandaloneSessionPicker-CK3O3N7F.js} +68 -67
- package/chunks/{acp-startup-profiler-VNTFWYAC.js → acp-startup-profiler-SVPUHLXV.js} +2 -2
- package/chunks/{acpAgent-AGS6HLQQ.js → acpAgent-DXUWYWDM.js} +1889 -640
- package/chunks/{agent-4NCVO27U.js → agent-DEPG4BP7.js} +42 -41
- package/chunks/agent-headless-VLBUWGPP.js +87 -0
- package/chunks/{anthropicContentGenerator-D3Y4RFT4.js → anthropicContentGenerator-YDT4EOKO.js} +8 -8
- package/chunks/{artifact-tool-N652YE4L.js → artifact-tool-4GCQQDZI.js} +2 -2
- package/chunks/{askUserQuestion-ONW74PKJ.js → askUserQuestion-HZJJLR3Z.js} +2 -2
- package/chunks/bridge-U7LETTTF.js +104 -0
- package/chunks/{ca-ZLKAB4K3.js → ca-4CQ6MYNQ.js} +2 -1
- package/chunks/{channel-management-service-PHELKOW2.js → channel-management-service-OADNGQM3.js} +6 -6
- package/chunks/channel-settings-store-B2GRIZ2D.js +102 -0
- package/chunks/{channel-worker-group-WQP4RCDO.js → channel-worker-group-IHBIHQ45.js} +9 -8
- package/chunks/{channel-worker-manager-MRDFAKIM.js → channel-worker-manager-GEHYJ5AE.js} +9 -8
- package/chunks/{channel-worker-supervisor-IVSDIMI4.js → channel-worker-supervisor-ZJIIWM4I.js} +7 -6
- package/chunks/{chunk-26CXSA6V.js → chunk-25VWCPYE.js} +2 -2
- package/chunks/{chunk-DP3IHZGG.js → chunk-2AUM35J5.js} +59 -7
- package/chunks/{chunk-URKIBIFC.js → chunk-2QHWLRQ2.js} +3 -3
- package/chunks/{chunk-4PYCZH2V.js → chunk-2ZWH53I4.js} +3 -3
- package/chunks/{chunk-UVX4Y6IN.js → chunk-3AEKDXKT.js} +1 -1
- package/chunks/{chunk-ABVRJU3D.js → chunk-3ER3FWZM.js} +9 -9
- package/chunks/{chunk-DZUO626D.js → chunk-3GM5DLBI.js} +3 -3
- package/chunks/{chunk-VSFKIRRW.js → chunk-3NBTNFNC.js} +4 -4
- package/chunks/{chunk-NEOXOWYH.js → chunk-3QZY3JSR.js} +7 -7
- package/chunks/{chunk-BKHCW2BI.js → chunk-3VUENPWF.js} +10 -0
- package/chunks/{chunk-67EWJE77.js → chunk-45NQKMYB.js} +1 -1
- package/chunks/{chunk-KKBPOU75.js → chunk-4AOVQPJU.js} +1 -1
- package/chunks/{chunk-OONWZLFK.js → chunk-4EB5GRRC.js} +4 -4
- package/chunks/{chunk-YGT2AUJ7.js → chunk-4KM2SYK5.js} +39 -19
- package/chunks/{chunk-Y3OVRWRY.js → chunk-4N4JVRZA.js} +1 -1
- package/chunks/{chunk-VNNWAZSI.js → chunk-56HVDG3M.js} +6 -6
- package/chunks/{chunk-TRRF5BSP.js → chunk-5C42HXEX.js} +1 -1
- package/chunks/{chunk-J6SZID63.js → chunk-5RUCD4ED.js} +2 -2
- package/chunks/{chunk-WAUGQKUU.js → chunk-63FNZTWG.js} +9 -5
- package/chunks/{chunk-F6WDTQ3M.js → chunk-655DWW7X.js} +5 -5
- package/chunks/{chunk-AAE6SR4Q.js → chunk-7P5NK5EI.js} +1 -1
- package/chunks/{chunk-MZSJ43WV.js → chunk-7U5G6JXI.js} +24 -2
- package/chunks/{chunk-GWVUR3QZ.js → chunk-7WROZ3E6.js} +3 -3
- package/chunks/{chunk-PBRVUF5B.js → chunk-A6NRNRKE.js} +1 -1
- package/chunks/{chunk-IBUGFUXC.js → chunk-A6TJ7QUA.js} +13 -13
- package/chunks/{chunk-DCZEPFB4.js → chunk-ADM4C4TX.js} +3 -3
- package/chunks/{chunk-UBX6NL47.js → chunk-AGWK35OJ.js} +47 -3
- package/chunks/{chunk-4MKXUHXY.js → chunk-AGWZRQJJ.js} +5 -5
- package/chunks/{chunk-GNPNYXJB.js → chunk-AKBFSOC5.js} +2 -2
- package/chunks/{chunk-YWPSGJFI.js → chunk-ARSQPRYL.js} +2 -2
- package/chunks/{chunk-IWTMYQ32.js → chunk-AVKPDOQZ.js} +12 -11
- package/chunks/{chunk-DX3RGJMS.js → chunk-AW27A43Y.js} +76 -19
- package/chunks/{chunk-MIKXJYZB.js → chunk-AZPFLLFR.js} +315 -299
- package/chunks/{chunk-2PLNY5TN.js → chunk-BBCGHZ4S.js} +4 -4
- package/chunks/{chunk-KID7K6H2.js → chunk-BP5VZBVK.js} +6 -6
- package/chunks/{chunk-LLCWZQCU.js → chunk-BRQR2FJ5.js} +3 -3
- package/chunks/{chunk-LHEC5V6G.js → chunk-BSR5AXZR.js} +4 -3
- package/chunks/{chunk-ONSZH6VM.js → chunk-CGM3E75C.js} +2 -2
- package/chunks/{chunk-SEZ556DZ.js → chunk-CPFFU46D.js} +1 -1
- package/chunks/{chunk-H6XPXXMH.js → chunk-CQ35AJ4Z.js} +252 -254
- package/chunks/{chunk-7MH4J33A.js → chunk-D2RNVVH6.js} +2 -2
- package/chunks/{chunk-M6HMMKVG.js → chunk-D7QGE3RT.js} +1 -1
- package/chunks/{chunk-UMD7WQTR.js → chunk-D7VALEOK.js} +13 -9
- package/chunks/chunk-DAV4QFD5.js +1280 -0
- package/chunks/{chunk-B2GJNDTV.js → chunk-DD6O3ZRD.js} +1 -1
- package/chunks/{chunk-HUWENAHO.js → chunk-DEDESZDL.js} +1 -1
- package/chunks/{chunk-3P2LV43B.js → chunk-DG4IQ6JG.js} +3 -3
- package/chunks/{chunk-QUI267ZP.js → chunk-DPTMKFIH.js} +492 -63
- package/chunks/{chunk-Q3JQ7OSU.js → chunk-EJOGLSNJ.js} +1 -1
- package/chunks/{chunk-NRLFZWCT.js → chunk-EQHCHTHC.js} +48 -5
- package/chunks/{chunk-P3BJLFSZ.js → chunk-EQR7YDXY.js} +3 -3
- package/chunks/{chunk-4WL6SY4F.js → chunk-EQUXHAFW.js} +1 -1
- package/chunks/{chunk-Q3AL4JQ3.js → chunk-F5BD3RNA.js} +2 -2
- package/chunks/{chunk-A7XMDZRI.js → chunk-FJYUSD2N.js} +5 -5
- package/chunks/{chunk-JT7XS4YW.js → chunk-FMIH5KMQ.js} +1 -1
- package/chunks/{chunk-ZBVS26BY.js → chunk-FPGTNKCP.js} +7 -5
- package/chunks/{chunk-W5UC37EE.js → chunk-FQDCO3CJ.js} +12 -1
- package/chunks/{chunk-EQL65XGA.js → chunk-FRHQQC2Z.js} +47 -21
- package/chunks/{chunk-FVKHVJZQ.js → chunk-G6MUFRNI.js} +1 -1
- package/chunks/{chunk-D27I6YJT.js → chunk-GB245X4Z.js} +129 -26
- package/chunks/{chunk-WCG5O7IP.js → chunk-GZDWTBT3.js} +2 -2
- package/chunks/{chunk-AOHJKPKL.js → chunk-H7TMVHKE.js} +1 -1
- package/chunks/{chunk-ZJ4W6SUY.js → chunk-HDRTQ5DH.js} +3 -3
- package/chunks/{chunk-ZZCWJWTF.js → chunk-HG3UBTJ4.js} +31 -11
- package/chunks/chunk-HHJLM3WQ.js +41 -0
- package/chunks/{chunk-6LP743KE.js → chunk-HHZU6ZZM.js} +79 -113
- package/chunks/{chunk-OIVKILPI.js → chunk-HOSVOUDK.js} +74 -0
- package/chunks/{chunk-DA4HRSBW.js → chunk-HTYND72J.js} +1 -1
- package/chunks/{chunk-ZRBMO3C7.js → chunk-IKFHTAQW.js} +1 -1
- package/chunks/{chunk-KZ22NXBY.js → chunk-IVROQYG5.js} +4 -4
- package/chunks/{chunk-UDXSXLER.js → chunk-IW6RQPQB.js} +14 -4
- package/chunks/{chunk-F24A2JBM.js → chunk-J6JVP7ZZ.js} +1180 -254
- package/chunks/{chunk-ECWR5LQR.js → chunk-JB6IM2TJ.js} +3 -3
- package/chunks/{chunk-MVUQRLOH.js → chunk-JRIVMPD2.js} +3 -3
- package/chunks/{chunk-Q7YDKOGY.js → chunk-JVEGA3MM.js} +1 -1
- package/chunks/{chunk-4TRQPFDP.js → chunk-K34GJQOZ.js} +140 -20
- package/chunks/{chunk-W4RQUHY3.js → chunk-K5IDV3PC.js} +184 -22
- package/chunks/{chunk-NDU63YLI.js → chunk-KD6FGI2Q.js} +4 -4
- package/chunks/{chunk-HV76SFIA.js → chunk-KEC5FHLM.js} +3 -3
- package/chunks/{chunk-IIJEYBNH.js → chunk-KLOMACIR.js} +197 -60
- package/chunks/{chunk-Z4JX4NSH.js → chunk-KSPRBJJ3.js} +50 -50
- package/chunks/{chunk-KONVMRK7.js → chunk-KX5TNFCJ.js} +1 -1
- package/chunks/{chunk-QGNOFE5E.js → chunk-KX7PC5QG.js} +1 -1
- package/chunks/{chunk-OJUQF2PL.js → chunk-LEKKQEQW.js} +5 -5
- package/chunks/{chunk-COBO5EBO.js → chunk-LSRI3ND3.js} +1 -1
- package/chunks/{chunk-BSI645OU.js → chunk-LUISTZXI.js} +3 -3
- package/chunks/{chunk-YTFDX4PR.js → chunk-M6NDLY2T.js} +1 -1
- package/chunks/{chunk-EBZ6BJTF.js → chunk-MNUKNVYQ.js} +1 -1
- package/chunks/{chunk-VFMASYQA.js → chunk-MS7GNABG.js} +3 -0
- package/chunks/{chunk-EI3NWELG.js → chunk-MSSNVG2G.js} +6430 -4463
- package/chunks/{chunk-L2AFWWJE.js → chunk-N4SVADAV.js} +351 -144
- package/chunks/{chunk-URK542T4.js → chunk-NF5J2WFA.js} +15 -2
- package/chunks/{chunk-EI3HZX6C.js → chunk-NLFLYSS4.js} +1 -1
- package/chunks/{chunk-NV3F44FL.js → chunk-NW2GIPG3.js} +2 -2
- package/chunks/{chunk-OQTXYMKW.js → chunk-NX4A23LY.js} +3 -3
- package/chunks/{chunk-E2FPSSKP.js → chunk-OK47XBYH.js} +97 -10
- package/chunks/{chunk-EKPKKXY2.js → chunk-OWGRUU7F.js} +1 -1
- package/chunks/{chunk-CTJLZLB5.js → chunk-OYWVIXHT.js} +1 -1
- package/chunks/{chunk-47PEPJO7.js → chunk-P7PSGVWP.js} +3 -3
- package/chunks/{chunk-6Q5ABMTU.js → chunk-PTSEETCO.js} +23 -19
- package/chunks/{chunk-6ZRFAKXK.js → chunk-PVXEJB66.js} +1 -1
- package/chunks/{chunk-EUNWC2VS.js → chunk-PZW46OTB.js} +2 -2
- package/chunks/{chunk-QSWDGAIC.js → chunk-QILD6R27.js} +1 -1
- package/chunks/{chunk-CKASRHZI.js → chunk-QLTATTPS.js} +1 -1
- package/chunks/{chunk-2UUMVNYT.js → chunk-QPBFRWCP.js} +3 -3
- package/chunks/{chunk-QJMOAMXT.js → chunk-QQSXM3FE.js} +8 -8
- package/chunks/{chunk-AEL7KN2O.js → chunk-RN7GFREP.js} +2 -2
- package/chunks/{chunk-AQAJJMRR.js → chunk-RYSBWLLV.js} +1 -1
- package/chunks/{chunk-MFDYOYZZ.js → chunk-SYHXR6WM.js} +26 -3
- package/chunks/{chunk-SR7RZ4MS.js → chunk-TB4YFWXG.js} +2 -2
- package/chunks/{chunk-IRZ2ZH72.js → chunk-TCMU4ZUE.js} +4 -4
- package/chunks/{chunk-OWMAZHIX.js → chunk-TMFWI4RC.js} +1 -1
- package/chunks/{chunk-TZEZYNYD.js → chunk-TQDFSQQF.js} +1 -1
- package/chunks/{chunk-IA7TGCN2.js → chunk-TTRH3RTQ.js} +4 -4
- package/chunks/{chunk-PJRW65JO.js → chunk-TXP5NGG3.js} +1 -1
- package/chunks/{chunk-VWKER4ZH.js → chunk-ULJGMSG5.js} +3 -3
- package/chunks/{chunk-2FRY5CRX.js → chunk-ULNWG62W.js} +3 -3
- package/chunks/{chunk-XVHYA33G.js → chunk-URYJYT5W.js} +4 -4
- package/chunks/{chunk-7GTMV7UE.js → chunk-US7J7LJT.js} +10786 -4462
- package/chunks/{chunk-HGCQ5SE7.js → chunk-UXEO7E3V.js} +21 -0
- package/chunks/{chunk-NV65ZUVM.js → chunk-VKT2R3NB.js} +1 -1
- package/chunks/{chunk-CPG6P4GG.js → chunk-VPV7WBVT.js} +1 -1
- package/chunks/{chunk-QG3FFJYU.js → chunk-VXSD4AGT.js} +1 -1
- package/chunks/{chunk-XCGIMOLN.js → chunk-WCCLLK7X.js} +14 -1
- package/chunks/{chunk-VJNBRRZG.js → chunk-WZMH7II3.js} +1 -1
- package/chunks/{chunk-5MZCSWI4.js → chunk-WZRLXVLJ.js} +1185 -1451
- package/chunks/{chunk-YF5MALI4.js → chunk-X5QJFMLY.js} +21 -17
- package/chunks/{chunk-DREZZAZM.js → chunk-XDRXOSAD.js} +13 -5
- package/chunks/{chunk-FOGU3LJX.js → chunk-YBHUXEC6.js} +1 -1
- package/chunks/{chunk-GM463R2B.js → chunk-YBVVOSOH.js} +1 -1
- package/chunks/{chunk-PYQADEFD.js → chunk-YIGGWOJE.js} +1 -1
- package/chunks/{chunk-XCWO3SMQ.js → chunk-YILJKX2T.js} +3 -3
- package/chunks/{chunk-Y4R47ZUH.js → chunk-YM3I6VW5.js} +7 -7
- package/chunks/{chunk-OCSFNUU4.js → chunk-YMALTWIZ.js} +13 -11
- package/chunks/{chunk-WOJZWRAZ.js → chunk-YRLW2MSX.js} +1 -1
- package/chunks/{chunk-UEOKWYGY.js → chunk-YYIOFWVH.js} +11 -11
- package/chunks/chunk-Z7B6SRPM.js +32 -0
- package/chunks/{chunk-S6HYI3MF.js → chunk-ZBB5EZZV.js} +2 -2
- package/chunks/{chunk-VKJ4KTPJ.js → chunk-ZLCT4C5A.js} +1 -1
- package/chunks/{chunk-O3EU6GMH.js → chunk-ZO37CAQH.js} +27 -4
- package/chunks/{computer-use-WQFK33Z3.js → computer-use-TMDO6TEC.js} +42 -41
- package/chunks/{config-utils-ULCSRMWD.js → config-utils-Z3OW3IQG.js} +6 -6
- package/chunks/{contextCommand-7EOZND7C.js → contextCommand-IUQ6G5ES.js} +44 -43
- package/chunks/{core-runtime-FGMQRM6E.js → core-runtime-HAZLPQXI.js} +42 -41
- package/chunks/{create-sub-session-QM2K5HLZ.js → create-sub-session-GREIOIZU.js} +42 -41
- package/chunks/{create-sub-session-QIDZUOPU.js → create-sub-session-XT6DLYOE.js} +2 -2
- package/chunks/{cron-create-VONA5JYY.js → cron-create-2JZ2TWTF.js} +4 -4
- package/chunks/{cron-delete-5JXSP2MI.js → cron-delete-CTPD2P26.js} +4 -4
- package/chunks/{cron-list-KE4F2CIR.js → cron-list-V44KHAF6.js} +4 -4
- package/chunks/{daemon-GWD7BT6E.js → daemon-GED37WOX.js} +216 -9
- package/chunks/daemon-git-worktree-guard-BSKVBYPM.js +2062 -0
- package/chunks/daemon-status-provider-7UK2DVVN.js +102 -0
- package/chunks/daemon-trust-policy-BZEALQSM.js +99 -0
- package/chunks/{daemon-trust-policy-monitor-6UKEABN5.js → daemon-trust-policy-monitor-P7OM342T.js} +49 -48
- package/chunks/{de-LIW4XVLN.js → de-UBEBKG6V.js} +2 -1
- package/chunks/{deferred-core-runtime-67GJXHXS.js → deferred-core-runtime-MTDXZT6B.js} +42 -41
- package/chunks/{display-image-NQRSIBXM.js → display-image-M2ELAVN4.js} +4 -4
- package/chunks/{dist-OTUO3AS2.js → dist-4ZPG4BY6.js} +13 -5
- package/chunks/{dist-B2CGTW6T.js → dist-BROOP2EG.js} +3 -3
- package/chunks/{dist-EZE3V3Q7.js → dist-IYYN3RUT.js} +3 -3
- package/chunks/{dist-3NTTUAHT.js → dist-JWMKPWT5.js} +5 -3
- package/chunks/{dist-Z3CS4OVP.js → dist-K7IQB53U.js} +11 -5
- package/chunks/{dist-J47AXBZC.js → dist-MAQXAQ2Y.js} +3 -3
- package/chunks/{dist-6BMOAE3Z.js → dist-WJ4BHIEW.js} +4 -4
- package/chunks/{dist-EWW3J4HQ.js → dist-YEPL4RAW.js} +3 -3
- package/chunks/{earlyInputCapture-IWMYR6OB.js → earlyInputCapture-BGZYFN2F.js} +43 -42
- package/chunks/{edit-ZFGROCAF.js → edit-ASQVJARF.js} +45 -43
- package/chunks/{en-SY5GTIGX.js → en-X6YV7GME.js} +2 -1
- package/chunks/{enter-worktree-TZZZCDM5.js → enter-worktree-WIUNMC64.js} +42 -41
- package/chunks/{enterPlanMode-U77BI3R6.js → enterPlanMode-TUBB2L7O.js} +42 -41
- package/chunks/{environment-HC37DS2I.js → environment-RWSNEY4T.js} +45 -44
- package/chunks/{errors-6AG54JPD.js → errors-44QVVNGT.js} +44 -43
- package/chunks/{exit-worktree-UYYWFPNK.js → exit-worktree-WPBRPIRR.js} +42 -41
- package/chunks/exitPlanMode-AP7J626M.js +85 -0
- package/chunks/{external-tool-guard-provider-5HTGOPGU.js → external-tool-guard-provider-TE4DRY36.js} +1 -1
- package/chunks/{fast-path-F5FSZ3O7.js → fast-path-XG5KXXLS.js} +6 -6
- package/chunks/{fast-path-settings-RPAVBD7P.js → fast-path-settings-LNOFM2YP.js} +2 -2
- package/chunks/{fr-RQFO7U4P.js → fr-VENTC2BS.js} +2 -1
- package/chunks/{gemini-NKQHYM36.js → gemini-PGXORAFF.js} +112 -103
- package/chunks/{geminiContentGenerator-HCWZOUX3.js → geminiContentGenerator-ZQVVD4J4.js} +6 -6
- package/chunks/{glob-3PDXKBAO.js → glob-Q6LWKMBU.js} +42 -41
- package/chunks/{goal-tools-SWNB6GP4.js → goal-tools-M4UDAZXP.js} +4 -4
- package/chunks/{grep-5HZKZYVD.js → grep-C67Z35I4.js} +42 -41
- package/chunks/handleAutoUpdate-75L74MB4.js +94 -0
- package/chunks/{i18n-Q27KKNDL.js → i18n-GYUC23UJ.js} +43 -42
- package/chunks/{image-gen-2Z2RJ6W7.js → image-gen-XE56S4MG.js} +10 -10
- package/chunks/initializer-V7XZVY35.js +100 -0
- package/chunks/{installationInfo-XXB75T7O.js → installationInfo-S5PPSD7T.js} +43 -42
- package/chunks/{ja-KOZKHJHZ.js → ja-QHT4EQTO.js} +2 -1
- package/chunks/{keychain-token-storage-TVAMTNP7.js → keychain-token-storage-NKKCUHI2.js} +2 -2
- package/chunks/list-JJ2FB7SP.js +103 -0
- package/chunks/{list-agents-Z4WABFDZ.js → list-agents-O6WSY4CT.js} +2 -2
- package/chunks/loadedSettingsAdapter-LNUDRGW5.js +97 -0
- package/chunks/{loggingContentGenerator-6NTFBM7Q.js → loggingContentGenerator-HCJ2DX2S.js} +162 -112
- package/chunks/{loop-wakeup-UZ5RL5Y2.js → loop-wakeup-GVQRMUKS.js} +5 -5
- package/chunks/{ls-TVHDGIES.js → ls-6W2D7TKU.js} +4 -4
- package/chunks/{lsp-CVN6OQPI.js → lsp-NJ4KFBI2.js} +2 -2
- package/chunks/{managed-npm-update-SPHYQUWZ.js → managed-npm-update-MDF2JDTH.js} +45 -44
- package/chunks/mcp-M5OML5FI.js +97 -0
- package/chunks/{monitor-ZBBPAA54.js → monitor-U5NM5ONC.js} +42 -41
- package/chunks/nonInteractiveCli-TX3QP7JT.js +163 -0
- package/chunks/{notebook-edit-5W3FW7Z2.js → notebook-edit-Q7SUR44R.js} +42 -41
- package/chunks/{openaiContentGenerator-TQANPEVZ.js → openaiContentGenerator-2H5CYLXP.js} +29 -29
- package/chunks/{pidfile-EQOBLH4E.js → pidfile-SHSMSAZR.js} +43 -42
- package/chunks/{processUtils-7XQG7EHS.js → processUtils-GZAP6EYW.js} +2 -2
- package/chunks/{pt-U6AOCTMF.js → pt-VL3I5RNY.js} +2 -1
- package/chunks/{qwenContentGenerator-BKCPHHXU.js → qwenContentGenerator-2624VVZH.js} +48 -48
- package/chunks/{qwenOAuth2-BJ6PQKE6.js → qwenOAuth2-AAWH3C7N.js} +9 -9
- package/chunks/read-file-ZWGQE2TE.js +32 -0
- package/chunks/{read-mcp-resource-PZ4ZF6YL.js → read-mcp-resource-GWCP23WG.js} +2 -2
- package/chunks/{read-package-up-TCM6I7S2.js → read-package-up-K6RKTL5D.js} +1 -1
- package/chunks/{record-artifact-P4HFMS7X.js → record-artifact-IYQDEYMV.js} +3 -3
- package/chunks/{resumeHistoryUtils-6N6XGJJW.js → resumeHistoryUtils-7N2H4QCU.js} +50 -49
- package/chunks/ripGrep-6JGJDWYB.js +85 -0
- package/chunks/{ru-CMX4UMYP.js → ru-4RCKL4PY.js} +2 -1
- package/chunks/{run-qwen-serve-BCKBCAMX.js → run-qwen-serve-2A6RHHI7.js} +197 -90
- package/chunks/{runtime-E2437YKL.js → runtime-NPYVZVRI.js} +55 -54
- package/chunks/{scheduler-K3D5Z655.js → scheduler-UMKTEQAM.js} +44 -43
- package/chunks/{sdk-exporters-http-XVTZQRCE.js → sdk-exporters-http-NHBYB5FZ.js} +11 -7
- package/chunks/{sdk-impl-7W7AKCS4.js → sdk-impl-SK4P5WON.js} +13 -10
- package/chunks/{send-message-CAMSLG2L.js → send-message-O7FO63UK.js} +6 -6
- package/chunks/serve-LYADPWRV.js +107 -0
- package/chunks/{server-UD6INW7J.js → server-WMVPH4G4.js} +1137 -382
- package/chunks/{session-GR4ZEVW4.js → session-LE6O62ZE.js} +122 -102
- package/chunks/{settings-5O24D3OJ.js → settings-2IPZYYGS.js} +48 -47
- package/chunks/{shell-UTLWLG5G.js → shell-VOBAZFFI.js} +42 -41
- package/chunks/{skill-QQAZL4VO.js → skill-6LKOWJV4.js} +19 -19
- package/chunks/{skill-settings-P3YHJVBZ.js → skill-settings-J5IHQA7L.js} +48 -47
- package/chunks/spawnChannel-TLW7N3SM.js +98 -0
- package/chunks/{standalone-update-QP742MGP.js → standalone-update-6OFPUBEM.js} +44 -43
- package/chunks/{startInteractiveUI-YCS6AEPN.js → startInteractiveUI-KVHNCR2L.js} +836 -444
- package/chunks/{syntheticOutput-PEBJQYJV.js → syntheticOutput-DVHJMUGV.js} +3 -3
- package/chunks/{task-create-5NWCQSJF.js → task-create-4NC7PDI4.js} +10 -10
- package/chunks/{task-list-53265TRZ.js → task-list-LBSRMOC7.js} +5 -5
- package/chunks/{task-stop-FPCOIRYX.js → task-stop-YFNATTIM.js} +2 -2
- package/chunks/{task-update-5HN577LS.js → task-update-BPLM52GD.js} +10 -10
- package/chunks/{team-create-WFH7OCDQ.js → team-create-INCC7G74.js} +44 -43
- package/chunks/{team-delete-MMQB4OSC.js → team-delete-MKYMYBFM.js} +5 -5
- package/chunks/{team-plan-approval-EGTT53MV.js → team-plan-approval-6DCWGZQ4.js} +42 -41
- package/chunks/{terminal-image-renderer-BWRESAQ7.js → terminal-image-renderer-O5EDW64G.js} +44 -43
- package/chunks/theme-manager-NZZO4SWE.js +89 -0
- package/chunks/{todoWrite-JGV6VLOX.js → todoWrite-K5K7NRE5.js} +4 -4
- package/chunks/{tool-search-TI5PTIBF.js → tool-search-JB2PXD5P.js} +19 -19
- package/chunks/total-session-admission-NWNMU6AW.js +99 -0
- package/chunks/{trustedFolders-4KYHA4IG.js → trustedFolders-A5ZWRRSP.js} +43 -42
- package/chunks/{update-relaunch-WB6LGIF2.js → update-relaunch-GG7EDBEA.js} +5 -5
- package/chunks/{updateCheck-LOS5GYFC.js → updateCheck-P6JJ4MBU.js} +48 -47
- package/chunks/{useAutoAcceptIndicator-MHAPY52L.js → useAutoAcceptIndicator-KV2AANVG.js} +53 -52
- package/chunks/{validateNonInterActiveAuth-QV22HNQU.js → validateNonInterActiveAuth-HXRCYXY7.js} +89 -88
- package/chunks/{version-DALWZHKQ.js → version-HH5V762G.js} +2 -2
- package/chunks/{web-fetch-JMJVMYFE.js → web-fetch-LVXPFB5O.js} +19 -19
- package/chunks/{web-search-DNDUIPU5.js → web-search-4E234FSM.js} +11 -11
- package/chunks/{workflow-JGNN64PM.js → workflow-GUE6WIMP.js} +117 -50
- package/chunks/workspace-providers-status-TUWLGJOF.js +100 -0
- package/chunks/{workspace-registration-store-LRJG7QA4.js → workspace-registration-store-22XXHPKR.js} +1 -1
- package/chunks/{workspace-registry-KVXIFM36.js → workspace-registry-HUFJF5W5.js} +50 -49
- package/chunks/{workspace-service-PO4AAKKT.js → workspace-service-NAGTBJXJ.js} +54 -53
- package/chunks/workspace-skills-status-LWDBXAQI.js +100 -0
- package/chunks/{workspace-trust-reconciler-DOZPCVHG.js → workspace-trust-reconciler-DLWV2ZO6.js} +57 -56
- package/chunks/write-file-QVHVOKKR.js +87 -0
- package/chunks/{zh-AGL2FVBI.js → zh-LMSTK4WD.js} +2 -1
- package/chunks/{zh-TW-KI66MHQY.js → zh-TW-SQ4HTSCW.js} +2 -1
- package/chunks/{zoom-image-CNC77ZMA.js → zoom-image-CJDXYWJH.js} +15 -15
- package/cli.js +18 -17
- package/locales/ca.js +1 -0
- package/locales/de.js +1 -0
- package/locales/en.js +1 -0
- package/locales/fr.js +1 -0
- package/locales/ja.js +1 -0
- package/locales/pt.js +1 -0
- package/locales/ru.js +1 -0
- package/locales/zh-TW.js +1 -0
- package/locales/zh.js +1 -0
- package/package.json +4 -4
- package/web-shell/assets/{arc-CDk0d60K.js → arc-DagtOPoO.js} +1 -1
- package/web-shell/assets/{architectureDiagram-3BPJPVTR-h-W3I2lP.js → architectureDiagram-3BPJPVTR-Dc3kGCBm.js} +1 -1
- package/web-shell/assets/{blockDiagram-GPEHLZMM-D1pvSmZg.js → blockDiagram-GPEHLZMM-BUZvQLL_.js} +1 -1
- package/web-shell/assets/{c4Diagram-AAUBKEIU-ByAm5ZNf.js → c4Diagram-AAUBKEIU-BbBgCu9K.js} +1 -1
- package/web-shell/assets/channel-aMHKHCQ2.js +1 -0
- package/web-shell/assets/{chunk-2J33WTMH-VrGPPOGV.js → chunk-2J33WTMH-CZ4miMNB.js} +1 -1
- package/web-shell/assets/{chunk-4BX2VUAB-B7hTowgG.js → chunk-4BX2VUAB-B2_qQSGx.js} +1 -1
- package/web-shell/assets/{chunk-55IACEB6-j1Fq8DpE.js → chunk-55IACEB6-EdmTwZW7.js} +1 -1
- package/web-shell/assets/{chunk-727SXJPM-UjABYpF2.js → chunk-727SXJPM-l2EpyrLV.js} +1 -1
- package/web-shell/assets/{chunk-AQP2D5EJ-D4uBItrs.js → chunk-AQP2D5EJ-0q9sx5lV.js} +1 -1
- package/web-shell/assets/{chunk-FMBD7UC4-DeFbKlb8.js → chunk-FMBD7UC4-CbGnA4Dp.js} +1 -1
- package/web-shell/assets/{chunk-ND2GUHAM-rQJ8TIgT.js → chunk-ND2GUHAM-D8JBELgZ.js} +1 -1
- package/web-shell/assets/{chunk-QZHKN3VN-DAGcRxvq.js → chunk-QZHKN3VN-DQMpGGOO.js} +1 -1
- package/web-shell/assets/classDiagram-4FO5ZUOK-zASpLzDx.js +1 -0
- package/web-shell/assets/classDiagram-v2-Q7XG4LA2-zASpLzDx.js +1 -0
- package/web-shell/assets/{cose-bilkent-S5V4N54A-MaE7MJSt.js → cose-bilkent-S5V4N54A-DzM-ZRsM.js} +1 -1
- package/web-shell/assets/{dagre-BM42HDAG-DzijYGSb.js → dagre-BM42HDAG-uxLS-TtN.js} +1 -1
- package/web-shell/assets/{diagram-2AECGRRQ-WdbG7WnX.js → diagram-2AECGRRQ-DH7Gnqzr.js} +1 -1
- package/web-shell/assets/{diagram-5GNKFQAL-NYutsBnw.js → diagram-5GNKFQAL-B2TngKRK.js} +1 -1
- package/web-shell/assets/{diagram-KO2AKTUF-Dqg0eBY0.js → diagram-KO2AKTUF-DQ61-HiV.js} +1 -1
- package/web-shell/assets/{diagram-LMA3HP47-C7vRP2Lb.js → diagram-LMA3HP47-By6qvgAT.js} +1 -1
- package/web-shell/assets/{diagram-OG6HWLK6-B2sEPpPt.js → diagram-OG6HWLK6-ClVSEz-3.js} +1 -1
- package/web-shell/assets/{erDiagram-TEJ5UH35-a4zIbzm8.js → erDiagram-TEJ5UH35-C9gFc5Fg.js} +1 -1
- package/web-shell/assets/{flowDiagram-I6XJVG4X-BK9y89ya.js → flowDiagram-I6XJVG4X-BWPLLJ5-.js} +1 -1
- package/web-shell/assets/{ganttDiagram-6RSMTGT7-wUQTSNvV.js → ganttDiagram-6RSMTGT7-C6RMacQQ.js} +1 -1
- package/web-shell/assets/{gitGraphDiagram-PVQCEYII-Dnzt4SAi.js → gitGraphDiagram-PVQCEYII-LnqiWuka.js} +1 -1
- package/web-shell/assets/index---fOcMdS.js +1789 -0
- package/web-shell/assets/{index-BA3wUcKL.js → index-B9iqcrv0.js} +1 -1
- package/web-shell/assets/index-BIGQygTL.css +5 -0
- package/web-shell/assets/{infoDiagram-5YYISTIA-DcaoToij.js → infoDiagram-5YYISTIA-Bc4iS8YB.js} +1 -1
- package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-DzduqhP2.js → ishikawaDiagram-YF4QCWOH-9pH4Dpnd.js} +1 -1
- package/web-shell/assets/{journeyDiagram-JHISSGLW-BvviZR_O.js → journeyDiagram-JHISSGLW-C-YMnw2W.js} +1 -1
- package/web-shell/assets/{kanban-definition-UN3LZRKU-Efm2JxY3.js → kanban-definition-UN3LZRKU-D-PaAIp-.js} +1 -1
- package/web-shell/assets/{linear-DtY3IbOs.js → linear-DpLgI2kt.js} +1 -1
- package/web-shell/assets/{mermaid.core-PzpFqoMe.js → mermaid.core-nZbOHGxx.js} +5 -5
- package/web-shell/assets/{mindmap-definition-RKZ34NQL-BLlTkHS0.js → mindmap-definition-RKZ34NQL-Dq0xxnET.js} +1 -1
- package/web-shell/assets/{pieDiagram-4H26LBE5-D-mKF-jE.js → pieDiagram-4H26LBE5-ctqG2eeF.js} +1 -1
- package/web-shell/assets/{quadrantDiagram-W4KKPZXB-DYCzslGm.js → quadrantDiagram-W4KKPZXB-MivToddn.js} +1 -1
- package/web-shell/assets/{requirementDiagram-4Y6WPE33-Dfpxlk7R.js → requirementDiagram-4Y6WPE33-DrLLnkpQ.js} +1 -1
- package/web-shell/assets/{sankeyDiagram-5OEKKPKP-D5cRaaxh.js → sankeyDiagram-5OEKKPKP-sYdYhdpV.js} +1 -1
- package/web-shell/assets/{sequenceDiagram-3UESZ5HK-s04DReiS.js → sequenceDiagram-3UESZ5HK-CuvhxDOs.js} +1 -1
- package/web-shell/assets/{stateDiagram-AJRCARHV-01UNFgnb.js → stateDiagram-AJRCARHV-BLZgbV7Q.js} +1 -1
- package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DR_gXrIC.js +1 -0
- package/web-shell/assets/{timeline-definition-PNZ67QCA-DX8_wZBC.js → timeline-definition-PNZ67QCA-lNr2Uz_Q.js} +1 -1
- package/web-shell/assets/{vennDiagram-CIIHVFJN-BK0FlBme.js → vennDiagram-CIIHVFJN-CoaexGVO.js} +1 -1
- package/web-shell/assets/{wardley-L42UT6IY-DkPc9UlD.js → wardley-L42UT6IY-DG1vhGKA.js} +1 -1
- package/web-shell/assets/{wardleyDiagram-YWT4CUSO-DNKkpDAo.js → wardleyDiagram-YWT4CUSO-CqNjF5xC.js} +1 -1
- package/web-shell/assets/{xychartDiagram-2RQKCTM6-CiPwg8QG.js → xychartDiagram-2RQKCTM6-BXg1gx3C.js} +1 -1
- package/web-shell/index.html +2 -2
- package/chunks/agent-headless-HYEHZFH6.js +0 -86
- package/chunks/bridge-FHINXZMN.js +0 -103
- package/chunks/channel-settings-store-OXYG5S5X.js +0 -101
- package/chunks/chunk-I5VM3SKY.js +0 -451
- package/chunks/chunk-PDPFQ2FO.js +0 -156
- package/chunks/daemon-status-provider-L3J6GKCT.js +0 -102
- package/chunks/daemon-trust-policy-4PHPY23S.js +0 -98
- package/chunks/exitPlanMode-RWJR2KGB.js +0 -84
- package/chunks/handleAutoUpdate-NHFSGYTF.js +0 -93
- package/chunks/initializer-Y5DJLT43.js +0 -99
- package/chunks/list-YHNQ32CS.js +0 -102
- package/chunks/loadedSettingsAdapter-GHUQK7H4.js +0 -96
- package/chunks/mcp-EA3KO6FS.js +0 -96
- package/chunks/nonInteractiveCli-NNOR56HU.js +0 -162
- package/chunks/read-file-KKTXGIZD.js +0 -32
- package/chunks/ripGrep-SJVAAYDV.js +0 -84
- package/chunks/serve-IH4XR5IL.js +0 -106
- package/chunks/spawnChannel-UAQMH6Y6.js +0 -94
- package/chunks/theme-manager-ZNDGAHJN.js +0 -88
- package/chunks/total-session-admission-66UDSOHO.js +0 -98
- package/chunks/workspace-providers-status-K22B3Z6B.js +0 -99
- package/chunks/workspace-skills-status-DDYCBVSH.js +0 -99
- package/chunks/write-file-TT6MWIKC.js +0 -86
- package/web-shell/assets/channel-DPFUV4oi.js +0 -1
- package/web-shell/assets/classDiagram-4FO5ZUOK-CLm0hVvw.js +0 -1
- package/web-shell/assets/classDiagram-v2-Q7XG4LA2-CLm0hVvw.js +0 -1
- package/web-shell/assets/index-BjC3yjjL.css +0 -5
- package/web-shell/assets/index-QzFq6w7o.js +0 -1775
- package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DXb5olqv.js +0 -1
|
@@ -13,17 +13,17 @@ import {
|
|
|
13
13
|
matchMcpServerByRef,
|
|
14
14
|
parseExtensionRef,
|
|
15
15
|
parseMcpServerRef
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-KD6FGI2Q.js";
|
|
17
17
|
import {
|
|
18
18
|
getAvailableCommands,
|
|
19
19
|
handleSlashCommand,
|
|
20
20
|
insertAfterFunctionResponses,
|
|
21
21
|
isSlashCommand,
|
|
22
22
|
normalizePartList
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-AZPFLLFR.js";
|
|
24
24
|
import {
|
|
25
25
|
recomputeMcpGating
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-AGWZRQJJ.js";
|
|
27
27
|
import {
|
|
28
28
|
SessionIdConflictError,
|
|
29
29
|
appEvents,
|
|
@@ -31,43 +31,48 @@ import {
|
|
|
31
31
|
cleanupReviewWorktreeLeases,
|
|
32
32
|
loadCliConfig,
|
|
33
33
|
normalizeDisabledToolList
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-US7J7LJT.js";
|
|
35
35
|
import {
|
|
36
36
|
getCommandSubcommandNames
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-VXSD4AGT.js";
|
|
38
38
|
import {
|
|
39
39
|
getEffectiveSupportedModes
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-ARSQPRYL.js";
|
|
41
|
+
import "./chunk-3SH53ANB.js";
|
|
41
42
|
import "./chunk-NYX53SV4.js";
|
|
42
|
-
import "./chunk-
|
|
43
|
+
import "./chunk-NW2GIPG3.js";
|
|
43
44
|
import {
|
|
44
45
|
collectContextData,
|
|
45
46
|
formatContextUsageText
|
|
46
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-655DWW7X.js";
|
|
47
48
|
import "./chunk-4WGODMVR.js";
|
|
49
|
+
import {
|
|
50
|
+
isGoalStatusKind
|
|
51
|
+
} from "./chunk-EKTCKZV5.js";
|
|
52
|
+
import "./chunk-OYWVIXHT.js";
|
|
48
53
|
import {
|
|
49
54
|
startNonInteractiveOpenAILogHousekeeping
|
|
50
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-IVROQYG5.js";
|
|
51
56
|
import "./chunk-KW7NOTN6.js";
|
|
52
|
-
import "./chunk-
|
|
53
|
-
import "./chunk-
|
|
54
|
-
import "./chunk-
|
|
57
|
+
import "./chunk-TCMU4ZUE.js";
|
|
58
|
+
import "./chunk-ADM4C4TX.js";
|
|
59
|
+
import "./chunk-2QHWLRQ2.js";
|
|
55
60
|
import "./chunk-YAF2MQZ6.js";
|
|
56
61
|
import {
|
|
57
62
|
computeCpuPercent
|
|
58
63
|
} from "./chunk-LBOVL47Y.js";
|
|
59
|
-
import "./chunk-
|
|
64
|
+
import "./chunk-X5QJFMLY.js";
|
|
60
65
|
import "./chunk-6H67XLET.js";
|
|
61
66
|
import {
|
|
62
67
|
beginAcpBootstrapConfigProfiling,
|
|
63
68
|
buildAndFreezeAcpStartupProfile,
|
|
64
69
|
endAcpBootstrapConfigProfiling,
|
|
65
70
|
markAcpStartup
|
|
66
|
-
} from "./chunk-
|
|
67
|
-
import "./chunk-DCZEPFB4.js";
|
|
71
|
+
} from "./chunk-FMIH5KMQ.js";
|
|
68
72
|
import {
|
|
69
73
|
GENERATION_MAX_PROMPT_BYTES,
|
|
70
74
|
GENERATION_TIMEOUT_MS,
|
|
75
|
+
HistoryReplayLimitError,
|
|
71
76
|
MAX_REMEMBER_CONTENT_BYTES,
|
|
72
77
|
REDACTED_MCP_SECRET,
|
|
73
78
|
collectHistoryReplayUpdates,
|
|
@@ -86,25 +91,21 @@ import {
|
|
|
86
91
|
shouldSuppressRememberErrorDetails,
|
|
87
92
|
workspaceMemoryFailureCode,
|
|
88
93
|
workspaceMemoryFailureDiagnostics
|
|
89
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-HHZU6ZZM.js";
|
|
90
95
|
import {
|
|
96
|
+
BaseEmitter,
|
|
91
97
|
HistoryReplayer,
|
|
92
|
-
MessageEmitter,
|
|
93
98
|
PlanEmitter,
|
|
94
99
|
ToolCallEmitter,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
import "./chunk-OWMAZHIX.js";
|
|
101
|
-
import "./chunk-ZRBMO3C7.js";
|
|
100
|
+
createTranscriptMessageUpdate,
|
|
101
|
+
createTranscriptUsageUpdate,
|
|
102
|
+
hasFullSessionContext
|
|
103
|
+
} from "./chunk-WZRLXVLJ.js";
|
|
104
|
+
import "./chunk-TMFWI4RC.js";
|
|
102
105
|
import "./chunk-4NFY2S7N.js";
|
|
106
|
+
import "./chunk-IKFHTAQW.js";
|
|
103
107
|
import "./chunk-2MIN6GRR.js";
|
|
104
108
|
import "./chunk-QHTIBUWB.js";
|
|
105
|
-
import {
|
|
106
|
-
isTerminalGoalStatusKind
|
|
107
|
-
} from "./chunk-EKTCKZV5.js";
|
|
108
109
|
import "./chunk-3Z43GZUQ.js";
|
|
109
110
|
import {
|
|
110
111
|
buildToolWriteOriginMeta
|
|
@@ -113,26 +114,25 @@ import {
|
|
|
113
114
|
normalizeSessionIdForLookup,
|
|
114
115
|
parseCallerSuppliedSessionId
|
|
115
116
|
} from "./chunk-TQOF5KBL.js";
|
|
116
|
-
import "./chunk-
|
|
117
|
+
import "./chunk-UXEO7E3V.js";
|
|
117
118
|
import {
|
|
118
119
|
PERMISSION_RULE_TYPES,
|
|
119
120
|
PermissionRulesValidationError,
|
|
120
121
|
buildPermissionSettings,
|
|
121
122
|
normalizePermissionRules,
|
|
122
123
|
readPermissionRuleSet
|
|
123
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-4N4JVRZA.js";
|
|
124
125
|
import {
|
|
125
126
|
MAX_AUDIO_BYTES,
|
|
126
127
|
sanitizeVoiceErrorMessage,
|
|
127
128
|
transcribeVoiceAudio
|
|
128
|
-
} from "./chunk-
|
|
129
|
+
} from "./chunk-BRQR2FJ5.js";
|
|
129
130
|
import {
|
|
130
131
|
readVoiceModel
|
|
131
|
-
} from "./chunk-
|
|
132
|
-
import "./chunk-
|
|
132
|
+
} from "./chunk-MNUKNVYQ.js";
|
|
133
|
+
import "./chunk-H7TMVHKE.js";
|
|
133
134
|
import "./chunk-NTTBXH7U.js";
|
|
134
|
-
import "./chunk-
|
|
135
|
-
import "./chunk-3SH53ANB.js";
|
|
135
|
+
import "./chunk-3NBTNFNC.js";
|
|
136
136
|
import {
|
|
137
137
|
ACP_ROUTE_ID_PREFIX,
|
|
138
138
|
buildAcpModelOptions,
|
|
@@ -141,32 +141,32 @@ import {
|
|
|
141
141
|
parseAcpModelOption,
|
|
142
142
|
resolveAcpModelOption,
|
|
143
143
|
sanitizeProviderBaseUrl
|
|
144
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-BBCGHZ4S.js";
|
|
145
145
|
import {
|
|
146
146
|
mapSkillConfigToStatus
|
|
147
147
|
} from "./chunk-BGXZBI5B.js";
|
|
148
148
|
import {
|
|
149
149
|
resolveSkillSettings
|
|
150
150
|
} from "./chunk-Z4X5MTRT.js";
|
|
151
|
-
import "./chunk-
|
|
152
|
-
import "./chunk-
|
|
151
|
+
import "./chunk-3QZY3JSR.js";
|
|
152
|
+
import "./chunk-D7VALEOK.js";
|
|
153
153
|
import "./chunk-57OAHC2Y.js";
|
|
154
|
-
import "./chunk-
|
|
155
|
-
import "./chunk-
|
|
156
|
-
import "./chunk-
|
|
154
|
+
import "./chunk-BSR5AXZR.js";
|
|
155
|
+
import "./chunk-45NQKMYB.js";
|
|
156
|
+
import "./chunk-OK47XBYH.js";
|
|
157
157
|
import {
|
|
158
158
|
createLoadedSettingsAdapter
|
|
159
|
-
} from "./chunk-
|
|
159
|
+
} from "./chunk-EQUXHAFW.js";
|
|
160
160
|
import {
|
|
161
161
|
SESSION_SOURCE_META_KEY,
|
|
162
162
|
parseSessionSource
|
|
163
|
-
} from "./chunk-
|
|
164
|
-
import "./chunk-
|
|
165
|
-
import "./chunk-
|
|
163
|
+
} from "./chunk-J6JVP7ZZ.js";
|
|
164
|
+
import "./chunk-7U5G6JXI.js";
|
|
165
|
+
import "./chunk-WCCLLK7X.js";
|
|
166
166
|
import "./chunk-OCPBI7J5.js";
|
|
167
167
|
import {
|
|
168
168
|
ndJsonStream
|
|
169
|
-
} from "./chunk-
|
|
169
|
+
} from "./chunk-DAV4QFD5.js";
|
|
170
170
|
import {
|
|
171
171
|
ACP_PREFLIGHT_KINDS,
|
|
172
172
|
IDLE_HOOK_EVENTS,
|
|
@@ -174,22 +174,26 @@ import {
|
|
|
174
174
|
SERVE_STATUS_EXT_METHODS,
|
|
175
175
|
STATUS_SCHEMA_VERSION,
|
|
176
176
|
mapDomainErrorToErrorKind
|
|
177
|
-
} from "./chunk-
|
|
178
|
-
import "./chunk-
|
|
177
|
+
} from "./chunk-HTYND72J.js";
|
|
178
|
+
import "./chunk-ZLCT4C5A.js";
|
|
179
179
|
import "./chunk-V6WHFGST.js";
|
|
180
180
|
import {
|
|
181
181
|
ACTIVE_WORK_CLOSE_IF_UNHELD_PARAM,
|
|
182
182
|
ACTIVE_WORK_HEARTBEAT_META_KEY,
|
|
183
183
|
ACTIVE_WORK_HEARTBEAT_VERSION,
|
|
184
184
|
ACTIVE_WORK_HOLD_CATEGORIES,
|
|
185
|
+
ACTIVE_WORK_LEGACY_HOLD_CATEGORIES,
|
|
185
186
|
ACTIVE_WORK_NOTIFICATION_METHOD,
|
|
186
187
|
CHANNEL_STARTUP_PROFILE_META_KEY,
|
|
187
188
|
CHANNEL_STARTUP_PROFILE_VERSION,
|
|
188
189
|
CLIENT_MCP_OVER_WS_CONFIG_FLAG,
|
|
189
190
|
DAEMON_CHANNEL_DELIVERY_META_KEY,
|
|
190
191
|
DAEMON_MODEL_PROMPT_META_KEY,
|
|
192
|
+
DAEMON_PROMPT_DISPLAY_TEXT_META_KEY,
|
|
191
193
|
LOAD_REPLAY_BULK_MODE,
|
|
192
194
|
LOAD_REPLAY_HIDE_INHERITED_META_KEY,
|
|
195
|
+
LOAD_REPLAY_MAX_BYTES,
|
|
196
|
+
LOAD_REPLAY_MAX_UPDATES,
|
|
193
197
|
LOAD_REPLAY_META_KEY,
|
|
194
198
|
LOAD_REPLAY_MODE_META_KEY,
|
|
195
199
|
LOAD_REPLAY_PAGE_SIZE_META_KEY,
|
|
@@ -202,7 +206,7 @@ import {
|
|
|
202
206
|
WORKTREE_MCP_DEFER_META_KEY,
|
|
203
207
|
clampActiveWorkIntervalMs,
|
|
204
208
|
isValidTrustedModelPrompt
|
|
205
|
-
} from "./chunk-
|
|
209
|
+
} from "./chunk-FQDCO3CJ.js";
|
|
206
210
|
import {
|
|
207
211
|
NOT_CURRENTLY_GENERATING_CANCEL_MESSAGE,
|
|
208
212
|
isNotCurrentlyGeneratingCancelError
|
|
@@ -210,7 +214,7 @@ import {
|
|
|
210
214
|
import "./chunk-6PLDPT2C.js";
|
|
211
215
|
import "./chunk-FYJ7W2PI.js";
|
|
212
216
|
import "./chunk-YP5KH5Y7.js";
|
|
213
|
-
import "./chunk-
|
|
217
|
+
import "./chunk-A6NRNRKE.js";
|
|
214
218
|
import "./chunk-ALMR3E6Q.js";
|
|
215
219
|
import "./chunk-HIBNSEJE.js";
|
|
216
220
|
import "./chunk-M5GB774H.js";
|
|
@@ -219,22 +223,24 @@ import {
|
|
|
219
223
|
EXTERNAL_TOOL_GUARD_REQUIRED_VALUE,
|
|
220
224
|
EXTERNAL_TOOL_GUARD_TOKEN_ENV,
|
|
221
225
|
PRIVATE_EXTERNAL_TOOL_GUARD_ENV,
|
|
226
|
+
PRIVATE_EXTERNAL_TOOL_GUARD_PROVIDER_ENV,
|
|
227
|
+
SHELL_EXECUTING_TOOL_NAMES,
|
|
222
228
|
isValidExternalToolGuardDenialReason
|
|
223
|
-
} from "./chunk-
|
|
224
|
-
import "./chunk-
|
|
229
|
+
} from "./chunk-3VUENPWF.js";
|
|
230
|
+
import "./chunk-3AEKDXKT.js";
|
|
225
231
|
import {
|
|
226
232
|
ACP_EVENT_LOOP_STALL_RESTART_MS,
|
|
227
233
|
CHANNEL_PROMPT_META_KEY
|
|
228
|
-
} from "./chunk-
|
|
234
|
+
} from "./chunk-AW27A43Y.js";
|
|
229
235
|
import {
|
|
230
236
|
AgentSideConnection,
|
|
231
237
|
PROTOCOL_VERSION,
|
|
232
238
|
RequestError
|
|
233
|
-
} from "./chunk-
|
|
239
|
+
} from "./chunk-IW6RQPQB.js";
|
|
234
240
|
import {
|
|
235
241
|
assembleMcpServers,
|
|
236
242
|
loadMcpApprovals
|
|
237
|
-
} from "./chunk-
|
|
243
|
+
} from "./chunk-BP5VZBVK.js";
|
|
238
244
|
import {
|
|
239
245
|
getOutputLanguageFilePath,
|
|
240
246
|
getPersistScopeForModelSelection,
|
|
@@ -243,9 +249,9 @@ import {
|
|
|
243
249
|
resolveOutputLanguageOrPreserveAuto,
|
|
244
250
|
updateOutputLanguageFile,
|
|
245
251
|
writeOutputLanguageAndRegisterPath
|
|
246
|
-
} from "./chunk-
|
|
247
|
-
import "./chunk-UBX6NL47.js";
|
|
252
|
+
} from "./chunk-3ER3FWZM.js";
|
|
248
253
|
import "./chunk-RKUWKYED.js";
|
|
254
|
+
import "./chunk-AGWK35OJ.js";
|
|
249
255
|
import "./chunk-GOXKNSDZ.js";
|
|
250
256
|
import {
|
|
251
257
|
getSystemDefaultsPath,
|
|
@@ -254,7 +260,7 @@ import {
|
|
|
254
260
|
import {
|
|
255
261
|
getCurrentLanguage,
|
|
256
262
|
setLanguageAsync
|
|
257
|
-
} from "./chunk-
|
|
263
|
+
} from "./chunk-YYIOFWVH.js";
|
|
258
264
|
import {
|
|
259
265
|
SUPPORTED_LANGUAGES
|
|
260
266
|
} from "./chunk-5EJZE3FP.js";
|
|
@@ -262,18 +268,18 @@ import {
|
|
|
262
268
|
findEnvFiles,
|
|
263
269
|
preResolveHomeEnvOverrides,
|
|
264
270
|
reloadEnvironment
|
|
265
|
-
} from "./chunk-
|
|
271
|
+
} from "./chunk-HDRTQ5DH.js";
|
|
266
272
|
import {
|
|
267
273
|
ENV_ACP_REPEATED_TOOL_FAILURE_GUARD
|
|
268
|
-
} from "./chunk-
|
|
269
|
-
import "./chunk-
|
|
270
|
-
import "./chunk-
|
|
271
|
-
import "./chunk-
|
|
274
|
+
} from "./chunk-MS7GNABG.js";
|
|
275
|
+
import "./chunk-F5BD3RNA.js";
|
|
276
|
+
import "./chunk-RN7GFREP.js";
|
|
277
|
+
import "./chunk-WZMH7II3.js";
|
|
272
278
|
import {
|
|
273
279
|
isFolderTrustEnabled,
|
|
274
280
|
isWorkspaceTrusted,
|
|
275
281
|
loadTrustedFolders
|
|
276
|
-
} from "./chunk-
|
|
282
|
+
} from "./chunk-7WROZ3E6.js";
|
|
277
283
|
import "./chunk-NPQ5ZKRP.js";
|
|
278
284
|
import "./chunk-MR3PXB6E.js";
|
|
279
285
|
import "./chunk-XFSFZCM5.js";
|
|
@@ -326,7 +332,7 @@ import {
|
|
|
326
332
|
buildPermissionCheckContext,
|
|
327
333
|
buildSessionRecoveryPlanFromApiHistory,
|
|
328
334
|
clampInlineMediaPart,
|
|
329
|
-
|
|
335
|
+
collectSessionTurnState,
|
|
330
336
|
computeUniqueBranchTitle,
|
|
331
337
|
convertToFunctionErrorResponse,
|
|
332
338
|
convertToFunctionResponse,
|
|
@@ -343,7 +349,6 @@ import {
|
|
|
343
349
|
evaluatePlanModeShellPolicy,
|
|
344
350
|
evaluateToolInvocationGuard,
|
|
345
351
|
finalizeToolResponses,
|
|
346
|
-
findBoundaryAtOrBefore,
|
|
347
352
|
findExistingProviderModels,
|
|
348
353
|
findPlanModeEntryBatchBoundaryIndex,
|
|
349
354
|
findProviderById,
|
|
@@ -376,7 +381,6 @@ import {
|
|
|
376
381
|
isDenialFallbackReason,
|
|
377
382
|
isGatedMcpScope,
|
|
378
383
|
isPlanModeBlocked,
|
|
379
|
-
isReplayTurnStartType,
|
|
380
384
|
markDuplicateProviderToolCallResponseSent,
|
|
381
385
|
matchesAnyServerPattern,
|
|
382
386
|
mcpServerRequiresOAuth,
|
|
@@ -384,10 +388,10 @@ import {
|
|
|
384
388
|
normalizeEventPayload,
|
|
385
389
|
normalizeSnapshotPayload,
|
|
386
390
|
persistPermissionOutcome,
|
|
391
|
+
projectGoalStateToLegacy,
|
|
387
392
|
readManyFiles,
|
|
388
393
|
recordAllow,
|
|
389
394
|
recordFallbackApprove,
|
|
390
|
-
redactUrlCredentials,
|
|
391
395
|
refreshMemoryAfterManagedWrite,
|
|
392
396
|
refreshMemoryInstruction,
|
|
393
397
|
resolveBaseUrl,
|
|
@@ -395,8 +399,6 @@ import {
|
|
|
395
399
|
runForkedAgent,
|
|
396
400
|
runManagedAutoMemoryDream,
|
|
397
401
|
runManagedRememberByAgent,
|
|
398
|
-
sessionIdContext,
|
|
399
|
-
setGoalTerminalObserver,
|
|
400
402
|
shouldClassifyAllShellForAutoMode,
|
|
401
403
|
shouldFallback,
|
|
402
404
|
shouldFirePermissionDeniedForAutoMode,
|
|
@@ -404,29 +406,29 @@ import {
|
|
|
404
406
|
shouldHaltOnTurnToolCallCap,
|
|
405
407
|
shouldRunAutoModeForCall,
|
|
406
408
|
subagentGenerator,
|
|
407
|
-
|
|
409
|
+
truncateNotificationLabel,
|
|
408
410
|
updateSetting,
|
|
409
411
|
validatePlanModeShellApproval,
|
|
410
412
|
validatePlanModeShellContext
|
|
411
|
-
} from "./chunk-
|
|
413
|
+
} from "./chunk-MSSNVG2G.js";
|
|
412
414
|
import "./chunk-GOFAQQZA.js";
|
|
413
415
|
import "./chunk-5M6IDOMF.js";
|
|
414
416
|
import "./chunk-TWPJO254.js";
|
|
415
417
|
import {
|
|
416
418
|
external_exports
|
|
417
|
-
} from "./chunk-
|
|
418
|
-
import "./chunk-
|
|
419
|
-
import "./chunk-
|
|
420
|
-
import "./chunk-
|
|
421
|
-
import "./chunk-
|
|
419
|
+
} from "./chunk-CQ35AJ4Z.js";
|
|
420
|
+
import "./chunk-QPBFRWCP.js";
|
|
421
|
+
import "./chunk-JRIVMPD2.js";
|
|
422
|
+
import "./chunk-YILJKX2T.js";
|
|
423
|
+
import "./chunk-D2RNVVH6.js";
|
|
422
424
|
import {
|
|
423
425
|
parsePositiveIntegerEnv
|
|
424
426
|
} from "./chunk-6PVPNMXU.js";
|
|
425
|
-
import "./chunk-
|
|
427
|
+
import "./chunk-5C42HXEX.js";
|
|
426
428
|
import "./chunk-IRH27ZC2.js";
|
|
427
429
|
import "./chunk-QHWCP53L.js";
|
|
428
|
-
import "./chunk-
|
|
429
|
-
import "./chunk-
|
|
430
|
+
import "./chunk-AKBFSOC5.js";
|
|
431
|
+
import "./chunk-DEDESZDL.js";
|
|
430
432
|
import {
|
|
431
433
|
promptIdContext,
|
|
432
434
|
todoWorkChainContext
|
|
@@ -434,53 +436,62 @@ import {
|
|
|
434
436
|
import "./chunk-T26EAKDL.js";
|
|
435
437
|
import "./chunk-ZPJWUGCS.js";
|
|
436
438
|
import "./chunk-CPBF7KYF.js";
|
|
437
|
-
import "./chunk-
|
|
439
|
+
import "./chunk-5RUCD4ED.js";
|
|
438
440
|
import "./chunk-KRXPRVGL.js";
|
|
439
441
|
import {
|
|
440
442
|
HookEventName,
|
|
441
443
|
createHookOutput
|
|
442
|
-
} from "./chunk-
|
|
443
|
-
import "./chunk-
|
|
444
|
-
import "./chunk-
|
|
444
|
+
} from "./chunk-YBVVOSOH.js";
|
|
445
|
+
import "./chunk-CPFFU46D.js";
|
|
446
|
+
import "./chunk-ULNWG62W.js";
|
|
445
447
|
import {
|
|
448
|
+
GoalPersistenceUnavailableError,
|
|
449
|
+
emptyGoalSnapshot,
|
|
450
|
+
goalTurnContext,
|
|
451
|
+
parseGoalSnapshotV2,
|
|
452
|
+
parseGoalStateCause,
|
|
446
453
|
wrapUserPromptSubmitContext
|
|
447
|
-
} from "./chunk-
|
|
454
|
+
} from "./chunk-DPTMKFIH.js";
|
|
448
455
|
import {
|
|
449
456
|
APPROVAL_MODES
|
|
450
|
-
} from "./chunk-
|
|
451
|
-
import "./chunk-
|
|
457
|
+
} from "./chunk-63FNZTWG.js";
|
|
458
|
+
import "./chunk-3GM5DLBI.js";
|
|
452
459
|
import {
|
|
460
|
+
AgentOutputMessageCapture,
|
|
461
|
+
addAgentInputMessageAttributes,
|
|
462
|
+
addDaemonRequestAttribute,
|
|
453
463
|
addToolArgumentsAttributes,
|
|
454
464
|
addToolCallResultAttributes,
|
|
455
465
|
extractDaemonTraceContext,
|
|
456
466
|
registerAcpEventLoopLagGauge,
|
|
457
467
|
startEventLoopLagMonitor,
|
|
458
468
|
withDaemonSpan
|
|
459
|
-
} from "./chunk-
|
|
469
|
+
} from "./chunk-K34GJQOZ.js";
|
|
460
470
|
import "./chunk-SAH4BD2J.js";
|
|
471
|
+
import "./chunk-KLOMACIR.js";
|
|
461
472
|
import {
|
|
462
473
|
runWithRuntimeContentGenerator
|
|
463
|
-
} from "./chunk-
|
|
474
|
+
} from "./chunk-VPV7WBVT.js";
|
|
464
475
|
import "./chunk-S6LOFUVP.js";
|
|
465
476
|
import "./chunk-2J3OJGTL.js";
|
|
466
477
|
import {
|
|
467
478
|
FORK_SUBAGENT_TYPE,
|
|
468
479
|
getStartupContextLength,
|
|
469
480
|
isSystemReminderContent
|
|
470
|
-
} from "./chunk-
|
|
481
|
+
} from "./chunk-TTRH3RTQ.js";
|
|
471
482
|
import "./chunk-K623ENWT.js";
|
|
472
483
|
import "./chunk-AQ37AY7B.js";
|
|
473
|
-
import "./chunk-
|
|
484
|
+
import "./chunk-FRHQQC2Z.js";
|
|
474
485
|
import {
|
|
475
486
|
clearCachedCredentialFile,
|
|
476
487
|
qwenOAuth2Events
|
|
477
|
-
} from "./chunk-
|
|
488
|
+
} from "./chunk-DG4IQ6JG.js";
|
|
478
489
|
import "./chunk-NAVJD2PQ.js";
|
|
479
|
-
import "./chunk-
|
|
480
|
-
import "./chunk-
|
|
490
|
+
import "./chunk-KEC5FHLM.js";
|
|
491
|
+
import "./chunk-2ZWH53I4.js";
|
|
481
492
|
import "./chunk-P3QQPMQA.js";
|
|
482
|
-
import "./chunk-
|
|
483
|
-
import "./chunk-
|
|
493
|
+
import "./chunk-TB4YFWXG.js";
|
|
494
|
+
import "./chunk-D7QGE3RT.js";
|
|
484
495
|
import {
|
|
485
496
|
REASONING_EFFORT_TIERS,
|
|
486
497
|
applyReasoningEffort
|
|
@@ -491,7 +502,7 @@ import {
|
|
|
491
502
|
getToolCallPreparations
|
|
492
503
|
} from "./chunk-GLCZKT5V.js";
|
|
493
504
|
import "./chunk-DJ2GSRLV.js";
|
|
494
|
-
import "./chunk-
|
|
505
|
+
import "./chunk-NLFLYSS4.js";
|
|
495
506
|
import {
|
|
496
507
|
ConversationFinishedEvent,
|
|
497
508
|
DiscoveredMCPTool,
|
|
@@ -502,6 +513,7 @@ import {
|
|
|
502
513
|
PromptSuggestionEvent,
|
|
503
514
|
RepeatedToolFailureGuardEvent,
|
|
504
515
|
UserPromptEvent,
|
|
516
|
+
apiActivityTracker,
|
|
505
517
|
formatFullTurnVisionNotice,
|
|
506
518
|
formatVisionBridgeNotice,
|
|
507
519
|
getAllGeminiMdFilenames,
|
|
@@ -523,17 +535,17 @@ import {
|
|
|
523
535
|
shouldRunVisionBridge,
|
|
524
536
|
splitImageParts,
|
|
525
537
|
uiTelemetryService
|
|
526
|
-
} from "./chunk-
|
|
527
|
-
import "./chunk-
|
|
538
|
+
} from "./chunk-4KM2SYK5.js";
|
|
539
|
+
import "./chunk-YRLW2MSX.js";
|
|
528
540
|
import "./chunk-VGC4I5JJ.js";
|
|
529
541
|
import {
|
|
530
542
|
getAutoMemoryRoot,
|
|
531
543
|
getUserAutoMemoryRoot
|
|
532
|
-
} from "./chunk-
|
|
544
|
+
} from "./chunk-G6MUFRNI.js";
|
|
533
545
|
import {
|
|
534
546
|
runSideQuery
|
|
535
|
-
} from "./chunk-
|
|
536
|
-
import "./chunk-
|
|
547
|
+
} from "./chunk-LSRI3ND3.js";
|
|
548
|
+
import "./chunk-PVXEJB66.js";
|
|
537
549
|
import {
|
|
538
550
|
BaseDeclarativeTool,
|
|
539
551
|
BaseToolInvocation,
|
|
@@ -541,43 +553,47 @@ import {
|
|
|
541
553
|
ToolNames,
|
|
542
554
|
canonicalToolName,
|
|
543
555
|
isShellProgressData
|
|
544
|
-
} from "./chunk-
|
|
556
|
+
} from "./chunk-YIGGWOJE.js";
|
|
545
557
|
import {
|
|
546
558
|
AuthType,
|
|
547
559
|
preloadContentGenerator
|
|
548
|
-
} from "./chunk-
|
|
560
|
+
} from "./chunk-YM3I6VW5.js";
|
|
549
561
|
import "./chunk-F6WFNA7U.js";
|
|
550
562
|
import "./chunk-46UV252V.js";
|
|
551
563
|
import {
|
|
552
564
|
DEFAULT_TOKEN_LIMIT,
|
|
553
565
|
tokenLimit
|
|
554
|
-
} from "./chunk-
|
|
555
|
-
import "./chunk-
|
|
556
|
-
import "./chunk-
|
|
557
|
-
import "./chunk-
|
|
566
|
+
} from "./chunk-FPGTNKCP.js";
|
|
567
|
+
import "./chunk-4AOVQPJU.js";
|
|
568
|
+
import "./chunk-PZW46OTB.js";
|
|
569
|
+
import "./chunk-YBHUXEC6.js";
|
|
558
570
|
import {
|
|
559
571
|
endToolExecutionSpan,
|
|
560
572
|
endToolSpan,
|
|
573
|
+
getActiveInteractionSpan,
|
|
561
574
|
initializeTelemetry,
|
|
575
|
+
redactUrlCredentials,
|
|
562
576
|
runInToolSpanContext,
|
|
563
577
|
startToolExecutionSpan,
|
|
564
578
|
startToolSpan,
|
|
565
579
|
withInteractionSpan
|
|
566
|
-
} from "./chunk-
|
|
567
|
-
import "./chunk-
|
|
568
|
-
import
|
|
580
|
+
} from "./chunk-N4SVADAV.js";
|
|
581
|
+
import "./chunk-HHJLM3WQ.js";
|
|
582
|
+
import {
|
|
583
|
+
sessionIdContext
|
|
584
|
+
} from "./chunk-K5IDV3PC.js";
|
|
569
585
|
import {
|
|
570
586
|
Storage,
|
|
571
587
|
createDebugLogger,
|
|
572
588
|
getErrorMessage,
|
|
573
589
|
getErrorStatus,
|
|
574
590
|
isSubpath
|
|
575
|
-
} from "./chunk-
|
|
591
|
+
} from "./chunk-HOSVOUDK.js";
|
|
576
592
|
import "./chunk-VOQXFAY5.js";
|
|
577
|
-
import "./chunk-
|
|
593
|
+
import "./chunk-RYSBWLLV.js";
|
|
578
594
|
import {
|
|
579
595
|
runExitCleanup
|
|
580
|
-
} from "./chunk-
|
|
596
|
+
} from "./chunk-7P5NK5EI.js";
|
|
581
597
|
import {
|
|
582
598
|
writeStderrLine,
|
|
583
599
|
writeStderrLineSafe
|
|
@@ -1424,6 +1440,86 @@ function prefixMidTurnUserMessageParts(parts, displayText) {
|
|
|
1424
1440
|
}
|
|
1425
1441
|
__name(prefixMidTurnUserMessageParts, "prefixMidTurnUserMessageParts");
|
|
1426
1442
|
|
|
1443
|
+
// packages/cli/src/ui/utils/restoreGoal.ts
|
|
1444
|
+
init_esbuild_shims();
|
|
1445
|
+
function findGoalToRestore(history) {
|
|
1446
|
+
for (let i = history.length - 1; i >= 0; i--) {
|
|
1447
|
+
const item = history[i];
|
|
1448
|
+
if (item?.type !== "goal_status" /* GOAL_STATUS */) continue;
|
|
1449
|
+
const goal = item;
|
|
1450
|
+
if (goal.kind !== "set" && goal.kind !== "checking") return null;
|
|
1451
|
+
const setAt = goal.setAt ?? findSetAtOfRun(history, i);
|
|
1452
|
+
return {
|
|
1453
|
+
condition: goal.condition,
|
|
1454
|
+
iterations: goal.iterations ?? 0,
|
|
1455
|
+
...setAt !== void 0 ? { setAt } : {}
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1458
|
+
return null;
|
|
1459
|
+
}
|
|
1460
|
+
__name(findGoalToRestore, "findGoalToRestore");
|
|
1461
|
+
function findSetAtOfRun(history, startIndex) {
|
|
1462
|
+
const start = history[startIndex];
|
|
1463
|
+
const condition = start?.condition;
|
|
1464
|
+
for (let i = startIndex - 1; i >= 0; i--) {
|
|
1465
|
+
const item = history[i];
|
|
1466
|
+
if (item?.type !== "goal_status" /* GOAL_STATUS */) continue;
|
|
1467
|
+
const goal = item;
|
|
1468
|
+
if (goal.kind !== "set" && goal.kind !== "checking") return void 0;
|
|
1469
|
+
if (goal.condition !== condition) return void 0;
|
|
1470
|
+
if (goal.setAt !== void 0) return goal.setAt;
|
|
1471
|
+
}
|
|
1472
|
+
return void 0;
|
|
1473
|
+
}
|
|
1474
|
+
__name(findSetAtOfRun, "findSetAtOfRun");
|
|
1475
|
+
function finiteNumber(value) {
|
|
1476
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1477
|
+
}
|
|
1478
|
+
__name(finiteNumber, "finiteNumber");
|
|
1479
|
+
function isTranscriptItemRecord(item) {
|
|
1480
|
+
return typeof item === "object" && item !== null && !Array.isArray(item);
|
|
1481
|
+
}
|
|
1482
|
+
__name(isTranscriptItemRecord, "isTranscriptItemRecord");
|
|
1483
|
+
function parseGoalStatusItem(item) {
|
|
1484
|
+
if (!isTranscriptItemRecord(item)) return null;
|
|
1485
|
+
if (item["type"] !== "goal_status" /* GOAL_STATUS */) return null;
|
|
1486
|
+
const kind = item["kind"];
|
|
1487
|
+
const condition = item["condition"];
|
|
1488
|
+
if (!isGoalStatusKind(kind) || typeof condition !== "string") return null;
|
|
1489
|
+
const iterations = finiteNumber(item["iterations"]);
|
|
1490
|
+
const setAt = finiteNumber(item["setAt"]);
|
|
1491
|
+
const durationMs = finiteNumber(item["durationMs"]);
|
|
1492
|
+
const lastReason = typeof item["lastReason"] === "string" ? item["lastReason"] : void 0;
|
|
1493
|
+
return {
|
|
1494
|
+
type: "goal_status" /* GOAL_STATUS */,
|
|
1495
|
+
kind,
|
|
1496
|
+
condition,
|
|
1497
|
+
...iterations !== void 0 ? { iterations } : {},
|
|
1498
|
+
...setAt !== void 0 ? { setAt } : {},
|
|
1499
|
+
...durationMs !== void 0 ? { durationMs } : {},
|
|
1500
|
+
...lastReason !== void 0 ? { lastReason } : {}
|
|
1501
|
+
};
|
|
1502
|
+
}
|
|
1503
|
+
__name(parseGoalStatusItem, "parseGoalStatusItem");
|
|
1504
|
+
function collectGoalStatusItemsFromRecords(records) {
|
|
1505
|
+
const items = [];
|
|
1506
|
+
for (const record of records) {
|
|
1507
|
+
if (record.type !== "system" || record.subtype !== "slash_command") {
|
|
1508
|
+
continue;
|
|
1509
|
+
}
|
|
1510
|
+
const payload = record.systemPayload;
|
|
1511
|
+
if (payload?.phase !== "result") continue;
|
|
1512
|
+
const raws = payload.outputHistoryItems;
|
|
1513
|
+
if (!Array.isArray(raws)) continue;
|
|
1514
|
+
for (const raw of raws) {
|
|
1515
|
+
const item = parseGoalStatusItem(raw);
|
|
1516
|
+
if (item) items.push(item);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
return items;
|
|
1520
|
+
}
|
|
1521
|
+
__name(collectGoalStatusItemsFromRecords, "collectGoalStatusItemsFromRecords");
|
|
1522
|
+
|
|
1427
1523
|
// packages/cli/src/acp-integration/session/tool-call-preparation-tracker.ts
|
|
1428
1524
|
init_esbuild_shims();
|
|
1429
1525
|
var ToolCallPreparationTracker = class {
|
|
@@ -1497,6 +1593,261 @@ var ToolCallPreparationTracker = class {
|
|
|
1497
1593
|
}
|
|
1498
1594
|
};
|
|
1499
1595
|
|
|
1596
|
+
// packages/cli/src/acp-integration/session/emitters/MessageEmitter.ts
|
|
1597
|
+
init_esbuild_shims();
|
|
1598
|
+
function buildGoalStatusUpdate(status) {
|
|
1599
|
+
return {
|
|
1600
|
+
sessionUpdate: "agent_message_chunk",
|
|
1601
|
+
content: { type: "text", text: "" },
|
|
1602
|
+
_meta: {
|
|
1603
|
+
goalStatus: status
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1606
|
+
}
|
|
1607
|
+
__name(buildGoalStatusUpdate, "buildGoalStatusUpdate");
|
|
1608
|
+
function buildGoalStateUpdate(snapshot, cause, previousGoal = null) {
|
|
1609
|
+
const projection = cause ? projectGoalStateToLegacy({ v: 2, cause, snapshot }, previousGoal) : void 0;
|
|
1610
|
+
const goalStatus = projection ? (() => {
|
|
1611
|
+
const { type: _type, ...status } = projection.goalStatus;
|
|
1612
|
+
return status;
|
|
1613
|
+
})() : void 0;
|
|
1614
|
+
return {
|
|
1615
|
+
sessionUpdate: "agent_message_chunk",
|
|
1616
|
+
content: { type: "text", text: "" },
|
|
1617
|
+
_meta: {
|
|
1618
|
+
goalState: snapshot,
|
|
1619
|
+
...goalStatus ? { goalStatus } : {},
|
|
1620
|
+
...projection?.goalTerminal ? { goalTerminal: projection.goalTerminal } : {}
|
|
1621
|
+
}
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
__name(buildGoalStateUpdate, "buildGoalStateUpdate");
|
|
1625
|
+
var MessageEmitter = class extends BaseEmitter {
|
|
1626
|
+
static {
|
|
1627
|
+
__name(this, "MessageEmitter");
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Emits a StopHookLoop event when Stop hooks create a loop.
|
|
1631
|
+
* This informs the client that Stop hooks have been executed multiple times.
|
|
1632
|
+
*
|
|
1633
|
+
* @param iterationCount - The current iteration count
|
|
1634
|
+
* @param reasons - Array of reasons from each Stop hook execution
|
|
1635
|
+
* @param stopHookCount - Number of Stop hooks that were executed
|
|
1636
|
+
*/
|
|
1637
|
+
async emitStopHookLoop(iterationCount, reasons, stopHookCount) {
|
|
1638
|
+
const activeGoal = getActiveGoal(this.sessionId);
|
|
1639
|
+
await this.sendUpdate({
|
|
1640
|
+
sessionUpdate: "agent_message_chunk",
|
|
1641
|
+
content: { type: "text", text: "" },
|
|
1642
|
+
_meta: {
|
|
1643
|
+
stopHookLoop: {
|
|
1644
|
+
iterationCount,
|
|
1645
|
+
reasons,
|
|
1646
|
+
stopHookCount,
|
|
1647
|
+
...activeGoal ? {
|
|
1648
|
+
goal: {
|
|
1649
|
+
condition: activeGoal.condition,
|
|
1650
|
+
iterations: activeGoal.iterations,
|
|
1651
|
+
setAt: activeGoal.setAt,
|
|
1652
|
+
lastReason: activeGoal.lastReason
|
|
1653
|
+
}
|
|
1654
|
+
} : {}
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
async emitGoalStatus(status, goalState) {
|
|
1660
|
+
const update = buildGoalStatusUpdate(status);
|
|
1661
|
+
if (goalState) {
|
|
1662
|
+
update._meta = { ...update._meta, goalState };
|
|
1663
|
+
}
|
|
1664
|
+
await this.sendUpdate(update);
|
|
1665
|
+
}
|
|
1666
|
+
async emitGoalState(snapshot, cause, previousGoal = null) {
|
|
1667
|
+
await this.sendUpdate(buildGoalStateUpdate(snapshot, cause, previousGoal));
|
|
1668
|
+
}
|
|
1669
|
+
/**
|
|
1670
|
+
* Emits a user message chunk.
|
|
1671
|
+
*
|
|
1672
|
+
* @param text - The user message text content
|
|
1673
|
+
* @param timestamp - Optional server-side timestamp (ISO string or ms) for message ordering
|
|
1674
|
+
*/
|
|
1675
|
+
async emitUserMessage(text, timestamp, options = {}) {
|
|
1676
|
+
await this.sendUpdate(
|
|
1677
|
+
createTranscriptMessageUpdate({
|
|
1678
|
+
role: "user",
|
|
1679
|
+
text,
|
|
1680
|
+
timestamp,
|
|
1681
|
+
...options.source ? { extra: { source: options.source } } : {}
|
|
1682
|
+
})
|
|
1683
|
+
);
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* Emits an agent thought chunk.
|
|
1687
|
+
*
|
|
1688
|
+
* @param text - The thought text content
|
|
1689
|
+
* @param timestamp - Optional server-side timestamp (ISO string or ms) for message ordering
|
|
1690
|
+
*/
|
|
1691
|
+
async emitAgentThought(text, timestamp, subagentMeta) {
|
|
1692
|
+
await this.sendUpdate(
|
|
1693
|
+
createTranscriptMessageUpdate({
|
|
1694
|
+
role: "assistant",
|
|
1695
|
+
thought: true,
|
|
1696
|
+
text,
|
|
1697
|
+
timestamp,
|
|
1698
|
+
...subagentMeta ? { extra: { ...subagentMeta } } : {}
|
|
1699
|
+
})
|
|
1700
|
+
);
|
|
1701
|
+
}
|
|
1702
|
+
/**
|
|
1703
|
+
* Emits an agent message chunk.
|
|
1704
|
+
*
|
|
1705
|
+
* @param text - The agent message text content
|
|
1706
|
+
* @param timestamp - Optional server-side timestamp (ISO string or ms) for message ordering
|
|
1707
|
+
*/
|
|
1708
|
+
async emitAgentMessage(text, timestamp, subagentMeta) {
|
|
1709
|
+
await this.sendUpdate(
|
|
1710
|
+
createTranscriptMessageUpdate({
|
|
1711
|
+
role: "assistant",
|
|
1712
|
+
text,
|
|
1713
|
+
timestamp,
|
|
1714
|
+
...subagentMeta ? { extra: { ...subagentMeta } } : {}
|
|
1715
|
+
})
|
|
1716
|
+
);
|
|
1717
|
+
}
|
|
1718
|
+
async emitSlashCommandOutput(text, timestamp) {
|
|
1719
|
+
const epochMs = BaseEmitter.toEpochMs(timestamp);
|
|
1720
|
+
await this.sendUpdate({
|
|
1721
|
+
sessionUpdate: "agent_message_chunk",
|
|
1722
|
+
content: { type: "text", text },
|
|
1723
|
+
_meta: {
|
|
1724
|
+
source: "slash_command",
|
|
1725
|
+
...epochMs != null ? { timestamp: epochMs } : {}
|
|
1726
|
+
}
|
|
1727
|
+
});
|
|
1728
|
+
}
|
|
1729
|
+
/**
|
|
1730
|
+
* Emits usage metadata.
|
|
1731
|
+
*/
|
|
1732
|
+
async emitUsageMetadata(usageMetadata, text = "", durationMs, subagentMeta) {
|
|
1733
|
+
const cumulative = this.ctx.cumulativeUsage;
|
|
1734
|
+
if (cumulative) {
|
|
1735
|
+
const addFinite = /* @__PURE__ */ __name((total, value) => typeof value === "number" && Number.isFinite(value) ? total + value : total, "addFinite");
|
|
1736
|
+
cumulative.promptTokens = addFinite(
|
|
1737
|
+
cumulative.promptTokens,
|
|
1738
|
+
usageMetadata.promptTokenCount
|
|
1739
|
+
);
|
|
1740
|
+
cumulative.candidateTokens = addFinite(
|
|
1741
|
+
cumulative.candidateTokens,
|
|
1742
|
+
usageMetadata.candidatesTokenCount
|
|
1743
|
+
);
|
|
1744
|
+
cumulative.cachedTokens = addFinite(
|
|
1745
|
+
cumulative.cachedTokens,
|
|
1746
|
+
usageMetadata.cachedContentTokenCount
|
|
1747
|
+
);
|
|
1748
|
+
cumulative.apiTimeMs = addFinite(cumulative.apiTimeMs, durationMs);
|
|
1749
|
+
}
|
|
1750
|
+
let activityMeta = {};
|
|
1751
|
+
if (typeof durationMs === "number") {
|
|
1752
|
+
const activity = apiActivityTracker.drain();
|
|
1753
|
+
activityMeta = {
|
|
1754
|
+
...activity.errors > 0 ? { apiErrors: activity.errors } : {},
|
|
1755
|
+
...activity.retries > 0 ? { apiRetries: activity.retries } : {}
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
await this.sendUpdate(
|
|
1759
|
+
createTranscriptUsageUpdate(usageMetadata, {
|
|
1760
|
+
text,
|
|
1761
|
+
extra: {
|
|
1762
|
+
...typeof durationMs === "number" ? { durationMs } : {},
|
|
1763
|
+
...activityMeta,
|
|
1764
|
+
...subagentMeta
|
|
1765
|
+
}
|
|
1766
|
+
})
|
|
1767
|
+
);
|
|
1768
|
+
if (!Number.isFinite(durationMs) || subagentMeta || !hasFullSessionContext(this.ctx)) {
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1771
|
+
const used = usageMetadata.promptTokenCount ?? usageMetadata.totalTokenCount;
|
|
1772
|
+
const size = this.ctx.config.getContentGeneratorConfig()?.contextWindowSize;
|
|
1773
|
+
if (typeof used !== "number" || !Number.isSafeInteger(used) || used < 0 || typeof size !== "number" || !Number.isSafeInteger(size) || size <= 0) {
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
await this.sendUpdate({
|
|
1777
|
+
sessionUpdate: "usage_update",
|
|
1778
|
+
used,
|
|
1779
|
+
size
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Emits a message chunk based on role and thought flag.
|
|
1784
|
+
* This is the unified method that handles all message types.
|
|
1785
|
+
*
|
|
1786
|
+
* @param text - The message text content
|
|
1787
|
+
* @param role - Whether this is a user or assistant message
|
|
1788
|
+
* @param isThought - Whether this is an assistant thought (only applies to assistant role)
|
|
1789
|
+
* @param timestamp - Optional server-side timestamp (ISO string or ms) for message ordering
|
|
1790
|
+
*/
|
|
1791
|
+
async emitMessage(text, role, isThought = false, timestamp, subagentMeta) {
|
|
1792
|
+
if (role === "user") {
|
|
1793
|
+
return this.emitUserMessage(text, timestamp);
|
|
1794
|
+
}
|
|
1795
|
+
return isThought ? this.emitAgentThought(text, timestamp, subagentMeta) : this.emitAgentMessage(text, timestamp, subagentMeta);
|
|
1796
|
+
}
|
|
1797
|
+
};
|
|
1798
|
+
|
|
1799
|
+
// packages/cli/src/acp-integration/session/recovered-goal-update.ts
|
|
1800
|
+
init_esbuild_shims();
|
|
1801
|
+
async function renderPreparedGoalUpdate(getRuntime, options = {}) {
|
|
1802
|
+
let runtime;
|
|
1803
|
+
try {
|
|
1804
|
+
runtime = await getRuntime();
|
|
1805
|
+
} catch (error) {
|
|
1806
|
+
if (!(error instanceof GoalPersistenceUnavailableError)) throw error;
|
|
1807
|
+
const status = unrestorableGoalStatus(
|
|
1808
|
+
options.replayedRecords,
|
|
1809
|
+
options.bootstrap
|
|
1810
|
+
);
|
|
1811
|
+
return { updates: status ? [buildGoalStatusUpdate(status)] : [] };
|
|
1812
|
+
}
|
|
1813
|
+
const cause = runtime.getRecoveryCause?.();
|
|
1814
|
+
if (!cause) return { updates: [] };
|
|
1815
|
+
const snapshot = runtime.getSnapshot();
|
|
1816
|
+
const publicationKey = goalPublicationKey(snapshot, cause);
|
|
1817
|
+
if (options.hideRuntimeGoal) {
|
|
1818
|
+
return {
|
|
1819
|
+
publicationKey,
|
|
1820
|
+
...snapshot.goal ? {
|
|
1821
|
+
suppressedGoalId: snapshot.goal.goalId
|
|
1822
|
+
} : {},
|
|
1823
|
+
updates: []
|
|
1824
|
+
};
|
|
1825
|
+
}
|
|
1826
|
+
const bootstrapGoal = options.bootstrap?.goalState?.goal;
|
|
1827
|
+
const bootstrapMatchesRuntime = bootstrapGoal != null && snapshot.goal?.goalId === bootstrapGoal.goalId && snapshot.goal?.revision === bootstrapGoal.revision;
|
|
1828
|
+
return {
|
|
1829
|
+
publicationKey,
|
|
1830
|
+
updates: options.bootstrap && bootstrapMatchesRuntime ? [] : [buildGoalStateUpdate(snapshot, cause, options.previousGoal ?? null)]
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
__name(renderPreparedGoalUpdate, "renderPreparedGoalUpdate");
|
|
1834
|
+
function unrestorableGoalStatus(replayedRecords, bootstrap) {
|
|
1835
|
+
const active = (replayedRecords?.length ? findGoalToRestore(collectGoalStatusItemsFromRecords(replayedRecords)) : void 0) ?? bootstrap?.goalStatus;
|
|
1836
|
+
if (!active) return void 0;
|
|
1837
|
+
return {
|
|
1838
|
+
kind: "cleared",
|
|
1839
|
+
condition: active.condition,
|
|
1840
|
+
iterations: active.iterations,
|
|
1841
|
+
...active.setAt !== void 0 ? { setAt: active.setAt } : {},
|
|
1842
|
+
lastReason: "Goal not restored: its saved state could not be read, so this session is not driving it."
|
|
1843
|
+
};
|
|
1844
|
+
}
|
|
1845
|
+
__name(unrestorableGoalStatus, "unrestorableGoalStatus");
|
|
1846
|
+
function goalPublicationKey(snapshot, cause) {
|
|
1847
|
+
return cause ? `${cause}:${JSON.stringify(snapshot)}` : void 0;
|
|
1848
|
+
}
|
|
1849
|
+
__name(goalPublicationKey, "goalPublicationKey");
|
|
1850
|
+
|
|
1500
1851
|
// packages/cli/src/acp-integration/session/SubAgentTracker.ts
|
|
1501
1852
|
init_esbuild_shims();
|
|
1502
1853
|
|
|
@@ -2678,6 +3029,7 @@ __name(reduceRepeatedToolFailureGuard, "reduceRepeatedToolFailureGuard");
|
|
|
2678
3029
|
var debugLogger6 = createDebugLogger("SESSION");
|
|
2679
3030
|
var permissionRequestTails = /* @__PURE__ */ new WeakMap();
|
|
2680
3031
|
var USER_CANCEL_ABORT_REASON = "qwen:user-cancel";
|
|
3032
|
+
var NEW_PROMPT_ABORT_REASON = "qwen:new-prompt";
|
|
2681
3033
|
var SESSION_DISPOSE_ABORT_REASON = "qwen:session-dispose";
|
|
2682
3034
|
var DAEMON_RETRY_META_KEY = "qwen.daemon.retry";
|
|
2683
3035
|
var DAEMON_CONTINUE_META_KEY = "qwen.daemon.continueLastTurn";
|
|
@@ -2725,10 +3077,66 @@ function getAbortAwareEndTurnStopReason(signal) {
|
|
|
2725
3077
|
return signal.aborted ? "cancelled" : "end_turn";
|
|
2726
3078
|
}
|
|
2727
3079
|
__name(getAbortAwareEndTurnStopReason, "getAbortAwareEndTurnStopReason");
|
|
3080
|
+
function sameGoalPermit(left, right) {
|
|
3081
|
+
return left?.goalId === right.goalId && left.revision === right.revision && left.turnId === right.turnId;
|
|
3082
|
+
}
|
|
3083
|
+
__name(sameGoalPermit, "sameGoalPermit");
|
|
3084
|
+
function buildGoalContinuationParts(turn) {
|
|
3085
|
+
return [
|
|
3086
|
+
{
|
|
3087
|
+
text: [
|
|
3088
|
+
"Continue working on the active Goal.",
|
|
3089
|
+
"Use get_goal for the authoritative objective and evidence state.",
|
|
3090
|
+
"Follow the objective's requested output format exactly. Do not add progress, status, or completion commentary unless the objective asks for it.",
|
|
3091
|
+
"If completion depends on content delivered in this turn, deliver only that content and call get_goal in the same response before update_goal.",
|
|
3092
|
+
`Runtime continuation context: ${turn.continuationContext}`,
|
|
3093
|
+
...turn.verifierFeedback ? [`Verifier feedback: ${turn.verifierFeedback}`] : []
|
|
3094
|
+
].join("\n")
|
|
3095
|
+
}
|
|
3096
|
+
];
|
|
3097
|
+
}
|
|
3098
|
+
__name(buildGoalContinuationParts, "buildGoalContinuationParts");
|
|
3099
|
+
async function claimGoalTurn(runtime, turnKey, signal) {
|
|
3100
|
+
if (signal.aborted) return void 0;
|
|
3101
|
+
const immediate = runtime.permitForTurn(turnKey) ?? runtime.beginTurn(turnKey);
|
|
3102
|
+
if (immediate || runtime.getSnapshot().goal?.status !== "active") {
|
|
3103
|
+
return immediate;
|
|
3104
|
+
}
|
|
3105
|
+
return new Promise((resolve6, reject) => {
|
|
3106
|
+
let settled = false;
|
|
3107
|
+
let unsubscribe = /* @__PURE__ */ __name(() => {
|
|
3108
|
+
}, "unsubscribe");
|
|
3109
|
+
const finish = /* @__PURE__ */ __name((permit, error) => {
|
|
3110
|
+
if (settled) return;
|
|
3111
|
+
settled = true;
|
|
3112
|
+
unsubscribe();
|
|
3113
|
+
signal.removeEventListener("abort", onAbort);
|
|
3114
|
+
if (error !== void 0) reject(error);
|
|
3115
|
+
else resolve6(permit);
|
|
3116
|
+
}, "finish");
|
|
3117
|
+
const inspect = /* @__PURE__ */ __name(() => {
|
|
3118
|
+
try {
|
|
3119
|
+
const permit = runtime.permitForTurn(turnKey);
|
|
3120
|
+
if (permit || runtime.getSnapshot().goal?.status !== "active") {
|
|
3121
|
+
finish(permit);
|
|
3122
|
+
}
|
|
3123
|
+
} catch (error) {
|
|
3124
|
+
finish(void 0, error);
|
|
3125
|
+
}
|
|
3126
|
+
}, "inspect");
|
|
3127
|
+
const onAbort = /* @__PURE__ */ __name(() => finish(void 0), "onAbort");
|
|
3128
|
+
unsubscribe = runtime.subscribe(inspect);
|
|
3129
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
3130
|
+
if (signal.aborted) onAbort();
|
|
3131
|
+
else inspect();
|
|
3132
|
+
});
|
|
3133
|
+
}
|
|
3134
|
+
__name(claimGoalTurn, "claimGoalTurn");
|
|
2728
3135
|
var DAEMON_INVALID_TOOL_PARAMS_THRESHOLD = 3;
|
|
2729
3136
|
var PERMISSION_CANCEL_SKIP_MESSAGE = "Skipped because a permission request was cancelled before the user answered; user input is required before continuing.";
|
|
2730
3137
|
var LOOP_DETECTED_SKIP_MESSAGE = "Skipped because loop detection stopped the current turn before this tool call could run.";
|
|
2731
3138
|
var LOOP_DETECTED_CONTEXT_MESSAGE = "System: this turn was terminated because the model exceeded tool-call safety limits. Try a different approach on the next turn.";
|
|
3139
|
+
var LOOP_DETECTED_TURN_ERROR_MESSAGE = "Tool-call loop protection stopped this turn. The session is still available; send a more specific instruction to continue.";
|
|
2732
3140
|
var TOOL_EXECUTION_CANCELLED_MESSAGE = "Tool execution was cancelled.";
|
|
2733
3141
|
var TOOL_POST_EXECUTION_CANCELLED_MESSAGE = "The tool had already completed; its output was discarded.";
|
|
2734
3142
|
function createDaemonToolLoopState(repeatedToolFailureMode) {
|
|
@@ -2797,6 +3205,7 @@ __name(recordRepeatedToolFailureDecision, "recordRepeatedToolFailureDecision");
|
|
|
2797
3205
|
function recordDaemonLoopDetected(config, promptId, loopType, message, loopState, options = {}) {
|
|
2798
3206
|
if (!loopState.loopDetected) {
|
|
2799
3207
|
loopState.loopDetected = true;
|
|
3208
|
+
loopState.loopType = loopType;
|
|
2800
3209
|
debugLogger6.warn(message);
|
|
2801
3210
|
try {
|
|
2802
3211
|
logLoopDetected(
|
|
@@ -2814,6 +3223,25 @@ function recordDaemonLoopDetected(config, promptId, loopType, message, loopState
|
|
|
2814
3223
|
return true;
|
|
2815
3224
|
}
|
|
2816
3225
|
__name(recordDaemonLoopDetected, "recordDaemonLoopDetected");
|
|
3226
|
+
function createLoopDetectedTurnError(loopState) {
|
|
3227
|
+
return new RequestError(-32603, LOOP_DETECTED_TURN_ERROR_MESSAGE, {
|
|
3228
|
+
code: "LOOP_DETECTED",
|
|
3229
|
+
errorKind: "loop_detected",
|
|
3230
|
+
...loopState.loopType ? { loopType: loopState.loopType } : {}
|
|
3231
|
+
});
|
|
3232
|
+
}
|
|
3233
|
+
__name(createLoopDetectedTurnError, "createLoopDetectedTurnError");
|
|
3234
|
+
function cancelledOrThrowLoopDetected(signal, loopState) {
|
|
3235
|
+
if (signal.aborted) return "cancelled";
|
|
3236
|
+
throw createLoopDetectedTurnError(loopState);
|
|
3237
|
+
}
|
|
3238
|
+
__name(cancelledOrThrowLoopDetected, "cancelledOrThrowLoopDetected");
|
|
3239
|
+
function isLoopDetectedTurnError(error) {
|
|
3240
|
+
if (!(error instanceof RequestError)) return false;
|
|
3241
|
+
const data = error.data;
|
|
3242
|
+
return typeof data === "object" && data !== null && data.code === "LOOP_DETECTED";
|
|
3243
|
+
}
|
|
3244
|
+
__name(isLoopDetectedTurnError, "isLoopDetectedTurnError");
|
|
2817
3245
|
function recordDaemonToolCalls(config, promptId, loopState, calls) {
|
|
2818
3246
|
if (!loopState || loopState.loopDetected)
|
|
2819
3247
|
return loopState?.loopDetected ?? false;
|
|
@@ -3077,14 +3505,16 @@ var TodoStopGuardClaimTimeoutError = class extends Error {
|
|
|
3077
3505
|
}
|
|
3078
3506
|
};
|
|
3079
3507
|
function beginChannelDeliveryResponseBlock(capture) {
|
|
3080
|
-
|
|
3081
|
-
capture
|
|
3508
|
+
capture?.agentOutput.beginResponse();
|
|
3509
|
+
if (!capture?.channelDelivery) return void 0;
|
|
3510
|
+
capture.channelDelivery.finalText = "";
|
|
3082
3511
|
return [];
|
|
3083
3512
|
}
|
|
3084
3513
|
__name(beginChannelDeliveryResponseBlock, "beginChannelDeliveryResponseBlock");
|
|
3085
3514
|
function commitChannelDeliveryResponseBlock(capture, responseBlock, hasFunctionCalls) {
|
|
3086
|
-
|
|
3087
|
-
|
|
3515
|
+
capture?.agentOutput.commitResponse(hasFunctionCalls);
|
|
3516
|
+
if (capture?.channelDelivery && responseBlock && !hasFunctionCalls) {
|
|
3517
|
+
capture.channelDelivery.finalText = responseBlock.join("");
|
|
3088
3518
|
}
|
|
3089
3519
|
}
|
|
3090
3520
|
__name(commitChannelDeliveryResponseBlock, "commitChannelDeliveryResponseBlock");
|
|
@@ -3136,28 +3566,6 @@ function resolveHomeLoopResolverRoots({
|
|
|
3136
3566
|
};
|
|
3137
3567
|
}
|
|
3138
3568
|
__name(resolveHomeLoopResolverRoots, "resolveHomeLoopResolverRoots");
|
|
3139
|
-
function computeInitialTurnFromHistory(records, sessionId) {
|
|
3140
|
-
let maxPromptTurn = 0;
|
|
3141
|
-
let userMessageCount = 0;
|
|
3142
|
-
const promptIdPrefix = `${sessionId}########`;
|
|
3143
|
-
for (const record of records) {
|
|
3144
|
-
if (record.sessionId === sessionId && isUserPromptRecord(record)) {
|
|
3145
|
-
userMessageCount += 1;
|
|
3146
|
-
}
|
|
3147
|
-
for (const promptId of getRecordPromptIds(record)) {
|
|
3148
|
-
if (!promptId.startsWith(promptIdPrefix)) {
|
|
3149
|
-
continue;
|
|
3150
|
-
}
|
|
3151
|
-
const suffix = promptId.slice(promptIdPrefix.length);
|
|
3152
|
-
if (!/^\d+$/.test(suffix)) {
|
|
3153
|
-
continue;
|
|
3154
|
-
}
|
|
3155
|
-
maxPromptTurn = Math.max(maxPromptTurn, Number(suffix));
|
|
3156
|
-
}
|
|
3157
|
-
}
|
|
3158
|
-
return maxPromptTurn > 0 ? maxPromptTurn : userMessageCount;
|
|
3159
|
-
}
|
|
3160
|
-
__name(computeInitialTurnFromHistory, "computeInitialTurnFromHistory");
|
|
3161
3569
|
async function fireSessionPermissionDeniedForAutoMode(config, decision, outcome, toolName, toolParams, callId, signal) {
|
|
3162
3570
|
if (!config.getDisableAllHooks?.() && shouldFirePermissionDeniedForAutoMode(decision, outcome)) {
|
|
3163
3571
|
try {
|
|
@@ -3177,40 +3585,6 @@ async function fireSessionPermissionDeniedForAutoMode(config, decision, outcome,
|
|
|
3177
3585
|
}
|
|
3178
3586
|
}
|
|
3179
3587
|
__name(fireSessionPermissionDeniedForAutoMode, "fireSessionPermissionDeniedForAutoMode");
|
|
3180
|
-
function getRecordPromptIds(record) {
|
|
3181
|
-
const promptIds = [];
|
|
3182
|
-
const recordPromptId = record.promptId;
|
|
3183
|
-
if (typeof recordPromptId === "string") {
|
|
3184
|
-
promptIds.push(recordPromptId);
|
|
3185
|
-
}
|
|
3186
|
-
const telemetryPromptId = readTelemetryPromptId(record.systemPayload);
|
|
3187
|
-
if (telemetryPromptId) {
|
|
3188
|
-
promptIds.push(telemetryPromptId);
|
|
3189
|
-
}
|
|
3190
|
-
return promptIds;
|
|
3191
|
-
}
|
|
3192
|
-
__name(getRecordPromptIds, "getRecordPromptIds");
|
|
3193
|
-
function readTelemetryPromptId(payload) {
|
|
3194
|
-
if (!payload || typeof payload !== "object" || !("uiEvent" in payload)) {
|
|
3195
|
-
return void 0;
|
|
3196
|
-
}
|
|
3197
|
-
const uiEvent = payload.uiEvent;
|
|
3198
|
-
if (!uiEvent || typeof uiEvent !== "object" || !("prompt_id" in uiEvent)) {
|
|
3199
|
-
return void 0;
|
|
3200
|
-
}
|
|
3201
|
-
const promptId = uiEvent.prompt_id;
|
|
3202
|
-
return typeof promptId === "string" ? promptId : void 0;
|
|
3203
|
-
}
|
|
3204
|
-
__name(readTelemetryPromptId, "readTelemetryPromptId");
|
|
3205
|
-
function isUserPromptRecord(record) {
|
|
3206
|
-
if (record.type !== "user" || record.subtype === "realtime_message") {
|
|
3207
|
-
return false;
|
|
3208
|
-
}
|
|
3209
|
-
return record.message?.parts?.some(
|
|
3210
|
-
(part) => typeof part.text === "string" && part.text.trim().length > 0
|
|
3211
|
-
) ?? false;
|
|
3212
|
-
}
|
|
3213
|
-
__name(isUserPromptRecord, "isUserPromptRecord");
|
|
3214
3588
|
var AT_TOKEN_RE = /@([^\s,;!?()[\]{}]+)/g;
|
|
3215
3589
|
function collectExtensionMentionRefs(text, mentions) {
|
|
3216
3590
|
for (const match of text.matchAll(AT_TOKEN_RE)) {
|
|
@@ -3346,11 +3720,9 @@ var Session = class {
|
|
|
3346
3720
|
this.todoStopGuardBackgroundBaseline = this.#captureTodoStopGuardBackgroundBaseline();
|
|
3347
3721
|
this.toolCallEmitter = new ToolCallEmitter(this);
|
|
3348
3722
|
this.planEmitter = new PlanEmitter(this);
|
|
3349
|
-
this.historyReplayer = new HistoryReplayer(this
|
|
3350
|
-
supersedeUnrestorableGoal: true
|
|
3351
|
-
});
|
|
3723
|
+
this.historyReplayer = new HistoryReplayer(this);
|
|
3352
3724
|
this.messageEmitter = new MessageEmitter(this);
|
|
3353
|
-
this
|
|
3725
|
+
this.#bindGoalRuntime();
|
|
3354
3726
|
this.#registerBackgroundNotificationCallbacks();
|
|
3355
3727
|
this.#registerSubSessionSpawner();
|
|
3356
3728
|
this.config.getWorkflowRunRegistry?.().setApprovalRequestCallback(
|
|
@@ -3435,9 +3807,21 @@ var Session = class {
|
|
|
3435
3807
|
notificationAbortController = null;
|
|
3436
3808
|
notificationCompletion = null;
|
|
3437
3809
|
currentAgentNotificationTaskId = null;
|
|
3810
|
+
currentShellNotificationActive = false;
|
|
3438
3811
|
persistedBackgroundNotificationTaskIds = /* @__PURE__ */ new Set();
|
|
3439
3812
|
backgroundNotificationAcceptances = /* @__PURE__ */ new Map();
|
|
3440
3813
|
activeAgentNotificationAcceptances = /* @__PURE__ */ new Set();
|
|
3814
|
+
goalQueue = [];
|
|
3815
|
+
goalProcessing = false;
|
|
3816
|
+
activeGoalTurn;
|
|
3817
|
+
goalHostUnbind;
|
|
3818
|
+
goalRuntimeUnsubscribe;
|
|
3819
|
+
lastGoalSnapshot;
|
|
3820
|
+
lastGoalPublicationKey;
|
|
3821
|
+
// Set only when runtime recovery selected a Goal that initial replay hid.
|
|
3822
|
+
// Keep that Goal private through activation and later progress updates.
|
|
3823
|
+
suppressedRecoveredGoalId;
|
|
3824
|
+
goalPublicationTail = Promise.resolve();
|
|
3441
3825
|
// Set true in dispose(). Guards #drainCronQueue and #drainNotificationQueue
|
|
3442
3826
|
// against the race where #drainNotificationQueue's finally block kicks off
|
|
3443
3827
|
// #drainCronQueue after the session has already been disposed (e.g. /clear
|
|
@@ -3451,6 +3835,7 @@ var Session = class {
|
|
|
3451
3835
|
/** The exact status-change callback this Session installed, so dispose can
|
|
3452
3836
|
* retract its own and nobody else's. */
|
|
3453
3837
|
#statusChangeCallback;
|
|
3838
|
+
#shellStatusChangeCallback;
|
|
3454
3839
|
workflowApprovalAbortController = new AbortController();
|
|
3455
3840
|
activeTodoPlanRevision;
|
|
3456
3841
|
// Modular components
|
|
@@ -3483,6 +3868,296 @@ var Session = class {
|
|
|
3483
3868
|
pendingRecoveredAgentsNotice = null;
|
|
3484
3869
|
// Implement SessionContext interface
|
|
3485
3870
|
sessionId;
|
|
3871
|
+
#bindGoalRuntime() {
|
|
3872
|
+
try {
|
|
3873
|
+
const runtime = this.config.getGoalRuntime();
|
|
3874
|
+
this.lastGoalSnapshot = runtime.getSnapshot();
|
|
3875
|
+
this.goalRuntimeUnsubscribe = runtime.subscribe((snapshot, cause) => {
|
|
3876
|
+
const previousGoal = this.lastGoalSnapshot?.goal ?? null;
|
|
3877
|
+
this.lastGoalSnapshot = snapshot;
|
|
3878
|
+
void this.#queueGoalState(snapshot, cause, previousGoal).catch(
|
|
3879
|
+
(error) => debugLogger6.warn(
|
|
3880
|
+
`Failed to emit ACP Goal state: ${error instanceof Error ? error.message : String(error)}`
|
|
3881
|
+
)
|
|
3882
|
+
);
|
|
3883
|
+
});
|
|
3884
|
+
const host = {
|
|
3885
|
+
startGoalTurn: /* @__PURE__ */ __name(async (input) => {
|
|
3886
|
+
if (this.goalQueue.some(
|
|
3887
|
+
({ permit }) => permit.turnId === input.permit.turnId
|
|
3888
|
+
) || this.activeGoalTurn?.permit.turnId === input.permit.turnId) {
|
|
3889
|
+
return;
|
|
3890
|
+
}
|
|
3891
|
+
this.goalQueue.push({
|
|
3892
|
+
permit: { ...input.permit },
|
|
3893
|
+
turnKey: `goal-runtime:${input.permit.turnId}`,
|
|
3894
|
+
controller: new AbortController(),
|
|
3895
|
+
origin: "runtime",
|
|
3896
|
+
continuationContext: input.continuationContext,
|
|
3897
|
+
...input.verifierFeedback ? { verifierFeedback: input.verifierFeedback } : {},
|
|
3898
|
+
modelStarted: false
|
|
3899
|
+
});
|
|
3900
|
+
void this.#drainGoalQueue();
|
|
3901
|
+
}, "startGoalTurn"),
|
|
3902
|
+
preemptGoalTurn: /* @__PURE__ */ __name((reason) => {
|
|
3903
|
+
for (const turn of this.goalQueue.splice(0)) {
|
|
3904
|
+
turn.controller.abort(reason);
|
|
3905
|
+
}
|
|
3906
|
+
this.activeGoalTurn?.controller.abort(reason);
|
|
3907
|
+
}, "preemptGoalTurn")
|
|
3908
|
+
};
|
|
3909
|
+
this.goalHostUnbind = this.config.bindGoalTurnHost(host);
|
|
3910
|
+
} catch (error) {
|
|
3911
|
+
if (!(error instanceof GoalPersistenceUnavailableError)) {
|
|
3912
|
+
throw error;
|
|
3913
|
+
}
|
|
3914
|
+
debugLogger6.debug("Canonical Goal runtime is unavailable for ACP");
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
/**
|
|
3918
|
+
* Re-attach this session to the Goal runtime after `/clear`.
|
|
3919
|
+
*
|
|
3920
|
+
* `Config.startNewSession()` disposes the old runtime and builds a fresh
|
|
3921
|
+
* one, so the `subscribe` callback installed by `#bindGoalRuntime` — the
|
|
3922
|
+
* only path that reaches `MessageEmitter.emitGoalState` — would stay
|
|
3923
|
+
* registered on the abandoned instance and the client would never receive
|
|
3924
|
+
* another `_meta.goalState` update. The retained turn host survives the
|
|
3925
|
+
* switch, but the subscription and the publication de-duplication state
|
|
3926
|
+
* belong to the old runtime and have to be rebuilt.
|
|
3927
|
+
*/
|
|
3928
|
+
rebindGoalRuntimeForNewSession() {
|
|
3929
|
+
if (this.disposed || this.closing) return;
|
|
3930
|
+
this.goalRuntimeUnsubscribe?.();
|
|
3931
|
+
this.goalRuntimeUnsubscribe = void 0;
|
|
3932
|
+
this.goalHostUnbind?.();
|
|
3933
|
+
this.goalHostUnbind = void 0;
|
|
3934
|
+
this.lastGoalSnapshot = void 0;
|
|
3935
|
+
this.lastGoalPublicationKey = void 0;
|
|
3936
|
+
this.suppressedRecoveredGoalId = void 0;
|
|
3937
|
+
this.#bindGoalRuntime();
|
|
3938
|
+
}
|
|
3939
|
+
/**
|
|
3940
|
+
* Publish the recovered Goal state once, after history replay.
|
|
3941
|
+
*
|
|
3942
|
+
* Goal recovery runs from the `Config` constructor, long before this
|
|
3943
|
+
* Session exists, so `restore()`'s correction broadcast reaches zero
|
|
3944
|
+
* listeners — and replay streams the pre-migration records, emitting the
|
|
3945
|
+
* legacy `set` card. Clients that derive the live goal from goal cards
|
|
3946
|
+
* (both web-shell and the daemon provider do) are therefore left showing a
|
|
3947
|
+
* goal as running when the migrated goal is `paused` and nothing drives
|
|
3948
|
+
* it; only a second reload self-corrected. Republishing here puts the
|
|
3949
|
+
* authoritative state *after* the replayed card, which is the ordering
|
|
3950
|
+
* that matters. `#publishGoalState` de-duplicates on `(cause, snapshot)`,
|
|
3951
|
+
* so this is a no-op when the subscription already delivered it.
|
|
3952
|
+
*
|
|
3953
|
+
* When recovery failed outright — a malformed or future-schema
|
|
3954
|
+
* `goal_state` record makes `recoverGoalFromRecords` return `unsupported`
|
|
3955
|
+
* — there is no state to publish and no in-session command can correct the
|
|
3956
|
+
* stream, because a degraded `/goal` answers without a cause. That case
|
|
3957
|
+
* gets the same trailing `cleared` card the replay-time
|
|
3958
|
+
* `supersedeUnrestorableGoal` used to emit.
|
|
3959
|
+
*/
|
|
3960
|
+
async publishRecoveredGoalState(replayedRecords) {
|
|
3961
|
+
if (this.disposed || this.closing) return;
|
|
3962
|
+
let runtime;
|
|
3963
|
+
try {
|
|
3964
|
+
runtime = await this.config.getGoalRuntimeReady();
|
|
3965
|
+
} catch (error) {
|
|
3966
|
+
if (!(error instanceof GoalPersistenceUnavailableError)) throw error;
|
|
3967
|
+
await this.#supersedeUnrestorableGoal(replayedRecords);
|
|
3968
|
+
return;
|
|
3969
|
+
}
|
|
3970
|
+
const cause = runtime.getRecoveryCause?.();
|
|
3971
|
+
if (!cause) return;
|
|
3972
|
+
await this.#queueGoalState(runtime.getSnapshot(), cause);
|
|
3973
|
+
}
|
|
3974
|
+
async renderRecoveredGoalUpdates(replayedRecords) {
|
|
3975
|
+
if (this.disposed || this.closing) return [];
|
|
3976
|
+
const rendered = await renderPreparedGoalUpdate(
|
|
3977
|
+
() => this.config.getGoalRuntimeReady(),
|
|
3978
|
+
{
|
|
3979
|
+
...replayedRecords ? { replayedRecords } : {},
|
|
3980
|
+
previousGoal: this.lastGoalSnapshot?.goal ?? null
|
|
3981
|
+
}
|
|
3982
|
+
);
|
|
3983
|
+
if (rendered.publicationKey && rendered.publicationKey === this.lastGoalPublicationKey) {
|
|
3984
|
+
return [];
|
|
3985
|
+
}
|
|
3986
|
+
this.primeRecoveredGoalPublication(rendered.publicationKey);
|
|
3987
|
+
return rendered.updates;
|
|
3988
|
+
}
|
|
3989
|
+
primeRecoveredGoalPublication(publicationKey, suppressedGoalId) {
|
|
3990
|
+
if (publicationKey) this.lastGoalPublicationKey = publicationKey;
|
|
3991
|
+
this.suppressedRecoveredGoalId = suppressedGoalId;
|
|
3992
|
+
}
|
|
3993
|
+
#suppressRecoveredGoalUpdate(snapshot) {
|
|
3994
|
+
const suppressedGoalId = this.suppressedRecoveredGoalId;
|
|
3995
|
+
if (!suppressedGoalId) return false;
|
|
3996
|
+
const goal = snapshot.goal;
|
|
3997
|
+
if (goal?.goalId === suppressedGoalId) return true;
|
|
3998
|
+
if (goal === null) {
|
|
3999
|
+
this.suppressedRecoveredGoalId = void 0;
|
|
4000
|
+
return true;
|
|
4001
|
+
}
|
|
4002
|
+
this.suppressedRecoveredGoalId = void 0;
|
|
4003
|
+
return false;
|
|
4004
|
+
}
|
|
4005
|
+
/**
|
|
4006
|
+
* Emit a trailing `cleared` card for an active legacy goal the runtime
|
|
4007
|
+
* refused to recover.
|
|
4008
|
+
*
|
|
4009
|
+
* Emitted, not recorded: the transcript keeps its `set` card, so a later
|
|
4010
|
+
* resume that can recover the goal still finds it.
|
|
4011
|
+
*/
|
|
4012
|
+
async #supersedeUnrestorableGoal(replayedRecords) {
|
|
4013
|
+
const status = this.#unrestorableGoalStatus(replayedRecords);
|
|
4014
|
+
if (!status) return;
|
|
4015
|
+
await this.messageEmitter.emitGoalStatus(status);
|
|
4016
|
+
}
|
|
4017
|
+
/**
|
|
4018
|
+
* The `cleared` card for an active legacy goal the runtime refused to
|
|
4019
|
+
* recover, or `undefined` when there is nothing to supersede. Shared by the
|
|
4020
|
+
* streaming and rendering recovery paths so they cannot drift.
|
|
4021
|
+
*/
|
|
4022
|
+
#unrestorableGoalStatus(replayedRecords) {
|
|
4023
|
+
if (!replayedRecords?.length) return void 0;
|
|
4024
|
+
const active = findGoalToRestore(
|
|
4025
|
+
collectGoalStatusItemsFromRecords(replayedRecords)
|
|
4026
|
+
);
|
|
4027
|
+
if (!active) return void 0;
|
|
4028
|
+
return {
|
|
4029
|
+
kind: "cleared",
|
|
4030
|
+
condition: active.condition,
|
|
4031
|
+
iterations: active.iterations,
|
|
4032
|
+
...active.setAt !== void 0 ? { setAt: active.setAt } : {},
|
|
4033
|
+
lastReason: "Goal not restored: its saved state could not be read, so this session is not driving it."
|
|
4034
|
+
};
|
|
4035
|
+
}
|
|
4036
|
+
async #publishGoalState(snapshot, cause, previousGoal = this.lastGoalSnapshot?.goal ?? null) {
|
|
4037
|
+
if (this.#suppressRecoveredGoalUpdate(snapshot)) return;
|
|
4038
|
+
const publicationKey = goalPublicationKey(snapshot, cause);
|
|
4039
|
+
if (publicationKey && publicationKey === this.lastGoalPublicationKey) {
|
|
4040
|
+
return;
|
|
4041
|
+
}
|
|
4042
|
+
if (publicationKey) this.lastGoalPublicationKey = publicationKey;
|
|
4043
|
+
await this.messageEmitter.emitGoalState(snapshot, cause, previousGoal);
|
|
4044
|
+
}
|
|
4045
|
+
#queueGoalState(snapshot, cause, previousGoal = this.lastGoalSnapshot?.goal ?? null) {
|
|
4046
|
+
const publication = this.goalPublicationTail.then(
|
|
4047
|
+
() => this.#publishGoalState(snapshot, cause, previousGoal)
|
|
4048
|
+
);
|
|
4049
|
+
this.goalPublicationTail = publication.catch(() => void 0);
|
|
4050
|
+
return publication;
|
|
4051
|
+
}
|
|
4052
|
+
async #drainGoalQueue() {
|
|
4053
|
+
if (this.disposed || this.closing || this.goalProcessing || this.pendingPrompt || this.pendingPromptCompletion || this.cronProcessing || this.cronAbortController || this.notificationProcessing || this.notificationAbortController) {
|
|
4054
|
+
return;
|
|
4055
|
+
}
|
|
4056
|
+
const turn = this.goalQueue.shift();
|
|
4057
|
+
if (!turn) return;
|
|
4058
|
+
this.goalProcessing = true;
|
|
4059
|
+
this.activeGoalTurn = turn;
|
|
4060
|
+
const parts = buildGoalContinuationParts(turn);
|
|
4061
|
+
try {
|
|
4062
|
+
await this.prompt(
|
|
4063
|
+
{
|
|
4064
|
+
sessionId: this.sessionId,
|
|
4065
|
+
prompt: parts.map((part) => ({
|
|
4066
|
+
type: "text",
|
|
4067
|
+
text: part.text ?? ""
|
|
4068
|
+
}))
|
|
4069
|
+
},
|
|
4070
|
+
void 0,
|
|
4071
|
+
void 0,
|
|
4072
|
+
void 0,
|
|
4073
|
+
turn
|
|
4074
|
+
);
|
|
4075
|
+
} catch (error) {
|
|
4076
|
+
await this.#settleGoalTurn(turn, void 0, true);
|
|
4077
|
+
debugLogger6.warn(
|
|
4078
|
+
`ACP Goal turn failed: ${error instanceof Error ? error.message : String(error)}`
|
|
4079
|
+
);
|
|
4080
|
+
} finally {
|
|
4081
|
+
if (this.activeGoalTurn === turn) this.activeGoalTurn = void 0;
|
|
4082
|
+
this.goalProcessing = false;
|
|
4083
|
+
void this.#drainCronQueue();
|
|
4084
|
+
void this.#drainNotificationQueue();
|
|
4085
|
+
void this.#drainGoalQueue();
|
|
4086
|
+
}
|
|
4087
|
+
}
|
|
4088
|
+
async #settleGoalTurn(turn, result, failed) {
|
|
4089
|
+
try {
|
|
4090
|
+
const runtime = await this.config.getGoalRuntimeReady();
|
|
4091
|
+
if (!sameGoalPermit(runtime.permitForTurn(turn.turnKey), turn.permit)) {
|
|
4092
|
+
return;
|
|
4093
|
+
}
|
|
4094
|
+
if (!turn.modelStarted) {
|
|
4095
|
+
if (turn.controller.signal.reason === USER_CANCEL_ABORT_REASON && runtime.getSnapshot().goal?.status === "active") {
|
|
4096
|
+
await runtime.dispatch({
|
|
4097
|
+
action: "pause",
|
|
4098
|
+
expectedGoalId: turn.permit.goalId,
|
|
4099
|
+
expectedRevision: turn.permit.revision
|
|
4100
|
+
});
|
|
4101
|
+
} else {
|
|
4102
|
+
await runtime.releaseTurn(turn.turnKey);
|
|
4103
|
+
}
|
|
4104
|
+
return;
|
|
4105
|
+
}
|
|
4106
|
+
try {
|
|
4107
|
+
await this.config.getChatRecordingService()?.flush();
|
|
4108
|
+
} catch (error) {
|
|
4109
|
+
debugLogger6.warn(
|
|
4110
|
+
`Failed to flush ACP Goal turn: ${error instanceof Error ? error.message : String(error)}`
|
|
4111
|
+
);
|
|
4112
|
+
}
|
|
4113
|
+
const cancelledByUser = result?.stopReason === "cancelled" && turn.controller.signal.reason === USER_CANCEL_ABORT_REASON;
|
|
4114
|
+
const supersededByNewPrompt = turn.controller.signal.reason === NEW_PROMPT_ABORT_REASON;
|
|
4115
|
+
const shouldPause = !supersededByNewPrompt && (failed || result?.stopReason === "max_tokens" || cancelledByUser || turn.controller.signal.reason === SESSION_DISPOSE_ABORT_REASON);
|
|
4116
|
+
try {
|
|
4117
|
+
if (shouldPause && runtime.getSnapshot().goal?.status === "active") {
|
|
4118
|
+
await runtime.dispatch({
|
|
4119
|
+
action: "pause",
|
|
4120
|
+
expectedGoalId: turn.permit.goalId,
|
|
4121
|
+
expectedRevision: turn.permit.revision
|
|
4122
|
+
});
|
|
4123
|
+
return;
|
|
4124
|
+
}
|
|
4125
|
+
await runtime.finishTurn(turn.permit);
|
|
4126
|
+
} catch (error) {
|
|
4127
|
+
debugLogger6.warn(
|
|
4128
|
+
`Failed to record ACP Goal turn settlement: ${error instanceof Error ? error.message : String(error)}`
|
|
4129
|
+
);
|
|
4130
|
+
await runtime.releaseTurn(turn.turnKey);
|
|
4131
|
+
}
|
|
4132
|
+
} catch (error) {
|
|
4133
|
+
debugLogger6.warn(
|
|
4134
|
+
`Failed to settle ACP Goal turn: ${error instanceof Error ? error.message : String(error)}`
|
|
4135
|
+
);
|
|
4136
|
+
}
|
|
4137
|
+
}
|
|
4138
|
+
/**
|
|
4139
|
+
* Stops an autonomous Goal loop when the Stop-hook blocking cap fires.
|
|
4140
|
+
*
|
|
4141
|
+
* `abortGoalForStopHookCap` only knows about the legacy `activeGoalStore`,
|
|
4142
|
+
* which no longer has a writer for daemon sessions, so ACP needs the
|
|
4143
|
+
* canonical runtime acted on directly.
|
|
4144
|
+
*/
|
|
4145
|
+
async #pauseGoalForStopHookCap() {
|
|
4146
|
+
try {
|
|
4147
|
+
const runtime = await this.config.getGoalRuntimeReady();
|
|
4148
|
+
const goal = runtime.getSnapshot().goal;
|
|
4149
|
+
if (goal?.status !== "active") return;
|
|
4150
|
+
await runtime.dispatch({
|
|
4151
|
+
action: "pause",
|
|
4152
|
+
expectedGoalId: goal.goalId,
|
|
4153
|
+
expectedRevision: goal.revision
|
|
4154
|
+
});
|
|
4155
|
+
} catch (error) {
|
|
4156
|
+
debugLogger6.warn(
|
|
4157
|
+
`Failed to pause the Goal after the Stop hook cap: ${error instanceof Error ? error.message : String(error)}`
|
|
4158
|
+
);
|
|
4159
|
+
}
|
|
4160
|
+
}
|
|
3486
4161
|
async #requestWorkflowApproval(runId, approval, rawArgs, approvalSignal) {
|
|
3487
4162
|
const registry = this.config.getWorkflowRunRegistry();
|
|
3488
4163
|
const externalToolCallId = `workflow:${this.sessionId}:${runId}:${approval.approvalId}`;
|
|
@@ -4129,6 +4804,10 @@ var Session = class {
|
|
|
4129
4804
|
for (const taskId of notificationIds) {
|
|
4130
4805
|
holds.push({ category: "notification", id: taskId });
|
|
4131
4806
|
}
|
|
4807
|
+
const shellActive = this.config.getBackgroundShellRegistry().hasRunningEntries() || this.notificationQueue.some((item) => item.kind === "shell") || this.currentShellNotificationActive;
|
|
4808
|
+
if (shellActive) {
|
|
4809
|
+
holds.push({ category: "shell", id: "background-shells" });
|
|
4810
|
+
}
|
|
4132
4811
|
return holds;
|
|
4133
4812
|
}
|
|
4134
4813
|
#activeWorkChanged() {
|
|
@@ -4136,7 +4815,7 @@ var Session = class {
|
|
|
4136
4815
|
}
|
|
4137
4816
|
#hasActiveTurn() {
|
|
4138
4817
|
return Boolean(
|
|
4139
|
-
this.pendingPrompt || this.pendingPromptCompletion || this.cronProcessing || this.cronAbortController || this.cronCompletion || this.notificationProcessing || this.notificationAbortController || this.notificationCompletion
|
|
4818
|
+
this.pendingPrompt || this.pendingPromptCompletion || this.goalProcessing || this.cronProcessing || this.cronAbortController || this.cronCompletion || this.notificationProcessing || this.notificationAbortController || this.notificationCompletion
|
|
4140
4819
|
);
|
|
4141
4820
|
}
|
|
4142
4821
|
beginClose() {
|
|
@@ -4164,6 +4843,7 @@ var Session = class {
|
|
|
4164
4843
|
resolveGate();
|
|
4165
4844
|
if (this.disposed) return;
|
|
4166
4845
|
this.closing = false;
|
|
4846
|
+
void this.#drainGoalQueue();
|
|
4167
4847
|
void this.#drainCronQueue();
|
|
4168
4848
|
void this.#drainNotificationQueue();
|
|
4169
4849
|
};
|
|
@@ -4227,6 +4907,14 @@ var Session = class {
|
|
|
4227
4907
|
this.hardSuspendTodoStopGuard();
|
|
4228
4908
|
this.notificationQueue = [];
|
|
4229
4909
|
this.cronQueue = [];
|
|
4910
|
+
for (const turn of this.goalQueue.splice(0)) {
|
|
4911
|
+
turn.controller.abort(SESSION_DISPOSE_ABORT_REASON);
|
|
4912
|
+
}
|
|
4913
|
+
this.activeGoalTurn?.controller.abort(SESSION_DISPOSE_ABORT_REASON);
|
|
4914
|
+
this.goalHostUnbind?.();
|
|
4915
|
+
this.goalHostUnbind = void 0;
|
|
4916
|
+
this.goalRuntimeUnsubscribe?.();
|
|
4917
|
+
this.goalRuntimeUnsubscribe = void 0;
|
|
4230
4918
|
this.notificationAbortController?.abort();
|
|
4231
4919
|
this.notificationAbortController = null;
|
|
4232
4920
|
this.notificationProcessing = false;
|
|
@@ -4247,14 +4935,18 @@ var Session = class {
|
|
|
4247
4935
|
this.#statusChangeCallback = void 0;
|
|
4248
4936
|
}
|
|
4249
4937
|
this.config.getMonitorRegistry().setNotificationCallback(void 0);
|
|
4250
|
-
this.config.getBackgroundShellRegistry()
|
|
4938
|
+
const shellRegistry = this.config.getBackgroundShellRegistry();
|
|
4939
|
+
shellRegistry.setNotificationCallback(void 0);
|
|
4940
|
+
if (this.#shellStatusChangeCallback) {
|
|
4941
|
+
shellRegistry.clearStatusChangeCallback(this.#shellStatusChangeCallback);
|
|
4942
|
+
this.#shellStatusChangeCallback = void 0;
|
|
4943
|
+
}
|
|
4251
4944
|
this.config.getChatRecordingService()?.setTitleRecordedCallback(void 0);
|
|
4252
4945
|
this.unsubscribeChatRecordingFailure?.();
|
|
4253
4946
|
this.unsubscribeChatRecordingFailure = void 0;
|
|
4254
4947
|
this.config.setSubSessionSpawner(void 0);
|
|
4255
4948
|
this.config.getWorkflowRunRegistry?.().setApprovalRequestCallback(void 0);
|
|
4256
4949
|
this.workflowApprovalAbortController.abort(SESSION_DISPOSE_ABORT_REASON);
|
|
4257
|
-
clearGoalTerminalObserver(this.sessionId);
|
|
4258
4950
|
}
|
|
4259
4951
|
/**
|
|
4260
4952
|
* Install the message rewrite middleware if configured.
|
|
@@ -4271,64 +4963,30 @@ var Session = class {
|
|
|
4271
4963
|
);
|
|
4272
4964
|
}
|
|
4273
4965
|
}
|
|
4274
|
-
/**
|
|
4275
|
-
* Installs (or replaces) this session's goal-terminal observer.
|
|
4276
|
-
*
|
|
4277
|
-
* Public because it does not stay installed: `registerGoalHook` and
|
|
4278
|
-
* `unregisterGoalHook` both clear the observer table for the session, so any
|
|
4279
|
-
* caller that (re-)registers a goal outside `#processSlashCommandResult` —
|
|
4280
|
-
* notably goal restore on resume — has to put it back. Idempotent.
|
|
4281
|
-
*/
|
|
4282
|
-
installGoalTerminalObserver() {
|
|
4283
|
-
setGoalTerminalObserver(this.sessionId, (event) => {
|
|
4284
|
-
void this.messageEmitter.emitGoalTerminal(event).catch((error) => {
|
|
4285
|
-
debugLogger6.warn(
|
|
4286
|
-
`Failed to emit goal terminal update: ${this.#formatError(error)}`
|
|
4287
|
-
);
|
|
4288
|
-
});
|
|
4289
|
-
recordGoalStatusItem(this.config, goalTerminalEventToHistoryItem(event));
|
|
4290
|
-
});
|
|
4291
|
-
}
|
|
4292
|
-
/**
|
|
4293
|
-
* Emits a goal card and persists it to the transcript. Both `set` and
|
|
4294
|
-
* `cleared` reach the client this way — from `#emitGoalStatusItems` for a
|
|
4295
|
-
* `/goal` prompt, and from the `sessionGoalClear` ext method — so recording
|
|
4296
|
-
* here (rather than at each call site) keeps the transcript in step with the
|
|
4297
|
-
* hook. Replay goes through `messageEmitter.emitGoalStatus` directly and so
|
|
4298
|
-
* does not re-record.
|
|
4299
|
-
*/
|
|
4300
|
-
emitGoalStatus(status) {
|
|
4301
|
-
void this.messageEmitter.emitGoalStatus(status).catch((error) => {
|
|
4302
|
-
debugLogger6.warn(
|
|
4303
|
-
`Failed to emit goal status update: ${this.#formatError(error)}`
|
|
4304
|
-
);
|
|
4305
|
-
});
|
|
4306
|
-
recordGoalStatusItem(this.config, {
|
|
4307
|
-
type: "goal_status" /* GOAL_STATUS */,
|
|
4308
|
-
...status
|
|
4309
|
-
});
|
|
4310
|
-
}
|
|
4311
4966
|
/**
|
|
4312
4967
|
* Replays conversation history to the client using modular components.
|
|
4313
4968
|
* Delegates to HistoryReplayer for consistent event emission.
|
|
4314
4969
|
*/
|
|
4315
4970
|
primeTurnFromHistory(records) {
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
if (typeof backgroundTask?.taskId === "string") {
|
|
4320
|
-
this.persistedBackgroundNotificationTaskIds.add(backgroundTask.taskId);
|
|
4321
|
-
}
|
|
4322
|
-
}
|
|
4323
|
-
this.turn = Math.max(
|
|
4324
|
-
this.turn,
|
|
4325
|
-
computeInitialTurnFromHistory(records, this.config.getSessionId())
|
|
4971
|
+
const turnState = collectSessionTurnState(
|
|
4972
|
+
records,
|
|
4973
|
+
this.config.getSessionId()
|
|
4326
4974
|
);
|
|
4975
|
+
this.primeTurnState(
|
|
4976
|
+
turnState.initialTurn,
|
|
4977
|
+
turnState.backgroundNotificationTaskIds
|
|
4978
|
+
);
|
|
4979
|
+
}
|
|
4980
|
+
primeTurnState(initialTurn, backgroundNotificationTaskIds) {
|
|
4981
|
+
for (const taskId of backgroundNotificationTaskIds) {
|
|
4982
|
+
this.persistedBackgroundNotificationTaskIds.add(taskId);
|
|
4983
|
+
}
|
|
4984
|
+
this.turn = Math.max(this.turn, initialTurn);
|
|
4327
4985
|
}
|
|
4328
|
-
async replayHistory(records, gaps) {
|
|
4986
|
+
async replayHistory(records, gaps, options) {
|
|
4329
4987
|
this.primeTurnFromHistory(records);
|
|
4330
4988
|
try {
|
|
4331
|
-
await this.historyReplayer.replay(records, gaps);
|
|
4989
|
+
await this.historyReplayer.replay(records, gaps, options);
|
|
4332
4990
|
} finally {
|
|
4333
4991
|
this.activeTodoPlanRevision = void 0;
|
|
4334
4992
|
}
|
|
@@ -4446,11 +5104,13 @@ var Session = class {
|
|
|
4446
5104
|
const hadPrompt = !!this.pendingPrompt;
|
|
4447
5105
|
const hadCron = !!this.cronAbortController;
|
|
4448
5106
|
const hadNotification = !!this.notificationAbortController || this.notificationProcessing;
|
|
5107
|
+
const queuedGoalTurns = this.goalQueue.splice(0);
|
|
5108
|
+
const hadQueuedGoalTurn = queuedGoalTurns.length > 0;
|
|
4449
5109
|
if (this.followupAbort) {
|
|
4450
5110
|
this.followupAbort.abort();
|
|
4451
5111
|
this.followupAbort = null;
|
|
4452
5112
|
}
|
|
4453
|
-
if (!hadPrompt && !hadCron && !hadNotification) {
|
|
5113
|
+
if (!hadPrompt && !hadCron && !hadNotification && !hadQueuedGoalTurn) {
|
|
4454
5114
|
throw new Error(NOT_CURRENTLY_GENERATING_CANCEL_MESSAGE);
|
|
4455
5115
|
}
|
|
4456
5116
|
this.todoStopGuard.suspend();
|
|
@@ -4458,6 +5118,9 @@ var Session = class {
|
|
|
4458
5118
|
this.pendingPrompt.abort(USER_CANCEL_ABORT_REASON);
|
|
4459
5119
|
this.pendingPrompt = null;
|
|
4460
5120
|
}
|
|
5121
|
+
for (const turn of queuedGoalTurns) {
|
|
5122
|
+
turn.controller.abort(USER_CANCEL_ABORT_REASON);
|
|
5123
|
+
}
|
|
4461
5124
|
if (this.cronAbortController) {
|
|
4462
5125
|
this.cronAbortController.abort();
|
|
4463
5126
|
this.cronAbortController = null;
|
|
@@ -4470,6 +5133,26 @@ var Session = class {
|
|
|
4470
5133
|
}
|
|
4471
5134
|
this.notificationQueue = [];
|
|
4472
5135
|
this.notificationProcessing = false;
|
|
5136
|
+
const queuedGoalTurn = queuedGoalTurns[0];
|
|
5137
|
+
if (queuedGoalTurn) {
|
|
5138
|
+
try {
|
|
5139
|
+
const runtime = this.config.getGoalRuntime();
|
|
5140
|
+
if (sameGoalPermit(
|
|
5141
|
+
runtime.permitForTurn(queuedGoalTurn.turnKey),
|
|
5142
|
+
queuedGoalTurn.permit
|
|
5143
|
+
) && runtime.getSnapshot().goal?.status === "active") {
|
|
5144
|
+
await runtime.dispatch({
|
|
5145
|
+
action: "pause",
|
|
5146
|
+
expectedGoalId: queuedGoalTurn.permit.goalId,
|
|
5147
|
+
expectedRevision: queuedGoalTurn.permit.revision
|
|
5148
|
+
});
|
|
5149
|
+
}
|
|
5150
|
+
} catch (error) {
|
|
5151
|
+
debugLogger6.warn(
|
|
5152
|
+
`Failed to pause queued ACP Goal turn: ${error instanceof Error ? error.message : String(error)}`
|
|
5153
|
+
);
|
|
5154
|
+
}
|
|
5155
|
+
}
|
|
4473
5156
|
this.#activeWorkChanged();
|
|
4474
5157
|
const scheduler = this.config.isCronEnabled() ? this.config.getCronScheduler() : null;
|
|
4475
5158
|
if (scheduler) {
|
|
@@ -4480,7 +5163,7 @@ var Session = class {
|
|
|
4480
5163
|
}
|
|
4481
5164
|
}
|
|
4482
5165
|
}
|
|
4483
|
-
async prompt(params, invocationContext, admissionCancellation, modelPrompt) {
|
|
5166
|
+
async prompt(params, invocationContext, admissionCancellation, modelPrompt, scheduledGoalTurn) {
|
|
4484
5167
|
if (this.closing) {
|
|
4485
5168
|
throw RequestError.invalidParams(void 0, "Session is closing");
|
|
4486
5169
|
}
|
|
@@ -4507,8 +5190,27 @@ var Session = class {
|
|
|
4507
5190
|
return { stopReason: "cancelled" };
|
|
4508
5191
|
}
|
|
4509
5192
|
const todoStopGuardPreparation = this.#prepareTodoStopGuardForPrompt(params);
|
|
4510
|
-
|
|
4511
|
-
|
|
5193
|
+
let goalTurn = scheduledGoalTurn;
|
|
5194
|
+
let reservedGoalRuntime;
|
|
5195
|
+
let reservedGoalTurnKey;
|
|
5196
|
+
if (!goalTurn) {
|
|
5197
|
+
try {
|
|
5198
|
+
const runtime = this.config.getGoalRuntime();
|
|
5199
|
+
if (runtime.getSnapshot().goal?.status === "active") {
|
|
5200
|
+
reservedGoalRuntime = runtime;
|
|
5201
|
+
reservedGoalTurnKey = `goal-user:${randomUUID()}`;
|
|
5202
|
+
runtime.beginTurn(reservedGoalTurnKey);
|
|
5203
|
+
for (const queued of this.goalQueue.splice(0)) {
|
|
5204
|
+
queued.controller.abort(NEW_PROMPT_ABORT_REASON);
|
|
5205
|
+
await runtime.releaseTurn(queued.turnKey);
|
|
5206
|
+
}
|
|
5207
|
+
}
|
|
5208
|
+
} catch (error) {
|
|
5209
|
+
if (!(error instanceof GoalPersistenceUnavailableError)) throw error;
|
|
5210
|
+
}
|
|
5211
|
+
}
|
|
5212
|
+
this.pendingPrompt?.abort(NEW_PROMPT_ABORT_REASON);
|
|
5213
|
+
const pendingSend = goalTurn?.controller ?? new AbortController();
|
|
4512
5214
|
const cancelPendingSend = /* @__PURE__ */ __name(() => pendingSend.abort(USER_CANCEL_ABORT_REASON), "cancelPendingSend");
|
|
4513
5215
|
if (admissionCancellation) {
|
|
4514
5216
|
admissionCancellation.addEventListener("abort", cancelPendingSend, {
|
|
@@ -4558,7 +5260,46 @@ var Session = class {
|
|
|
4558
5260
|
} catch {
|
|
4559
5261
|
}
|
|
4560
5262
|
}
|
|
5263
|
+
if (reservedGoalRuntime && reservedGoalTurnKey) {
|
|
5264
|
+
try {
|
|
5265
|
+
const permit = await claimGoalTurn(
|
|
5266
|
+
reservedGoalRuntime,
|
|
5267
|
+
reservedGoalTurnKey,
|
|
5268
|
+
pendingSend.signal
|
|
5269
|
+
);
|
|
5270
|
+
if (permit) {
|
|
5271
|
+
const goal = reservedGoalRuntime.getSnapshot().goal;
|
|
5272
|
+
if (goal) {
|
|
5273
|
+
const verifierFeedback = reservedGoalRuntime.getVerifierFeedback(permit);
|
|
5274
|
+
goalTurn = {
|
|
5275
|
+
permit,
|
|
5276
|
+
turnKey: reservedGoalTurnKey,
|
|
5277
|
+
controller: pendingSend,
|
|
5278
|
+
origin: "user",
|
|
5279
|
+
continuationContext: goal.objective,
|
|
5280
|
+
...verifierFeedback ? { verifierFeedback } : {},
|
|
5281
|
+
modelStarted: false
|
|
5282
|
+
};
|
|
5283
|
+
}
|
|
5284
|
+
}
|
|
5285
|
+
} catch (error) {
|
|
5286
|
+
try {
|
|
5287
|
+
await reservedGoalRuntime.releaseTurn(reservedGoalTurnKey);
|
|
5288
|
+
} catch (releaseError) {
|
|
5289
|
+
debugLogger6.warn(
|
|
5290
|
+
`Failed to release Goal reservation after admission failure: ${releaseError instanceof Error ? releaseError.message : String(releaseError)}`
|
|
5291
|
+
);
|
|
5292
|
+
} finally {
|
|
5293
|
+
releasePendingSend();
|
|
5294
|
+
this.todoStopGuard.suspend();
|
|
5295
|
+
}
|
|
5296
|
+
throw error;
|
|
5297
|
+
}
|
|
5298
|
+
}
|
|
4561
5299
|
if (pendingSend.signal.aborted) {
|
|
5300
|
+
if (reservedGoalRuntime && reservedGoalTurnKey) {
|
|
5301
|
+
await reservedGoalRuntime.releaseTurn(reservedGoalTurnKey);
|
|
5302
|
+
}
|
|
4562
5303
|
releasePendingSend();
|
|
4563
5304
|
this.todoStopGuard.suspend();
|
|
4564
5305
|
return { stopReason: "cancelled" };
|
|
@@ -4570,19 +5311,39 @@ var Session = class {
|
|
|
4570
5311
|
}
|
|
4571
5312
|
this.duplicateProviderToolCallResponseIds.clear();
|
|
4572
5313
|
const channelDelivery = parsePromptChannelDelivery(params);
|
|
4573
|
-
const
|
|
5314
|
+
const responseCapture = {
|
|
5315
|
+
...channelDelivery ? { channelDelivery: { finalText: "" } } : {},
|
|
5316
|
+
agentOutput: new AgentOutputMessageCapture(this.config)
|
|
5317
|
+
};
|
|
5318
|
+
const channelPromptTurn = params._meta?.[CHANNEL_PROMPT_META_KEY] === true;
|
|
4574
5319
|
let resolveCompletion;
|
|
4575
5320
|
this.pendingPromptCompletion = new Promise((resolve6) => {
|
|
4576
5321
|
resolveCompletion = resolve6;
|
|
4577
5322
|
});
|
|
5323
|
+
let rejectedByLoopProtection = false;
|
|
5324
|
+
let promptResult;
|
|
5325
|
+
let promptFailed = false;
|
|
4578
5326
|
try {
|
|
4579
5327
|
const result = await this.#executePrompt(
|
|
4580
5328
|
params,
|
|
4581
5329
|
pendingSend,
|
|
4582
|
-
|
|
5330
|
+
responseCapture,
|
|
4583
5331
|
invocationContext,
|
|
4584
|
-
modelPrompt
|
|
5332
|
+
modelPrompt,
|
|
5333
|
+
// Channel turns are non-interactive deliveries: like cron,
|
|
5334
|
+
// background-notification, and goal turns they keep the graceful
|
|
5335
|
+
// end-turn handling so the collected response text is still
|
|
5336
|
+
// delivered. Only the authenticated CHANNEL_PROMPT_META_KEY turns
|
|
5337
|
+
// sent by the channel bridges qualify; the delivery meta alone
|
|
5338
|
+
// schedules the delivery but keeps the foreground rejection. Goal
|
|
5339
|
+
// turns bypass the bridge entirely, so a rejection there would
|
|
5340
|
+
// settle the turn as failed and pause the goal without any
|
|
5341
|
+
// turn_error ever being published.
|
|
5342
|
+
!channelPromptTurn && goalTurn === void 0,
|
|
5343
|
+
goalTurn,
|
|
5344
|
+
channelPromptTurn
|
|
4585
5345
|
);
|
|
5346
|
+
promptResult = result;
|
|
4586
5347
|
releasePendingSend();
|
|
4587
5348
|
void this.#drainCronQueue();
|
|
4588
5349
|
void this.#drainNotificationQueue();
|
|
@@ -4594,23 +5355,30 @@ var Session = class {
|
|
|
4594
5355
|
source: "prompt",
|
|
4595
5356
|
target: channelDelivery.target,
|
|
4596
5357
|
text: normalizeChannelDeliveryText(
|
|
4597
|
-
|
|
5358
|
+
responseCapture.channelDelivery?.finalText ?? ""
|
|
4598
5359
|
),
|
|
4599
5360
|
promptId: channelDelivery.deliveryId
|
|
4600
5361
|
});
|
|
4601
5362
|
}
|
|
4602
5363
|
return result;
|
|
4603
5364
|
} catch (error) {
|
|
5365
|
+
promptFailed = true;
|
|
4604
5366
|
if (error instanceof SessionWriterError) {
|
|
4605
5367
|
throw new RequestError(error.rpcCode, error.message, {
|
|
4606
5368
|
errorKind: error.errorKind
|
|
4607
5369
|
});
|
|
4608
5370
|
}
|
|
5371
|
+
rejectedByLoopProtection = isLoopDetectedTurnError(error);
|
|
4609
5372
|
throw error;
|
|
4610
5373
|
} finally {
|
|
4611
5374
|
const stillOwnsPendingPrompt = this.pendingPrompt === pendingSend;
|
|
4612
5375
|
releasePendingSend();
|
|
4613
|
-
const shouldDrainAutomaticQueues =
|
|
5376
|
+
const shouldDrainAutomaticQueues = (
|
|
5377
|
+
// Loop-detected turns resolved end_turn (and drained) before loop
|
|
5378
|
+
// stops became rejections; keep that invariant on the new path so
|
|
5379
|
+
// queued cron/notification work is not stranded.
|
|
5380
|
+
rejectedByLoopProtection || todoStopGuardPreparation.drainSupersededAutomaticQueues || this.todoStopGuardDrainAutomaticQueuesWhenIdle || this.todoStopGuard.blocksUnrelatedAutomaticTurns || this.todoStopGuard.hasCommittedContinuation || this.todoStopGuardQueuedPromptPriority
|
|
5381
|
+
);
|
|
4614
5382
|
if (stillOwnsPendingPrompt) {
|
|
4615
5383
|
this.todoStopGuardDrainAutomaticQueuesWhenIdle = false;
|
|
4616
5384
|
}
|
|
@@ -4618,9 +5386,15 @@ var Session = class {
|
|
|
4618
5386
|
void this.#drainCronQueue();
|
|
4619
5387
|
void this.#drainNotificationQueue();
|
|
4620
5388
|
}
|
|
5389
|
+
if (goalTurn) {
|
|
5390
|
+
await this.#settleGoalTurn(goalTurn, promptResult, promptFailed);
|
|
5391
|
+
} else if (reservedGoalRuntime && reservedGoalTurnKey) {
|
|
5392
|
+
await reservedGoalRuntime.releaseTurn(reservedGoalTurnKey);
|
|
5393
|
+
}
|
|
4621
5394
|
void this.#startCronSchedulerInRuntime();
|
|
4622
5395
|
resolveCompletion();
|
|
4623
5396
|
this.pendingPromptCompletion = null;
|
|
5397
|
+
void this.#drainGoalQueue();
|
|
4624
5398
|
await this.#consumeLiveEndInstruction();
|
|
4625
5399
|
}
|
|
4626
5400
|
}
|
|
@@ -4742,7 +5516,7 @@ var Session = class {
|
|
|
4742
5516
|
}
|
|
4743
5517
|
})();
|
|
4744
5518
|
}
|
|
4745
|
-
async #executePrompt(params, pendingSend,
|
|
5519
|
+
async #executePrompt(params, pendingSend, responseCapture, invocationContext, modelPrompt, rejectOnLoopDetected = false, goalTurn, channelTurn = false) {
|
|
4746
5520
|
const sessionId = this.config.getSessionId();
|
|
4747
5521
|
if (invocationContext !== void 0 && invocationContext.sessionId !== sessionId) {
|
|
4748
5522
|
throw RequestError.invalidParams(
|
|
@@ -4750,20 +5524,24 @@ var Session = class {
|
|
|
4750
5524
|
"Invocation context session does not match the active session"
|
|
4751
5525
|
);
|
|
4752
5526
|
}
|
|
4753
|
-
|
|
5527
|
+
const execute = /* @__PURE__ */ __name(() => runWithInvocationContext(
|
|
4754
5528
|
invocationContext,
|
|
4755
5529
|
() => sessionIdContext.run(
|
|
4756
5530
|
sessionId,
|
|
4757
5531
|
() => this.#executePromptInner(
|
|
4758
5532
|
params,
|
|
4759
5533
|
pendingSend,
|
|
4760
|
-
|
|
4761
|
-
modelPrompt
|
|
5534
|
+
responseCapture,
|
|
5535
|
+
modelPrompt,
|
|
5536
|
+
rejectOnLoopDetected,
|
|
5537
|
+
goalTurn,
|
|
5538
|
+
channelTurn
|
|
4762
5539
|
)
|
|
4763
5540
|
)
|
|
4764
|
-
);
|
|
5541
|
+
), "execute");
|
|
5542
|
+
return goalTurn ? goalTurnContext.run(goalTurn.permit, execute) : goalTurnContext.exit(execute);
|
|
4765
5543
|
}
|
|
4766
|
-
async #executePromptInner(params, pendingSend,
|
|
5544
|
+
async #executePromptInner(params, pendingSend, responseCapture, modelPrompt, rejectOnLoopDetected = false, goalTurn, channelTurn = false) {
|
|
4767
5545
|
return Storage.runWithRuntimeBaseDir(
|
|
4768
5546
|
this.runtimeBaseDir,
|
|
4769
5547
|
this.config.getWorkingDir(),
|
|
@@ -4788,6 +5566,7 @@ var Session = class {
|
|
|
4788
5566
|
},
|
|
4789
5567
|
async () => {
|
|
4790
5568
|
const promptText = params.prompt.filter((block) => block.type === "text").map((block) => block.type === "text" ? block.text : "").join(" ");
|
|
5569
|
+
const promptDisplayText = typeof promptMetadata?.[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY] === "string" ? promptMetadata[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY] : void 0;
|
|
4791
5570
|
const modelPromptBlocks = modelPrompt === void 0 ? params.prompt : [{ type: "text", text: modelPrompt }];
|
|
4792
5571
|
logUserPrompt(
|
|
4793
5572
|
this.config,
|
|
@@ -4800,10 +5579,25 @@ var Session = class {
|
|
|
4800
5579
|
);
|
|
4801
5580
|
const isRetry = params.retry === true || params._meta?.[DAEMON_RETRY_META_KEY] === true;
|
|
4802
5581
|
const isContinue = params._meta?.[DAEMON_CONTINUE_META_KEY] === true;
|
|
5582
|
+
if (!isRetry && !isContinue && goalTurn?.origin !== "runtime") {
|
|
5583
|
+
const interactionSpan = getActiveInteractionSpan();
|
|
5584
|
+
if (interactionSpan) {
|
|
5585
|
+
addAgentInputMessageAttributes(
|
|
5586
|
+
this.config,
|
|
5587
|
+
interactionSpan,
|
|
5588
|
+
promptDisplayText ?? promptText
|
|
5589
|
+
);
|
|
5590
|
+
}
|
|
5591
|
+
}
|
|
4803
5592
|
let continuationParts = null;
|
|
4804
5593
|
let strippedOrphanEntries = null;
|
|
4805
5594
|
let orphanPushCountSnapshot = 0;
|
|
4806
|
-
if (
|
|
5595
|
+
if (goalTurn?.origin === "runtime") {
|
|
5596
|
+
this.config.getChatRecordingService()?.recordGoalRuntimeMessage(
|
|
5597
|
+
modelPromptBlocks.filter((block) => block.type === "text").map((block) => ({ text: block.text })),
|
|
5598
|
+
goalTurn.permit
|
|
5599
|
+
);
|
|
5600
|
+
} else if (isContinue) {
|
|
4807
5601
|
const recoveryPlan = buildSessionRecoveryPlanFromApiHistory({
|
|
4808
5602
|
sessionId: this.sessionId,
|
|
4809
5603
|
apiHistory: this.#getCurrentChat().getHistory()
|
|
@@ -4829,11 +5623,22 @@ var Session = class {
|
|
|
4829
5623
|
continuationParts = recoveryPlan.continuation.parts;
|
|
4830
5624
|
}
|
|
4831
5625
|
}
|
|
4832
|
-
if (
|
|
5626
|
+
if (goalTurn?.origin === "runtime") {
|
|
5627
|
+
} else if (isContinue) {
|
|
4833
5628
|
} else if (isRetry) {
|
|
4834
5629
|
this.#getCurrentChat().stripOrphanedUserEntriesFromHistory();
|
|
4835
5630
|
} else {
|
|
4836
|
-
this.config.getChatRecordingService()
|
|
5631
|
+
const recorder = this.config.getChatRecordingService();
|
|
5632
|
+
if (promptDisplayText !== void 0) {
|
|
5633
|
+
recorder?.recordUserMessage(promptText, goalTurn?.permit, {
|
|
5634
|
+
displayText: promptDisplayText,
|
|
5635
|
+
hookContext: ""
|
|
5636
|
+
});
|
|
5637
|
+
} else if (goalTurn) {
|
|
5638
|
+
recorder?.recordUserMessage(promptText, goalTurn.permit);
|
|
5639
|
+
} else {
|
|
5640
|
+
recorder?.recordUserMessage(promptText);
|
|
5641
|
+
}
|
|
4837
5642
|
}
|
|
4838
5643
|
const firstTextBlock = modelPromptBlocks.find(
|
|
4839
5644
|
(block) => block.type === "text"
|
|
@@ -4862,7 +5667,13 @@ var Session = class {
|
|
|
4862
5667
|
inputText,
|
|
4863
5668
|
pendingSend,
|
|
4864
5669
|
this.config,
|
|
4865
|
-
this.settings
|
|
5670
|
+
this.settings,
|
|
5671
|
+
{
|
|
5672
|
+
// `/clear` swaps in a new Goal runtime under this
|
|
5673
|
+
// long-lived Session; without this the goal-state
|
|
5674
|
+
// subscription stays on the disposed instance.
|
|
5675
|
+
startNewSession: /* @__PURE__ */ __name(() => this.rebindGoalRuntimeForNewSession(), "startNewSession")
|
|
5676
|
+
}
|
|
4866
5677
|
);
|
|
4867
5678
|
parts = await this.#processSlashCommandResult(
|
|
4868
5679
|
slashCommandResult,
|
|
@@ -4882,7 +5693,8 @@ var Session = class {
|
|
|
4882
5693
|
}
|
|
4883
5694
|
const hooksEnabled = !this.config.getDisableAllHooks?.();
|
|
4884
5695
|
const messageBus = this.config.getMessageBus?.();
|
|
4885
|
-
|
|
5696
|
+
const isRuntimeContinuation = goalTurn?.origin === "runtime";
|
|
5697
|
+
if (!isContinue && !isRuntimeContinuation && hooksEnabled && messageBus && this.config.hasHooksForEvent?.("UserPromptSubmit")) {
|
|
4886
5698
|
const response = await messageBus.request(
|
|
4887
5699
|
{
|
|
4888
5700
|
type: "hook-execution-request" /* HOOK_EXECUTION_REQUEST */,
|
|
@@ -4975,7 +5787,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
4975
5787
|
let nextMessage = { role: "user", parts };
|
|
4976
5788
|
let turnCount = 0;
|
|
4977
5789
|
const toolLoopState = createDaemonToolLoopState(
|
|
4978
|
-
|
|
5790
|
+
channelTurn ? "off" : this.repeatedToolFailureGuardMode
|
|
4979
5791
|
);
|
|
4980
5792
|
try {
|
|
4981
5793
|
while (nextMessage !== null) {
|
|
@@ -4995,7 +5807,9 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
4995
5807
|
pendingSend.signal
|
|
4996
5808
|
);
|
|
4997
5809
|
let channelDeliveryResponseBlock;
|
|
5810
|
+
let channelDeliveryCheckpoint = 0;
|
|
4998
5811
|
try {
|
|
5812
|
+
if (goalTurn) goalTurn.modelStarted = true;
|
|
4999
5813
|
const sendResult = await this.#sendMessageStreamWithAutoCompression(
|
|
5000
5814
|
promptId,
|
|
5001
5815
|
nextMessage?.parts ?? [],
|
|
@@ -5012,8 +5826,8 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5012
5826
|
}
|
|
5013
5827
|
const responseStream = sendResult.responseStream;
|
|
5014
5828
|
nextMessage = null;
|
|
5015
|
-
channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(
|
|
5016
|
-
|
|
5829
|
+
channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(responseCapture);
|
|
5830
|
+
channelDeliveryCheckpoint = channelDeliveryResponseBlock?.length ?? 0;
|
|
5017
5831
|
let streamFailed = false;
|
|
5018
5832
|
try {
|
|
5019
5833
|
for await (const resp of responseStream) {
|
|
@@ -5033,10 +5847,14 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5033
5847
|
part.thought
|
|
5034
5848
|
);
|
|
5035
5849
|
if (!part.thought) {
|
|
5850
|
+
responseCapture.agentOutput.appendText(part.text);
|
|
5036
5851
|
channelDeliveryResponseBlock?.push(part.text);
|
|
5037
5852
|
messageDisplay?.addChunk(part.text);
|
|
5038
5853
|
}
|
|
5039
5854
|
}
|
|
5855
|
+
responseCapture.agentOutput.observeFinishReason(
|
|
5856
|
+
candidate.finishReason
|
|
5857
|
+
);
|
|
5040
5858
|
}
|
|
5041
5859
|
if (resp.type === "chunk" /* CHUNK */ && resp.value.usageMetadata) {
|
|
5042
5860
|
usageMetadata = resp.value.usageMetadata;
|
|
@@ -5049,6 +5867,9 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5049
5867
|
}
|
|
5050
5868
|
}
|
|
5051
5869
|
if (resp.type === "retry" /* RETRY */ || resp.type === "model_fallback" /* MODEL_FALLBACK */) {
|
|
5870
|
+
responseCapture.agentOutput.restartAttempt(
|
|
5871
|
+
resp.type === "retry" /* RETRY */ && resp.isContinuation === true
|
|
5872
|
+
);
|
|
5052
5873
|
if (resp.type === "model_fallback" /* MODEL_FALLBACK */ || !resp.isContinuation) {
|
|
5053
5874
|
if (channelDeliveryResponseBlock) {
|
|
5054
5875
|
channelDeliveryResponseBlock.length = channelDeliveryCheckpoint;
|
|
@@ -5109,7 +5930,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5109
5930
|
await messageDisplay?.finish();
|
|
5110
5931
|
}
|
|
5111
5932
|
commitChannelDeliveryResponseBlock(
|
|
5112
|
-
|
|
5933
|
+
responseCapture,
|
|
5113
5934
|
channelDeliveryResponseBlock,
|
|
5114
5935
|
functionCalls.length > 0
|
|
5115
5936
|
);
|
|
@@ -5153,14 +5974,16 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5153
5974
|
pendingSend.signal,
|
|
5154
5975
|
promptId,
|
|
5155
5976
|
toolLoopState,
|
|
5156
|
-
onFullTurnModel
|
|
5977
|
+
onFullTurnModel,
|
|
5978
|
+
rejectOnLoopDetected
|
|
5157
5979
|
);
|
|
5158
5980
|
nextMessage = nextAfterTools.message;
|
|
5159
5981
|
if (nextAfterTools.stoppedByRepeatedToolFailure) {
|
|
5160
5982
|
return {
|
|
5161
|
-
stopReason:
|
|
5162
|
-
pendingSend.signal
|
|
5163
|
-
|
|
5983
|
+
stopReason: rejectOnLoopDetected ? cancelledOrThrowLoopDetected(
|
|
5984
|
+
pendingSend.signal,
|
|
5985
|
+
toolLoopState
|
|
5986
|
+
) : getAbortAwareEndTurnStopReason(pendingSend.signal)
|
|
5164
5987
|
};
|
|
5165
5988
|
}
|
|
5166
5989
|
if (toolRun.loopDetected) {
|
|
@@ -5170,9 +5993,10 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5170
5993
|
pendingSend.signal
|
|
5171
5994
|
);
|
|
5172
5995
|
return {
|
|
5173
|
-
stopReason:
|
|
5174
|
-
pendingSend.signal
|
|
5175
|
-
|
|
5996
|
+
stopReason: rejectOnLoopDetected ? cancelledOrThrowLoopDetected(
|
|
5997
|
+
pendingSend.signal,
|
|
5998
|
+
toolLoopState
|
|
5999
|
+
) : getAbortAwareEndTurnStopReason(pendingSend.signal)
|
|
5176
6000
|
};
|
|
5177
6001
|
}
|
|
5178
6002
|
}
|
|
@@ -5180,15 +6004,22 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5180
6004
|
if (this.messageRewriter) {
|
|
5181
6005
|
await this.messageRewriter.waitForPendingRewrites();
|
|
5182
6006
|
}
|
|
5183
|
-
|
|
6007
|
+
const result = await this.#handleStopHookLoop(
|
|
5184
6008
|
pendingSend,
|
|
5185
6009
|
promptId,
|
|
5186
6010
|
hooksEnabled,
|
|
5187
6011
|
messageBus,
|
|
5188
6012
|
true,
|
|
5189
6013
|
fullTurnModelOverride,
|
|
5190
|
-
|
|
6014
|
+
responseCapture,
|
|
6015
|
+
rejectOnLoopDetected
|
|
5191
6016
|
);
|
|
6017
|
+
if (result.stopReason !== "cancelled") {
|
|
6018
|
+
responseCapture.agentOutput.writeToSpan(
|
|
6019
|
+
getActiveInteractionSpan()
|
|
6020
|
+
);
|
|
6021
|
+
}
|
|
6022
|
+
return result;
|
|
5192
6023
|
} finally {
|
|
5193
6024
|
logConversationFinishedEvent(
|
|
5194
6025
|
this.config,
|
|
@@ -5209,7 +6040,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5209
6040
|
}
|
|
5210
6041
|
);
|
|
5211
6042
|
}
|
|
5212
|
-
async #handleStopHookLoop(pendingSend, promptId, hooksEnabled, messageBus, allowExternalHooks = true, modelOverride,
|
|
6043
|
+
async #handleStopHookLoop(pendingSend, promptId, hooksEnabled, messageBus, allowExternalHooks = true, modelOverride, responseCapture, rejectOnLoopDetected = false) {
|
|
5213
6044
|
const stopHookBlockingCap = this.config.getStopHookBlockingCap();
|
|
5214
6045
|
let stopHookIterationCount = 0;
|
|
5215
6046
|
let stopHookReasons = [];
|
|
@@ -5269,7 +6100,8 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5269
6100
|
{
|
|
5270
6101
|
onFullTurnModel,
|
|
5271
6102
|
getModelOverride: /* @__PURE__ */ __name(() => modelOverride, "getModelOverride"),
|
|
5272
|
-
|
|
6103
|
+
responseCapture,
|
|
6104
|
+
rejectOnLoopDetected
|
|
5273
6105
|
}
|
|
5274
6106
|
);
|
|
5275
6107
|
if (continuation2.kind === "terminal") {
|
|
@@ -5353,7 +6185,8 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5353
6185
|
{
|
|
5354
6186
|
onFullTurnModel,
|
|
5355
6187
|
getModelOverride: /* @__PURE__ */ __name(() => modelOverride, "getModelOverride"),
|
|
5356
|
-
|
|
6188
|
+
responseCapture,
|
|
6189
|
+
rejectOnLoopDetected
|
|
5357
6190
|
}
|
|
5358
6191
|
);
|
|
5359
6192
|
if (continuation2.kind === "terminal") {
|
|
@@ -5404,11 +6237,13 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5404
6237
|
"Stop",
|
|
5405
6238
|
stopHookBlockingCap
|
|
5406
6239
|
);
|
|
5407
|
-
abortGoalForStopHookCap(
|
|
6240
|
+
if (!abortGoalForStopHookCap(
|
|
5408
6241
|
this.config,
|
|
5409
6242
|
this.config.getSessionId(),
|
|
5410
6243
|
warning
|
|
5411
|
-
)
|
|
6244
|
+
)) {
|
|
6245
|
+
await this.#pauseGoalForStopHookCap();
|
|
6246
|
+
}
|
|
5412
6247
|
this.todoStopGuard.suspend();
|
|
5413
6248
|
await this.messageEmitter.emitAgentMessage(warning);
|
|
5414
6249
|
debugLogger6.warn(warning);
|
|
@@ -5450,7 +6285,8 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5450
6285
|
} : {},
|
|
5451
6286
|
onFullTurnModel,
|
|
5452
6287
|
getModelOverride: /* @__PURE__ */ __name(() => modelOverride, "getModelOverride"),
|
|
5453
|
-
|
|
6288
|
+
responseCapture,
|
|
6289
|
+
rejectOnLoopDetected
|
|
5454
6290
|
}
|
|
5455
6291
|
);
|
|
5456
6292
|
if (continuation.supersededAutomaticContinuation && externalReason) {
|
|
@@ -5517,6 +6353,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5517
6353
|
pendingSend.signal
|
|
5518
6354
|
);
|
|
5519
6355
|
let channelDeliveryResponseBlock;
|
|
6356
|
+
let channelDeliveryCheckpoint = 0;
|
|
5520
6357
|
let providerSendChat;
|
|
5521
6358
|
let userContentPushCountBeforeSend = 0;
|
|
5522
6359
|
try {
|
|
@@ -5747,9 +6584,9 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5747
6584
|
const responseStream = sendResult.responseStream;
|
|
5748
6585
|
nextMessage = null;
|
|
5749
6586
|
channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(
|
|
5750
|
-
options.
|
|
6587
|
+
options.responseCapture
|
|
5751
6588
|
);
|
|
5752
|
-
|
|
6589
|
+
channelDeliveryCheckpoint = channelDeliveryResponseBlock?.length ?? 0;
|
|
5753
6590
|
initialSend = false;
|
|
5754
6591
|
if (guardForThisSend) {
|
|
5755
6592
|
const guardCommitted = this.todoStopGuard.commitContinuation(
|
|
@@ -5781,10 +6618,14 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5781
6618
|
part.thought
|
|
5782
6619
|
);
|
|
5783
6620
|
if (!part.thought) {
|
|
6621
|
+
options.responseCapture?.agentOutput.appendText(part.text);
|
|
5784
6622
|
channelDeliveryResponseBlock?.push(part.text);
|
|
5785
6623
|
messageDisplay?.addChunk(part.text);
|
|
5786
6624
|
}
|
|
5787
6625
|
}
|
|
6626
|
+
options.responseCapture?.agentOutput.observeFinishReason(
|
|
6627
|
+
candidate.finishReason
|
|
6628
|
+
);
|
|
5788
6629
|
}
|
|
5789
6630
|
if (response.type === "chunk" /* CHUNK */ && response.value.usageMetadata) {
|
|
5790
6631
|
usageMetadata = response.value.usageMetadata;
|
|
@@ -5797,6 +6638,9 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5797
6638
|
}
|
|
5798
6639
|
}
|
|
5799
6640
|
if (response.type === "retry" /* RETRY */ || response.type === "model_fallback" /* MODEL_FALLBACK */) {
|
|
6641
|
+
options.responseCapture?.agentOutput.restartAttempt(
|
|
6642
|
+
response.type === "retry" /* RETRY */ && response.isContinuation === true
|
|
6643
|
+
);
|
|
5800
6644
|
if (response.type === "model_fallback" /* MODEL_FALLBACK */ || !response.isContinuation) {
|
|
5801
6645
|
if (channelDeliveryResponseBlock) {
|
|
5802
6646
|
channelDeliveryResponseBlock.length = channelDeliveryCheckpoint;
|
|
@@ -5859,7 +6703,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5859
6703
|
}
|
|
5860
6704
|
}
|
|
5861
6705
|
commitChannelDeliveryResponseBlock(
|
|
5862
|
-
options.
|
|
6706
|
+
options.responseCapture,
|
|
5863
6707
|
channelDeliveryResponseBlock,
|
|
5864
6708
|
functionCalls.length > 0
|
|
5865
6709
|
);
|
|
@@ -5883,7 +6727,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5883
6727
|
options.onFullTurnModel
|
|
5884
6728
|
)
|
|
5885
6729
|
);
|
|
5886
|
-
if (toolRun.stopAfterPermissionCancel ||
|
|
6730
|
+
if (toolRun.stopAfterPermissionCancel || pendingSend.signal.aborted) {
|
|
5887
6731
|
this.todoStopGuard.suspend();
|
|
5888
6732
|
await this.#preserveStoppedToolRun(toolRun, pendingSend.signal);
|
|
5889
6733
|
return {
|
|
@@ -5892,12 +6736,25 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
5892
6736
|
...supersededAutomaticContinuation ? { supersededAutomaticContinuation: true } : {}
|
|
5893
6737
|
};
|
|
5894
6738
|
}
|
|
6739
|
+
if (toolRun.loopDetected) {
|
|
6740
|
+
this.todoStopGuard.suspend();
|
|
6741
|
+
await this.#preserveStoppedToolRun(toolRun, pendingSend.signal);
|
|
6742
|
+
return {
|
|
6743
|
+
kind: "terminal",
|
|
6744
|
+
// Only the foreground chain rejects a loop-detected stop; cron
|
|
6745
|
+
// and background-notification turns keep the graceful end-turn
|
|
6746
|
+
// handling they had before loop stops became rejections.
|
|
6747
|
+
stopReason: options.rejectOnLoopDetected ? cancelledOrThrowLoopDetected(pendingSend.signal, toolLoopState) : getAbortAwareEndTurnStopReason(pendingSend.signal),
|
|
6748
|
+
...supersededAutomaticContinuation ? { supersededAutomaticContinuation: true } : {}
|
|
6749
|
+
};
|
|
6750
|
+
}
|
|
5895
6751
|
const nextAfterTools = await this.#buildNextMessageAfterToolRun(
|
|
5896
6752
|
toolRun,
|
|
5897
6753
|
pendingSend.signal,
|
|
5898
6754
|
toolPromptId,
|
|
5899
6755
|
toolLoopState,
|
|
5900
|
-
options.onFullTurnModel
|
|
6756
|
+
options.onFullTurnModel,
|
|
6757
|
+
options.rejectOnLoopDetected ?? false
|
|
5901
6758
|
);
|
|
5902
6759
|
nextMessage = nextAfterTools.message;
|
|
5903
6760
|
if (nextAfterTools.hadMidTurnUserInput) {
|
|
@@ -6149,16 +7006,16 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
6149
7006
|
);
|
|
6150
7007
|
return { responseStream: null, stopReason: "cancelled" };
|
|
6151
7008
|
}
|
|
6152
|
-
const
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
);
|
|
7009
|
+
const chat = this.#getCurrentChat();
|
|
7010
|
+
const model = options.getModelOverride?.() ?? options.modelOverride ?? this.config.getModel();
|
|
7011
|
+
const request = {
|
|
7012
|
+
message,
|
|
7013
|
+
config: {
|
|
7014
|
+
abortSignal
|
|
7015
|
+
}
|
|
7016
|
+
};
|
|
7017
|
+
const goalPermit = goalTurnContext.getStore();
|
|
7018
|
+
const responseStream = goalPermit ? await chat.sendMessageStream(model, request, promptId, goalPermit) : await chat.sendMessageStream(model, request, promptId);
|
|
6162
7019
|
return { responseStream };
|
|
6163
7020
|
}
|
|
6164
7021
|
#preserveUnsentMessageHistory(message, preserveFullMessage) {
|
|
@@ -6202,7 +7059,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
6202
7059
|
);
|
|
6203
7060
|
await this.messageRewriter?.waitForPendingRewrites();
|
|
6204
7061
|
}
|
|
6205
|
-
async #buildNextMessageAfterToolRun(toolRun, abortSignal, promptId, toolLoopState, onFullTurnModel) {
|
|
7062
|
+
async #buildNextMessageAfterToolRun(toolRun, abortSignal, promptId, toolLoopState, onFullTurnModel, rejectOnLoopDetected = false) {
|
|
6206
7063
|
if (toolRun.loopDetected) {
|
|
6207
7064
|
debugLogger6.debug("Stopping ACP turn after daemon loop detection.");
|
|
6208
7065
|
return { message: null, hadMidTurnUserInput: false };
|
|
@@ -6292,14 +7149,16 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
6292
7149
|
toolLoopState,
|
|
6293
7150
|
{ recordToQwenLogger: false }
|
|
6294
7151
|
);
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
7152
|
+
if (!rejectOnLoopDetected) {
|
|
7153
|
+
try {
|
|
7154
|
+
await this.messageEmitter.emitAgentMessage(
|
|
7155
|
+
REPEATED_TOOL_FAILURE_STOP_MESSAGE
|
|
7156
|
+
);
|
|
7157
|
+
} catch (error) {
|
|
7158
|
+
debugLogger6.warn(
|
|
7159
|
+
`Failed to emit repeated tool failure stop message: ${this.#formatError(error)}`
|
|
7160
|
+
);
|
|
7161
|
+
}
|
|
6303
7162
|
}
|
|
6304
7163
|
return {
|
|
6305
7164
|
message: null,
|
|
@@ -6638,6 +7497,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
6638
7497
|
if (this.closing) return;
|
|
6639
7498
|
if (this.cronProcessing) return;
|
|
6640
7499
|
if (this.pendingPrompt) return;
|
|
7500
|
+
if (this.goalProcessing) return;
|
|
6641
7501
|
if (this.notificationProcessing) return;
|
|
6642
7502
|
if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
|
|
6643
7503
|
if (this.#nextCronQueueIndex() < 0) return;
|
|
@@ -6649,7 +7509,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
6649
7509
|
);
|
|
6650
7510
|
return;
|
|
6651
7511
|
}
|
|
6652
|
-
if (this.disposed || this.closing || this.cronProcessing || this.pendingPrompt || this.notificationProcessing || this.#nextCronQueueIndex() < 0) {
|
|
7512
|
+
if (this.disposed || this.closing || this.cronProcessing || this.pendingPrompt || this.goalProcessing || this.notificationProcessing || this.#nextCronQueueIndex() < 0) {
|
|
6653
7513
|
return;
|
|
6654
7514
|
}
|
|
6655
7515
|
if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
|
|
@@ -6670,6 +7530,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
6670
7530
|
this.cronProcessing = false;
|
|
6671
7531
|
resolveCompletion();
|
|
6672
7532
|
this.cronCompletion = null;
|
|
7533
|
+
void this.#drainGoalQueue();
|
|
6673
7534
|
void this.#drainNotificationQueue();
|
|
6674
7535
|
if (this.config.isCronEnabled()) {
|
|
6675
7536
|
const scheduler = this.config.getCronScheduler();
|
|
@@ -6734,7 +7595,10 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
6734
7595
|
const promptId = this.config.getSessionId() + "########cron" + Date.now();
|
|
6735
7596
|
let cronHadError = false;
|
|
6736
7597
|
let cronCompleted = false;
|
|
6737
|
-
const
|
|
7598
|
+
const responseCapture = {
|
|
7599
|
+
...item.delivery ? { channelDelivery: { finalText: "" } } : {},
|
|
7600
|
+
agentOutput: new AgentOutputMessageCapture(this.config)
|
|
7601
|
+
};
|
|
6738
7602
|
await withInteractionSpan(
|
|
6739
7603
|
this.config,
|
|
6740
7604
|
{
|
|
@@ -6847,7 +7711,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
6847
7711
|
return;
|
|
6848
7712
|
}
|
|
6849
7713
|
const responseStream = sendResult.responseStream;
|
|
6850
|
-
const channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(
|
|
7714
|
+
const channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(responseCapture);
|
|
6851
7715
|
const channelDeliveryCheckpoint = channelDeliveryResponseBlock?.length ?? 0;
|
|
6852
7716
|
if (loopTick && turnCount === 1) {
|
|
6853
7717
|
this.loopTickResolver?.markDelivered();
|
|
@@ -6873,10 +7737,14 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
6873
7737
|
part.thought
|
|
6874
7738
|
);
|
|
6875
7739
|
if (!part.thought) {
|
|
7740
|
+
responseCapture.agentOutput.appendText(part.text);
|
|
6876
7741
|
channelDeliveryResponseBlock?.push(part.text);
|
|
6877
7742
|
messageDisplay?.addChunk(part.text);
|
|
6878
7743
|
}
|
|
6879
7744
|
}
|
|
7745
|
+
responseCapture.agentOutput.observeFinishReason(
|
|
7746
|
+
candidate.finishReason
|
|
7747
|
+
);
|
|
6880
7748
|
}
|
|
6881
7749
|
if (resp.type === "chunk" /* CHUNK */ && resp.value.usageMetadata) {
|
|
6882
7750
|
usageMetadata = resp.value.usageMetadata;
|
|
@@ -6889,6 +7757,9 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
6889
7757
|
}
|
|
6890
7758
|
}
|
|
6891
7759
|
if (resp.type === "retry" /* RETRY */ || resp.type === "model_fallback" /* MODEL_FALLBACK */) {
|
|
7760
|
+
responseCapture.agentOutput.restartAttempt(
|
|
7761
|
+
resp.type === "retry" /* RETRY */ && resp.isContinuation === true
|
|
7762
|
+
);
|
|
6892
7763
|
if (resp.type === "model_fallback" /* MODEL_FALLBACK */ || !resp.isContinuation) {
|
|
6893
7764
|
if (channelDeliveryResponseBlock) {
|
|
6894
7765
|
channelDeliveryResponseBlock.length = channelDeliveryCheckpoint;
|
|
@@ -6917,7 +7788,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
6917
7788
|
}
|
|
6918
7789
|
}
|
|
6919
7790
|
commitChannelDeliveryResponseBlock(
|
|
6920
|
-
|
|
7791
|
+
responseCapture,
|
|
6921
7792
|
channelDeliveryResponseBlock,
|
|
6922
7793
|
functionCalls.length > 0
|
|
6923
7794
|
);
|
|
@@ -6968,7 +7839,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
6968
7839
|
void 0,
|
|
6969
7840
|
false,
|
|
6970
7841
|
void 0,
|
|
6971
|
-
|
|
7842
|
+
responseCapture
|
|
6972
7843
|
);
|
|
6973
7844
|
stopReason = guardStop.stopReason;
|
|
6974
7845
|
if (guardStop.stopReason === "max_tokens") {
|
|
@@ -7001,6 +7872,11 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7001
7872
|
)
|
|
7002
7873
|
);
|
|
7003
7874
|
}
|
|
7875
|
+
if (!ac.signal.aborted && !cronHadError) {
|
|
7876
|
+
responseCapture.agentOutput.writeToSpan(
|
|
7877
|
+
getActiveInteractionSpan()
|
|
7878
|
+
);
|
|
7879
|
+
}
|
|
7004
7880
|
},
|
|
7005
7881
|
() => ac.signal.aborted ? "cancelled" : cronHadError ? "error" : "ok"
|
|
7006
7882
|
);
|
|
@@ -7011,7 +7887,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7011
7887
|
source: "scheduled",
|
|
7012
7888
|
target: item.delivery.target,
|
|
7013
7889
|
text: normalizeChannelDeliveryText(
|
|
7014
|
-
|
|
7890
|
+
responseCapture.channelDelivery?.finalText ?? ""
|
|
7015
7891
|
),
|
|
7016
7892
|
taskId: item.taskId,
|
|
7017
7893
|
firedAt: item.firedAt
|
|
@@ -7039,6 +7915,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7039
7915
|
backgroundRegistry.setStatusChangeCallback(this.#statusChangeCallback);
|
|
7040
7916
|
backgroundRegistry.setNotificationCallback(
|
|
7041
7917
|
(displayText, modelText, meta) => {
|
|
7918
|
+
const entry = backgroundRegistry.get(meta.agentId);
|
|
7042
7919
|
this.#enqueueBackgroundNotification({
|
|
7043
7920
|
displayText,
|
|
7044
7921
|
modelText,
|
|
@@ -7047,7 +7924,12 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7047
7924
|
kind: "agent",
|
|
7048
7925
|
continuesTodoStopGuardWorkChain: this.#agentContinuesTodoStopGuardWorkChain(meta.agentId),
|
|
7049
7926
|
toolUseId: meta.toolUseId,
|
|
7050
|
-
todoWorkChainId: meta.todoWorkChainId
|
|
7927
|
+
todoWorkChainId: meta.todoWorkChainId,
|
|
7928
|
+
structured: entry ? {
|
|
7929
|
+
description: truncateNotificationLabel(
|
|
7930
|
+
buildBackgroundEntryLabel(entry)
|
|
7931
|
+
)
|
|
7932
|
+
} : void 0
|
|
7051
7933
|
});
|
|
7052
7934
|
}
|
|
7053
7935
|
);
|
|
@@ -7056,6 +7938,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7056
7938
|
if (meta.status === "running") {
|
|
7057
7939
|
return;
|
|
7058
7940
|
}
|
|
7941
|
+
const entry = monitorRegistry.get(meta.monitorId);
|
|
7059
7942
|
this.#enqueueBackgroundNotification({
|
|
7060
7943
|
displayText,
|
|
7061
7944
|
modelText,
|
|
@@ -7067,11 +7950,21 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7067
7950
|
meta.ownerAgentId
|
|
7068
7951
|
),
|
|
7069
7952
|
toolUseId: meta.toolUseId,
|
|
7070
|
-
todoWorkChainId: meta.todoWorkChainId
|
|
7953
|
+
todoWorkChainId: meta.todoWorkChainId,
|
|
7954
|
+
structured: entry ? {
|
|
7955
|
+
description: truncateNotificationLabel(entry.description),
|
|
7956
|
+
eventCount: meta.eventCount,
|
|
7957
|
+
droppedLines: entry.droppedLines || void 0
|
|
7958
|
+
} : void 0
|
|
7071
7959
|
});
|
|
7072
7960
|
});
|
|
7073
7961
|
const shellRegistry = this.config.getBackgroundShellRegistry();
|
|
7962
|
+
this.#shellStatusChangeCallback = () => {
|
|
7963
|
+
this.#activeWorkChanged();
|
|
7964
|
+
};
|
|
7965
|
+
shellRegistry.setStatusChangeCallback(this.#shellStatusChangeCallback);
|
|
7074
7966
|
shellRegistry.setNotificationCallback((displayText, modelText, meta) => {
|
|
7967
|
+
const entry = shellRegistry.get(meta.shellId);
|
|
7075
7968
|
this.#enqueueBackgroundNotification({
|
|
7076
7969
|
displayText,
|
|
7077
7970
|
modelText,
|
|
@@ -7079,7 +7972,8 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7079
7972
|
status: meta.status,
|
|
7080
7973
|
kind: "shell",
|
|
7081
7974
|
continuesTodoStopGuardWorkChain: !this.todoStopGuardBackgroundBaseline.shells.has(meta.shellId),
|
|
7082
|
-
todoWorkChainId: meta.todoWorkChainId
|
|
7975
|
+
todoWorkChainId: meta.todoWorkChainId,
|
|
7976
|
+
structured: entry ? { commandLabel: truncateNotificationLabel(entry.description) } : void 0
|
|
7083
7977
|
});
|
|
7084
7978
|
});
|
|
7085
7979
|
this.config.getChatRecordingService()?.setTitleRecordedCallback((customTitle, titleSource, sessionId) => {
|
|
@@ -7170,7 +8064,8 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7170
8064
|
taskId: item.taskId,
|
|
7171
8065
|
status: item.status,
|
|
7172
8066
|
kind: item.kind,
|
|
7173
|
-
toolUseId: item.toolUseId
|
|
8067
|
+
toolUseId: item.toolUseId,
|
|
8068
|
+
...item.structured
|
|
7174
8069
|
}
|
|
7175
8070
|
);
|
|
7176
8071
|
} catch (error) {
|
|
@@ -7193,7 +8088,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7193
8088
|
if (this.disposed) return;
|
|
7194
8089
|
if (this.closing) return;
|
|
7195
8090
|
if (this.notificationProcessing) return;
|
|
7196
|
-
if (this.pendingPrompt || this.cronProcessing || this.cronAbortController) {
|
|
8091
|
+
if (this.pendingPrompt || this.goalProcessing || this.cronProcessing || this.cronAbortController) {
|
|
7197
8092
|
return;
|
|
7198
8093
|
}
|
|
7199
8094
|
if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
|
|
@@ -7207,7 +8102,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7207
8102
|
);
|
|
7208
8103
|
return;
|
|
7209
8104
|
}
|
|
7210
|
-
if (this.disposed || this.closing || this.notificationProcessing || this.pendingPrompt || this.cronProcessing || this.cronAbortController || this.#nextNotificationQueueIndex() < 0) {
|
|
8105
|
+
if (this.disposed || this.closing || this.notificationProcessing || this.pendingPrompt || this.goalProcessing || this.cronProcessing || this.cronAbortController || this.#nextNotificationQueueIndex() < 0) {
|
|
7211
8106
|
return;
|
|
7212
8107
|
}
|
|
7213
8108
|
if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
|
|
@@ -7218,7 +8113,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7218
8113
|
});
|
|
7219
8114
|
try {
|
|
7220
8115
|
while (this.notificationQueue.length > 0) {
|
|
7221
|
-
if (this.pendingPrompt || this.cronProcessing || this.cronAbortController) {
|
|
8116
|
+
if (this.pendingPrompt || this.goalProcessing || this.cronProcessing || this.cronAbortController) {
|
|
7222
8117
|
break;
|
|
7223
8118
|
}
|
|
7224
8119
|
const nextIndex = this.#nextNotificationQueueIndex();
|
|
@@ -7226,6 +8121,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7226
8121
|
const [item] = this.notificationQueue.splice(nextIndex, 1);
|
|
7227
8122
|
if (!item) break;
|
|
7228
8123
|
this.currentAgentNotificationTaskId = item.kind === "agent" ? item.taskId : null;
|
|
8124
|
+
this.currentShellNotificationActive = item.kind === "shell";
|
|
7229
8125
|
this.#activeWorkChanged();
|
|
7230
8126
|
try {
|
|
7231
8127
|
await runWithInvocationContext(
|
|
@@ -7237,6 +8133,7 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7237
8133
|
);
|
|
7238
8134
|
} finally {
|
|
7239
8135
|
this.currentAgentNotificationTaskId = null;
|
|
8136
|
+
this.currentShellNotificationActive = false;
|
|
7240
8137
|
this.#activeWorkChanged();
|
|
7241
8138
|
}
|
|
7242
8139
|
}
|
|
@@ -7245,8 +8142,9 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7245
8142
|
resolveCompletion();
|
|
7246
8143
|
this.notificationCompletion = null;
|
|
7247
8144
|
this.#activeWorkChanged();
|
|
8145
|
+
void this.#drainGoalQueue();
|
|
7248
8146
|
void this.#drainCronQueue();
|
|
7249
|
-
if (this.notificationQueue.length > 0 && !this.pendingPrompt && !this.cronProcessing && !this.cronAbortController) {
|
|
8147
|
+
if (this.notificationQueue.length > 0 && !this.pendingPrompt && !this.goalProcessing && !this.cronProcessing && !this.cronAbortController) {
|
|
7250
8148
|
void this.#drainNotificationQueue();
|
|
7251
8149
|
}
|
|
7252
8150
|
}
|
|
@@ -7283,7 +8181,8 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7283
8181
|
taskId: item.taskId,
|
|
7284
8182
|
status: item.status,
|
|
7285
8183
|
kind: item.kind,
|
|
7286
|
-
toolUseId: item.toolUseId
|
|
8184
|
+
toolUseId: item.toolUseId,
|
|
8185
|
+
...item.structured
|
|
7287
8186
|
});
|
|
7288
8187
|
}
|
|
7289
8188
|
const notificationReminders = await this.#buildInitialSystemReminders();
|
|
@@ -7499,7 +8398,8 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
7499
8398
|
taskId: item.taskId,
|
|
7500
8399
|
status: item.status,
|
|
7501
8400
|
kind: item.kind,
|
|
7502
|
-
toolUseId: item.toolUseId
|
|
8401
|
+
toolUseId: item.toolUseId,
|
|
8402
|
+
...item.structured
|
|
7503
8403
|
}
|
|
7504
8404
|
}
|
|
7505
8405
|
});
|
|
@@ -9249,6 +10149,13 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
9249
10149
|
toolName: policyToolName,
|
|
9250
10150
|
args: invocation.params,
|
|
9251
10151
|
signal: activeToolAbortSignal,
|
|
10152
|
+
// Same identity and execution scope `CoreToolScheduler`
|
|
10153
|
+
// supplies. This is the path daemon ACP sessions actually
|
|
10154
|
+
// take, so without them a host policy that falls back to the
|
|
10155
|
+
// session — or reasons about where the tool runs — sees
|
|
10156
|
+
// neither on every call made here.
|
|
10157
|
+
sessionId: this.config.getSessionId(),
|
|
10158
|
+
cwd: this.config.getTargetDir(),
|
|
9252
10159
|
...invocationContext ? { invocationContext } : {}
|
|
9253
10160
|
}
|
|
9254
10161
|
);
|
|
@@ -9721,30 +10628,6 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
9721
10628
|
}
|
|
9722
10629
|
}
|
|
9723
10630
|
}
|
|
9724
|
-
#emitGoalStatusItems(result) {
|
|
9725
|
-
if (!("outputHistoryItems" in result)) {
|
|
9726
|
-
return;
|
|
9727
|
-
}
|
|
9728
|
-
let hasActiveGoalStatus = false;
|
|
9729
|
-
for (const item of result.outputHistoryItems ?? []) {
|
|
9730
|
-
if (item.type === "goal_status" /* GOAL_STATUS */) {
|
|
9731
|
-
this.emitGoalStatus({
|
|
9732
|
-
kind: item.kind,
|
|
9733
|
-
condition: item.condition,
|
|
9734
|
-
...item.iterations !== void 0 ? { iterations: item.iterations } : {},
|
|
9735
|
-
...item.setAt !== void 0 ? { setAt: item.setAt } : {},
|
|
9736
|
-
...item.durationMs !== void 0 ? { durationMs: item.durationMs } : {},
|
|
9737
|
-
...item.lastReason !== void 0 ? { lastReason: item.lastReason } : {}
|
|
9738
|
-
});
|
|
9739
|
-
if (!isTerminalGoalStatusKind(item.kind)) {
|
|
9740
|
-
hasActiveGoalStatus = true;
|
|
9741
|
-
}
|
|
9742
|
-
}
|
|
9743
|
-
}
|
|
9744
|
-
if (hasActiveGoalStatus) {
|
|
9745
|
-
this.installGoalTerminalObserver();
|
|
9746
|
-
}
|
|
9747
|
-
}
|
|
9748
10631
|
/**
|
|
9749
10632
|
* Processes the result of a slash command execution.
|
|
9750
10633
|
*
|
|
@@ -9762,7 +10645,6 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
9762
10645
|
* @returns Parts to use for the prompt, or null if command was handled without needing model interaction
|
|
9763
10646
|
*/
|
|
9764
10647
|
async #processSlashCommandResult(result, originalPrompt, abortSignal, onFullTurnModel) {
|
|
9765
|
-
this.#emitGoalStatusItems(result);
|
|
9766
10648
|
this.refreshContextFilesOnWrite = result.type === "submit_prompt" && Boolean(result.refreshContextFilesOnWrite);
|
|
9767
10649
|
switch (result.type) {
|
|
9768
10650
|
case "submit_prompt":
|
|
@@ -9813,9 +10695,15 @@ ${this.pendingRecoveredAgentsNotice}
|
|
|
9813
10695
|
throw new Error(unsupportedError);
|
|
9814
10696
|
}
|
|
9815
10697
|
case "goal_control":
|
|
9816
|
-
|
|
9817
|
-
|
|
9818
|
-
|
|
10698
|
+
if (!result.cause) {
|
|
10699
|
+
await this.#queueGoalState(
|
|
10700
|
+
result.response.snapshot,
|
|
10701
|
+
void 0,
|
|
10702
|
+
this.lastGoalSnapshot?.goal ?? null
|
|
10703
|
+
);
|
|
10704
|
+
this.lastGoalSnapshot = result.response.snapshot;
|
|
10705
|
+
}
|
|
10706
|
+
return null;
|
|
9819
10707
|
case "no_command":
|
|
9820
10708
|
return this.#resolvePrompt(originalPrompt, abortSignal, {
|
|
9821
10709
|
promptLast: true,
|
|
@@ -10274,10 +11162,11 @@ ${contextPart.text}`
|
|
|
10274
11162
|
init_esbuild_shims();
|
|
10275
11163
|
var debugLogger7 = createDebugLogger("ACTIVE_WORK");
|
|
10276
11164
|
var ActiveWorkReporter = class {
|
|
10277
|
-
constructor(send, listSources, intervalMs) {
|
|
11165
|
+
constructor(send, listSources, intervalMs, enabledCategories) {
|
|
10278
11166
|
this.send = send;
|
|
10279
11167
|
this.listSources = listSources;
|
|
10280
11168
|
this.intervalMs = intervalMs;
|
|
11169
|
+
this.#enabledCategories = new Set(enabledCategories);
|
|
10281
11170
|
this.#timer = setInterval(() => {
|
|
10282
11171
|
this.#publish();
|
|
10283
11172
|
}, intervalMs);
|
|
@@ -10292,6 +11181,7 @@ var ActiveWorkReporter = class {
|
|
|
10292
11181
|
#coalescing = false;
|
|
10293
11182
|
#timer;
|
|
10294
11183
|
#disposed = false;
|
|
11184
|
+
#enabledCategories;
|
|
10295
11185
|
/**
|
|
10296
11186
|
* Note that some Session's derived state may have changed. Coalesced to
|
|
10297
11187
|
* one snapshot per microtask so a burst of transitions (an agent finishing
|
|
@@ -10339,7 +11229,7 @@ var ActiveWorkReporter = class {
|
|
|
10339
11229
|
for (const source of this.listSources()) {
|
|
10340
11230
|
sessions.push({
|
|
10341
11231
|
sessionId: source.sessionId,
|
|
10342
|
-
holds: source.collectActiveWorkHolds()
|
|
11232
|
+
holds: source.collectActiveWorkHolds().filter((hold) => this.#enabledCategories.has(hold.category))
|
|
10343
11233
|
});
|
|
10344
11234
|
}
|
|
10345
11235
|
} catch (error) {
|
|
@@ -10362,6 +11252,22 @@ var ActiveWorkReporter = class {
|
|
|
10362
11252
|
}
|
|
10363
11253
|
};
|
|
10364
11254
|
|
|
11255
|
+
// packages/cli/src/acp-integration/model-configuration.ts
|
|
11256
|
+
init_esbuild_shims();
|
|
11257
|
+
var MODEL_CONFIGURATIONS = {
|
|
11258
|
+
"qwen3.8-max": {
|
|
11259
|
+
reasoning: {
|
|
11260
|
+
thinking: true,
|
|
11261
|
+
efforts: ["low", "medium", "xhigh"],
|
|
11262
|
+
defaultEffort: "xhigh"
|
|
11263
|
+
}
|
|
11264
|
+
}
|
|
11265
|
+
};
|
|
11266
|
+
function getModelConfiguration(modelId) {
|
|
11267
|
+
return modelId === "qwen3.8-max" ? MODEL_CONFIGURATIONS[modelId] : void 0;
|
|
11268
|
+
}
|
|
11269
|
+
__name(getModelConfiguration, "getModelConfiguration");
|
|
11270
|
+
|
|
10365
11271
|
// packages/cli/src/acp-integration/session/tasksSnapshot.ts
|
|
10366
11272
|
init_esbuild_shims();
|
|
10367
11273
|
function runtimeMs(entry, now) {
|
|
@@ -10499,6 +11405,7 @@ var BTW_CHILD_TIMEOUT_MS = 55e3;
|
|
|
10499
11405
|
var MCP_OAUTH_START_TIMEOUT_MS = 3e4;
|
|
10500
11406
|
var SESSION_DRAIN_TIMEOUT_MS = 3e4;
|
|
10501
11407
|
var ACP_REASONING_EFFORT_DEFAULT = "default";
|
|
11408
|
+
var ACP_REASONING_EFFORT_NONE = "none";
|
|
10502
11409
|
var ACP_REASONING_EFFORT_NAMES = {
|
|
10503
11410
|
low: "Low",
|
|
10504
11411
|
medium: "Medium",
|
|
@@ -10719,17 +11626,173 @@ function invalidArtifactPersistPayload() {
|
|
|
10719
11626
|
"Invalid or missing artifact persist payload"
|
|
10720
11627
|
);
|
|
10721
11628
|
}
|
|
10722
|
-
__name(invalidArtifactPersistPayload, "invalidArtifactPersistPayload");
|
|
10723
|
-
function isBulkLoadReplayRequest(params) {
|
|
10724
|
-
const meta = isObjectRecord(params._meta) ? params._meta : void 0;
|
|
10725
|
-
return meta?.[LOAD_REPLAY_MODE_META_KEY] === LOAD_REPLAY_BULK_MODE;
|
|
10726
|
-
}
|
|
10727
|
-
__name(isBulkLoadReplayRequest, "isBulkLoadReplayRequest");
|
|
10728
|
-
function shouldHideInheritedHistory(params) {
|
|
10729
|
-
const meta = isObjectRecord(params._meta) ? params._meta : void 0;
|
|
10730
|
-
return meta?.[LOAD_REPLAY_HIDE_INHERITED_META_KEY] === true;
|
|
11629
|
+
__name(invalidArtifactPersistPayload, "invalidArtifactPersistPayload");
|
|
11630
|
+
function isBulkLoadReplayRequest(params) {
|
|
11631
|
+
const meta = isObjectRecord(params._meta) ? params._meta : void 0;
|
|
11632
|
+
return meta?.[LOAD_REPLAY_MODE_META_KEY] === LOAD_REPLAY_BULK_MODE;
|
|
11633
|
+
}
|
|
11634
|
+
__name(isBulkLoadReplayRequest, "isBulkLoadReplayRequest");
|
|
11635
|
+
function shouldHideInheritedHistory(params) {
|
|
11636
|
+
const meta = isObjectRecord(params._meta) ? params._meta : void 0;
|
|
11637
|
+
return meta?.[LOAD_REPLAY_HIDE_INHERITED_META_KEY] === true;
|
|
11638
|
+
}
|
|
11639
|
+
__name(shouldHideInheritedHistory, "shouldHideInheritedHistory");
|
|
11640
|
+
function loadRestoreOptions(params) {
|
|
11641
|
+
const hideInheritedHistory = shouldHideInheritedHistory(params);
|
|
11642
|
+
if (!isBulkLoadReplayRequest(params)) {
|
|
11643
|
+
return { replay: { kind: "all", hideInheritedHistory } };
|
|
11644
|
+
}
|
|
11645
|
+
const limit = getLoadReplayPageSize(params);
|
|
11646
|
+
return limit === void 0 ? { replay: { kind: "all", hideInheritedHistory } } : { replay: { kind: "recent", limit, hideInheritedHistory } };
|
|
11647
|
+
}
|
|
11648
|
+
__name(loadRestoreOptions, "loadRestoreOptions");
|
|
11649
|
+
var RESUME_RESTORE_OPTIONS = {
|
|
11650
|
+
replay: { kind: "none" }
|
|
11651
|
+
};
|
|
11652
|
+
function mapSessionRestoreRequestError(error, sessionId) {
|
|
11653
|
+
const mappedWriterError = mapSessionWriterRequestError(error);
|
|
11654
|
+
if (mappedWriterError !== error) return mappedWriterError;
|
|
11655
|
+
if (error instanceof SessionTranscriptSnapshotUnavailableError) {
|
|
11656
|
+
return new RequestError(-32010, error.message, {
|
|
11657
|
+
errorKind: "transcript_snapshot_unavailable",
|
|
11658
|
+
sessionId
|
|
11659
|
+
});
|
|
11660
|
+
}
|
|
11661
|
+
if (error instanceof SessionTranscriptTooLargeError) {
|
|
11662
|
+
return new RequestError(-32011, error.message, {
|
|
11663
|
+
errorKind: "transcript_too_large",
|
|
11664
|
+
sessionId,
|
|
11665
|
+
snapshotSize: error.snapshotSize,
|
|
11666
|
+
maxBytes: error.maxBytes
|
|
11667
|
+
});
|
|
11668
|
+
}
|
|
11669
|
+
if (error instanceof SessionTranscriptPageTooLargeError) {
|
|
11670
|
+
addDaemonRequestAttribute(
|
|
11671
|
+
"qwen-code.daemon.session_restore.envelope_limit_reason",
|
|
11672
|
+
"bytes"
|
|
11673
|
+
);
|
|
11674
|
+
return new RequestError(-32012, error.message, {
|
|
11675
|
+
errorKind: "transcript_page_too_large",
|
|
11676
|
+
sessionId,
|
|
11677
|
+
pageBytes: error.pageBytes,
|
|
11678
|
+
maxBytes: error.maxBytes
|
|
11679
|
+
});
|
|
11680
|
+
}
|
|
11681
|
+
if (error instanceof HistoryReplayLimitError) {
|
|
11682
|
+
addDaemonRequestAttribute(
|
|
11683
|
+
"qwen-code.daemon.session_restore.envelope_limit_reason",
|
|
11684
|
+
error.reason
|
|
11685
|
+
);
|
|
11686
|
+
return new RequestError(-32012, error.message, {
|
|
11687
|
+
errorKind: "transcript_page_too_large",
|
|
11688
|
+
sessionId,
|
|
11689
|
+
reason: error.reason,
|
|
11690
|
+
observed: error.observed,
|
|
11691
|
+
limit: error.limit
|
|
11692
|
+
});
|
|
11693
|
+
}
|
|
11694
|
+
return error;
|
|
11695
|
+
}
|
|
11696
|
+
__name(mapSessionRestoreRequestError, "mapSessionRestoreRequestError");
|
|
11697
|
+
function validateLoadReplayEnvelope(sessionId, envelope, enforceLimits) {
|
|
11698
|
+
if (!enforceLimits) return;
|
|
11699
|
+
if (envelope.updates.length > LOAD_REPLAY_MAX_UPDATES) {
|
|
11700
|
+
throw new HistoryReplayLimitError(
|
|
11701
|
+
sessionId,
|
|
11702
|
+
"updates",
|
|
11703
|
+
envelope.updates.length,
|
|
11704
|
+
LOAD_REPLAY_MAX_UPDATES
|
|
11705
|
+
);
|
|
11706
|
+
}
|
|
11707
|
+
const pageBytes = Buffer.byteLength(JSON.stringify(envelope), "utf8");
|
|
11708
|
+
if (pageBytes > LOAD_REPLAY_MAX_BYTES) {
|
|
11709
|
+
throw new HistoryReplayLimitError(
|
|
11710
|
+
sessionId,
|
|
11711
|
+
"bytes",
|
|
11712
|
+
pageBytes,
|
|
11713
|
+
LOAD_REPLAY_MAX_BYTES
|
|
11714
|
+
);
|
|
11715
|
+
}
|
|
11716
|
+
}
|
|
11717
|
+
__name(validateLoadReplayEnvelope, "validateLoadReplayEnvelope");
|
|
11718
|
+
function replayGoalBootstrap(projection) {
|
|
11719
|
+
if (projection && !("runtime" in projection)) {
|
|
11720
|
+
const sourceUuid2 = projection.goalRecoverySourceUuid;
|
|
11721
|
+
if (!sourceUuid2) return void 0;
|
|
11722
|
+
if (projection.replay?.records.some((record) => record.uuid === sourceUuid2)) {
|
|
11723
|
+
return void 0;
|
|
11724
|
+
}
|
|
11725
|
+
const replay = projection.replay?.replay;
|
|
11726
|
+
if (isObjectRecord(replay)) {
|
|
11727
|
+
const bootstrap = HistoryReplayer.v2GoalBootstrap(
|
|
11728
|
+
replay["goalState"],
|
|
11729
|
+
replay["goalCause"]
|
|
11730
|
+
);
|
|
11731
|
+
if (bootstrap) return bootstrap;
|
|
11732
|
+
}
|
|
11733
|
+
const sourceRecord2 = projection.goalRecords?.find(
|
|
11734
|
+
(record) => record.uuid === sourceUuid2
|
|
11735
|
+
);
|
|
11736
|
+
if (sourceRecord2?.subtype === "goal_state") {
|
|
11737
|
+
const payload = isObjectRecord(sourceRecord2.systemPayload) ? sourceRecord2.systemPayload : void 0;
|
|
11738
|
+
return HistoryReplayer.v2GoalBootstrap(
|
|
11739
|
+
payload?.["snapshot"],
|
|
11740
|
+
payload?.["cause"]
|
|
11741
|
+
);
|
|
11742
|
+
}
|
|
11743
|
+
const active2 = findGoalToRestore(
|
|
11744
|
+
collectGoalStatusItemsFromRecords(projection.goalRecords ?? [])
|
|
11745
|
+
);
|
|
11746
|
+
return active2 ? {
|
|
11747
|
+
goalStatus: {
|
|
11748
|
+
kind: active2.iterations > 0 ? "checking" : "set",
|
|
11749
|
+
condition: active2.condition,
|
|
11750
|
+
iterations: active2.iterations,
|
|
11751
|
+
...active2.setAt !== void 0 ? { setAt: active2.setAt } : {}
|
|
11752
|
+
}
|
|
11753
|
+
} : void 0;
|
|
11754
|
+
}
|
|
11755
|
+
const sourceUuid = projection?.replay?.goalRecoverySourceUuid;
|
|
11756
|
+
if (!projection?.replay || !sourceUuid) return void 0;
|
|
11757
|
+
if (projection.replay.records.some((record) => record.uuid === sourceUuid)) {
|
|
11758
|
+
return void 0;
|
|
11759
|
+
}
|
|
11760
|
+
const goalBootstrapRecords = projection.replay.goalBootstrapRecords ?? [];
|
|
11761
|
+
const sourceRecord = goalBootstrapRecords.find(
|
|
11762
|
+
(record) => record.uuid === sourceUuid
|
|
11763
|
+
);
|
|
11764
|
+
if (sourceRecord?.subtype === "goal_state") {
|
|
11765
|
+
const payload = isObjectRecord(sourceRecord.systemPayload) ? sourceRecord.systemPayload : void 0;
|
|
11766
|
+
return HistoryReplayer.v2GoalBootstrap(
|
|
11767
|
+
payload?.["snapshot"],
|
|
11768
|
+
payload?.["cause"]
|
|
11769
|
+
);
|
|
11770
|
+
}
|
|
11771
|
+
const active = findGoalToRestore(
|
|
11772
|
+
collectGoalStatusItemsFromRecords(goalBootstrapRecords)
|
|
11773
|
+
);
|
|
11774
|
+
if (!active) return void 0;
|
|
11775
|
+
return {
|
|
11776
|
+
goalStatus: {
|
|
11777
|
+
kind: active.iterations > 0 ? "checking" : "set",
|
|
11778
|
+
condition: active.condition,
|
|
11779
|
+
iterations: active.iterations,
|
|
11780
|
+
...active.setAt !== void 0 ? { setAt: active.setAt } : {}
|
|
11781
|
+
}
|
|
11782
|
+
};
|
|
11783
|
+
}
|
|
11784
|
+
__name(replayGoalBootstrap, "replayGoalBootstrap");
|
|
11785
|
+
function replayInitialGoalState(projection) {
|
|
11786
|
+
const replay = projection?.replay?.replay;
|
|
11787
|
+
if (!isObjectRecord(replay)) return {};
|
|
11788
|
+
const initialGoalState = parseGoalSnapshotV2(replay["goalState"]);
|
|
11789
|
+
const initialGoalCause = parseGoalStateCause(replay["goalCause"]);
|
|
11790
|
+
return {
|
|
11791
|
+
...initialGoalState ? { initialGoalState } : {},
|
|
11792
|
+
...initialGoalCause ? { initialGoalCause } : {}
|
|
11793
|
+
};
|
|
10731
11794
|
}
|
|
10732
|
-
__name(
|
|
11795
|
+
__name(replayInitialGoalState, "replayInitialGoalState");
|
|
10733
11796
|
function selectVisibleHistoryRecords(records, hideInheritedHistory) {
|
|
10734
11797
|
const sourceBoundary = records.findIndex(
|
|
10735
11798
|
(record) => record.type === "system" && record.subtype === "session_source" && isObjectRecord(record.systemPayload) && record.systemPayload["sourceType"] === "side_task"
|
|
@@ -10770,61 +11833,6 @@ function getLoadReplayPageSize(params) {
|
|
|
10770
11833
|
return value;
|
|
10771
11834
|
}
|
|
10772
11835
|
__name(getLoadReplayPageSize, "getLoadReplayPageSize");
|
|
10773
|
-
function isHistoryTurnStart(record) {
|
|
10774
|
-
return isReplayTurnStartType(record.type, record.subtype);
|
|
10775
|
-
}
|
|
10776
|
-
__name(isHistoryTurnStart, "isHistoryTurnStart");
|
|
10777
|
-
function isHistoryPageStart(record) {
|
|
10778
|
-
return record.subtype !== "realtime_message" && (record.type === "assistant" || isHistoryTurnStart(record));
|
|
10779
|
-
}
|
|
10780
|
-
__name(isHistoryPageStart, "isHistoryPageStart");
|
|
10781
|
-
function historyOrphansToolResult(records, start, end) {
|
|
10782
|
-
for (let i = start; i < end; i++) {
|
|
10783
|
-
if (records[i].type !== "tool_result") continue;
|
|
10784
|
-
for (let owner = i - 1; owner >= start; owner--) {
|
|
10785
|
-
if (isHistoryPageStart(records[owner])) return false;
|
|
10786
|
-
}
|
|
10787
|
-
return true;
|
|
10788
|
-
}
|
|
10789
|
-
return false;
|
|
10790
|
-
}
|
|
10791
|
-
__name(historyOrphansToolResult, "historyOrphansToolResult");
|
|
10792
|
-
function selectRecentHistoryRecords(records, pageSize) {
|
|
10793
|
-
if (pageSize === void 0 || records.length <= pageSize) {
|
|
10794
|
-
return { records, hasMore: false };
|
|
10795
|
-
}
|
|
10796
|
-
let start = records.length - pageSize;
|
|
10797
|
-
for (let i = start; i < records.length; i++) {
|
|
10798
|
-
if (isHistoryTurnStart(records[i])) {
|
|
10799
|
-
start = i;
|
|
10800
|
-
break;
|
|
10801
|
-
}
|
|
10802
|
-
}
|
|
10803
|
-
const expansionFloor = Math.max(0, records.length - 2 * pageSize);
|
|
10804
|
-
const aligned = findBoundaryAtOrBefore(
|
|
10805
|
-
records,
|
|
10806
|
-
start,
|
|
10807
|
-
expansionFloor,
|
|
10808
|
-
isHistoryTurnStart
|
|
10809
|
-
);
|
|
10810
|
-
if (isHistoryTurnStart(records[aligned])) {
|
|
10811
|
-
start = aligned;
|
|
10812
|
-
}
|
|
10813
|
-
if (start > 0 && historyOrphansToolResult(records, start, records.length)) {
|
|
10814
|
-
const pairFloor = Math.max(0, start - pageSize);
|
|
10815
|
-
const owner = findBoundaryAtOrBefore(
|
|
10816
|
-
records,
|
|
10817
|
-
start,
|
|
10818
|
-
pairFloor,
|
|
10819
|
-
isHistoryPageStart
|
|
10820
|
-
);
|
|
10821
|
-
if (isHistoryPageStart(records[owner])) {
|
|
10822
|
-
start = owner;
|
|
10823
|
-
}
|
|
10824
|
-
}
|
|
10825
|
-
return { records: records.slice(start), hasMore: start > 0 };
|
|
10826
|
-
}
|
|
10827
|
-
__name(selectRecentHistoryRecords, "selectRecentHistoryRecords");
|
|
10828
11836
|
function createHiddenWorkspaceMemoryConfig(config) {
|
|
10829
11837
|
return new Proxy(config, {
|
|
10830
11838
|
get(target, prop) {
|
|
@@ -12220,23 +13228,28 @@ async function deliverClientMcpMessage(connection, serverName, message, sessionI
|
|
|
12220
13228
|
return payload;
|
|
12221
13229
|
}
|
|
12222
13230
|
__name(deliverClientMcpMessage, "deliverClientMcpMessage");
|
|
12223
|
-
function createManagedExternalToolGuard(connection
|
|
13231
|
+
function createManagedExternalToolGuard(connection, options = {
|
|
13232
|
+
externalProviderAttached: false
|
|
13233
|
+
}) {
|
|
12224
13234
|
return async (context) => {
|
|
13235
|
+
if (!options.externalProviderAttached && !SHELL_EXECUTING_TOOL_NAMES.has(context.toolName)) {
|
|
13236
|
+
return { allowed: true };
|
|
13237
|
+
}
|
|
12225
13238
|
const invocation = context.invocationContext;
|
|
12226
|
-
if (!invocation) {
|
|
13239
|
+
if (!invocation && options.externalProviderAttached) {
|
|
12227
13240
|
throw new Error(
|
|
12228
13241
|
"Managed external tool guard requires a runtime invocation context."
|
|
12229
13242
|
);
|
|
12230
13243
|
}
|
|
13244
|
+
const sessionId = invocation?.sessionId ?? context.sessionId;
|
|
13245
|
+
if (typeof sessionId !== "string" || sessionId.length === 0) {
|
|
13246
|
+
throw new Error(
|
|
13247
|
+
"Managed external tool guard requires a session identity."
|
|
13248
|
+
);
|
|
13249
|
+
}
|
|
12231
13250
|
if (context.signal.aborted) {
|
|
12232
13251
|
throw new DOMException("Tool invocation aborted", "AbortError");
|
|
12233
13252
|
}
|
|
12234
|
-
if (context.toolName === ToolNames.AGENT || context.toolName === ToolNames.WORKFLOW || context.toolName === ToolNames.CREATE_SUB_SESSION || context.toolName === ToolNames.SEND_MESSAGE) {
|
|
12235
|
-
return {
|
|
12236
|
-
allowed: false,
|
|
12237
|
-
reason: "Managed external tool guard v1 does not support nested or delegated agent execution."
|
|
12238
|
-
};
|
|
12239
|
-
}
|
|
12240
13253
|
let rejectOnAbort;
|
|
12241
13254
|
const aborted = new Promise((_resolve, reject) => {
|
|
12242
13255
|
rejectOnAbort = reject;
|
|
@@ -12251,11 +13264,14 @@ function createManagedExternalToolGuard(connection) {
|
|
|
12251
13264
|
connection.extMethod(
|
|
12252
13265
|
SERVE_CONTROL_EXT_METHODS.externalToolGuardPrepare,
|
|
12253
13266
|
{
|
|
12254
|
-
sessionId
|
|
12255
|
-
promptId: invocation.promptId,
|
|
13267
|
+
sessionId,
|
|
13268
|
+
...invocation ? { promptId: invocation.promptId } : {},
|
|
12256
13269
|
toolCallId: context.callId,
|
|
12257
13270
|
toolName: context.toolName,
|
|
12258
|
-
arguments: context.args
|
|
13271
|
+
arguments: context.args,
|
|
13272
|
+
// A sub-agent pinned to a worktree executes here, not in the
|
|
13273
|
+
// session's own directory; the host validates this before use.
|
|
13274
|
+
...typeof context.cwd === "string" && context.cwd.length > 0 ? { invocationCwd: context.cwd } : {}
|
|
12259
13275
|
}
|
|
12260
13276
|
),
|
|
12261
13277
|
aborted
|
|
@@ -12382,8 +13398,10 @@ async function runAcpAgent(config, settings, argv, options) {
|
|
|
12382
13398
|
const privateParentCapability = options === void 0 ? process.env[PRIVATE_ACP_CAPABILITY_ENV] : options.privateParentCapability;
|
|
12383
13399
|
delete process.env[PRIVATE_ACP_CAPABILITY_ENV];
|
|
12384
13400
|
delete process.env[PRIVATE_EXTERNAL_TOOL_GUARD_ENV];
|
|
13401
|
+
delete process.env[PRIVATE_EXTERNAL_TOOL_GUARD_PROVIDER_ENV];
|
|
12385
13402
|
delete process.env[EXTERNAL_TOOL_GUARD_TOKEN_ENV];
|
|
12386
13403
|
const externalToolGuardRequired = options?.externalToolGuardRequired === true;
|
|
13404
|
+
const externalToolGuardProviderAttached = options?.externalToolGuardProviderAttached === true;
|
|
12387
13405
|
if (externalToolGuardRequired && privateParentCapability === void 0) {
|
|
12388
13406
|
throw new Error(
|
|
12389
13407
|
"Required external tool guard is available only to a private managed ACP parent."
|
|
@@ -12465,7 +13483,9 @@ async function runAcpAgent(config, settings, argv, options) {
|
|
|
12465
13483
|
});
|
|
12466
13484
|
connection = new AgentSideConnection((conn) => {
|
|
12467
13485
|
acpConnection = conn;
|
|
12468
|
-
const managedToolInvocationGuard = externalToolGuardRequired ? createManagedExternalToolGuard(conn
|
|
13486
|
+
const managedToolInvocationGuard = externalToolGuardRequired ? createManagedExternalToolGuard(conn, {
|
|
13487
|
+
externalProviderAttached: externalToolGuardProviderAttached
|
|
13488
|
+
}) : void 0;
|
|
12469
13489
|
agentInstance = new QwenAgent(
|
|
12470
13490
|
config,
|
|
12471
13491
|
settings,
|
|
@@ -12473,7 +13493,8 @@ async function runAcpAgent(config, settings, argv, options) {
|
|
|
12473
13493
|
conn,
|
|
12474
13494
|
privateParentCapability,
|
|
12475
13495
|
sessionWriterLeaseEnabledAtStartup,
|
|
12476
|
-
managedToolInvocationGuard
|
|
13496
|
+
managedToolInvocationGuard,
|
|
13497
|
+
externalToolGuardProviderAttached
|
|
12477
13498
|
);
|
|
12478
13499
|
return agentInstance;
|
|
12479
13500
|
}, stream);
|
|
@@ -12779,7 +13800,7 @@ function isOwnerOnlyDirectory(stats) {
|
|
|
12779
13800
|
}
|
|
12780
13801
|
__name(isOwnerOnlyDirectory, "isOwnerOnlyDirectory");
|
|
12781
13802
|
var QwenAgent = class {
|
|
12782
|
-
constructor(config, settings, argv, connection, expectedPrivateParentCapability, sessionWriterLeaseEnabledAtStartup = false, managedToolInvocationGuard) {
|
|
13803
|
+
constructor(config, settings, argv, connection, expectedPrivateParentCapability, sessionWriterLeaseEnabledAtStartup = false, managedToolInvocationGuard, externalToolGuardProviderAttached = false) {
|
|
12783
13804
|
this.config = config;
|
|
12784
13805
|
this.settings = settings;
|
|
12785
13806
|
this.argv = argv;
|
|
@@ -12787,6 +13808,7 @@ var QwenAgent = class {
|
|
|
12787
13808
|
this.expectedPrivateParentCapability = expectedPrivateParentCapability;
|
|
12788
13809
|
this.sessionWriterLeaseEnabledAtStartup = sessionWriterLeaseEnabledAtStartup;
|
|
12789
13810
|
this.managedToolInvocationGuard = managedToolInvocationGuard;
|
|
13811
|
+
this.externalToolGuardProviderAttached = externalToolGuardProviderAttached;
|
|
12790
13812
|
if (process.env["QWEN_SERVE_NO_MCP_POOL"] === "1") {
|
|
12791
13813
|
this.mcpPool = void 0;
|
|
12792
13814
|
this.workspaceMcpBudget = void 0;
|
|
@@ -12881,7 +13903,7 @@ var QwenAgent = class {
|
|
|
12881
13903
|
}
|
|
12882
13904
|
}
|
|
12883
13905
|
rejectUnsupportedGuardedHiddenAgent(operation) {
|
|
12884
|
-
if (this.managedToolInvocationGuard) {
|
|
13906
|
+
if (this.managedToolInvocationGuard && this.externalToolGuardProviderAttached) {
|
|
12885
13907
|
throw RequestError.invalidParams(
|
|
12886
13908
|
void 0,
|
|
12887
13909
|
`Managed external tool guard v1 does not support ${operation}.`
|
|
@@ -13274,11 +14296,6 @@ var QwenAgent = class {
|
|
|
13274
14296
|
cleanupErrors.push(error);
|
|
13275
14297
|
}
|
|
13276
14298
|
}
|
|
13277
|
-
try {
|
|
13278
|
-
unregisterGoalHook(session.getConfig(), sessionId);
|
|
13279
|
-
} catch (error) {
|
|
13280
|
-
cleanupErrors.push(error);
|
|
13281
|
-
}
|
|
13282
14299
|
try {
|
|
13283
14300
|
this.mcpPool?.releaseSession(sessionId);
|
|
13284
14301
|
} catch (error) {
|
|
@@ -13299,7 +14316,7 @@ var QwenAgent = class {
|
|
|
13299
14316
|
);
|
|
13300
14317
|
}
|
|
13301
14318
|
}
|
|
13302
|
-
async withLiveSessionRestore(sessionId, session, operation) {
|
|
14319
|
+
async withLiveSessionRestore(sessionId, session, options, operation) {
|
|
13303
14320
|
await session.assertCanStartTurn();
|
|
13304
14321
|
const config = session.getConfig();
|
|
13305
14322
|
const releaseGate = session.beginClose();
|
|
@@ -13310,12 +14327,12 @@ var QwenAgent = class {
|
|
|
13310
14327
|
"restore"
|
|
13311
14328
|
);
|
|
13312
14329
|
const recorder = config.getChatRecordingService();
|
|
13313
|
-
const
|
|
13314
|
-
const
|
|
13315
|
-
if (!
|
|
13316
|
-
return await operation(config,
|
|
14330
|
+
const readProjection = /* @__PURE__ */ __name(() => config.getSessionService().readLiveRestoreProjection(sessionId, options), "readProjection");
|
|
14331
|
+
const projection = recorder ? await recorder.runWithWriteBarrier(readProjection) : await readProjection();
|
|
14332
|
+
if (!projection) throw new SessionWriterUnavailableError();
|
|
14333
|
+
return await operation(config, projection);
|
|
13317
14334
|
} catch (error) {
|
|
13318
|
-
throw
|
|
14335
|
+
throw mapSessionRestoreRequestError(error, sessionId);
|
|
13319
14336
|
} finally {
|
|
13320
14337
|
releaseGate();
|
|
13321
14338
|
}
|
|
@@ -13342,7 +14359,7 @@ var QwenAgent = class {
|
|
|
13342
14359
|
this.pendingConfigCleanup.delete(cleanupKey);
|
|
13343
14360
|
}
|
|
13344
14361
|
}
|
|
13345
|
-
async cleanupAfterRequestFailure(error, cleanup) {
|
|
14362
|
+
async cleanupAfterRequestFailure(error, cleanup, sessionId) {
|
|
13346
14363
|
try {
|
|
13347
14364
|
await cleanup();
|
|
13348
14365
|
} catch (cleanupError) {
|
|
@@ -13350,7 +14367,7 @@ var QwenAgent = class {
|
|
|
13350
14367
|
`Session cleanup failed while preserving the original request error: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`
|
|
13351
14368
|
);
|
|
13352
14369
|
}
|
|
13353
|
-
throw mapSessionWriterRequestError(error);
|
|
14370
|
+
throw sessionId ? mapSessionRestoreRequestError(error, sessionId) : mapSessionWriterRequestError(error);
|
|
13354
14371
|
}
|
|
13355
14372
|
pendingConfigCleanupKey(runtimeBaseDir, sessionId) {
|
|
13356
14373
|
return `${path4.resolve(runtimeBaseDir)}\0${sessionId}`;
|
|
@@ -13417,6 +14434,12 @@ var QwenAgent = class {
|
|
|
13417
14434
|
drainTimeoutMs,
|
|
13418
14435
|
"close"
|
|
13419
14436
|
);
|
|
14437
|
+
if (opts?.onlyIfUnheld) {
|
|
14438
|
+
const holds = session.collectActiveWorkHolds();
|
|
14439
|
+
if (holds.length > 0) {
|
|
14440
|
+
return { closed: false, holds };
|
|
14441
|
+
}
|
|
14442
|
+
}
|
|
13420
14443
|
recorder?.finalize();
|
|
13421
14444
|
let flushError;
|
|
13422
14445
|
try {
|
|
@@ -13550,7 +14573,7 @@ var QwenAgent = class {
|
|
|
13550
14573
|
}
|
|
13551
14574
|
this.clientCapabilities = args.clientCapabilities;
|
|
13552
14575
|
const authMethods = buildAuthMethods();
|
|
13553
|
-
const version = "0.21.
|
|
14576
|
+
const version = "0.21.11-nightly.20260815.c396fe3d12";
|
|
13554
14577
|
const response = {
|
|
13555
14578
|
protocolVersion: PROTOCOL_VERSION,
|
|
13556
14579
|
agentInfo: {
|
|
@@ -13594,12 +14617,17 @@ var QwenAgent = class {
|
|
|
13594
14617
|
const activeWorkIntervalMs = activeWorkRequested ? clampActiveWorkIntervalMs(
|
|
13595
14618
|
requestedActiveWork["intervalMs"]
|
|
13596
14619
|
) : void 0;
|
|
14620
|
+
const requestedActiveWorkCategories = activeWorkRequested ? requestedActiveWork["categories"] : void 0;
|
|
14621
|
+
const activeWorkCategories = activeWorkRequested ? Array.isArray(requestedActiveWorkCategories) ? ACTIVE_WORK_HOLD_CATEGORIES.filter(
|
|
14622
|
+
(category) => requestedActiveWorkCategories.includes(category)
|
|
14623
|
+
) : ACTIVE_WORK_LEGACY_HOLD_CATEGORIES : void 0;
|
|
13597
14624
|
if (activeWorkIntervalMs !== void 0) {
|
|
13598
14625
|
this.activeWorkReporter?.dispose();
|
|
13599
14626
|
this.activeWorkReporter = new ActiveWorkReporter(
|
|
13600
14627
|
(method, params) => this.connection.extNotification(method, params),
|
|
13601
14628
|
() => this.sessions.values(),
|
|
13602
|
-
activeWorkIntervalMs
|
|
14629
|
+
activeWorkIntervalMs,
|
|
14630
|
+
activeWorkCategories ?? []
|
|
13603
14631
|
);
|
|
13604
14632
|
}
|
|
13605
14633
|
const responseMeta = {
|
|
@@ -13611,7 +14639,7 @@ var QwenAgent = class {
|
|
|
13611
14639
|
[ACTIVE_WORK_HEARTBEAT_META_KEY]: {
|
|
13612
14640
|
v: ACTIVE_WORK_HEARTBEAT_VERSION,
|
|
13613
14641
|
intervalMs: activeWorkIntervalMs,
|
|
13614
|
-
categories: [...
|
|
14642
|
+
categories: [...activeWorkCategories ?? []]
|
|
13615
14643
|
}
|
|
13616
14644
|
} : {}
|
|
13617
14645
|
};
|
|
@@ -13751,6 +14779,7 @@ var QwenAgent = class {
|
|
|
13751
14779
|
async loadSessionWithProfiler(params, initialSessionId, profiler) {
|
|
13752
14780
|
let sessionId = initialSessionId;
|
|
13753
14781
|
const sessionSource = getSessionSource(params);
|
|
14782
|
+
const restoreOptions = loadRestoreOptions(params);
|
|
13754
14783
|
const liveSession = this.sessions.get(sessionId);
|
|
13755
14784
|
if (liveSession) {
|
|
13756
14785
|
const settings = profiler.timeSync(
|
|
@@ -13763,35 +14792,43 @@ var QwenAgent = class {
|
|
|
13763
14792
|
return this.withLiveSessionRestore(
|
|
13764
14793
|
sessionId,
|
|
13765
14794
|
liveSession,
|
|
13766
|
-
|
|
14795
|
+
restoreOptions,
|
|
14796
|
+
async (config, projection) => {
|
|
13767
14797
|
const response = profiler.timeSync(
|
|
13768
14798
|
"response_build",
|
|
13769
14799
|
() => ({
|
|
13770
14800
|
modes: this.buildModesData(config),
|
|
13771
14801
|
models: this.buildAvailableModels(config),
|
|
13772
14802
|
configOptions: this.buildConfigOptions(config),
|
|
13773
|
-
...
|
|
14803
|
+
...projection?.artifactSnapshot ? { artifactSnapshot: projection.artifactSnapshot } : {}
|
|
13774
14804
|
})
|
|
13775
14805
|
);
|
|
13776
|
-
const
|
|
13777
|
-
|
|
13778
|
-
records,
|
|
13779
|
-
shouldHideInheritedHistory(params)
|
|
13780
|
-
);
|
|
13781
|
-
if (visibleRecords.length === 0) return response;
|
|
14806
|
+
const replayPage = projection?.replay;
|
|
14807
|
+
if (!replayPage || replayPage.records.length === 0) return response;
|
|
13782
14808
|
const bulkReplay = isBulkLoadReplayRequest(params);
|
|
13783
|
-
const
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
|
|
13788
|
-
|
|
13789
|
-
|
|
13790
|
-
|
|
13791
|
-
|
|
13792
|
-
|
|
13793
|
-
|
|
13794
|
-
|
|
14809
|
+
const replay = await profiler.time(
|
|
14810
|
+
"history_replay",
|
|
14811
|
+
() => collectHistoryReplayUpdates({
|
|
14812
|
+
sessionId,
|
|
14813
|
+
config,
|
|
14814
|
+
records: replayPage.records,
|
|
14815
|
+
gaps: replayPage.gaps,
|
|
14816
|
+
cumulativeUsage: createReplayCumulativeUsage(),
|
|
14817
|
+
replayState: replayPage.replay,
|
|
14818
|
+
goalBootstrap: replayGoalBootstrap(projection),
|
|
14819
|
+
...restoreOptions.replay.kind === "recent" ? {
|
|
14820
|
+
limits: {
|
|
14821
|
+
maxBytes: LOAD_REPLAY_MAX_BYTES,
|
|
14822
|
+
maxUpdates: LOAD_REPLAY_MAX_UPDATES
|
|
14823
|
+
}
|
|
14824
|
+
} : {},
|
|
14825
|
+
logger: debugLogger8
|
|
14826
|
+
})
|
|
14827
|
+
);
|
|
14828
|
+
addDaemonRequestAttribute(
|
|
14829
|
+
"qwen-code.daemon.session_restore.partial_replay",
|
|
14830
|
+
replay.replayError !== void 0
|
|
14831
|
+
);
|
|
13795
14832
|
if (!bulkReplay) {
|
|
13796
14833
|
try {
|
|
13797
14834
|
for (const update of replay.updates) {
|
|
@@ -13805,18 +14842,25 @@ var QwenAgent = class {
|
|
|
13805
14842
|
}
|
|
13806
14843
|
return response;
|
|
13807
14844
|
}
|
|
14845
|
+
const envelope = {
|
|
14846
|
+
v: LOAD_REPLAY_VERSION,
|
|
14847
|
+
updates: replay.updates,
|
|
14848
|
+
...replayPage.anchorRecordId ? { anchorRecordId: replayPage.anchorRecordId } : {},
|
|
14849
|
+
...replay.replayError !== void 0 ? {
|
|
14850
|
+
partial: true,
|
|
14851
|
+
replayError: replay.replayError
|
|
14852
|
+
} : {},
|
|
14853
|
+
...replayPage.hasMore ? { hasMore: true } : {}
|
|
14854
|
+
};
|
|
14855
|
+
validateLoadReplayEnvelope(
|
|
14856
|
+
sessionId,
|
|
14857
|
+
envelope,
|
|
14858
|
+
restoreOptions.replay.kind === "recent"
|
|
14859
|
+
);
|
|
13808
14860
|
return {
|
|
13809
14861
|
...response,
|
|
13810
14862
|
_meta: {
|
|
13811
|
-
[LOAD_REPLAY_META_KEY]:
|
|
13812
|
-
v: LOAD_REPLAY_VERSION,
|
|
13813
|
-
updates: replay.updates,
|
|
13814
|
-
...replay.replayError !== void 0 ? {
|
|
13815
|
-
partial: true,
|
|
13816
|
-
replayError: replay.replayError
|
|
13817
|
-
} : {},
|
|
13818
|
-
...replayPage.hasMore ? { hasMore: true } : {}
|
|
13819
|
-
}
|
|
14863
|
+
[LOAD_REPLAY_META_KEY]: envelope
|
|
13820
14864
|
}
|
|
13821
14865
|
};
|
|
13822
14866
|
}
|
|
@@ -13858,13 +14902,32 @@ var QwenAgent = class {
|
|
|
13858
14902
|
settings,
|
|
13859
14903
|
sessionSource,
|
|
13860
14904
|
sessionId,
|
|
13861
|
-
true
|
|
14905
|
+
true,
|
|
14906
|
+
{},
|
|
14907
|
+
void 0,
|
|
14908
|
+
restoreOptions
|
|
13862
14909
|
)
|
|
13863
14910
|
);
|
|
13864
|
-
const
|
|
14911
|
+
const projection = config.consumeSessionRestoreProjection?.();
|
|
14912
|
+
const suppressRecoveredGoalPresentation = projection?.runtime.goalRecoverySourceUuid !== void 0 && projection.runtime.goalRecoverySourceUuid !== projection.replay?.goalRecoverySourceUuid;
|
|
13865
14913
|
const bulkReplay = isBulkLoadReplayRequest(params);
|
|
13866
|
-
const replayPageSize = bulkReplay ? getLoadReplayPageSize(params) : void 0;
|
|
13867
14914
|
let replayEnvelope;
|
|
14915
|
+
const replayUsage = createReplayCumulativeUsage();
|
|
14916
|
+
let recoveredGoalPublicationKey;
|
|
14917
|
+
let suppressedRecoveredGoalId;
|
|
14918
|
+
let streamGoalUpdates = [];
|
|
14919
|
+
let response;
|
|
14920
|
+
const buildResponse = /* @__PURE__ */ __name(() => profiler.timeSync("response_build", () => ({
|
|
14921
|
+
modes: this.buildModesData(config),
|
|
14922
|
+
models: this.buildAvailableModels(config),
|
|
14923
|
+
configOptions: this.buildConfigOptions(config),
|
|
14924
|
+
...projection?.runtime.artifactSnapshot ? { artifactSnapshot: projection.runtime.artifactSnapshot } : {},
|
|
14925
|
+
...replayEnvelope ? {
|
|
14926
|
+
_meta: {
|
|
14927
|
+
[LOAD_REPLAY_META_KEY]: replayEnvelope
|
|
14928
|
+
}
|
|
14929
|
+
} : {}
|
|
14930
|
+
})), "buildResponse");
|
|
13868
14931
|
try {
|
|
13869
14932
|
await profiler.time("auth", () => this.ensureAuthenticated(config));
|
|
13870
14933
|
profiler.timeSync(
|
|
@@ -13873,91 +14936,165 @@ var QwenAgent = class {
|
|
|
13873
14936
|
);
|
|
13874
14937
|
await profiler.time(
|
|
13875
14938
|
"session_register",
|
|
13876
|
-
() => this.createAndStoreSession(config, settings,
|
|
14939
|
+
() => this.createAndStoreSession(config, settings, void 0, {
|
|
13877
14940
|
enableLiveScreenContext: isCompatibleLiveSessionSource(
|
|
13878
14941
|
sessionSource ?? {}
|
|
13879
14942
|
),
|
|
13880
|
-
|
|
13881
|
-
|
|
13882
|
-
if (bulkReplay) {
|
|
13883
|
-
const
|
|
13884
|
-
|
|
13885
|
-
|
|
13886
|
-
createdSession.primeTurnFromHistory(records);
|
|
13887
|
-
const visibleRecords = selectVisibleHistoryRecords(
|
|
13888
|
-
records,
|
|
13889
|
-
shouldHideInheritedHistory(params)
|
|
13890
|
-
);
|
|
13891
|
-
const replayPage = selectRecentHistoryRecords(
|
|
13892
|
-
visibleRecords,
|
|
13893
|
-
replayPageSize
|
|
13894
|
-
);
|
|
13895
|
-
const replayUsage = createReplayCumulativeUsage();
|
|
13896
|
-
const replay = await collectHistoryReplayUpdates({
|
|
14943
|
+
replayHistory: false,
|
|
14944
|
+
prepareBeforeSessionCreate: /* @__PURE__ */ __name(async () => {
|
|
14945
|
+
if (bulkReplay && projection?.replay) {
|
|
14946
|
+
const replay = await profiler.time(
|
|
14947
|
+
"history_replay",
|
|
14948
|
+
() => collectHistoryReplayUpdates({
|
|
13897
14949
|
sessionId,
|
|
13898
14950
|
config,
|
|
13899
|
-
records:
|
|
13900
|
-
gaps:
|
|
14951
|
+
records: projection.replay.records,
|
|
14952
|
+
gaps: projection.replay.gaps,
|
|
13901
14953
|
cumulativeUsage: replayUsage,
|
|
13902
|
-
|
|
14954
|
+
replayState: projection.replay.replay,
|
|
14955
|
+
goalBootstrap: replayGoalBootstrap(projection),
|
|
14956
|
+
...restoreOptions.replay.kind === "recent" ? {
|
|
14957
|
+
limits: {
|
|
14958
|
+
maxBytes: LOAD_REPLAY_MAX_BYTES,
|
|
14959
|
+
maxUpdates: LOAD_REPLAY_MAX_UPDATES
|
|
14960
|
+
}
|
|
14961
|
+
} : {},
|
|
13903
14962
|
logger: debugLogger8
|
|
13904
|
-
})
|
|
13905
|
-
|
|
13906
|
-
|
|
13907
|
-
|
|
13908
|
-
|
|
13909
|
-
|
|
13910
|
-
|
|
13911
|
-
|
|
13912
|
-
|
|
13913
|
-
|
|
13914
|
-
|
|
13915
|
-
|
|
13916
|
-
|
|
13917
|
-
|
|
13918
|
-
}
|
|
13919
|
-
|
|
13920
|
-
|
|
13921
|
-
|
|
13922
|
-
|
|
13923
|
-
|
|
14963
|
+
})
|
|
14964
|
+
);
|
|
14965
|
+
addDaemonRequestAttribute(
|
|
14966
|
+
"qwen-code.daemon.session_restore.partial_replay",
|
|
14967
|
+
replay.replayError !== void 0
|
|
14968
|
+
);
|
|
14969
|
+
replayEnvelope = {
|
|
14970
|
+
v: LOAD_REPLAY_VERSION,
|
|
14971
|
+
updates: replay.updates,
|
|
14972
|
+
...projection.replay.anchorRecordId ? { anchorRecordId: projection.replay.anchorRecordId } : {},
|
|
14973
|
+
...replay.replayError !== void 0 ? {
|
|
14974
|
+
partial: true,
|
|
14975
|
+
replayError: replay.replayError
|
|
14976
|
+
} : {},
|
|
14977
|
+
...projection.replay.hasMore ? { hasMore: true } : {}
|
|
14978
|
+
};
|
|
14979
|
+
validateLoadReplayEnvelope(
|
|
14980
|
+
sessionId,
|
|
14981
|
+
replayEnvelope,
|
|
14982
|
+
restoreOptions.replay.kind === "recent"
|
|
14983
|
+
);
|
|
14984
|
+
}
|
|
14985
|
+
const goalBootstrap = replayGoalBootstrap(projection);
|
|
14986
|
+
const rendered = await renderPreparedGoalUpdate(
|
|
14987
|
+
() => config.getGoalRuntimePrepared(),
|
|
14988
|
+
{
|
|
14989
|
+
...projection?.replay?.records ? { replayedRecords: projection.replay.records } : {},
|
|
14990
|
+
...suppressRecoveredGoalPresentation ? { hideRuntimeGoal: true } : {},
|
|
14991
|
+
...goalBootstrap ? { bootstrap: goalBootstrap } : {}
|
|
13924
14992
|
}
|
|
14993
|
+
).catch((error) => {
|
|
14994
|
+
if (suppressRecoveredGoalPresentation) throw error;
|
|
14995
|
+
debugLogger8.debug(
|
|
14996
|
+
`Failed to render recovered Goal state: ${error instanceof Error ? error.message : String(error)}`
|
|
14997
|
+
);
|
|
14998
|
+
return {
|
|
14999
|
+
publicationKey: void 0,
|
|
15000
|
+
suppressedGoalId: void 0,
|
|
15001
|
+
updates: []
|
|
15002
|
+
};
|
|
15003
|
+
});
|
|
15004
|
+
recoveredGoalPublicationKey = rendered.publicationKey;
|
|
15005
|
+
suppressedRecoveredGoalId = rendered.suppressedGoalId;
|
|
15006
|
+
if (!bulkReplay) {
|
|
15007
|
+
streamGoalUpdates = rendered.updates;
|
|
15008
|
+
return;
|
|
15009
|
+
}
|
|
15010
|
+
const goalUpdates = rendered.updates;
|
|
15011
|
+
if (goalUpdates.length > 0) {
|
|
13925
15012
|
replayEnvelope ??= {
|
|
13926
15013
|
v: LOAD_REPLAY_VERSION,
|
|
13927
|
-
updates:
|
|
15014
|
+
updates: []
|
|
13928
15015
|
};
|
|
15016
|
+
replayEnvelope.updates.push(...goalUpdates);
|
|
15017
|
+
validateLoadReplayEnvelope(
|
|
15018
|
+
sessionId,
|
|
15019
|
+
replayEnvelope,
|
|
15020
|
+
restoreOptions.replay.kind === "recent"
|
|
15021
|
+
);
|
|
13929
15022
|
}
|
|
13930
|
-
|
|
13931
|
-
|
|
13932
|
-
|
|
13933
|
-
|
|
13934
|
-
|
|
13935
|
-
|
|
15023
|
+
}, "prepareBeforeSessionCreate"),
|
|
15024
|
+
beforeSessionCreate: /* @__PURE__ */ __name(() => {
|
|
15025
|
+
response = buildResponse();
|
|
15026
|
+
}, "beforeSessionCreate"),
|
|
15027
|
+
primeSession: /* @__PURE__ */ __name((createdSession) => {
|
|
15028
|
+
profiler.timeSync("runtime_initialize", () => {
|
|
15029
|
+
if (!projection) return;
|
|
15030
|
+
createdSession.primeTurnState(
|
|
15031
|
+
projection.runtime.initialTurn,
|
|
15032
|
+
projection.runtime.backgroundNotificationTaskIds
|
|
15033
|
+
);
|
|
15034
|
+
copyCumulativeUsage(
|
|
15035
|
+
createdSession.cumulativeUsage,
|
|
15036
|
+
replayUsage
|
|
15037
|
+
);
|
|
15038
|
+
createdSession.primeRecoveredGoalPublication(
|
|
15039
|
+
recoveredGoalPublicationKey,
|
|
15040
|
+
suppressedRecoveredGoalId
|
|
15041
|
+
);
|
|
15042
|
+
});
|
|
15043
|
+
}, "primeSession"),
|
|
15044
|
+
beforeStartPostReplayServices: /* @__PURE__ */ __name(async (createdSession) => {
|
|
15045
|
+
if (!bulkReplay && projection?.replay) {
|
|
15046
|
+
await profiler.time("history_replay", async () => {
|
|
15047
|
+
const goalBootstrap = replayGoalBootstrap(projection);
|
|
15048
|
+
const initialGoalState = replayInitialGoalState(projection);
|
|
15049
|
+
const hasGoalReplayState = goalBootstrap !== void 0 || initialGoalState.initialGoalState !== void 0 || initialGoalState.initialGoalCause !== void 0;
|
|
15050
|
+
if (hasGoalReplayState) {
|
|
15051
|
+
await createdSession.replayHistory(
|
|
15052
|
+
projection.replay.records,
|
|
15053
|
+
projection.replay.gaps,
|
|
15054
|
+
{
|
|
15055
|
+
...goalBootstrap ? { goalBootstrap } : {},
|
|
15056
|
+
...initialGoalState
|
|
15057
|
+
}
|
|
15058
|
+
);
|
|
15059
|
+
} else {
|
|
15060
|
+
await createdSession.replayHistory(
|
|
15061
|
+
projection.replay.records,
|
|
15062
|
+
projection.replay.gaps
|
|
15063
|
+
);
|
|
15064
|
+
}
|
|
15065
|
+
});
|
|
15066
|
+
try {
|
|
15067
|
+
for (const update of streamGoalUpdates) {
|
|
15068
|
+
await createdSession.sendUpdate(update);
|
|
15069
|
+
}
|
|
15070
|
+
} catch (error) {
|
|
15071
|
+
debugLogger8.debug(
|
|
15072
|
+
`Failed to publish recovered Goal state: ${error instanceof Error ? error.message : String(error)}`
|
|
15073
|
+
);
|
|
15074
|
+
}
|
|
15075
|
+
}
|
|
15076
|
+
await profiler.time("post_replay_services", async () => {
|
|
15077
|
+
await this.#restoreWorktreeOnResume(config, createdSession);
|
|
15078
|
+
await this.#restoreBackgroundAgentsOnResume(
|
|
15079
|
+
config,
|
|
15080
|
+
createdSession
|
|
15081
|
+
);
|
|
15082
|
+
});
|
|
13936
15083
|
}, "beforeStartPostReplayServices")
|
|
13937
15084
|
})
|
|
13938
15085
|
);
|
|
13939
15086
|
} catch (error) {
|
|
13940
|
-
return this.cleanupAfterRequestFailure(
|
|
13941
|
-
|
|
13942
|
-
|
|
13943
|
-
|
|
13944
|
-
|
|
15087
|
+
return this.cleanupAfterRequestFailure(
|
|
15088
|
+
error,
|
|
15089
|
+
async () => {
|
|
15090
|
+
if (this.sessions.get(config.getSessionId())?.getConfig() !== config) {
|
|
15091
|
+
await this.cleanupUnstoredConfig(config);
|
|
15092
|
+
}
|
|
15093
|
+
},
|
|
15094
|
+
sessionId
|
|
15095
|
+
);
|
|
13945
15096
|
}
|
|
13946
|
-
return
|
|
13947
|
-
const response = {
|
|
13948
|
-
modes: this.buildModesData(config),
|
|
13949
|
-
models: this.buildAvailableModels(config),
|
|
13950
|
-
configOptions: this.buildConfigOptions(config),
|
|
13951
|
-
...sessionData?.artifactSnapshot ? { artifactSnapshot: sessionData.artifactSnapshot } : {}
|
|
13952
|
-
};
|
|
13953
|
-
if (!replayEnvelope) return response;
|
|
13954
|
-
return {
|
|
13955
|
-
...response,
|
|
13956
|
-
_meta: {
|
|
13957
|
-
[LOAD_REPLAY_META_KEY]: replayEnvelope
|
|
13958
|
-
}
|
|
13959
|
-
};
|
|
13960
|
-
});
|
|
15097
|
+
return response;
|
|
13961
15098
|
} finally {
|
|
13962
15099
|
releaseStartingSessionId();
|
|
13963
15100
|
}
|
|
@@ -13995,13 +15132,14 @@ var QwenAgent = class {
|
|
|
13995
15132
|
return this.withLiveSessionRestore(
|
|
13996
15133
|
sessionId,
|
|
13997
15134
|
liveSession,
|
|
13998
|
-
|
|
15135
|
+
RESUME_RESTORE_OPTIONS,
|
|
15136
|
+
async (config, projection) => profiler.timeSync(
|
|
13999
15137
|
"response_build",
|
|
14000
15138
|
() => ({
|
|
14001
15139
|
modes: this.buildModesData(config),
|
|
14002
15140
|
models: this.buildAvailableModels(config),
|
|
14003
15141
|
configOptions: this.buildConfigOptions(config),
|
|
14004
|
-
...
|
|
15142
|
+
...projection?.artifactSnapshot ? { artifactSnapshot: projection.artifactSnapshot } : {}
|
|
14005
15143
|
})
|
|
14006
15144
|
)
|
|
14007
15145
|
);
|
|
@@ -14038,9 +15176,14 @@ var QwenAgent = class {
|
|
|
14038
15176
|
settings,
|
|
14039
15177
|
sessionSource,
|
|
14040
15178
|
sessionId,
|
|
14041
|
-
true
|
|
15179
|
+
true,
|
|
15180
|
+
{},
|
|
15181
|
+
void 0,
|
|
15182
|
+
RESUME_RESTORE_OPTIONS
|
|
14042
15183
|
)
|
|
14043
15184
|
);
|
|
15185
|
+
const projection = config.consumeSessionRestoreProjection?.();
|
|
15186
|
+
let response;
|
|
14044
15187
|
try {
|
|
14045
15188
|
await profiler.time("auth", () => this.ensureAuthenticated(config));
|
|
14046
15189
|
profiler.timeSync(
|
|
@@ -14049,43 +15192,51 @@ var QwenAgent = class {
|
|
|
14049
15192
|
);
|
|
14050
15193
|
await profiler.time(
|
|
14051
15194
|
"session_register",
|
|
14052
|
-
() => this.createAndStoreSession(
|
|
14053
|
-
|
|
14054
|
-
|
|
14055
|
-
|
|
14056
|
-
|
|
14057
|
-
|
|
14058
|
-
|
|
14059
|
-
|
|
14060
|
-
|
|
14061
|
-
|
|
15195
|
+
() => this.createAndStoreSession(config, settings, void 0, {
|
|
15196
|
+
enableLiveScreenContext: isCompatibleLiveSessionSource(
|
|
15197
|
+
sessionSource ?? {}
|
|
15198
|
+
),
|
|
15199
|
+
replayHistory: false,
|
|
15200
|
+
beforeSessionCreate: /* @__PURE__ */ __name(() => {
|
|
15201
|
+
response = profiler.timeSync("response_build", () => ({
|
|
15202
|
+
modes: this.buildModesData(config),
|
|
15203
|
+
models: this.buildAvailableModels(config),
|
|
15204
|
+
configOptions: this.buildConfigOptions(config),
|
|
15205
|
+
...projection?.runtime.artifactSnapshot ? { artifactSnapshot: projection.runtime.artifactSnapshot } : {}
|
|
15206
|
+
}));
|
|
15207
|
+
}, "beforeSessionCreate"),
|
|
15208
|
+
primeSession: /* @__PURE__ */ __name((createdSession) => {
|
|
15209
|
+
profiler.timeSync("runtime_initialize", () => {
|
|
15210
|
+
if (!projection) return;
|
|
15211
|
+
createdSession.primeTurnState(
|
|
15212
|
+
projection.runtime.initialTurn,
|
|
15213
|
+
projection.runtime.backgroundNotificationTaskIds
|
|
15214
|
+
);
|
|
15215
|
+
});
|
|
15216
|
+
}, "primeSession"),
|
|
15217
|
+
beforeStartPostReplayServices: /* @__PURE__ */ __name(async (createdSession) => {
|
|
15218
|
+
await profiler.time("post_replay_services", async () => {
|
|
14062
15219
|
await this.#restoreWorktreeOnResume(config, createdSession);
|
|
14063
15220
|
await this.#restoreBackgroundAgentsOnResume(
|
|
14064
15221
|
config,
|
|
14065
15222
|
createdSession
|
|
14066
15223
|
);
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
)
|
|
15224
|
+
});
|
|
15225
|
+
}, "beforeStartPostReplayServices")
|
|
15226
|
+
})
|
|
14071
15227
|
);
|
|
14072
15228
|
} catch (error) {
|
|
14073
|
-
return this.cleanupAfterRequestFailure(
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
15229
|
+
return this.cleanupAfterRequestFailure(
|
|
15230
|
+
error,
|
|
15231
|
+
async () => {
|
|
15232
|
+
if (this.sessions.get(config.getSessionId())?.getConfig() !== config) {
|
|
15233
|
+
await this.cleanupUnstoredConfig(config);
|
|
15234
|
+
}
|
|
15235
|
+
},
|
|
15236
|
+
sessionId
|
|
15237
|
+
);
|
|
14078
15238
|
}
|
|
14079
|
-
|
|
14080
|
-
return profiler.timeSync(
|
|
14081
|
-
"response_build",
|
|
14082
|
-
() => ({
|
|
14083
|
-
modes: this.buildModesData(config),
|
|
14084
|
-
models: this.buildAvailableModels(config),
|
|
14085
|
-
configOptions: this.buildConfigOptions(config),
|
|
14086
|
-
...sessionData?.artifactSnapshot ? { artifactSnapshot: sessionData.artifactSnapshot } : {}
|
|
14087
|
-
})
|
|
14088
|
-
);
|
|
15239
|
+
return response;
|
|
14089
15240
|
} finally {
|
|
14090
15241
|
releaseStartingSessionId();
|
|
14091
15242
|
}
|
|
@@ -14111,48 +15262,6 @@ var QwenAgent = class {
|
|
|
14111
15262
|
await config.loadPausedBackgroundAgents(config.getSessionId());
|
|
14112
15263
|
session.pendingRecoveredAgentsNotice = config.consumePendingRecoveredAgentsNotice();
|
|
14113
15264
|
}
|
|
14114
|
-
/**
|
|
14115
|
-
* Re-registers the `/goal` Stop hook when a resumed transcript ends on an
|
|
14116
|
-
* unsatisfied goal — the daemon counterpart of the TUI's resume restore.
|
|
14117
|
-
* Without this the goal loop silently dies whenever a session is reloaded or
|
|
14118
|
-
* `qwen serve` restarts, even though the transcript still shows it as active.
|
|
14119
|
-
*
|
|
14120
|
-
* The `addItem` bridge that `restoreGoalFromHistory` takes in the TUI is not
|
|
14121
|
-
* used here — the daemon's terminal card goes out over the wire, not into an
|
|
14122
|
-
* Ink history. But restore reaches `unregisterGoalHook` on every path,
|
|
14123
|
-
* including the one where there was nothing to restore, and that clears the
|
|
14124
|
-
* observer the `Session` constructor installed. So it is put back afterwards,
|
|
14125
|
-
* unconditionally: without it a restored goal that later achieves or fails
|
|
14126
|
-
* emits no terminal update and persists no terminal card, and the next reload
|
|
14127
|
-
* revives a goal that already finished.
|
|
14128
|
-
*
|
|
14129
|
-
* Best-effort: a failed restore must not block session load.
|
|
14130
|
-
*/
|
|
14131
|
-
#restoreGoalOnResume(config, session) {
|
|
14132
|
-
try {
|
|
14133
|
-
const records = config.getResumedSessionData()?.conversation.messages;
|
|
14134
|
-
if (!records?.length) return;
|
|
14135
|
-
const restored = restoreGoalFromHistory(
|
|
14136
|
-
collectGoalStatusItemsFromRecords(records),
|
|
14137
|
-
config
|
|
14138
|
-
);
|
|
14139
|
-
if (restored.restored) {
|
|
14140
|
-
debugLogger8.info(
|
|
14141
|
-
`ACP goal restored sessionId=${config.getSessionId()} condition=${restored.condition}`
|
|
14142
|
-
);
|
|
14143
|
-
} else if (restored.blockedBy && restored.blockedBy !== "condition-invalid") {
|
|
14144
|
-
writeStderrLineSafe(
|
|
14145
|
-
`qwen: not restoring the active goal for session ${config.getSessionId()} (${restored.blockedBy}).`
|
|
14146
|
-
);
|
|
14147
|
-
}
|
|
14148
|
-
} catch (error) {
|
|
14149
|
-
writeStderrLineSafe(
|
|
14150
|
-
`qwen: goal restore failed for session ${config.getSessionId()}: ${error}`
|
|
14151
|
-
);
|
|
14152
|
-
} finally {
|
|
14153
|
-
session.installGoalTerminalObserver();
|
|
14154
|
-
}
|
|
14155
|
-
}
|
|
14156
15265
|
async unstable_listSessions(params) {
|
|
14157
15266
|
const cwd = params.cwd || process.cwd();
|
|
14158
15267
|
const numericCursor = parseAcpSessionListCursor(params.cursor);
|
|
@@ -14233,6 +15342,29 @@ var QwenAgent = class {
|
|
|
14233
15342
|
break;
|
|
14234
15343
|
}
|
|
14235
15344
|
case "reasoning_effort": {
|
|
15345
|
+
const modelReasoning = this.getModelReasoningConfiguration(
|
|
15346
|
+
session.getConfig()
|
|
15347
|
+
);
|
|
15348
|
+
if (modelReasoning) {
|
|
15349
|
+
const selected = value === ACP_REASONING_EFFORT_NONE ? ACP_REASONING_EFFORT_NONE : modelReasoning.efforts.find((effort2) => effort2 === value);
|
|
15350
|
+
if (!selected) {
|
|
15351
|
+
throw RequestError.invalidParams(
|
|
15352
|
+
void 0,
|
|
15353
|
+
`Unknown reasoning effort: ${value}. Choose one of: ${ACP_REASONING_EFFORT_NONE}, ${modelReasoning.efforts.join(", ")}`
|
|
15354
|
+
);
|
|
15355
|
+
}
|
|
15356
|
+
const generation = session.getConfig().getContentGeneratorConfig();
|
|
15357
|
+
if (selected === ACP_REASONING_EFFORT_NONE) {
|
|
15358
|
+
generation.reasoning = false;
|
|
15359
|
+
} else {
|
|
15360
|
+
const current = generation.reasoning;
|
|
15361
|
+
generation.reasoning = {
|
|
15362
|
+
...current || {},
|
|
15363
|
+
effort: selected
|
|
15364
|
+
};
|
|
15365
|
+
}
|
|
15366
|
+
break;
|
|
15367
|
+
}
|
|
14236
15368
|
const effort = value === ACP_REASONING_EFFORT_DEFAULT ? void 0 : REASONING_EFFORT_TIERS.find((tier) => tier === value);
|
|
14237
15369
|
if (value !== ACP_REASONING_EFFORT_DEFAULT && effort === void 0) {
|
|
14238
15370
|
throw RequestError.invalidParams(
|
|
@@ -14268,9 +15400,24 @@ var QwenAgent = class {
|
|
|
14268
15400
|
const meta = params._meta && typeof params._meta === "object" ? { ...params._meta } : {};
|
|
14269
15401
|
const suppliedContext = meta[INVOCATION_CONTEXT_META_KEY];
|
|
14270
15402
|
const suppliedModelPrompt = meta[DAEMON_MODEL_PROMPT_META_KEY];
|
|
15403
|
+
const suppliedPromptDisplayText = meta[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY];
|
|
15404
|
+
const suppliedChannelPrompt = meta[CHANNEL_PROMPT_META_KEY];
|
|
15405
|
+
const suppliedChannelDelivery = meta[DAEMON_CHANNEL_DELIVERY_META_KEY];
|
|
14271
15406
|
delete meta[INVOCATION_CONTEXT_META_KEY];
|
|
14272
15407
|
delete meta[DAEMON_MODEL_PROMPT_META_KEY];
|
|
14273
15408
|
delete meta[PRIVATE_PARENT_CAPABILITY_META_KEY];
|
|
15409
|
+
delete meta[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY];
|
|
15410
|
+
delete meta[CHANNEL_PROMPT_META_KEY];
|
|
15411
|
+
delete meta[DAEMON_CHANNEL_DELIVERY_META_KEY];
|
|
15412
|
+
if (this.privateParentState === "trusted" && typeof suppliedPromptDisplayText === "string") {
|
|
15413
|
+
meta[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY] = suppliedPromptDisplayText;
|
|
15414
|
+
}
|
|
15415
|
+
if (this.privateParentState === "trusted" && suppliedChannelPrompt === true) {
|
|
15416
|
+
meta[CHANNEL_PROMPT_META_KEY] = true;
|
|
15417
|
+
}
|
|
15418
|
+
if (this.privateParentState === "trusted" && suppliedChannelDelivery !== void 0) {
|
|
15419
|
+
meta[DAEMON_CHANNEL_DELIVERY_META_KEY] = suppliedChannelDelivery;
|
|
15420
|
+
}
|
|
14274
15421
|
if (Object.keys(meta).length > 0) {
|
|
14275
15422
|
sanitizedParams._meta = meta;
|
|
14276
15423
|
} else {
|
|
@@ -16627,7 +17774,7 @@ var QwenAgent = class {
|
|
|
16627
17774
|
);
|
|
16628
17775
|
case SERVE_CONTROL_EXT_METHODS.workspaceMemoryRememberAvailability:
|
|
16629
17776
|
return {
|
|
16630
|
-
available: !this.managedToolInvocationGuard && this.config.isManagedMemoryAvailable()
|
|
17777
|
+
available: !(this.managedToolInvocationGuard && this.externalToolGuardProviderAttached) && this.config.isManagedMemoryAvailable()
|
|
16631
17778
|
};
|
|
16632
17779
|
case SERVE_CONTROL_EXT_METHODS.workspaceMemoryRemember: {
|
|
16633
17780
|
this.rejectUnsupportedGuardedHiddenAgent(
|
|
@@ -18184,7 +19331,7 @@ var QwenAgent = class {
|
|
|
18184
19331
|
return { sessionId, answer: result.text || null };
|
|
18185
19332
|
}
|
|
18186
19333
|
case SERVE_CONTROL_EXT_METHODS.sessionForkAgent: {
|
|
18187
|
-
if (this.managedToolInvocationGuard) {
|
|
19334
|
+
if (this.managedToolInvocationGuard && this.externalToolGuardProviderAttached) {
|
|
18188
19335
|
throw RequestError.invalidParams(
|
|
18189
19336
|
void 0,
|
|
18190
19337
|
"Managed external tool guard v1 does not support /fork."
|
|
@@ -18390,21 +19537,34 @@ ${outputText}
|
|
|
18390
19537
|
}
|
|
18391
19538
|
const session = this.sessionOrThrow(sessionId);
|
|
18392
19539
|
const config = session.getConfig();
|
|
18393
|
-
|
|
18394
|
-
|
|
18395
|
-
|
|
18396
|
-
|
|
18397
|
-
|
|
18398
|
-
|
|
18399
|
-
|
|
18400
|
-
|
|
19540
|
+
let runtime;
|
|
19541
|
+
try {
|
|
19542
|
+
runtime = await config.getGoalRuntimeReady();
|
|
19543
|
+
} catch (error) {
|
|
19544
|
+
if (!(error instanceof GoalPersistenceUnavailableError)) throw error;
|
|
19545
|
+
debugLogger8.info(
|
|
19546
|
+
`sessionGoalClear sessionId=${sessionId} cleared=false (goal persistence unavailable)`
|
|
19547
|
+
);
|
|
19548
|
+
return {
|
|
19549
|
+
cleared: false,
|
|
19550
|
+
condition: void 0,
|
|
19551
|
+
snapshot: emptyGoalSnapshot()
|
|
19552
|
+
};
|
|
18401
19553
|
}
|
|
19554
|
+
const before = runtime.getSnapshot();
|
|
19555
|
+
const goal = before.goal;
|
|
19556
|
+
const response = goal ? await runtime.dispatch({
|
|
19557
|
+
action: "clear",
|
|
19558
|
+
expectedGoalId: goal.goalId,
|
|
19559
|
+
expectedRevision: goal.revision
|
|
19560
|
+
}) : { snapshot: before };
|
|
18402
19561
|
debugLogger8.info(
|
|
18403
|
-
`sessionGoalClear sessionId=${sessionId} cleared=${!!
|
|
19562
|
+
`sessionGoalClear sessionId=${sessionId} cleared=${!!goal} objective=${goal?.objective ?? "(none)"}`
|
|
18404
19563
|
);
|
|
18405
19564
|
return {
|
|
18406
|
-
cleared: !!
|
|
18407
|
-
condition:
|
|
19565
|
+
cleared: !!goal,
|
|
19566
|
+
condition: goal?.objective,
|
|
19567
|
+
snapshot: response.snapshot
|
|
18408
19568
|
};
|
|
18409
19569
|
}
|
|
18410
19570
|
case SERVE_CONTROL_EXT_METHODS.sessionGoalGet: {
|
|
@@ -18415,16 +19575,22 @@ ${outputText}
|
|
|
18415
19575
|
"Invalid or missing sessionId"
|
|
18416
19576
|
);
|
|
18417
19577
|
}
|
|
18418
|
-
this.sessionOrThrow(sessionId);
|
|
18419
|
-
|
|
19578
|
+
const session = this.sessionOrThrow(sessionId);
|
|
19579
|
+
let snapshot;
|
|
19580
|
+
try {
|
|
19581
|
+
snapshot = (await session.getConfig().getGoalRuntimeReady()).getSnapshot();
|
|
19582
|
+
} catch (error) {
|
|
19583
|
+
if (!(error instanceof GoalPersistenceUnavailableError)) throw error;
|
|
19584
|
+
snapshot = emptyGoalSnapshot();
|
|
19585
|
+
}
|
|
19586
|
+
const activeGoal = snapshot.goal?.status === "active" ? snapshot.goal : null;
|
|
18420
19587
|
return {
|
|
18421
|
-
|
|
18422
|
-
|
|
18423
|
-
|
|
18424
|
-
|
|
18425
|
-
|
|
18426
|
-
|
|
18427
|
-
...active.lastReason !== void 0 ? { lastReason: active.lastReason } : {}
|
|
19588
|
+
snapshot,
|
|
19589
|
+
active: activeGoal ? {
|
|
19590
|
+
condition: activeGoal.objective,
|
|
19591
|
+
iterations: activeGoal.turnCount,
|
|
19592
|
+
setAt: activeGoal.createdAt,
|
|
19593
|
+
...activeGoal.lastReason !== void 0 ? { lastReason: activeGoal.lastReason } : {}
|
|
18428
19594
|
} : null
|
|
18429
19595
|
};
|
|
18430
19596
|
}
|
|
@@ -19412,7 +20578,7 @@ ${outputText}
|
|
|
19412
20578
|
throw error;
|
|
19413
20579
|
}
|
|
19414
20580
|
}
|
|
19415
|
-
async newSessionConfig(cwd, mcpServers, settings, sessionSource, sessionId, resume, initializeOptions = {}, chatRecording) {
|
|
20581
|
+
async newSessionConfig(cwd, mcpServers, settings, sessionSource, sessionId, resume, initializeOptions = {}, chatRecording, restoreOptions) {
|
|
19416
20582
|
try {
|
|
19417
20583
|
this.assertManagedSessionAdmission();
|
|
19418
20584
|
return await this.runWithPinnedRuntimeBaseDir(settings, cwd, async () => {
|
|
@@ -19428,7 +20594,8 @@ ${outputText}
|
|
|
19428
20594
|
sessionId,
|
|
19429
20595
|
resume,
|
|
19430
20596
|
initializeOptions,
|
|
19431
|
-
chatRecording
|
|
20597
|
+
chatRecording,
|
|
20598
|
+
restoreOptions
|
|
19432
20599
|
);
|
|
19433
20600
|
});
|
|
19434
20601
|
} catch (error) {
|
|
@@ -19444,10 +20611,10 @@ ${outputText}
|
|
|
19444
20611
|
errorKind: writerError.errorKind
|
|
19445
20612
|
});
|
|
19446
20613
|
}
|
|
19447
|
-
throw error;
|
|
20614
|
+
throw sessionId && restoreOptions ? mapSessionRestoreRequestError(error, sessionId) : error;
|
|
19448
20615
|
}
|
|
19449
20616
|
}
|
|
19450
|
-
async newSessionConfigInRuntimeContext(cwd, mcpServers, settings, sessionSource, sessionId, resume, initializeOptions = {}, chatRecording) {
|
|
20617
|
+
async newSessionConfigInRuntimeContext(cwd, mcpServers, settings, sessionSource, sessionId, resume, initializeOptions = {}, chatRecording, restoreOptions) {
|
|
19451
20618
|
const sessionMcpServers = {};
|
|
19452
20619
|
for (const server of mcpServers) {
|
|
19453
20620
|
const stdioServer = toStdioServer(server);
|
|
@@ -19545,7 +20712,19 @@ ${outputText}
|
|
|
19545
20712
|
// not process.exit(1) the shared ACP child and every session on its
|
|
19546
20713
|
// channel. newSessionConfig maps the throw to a RequestError.
|
|
19547
20714
|
true,
|
|
19548
|
-
this.managedToolInvocationGuard ? {
|
|
20715
|
+
this.managedToolInvocationGuard || restoreOptions ? {
|
|
20716
|
+
...this.managedToolInvocationGuard ? { toolInvocationGuard: this.managedToolInvocationGuard } : {},
|
|
20717
|
+
...restoreOptions && sessionId ? {
|
|
20718
|
+
sessionRestore: {
|
|
20719
|
+
projectionSource: /* @__PURE__ */ __name((restoreSessionId) => new SessionService(cwd, {
|
|
20720
|
+
runtimeBaseDir: Storage.getRuntimeBaseDir()
|
|
20721
|
+
}).readRestoreProjection(
|
|
20722
|
+
restoreSessionId,
|
|
20723
|
+
restoreOptions
|
|
20724
|
+
), "projectionSource")
|
|
20725
|
+
}
|
|
20726
|
+
} : {}
|
|
20727
|
+
} : void 0
|
|
19549
20728
|
);
|
|
19550
20729
|
if (sessionSource) {
|
|
19551
20730
|
config.setSessionSource(sessionSource.sourceType, sessionSource.sourceId);
|
|
@@ -19682,6 +20861,16 @@ ${outputText}
|
|
|
19682
20861
|
{ errorKind: "session_id_conflict", sessionId }
|
|
19683
20862
|
);
|
|
19684
20863
|
}
|
|
20864
|
+
await options.prepareBeforeSessionCreate?.();
|
|
20865
|
+
this.assertManagedSessionAdmission();
|
|
20866
|
+
if (this.sessions.has(sessionId)) {
|
|
20867
|
+
throw new RequestError(
|
|
20868
|
+
ACP_ERROR_CODES.INVALID_PARAMS,
|
|
20869
|
+
`Session ${sessionId} is already active.`,
|
|
20870
|
+
{ errorKind: "session_id_conflict", sessionId }
|
|
20871
|
+
);
|
|
20872
|
+
}
|
|
20873
|
+
options.beforeSessionCreate?.();
|
|
19685
20874
|
const session = new Session(
|
|
19686
20875
|
sessionId,
|
|
19687
20876
|
config,
|
|
@@ -19689,10 +20878,14 @@ ${outputText}
|
|
|
19689
20878
|
settings,
|
|
19690
20879
|
() => this.activeWorkReporter?.notifyChanged()
|
|
19691
20880
|
);
|
|
19692
|
-
|
|
19693
|
-
this.activeWorkReporter?.notifyChanged();
|
|
19694
|
-
this.initializingConfigs.delete(config);
|
|
20881
|
+
let published = false;
|
|
19695
20882
|
try {
|
|
20883
|
+
options.primeSession?.(session);
|
|
20884
|
+
config.hydrateSessionRestoreFileHistory?.();
|
|
20885
|
+
this.sessions.set(sessionId, session);
|
|
20886
|
+
published = true;
|
|
20887
|
+
this.activeWorkReporter?.notifyChanged();
|
|
20888
|
+
this.initializingConfigs.delete(config);
|
|
19696
20889
|
if (options.enableLiveScreenContext) {
|
|
19697
20890
|
await session.enableLiveScreenContext();
|
|
19698
20891
|
}
|
|
@@ -19707,15 +20900,35 @@ ${outputText}
|
|
|
19707
20900
|
sessionData.conversation.messages,
|
|
19708
20901
|
sessionData.historyGaps
|
|
19709
20902
|
);
|
|
20903
|
+
try {
|
|
20904
|
+
await session.publishRecoveredGoalState(
|
|
20905
|
+
sessionData.conversation.messages
|
|
20906
|
+
);
|
|
20907
|
+
} catch (error) {
|
|
20908
|
+
debugLogger8.debug(
|
|
20909
|
+
`Failed to publish recovered Goal state: ${error instanceof Error ? error.message : String(error)}`
|
|
20910
|
+
);
|
|
20911
|
+
}
|
|
19710
20912
|
}
|
|
19711
20913
|
await options.beforeStartPostReplayServices?.(session);
|
|
19712
20914
|
session.installRewriter();
|
|
20915
|
+
config.finalizeSessionRestore?.();
|
|
19713
20916
|
session.startCronScheduler();
|
|
19714
20917
|
setTimeout(() => {
|
|
19715
20918
|
void session.sendAvailableCommandsUpdate();
|
|
19716
20919
|
}, 0);
|
|
19717
20920
|
return session;
|
|
19718
20921
|
} catch (error) {
|
|
20922
|
+
if (!published) {
|
|
20923
|
+
try {
|
|
20924
|
+
session.dispose();
|
|
20925
|
+
} catch (disposeError) {
|
|
20926
|
+
debugLogger8.warn(
|
|
20927
|
+
`Failed to dispose unpublished session ${sessionId}: ${disposeError instanceof Error ? disposeError.message : String(disposeError)}`
|
|
20928
|
+
);
|
|
20929
|
+
}
|
|
20930
|
+
throw error;
|
|
20931
|
+
}
|
|
19719
20932
|
try {
|
|
19720
20933
|
await this.discardStoredSessionIfCurrent(sessionId, session, {
|
|
19721
20934
|
shutdownConfig: false
|
|
@@ -19807,13 +21020,41 @@ ${outputText}
|
|
|
19807
21020
|
currentValue: currentModelId,
|
|
19808
21021
|
options: configModelOptions
|
|
19809
21022
|
};
|
|
19810
|
-
const
|
|
21023
|
+
const modelReasoning = this.getModelReasoningConfiguration(config);
|
|
21024
|
+
const currentModelEffort = config.getReasoningEffort?.();
|
|
21025
|
+
const reasoningEffortConfigOption = modelReasoning ? {
|
|
21026
|
+
id: "reasoning_effort",
|
|
21027
|
+
name: "Reasoning effort",
|
|
21028
|
+
description: `Thinking and reasoning effort for ${rawCurrentModelId}`,
|
|
21029
|
+
category: "thought_level",
|
|
21030
|
+
type: "select",
|
|
21031
|
+
currentValue: config.getContentGeneratorConfig().reasoning === false ? ACP_REASONING_EFFORT_NONE : modelReasoning.efforts.find(
|
|
21032
|
+
(effort) => effort === currentModelEffort
|
|
21033
|
+
) ?? modelReasoning.defaultEffort,
|
|
21034
|
+
options: [
|
|
21035
|
+
{
|
|
21036
|
+
value: ACP_REASONING_EFFORT_NONE,
|
|
21037
|
+
name: "Thinking off",
|
|
21038
|
+
description: "Disable thinking for this session"
|
|
21039
|
+
},
|
|
21040
|
+
...modelReasoning.efforts.map((effort) => ({
|
|
21041
|
+
value: effort,
|
|
21042
|
+
name: ACP_REASONING_EFFORT_NAMES[effort],
|
|
21043
|
+
description: "Apply this effort to the next request"
|
|
21044
|
+
}))
|
|
21045
|
+
],
|
|
21046
|
+
_meta: {
|
|
21047
|
+
"qwenCode/reasoning": {
|
|
21048
|
+
defaultEffort: modelReasoning.defaultEffort
|
|
21049
|
+
}
|
|
21050
|
+
}
|
|
21051
|
+
} : {
|
|
19811
21052
|
id: "reasoning_effort",
|
|
19812
21053
|
name: "Reasoning effort",
|
|
19813
21054
|
description: "How hard reasoning-capable models should think",
|
|
19814
21055
|
category: "thought_level",
|
|
19815
21056
|
type: "select",
|
|
19816
|
-
currentValue:
|
|
21057
|
+
currentValue: currentModelEffort ?? ACP_REASONING_EFFORT_DEFAULT,
|
|
19817
21058
|
options: [
|
|
19818
21059
|
{
|
|
19819
21060
|
value: ACP_REASONING_EFFORT_DEFAULT,
|
|
@@ -19829,6 +21070,14 @@ ${outputText}
|
|
|
19829
21070
|
};
|
|
19830
21071
|
return [modeConfigOption, modelConfigOption, reasoningEffortConfigOption];
|
|
19831
21072
|
}
|
|
21073
|
+
getModelReasoningConfiguration(config) {
|
|
21074
|
+
if (config.getActiveRuntimeModelSnapshot?.() || config.getReasoningEffortOverride?.() || config.getContentGeneratorConfig().thinkingMandatory === true) {
|
|
21075
|
+
return void 0;
|
|
21076
|
+
}
|
|
21077
|
+
const reasoning = getModelConfiguration(config.getModel())?.reasoning;
|
|
21078
|
+
const currentEffort = config.getReasoningEffort?.();
|
|
21079
|
+
return reasoning?.thinking && (!currentEffort || reasoning.efforts.includes(currentEffort)) ? reasoning : void 0;
|
|
21080
|
+
}
|
|
19832
21081
|
buildSelectableModelOptions(config) {
|
|
19833
21082
|
const currentAuthType = config.getAuthType();
|
|
19834
21083
|
return buildAcpModelOptions(
|