@qwen-code/qwen-code 0.19.12 → 0.20.0-nightly.20260721.cda0e0348
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/qc-helper/docs/configuration/settings.md +1 -1
- package/bundled/qc-helper/docs/features/commands.md +54 -0
- package/bundled/qc-helper/docs/integration-github-action.md +1 -1
- package/bundled/qc-helper/docs/qwen-serve.md +44 -6
- package/bundled/review/DESIGN.md +2 -2
- package/bundled/review/SKILL.md +13 -9
- package/chunks/{MaxSizedBox-QOXLJGAF.js → MaxSizedBox-EE76OHAP.js} +30 -27
- package/chunks/{StandaloneSessionPicker-FLV6CGYJ.js → StandaloneSessionPicker-WZH4PC3K.js} +50 -45
- package/chunks/{acpAgent-OB2CTF3P.js → acpAgent-2ATF4LMP.js} +437 -156
- package/chunks/{agent-CKSI7BTR.js → agent-KTOOFWMV.js} +22 -22
- package/chunks/{agent-headless-U36LIYTU.js → agent-headless-WVJCQ27D.js} +22 -22
- package/chunks/{anthropicContentGenerator-ZZRGFEES.js → anthropicContentGenerator-W4JLNYWQ.js} +6 -5
- package/chunks/{artifact-tool-PHO5XEGZ.js → artifact-tool-WBCAMD3O.js} +2 -2
- package/chunks/{askUserQuestion-CEPBT47X.js → askUserQuestion-6DZC4UV5.js} +2 -2
- package/chunks/{bridge-AIKTINJG.js → bridge-T4TLAZSJ.js} +25 -25
- package/chunks/build-SSCNEHZZ.js +62 -0
- package/chunks/{ca-2SL2BXTK.js → ca-ISKASTR5.js} +606 -200
- package/chunks/{channel-worker-group-NEUVTPB2.js → channel-worker-group-QZV2SP5U.js} +4 -4
- package/chunks/{channel-worker-manager-7CQVOVWV.js → channel-worker-manager-3GMAU45H.js} +4 -4
- package/chunks/{channel-worker-supervisor-3BU2KNCZ.js → channel-worker-supervisor-QCXSXCRY.js} +3 -3
- package/chunks/{chunk-6ETOSWAO.js → chunk-246TW4IX.js} +3 -3
- package/chunks/{chunk-2CCDMJM7.js → chunk-25Y6JSH2.js} +3 -3
- package/chunks/{chunk-XSEWNUMZ.js → chunk-2CWOJ2FA.js} +8 -8
- package/chunks/{chunk-UZC5VPOJ.js → chunk-2GFRA3MN.js} +3 -3
- package/chunks/chunk-2GOPPEHK.js +442 -0
- package/chunks/{chunk-MRE77ST5.js → chunk-2ITGJJE2.js} +69 -2216
- package/chunks/{chunk-BABX5XRO.js → chunk-2LI23QA6.js} +1 -1
- package/chunks/{chunk-EFAXBOQO.js → chunk-32F7BZSK.js} +7 -7
- package/chunks/chunk-43T5WDQ7.js +127 -0
- package/chunks/{chunk-DJ4VHAFJ.js → chunk-4CWPMWCD.js} +7 -3
- package/chunks/{chunk-GMUPIMHF.js → chunk-4RA7PWIY.js} +3 -3
- package/chunks/{chunk-6IITZE7O.js → chunk-5JX5EWR5.js} +7 -7
- package/chunks/{chunk-OBSLEYCD.js → chunk-5PZ6R37W.js} +29 -2
- package/chunks/{chunk-HTHUX2T5.js → chunk-5QWWOFGG.js} +0 -1
- package/chunks/{chunk-3DJY4IFO.js → chunk-5SCI6E3E.js} +1 -1
- package/chunks/{chunk-GSPWDTYY.js → chunk-5WG2K5RH.js} +53 -16
- package/chunks/{chunk-NPMVLWYL.js → chunk-5YVZ2XLV.js} +6 -6
- package/chunks/{chunk-TKASNYDS.js → chunk-6DHWO5ZF.js} +3 -3
- package/chunks/{chunk-4CHDYDG3.js → chunk-6EFTQYW7.js} +1 -1
- package/chunks/{chunk-RKUMFUFM.js → chunk-6MC5ASQK.js} +4 -4
- package/chunks/{chunk-HZ4M2UQD.js → chunk-6RVJRVQR.js} +1 -1
- package/chunks/{chunk-W6CQPLWM.js → chunk-6ZBPS62S.js} +1 -1
- package/chunks/chunk-7KGXAXF7.js +114 -0
- package/chunks/{chunk-PK7COE5O.js → chunk-ABIL4ZQU.js} +1 -1
- package/chunks/{chunk-OEHCAWUA.js → chunk-ACW3VNUE.js} +2 -2
- package/chunks/{chunk-APOFULHK.js → chunk-AWVS63WA.js} +7 -6
- package/chunks/{chunk-KGWA7XYL.js → chunk-AY3CSB6F.js} +6 -226
- package/chunks/{chunk-XAAEDML2.js → chunk-AYCDXHZB.js} +1 -1
- package/chunks/{chunk-42VIHAYT.js → chunk-B452RETY.js} +1 -1
- package/chunks/{chunk-VAJS2E2D.js → chunk-BDBMYST4.js} +1 -1
- package/chunks/{chunk-5N7M4XYN.js → chunk-BUKOHGBE.js} +5 -5
- package/chunks/{chunk-F2RR4HO2.js → chunk-BVLROR2T.js} +1 -1
- package/chunks/{chunk-WIYV7CSF.js → chunk-BWK3FX3K.js} +3 -3
- package/chunks/{chunk-UE5TZ55T.js → chunk-C27BYUX6.js} +29 -2
- package/chunks/{chunk-KRMARA3A.js → chunk-CG2HPAVD.js} +29 -13
- package/chunks/{chunk-UOA2IHRI.js → chunk-CPCVCKKF.js} +1 -1
- package/chunks/{chunk-HD6EGS5K.js → chunk-CUJX3F4X.js} +31 -6
- package/chunks/{chunk-4RPARQ5D.js → chunk-D2VIDMVM.js} +2 -2
- package/chunks/{chunk-PUKUUASO.js → chunk-DMRO4GU2.js} +1 -1
- package/chunks/{chunk-64GC5EMF.js → chunk-DZZIOIVF.js} +1 -1
- package/chunks/{chunk-FUSMC3SZ.js → chunk-E5QFCC4X.js} +13 -8
- package/chunks/{chunk-LKR7QQ63.js → chunk-EAUYY7SS.js} +3 -3
- package/chunks/{chunk-NE6HHLL3.js → chunk-EDMGFJ3E.js} +2 -2
- package/chunks/{chunk-J2MKYJKZ.js → chunk-EIAK6Q2B.js} +2 -2
- package/chunks/{chunk-WEPXQKGP.js → chunk-EZVDJFZ7.js} +1 -1
- package/chunks/{chunk-NALRQ3SG.js → chunk-FCUUJKZF.js} +394 -128
- package/chunks/{chunk-4XCVGEEX.js → chunk-FSL5W5TI.js} +3 -3
- package/chunks/{chunk-CHPQFLW6.js → chunk-FYA3Y5JR.js} +5 -5
- package/chunks/{chunk-V4PCIS25.js → chunk-FZVSFBNW.js} +69 -7
- package/chunks/{chunk-4MPYGENG.js → chunk-G45NOBV7.js} +6 -6
- package/chunks/{chunk-OSSDHJDU.js → chunk-G45X5TRN.js} +1 -1
- package/chunks/{chunk-3B6PSWHE.js → chunk-GH7OEOYU.js} +4 -4
- package/chunks/{chunk-KANTXY7B.js → chunk-GKY2OJ7R.js} +2 -2
- package/chunks/chunk-GMGDLUC7.js +37 -0
- package/chunks/{chunk-2476XGOU.js → chunk-GPILFVPY.js} +1 -1
- package/chunks/{chunk-EISVEV45.js → chunk-H24SOJIQ.js} +2 -2
- package/chunks/{chunk-J6NT5YTN.js → chunk-H2XVO6NE.js} +1 -289
- package/chunks/{chunk-QIFTJDBY.js → chunk-IM2A6YO3.js} +1 -1
- package/chunks/{chunk-R3EDIMYZ.js → chunk-IYZENXFW.js} +1 -1
- package/chunks/{chunk-LPHGXXZX.js → chunk-JD3MKVKL.js} +1 -1
- package/chunks/{chunk-NUHSLBJZ.js → chunk-JNWZQ27S.js} +15 -9
- package/chunks/{chunk-ETN2G32U.js → chunk-JPRLCXAO.js} +4 -4
- package/chunks/{chunk-WHQNBBWW.js → chunk-JQMBPGOU.js} +2 -2
- package/chunks/{chunk-5QSVANRT.js → chunk-JR6UJ24K.js} +2 -2
- package/chunks/{chunk-VLHQMOZK.js → chunk-JRW46GQX.js} +3 -3
- package/chunks/{chunk-DUR7BZYK.js → chunk-KRI4VCHX.js} +53 -28
- package/chunks/{chunk-PR5XQ73G.js → chunk-KTNIZG2C.js} +2 -2
- package/chunks/{chunk-QSG4ZFG4.js → chunk-KTUQMDEP.js} +1 -1
- package/chunks/{chunk-HVGJWOR6.js → chunk-L4YSPHR4.js} +2 -2
- package/chunks/{chunk-BEZPRKD3.js → chunk-LC5CAVMS.js} +160 -2
- package/chunks/{chunk-67Q33DQY.js → chunk-LLDGOZMJ.js} +4 -4
- package/chunks/{chunk-UCTCDLDS.js → chunk-LWQ4IAOJ.js} +136 -4
- package/chunks/{chunk-GEHSF7MS.js → chunk-NEEB7UEN.js} +2545 -1974
- package/chunks/{chunk-GCY7QTCE.js → chunk-NO6XTCYT.js} +1822 -424
- package/chunks/{chunk-JCJPZMJV.js → chunk-OOCI5VVU.js} +1 -1
- package/chunks/{chunk-XSPFQQRE.js → chunk-OONJNQ42.js} +3 -3
- package/chunks/{chunk-ANRANWVE.js → chunk-OP4MOGXF.js} +1 -1
- package/chunks/{chunk-GW7BONBU.js → chunk-OV2KB55J.js} +5 -5
- package/chunks/{chunk-CPU6I5YV.js → chunk-P64HXIC5.js} +115 -32
- package/chunks/{chunk-SGPFJMRP.js → chunk-PBATSWUQ.js} +1 -1
- package/chunks/{chunk-GXFYV7MP.js → chunk-PFKNXN67.js} +1106 -592
- package/chunks/{chunk-KNGZ5EYL.js → chunk-PYNCSQSI.js} +198 -120
- package/chunks/{chunk-I7RRHHYG.js → chunk-QKTHJXCS.js} +1 -1
- package/chunks/chunk-QKYTTBYW.js +624 -0
- package/chunks/{chunk-76BFY7AF.js → chunk-QTERJVPZ.js} +1 -6
- package/chunks/{chunk-W4UN42YP.js → chunk-R3VZNHRX.js} +85 -21
- package/chunks/chunk-R5N7NF5D.js +1187 -0
- package/chunks/{chunk-ZSDFNE6Y.js → chunk-RF34V75B.js} +3 -3
- package/chunks/{chunk-HCCR43AY.js → chunk-RFIAR4YL.js} +1 -1
- package/chunks/chunk-RS7MT2QG.js +305 -0
- package/chunks/{chunk-BKNPMEN6.js → chunk-RVLZCXEE.js} +162 -17
- package/chunks/chunk-SV5PQVQE.js +71 -0
- package/chunks/{chunk-3ESL7JXA.js → chunk-U4VGYZN7.js} +3 -3
- package/chunks/{chunk-4CA4WUMS.js → chunk-UEY4AYUL.js} +2 -2
- package/chunks/{chunk-ZGT623SG.js → chunk-USTF7LPI.js} +12 -12
- package/chunks/chunk-V7RNNPGC.js +44 -0
- package/chunks/{chunk-VEFR4XJQ.js → chunk-W3BKN3LO.js} +1 -1
- package/chunks/{chunk-4SJJT466.js → chunk-WQQDJE2P.js} +94 -177
- package/chunks/{chunk-KMJOMWHE.js → chunk-WRRF6TEQ.js} +1 -1
- package/chunks/{chunk-GLH2NTPB.js → chunk-XCHUDLER.js} +1 -1
- package/chunks/{chunk-7SX6WZNO.js → chunk-XVVH63JG.js} +3 -3
- package/chunks/{chunk-N47VAEAJ.js → chunk-XZOBDSDG.js} +2379 -1291
- package/chunks/chunk-YGIUIIIF.js +125 -0
- package/chunks/{chunk-335ECZTA.js → chunk-ZEOZL37W.js} +1 -1
- package/chunks/{computer-use-4PUGCUQK.js → computer-use-M6MGRJF2.js} +22 -22
- package/chunks/{config-utils-6PJUXHLI.js → config-utils-MOGE4EVB.js} +3 -3
- package/chunks/{contextCommand-C57KTWFV.js → contextCommand-HTRJJYNE.js} +25 -26
- package/chunks/{create-sub-session-5Q42XR6I.js → create-sub-session-MB35IHCR.js} +22 -22
- package/chunks/{create-sub-session-DIJOV6HV.js → create-sub-session-P26FE5GG.js} +2 -2
- package/chunks/{cron-create-X462ERYA.js → cron-create-JWFHBDRQ.js} +4 -4
- package/chunks/{cron-delete-SL5UJUM3.js → cron-delete-GDX4E26G.js} +4 -4
- package/chunks/{cron-list-3MD6SVXI.js → cron-list-USMAIWPT.js} +4 -4
- package/chunks/{daemon-ZW6LHOXT.js → daemon-KLPTQIE4.js} +287 -143
- package/chunks/{daemon-status-provider-YPV3UXHT.js → daemon-status-provider-67EKK6S3.js} +29 -29
- package/chunks/{dist-NUXRQHC5.js → dist-OAV7LJGJ.js} +1 -1
- package/chunks/{dist-XLE6ODMB.js → dist-OMW6WDEO.js} +1 -1
- package/chunks/{dist-J2H4KTLB.js → dist-PJLG2XYX.js} +1 -1
- package/chunks/{dist-IEQSDXS7.js → dist-UIFWIFRO.js} +2 -2
- package/chunks/{dist-IGZMVS5R.js → dist-VGJTZL4E.js} +33 -22
- package/chunks/{dist-3DQNQJ6H.js → dist-XBJVSWS2.js} +1 -1
- package/chunks/{earlyInputCapture-5VDWSYAM.js → earlyInputCapture-7QJX25AC.js} +23 -23
- package/chunks/{edit-GORZTX2U.js → edit-BTPQWGAA.js} +23 -23
- package/chunks/{enter-worktree-LJB2AW4L.js → enter-worktree-N3SEYKOO.js} +22 -22
- package/chunks/{enterPlanMode-LIIPP37T.js → enterPlanMode-TN2JV5MY.js} +28 -23
- package/chunks/{environment-HQ2UHJ35.js → environment-HP6RK262.js} +24 -24
- package/chunks/{errors-6JD5VMVQ.js → errors-VHGRDDOQ.js} +24 -24
- package/chunks/{exit-worktree-IEP2WHOV.js → exit-worktree-FI3SQY3U.js} +22 -22
- package/chunks/{exitPlanMode-U5Z6XBLO.js → exitPlanMode-NZWRVIIY.js} +22 -22
- package/chunks/{fast-path-HFKNMP23.js → fast-path-EGP7AXNR.js} +3 -2
- package/chunks/{gemini-C2SCJH3N.js → gemini-AN5YMD5O.js} +70 -68
- package/chunks/{geminiContentGenerator-ADZTXEKV.js → geminiContentGenerator-ABTMU4FE.js} +4 -4
- package/chunks/{glob-GOAPGD6G.js → glob-5YABOPJB.js} +22 -22
- package/chunks/{grep-HZLSTX7D.js → grep-U67FKUJT.js} +22 -22
- package/chunks/{handleAutoUpdate-UF74WGFE.js → handleAutoUpdate-OOKBP5VD.js} +27 -28
- package/chunks/{i18n-FMXIYUOC.js → i18n-GMQV324P.js} +23 -23
- package/chunks/{initializer-ERDBM3DU.js → initializer-NWALZGQ5.js} +28 -28
- package/chunks/{installationInfo-LROMXYLX.js → installationInfo-Y3M433E7.js} +25 -23
- package/chunks/{keychain-token-storage-K23CFKGN.js → keychain-token-storage-DWRJMNH3.js} +2 -2
- package/chunks/{list-6JPJROU5.js → list-CQDDWHTS.js} +30 -30
- package/chunks/{loadedSettingsAdapter-QCWYUBBF.js → loadedSettingsAdapter-I5KG37EI.js} +27 -27
- package/chunks/{loop-wakeup-6H7OENTB.js → loop-wakeup-5GLTUBHA.js} +5 -5
- package/chunks/{ls-APTSOOS5.js → ls-FHBY3Y7I.js} +4 -4
- package/chunks/{lsp-HPACPJAN.js → lsp-B6VMEW6Y.js} +2 -2
- package/chunks/{mcp-3P3KWYWO.js → mcp-24HHCBSP.js} +27 -27
- package/chunks/{monitor-LMYKCF6R.js → monitor-Z7NZNNRC.js} +22 -22
- package/chunks/nonInteractiveCli-GVF2XDJT.js +126 -0
- package/chunks/{notebook-edit-IBEOVZ6A.js → notebook-edit-GFOYAQAZ.js} +23 -23
- package/chunks/{openaiContentGenerator-42PZKET5.js → openaiContentGenerator-XAAYV6WR.js} +11 -11
- package/chunks/{pidfile-VTBDIGOH.js → pidfile-ILI37KRQ.js} +23 -23
- package/chunks/{processUtils-L7ZKOGDG.js → processUtils-LIPJMLVZ.js} +2 -2
- package/chunks/{qwenContentGenerator-VR2CNFGI.js → qwenContentGenerator-DLJ3KKGZ.js} +24 -24
- package/chunks/{qwenOAuth2-6LS2T3Q6.js → qwenOAuth2-J47FU5PW.js} +11 -11
- package/chunks/react-SG7JAQSZ.js +8 -0
- package/chunks/{read-file-VSKOE22I.js → read-file-LCQ2KNNP.js} +8 -8
- package/chunks/{read-mcp-resource-C6NT52T6.js → read-mcp-resource-AKCL7I43.js} +2 -2
- package/chunks/{record-artifact-ENCU7QCL.js → record-artifact-PEUB7727.js} +2 -2
- package/chunks/resumeHistoryUtils-PSCSAKA6.js +78 -0
- package/chunks/{ripGrep-5V5FLW2A.js → ripGrep-Y2XW4EFC.js} +22 -22
- package/chunks/{run-qwen-serve-LSOPP4R2.js → run-qwen-serve-DQ5ZIR36.js} +1459 -148
- package/chunks/{runtime-LT7R4CS5.js → runtime-6MQFF2A6.js} +33 -31
- package/chunks/{scheduler-YOWQ7KZP.js → scheduler-K4S7NY3G.js} +22 -22
- package/chunks/{send-message-5GZ4FX2V.js → send-message-3RHE7HSM.js} +3 -3
- package/chunks/{serve-VWLBXKGK.js → serve-JFAAPC5J.js} +27 -27
- package/chunks/{server-3RW3FYOH.js → server-QB6CHRZN.js} +866 -271
- package/chunks/{session-ZONXFOBQ.js → session-FKPVXAAB.js} +79 -163
- package/chunks/{settings-JC3VC53L.js → settings-CADELKSU.js} +26 -26
- package/chunks/{shell-2NGEMAVM.js → shell-EON6WVVH.js} +22 -22
- package/chunks/{skill-3U2T6H3E.js → skill-FKSYXJ5U.js} +10 -10
- package/chunks/{spawnChannel-QEAUPARQ.js → spawnChannel-VM5IHLJO.js} +24 -24
- package/chunks/{src-75ZPXO7B.js → src-Q4XB6SVD.js} +66 -22
- package/chunks/{standalone-update-UUJWJWYY.js → standalone-update-KGZHPBMA.js} +24 -24
- package/chunks/{startInteractiveUI-V7XISPQ6.js → startInteractiveUI-EYDJIIIZ.js} +5484 -2045
- package/chunks/{syntheticOutput-ULOVVLY4.js → syntheticOutput-FG5PQKIR.js} +3 -3
- package/chunks/{task-create-DUE2PMNI.js → task-create-HX32YXO7.js} +7 -7
- package/chunks/{task-list-WVPNX7BZ.js → task-list-QWSY4ZIU.js} +5 -5
- package/chunks/{task-stop-CPEQWOT6.js → task-stop-GWC6UWAL.js} +2 -2
- package/chunks/{task-update-HY2LNFFB.js → task-update-NCTAB73Q.js} +7 -7
- package/chunks/{team-create-R6AXDYPG.js → team-create-CYP3YKYT.js} +22 -22
- package/chunks/{team-delete-JJV6IUOA.js → team-delete-KK37HTOG.js} +5 -5
- package/chunks/{team-plan-approval-O2ZPPT64.js → team-plan-approval-5LXIFKNV.js} +22 -22
- package/chunks/{theme-manager-YIX2IC2D.js → theme-manager-QOUMDWMP.js} +23 -23
- package/chunks/{todoWrite-JHHIDOIV.js → todoWrite-ERCAMLFS.js} +4 -4
- package/chunks/{tool-search-5IE2VO7X.js → tool-search-Q27QHQU3.js} +9 -9
- package/chunks/{total-session-admission-K6APQYEF.js → total-session-admission-HWVCZ2WR.js} +25 -25
- package/chunks/{trustedFolders-GPSSPVBF.js → trustedFolders-C6664IQC.js} +23 -23
- package/chunks/{update-relaunch-4BVAPX6Y.js → update-relaunch-QC3E4FZW.js} +9 -9
- package/chunks/{updateCheck-AHTHWLAM.js → updateCheck-MVUKJMBX.js} +33 -26
- package/chunks/useAutoAcceptIndicator-J234IFIS.js +80 -0
- package/chunks/{validateNonInterActiveAuth-UKAPCWDM.js → validateNonInterActiveAuth-YPPEKX4N.js} +61 -63
- package/chunks/{version-EXGWKKQE.js → version-5IXFQ4PT.js} +1 -1
- package/chunks/{web-fetch-ZDNE6FF2.js → web-fetch-L62NQVKN.js} +10 -10
- package/chunks/{workflow-G7U6OQWS.js → workflow-6MHBBFQU.js} +23 -23
- package/chunks/{workspace-providers-status-W6CEA6YM.js → workspace-providers-status-ZTW2B5QU.js} +30 -30
- package/chunks/{workspace-registration-store-OGBMWCLC.js → workspace-registration-store-P6QHCSMU.js} +7 -1
- package/chunks/{workspace-registry-ZUWQM44P.js → workspace-registry-R54M5O3W.js} +25 -25
- package/chunks/{workspace-service-UXX5P7GU.js → workspace-service-WYLRGM4A.js} +32 -32
- package/chunks/{workspace-skills-status-635B5R7N.js → workspace-skills-status-NN5QFU3A.js} +28 -28
- package/chunks/{write-file-DR3HN7IH.js → write-file-EAT3CHUK.js} +23 -23
- package/cli.js +11 -11
- package/locales/ca.js +763 -201
- package/package.json +3 -3
- package/web-shell/assets/{arc-_dVIKMdB.js → arc-B0iTWRo2.js} +1 -1
- package/web-shell/assets/{architectureDiagram-3BPJPVTR-MuN3nKpL.js → architectureDiagram-3BPJPVTR-DSQP4-9D.js} +1 -1
- package/web-shell/assets/{blockDiagram-GPEHLZMM-BtmvJjzx.js → blockDiagram-GPEHLZMM-BNPVXVT3.js} +1 -1
- package/web-shell/assets/{c4Diagram-AAUBKEIU-Dvi58_BU.js → c4Diagram-AAUBKEIU-DEHfJFiD.js} +1 -1
- package/web-shell/assets/channel-tVz-qNSq.js +1 -0
- package/web-shell/assets/{chunk-2J33WTMH-YqxOVhS1.js → chunk-2J33WTMH-VZ0uL1p9.js} +1 -1
- package/web-shell/assets/{chunk-4BX2VUAB-DoBgbC9z.js → chunk-4BX2VUAB-D5TKmvwG.js} +1 -1
- package/web-shell/assets/{chunk-55IACEB6-3NEQrBAr.js → chunk-55IACEB6-BDW1Lcq-.js} +1 -1
- package/web-shell/assets/{chunk-727SXJPM-DrCZQxp0.js → chunk-727SXJPM-Cj4h85iM.js} +1 -1
- package/web-shell/assets/{chunk-AQP2D5EJ-m_g3zjgv.js → chunk-AQP2D5EJ-5LeqiOhZ.js} +1 -1
- package/web-shell/assets/{chunk-FMBD7UC4-D1_crABJ.js → chunk-FMBD7UC4-BaTgsco7.js} +1 -1
- package/web-shell/assets/{chunk-ND2GUHAM-BdhgVtBx.js → chunk-ND2GUHAM-t3uGlIUk.js} +1 -1
- package/web-shell/assets/{chunk-QZHKN3VN-BlmThhm-.js → chunk-QZHKN3VN-rOnNXL2Q.js} +1 -1
- package/web-shell/assets/classDiagram-4FO5ZUOK-CWuaBxYV.js +1 -0
- package/web-shell/assets/classDiagram-v2-Q7XG4LA2-CWuaBxYV.js +1 -0
- package/web-shell/assets/{cose-bilkent-S5V4N54A-Cbjm_00Z.js → cose-bilkent-S5V4N54A-CcqXykgA.js} +1 -1
- package/web-shell/assets/{dagre-BM42HDAG-C39QNVgC.js → dagre-BM42HDAG-Dkjrchoy.js} +1 -1
- package/web-shell/assets/{diagram-2AECGRRQ-DNXSAixC.js → diagram-2AECGRRQ-B6lcra9M.js} +1 -1
- package/web-shell/assets/{diagram-5GNKFQAL-BCbGUPEA.js → diagram-5GNKFQAL-bAIzq3PT.js} +1 -1
- package/web-shell/assets/{diagram-KO2AKTUF-1eujKSDC.js → diagram-KO2AKTUF-G9MAZDNW.js} +1 -1
- package/web-shell/assets/{diagram-LMA3HP47-DUMKXgql.js → diagram-LMA3HP47-DVLF1uWZ.js} +1 -1
- package/web-shell/assets/{diagram-OG6HWLK6-BFktU3_u.js → diagram-OG6HWLK6-Cf7y20Tc.js} +1 -1
- package/web-shell/assets/{erDiagram-TEJ5UH35-BvJC7DLk.js → erDiagram-TEJ5UH35-C7ETZB3o.js} +1 -1
- package/web-shell/assets/{flowDiagram-I6XJVG4X-Cgu3PlOt.js → flowDiagram-I6XJVG4X-Cl2xgL6J.js} +1 -1
- package/web-shell/assets/{ganttDiagram-6RSMTGT7-DLNXN5Xh.js → ganttDiagram-6RSMTGT7-BgjbMs3q.js} +1 -1
- package/web-shell/assets/{gitGraphDiagram-PVQCEYII-BQFRDv6R.js → gitGraphDiagram-PVQCEYII-JVX34Omm.js} +1 -1
- package/web-shell/assets/index-48bIcdqF.js +1197 -0
- package/web-shell/assets/{index-CdC3pjP3.js → index-BG7Zc4f_.js} +1 -1
- package/web-shell/assets/index-BI-JAO07.css +5 -0
- package/web-shell/assets/{infoDiagram-5YYISTIA-DT2mOSvp.js → infoDiagram-5YYISTIA-3NYyMeZU.js} +1 -1
- package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-9fy_K4bd.js → ishikawaDiagram-YF4QCWOH-C03VCu-U.js} +1 -1
- package/web-shell/assets/{journeyDiagram-JHISSGLW-CoGSEuhE.js → journeyDiagram-JHISSGLW-C9PuBRZW.js} +1 -1
- package/web-shell/assets/{kanban-definition-UN3LZRKU-BP9hHYIj.js → kanban-definition-UN3LZRKU-C3LvioWR.js} +1 -1
- package/web-shell/assets/{linear-uIroDsmp.js → linear-Du6Yw8N_.js} +1 -1
- package/web-shell/assets/{mermaid.core-BUwoStsA.js → mermaid.core-BXY5D2-X.js} +5 -5
- package/web-shell/assets/{mindmap-definition-RKZ34NQL-DZB-FWim.js → mindmap-definition-RKZ34NQL-2UrHLaDp.js} +1 -1
- package/web-shell/assets/{pieDiagram-4H26LBE5-YPptloKl.js → pieDiagram-4H26LBE5-dC03ml45.js} +1 -1
- package/web-shell/assets/{quadrantDiagram-W4KKPZXB-dgk3DSzm.js → quadrantDiagram-W4KKPZXB-CD6jARrp.js} +1 -1
- package/web-shell/assets/{requirementDiagram-4Y6WPE33-BH2En2i9.js → requirementDiagram-4Y6WPE33-BrK8aXfv.js} +1 -1
- package/web-shell/assets/{sankeyDiagram-5OEKKPKP-BB98feeI.js → sankeyDiagram-5OEKKPKP-B5Vitki_.js} +1 -1
- package/web-shell/assets/{sequenceDiagram-3UESZ5HK-CunAIGh8.js → sequenceDiagram-3UESZ5HK-CBy2t6Bo.js} +1 -1
- package/web-shell/assets/{stateDiagram-AJRCARHV-DTJs_-I2.js → stateDiagram-AJRCARHV-Enrka6T2.js} +1 -1
- package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DUtYfXpW.js +1 -0
- package/web-shell/assets/{timeline-definition-PNZ67QCA-Cd4AN7O0.js → timeline-definition-PNZ67QCA-CwFq78ss.js} +1 -1
- package/web-shell/assets/{vennDiagram-CIIHVFJN-xIG-rUU9.js → vennDiagram-CIIHVFJN-BkOidM0g.js} +1 -1
- package/web-shell/assets/{wardley-L42UT6IY-D1UyjIcG.js → wardley-L42UT6IY-D_j13hQW.js} +1 -1
- package/web-shell/assets/{wardleyDiagram-YWT4CUSO-BVM0Mb99.js → wardleyDiagram-YWT4CUSO-7EveB1w6.js} +1 -1
- package/web-shell/assets/{xychartDiagram-2RQKCTM6-BX31JDSz.js → xychartDiagram-2RQKCTM6-DRkBhMXr.js} +1 -1
- package/web-shell/index.html +2 -2
- package/chunks/chunk-EDFD7VOX.js +0 -368
- package/chunks/chunk-GFYFLDEG.js +0 -709
- package/chunks/chunk-LUJQUNKY.js +0 -3288
- package/chunks/nonInteractiveCli-YURFHZV5.js +0 -129
- package/web-shell/assets/channel-Bi5TehaT.js +0 -1
- package/web-shell/assets/classDiagram-4FO5ZUOK-BKhhRdd1.js +0 -1
- package/web-shell/assets/classDiagram-v2-Q7XG4LA2-BKhhRdd1.js +0 -1
- package/web-shell/assets/index-C_ouplMQ.js +0 -1187
- package/web-shell/assets/index-XGDFJE-X.css +0 -5
- package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DrfFMYta.js +0 -1
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
3
|
import {
|
|
4
|
-
formatHistoryGapNotice
|
|
5
|
-
|
|
6
|
-
} from "./chunk-HZ4M2UQD.js";
|
|
4
|
+
formatHistoryGapNotice
|
|
5
|
+
} from "./chunk-6RVJRVQR.js";
|
|
7
6
|
import {
|
|
8
7
|
sanitizeTerminalText
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RS7MT2QG.js";
|
|
10
9
|
import {
|
|
11
10
|
isGoalStatusKind,
|
|
12
11
|
isTerminalGoalStatusKind
|
|
13
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-QTERJVPZ.js";
|
|
14
13
|
import {
|
|
15
14
|
require_undici
|
|
16
15
|
} from "./chunk-L573Z2QZ.js";
|
|
@@ -24,18 +23,18 @@ import {
|
|
|
24
23
|
setGoalTerminalObserver,
|
|
25
24
|
setLastGoalTerminal,
|
|
26
25
|
unregisterGoalHook
|
|
27
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-NO6XTCYT.js";
|
|
28
27
|
import {
|
|
29
28
|
apiActivityTracker,
|
|
30
29
|
formatVisionBridgeNoticeDisplay,
|
|
31
30
|
isVisionBridgeNoticeDisplay
|
|
32
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-P64HXIC5.js";
|
|
33
32
|
import {
|
|
34
33
|
ToolNames
|
|
35
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-OP4MOGXF.js";
|
|
36
35
|
import {
|
|
37
36
|
createDebugLogger
|
|
38
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-C27BYUX6.js";
|
|
39
38
|
import {
|
|
40
39
|
init_esbuild_shims
|
|
41
40
|
} from "./chunk-5O2XNYP6.js";
|
|
@@ -683,6 +682,856 @@ __name(realpathOrResolve, "realpathOrResolve");
|
|
|
683
682
|
// packages/cli/src/acp-integration/session/emitters/MessageEmitter.ts
|
|
684
683
|
init_esbuild_shims();
|
|
685
684
|
|
|
685
|
+
// packages/acp-bridge/src/transcript-replay.ts
|
|
686
|
+
init_esbuild_shims();
|
|
687
|
+
var MISSING_TRANSCRIPT_TOOL_RESULT_MESSAGE = "Tool result missing from saved history; the previous run likely ended before this tool completed.";
|
|
688
|
+
var TRANSCRIPT_GOAL_STATUS_KINDS = /* @__PURE__ */ new Set([
|
|
689
|
+
"set",
|
|
690
|
+
"achieved",
|
|
691
|
+
"cleared",
|
|
692
|
+
"failed",
|
|
693
|
+
"aborted",
|
|
694
|
+
"checking"
|
|
695
|
+
]);
|
|
696
|
+
function isObjectRecord(value) {
|
|
697
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
698
|
+
}
|
|
699
|
+
__name(isObjectRecord, "isObjectRecord");
|
|
700
|
+
function toTranscriptEpochMs(timestamp) {
|
|
701
|
+
if (typeof timestamp === "number") {
|
|
702
|
+
return Number.isFinite(timestamp) ? timestamp : void 0;
|
|
703
|
+
}
|
|
704
|
+
if (typeof timestamp !== "string") return void 0;
|
|
705
|
+
const epochMs = new Date(timestamp).getTime();
|
|
706
|
+
return Number.isFinite(epochMs) ? epochMs : void 0;
|
|
707
|
+
}
|
|
708
|
+
__name(toTranscriptEpochMs, "toTranscriptEpochMs");
|
|
709
|
+
function buildUpdateMeta(options) {
|
|
710
|
+
const timestamp = toTranscriptEpochMs(options.timestamp);
|
|
711
|
+
const sourceRecordIds = dedupeStrings(options.sourceRecordIds ?? []);
|
|
712
|
+
const qwenTranscript = {
|
|
713
|
+
...sourceRecordIds.length > 0 ? { sourceRecordIds } : {},
|
|
714
|
+
...options.planToolCallId ? { planToolCallId: options.planToolCallId } : {}
|
|
715
|
+
};
|
|
716
|
+
const meta = {
|
|
717
|
+
...options.extra ?? {},
|
|
718
|
+
...timestamp !== void 0 ? { timestamp } : {},
|
|
719
|
+
...Object.keys(qwenTranscript).length > 0 ? { qwenTranscript } : {}
|
|
720
|
+
};
|
|
721
|
+
return Object.keys(meta).length > 0 ? meta : void 0;
|
|
722
|
+
}
|
|
723
|
+
__name(buildUpdateMeta, "buildUpdateMeta");
|
|
724
|
+
function createTranscriptMessageUpdate(options) {
|
|
725
|
+
const meta = buildUpdateMeta(options);
|
|
726
|
+
return {
|
|
727
|
+
sessionUpdate: options.role === "user" ? "user_message_chunk" : options.thought ? "agent_thought_chunk" : "agent_message_chunk",
|
|
728
|
+
content: { type: "text", text: options.text },
|
|
729
|
+
...meta ? { _meta: meta } : {}
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
__name(createTranscriptMessageUpdate, "createTranscriptMessageUpdate");
|
|
733
|
+
function createTranscriptImageUpdate(options) {
|
|
734
|
+
const meta = buildUpdateMeta(options);
|
|
735
|
+
return {
|
|
736
|
+
sessionUpdate: "user_message_chunk",
|
|
737
|
+
content: { type: "image", data: options.data, mimeType: options.mimeType },
|
|
738
|
+
...meta ? { _meta: meta } : {}
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
__name(createTranscriptImageUpdate, "createTranscriptImageUpdate");
|
|
742
|
+
function createTranscriptUsageUpdate(usageMetadata, options = {}) {
|
|
743
|
+
const usage = {
|
|
744
|
+
inputTokens: finiteNumber2(usageMetadata.promptTokenCount) ?? 0,
|
|
745
|
+
outputTokens: finiteNumber2(usageMetadata.candidatesTokenCount) ?? 0,
|
|
746
|
+
totalTokens: finiteNumber2(usageMetadata.totalTokenCount) ?? 0,
|
|
747
|
+
...finiteNumber2(usageMetadata.thoughtsTokenCount) !== void 0 ? { thoughtTokens: finiteNumber2(usageMetadata.thoughtsTokenCount) } : {},
|
|
748
|
+
...finiteNumber2(usageMetadata.cachedContentTokenCount) !== void 0 ? {
|
|
749
|
+
cachedReadTokens: finiteNumber2(usageMetadata.cachedContentTokenCount)
|
|
750
|
+
} : {}
|
|
751
|
+
};
|
|
752
|
+
const meta = buildUpdateMeta({
|
|
753
|
+
...options,
|
|
754
|
+
extra: { usage, ...options.extra ?? {} }
|
|
755
|
+
});
|
|
756
|
+
return {
|
|
757
|
+
sessionUpdate: "agent_message_chunk",
|
|
758
|
+
content: { type: "text", text: options.text ?? "" },
|
|
759
|
+
_meta: meta
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
__name(createTranscriptUsageUpdate, "createTranscriptUsageUpdate");
|
|
763
|
+
function createTranscriptToolCallStartUpdate(options) {
|
|
764
|
+
const provenance = resolveToolProvenance(options.toolName);
|
|
765
|
+
return {
|
|
766
|
+
sessionUpdate: options.asUpdate ? "tool_call_update" : "tool_call",
|
|
767
|
+
toolCallId: options.callId,
|
|
768
|
+
status: options.status ?? "pending",
|
|
769
|
+
title: options.metadata.title,
|
|
770
|
+
content: [],
|
|
771
|
+
locations: [...options.metadata.locations],
|
|
772
|
+
kind: options.metadata.kind,
|
|
773
|
+
rawInput: options.args ?? {},
|
|
774
|
+
_meta: buildUpdateMeta({
|
|
775
|
+
...options,
|
|
776
|
+
extra: {
|
|
777
|
+
toolName: options.toolName,
|
|
778
|
+
provenance: provenance.provenance,
|
|
779
|
+
...provenance.serverId ? { serverId: provenance.serverId } : {},
|
|
780
|
+
...options.extra ?? {}
|
|
781
|
+
}
|
|
782
|
+
})
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
__name(createTranscriptToolCallStartUpdate, "createTranscriptToolCallStartUpdate");
|
|
786
|
+
function createTranscriptToolCallResultUpdate(options) {
|
|
787
|
+
const provenance = resolveToolProvenance(options.toolName);
|
|
788
|
+
const content = buildToolResultContent(options);
|
|
789
|
+
const update = {
|
|
790
|
+
sessionUpdate: "tool_call_update",
|
|
791
|
+
toolCallId: options.callId,
|
|
792
|
+
status: options.success ? "completed" : "failed",
|
|
793
|
+
content,
|
|
794
|
+
_meta: buildUpdateMeta({
|
|
795
|
+
...options,
|
|
796
|
+
extra: {
|
|
797
|
+
toolName: options.toolName,
|
|
798
|
+
provenance: provenance.provenance,
|
|
799
|
+
...provenance.serverId ? { serverId: provenance.serverId } : {},
|
|
800
|
+
...options.artifacts && options.artifacts.length > 0 ? { artifacts: options.artifacts } : {},
|
|
801
|
+
...options.extra ?? {}
|
|
802
|
+
}
|
|
803
|
+
})
|
|
804
|
+
};
|
|
805
|
+
if (options.resultDisplay !== void 0 && !isTruncatedSessionDiffDisplay(options.resultDisplay)) {
|
|
806
|
+
update["rawOutput"] = options.resultDisplay;
|
|
807
|
+
}
|
|
808
|
+
return update;
|
|
809
|
+
}
|
|
810
|
+
__name(createTranscriptToolCallResultUpdate, "createTranscriptToolCallResultUpdate");
|
|
811
|
+
function createTranscriptPlanUpdate(todos, cumulativeUsage, options = {}) {
|
|
812
|
+
const meta = buildUpdateMeta({
|
|
813
|
+
...options,
|
|
814
|
+
extra: {
|
|
815
|
+
...cumulativeUsage ? { stats: { ...cumulativeUsage } } : {},
|
|
816
|
+
...options.extra ?? {}
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
return {
|
|
820
|
+
sessionUpdate: "plan",
|
|
821
|
+
entries: todos.map((todo) => ({
|
|
822
|
+
content: todo.content,
|
|
823
|
+
priority: "medium",
|
|
824
|
+
status: todo.status
|
|
825
|
+
})),
|
|
826
|
+
...meta ? { _meta: meta } : {}
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
__name(createTranscriptPlanUpdate, "createTranscriptPlanUpdate");
|
|
830
|
+
function extractTranscriptTodos(resultDisplay, args) {
|
|
831
|
+
const fromDisplay = extractTodosFromDisplay(resultDisplay);
|
|
832
|
+
if (fromDisplay) return fromDisplay;
|
|
833
|
+
return args && Array.isArray(args["todos"]) ? normalizeTodos(args["todos"]) : null;
|
|
834
|
+
}
|
|
835
|
+
__name(extractTranscriptTodos, "extractTranscriptTodos");
|
|
836
|
+
function createTranscriptReplayMachine(options = {}) {
|
|
837
|
+
return new DefaultTranscriptReplayMachine(options);
|
|
838
|
+
}
|
|
839
|
+
__name(createTranscriptReplayMachine, "createTranscriptReplayMachine");
|
|
840
|
+
var DefaultTranscriptReplayMachine = class {
|
|
841
|
+
constructor(options) {
|
|
842
|
+
this.options = options;
|
|
843
|
+
const initialState = parseInitialState(
|
|
844
|
+
options.initialState,
|
|
845
|
+
options.onDiagnostic
|
|
846
|
+
);
|
|
847
|
+
this.usage = { ...initialState.cumulativeUsage };
|
|
848
|
+
for (const pending of initialState.pendingToolCalls) {
|
|
849
|
+
this.pendingToolCalls.set(pending.callId, pending);
|
|
850
|
+
this.usedToolCallIds.add(pending.callId);
|
|
851
|
+
}
|
|
852
|
+
for (const gap of options.gaps ?? []) {
|
|
853
|
+
if (!this.gapByChild.has(gap.childUuid)) {
|
|
854
|
+
this.gapByChild.set(gap.childUuid, gap);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
static {
|
|
859
|
+
__name(this, "DefaultTranscriptReplayMachine");
|
|
860
|
+
}
|
|
861
|
+
pendingToolCalls = /* @__PURE__ */ new Map();
|
|
862
|
+
usedToolCallIds = /* @__PURE__ */ new Set();
|
|
863
|
+
gapByChild = /* @__PURE__ */ new Map();
|
|
864
|
+
usage;
|
|
865
|
+
finalized = false;
|
|
866
|
+
*project(record) {
|
|
867
|
+
if (this.finalized) {
|
|
868
|
+
throw new Error(
|
|
869
|
+
"Cannot project records after transcript replay finalize."
|
|
870
|
+
);
|
|
871
|
+
}
|
|
872
|
+
let ordinal = 0;
|
|
873
|
+
const emit = /* @__PURE__ */ __name((update) => ({
|
|
874
|
+
sourceRecordId: record.uuid,
|
|
875
|
+
...record.timestamp ? { sourceTimestamp: record.timestamp } : {},
|
|
876
|
+
emissionOrdinal: ordinal++,
|
|
877
|
+
update
|
|
878
|
+
}), "emit");
|
|
879
|
+
const meta = {
|
|
880
|
+
timestamp: record.timestamp,
|
|
881
|
+
sourceRecordIds: [record.uuid]
|
|
882
|
+
};
|
|
883
|
+
const gap = this.gapByChild.get(record.uuid);
|
|
884
|
+
if (gap) {
|
|
885
|
+
yield emit(
|
|
886
|
+
createTranscriptMessageUpdate({
|
|
887
|
+
role: "assistant",
|
|
888
|
+
text: this.formatGap(gap),
|
|
889
|
+
...meta,
|
|
890
|
+
extra: { qwenDiscreteMessage: true }
|
|
891
|
+
})
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
switch (record.type) {
|
|
895
|
+
case "user":
|
|
896
|
+
yield* this.projectUserRecord(record, emit, meta);
|
|
897
|
+
break;
|
|
898
|
+
case "assistant":
|
|
899
|
+
yield* this.projectAssistantRecord(record, emit, meta);
|
|
900
|
+
break;
|
|
901
|
+
case "tool_result":
|
|
902
|
+
yield* this.projectToolResult(record, emit, meta);
|
|
903
|
+
break;
|
|
904
|
+
case "system":
|
|
905
|
+
yield* this.projectSystemRecord(record, emit, meta);
|
|
906
|
+
break;
|
|
907
|
+
default:
|
|
908
|
+
this.report(
|
|
909
|
+
"unknown_record_or_part",
|
|
910
|
+
"Skipped an unknown transcript record type.",
|
|
911
|
+
record.uuid
|
|
912
|
+
);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
*finalize() {
|
|
916
|
+
if (this.finalized) return;
|
|
917
|
+
this.finalized = true;
|
|
918
|
+
let ordinal = 0;
|
|
919
|
+
for (const pending of [...this.pendingToolCalls.values()]) {
|
|
920
|
+
this.pendingToolCalls.delete(pending.callId);
|
|
921
|
+
yield {
|
|
922
|
+
sourceRecordId: pending.sourceRecordId,
|
|
923
|
+
...pending.sourceTimestamp ? { sourceTimestamp: pending.sourceTimestamp } : {},
|
|
924
|
+
emissionOrdinal: ordinal++,
|
|
925
|
+
update: createTranscriptToolCallResultUpdate({
|
|
926
|
+
toolName: pending.toolName,
|
|
927
|
+
callId: pending.callId,
|
|
928
|
+
success: false,
|
|
929
|
+
errorMessage: MISSING_TRANSCRIPT_TOOL_RESULT_MESSAGE,
|
|
930
|
+
timestamp: pending.sourceTimestamp,
|
|
931
|
+
sourceRecordIds: [pending.sourceRecordId]
|
|
932
|
+
})
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
snapshot() {
|
|
937
|
+
return {
|
|
938
|
+
v: 1,
|
|
939
|
+
pendingToolCalls: [...this.pendingToolCalls.values()].map((pending) => ({
|
|
940
|
+
...pending
|
|
941
|
+
})),
|
|
942
|
+
cumulativeUsage: { ...this.usage }
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
*projectUserRecord(record, emit, meta) {
|
|
946
|
+
if (record.subtype === "notification" || record.subtype === "cron" || record.subtype === "mid_turn_user_message") {
|
|
947
|
+
const payload = isObjectRecord(record.systemPayload) ? record.systemPayload : void 0;
|
|
948
|
+
const displayText = payload && typeof payload["displayText"] === "string" ? payload["displayText"] : void 0;
|
|
949
|
+
if (displayText) {
|
|
950
|
+
yield emit(
|
|
951
|
+
createTranscriptMessageUpdate({
|
|
952
|
+
role: "user",
|
|
953
|
+
text: displayText,
|
|
954
|
+
...meta,
|
|
955
|
+
...record.subtype === "cron" ? { extra: { source: "cron" } } : {}
|
|
956
|
+
})
|
|
957
|
+
);
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
if (record.subtype !== "mid_turn_user_message") return;
|
|
961
|
+
}
|
|
962
|
+
yield* this.projectMessageParts(record, "user", emit, meta);
|
|
963
|
+
}
|
|
964
|
+
*projectAssistantRecord(record, emit, meta) {
|
|
965
|
+
const usageMetadata = isObjectRecord(record.usageMetadata) ? record.usageMetadata : void 0;
|
|
966
|
+
let usageEmitted = false;
|
|
967
|
+
const takeUsageUpdate = /* @__PURE__ */ __name(() => {
|
|
968
|
+
if (!usageMetadata || usageEmitted) return void 0;
|
|
969
|
+
usageEmitted = true;
|
|
970
|
+
this.addUsage(usageMetadata);
|
|
971
|
+
return createTranscriptUsageUpdate(usageMetadata, meta);
|
|
972
|
+
}, "takeUsageUpdate");
|
|
973
|
+
yield* this.projectMessageParts(
|
|
974
|
+
record,
|
|
975
|
+
"assistant",
|
|
976
|
+
emit,
|
|
977
|
+
meta,
|
|
978
|
+
takeUsageUpdate
|
|
979
|
+
);
|
|
980
|
+
const trailingUsage = takeUsageUpdate();
|
|
981
|
+
if (trailingUsage) yield emit(trailingUsage);
|
|
982
|
+
}
|
|
983
|
+
*projectMessageParts(record, role, emit, meta, beforeToolCall) {
|
|
984
|
+
const parts = record.message?.parts;
|
|
985
|
+
if (!parts) return;
|
|
986
|
+
for (let partIndex = 0; partIndex < parts.length; partIndex += 1) {
|
|
987
|
+
const part = parts[partIndex];
|
|
988
|
+
if (!isObjectRecord(part)) {
|
|
989
|
+
this.report(
|
|
990
|
+
"malformed_part",
|
|
991
|
+
"Skipped a malformed transcript message part.",
|
|
992
|
+
record.uuid,
|
|
993
|
+
`message.parts[${partIndex}]`
|
|
994
|
+
);
|
|
995
|
+
continue;
|
|
996
|
+
}
|
|
997
|
+
let recognized = false;
|
|
998
|
+
if (typeof part["text"] === "string" && part["text"].length > 0) {
|
|
999
|
+
recognized = true;
|
|
1000
|
+
yield emit(
|
|
1001
|
+
createTranscriptMessageUpdate({
|
|
1002
|
+
role,
|
|
1003
|
+
text: part["text"],
|
|
1004
|
+
thought: role === "assistant" && part["thought"] === true,
|
|
1005
|
+
...meta
|
|
1006
|
+
})
|
|
1007
|
+
);
|
|
1008
|
+
}
|
|
1009
|
+
const inlineData = isObjectRecord(part["inlineData"]) ? part["inlineData"] : void 0;
|
|
1010
|
+
if (inlineData) {
|
|
1011
|
+
recognized = true;
|
|
1012
|
+
const data = inlineData["data"];
|
|
1013
|
+
const mimeType = inlineData["mimeType"];
|
|
1014
|
+
if (role === "user" && typeof data === "string" && typeof mimeType === "string" && mimeType.startsWith("image/")) {
|
|
1015
|
+
yield emit(createTranscriptImageUpdate({ data, mimeType, ...meta }));
|
|
1016
|
+
} else {
|
|
1017
|
+
this.report(
|
|
1018
|
+
"malformed_part",
|
|
1019
|
+
"Skipped an unsupported or malformed inline transcript part.",
|
|
1020
|
+
record.uuid,
|
|
1021
|
+
`message.parts[${partIndex}].inlineData`
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
const functionCall = isObjectRecord(part["functionCall"]) ? part["functionCall"] : void 0;
|
|
1026
|
+
if (functionCall) {
|
|
1027
|
+
recognized = true;
|
|
1028
|
+
const toolName = typeof functionCall["name"] === "string" ? functionCall["name"] : "";
|
|
1029
|
+
const args = isObjectRecord(functionCall["args"]) ? functionCall["args"] : {};
|
|
1030
|
+
if (!toolName) {
|
|
1031
|
+
this.report(
|
|
1032
|
+
"malformed_part",
|
|
1033
|
+
"Skipped a tool call without a tool name.",
|
|
1034
|
+
record.uuid,
|
|
1035
|
+
`message.parts[${partIndex}].functionCall`
|
|
1036
|
+
);
|
|
1037
|
+
continue;
|
|
1038
|
+
}
|
|
1039
|
+
const preToolUpdate = beforeToolCall?.();
|
|
1040
|
+
if (preToolUpdate) yield emit(preToolUpdate);
|
|
1041
|
+
if (toolName === "todo_write") continue;
|
|
1042
|
+
const explicitId = typeof functionCall["id"] === "string" && functionCall["id"].length > 0 ? functionCall["id"] : void 0;
|
|
1043
|
+
const callId = this.allocateToolCallId(
|
|
1044
|
+
explicitId ?? `qwen-replay-tool:${record.uuid}:${partIndex}`
|
|
1045
|
+
);
|
|
1046
|
+
const update = createTranscriptToolCallStartUpdate({
|
|
1047
|
+
toolName,
|
|
1048
|
+
callId,
|
|
1049
|
+
args,
|
|
1050
|
+
status: "in_progress",
|
|
1051
|
+
metadata: this.resolveToolMetadata(toolName, args, record.uuid),
|
|
1052
|
+
...meta
|
|
1053
|
+
});
|
|
1054
|
+
yield emit(update);
|
|
1055
|
+
if (role === "assistant") {
|
|
1056
|
+
this.pendingToolCalls.set(callId, {
|
|
1057
|
+
callId,
|
|
1058
|
+
toolName,
|
|
1059
|
+
sourceRecordId: record.uuid,
|
|
1060
|
+
...record.timestamp ? { sourceTimestamp: record.timestamp } : {}
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
if (!recognized && !("functionResponse" in part)) {
|
|
1065
|
+
this.report(
|
|
1066
|
+
"unknown_record_or_part",
|
|
1067
|
+
"Skipped an unknown transcript message part.",
|
|
1068
|
+
record.uuid,
|
|
1069
|
+
`message.parts[${partIndex}]`
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
*projectToolResult(record, emit, meta) {
|
|
1075
|
+
const result = isObjectRecord(record.toolCallResult) ? record.toolCallResult : void 0;
|
|
1076
|
+
const toolName = extractToolName(record);
|
|
1077
|
+
if (!toolName) {
|
|
1078
|
+
this.report(
|
|
1079
|
+
"malformed_part",
|
|
1080
|
+
"A transcript tool result has no tool name.",
|
|
1081
|
+
record.uuid,
|
|
1082
|
+
"message.parts"
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1085
|
+
const explicitCallId = extractToolResultCallId(record, result);
|
|
1086
|
+
const callId = explicitCallId ? this.allocateToolCallId(explicitCallId, true) : this.correlateResultCallId(toolName, record.uuid);
|
|
1087
|
+
this.pendingToolCalls.delete(callId);
|
|
1088
|
+
const resultDisplay = result?.["resultDisplay"];
|
|
1089
|
+
if (toolName === "todo_write") {
|
|
1090
|
+
const todos = extractTranscriptTodos(resultDisplay);
|
|
1091
|
+
if (todos) {
|
|
1092
|
+
yield emit(
|
|
1093
|
+
createTranscriptPlanUpdate(todos, this.usage, {
|
|
1094
|
+
...meta,
|
|
1095
|
+
planToolCallId: callId
|
|
1096
|
+
})
|
|
1097
|
+
);
|
|
1098
|
+
}
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1101
|
+
yield emit(
|
|
1102
|
+
createTranscriptToolCallResultUpdate({
|
|
1103
|
+
toolName,
|
|
1104
|
+
callId,
|
|
1105
|
+
success: result?.["status"] === void 0 ? !result?.["error"] : result["status"] === "success" && !result["error"],
|
|
1106
|
+
errorMessage: extractErrorMessage(result?.["error"]),
|
|
1107
|
+
message: record.message?.parts,
|
|
1108
|
+
resultDisplay,
|
|
1109
|
+
artifacts: Array.isArray(result?.["artifacts"]) ? result["artifacts"] : void 0,
|
|
1110
|
+
contentPrefix: this.buildToolResultContentPrefix(
|
|
1111
|
+
resultDisplay,
|
|
1112
|
+
record.uuid
|
|
1113
|
+
),
|
|
1114
|
+
...meta
|
|
1115
|
+
})
|
|
1116
|
+
);
|
|
1117
|
+
if (isTaskExecutionDisplay(resultDisplay)) {
|
|
1118
|
+
const usage = usageFromTaskExecution(resultDisplay);
|
|
1119
|
+
if (Object.keys(usage).length > 0) {
|
|
1120
|
+
this.addUsage(usage);
|
|
1121
|
+
yield emit(createTranscriptUsageUpdate(usage, meta));
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
*projectSystemRecord(record, emit, meta) {
|
|
1126
|
+
if (record.subtype !== "slash_command") return;
|
|
1127
|
+
const payload = isObjectRecord(record.systemPayload) ? record.systemPayload : void 0;
|
|
1128
|
+
if (payload?.["phase"] !== "result") return;
|
|
1129
|
+
const items = Array.isArray(payload["outputHistoryItems"]) ? payload["outputHistoryItems"] : [];
|
|
1130
|
+
for (const item of items) {
|
|
1131
|
+
const goalStatus = parseTranscriptGoalStatus(item);
|
|
1132
|
+
if (goalStatus) {
|
|
1133
|
+
if (goalStatus.condition.length === 0) {
|
|
1134
|
+
this.report(
|
|
1135
|
+
"malformed_part",
|
|
1136
|
+
"Skipped replay of a goal card whose condition is empty.",
|
|
1137
|
+
record.uuid,
|
|
1138
|
+
"systemPayload.outputHistoryItems.goalStatus.condition"
|
|
1139
|
+
);
|
|
1140
|
+
} else if (goalStatus.kind !== "checking") {
|
|
1141
|
+
yield emit(
|
|
1142
|
+
createTranscriptMessageUpdate({
|
|
1143
|
+
role: "assistant",
|
|
1144
|
+
text: "",
|
|
1145
|
+
...meta,
|
|
1146
|
+
extra: { goalStatus }
|
|
1147
|
+
})
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
continue;
|
|
1151
|
+
}
|
|
1152
|
+
if (!isObjectRecord(item) || typeof item["text"] !== "string") continue;
|
|
1153
|
+
yield emit(
|
|
1154
|
+
createTranscriptMessageUpdate({
|
|
1155
|
+
role: "assistant",
|
|
1156
|
+
text: item["text"].replace(/\n/g, " \n"),
|
|
1157
|
+
...meta,
|
|
1158
|
+
extra: { source: "slash_command" }
|
|
1159
|
+
})
|
|
1160
|
+
);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
addUsage(metadata) {
|
|
1164
|
+
this.usage.promptTokens += finiteNumber2(metadata["promptTokenCount"]) ?? 0;
|
|
1165
|
+
this.usage.candidateTokens += finiteNumber2(metadata["candidatesTokenCount"]) ?? 0;
|
|
1166
|
+
this.usage.cachedTokens += finiteNumber2(metadata["cachedContentTokenCount"]) ?? 0;
|
|
1167
|
+
}
|
|
1168
|
+
correlateResultCallId(toolName, recordId) {
|
|
1169
|
+
const candidates = [...this.pendingToolCalls.values()].filter(
|
|
1170
|
+
(pending) => pending.toolName === toolName
|
|
1171
|
+
);
|
|
1172
|
+
if (candidates.length === 1) return candidates[0].callId;
|
|
1173
|
+
this.report(
|
|
1174
|
+
"ambiguous_tool_call_correlation",
|
|
1175
|
+
"A tool result could not be matched to exactly one pending tool call.",
|
|
1176
|
+
recordId
|
|
1177
|
+
);
|
|
1178
|
+
return this.allocateToolCallId(`qwen-replay-tool:${recordId}:result`);
|
|
1179
|
+
}
|
|
1180
|
+
allocateToolCallId(candidate, reuse = false) {
|
|
1181
|
+
if (reuse && this.pendingToolCalls.has(candidate)) {
|
|
1182
|
+
this.usedToolCallIds.add(candidate);
|
|
1183
|
+
return candidate;
|
|
1184
|
+
}
|
|
1185
|
+
if (!this.usedToolCallIds.has(candidate)) {
|
|
1186
|
+
this.usedToolCallIds.add(candidate);
|
|
1187
|
+
return candidate;
|
|
1188
|
+
}
|
|
1189
|
+
let occurrence = 2;
|
|
1190
|
+
while (this.usedToolCallIds.has(`${candidate}:${occurrence}`)) {
|
|
1191
|
+
occurrence += 1;
|
|
1192
|
+
}
|
|
1193
|
+
const id = `${candidate}:${occurrence}`;
|
|
1194
|
+
this.usedToolCallIds.add(id);
|
|
1195
|
+
return id;
|
|
1196
|
+
}
|
|
1197
|
+
resolveToolMetadata(toolName, args, recordId) {
|
|
1198
|
+
try {
|
|
1199
|
+
return this.options.presentation?.resolveToolMetadata(toolName, args) ?? fallbackToolMetadata(toolName, args);
|
|
1200
|
+
} catch {
|
|
1201
|
+
this.report(
|
|
1202
|
+
"presentation_fallback",
|
|
1203
|
+
"Tool presentation metadata fell back to deterministic defaults.",
|
|
1204
|
+
recordId,
|
|
1205
|
+
void 0,
|
|
1206
|
+
false
|
|
1207
|
+
);
|
|
1208
|
+
return fallbackToolMetadata(toolName, args);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
formatGap(gap) {
|
|
1212
|
+
try {
|
|
1213
|
+
return this.options.presentation?.formatHistoryGap(gap) ?? "Some earlier messages are unavailable because the saved history is incomplete.";
|
|
1214
|
+
} catch {
|
|
1215
|
+
this.report(
|
|
1216
|
+
"presentation_fallback",
|
|
1217
|
+
"History gap presentation fell back to deterministic defaults.",
|
|
1218
|
+
gap.childUuid,
|
|
1219
|
+
void 0,
|
|
1220
|
+
false
|
|
1221
|
+
);
|
|
1222
|
+
return "Some earlier messages are unavailable because the saved history is incomplete.";
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
buildToolResultContentPrefix(resultDisplay, recordId) {
|
|
1226
|
+
try {
|
|
1227
|
+
return this.options.presentation?.buildToolResultContentPrefix?.(
|
|
1228
|
+
resultDisplay
|
|
1229
|
+
) ?? defaultToolResultContentPrefix(resultDisplay);
|
|
1230
|
+
} catch {
|
|
1231
|
+
this.report(
|
|
1232
|
+
"presentation_fallback",
|
|
1233
|
+
"Tool result content presentation fell back to deterministic defaults.",
|
|
1234
|
+
recordId,
|
|
1235
|
+
void 0,
|
|
1236
|
+
false
|
|
1237
|
+
);
|
|
1238
|
+
return defaultToolResultContentPrefix(resultDisplay);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
report(code, message, recordId, path2, affectsCompleteness = true) {
|
|
1242
|
+
this.options.onDiagnostic?.({
|
|
1243
|
+
code,
|
|
1244
|
+
severity: affectsCompleteness ? "warning" : "info",
|
|
1245
|
+
message,
|
|
1246
|
+
affectsCompleteness,
|
|
1247
|
+
...recordId ? { recordId } : {},
|
|
1248
|
+
...path2 ? { path: path2 } : {}
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
};
|
|
1252
|
+
function parseTranscriptGoalStatus(value) {
|
|
1253
|
+
if (!isObjectRecord(value) || value["type"] !== "goal_status") {
|
|
1254
|
+
return void 0;
|
|
1255
|
+
}
|
|
1256
|
+
const kind = value["kind"];
|
|
1257
|
+
const condition = value["condition"];
|
|
1258
|
+
if (typeof kind !== "string" || !TRANSCRIPT_GOAL_STATUS_KINDS.has(kind) || typeof condition !== "string") {
|
|
1259
|
+
return void 0;
|
|
1260
|
+
}
|
|
1261
|
+
const iterations = finiteNumber2(value["iterations"]);
|
|
1262
|
+
const setAt = finiteNumber2(value["setAt"]);
|
|
1263
|
+
const durationMs = finiteNumber2(value["durationMs"]);
|
|
1264
|
+
const lastReason = typeof value["lastReason"] === "string" ? value["lastReason"] : void 0;
|
|
1265
|
+
return {
|
|
1266
|
+
kind,
|
|
1267
|
+
condition,
|
|
1268
|
+
...iterations !== void 0 ? { iterations } : {},
|
|
1269
|
+
...setAt !== void 0 ? { setAt } : {},
|
|
1270
|
+
...durationMs !== void 0 ? { durationMs } : {},
|
|
1271
|
+
...lastReason !== void 0 ? { lastReason } : {}
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
__name(parseTranscriptGoalStatus, "parseTranscriptGoalStatus");
|
|
1275
|
+
function defaultToolResultContentPrefix(resultDisplay) {
|
|
1276
|
+
if (!isObjectRecord(resultDisplay) || resultDisplay["type"] !== "vision_bridge_notice" || typeof resultDisplay["summary"] !== "string" || typeof resultDisplay["notice"] !== "string") {
|
|
1277
|
+
return [];
|
|
1278
|
+
}
|
|
1279
|
+
return [
|
|
1280
|
+
{
|
|
1281
|
+
type: "content",
|
|
1282
|
+
content: {
|
|
1283
|
+
type: "text",
|
|
1284
|
+
text: `${resultDisplay["summary"]}
|
|
1285
|
+
${resultDisplay["notice"]}`
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
];
|
|
1289
|
+
}
|
|
1290
|
+
__name(defaultToolResultContentPrefix, "defaultToolResultContentPrefix");
|
|
1291
|
+
function parseInitialState(value, onDiagnostic) {
|
|
1292
|
+
const empty = {
|
|
1293
|
+
v: 1,
|
|
1294
|
+
pendingToolCalls: [],
|
|
1295
|
+
cumulativeUsage: emptyUsage()
|
|
1296
|
+
};
|
|
1297
|
+
if (value === void 0) return empty;
|
|
1298
|
+
if (!isObjectRecord(value)) {
|
|
1299
|
+
throw new TypeError("Invalid transcript replay state.");
|
|
1300
|
+
}
|
|
1301
|
+
if ("v" in value && value["v"] !== 1) {
|
|
1302
|
+
throw new TypeError("Unsupported transcript replay state version.");
|
|
1303
|
+
}
|
|
1304
|
+
const rawPending = Array.isArray(value["pendingToolCalls"]) ? value["pendingToolCalls"] : [];
|
|
1305
|
+
const pendingToolCalls = rawPending.flatMap(
|
|
1306
|
+
(pending) => {
|
|
1307
|
+
if (!isObjectRecord(pending) || typeof pending["callId"] !== "string" || typeof pending["toolName"] !== "string" || typeof pending["sourceRecordId"] !== "string") {
|
|
1308
|
+
onDiagnostic?.({
|
|
1309
|
+
code: "invalid_replay_state",
|
|
1310
|
+
severity: "warning",
|
|
1311
|
+
message: "Dropped a malformed pending tool call from replay state.",
|
|
1312
|
+
affectsCompleteness: true
|
|
1313
|
+
});
|
|
1314
|
+
return [];
|
|
1315
|
+
}
|
|
1316
|
+
return [
|
|
1317
|
+
{
|
|
1318
|
+
callId: pending["callId"],
|
|
1319
|
+
toolName: pending["toolName"],
|
|
1320
|
+
sourceRecordId: pending["sourceRecordId"],
|
|
1321
|
+
...typeof pending["sourceTimestamp"] === "string" ? { sourceTimestamp: pending["sourceTimestamp"] } : {}
|
|
1322
|
+
}
|
|
1323
|
+
];
|
|
1324
|
+
}
|
|
1325
|
+
);
|
|
1326
|
+
const rawUsage = value.cumulativeUsage;
|
|
1327
|
+
const usage = isObjectRecord(rawUsage) ? rawUsage : {};
|
|
1328
|
+
const validUsage = finiteNumber2(usage["promptTokens"]) !== void 0 && finiteNumber2(usage["cachedTokens"]) !== void 0 && finiteNumber2(usage["candidateTokens"]) !== void 0 && finiteNumber2(usage["apiTimeMs"]) !== void 0;
|
|
1329
|
+
if (!validUsage) {
|
|
1330
|
+
onDiagnostic?.({
|
|
1331
|
+
code: "invalid_replay_state",
|
|
1332
|
+
severity: "warning",
|
|
1333
|
+
message: "Reset invalid cumulative usage in transcript replay state.",
|
|
1334
|
+
affectsCompleteness: true
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
return {
|
|
1338
|
+
v: 1,
|
|
1339
|
+
pendingToolCalls,
|
|
1340
|
+
cumulativeUsage: validUsage ? {
|
|
1341
|
+
promptTokens: usage["promptTokens"],
|
|
1342
|
+
cachedTokens: usage["cachedTokens"],
|
|
1343
|
+
candidateTokens: usage["candidateTokens"],
|
|
1344
|
+
apiTimeMs: usage["apiTimeMs"]
|
|
1345
|
+
} : emptyUsage()
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
__name(parseInitialState, "parseInitialState");
|
|
1349
|
+
function emptyUsage() {
|
|
1350
|
+
return {
|
|
1351
|
+
promptTokens: 0,
|
|
1352
|
+
cachedTokens: 0,
|
|
1353
|
+
candidateTokens: 0,
|
|
1354
|
+
apiTimeMs: 0
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
__name(emptyUsage, "emptyUsage");
|
|
1358
|
+
function fallbackToolMetadata(toolName, args) {
|
|
1359
|
+
const description = typeof args["description"] === "string" ? args["description"].trim() : "";
|
|
1360
|
+
return {
|
|
1361
|
+
title: description ? `${toolName}: ${description}` : toolName,
|
|
1362
|
+
locations: [],
|
|
1363
|
+
kind: "other"
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
__name(fallbackToolMetadata, "fallbackToolMetadata");
|
|
1367
|
+
function resolveToolProvenance(toolName) {
|
|
1368
|
+
if (toolName.startsWith("mcp__")) {
|
|
1369
|
+
const parts = toolName.split("__");
|
|
1370
|
+
if (parts.length >= 3 && parts[1]) {
|
|
1371
|
+
return { provenance: "mcp", serverId: parts[1] };
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
return { provenance: "builtin" };
|
|
1375
|
+
}
|
|
1376
|
+
__name(resolveToolProvenance, "resolveToolProvenance");
|
|
1377
|
+
function buildToolResultContent(options) {
|
|
1378
|
+
const prefix = [...options.contentPrefix ?? []];
|
|
1379
|
+
const diff = extractDiffContent(options.resultDisplay);
|
|
1380
|
+
if (diff) return [...prefix, diff];
|
|
1381
|
+
if (options.errorMessage) {
|
|
1382
|
+
return [
|
|
1383
|
+
...prefix,
|
|
1384
|
+
{
|
|
1385
|
+
type: "content",
|
|
1386
|
+
content: { type: "text", text: options.errorMessage }
|
|
1387
|
+
}
|
|
1388
|
+
];
|
|
1389
|
+
}
|
|
1390
|
+
const content = [...prefix];
|
|
1391
|
+
for (const part of options.message ?? []) {
|
|
1392
|
+
if (!isObjectRecord(part)) continue;
|
|
1393
|
+
if (typeof part["text"] === "string" && part["text"]) {
|
|
1394
|
+
content.push({
|
|
1395
|
+
type: "content",
|
|
1396
|
+
content: { type: "text", text: part["text"] }
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
const response = isObjectRecord(part["functionResponse"]) ? part["functionResponse"] : void 0;
|
|
1400
|
+
const payload = response && isObjectRecord(response["response"]) ? response["response"] : void 0;
|
|
1401
|
+
if (!payload) continue;
|
|
1402
|
+
try {
|
|
1403
|
+
const output = payload["output"];
|
|
1404
|
+
const error = payload["error"];
|
|
1405
|
+
const text = typeof output === "string" ? output : typeof error === "string" ? error : JSON.stringify(payload);
|
|
1406
|
+
content.push({
|
|
1407
|
+
type: "content",
|
|
1408
|
+
content: { type: "text", text }
|
|
1409
|
+
});
|
|
1410
|
+
} catch {
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
return content;
|
|
1414
|
+
}
|
|
1415
|
+
__name(buildToolResultContent, "buildToolResultContent");
|
|
1416
|
+
function extractDiffContent(resultDisplay) {
|
|
1417
|
+
if (!isObjectRecord(resultDisplay)) return null;
|
|
1418
|
+
if (!("fileName" in resultDisplay) || !("newContent" in resultDisplay)) {
|
|
1419
|
+
return null;
|
|
1420
|
+
}
|
|
1421
|
+
if (isTruncatedSessionDiffDisplay(resultDisplay)) {
|
|
1422
|
+
return {
|
|
1423
|
+
type: "content",
|
|
1424
|
+
content: {
|
|
1425
|
+
type: "text",
|
|
1426
|
+
text: buildTruncatedDiffPreviewText(resultDisplay)
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1429
|
+
}
|
|
1430
|
+
return {
|
|
1431
|
+
type: "diff",
|
|
1432
|
+
path: typeof resultDisplay["fileName"] === "string" ? resultDisplay["fileName"] : "",
|
|
1433
|
+
oldText: typeof resultDisplay["originalContent"] === "string" ? resultDisplay["originalContent"] : "",
|
|
1434
|
+
newText: typeof resultDisplay["newContent"] === "string" ? resultDisplay["newContent"] : ""
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
__name(extractDiffContent, "extractDiffContent");
|
|
1438
|
+
function isTruncatedSessionDiffDisplay(value) {
|
|
1439
|
+
return isObjectRecord(value) && value["truncatedForSession"] === true && "fileName" in value && "newContent" in value;
|
|
1440
|
+
}
|
|
1441
|
+
__name(isTruncatedSessionDiffDisplay, "isTruncatedSessionDiffDisplay");
|
|
1442
|
+
function buildTruncatedDiffPreviewText(display) {
|
|
1443
|
+
const fileName = typeof display["fileName"] === "string" ? display["fileName"] : "the edited file";
|
|
1444
|
+
const fileDiffLength = typeof display["fileDiffLength"] === "number" ? ` Original fileDiff length: ${display["fileDiffLength"]} chars.` : "";
|
|
1445
|
+
return display["fileDiffTruncated"] === true ? `Full diff omitted from saved session history for ${fileName}.${fileDiffLength}` : `Saved session preview only for ${fileName}; full original and new file contents are unavailable.`;
|
|
1446
|
+
}
|
|
1447
|
+
__name(buildTruncatedDiffPreviewText, "buildTruncatedDiffPreviewText");
|
|
1448
|
+
function extractToolName(record) {
|
|
1449
|
+
for (const part of record.message?.parts ?? []) {
|
|
1450
|
+
if (!isObjectRecord(part) || !isObjectRecord(part["functionResponse"])) {
|
|
1451
|
+
continue;
|
|
1452
|
+
}
|
|
1453
|
+
const name = part["functionResponse"]["name"];
|
|
1454
|
+
if (typeof name === "string") return name;
|
|
1455
|
+
}
|
|
1456
|
+
return "";
|
|
1457
|
+
}
|
|
1458
|
+
__name(extractToolName, "extractToolName");
|
|
1459
|
+
function extractToolResultCallId(record, result) {
|
|
1460
|
+
if (typeof result?.["callId"] === "string" && result["callId"].length > 0) {
|
|
1461
|
+
return result["callId"];
|
|
1462
|
+
}
|
|
1463
|
+
for (const part of record.message?.parts ?? []) {
|
|
1464
|
+
if (!isObjectRecord(part) || !isObjectRecord(part["functionResponse"])) {
|
|
1465
|
+
continue;
|
|
1466
|
+
}
|
|
1467
|
+
const id = part["functionResponse"]["id"];
|
|
1468
|
+
if (typeof id === "string" && id.length > 0) return id;
|
|
1469
|
+
}
|
|
1470
|
+
return void 0;
|
|
1471
|
+
}
|
|
1472
|
+
__name(extractToolResultCallId, "extractToolResultCallId");
|
|
1473
|
+
function extractTodosFromDisplay(value) {
|
|
1474
|
+
if (isObjectRecord(value) && value["type"] === "todo_list") {
|
|
1475
|
+
return Array.isArray(value["todos"]) ? normalizeTodos(value["todos"]) : null;
|
|
1476
|
+
}
|
|
1477
|
+
if (typeof value !== "string") return null;
|
|
1478
|
+
try {
|
|
1479
|
+
const parsed = JSON.parse(value);
|
|
1480
|
+
return isObjectRecord(parsed) && parsed["type"] === "todo_list" && Array.isArray(parsed["todos"]) ? normalizeTodos(parsed["todos"]) : null;
|
|
1481
|
+
} catch {
|
|
1482
|
+
return null;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
__name(extractTodosFromDisplay, "extractTodosFromDisplay");
|
|
1486
|
+
function normalizeTodos(values) {
|
|
1487
|
+
return values.flatMap((value) => {
|
|
1488
|
+
if (!isObjectRecord(value) || typeof value["content"] !== "string")
|
|
1489
|
+
return [];
|
|
1490
|
+
const status = value["status"];
|
|
1491
|
+
if (status !== "pending" && status !== "in_progress" && status !== "completed") {
|
|
1492
|
+
return [];
|
|
1493
|
+
}
|
|
1494
|
+
return [
|
|
1495
|
+
{
|
|
1496
|
+
...typeof value["id"] === "string" ? { id: value["id"] } : {},
|
|
1497
|
+
content: value["content"],
|
|
1498
|
+
status
|
|
1499
|
+
}
|
|
1500
|
+
];
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1503
|
+
__name(normalizeTodos, "normalizeTodos");
|
|
1504
|
+
function isTaskExecutionDisplay(value) {
|
|
1505
|
+
return isObjectRecord(value) && value["type"] === "task_execution";
|
|
1506
|
+
}
|
|
1507
|
+
__name(isTaskExecutionDisplay, "isTaskExecutionDisplay");
|
|
1508
|
+
function usageFromTaskExecution(display) {
|
|
1509
|
+
const summary = isObjectRecord(display["executionSummary"]) ? display["executionSummary"] : void 0;
|
|
1510
|
+
if (!summary) return {};
|
|
1511
|
+
return {
|
|
1512
|
+
...finiteNumber2(summary["inputTokens"]) !== void 0 ? { promptTokenCount: summary["inputTokens"] } : {},
|
|
1513
|
+
...finiteNumber2(summary["outputTokens"]) !== void 0 ? { candidatesTokenCount: summary["outputTokens"] } : {},
|
|
1514
|
+
...finiteNumber2(summary["thoughtTokens"]) !== void 0 ? { thoughtsTokenCount: summary["thoughtTokens"] } : {},
|
|
1515
|
+
...finiteNumber2(summary["cachedTokens"]) !== void 0 ? { cachedContentTokenCount: summary["cachedTokens"] } : {},
|
|
1516
|
+
...finiteNumber2(summary["totalTokens"]) !== void 0 ? { totalTokenCount: summary["totalTokens"] } : {}
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1519
|
+
__name(usageFromTaskExecution, "usageFromTaskExecution");
|
|
1520
|
+
function finiteNumber2(value) {
|
|
1521
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1522
|
+
}
|
|
1523
|
+
__name(finiteNumber2, "finiteNumber");
|
|
1524
|
+
function extractErrorMessage(value) {
|
|
1525
|
+
if (value instanceof Error) return value.message;
|
|
1526
|
+
if (!isObjectRecord(value)) return void 0;
|
|
1527
|
+
return typeof value["message"] === "string" ? value["message"] : void 0;
|
|
1528
|
+
}
|
|
1529
|
+
__name(extractErrorMessage, "extractErrorMessage");
|
|
1530
|
+
function dedupeStrings(values) {
|
|
1531
|
+
return [...new Set(values.filter((value) => value.length > 0))];
|
|
1532
|
+
}
|
|
1533
|
+
__name(dedupeStrings, "dedupeStrings");
|
|
1534
|
+
|
|
686
1535
|
// packages/cli/src/acp-integration/session/emitters/base-emitter.ts
|
|
687
1536
|
init_esbuild_shims();
|
|
688
1537
|
var BaseEmitter = class {
|
|
@@ -785,16 +1634,14 @@ var MessageEmitter = class extends BaseEmitter {
|
|
|
785
1634
|
* @param timestamp - Optional server-side timestamp (ISO string or ms) for message ordering
|
|
786
1635
|
*/
|
|
787
1636
|
async emitUserMessage(text, timestamp, options = {}) {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
...Object.keys(_meta).length > 0 ? { _meta } : {}
|
|
797
|
-
});
|
|
1637
|
+
await this.sendUpdate(
|
|
1638
|
+
createTranscriptMessageUpdate({
|
|
1639
|
+
role: "user",
|
|
1640
|
+
text,
|
|
1641
|
+
timestamp,
|
|
1642
|
+
...options.source ? { extra: { source: options.source } } : {}
|
|
1643
|
+
})
|
|
1644
|
+
);
|
|
798
1645
|
}
|
|
799
1646
|
/**
|
|
800
1647
|
* Emits an agent thought chunk.
|
|
@@ -803,15 +1650,15 @@ var MessageEmitter = class extends BaseEmitter {
|
|
|
803
1650
|
* @param timestamp - Optional server-side timestamp (ISO string or ms) for message ordering
|
|
804
1651
|
*/
|
|
805
1652
|
async emitAgentThought(text, timestamp, subagentMeta) {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
1653
|
+
await this.sendUpdate(
|
|
1654
|
+
createTranscriptMessageUpdate({
|
|
1655
|
+
role: "assistant",
|
|
1656
|
+
thought: true,
|
|
1657
|
+
text,
|
|
1658
|
+
timestamp,
|
|
1659
|
+
...subagentMeta ? { extra: { ...subagentMeta } } : {}
|
|
1660
|
+
})
|
|
809
1661
|
);
|
|
810
|
-
await this.sendUpdate({
|
|
811
|
-
sessionUpdate: "agent_thought_chunk",
|
|
812
|
-
content: { type: "text", text },
|
|
813
|
-
..._meta ? { _meta } : {}
|
|
814
|
-
});
|
|
815
1662
|
}
|
|
816
1663
|
/**
|
|
817
1664
|
* Emits an agent message chunk.
|
|
@@ -820,15 +1667,14 @@ var MessageEmitter = class extends BaseEmitter {
|
|
|
820
1667
|
* @param timestamp - Optional server-side timestamp (ISO string or ms) for message ordering
|
|
821
1668
|
*/
|
|
822
1669
|
async emitAgentMessage(text, timestamp, subagentMeta) {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
1670
|
+
await this.sendUpdate(
|
|
1671
|
+
createTranscriptMessageUpdate({
|
|
1672
|
+
role: "assistant",
|
|
1673
|
+
text,
|
|
1674
|
+
timestamp,
|
|
1675
|
+
...subagentMeta ? { extra: { ...subagentMeta } } : {}
|
|
1676
|
+
})
|
|
826
1677
|
);
|
|
827
|
-
await this.sendUpdate({
|
|
828
|
-
sessionUpdate: "agent_message_chunk",
|
|
829
|
-
content: { type: "text", text },
|
|
830
|
-
..._meta ? { _meta } : {}
|
|
831
|
-
});
|
|
832
1678
|
}
|
|
833
1679
|
async emitSlashCommandOutput(text, timestamp) {
|
|
834
1680
|
const epochMs = BaseEmitter.toEpochMs(timestamp);
|
|
@@ -845,48 +1691,41 @@ var MessageEmitter = class extends BaseEmitter {
|
|
|
845
1691
|
* Emits usage metadata.
|
|
846
1692
|
*/
|
|
847
1693
|
async emitUsageMetadata(usageMetadata, text = "", durationMs, subagentMeta) {
|
|
848
|
-
const usage = {
|
|
849
|
-
inputTokens: usageMetadata.promptTokenCount ?? 0,
|
|
850
|
-
outputTokens: usageMetadata.candidatesTokenCount ?? 0,
|
|
851
|
-
totalTokens: usageMetadata.totalTokenCount ?? 0,
|
|
852
|
-
thoughtTokens: usageMetadata.thoughtsTokenCount,
|
|
853
|
-
cachedReadTokens: usageMetadata.cachedContentTokenCount
|
|
854
|
-
};
|
|
855
1694
|
const cumulative = this.ctx.cumulativeUsage;
|
|
856
1695
|
if (cumulative) {
|
|
857
1696
|
const addFinite = /* @__PURE__ */ __name((total, value) => typeof value === "number" && Number.isFinite(value) ? total + value : total, "addFinite");
|
|
858
1697
|
cumulative.promptTokens = addFinite(
|
|
859
1698
|
cumulative.promptTokens,
|
|
860
|
-
|
|
1699
|
+
usageMetadata.promptTokenCount
|
|
861
1700
|
);
|
|
862
1701
|
cumulative.candidateTokens = addFinite(
|
|
863
1702
|
cumulative.candidateTokens,
|
|
864
|
-
|
|
1703
|
+
usageMetadata.candidatesTokenCount
|
|
865
1704
|
);
|
|
866
1705
|
cumulative.cachedTokens = addFinite(
|
|
867
1706
|
cumulative.cachedTokens,
|
|
868
|
-
|
|
1707
|
+
usageMetadata.cachedContentTokenCount
|
|
869
1708
|
);
|
|
870
1709
|
cumulative.apiTimeMs = addFinite(cumulative.apiTimeMs, durationMs);
|
|
871
1710
|
}
|
|
872
|
-
let
|
|
1711
|
+
let activityMeta = {};
|
|
873
1712
|
if (typeof durationMs === "number") {
|
|
874
1713
|
const activity = apiActivityTracker.drain();
|
|
875
|
-
|
|
876
|
-
usage,
|
|
877
|
-
durationMs,
|
|
1714
|
+
activityMeta = {
|
|
878
1715
|
...activity.errors > 0 ? { apiErrors: activity.errors } : {},
|
|
879
|
-
...activity.retries > 0 ? { apiRetries: activity.retries } : {}
|
|
880
|
-
...subagentMeta
|
|
1716
|
+
...activity.retries > 0 ? { apiRetries: activity.retries } : {}
|
|
881
1717
|
};
|
|
882
|
-
} else {
|
|
883
|
-
meta = { usage, ...subagentMeta };
|
|
884
1718
|
}
|
|
885
|
-
await this.sendUpdate(
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
1719
|
+
await this.sendUpdate(
|
|
1720
|
+
createTranscriptUsageUpdate(usageMetadata, {
|
|
1721
|
+
text,
|
|
1722
|
+
extra: {
|
|
1723
|
+
...typeof durationMs === "number" ? { durationMs } : {},
|
|
1724
|
+
...activityMeta,
|
|
1725
|
+
...subagentMeta
|
|
1726
|
+
}
|
|
1727
|
+
})
|
|
1728
|
+
);
|
|
890
1729
|
}
|
|
891
1730
|
/**
|
|
892
1731
|
* Emits a message chunk based on role and thought flag.
|
|
@@ -903,14 +1742,6 @@ var MessageEmitter = class extends BaseEmitter {
|
|
|
903
1742
|
}
|
|
904
1743
|
return isThought ? this.emitAgentThought(text, timestamp, subagentMeta) : this.emitAgentMessage(text, timestamp, subagentMeta);
|
|
905
1744
|
}
|
|
906
|
-
buildChunkMeta(epochMs, subagentMeta) {
|
|
907
|
-
const meta = {
|
|
908
|
-
...subagentMeta?.parentToolCallId ? { parentToolCallId: subagentMeta.parentToolCallId } : {},
|
|
909
|
-
...subagentMeta?.subagentType ? { subagentType: subagentMeta.subagentType } : {},
|
|
910
|
-
...epochMs != null ? { timestamp: epochMs } : {}
|
|
911
|
-
};
|
|
912
|
-
return Object.keys(meta).length > 0 ? meta : void 0;
|
|
913
|
-
}
|
|
914
1745
|
};
|
|
915
1746
|
|
|
916
1747
|
// packages/cli/src/acp-integration/session/emitters/PlanEmitter.ts
|
|
@@ -925,18 +1756,8 @@ var PlanEmitter = class extends BaseEmitter {
|
|
|
925
1756
|
* @param todos - Array of todo items to send as plan entries
|
|
926
1757
|
*/
|
|
927
1758
|
async emitPlan(todos) {
|
|
928
|
-
const entries = todos.map((todo) => ({
|
|
929
|
-
content: todo.content,
|
|
930
|
-
priority: "medium",
|
|
931
|
-
// Default priority since todos don't have priority
|
|
932
|
-
status: todo.status
|
|
933
|
-
}));
|
|
934
1759
|
const cumulative = this.ctx.cumulativeUsage;
|
|
935
|
-
await this.sendUpdate(
|
|
936
|
-
sessionUpdate: "plan",
|
|
937
|
-
entries,
|
|
938
|
-
...cumulative ? { _meta: { stats: { ...cumulative } } } : {}
|
|
939
|
-
});
|
|
1760
|
+
await this.sendUpdate(createTranscriptPlanUpdate(todos, cumulative));
|
|
940
1761
|
}
|
|
941
1762
|
/**
|
|
942
1763
|
* Extracts todos from tool result display or args.
|
|
@@ -950,35 +1771,12 @@ var PlanEmitter = class extends BaseEmitter {
|
|
|
950
1771
|
* @returns Array of todos if found, null otherwise
|
|
951
1772
|
*/
|
|
952
1773
|
extractTodos(resultDisplay, args) {
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* Extracts todos from a result display value.
|
|
962
|
-
* Handles both object and JSON string formats.
|
|
963
|
-
*/
|
|
964
|
-
extractFromResultDisplay(resultDisplay) {
|
|
965
|
-
if (!resultDisplay) return null;
|
|
966
|
-
if (typeof resultDisplay === "object") {
|
|
967
|
-
const obj = resultDisplay;
|
|
968
|
-
if (obj["type"] === "todo_list" && Array.isArray(obj["todos"])) {
|
|
969
|
-
return obj["todos"];
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
if (typeof resultDisplay === "string") {
|
|
973
|
-
try {
|
|
974
|
-
const parsed = JSON.parse(resultDisplay);
|
|
975
|
-
if (parsed?.["type"] === "todo_list" && Array.isArray(parsed["todos"])) {
|
|
976
|
-
return parsed["todos"];
|
|
977
|
-
}
|
|
978
|
-
} catch {
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
return null;
|
|
1774
|
+
const todos = extractTranscriptTodos(resultDisplay, args);
|
|
1775
|
+
return todos?.map((todo, index) => ({
|
|
1776
|
+
id: todo.id ?? String(index),
|
|
1777
|
+
content: todo.content,
|
|
1778
|
+
status: todo.status
|
|
1779
|
+
})) ?? null;
|
|
982
1780
|
}
|
|
983
1781
|
};
|
|
984
1782
|
|
|
@@ -992,18 +1790,6 @@ function hasFullSessionContext(context) {
|
|
|
992
1790
|
}
|
|
993
1791
|
__name(hasFullSessionContext, "hasFullSessionContext");
|
|
994
1792
|
|
|
995
|
-
// packages/cli/src/utils/truncatedDiffPreview.ts
|
|
996
|
-
init_esbuild_shims();
|
|
997
|
-
function buildTruncatedDiffPreviewText(display) {
|
|
998
|
-
const fileName = typeof display["fileName"] === "string" ? display["fileName"] : "the edited file";
|
|
999
|
-
const fileDiffLength = typeof display["fileDiffLength"] === "number" ? ` Original fileDiff length: ${display["fileDiffLength"]} chars.` : "";
|
|
1000
|
-
if (display["fileDiffTruncated"] === true) {
|
|
1001
|
-
return `Full diff omitted from saved session history for ${fileName}.${fileDiffLength}`;
|
|
1002
|
-
}
|
|
1003
|
-
return `Saved session preview only for ${fileName}; full original and new file contents are unavailable.`;
|
|
1004
|
-
}
|
|
1005
|
-
__name(buildTruncatedDiffPreviewText, "buildTruncatedDiffPreviewText");
|
|
1006
|
-
|
|
1007
1793
|
// packages/cli/src/acp-integration/session/emitters/tool-call-emitter.ts
|
|
1008
1794
|
var KIND_MAP = {
|
|
1009
1795
|
["read" /* Read */]: "read",
|
|
@@ -1056,27 +1842,22 @@ var ToolCallEmitter = class _ToolCallEmitter extends BaseEmitter {
|
|
|
1056
1842
|
params.subagentMeta
|
|
1057
1843
|
);
|
|
1058
1844
|
const updatesPreparedCall = params.phase !== "preparing" && this.preparedCallIds.delete(params.callId);
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
status: params.status || "pending",
|
|
1062
|
-
title,
|
|
1063
|
-
content: [],
|
|
1064
|
-
locations,
|
|
1065
|
-
kind,
|
|
1066
|
-
rawInput: params.args ?? {},
|
|
1067
|
-
_meta: {
|
|
1845
|
+
await this.sendUpdate(
|
|
1846
|
+
createTranscriptToolCallStartUpdate({
|
|
1068
1847
|
toolName: params.toolName,
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1848
|
+
callId: params.callId,
|
|
1849
|
+
status: params.status || "pending",
|
|
1850
|
+
args: params.args,
|
|
1851
|
+
metadata: { title, locations, kind },
|
|
1852
|
+
timestamp: params.timestamp,
|
|
1853
|
+
asUpdate: updatesPreparedCall,
|
|
1854
|
+
extra: {
|
|
1855
|
+
...params.phase ? { phase: params.phase } : {},
|
|
1856
|
+
...params.subagentMeta,
|
|
1857
|
+
provenance: provenance.provenance,
|
|
1858
|
+
...provenance.serverId ? { serverId: provenance.serverId } : {}
|
|
1075
1859
|
}
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
await this.sendUpdate(
|
|
1079
|
-
updatesPreparedCall ? { sessionUpdate: "tool_call_update", ...update } : { sessionUpdate: "tool_call", ...update }
|
|
1860
|
+
})
|
|
1080
1861
|
);
|
|
1081
1862
|
if (params.phase === "preparing") {
|
|
1082
1863
|
this.preparedCallIds.add(params.callId);
|
|
@@ -1121,62 +1902,35 @@ var ToolCallEmitter = class _ToolCallEmitter extends BaseEmitter {
|
|
|
1121
1902
|
params.args
|
|
1122
1903
|
);
|
|
1123
1904
|
if (todos && todos.length > 0) {
|
|
1124
|
-
await this.planEmitter.emitPlan(todos);
|
|
1125
|
-
} else if (params.args && Array.isArray(params.args["todos"])) {
|
|
1126
|
-
await this.planEmitter.emitPlan([]);
|
|
1127
|
-
}
|
|
1128
|
-
return;
|
|
1129
|
-
}
|
|
1130
|
-
this.preparedCallIds.delete(params.callId);
|
|
1131
|
-
let contentArray = [];
|
|
1132
|
-
const diffContent = this.extractDiffContent(params.resultDisplay);
|
|
1133
|
-
if (diffContent) {
|
|
1134
|
-
contentArray = [diffContent];
|
|
1135
|
-
} else if (params.error) {
|
|
1136
|
-
contentArray = [
|
|
1137
|
-
{
|
|
1138
|
-
type: "content",
|
|
1139
|
-
content: { type: "text", text: params.error.message }
|
|
1140
|
-
}
|
|
1141
|
-
];
|
|
1142
|
-
} else {
|
|
1143
|
-
contentArray = this.transformPartsToToolCallContent(params.message);
|
|
1144
|
-
}
|
|
1145
|
-
if (isVisionBridgeNoticeDisplay(params.resultDisplay)) {
|
|
1146
|
-
contentArray.unshift({
|
|
1147
|
-
type: "content",
|
|
1148
|
-
content: {
|
|
1149
|
-
type: "text",
|
|
1150
|
-
text: sanitizeTerminalText(
|
|
1151
|
-
formatVisionBridgeNoticeDisplay(params.resultDisplay)
|
|
1152
|
-
)
|
|
1153
|
-
}
|
|
1154
|
-
});
|
|
1905
|
+
await this.planEmitter.emitPlan(todos);
|
|
1906
|
+
} else if (params.args && Array.isArray(params.args["todos"])) {
|
|
1907
|
+
await this.planEmitter.emitPlan([]);
|
|
1908
|
+
}
|
|
1909
|
+
return;
|
|
1155
1910
|
}
|
|
1911
|
+
this.preparedCallIds.delete(params.callId);
|
|
1156
1912
|
const provenance = _ToolCallEmitter.resolveToolProvenance(
|
|
1157
1913
|
params.toolName,
|
|
1158
1914
|
params.subagentMeta
|
|
1159
1915
|
);
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
toolCallId: params.callId,
|
|
1163
|
-
status: params.success ? "completed" : "failed",
|
|
1164
|
-
content: contentArray,
|
|
1165
|
-
_meta: {
|
|
1916
|
+
await this.sendUpdate(
|
|
1917
|
+
createTranscriptToolCallResultUpdate({
|
|
1166
1918
|
toolName: params.toolName,
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1919
|
+
callId: params.callId,
|
|
1920
|
+
success: params.success,
|
|
1921
|
+
message: params.message,
|
|
1922
|
+
resultDisplay: params.resultDisplay,
|
|
1923
|
+
errorMessage: params.error?.message,
|
|
1924
|
+
artifacts: params.artifacts,
|
|
1925
|
+
contentPrefix: buildToolResultContentPrefix(params.resultDisplay),
|
|
1926
|
+
timestamp: params.timestamp,
|
|
1927
|
+
extra: {
|
|
1928
|
+
...params.subagentMeta,
|
|
1929
|
+
provenance: provenance.provenance,
|
|
1930
|
+
...provenance.serverId ? { serverId: provenance.serverId } : {}
|
|
1931
|
+
}
|
|
1932
|
+
})
|
|
1933
|
+
);
|
|
1180
1934
|
}
|
|
1181
1935
|
/**
|
|
1182
1936
|
* Emits a tool call error event.
|
|
@@ -1193,20 +1947,19 @@ var ToolCallEmitter = class _ToolCallEmitter extends BaseEmitter {
|
|
|
1193
1947
|
toolName,
|
|
1194
1948
|
subagentMeta
|
|
1195
1949
|
);
|
|
1196
|
-
await this.sendUpdate(
|
|
1197
|
-
|
|
1198
|
-
toolCallId: callId,
|
|
1199
|
-
status: "failed",
|
|
1200
|
-
content: [
|
|
1201
|
-
{ type: "content", content: { type: "text", text: error.message } }
|
|
1202
|
-
],
|
|
1203
|
-
_meta: {
|
|
1950
|
+
await this.sendUpdate(
|
|
1951
|
+
createTranscriptToolCallResultUpdate({
|
|
1204
1952
|
toolName,
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1953
|
+
callId,
|
|
1954
|
+
success: false,
|
|
1955
|
+
errorMessage: error.message,
|
|
1956
|
+
extra: {
|
|
1957
|
+
...subagentMeta,
|
|
1958
|
+
provenance: provenance.provenance,
|
|
1959
|
+
...provenance.serverId ? { serverId: provenance.serverId } : {}
|
|
1960
|
+
}
|
|
1961
|
+
})
|
|
1962
|
+
);
|
|
1210
1963
|
}
|
|
1211
1964
|
/**
|
|
1212
1965
|
* Resolve a tool's provenance for UI dispatch on tool_call events.
|
|
@@ -1315,167 +2068,88 @@ var ToolCallEmitter = class _ToolCallEmitter extends BaseEmitter {
|
|
|
1315
2068
|
}
|
|
1316
2069
|
return KIND_MAP[kind] ?? "other";
|
|
1317
2070
|
}
|
|
1318
|
-
// ==================== Private Helpers ====================
|
|
1319
|
-
/**
|
|
1320
|
-
* Extracts diff content from resultDisplay if it's a diff type (edit tool result).
|
|
1321
|
-
* Returns null if not a diff.
|
|
1322
|
-
*/
|
|
1323
|
-
extractDiffContent(resultDisplay) {
|
|
1324
|
-
if (!resultDisplay || typeof resultDisplay !== "object") return null;
|
|
1325
|
-
const obj = resultDisplay;
|
|
1326
|
-
if ("fileName" in obj && "newContent" in obj) {
|
|
1327
|
-
if (this.isTruncatedSessionDiffDisplay(resultDisplay)) {
|
|
1328
|
-
return {
|
|
1329
|
-
type: "content",
|
|
1330
|
-
content: {
|
|
1331
|
-
type: "text",
|
|
1332
|
-
text: buildTruncatedDiffPreviewText(obj)
|
|
1333
|
-
}
|
|
1334
|
-
};
|
|
1335
|
-
}
|
|
1336
|
-
return {
|
|
1337
|
-
type: "diff",
|
|
1338
|
-
path: obj["fileName"],
|
|
1339
|
-
oldText: obj["originalContent"] ?? "",
|
|
1340
|
-
newText: obj["newContent"]
|
|
1341
|
-
};
|
|
1342
|
-
}
|
|
1343
|
-
return null;
|
|
1344
|
-
}
|
|
1345
|
-
isTruncatedSessionDiffDisplay(resultDisplay) {
|
|
1346
|
-
if (!resultDisplay || typeof resultDisplay !== "object") return false;
|
|
1347
|
-
const obj = resultDisplay;
|
|
1348
|
-
return obj["truncatedForSession"] === true && "fileName" in obj && "newContent" in obj;
|
|
1349
|
-
}
|
|
1350
|
-
/**
|
|
1351
|
-
* Transforms Part[] to ToolCallContent[].
|
|
1352
|
-
* Extracts text from functionResponse parts and text parts.
|
|
1353
|
-
*/
|
|
1354
|
-
transformPartsToToolCallContent(parts) {
|
|
1355
|
-
const result = [];
|
|
1356
|
-
for (const part of parts) {
|
|
1357
|
-
if ("text" in part && part.text) {
|
|
1358
|
-
result.push({
|
|
1359
|
-
type: "content",
|
|
1360
|
-
content: { type: "text", text: part.text }
|
|
1361
|
-
});
|
|
1362
|
-
}
|
|
1363
|
-
if ("functionResponse" in part && part.functionResponse) {
|
|
1364
|
-
try {
|
|
1365
|
-
const resp = part.functionResponse.response;
|
|
1366
|
-
const outputField = resp["output"];
|
|
1367
|
-
const errorField = resp["error"];
|
|
1368
|
-
const responseText = typeof outputField === "string" ? outputField : typeof errorField === "string" ? errorField : JSON.stringify(resp);
|
|
1369
|
-
result.push({
|
|
1370
|
-
type: "content",
|
|
1371
|
-
content: { type: "text", text: responseText }
|
|
1372
|
-
});
|
|
1373
|
-
} catch {
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
return result;
|
|
1378
|
-
}
|
|
1379
2071
|
};
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
const resultCallId = record.toolCallResult?.callId;
|
|
1392
|
-
if (typeof resultCallId === "string" && resultCallId.length > 0) {
|
|
1393
|
-
return resultCallId;
|
|
1394
|
-
}
|
|
1395
|
-
return extractFunctionResponseId(record);
|
|
1396
|
-
}
|
|
1397
|
-
__name(getExplicitToolResultCallId, "getExplicitToolResultCallId");
|
|
1398
|
-
function extractFunctionResponseId(record) {
|
|
1399
|
-
if (!record.message?.parts) {
|
|
1400
|
-
return void 0;
|
|
1401
|
-
}
|
|
1402
|
-
for (const part of record.message.parts) {
|
|
1403
|
-
const id = "functionResponse" in part ? part.functionResponse?.id : void 0;
|
|
1404
|
-
if (typeof id === "string" && id.length > 0) {
|
|
1405
|
-
return id;
|
|
2072
|
+
function buildToolResultContentPrefix(resultDisplay) {
|
|
2073
|
+
if (!isVisionBridgeNoticeDisplay(resultDisplay)) return [];
|
|
2074
|
+
return [
|
|
2075
|
+
{
|
|
2076
|
+
type: "content",
|
|
2077
|
+
content: {
|
|
2078
|
+
type: "text",
|
|
2079
|
+
text: sanitizeTerminalText(
|
|
2080
|
+
formatVisionBridgeNoticeDisplay(resultDisplay)
|
|
2081
|
+
)
|
|
2082
|
+
}
|
|
1406
2083
|
}
|
|
1407
|
-
|
|
1408
|
-
return void 0;
|
|
2084
|
+
];
|
|
1409
2085
|
}
|
|
1410
|
-
__name(
|
|
2086
|
+
__name(buildToolResultContentPrefix, "buildToolResultContentPrefix");
|
|
1411
2087
|
|
|
1412
2088
|
// packages/cli/src/acp-integration/session/history-replayer.ts
|
|
2089
|
+
init_esbuild_shims();
|
|
1413
2090
|
var GOAL_NOT_RESTORED_REASON = {
|
|
1414
2091
|
"untrusted-folder": "Goal not restored: this folder is not trusted, so its Stop hook cannot run.",
|
|
1415
2092
|
"hooks-disabled": "Goal not restored: hooks are disabled for this session.",
|
|
1416
2093
|
"no-hook-system": "Goal not restored: the hook system is unavailable."
|
|
1417
2094
|
};
|
|
1418
|
-
var MISSING_TOOL_RESULT_MESSAGE = "Tool result missing from saved history; the previous run likely ended before this tool completed.";
|
|
1419
2095
|
var HistoryReplayer = class {
|
|
1420
|
-
static {
|
|
1421
|
-
__name(this, "HistoryReplayer");
|
|
1422
|
-
}
|
|
1423
|
-
ctx;
|
|
1424
|
-
messageEmitter;
|
|
1425
|
-
toolCallEmitter;
|
|
1426
|
-
options;
|
|
1427
|
-
pendingReplayToolCalls = /* @__PURE__ */ new Map();
|
|
1428
2096
|
constructor(ctx, options = {}) {
|
|
1429
2097
|
this.ctx = ctx;
|
|
1430
2098
|
this.options = options;
|
|
1431
2099
|
this.messageEmitter = new MessageEmitter(ctx);
|
|
1432
2100
|
this.toolCallEmitter = new ToolCallEmitter(ctx);
|
|
2101
|
+
this.machine = this.createMachine();
|
|
1433
2102
|
}
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
*/
|
|
2103
|
+
static {
|
|
2104
|
+
__name(this, "HistoryReplayer");
|
|
2105
|
+
}
|
|
2106
|
+
messageEmitter;
|
|
2107
|
+
toolCallEmitter;
|
|
2108
|
+
options;
|
|
2109
|
+
machine;
|
|
1442
2110
|
async replay(records, gaps) {
|
|
1443
2111
|
try {
|
|
1444
2112
|
await this.replayPage(records, { finalizeDangling: true, gaps });
|
|
1445
2113
|
await this.supersedeUnrestorableGoal(records);
|
|
1446
2114
|
} finally {
|
|
1447
|
-
this.pendingReplayToolCalls.clear();
|
|
1448
2115
|
this.setActiveRecordId(null);
|
|
1449
2116
|
}
|
|
1450
2117
|
}
|
|
1451
2118
|
async replayPage(records, options = {}) {
|
|
1452
|
-
this.
|
|
1453
|
-
for (const pending of options.pendingToolCalls ?? []) {
|
|
1454
|
-
this.pendingReplayToolCalls.set(pending.callId, pending);
|
|
1455
|
-
}
|
|
1456
|
-
const gapByChildUuid = indexGapsByChild(options.gaps);
|
|
2119
|
+
this.machine = this.createMachine(options);
|
|
1457
2120
|
let replayError;
|
|
1458
2121
|
try {
|
|
1459
2122
|
for (const record of records) {
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1462
|
-
|
|
2123
|
+
for (const emission of this.machine.project(record)) {
|
|
2124
|
+
this.setActiveRecordId(
|
|
2125
|
+
emission.sourceRecordId,
|
|
2126
|
+
emission.sourceTimestamp
|
|
2127
|
+
);
|
|
2128
|
+
await this.sendUpdate(emission.update);
|
|
1463
2129
|
}
|
|
1464
|
-
await this.replayRecord(record);
|
|
1465
2130
|
}
|
|
1466
2131
|
} catch (error) {
|
|
1467
2132
|
replayError = error;
|
|
1468
2133
|
}
|
|
1469
2134
|
let danglingError;
|
|
1470
2135
|
if (options.finalizeDangling === true) {
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
2136
|
+
for (const emission of this.machine.finalize()) {
|
|
2137
|
+
this.setActiveRecordId(
|
|
2138
|
+
emission.sourceRecordId,
|
|
2139
|
+
emission.sourceTimestamp
|
|
2140
|
+
);
|
|
2141
|
+
try {
|
|
2142
|
+
await this.sendUpdate(emission.update);
|
|
2143
|
+
} catch (error) {
|
|
2144
|
+
danglingError ??= error;
|
|
2145
|
+
}
|
|
1475
2146
|
}
|
|
1476
2147
|
}
|
|
2148
|
+
const replay = this.machine.snapshot();
|
|
2149
|
+
this.copyCumulativeUsage(replay);
|
|
1477
2150
|
const state = {
|
|
1478
|
-
pendingToolCalls: options.finalizeDangling === true ? [] :
|
|
2151
|
+
pendingToolCalls: options.finalizeDangling === true ? [] : replay.pendingToolCalls.map(toLegacyPendingToolCall),
|
|
2152
|
+
replay
|
|
1479
2153
|
};
|
|
1480
2154
|
this.setActiveRecordId(null);
|
|
1481
2155
|
if (replayError && danglingError) {
|
|
@@ -1484,271 +2158,62 @@ var HistoryReplayer = class {
|
|
|
1484
2158
|
"Replay and dangling-cleanup both failed"
|
|
1485
2159
|
);
|
|
1486
2160
|
}
|
|
1487
|
-
if (replayError)
|
|
1488
|
-
|
|
1489
|
-
}
|
|
1490
|
-
if (danglingError) {
|
|
1491
|
-
throw danglingError;
|
|
1492
|
-
}
|
|
2161
|
+
if (replayError) throw replayError;
|
|
2162
|
+
if (danglingError) throw danglingError;
|
|
1493
2163
|
return state;
|
|
1494
2164
|
}
|
|
1495
2165
|
getPendingToolCalls() {
|
|
1496
|
-
return
|
|
1497
|
-
}
|
|
1498
|
-
/**
|
|
1499
|
-
* Replays a single chat record.
|
|
1500
|
-
*/
|
|
1501
|
-
async replayRecord(record) {
|
|
1502
|
-
this.setActiveRecordId(record.uuid, record.timestamp);
|
|
1503
|
-
try {
|
|
1504
|
-
switch (record.type) {
|
|
1505
|
-
case "user":
|
|
1506
|
-
if (record.subtype === "notification" || record.subtype === "cron") {
|
|
1507
|
-
const displayText = record.systemPayload?.displayText;
|
|
1508
|
-
if (displayText) {
|
|
1509
|
-
await this.messageEmitter.emitUserMessage(
|
|
1510
|
-
displayText,
|
|
1511
|
-
record.timestamp,
|
|
1512
|
-
record.subtype === "cron" ? { source: "cron" } : void 0
|
|
1513
|
-
);
|
|
1514
|
-
}
|
|
1515
|
-
break;
|
|
1516
|
-
}
|
|
1517
|
-
if (record.subtype === "mid_turn_user_message") {
|
|
1518
|
-
const displayText = record.systemPayload?.displayText;
|
|
1519
|
-
if (displayText) {
|
|
1520
|
-
await this.messageEmitter.emitUserMessage(
|
|
1521
|
-
displayText,
|
|
1522
|
-
record.timestamp
|
|
1523
|
-
);
|
|
1524
|
-
} else if (record.message) {
|
|
1525
|
-
await this.replayContent(
|
|
1526
|
-
record.message,
|
|
1527
|
-
"user",
|
|
1528
|
-
record.timestamp,
|
|
1529
|
-
record.uuid
|
|
1530
|
-
);
|
|
1531
|
-
}
|
|
1532
|
-
break;
|
|
1533
|
-
}
|
|
1534
|
-
if (record.message) {
|
|
1535
|
-
await this.replayContent(
|
|
1536
|
-
record.message,
|
|
1537
|
-
"user",
|
|
1538
|
-
record.timestamp,
|
|
1539
|
-
record.uuid
|
|
1540
|
-
);
|
|
1541
|
-
}
|
|
1542
|
-
break;
|
|
1543
|
-
case "assistant":
|
|
1544
|
-
if (record.message) {
|
|
1545
|
-
await this.replayContent(
|
|
1546
|
-
record.message,
|
|
1547
|
-
"assistant",
|
|
1548
|
-
record.timestamp,
|
|
1549
|
-
record.uuid
|
|
1550
|
-
);
|
|
1551
|
-
}
|
|
1552
|
-
if (record.usageMetadata) {
|
|
1553
|
-
await this.replayUsageMetadata(record.usageMetadata);
|
|
1554
|
-
}
|
|
1555
|
-
break;
|
|
1556
|
-
case "tool_result":
|
|
1557
|
-
await this.replayToolResult(record);
|
|
1558
|
-
break;
|
|
1559
|
-
case "system":
|
|
1560
|
-
if (record.subtype === "slash_command") {
|
|
1561
|
-
await this.replaySlashCommandResult(record);
|
|
1562
|
-
}
|
|
1563
|
-
break;
|
|
1564
|
-
default:
|
|
1565
|
-
break;
|
|
1566
|
-
}
|
|
1567
|
-
} finally {
|
|
1568
|
-
this.setActiveRecordId(null);
|
|
1569
|
-
}
|
|
2166
|
+
return this.machine.snapshot().pendingToolCalls.map(toLegacyPendingToolCall);
|
|
1570
2167
|
}
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
* earlier segment was physically lost (storage interruption) and could not be
|
|
1574
|
-
* recovered, so the surviving turns below must not be read as contiguous with
|
|
1575
|
-
* whatever came before the gap. Uses the agent message channel — the same one
|
|
1576
|
-
* used for other system notices (see MessageEmitter.emitStopHookLoop) — so no
|
|
1577
|
-
* new session-update kind is needed.
|
|
1578
|
-
*/
|
|
1579
|
-
async emitHistoryGapNotice(gap, timestamp) {
|
|
1580
|
-
await this.messageEmitter.emitAgentMessage(
|
|
1581
|
-
formatHistoryGapNotice(gap),
|
|
1582
|
-
timestamp
|
|
1583
|
-
);
|
|
2168
|
+
getReplayState() {
|
|
2169
|
+
return this.machine.snapshot();
|
|
1584
2170
|
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
await this.messageEmitter.emitMessage(
|
|
1598
|
-
part.text,
|
|
1599
|
-
role,
|
|
1600
|
-
isThought,
|
|
1601
|
-
timestamp
|
|
1602
|
-
);
|
|
2171
|
+
createMachine(options = {}) {
|
|
2172
|
+
const cumulative = this.ctx.cumulativeUsage;
|
|
2173
|
+
const initialState = {
|
|
2174
|
+
v: 1,
|
|
2175
|
+
pendingToolCalls: (options.pendingToolCalls ?? []).map(
|
|
2176
|
+
toPendingTranscriptToolCall
|
|
2177
|
+
),
|
|
2178
|
+
cumulativeUsage: cumulative ? { ...cumulative } : {
|
|
2179
|
+
promptTokens: 0,
|
|
2180
|
+
cachedTokens: 0,
|
|
2181
|
+
candidateTokens: 0,
|
|
2182
|
+
apiTimeMs: 0
|
|
1603
2183
|
}
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
status: "in_progress",
|
|
1613
|
-
timestamp
|
|
1614
|
-
});
|
|
1615
|
-
if (emitted && role === "assistant" && recordId && sourceCallId) {
|
|
1616
|
-
this.pendingReplayToolCalls.set(callId, {
|
|
1617
|
-
callId,
|
|
1618
|
-
toolName: functionName,
|
|
1619
|
-
timestamp,
|
|
1620
|
-
recordId
|
|
1621
|
-
});
|
|
2184
|
+
};
|
|
2185
|
+
return createTranscriptReplayMachine({
|
|
2186
|
+
initialState,
|
|
2187
|
+
gaps: options.gaps,
|
|
2188
|
+
presentation: this.presentationAdapter(),
|
|
2189
|
+
onDiagnostic: /* @__PURE__ */ __name((diagnostic) => {
|
|
2190
|
+
if (diagnostic.code === "malformed_part" && diagnostic.path === "systemPayload.outputHistoryItems.goalStatus.condition") {
|
|
2191
|
+
writeStderrLineSafe(`qwen: ${diagnostic.message}`);
|
|
1622
2192
|
}
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
/**
|
|
1627
|
-
* Replays usage metadata.
|
|
1628
|
-
* @param usageMetadata - The usage metadata to replay
|
|
1629
|
-
*/
|
|
1630
|
-
async replayUsageMetadata(usageMetadata) {
|
|
1631
|
-
await this.messageEmitter.emitUsageMetadata(usageMetadata);
|
|
1632
|
-
}
|
|
1633
|
-
/**
|
|
1634
|
-
* Replays a tool result record.
|
|
1635
|
-
*/
|
|
1636
|
-
async replayToolResult(record) {
|
|
1637
|
-
if (!record.message?.parts) {
|
|
1638
|
-
return;
|
|
1639
|
-
}
|
|
1640
|
-
const result = record.toolCallResult;
|
|
1641
|
-
const callId = getToolResultCallId(record);
|
|
1642
|
-
this.pendingReplayToolCalls.delete(callId);
|
|
1643
|
-
const toolName = this.extractToolNameFromRecord(record);
|
|
1644
|
-
await this.toolCallEmitter.emitResult({
|
|
1645
|
-
toolName,
|
|
1646
|
-
callId,
|
|
1647
|
-
success: result?.status === void 0 ? !result?.error : result.status === "success" && !result.error,
|
|
1648
|
-
message: record.message.parts,
|
|
1649
|
-
resultDisplay: result?.resultDisplay,
|
|
1650
|
-
artifacts: result?.artifacts,
|
|
1651
|
-
// For TodoWriteTool fallback, try to extract args from the record
|
|
1652
|
-
// Note: args aren't stored in tool_result records by default
|
|
1653
|
-
args: void 0,
|
|
1654
|
-
timestamp: record.timestamp
|
|
2193
|
+
}, "onDiagnostic")
|
|
1655
2194
|
});
|
|
1656
|
-
const { resultDisplay } = result ?? {};
|
|
1657
|
-
if (!!resultDisplay && typeof resultDisplay === "object" && "type" in resultDisplay && resultDisplay.type === "task_execution") {
|
|
1658
|
-
await this.emitTaskUsageFromResultDisplay(
|
|
1659
|
-
resultDisplay
|
|
1660
|
-
);
|
|
1661
|
-
}
|
|
1662
2195
|
}
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
toolName: pending.toolName,
|
|
1670
|
-
callId: pending.callId,
|
|
1671
|
-
success: false,
|
|
1672
|
-
message: [],
|
|
1673
|
-
error: new Error(MISSING_TOOL_RESULT_MESSAGE),
|
|
1674
|
-
timestamp: pending.timestamp
|
|
1675
|
-
});
|
|
1676
|
-
} catch (error) {
|
|
1677
|
-
firstError ??= error;
|
|
1678
|
-
} finally {
|
|
1679
|
-
this.setActiveRecordId(null);
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
if (firstError) {
|
|
1683
|
-
throw firstError;
|
|
1684
|
-
}
|
|
2196
|
+
presentationAdapter() {
|
|
2197
|
+
return {
|
|
2198
|
+
resolveToolMetadata: /* @__PURE__ */ __name((toolName, args) => this.toolCallEmitter.resolveToolMetadata(toolName, { ...args }), "resolveToolMetadata"),
|
|
2199
|
+
formatHistoryGap: /* @__PURE__ */ __name((gap) => formatHistoryGapNotice(gap), "formatHistoryGap"),
|
|
2200
|
+
buildToolResultContentPrefix
|
|
2201
|
+
};
|
|
1685
2202
|
}
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
async emitTaskUsageFromResultDisplay(resultDisplay) {
|
|
1690
|
-
const summary = resultDisplay.executionSummary;
|
|
1691
|
-
if (!summary) {
|
|
2203
|
+
async sendUpdate(update) {
|
|
2204
|
+
if (this.ctx.messageRewriter) {
|
|
2205
|
+
await this.ctx.messageRewriter.interceptUpdate(update);
|
|
1692
2206
|
return;
|
|
1693
2207
|
}
|
|
1694
|
-
|
|
1695
|
-
if (Number.isFinite(summary.inputTokens)) {
|
|
1696
|
-
usageMetadata.promptTokenCount = summary.inputTokens;
|
|
1697
|
-
}
|
|
1698
|
-
if (Number.isFinite(summary.outputTokens)) {
|
|
1699
|
-
usageMetadata.candidatesTokenCount = summary.outputTokens;
|
|
1700
|
-
}
|
|
1701
|
-
if (Number.isFinite(summary.thoughtTokens)) {
|
|
1702
|
-
usageMetadata.thoughtsTokenCount = summary.thoughtTokens;
|
|
1703
|
-
}
|
|
1704
|
-
if (Number.isFinite(summary.cachedTokens)) {
|
|
1705
|
-
usageMetadata.cachedContentTokenCount = summary.cachedTokens;
|
|
1706
|
-
}
|
|
1707
|
-
if (Number.isFinite(summary.totalTokens)) {
|
|
1708
|
-
usageMetadata.totalTokenCount = summary.totalTokens;
|
|
1709
|
-
}
|
|
1710
|
-
if (Object.keys(usageMetadata).length > 0) {
|
|
1711
|
-
await this.messageEmitter.emitUsageMetadata(usageMetadata);
|
|
1712
|
-
}
|
|
2208
|
+
await this.ctx.sendUpdate(update);
|
|
1713
2209
|
}
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
* the client would lose the goal card (and its status pill) on every reload.
|
|
1722
|
-
* Per-iteration `checking` cards are skipped — a TUI transcript persists one
|
|
1723
|
-
* per stop-hook turn, and clients suppress them as noise. Skipping costs no
|
|
1724
|
-
* fidelity: goal restore reads the records directly, not this replay.
|
|
1725
|
-
*/
|
|
1726
|
-
async replaySlashCommandResult(record) {
|
|
1727
|
-
const payload = record.systemPayload;
|
|
1728
|
-
if (payload?.phase !== "result") return;
|
|
1729
|
-
const items = payload.outputHistoryItems;
|
|
1730
|
-
if (!Array.isArray(items) || items.length === 0) return;
|
|
1731
|
-
for (const item of items) {
|
|
1732
|
-
const goalStatus = parseGoalStatusItem(item);
|
|
1733
|
-
if (goalStatus) {
|
|
1734
|
-
if (goalConditionBlockedBy(goalStatus.condition)) {
|
|
1735
|
-
writeStderrLineSafe(
|
|
1736
|
-
"qwen: skipping replay of a goal card whose condition is empty."
|
|
1737
|
-
);
|
|
1738
|
-
} else if (goalStatus.kind !== "checking") {
|
|
1739
|
-
const { type: _type, ...status } = goalStatus;
|
|
1740
|
-
await this.messageEmitter.emitGoalStatus(status);
|
|
1741
|
-
}
|
|
1742
|
-
continue;
|
|
1743
|
-
}
|
|
1744
|
-
const text = isTranscriptItemRecord(item) && typeof item["text"] === "string" ? item["text"] : "";
|
|
1745
|
-
if (text) {
|
|
1746
|
-
await this.messageEmitter.emitSlashCommandOutput(
|
|
1747
|
-
text.replace(/\n/g, " \n"),
|
|
1748
|
-
record.timestamp
|
|
1749
|
-
);
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
2210
|
+
copyCumulativeUsage(state) {
|
|
2211
|
+
const cumulative = this.ctx.cumulativeUsage;
|
|
2212
|
+
if (!cumulative) return;
|
|
2213
|
+
cumulative.promptTokens = state.cumulativeUsage.promptTokens;
|
|
2214
|
+
cumulative.cachedTokens = state.cumulativeUsage.cachedTokens;
|
|
2215
|
+
cumulative.candidateTokens = state.cumulativeUsage.candidateTokens;
|
|
2216
|
+
cumulative.apiTimeMs = state.cumulativeUsage.apiTimeMs;
|
|
1752
2217
|
}
|
|
1753
2218
|
/**
|
|
1754
2219
|
* Emits a trailing `cleared` card when the transcript ends on an active goal
|
|
@@ -1786,27 +2251,62 @@ var HistoryReplayer = class {
|
|
|
1786
2251
|
lastReason: GOAL_NOT_RESTORED_REASON[blockedBy]
|
|
1787
2252
|
});
|
|
1788
2253
|
}
|
|
1789
|
-
/**
|
|
1790
|
-
* Extracts tool name from a chat record's function response.
|
|
1791
|
-
*/
|
|
1792
|
-
extractToolNameFromRecord(record) {
|
|
1793
|
-
if (record.message?.parts) {
|
|
1794
|
-
for (const part of record.message.parts) {
|
|
1795
|
-
if ("functionResponse" in part && part.functionResponse?.name) {
|
|
1796
|
-
return part.functionResponse.name;
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
}
|
|
1800
|
-
return "";
|
|
1801
|
-
}
|
|
1802
2254
|
setActiveRecordId(recordId, timestamp) {
|
|
1803
2255
|
this.ctx.setActiveRecordId?.(recordId, timestamp);
|
|
1804
2256
|
}
|
|
1805
2257
|
};
|
|
2258
|
+
function toPendingTranscriptToolCall(pending) {
|
|
2259
|
+
return {
|
|
2260
|
+
callId: pending.callId,
|
|
2261
|
+
toolName: pending.toolName,
|
|
2262
|
+
sourceRecordId: pending.recordId,
|
|
2263
|
+
...pending.timestamp ? { sourceTimestamp: pending.timestamp } : {}
|
|
2264
|
+
};
|
|
2265
|
+
}
|
|
2266
|
+
__name(toPendingTranscriptToolCall, "toPendingTranscriptToolCall");
|
|
2267
|
+
function toLegacyPendingToolCall(pending) {
|
|
2268
|
+
return {
|
|
2269
|
+
callId: pending.callId,
|
|
2270
|
+
toolName: pending.toolName,
|
|
2271
|
+
recordId: pending.sourceRecordId,
|
|
2272
|
+
...pending.sourceTimestamp ? { timestamp: pending.sourceTimestamp } : {}
|
|
2273
|
+
};
|
|
2274
|
+
}
|
|
2275
|
+
__name(toLegacyPendingToolCall, "toLegacyPendingToolCall");
|
|
1806
2276
|
|
|
1807
2277
|
// packages/cli/src/ui/utils/export/collect.ts
|
|
1808
2278
|
init_esbuild_shims();
|
|
1809
2279
|
import { randomUUID } from "node:crypto";
|
|
2280
|
+
|
|
2281
|
+
// packages/cli/src/utils/chat-record-tool-call-id.ts
|
|
2282
|
+
init_esbuild_shims();
|
|
2283
|
+
function getToolResultCallId(record) {
|
|
2284
|
+
return getExplicitToolResultCallId(record) ?? record.uuid;
|
|
2285
|
+
}
|
|
2286
|
+
__name(getToolResultCallId, "getToolResultCallId");
|
|
2287
|
+
function getExplicitToolResultCallId(record) {
|
|
2288
|
+
const resultCallId = record.toolCallResult?.callId;
|
|
2289
|
+
if (typeof resultCallId === "string" && resultCallId.length > 0) {
|
|
2290
|
+
return resultCallId;
|
|
2291
|
+
}
|
|
2292
|
+
return extractFunctionResponseId(record);
|
|
2293
|
+
}
|
|
2294
|
+
__name(getExplicitToolResultCallId, "getExplicitToolResultCallId");
|
|
2295
|
+
function extractFunctionResponseId(record) {
|
|
2296
|
+
if (!record.message?.parts) {
|
|
2297
|
+
return void 0;
|
|
2298
|
+
}
|
|
2299
|
+
for (const part of record.message.parts) {
|
|
2300
|
+
const id = "functionResponse" in part ? part.functionResponse?.id : void 0;
|
|
2301
|
+
if (typeof id === "string" && id.length > 0) {
|
|
2302
|
+
return id;
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
return void 0;
|
|
2306
|
+
}
|
|
2307
|
+
__name(extractFunctionResponseId, "extractFunctionResponseId");
|
|
2308
|
+
|
|
2309
|
+
// packages/cli/src/ui/utils/export/collect.ts
|
|
1810
2310
|
function extractToolNameFromRecord(record) {
|
|
1811
2311
|
if (!record.message?.parts) {
|
|
1812
2312
|
return void 0;
|
|
@@ -1993,7 +2493,7 @@ async function extractMetadata(conversation, config) {
|
|
|
1993
2493
|
const gitBranch = firstRecord?.gitBranch;
|
|
1994
2494
|
let gitRepo;
|
|
1995
2495
|
if (cwd) {
|
|
1996
|
-
const { getGitRepoName } = await import("./src-
|
|
2496
|
+
const { getGitRepoName } = await import("./src-Q4XB6SVD.js");
|
|
1997
2497
|
gitRepo = getGitRepoName(cwd);
|
|
1998
2498
|
}
|
|
1999
2499
|
let model;
|
|
@@ -2220,6 +2720,20 @@ __name(collectSessionData, "collectSessionData");
|
|
|
2220
2720
|
|
|
2221
2721
|
// packages/cli/src/ui/utils/export/normalize.ts
|
|
2222
2722
|
init_esbuild_shims();
|
|
2723
|
+
|
|
2724
|
+
// packages/cli/src/utils/truncatedDiffPreview.ts
|
|
2725
|
+
init_esbuild_shims();
|
|
2726
|
+
function buildTruncatedDiffPreviewText2(display) {
|
|
2727
|
+
const fileName = typeof display["fileName"] === "string" ? display["fileName"] : "the edited file";
|
|
2728
|
+
const fileDiffLength = typeof display["fileDiffLength"] === "number" ? ` Original fileDiff length: ${display["fileDiffLength"]} chars.` : "";
|
|
2729
|
+
if (display["fileDiffTruncated"] === true) {
|
|
2730
|
+
return `Full diff omitted from saved session history for ${fileName}.${fileDiffLength}`;
|
|
2731
|
+
}
|
|
2732
|
+
return `Saved session preview only for ${fileName}; full original and new file contents are unavailable.`;
|
|
2733
|
+
}
|
|
2734
|
+
__name(buildTruncatedDiffPreviewText2, "buildTruncatedDiffPreviewText");
|
|
2735
|
+
|
|
2736
|
+
// packages/cli/src/ui/utils/export/normalize.ts
|
|
2223
2737
|
function normalizeSessionData(sessionData, originalRecords, config) {
|
|
2224
2738
|
const normalized = [...sessionData.messages];
|
|
2225
2739
|
const toolCallIndexById = /* @__PURE__ */ new Map();
|
|
@@ -2308,7 +2822,7 @@ function buildToolCallMessageFromResult(record, config) {
|
|
|
2308
2822
|
const rawInput = normalizeRawInput(
|
|
2309
2823
|
functionCallArgs ?? toolCallResult?.args
|
|
2310
2824
|
);
|
|
2311
|
-
const resultContent =
|
|
2825
|
+
const resultContent = extractDiffContent2(toolCallResult?.resultDisplay) ?? transformPartsToToolCallContent(record.message?.parts ?? []);
|
|
2312
2826
|
const content = isVisionBridgeNoticeDisplay(toolCallResult?.resultDisplay) ? [
|
|
2313
2827
|
{
|
|
2314
2828
|
type: "content",
|
|
@@ -2408,7 +2922,7 @@ function mapToolKind(kind, toolName) {
|
|
|
2408
2922
|
return "other";
|
|
2409
2923
|
}
|
|
2410
2924
|
__name(mapToolKind, "mapToolKind");
|
|
2411
|
-
function
|
|
2925
|
+
function extractDiffContent2(resultDisplay) {
|
|
2412
2926
|
if (!resultDisplay || typeof resultDisplay !== "object") {
|
|
2413
2927
|
return null;
|
|
2414
2928
|
}
|
|
@@ -2420,7 +2934,7 @@ function extractDiffContent(resultDisplay) {
|
|
|
2420
2934
|
type: "content",
|
|
2421
2935
|
content: {
|
|
2422
2936
|
type: "text",
|
|
2423
|
-
text:
|
|
2937
|
+
text: buildTruncatedDiffPreviewText2(display)
|
|
2424
2938
|
}
|
|
2425
2939
|
}
|
|
2426
2940
|
];
|
|
@@ -2436,7 +2950,7 @@ function extractDiffContent(resultDisplay) {
|
|
|
2436
2950
|
}
|
|
2437
2951
|
return null;
|
|
2438
2952
|
}
|
|
2439
|
-
__name(
|
|
2953
|
+
__name(extractDiffContent2, "extractDiffContent");
|
|
2440
2954
|
function normalizeRawInput(value) {
|
|
2441
2955
|
if (typeof value === "string") return value;
|
|
2442
2956
|
if (typeof value === "object" && value !== null) return value;
|