@qwen-code/qwen-code 0.21.0 → 0.21.1-nightly.20260731.702932cc7
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/model-providers.md +2 -0
- package/bundled/qc-helper/docs/configuration/settings.md +39 -28
- package/bundled/qc-helper/docs/features/channels/_meta.ts +2 -0
- package/bundled/qc-helper/docs/features/channels/github.md +139 -0
- package/bundled/qc-helper/docs/features/channels/gitlab.md +171 -0
- package/bundled/qc-helper/docs/features/channels/overview.md +61 -6
- package/bundled/qc-helper/docs/features/code-review.md +21 -1
- package/bundled/qc-helper/docs/features/hooks.md +72 -15
- package/bundled/qc-helper/docs/features/mcp.md +9 -1
- package/bundled/qc-helper/docs/features/scheduled-tasks.md +3 -1
- package/bundled/qc-helper/docs/features/sub-agents.md +42 -8
- package/bundled/qc-helper/docs/qwen-serve.md +11 -7
- package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +2 -2
- package/bundled/qc-helper/docs/support/troubleshooting.md +2 -1
- package/bundled/review/DESIGN.md +19 -0
- package/bundled/review/SKILL.md +120 -61
- package/chunks/MaxSizedBox-LAFHK4VO.js +88 -0
- package/chunks/{StandaloneSessionPicker-BIRMPLRD.js → StandaloneSessionPicker-EMNOBN3S.js} +71 -68
- package/chunks/{acp-startup-profiler-RV3IV562.js → acp-startup-profiler-2C4A5ZTJ.js} +2 -2
- package/chunks/{acpAgent-6J2U72PQ.js → acpAgent-ERFA6HWV.js} +1674 -591
- package/chunks/agent-PLKF6JK4.js +84 -0
- package/chunks/agent-headless-JAORDQ63.js +78 -0
- package/chunks/{anthropicContentGenerator-75BKLTSP.js → anthropicContentGenerator-OFHSZJBF.js} +79 -27
- package/chunks/{artifact-tool-Y5T7GG7F.js → artifact-tool-RDN2W7ND.js} +4 -4
- package/chunks/{askUserQuestion-2H6747FR.js → askUserQuestion-OZERWH5R.js} +4 -4
- package/chunks/bridge-NYOBVRIT.js +94 -0
- package/chunks/{build-RV63TIRH.js → build-GDBLPA24.js} +1 -1
- package/chunks/{ca-25EDXPFZ.js → ca-6W3SK7OQ.js} +6 -1
- package/chunks/channel-management-service-5S7YCWX5.js +418 -0
- package/chunks/channel-settings-store-NLOKYO23.js +91 -0
- package/chunks/{channel-worker-group-2ZD7TVAT.js → channel-worker-group-OVWGYMZS.js} +11 -6
- package/chunks/{channel-worker-manager-4OA4BCGB.js → channel-worker-manager-H55GKOQA.js} +11 -6
- package/chunks/{channel-worker-supervisor-V7KCFJTS.js → channel-worker-supervisor-CABBXYHK.js} +7 -5
- package/chunks/{chunk-RIBKPMRP.js → chunk-23F4XGWO.js} +19 -6
- package/chunks/{chunk-ACY3A37B.js → chunk-25VHI5T7.js} +23 -18
- package/chunks/{chunk-MZAXJAUM.js → chunk-26JK4RPD.js} +1 -1
- package/chunks/{chunk-6GMVPFB2.js → chunk-2IIJTXYF.js} +45 -16
- package/chunks/{chunk-BPJSQIJX.js → chunk-2J3OJGTL.js} +0 -2
- package/chunks/{chunk-2X55UKQE.js → chunk-2JZR3B4A.js} +3 -3
- package/chunks/{chunk-7JURR4JT.js → chunk-2OQUICDM.js} +167 -81
- package/chunks/{chunk-ZJHVAS7M.js → chunk-2YCYFWYZ.js} +4 -5
- package/chunks/{chunk-3QMGYBFN.js → chunk-3APUUXRF.js} +1 -80
- package/chunks/{chunk-MUP3T3AD.js → chunk-3I6DUGQD.js} +1 -35
- package/chunks/{chunk-JVPM2ULZ.js → chunk-3XZ5SSNR.js} +6 -6
- package/chunks/chunk-42VPM33K.js +319 -0
- package/chunks/{chunk-VAK25FTU.js → chunk-45IOTAUS.js} +1 -1
- package/chunks/chunk-45UYUCJ6.js +363 -0
- package/chunks/{chunk-JZA3JUDJ.js → chunk-4KP2F2TE.js} +1 -1
- package/chunks/{chunk-IO3IX5Q4.js → chunk-4YJQD2IO.js} +1 -1
- package/chunks/{chunk-JXJFVC6E.js → chunk-5G6XUGXO.js} +61 -14
- package/chunks/{chunk-ZOIFNCKL.js → chunk-5NNHICSA.js} +3 -23
- package/chunks/{chunk-A4UCTEB5.js → chunk-5WV5S2GT.js} +0 -1
- package/chunks/{chunk-RHLZR4E5.js → chunk-675H6PLP.js} +1 -1
- package/chunks/chunk-6FMJLI5M.js +1591 -0
- package/chunks/chunk-6MPDY6ZG.js +76 -0
- package/chunks/{chunk-PSOO6YXD.js → chunk-6NUWQ3R7.js} +9 -7
- package/chunks/{chunk-7MVVZO4N.js → chunk-6ZRWX46I.js} +4 -4
- package/chunks/{chunk-TPRQ7RZH.js → chunk-76E5Y3UZ.js} +3117 -993
- package/chunks/{chunk-UUUTRMI2.js → chunk-7ULQIS27.js} +1 -1
- package/chunks/{chunk-BKHWX6I2.js → chunk-A5BZ722X.js} +11 -3
- package/chunks/{chunk-TEHGS6UP.js → chunk-A5T5W7PR.js} +154 -16
- package/chunks/{chunk-VIA5XA4U.js → chunk-A5UODYG3.js} +4 -1
- package/chunks/{chunk-JLU636DO.js → chunk-ALMR3E6Q.js} +1 -0
- package/chunks/{chunk-EBJQ6AXW.js → chunk-ANDVK2JN.js} +358 -14
- package/chunks/{chunk-TOFQCPDC.js → chunk-AOHY3QJ3.js} +14 -8
- package/chunks/chunk-AQ37AY7B.js +93 -0
- package/chunks/{chunk-PJIZUQVC.js → chunk-AZQ3DT76.js} +2 -2
- package/chunks/{chunk-LKEJ26GS.js → chunk-B3TA3IF5.js} +16 -11
- package/chunks/{chunk-Q4M4MDQ4.js → chunk-B43QHWY6.js} +1 -1
- package/chunks/{chunk-UH3WSE5L.js → chunk-B4AJNNOL.js} +1 -6
- package/chunks/{chunk-K36B6G2O.js → chunk-B6FOGNGH.js} +5 -5
- package/chunks/{chunk-PWVFN2LF.js → chunk-BP2H5K25.js} +1 -1
- package/chunks/{chunk-LB6DUZ26.js → chunk-BTWSGZCT.js} +264 -185
- package/chunks/{chunk-ZNAUOR2I.js → chunk-BZBPT52P.js} +2 -2
- package/chunks/{chunk-L26JL52R.js → chunk-CBBP4BMC.js} +64 -67
- package/chunks/{chunk-ZD6UTE4A.js → chunk-CNTR4GR6.js} +1 -1
- package/chunks/{chunk-3SJ43L4W.js → chunk-CPZAH673.js} +6 -0
- package/chunks/{chunk-EPDRMGT4.js → chunk-D4HTUMGX.js} +4 -28
- package/chunks/{chunk-QAF7NMK7.js → chunk-D7CQTWRS.js} +1 -1
- package/chunks/{chunk-XVNQMZ2I.js → chunk-DGEIYUC3.js} +0 -1
- package/chunks/{chunk-BPZALHVR.js → chunk-DI35ZN7T.js} +1 -1
- package/chunks/{chunk-IKCX4CCL.js → chunk-DKPJUF5F.js} +118 -95
- package/chunks/{chunk-DLWL3Z7A.js → chunk-DSFHVTWD.js} +3 -3
- package/chunks/{chunk-FSITMZJH.js → chunk-DYRYLJ3O.js} +18 -9
- package/chunks/{chunk-NL7LTRLR.js → chunk-E2BHWIDT.js} +48 -72
- package/chunks/{chunk-UDX5OBWR.js → chunk-E2FN6SM7.js} +94 -4
- package/chunks/{chunk-USTWD7QV.js → chunk-E6CJ2SMM.js} +26 -16
- package/chunks/{chunk-KMQ33DO4.js → chunk-EDB7A72S.js} +4 -4
- package/chunks/{chunk-7ZCNENPP.js → chunk-FANRZEAJ.js} +1 -1
- package/chunks/{chunk-WBL3FJEU.js → chunk-FC4KQFCS.js} +1 -1
- package/chunks/{chunk-5NBDS5S6.js → chunk-FCYYAB4S.js} +162 -7
- package/chunks/{chunk-OKY7HXPG.js → chunk-FJ5WUMUQ.js} +2 -2
- package/chunks/{chunk-PHOF65IG.js → chunk-FRXG4ARO.js} +36273 -44436
- package/chunks/{chunk-FQK6JAFG.js → chunk-FS674JW4.js} +4 -4
- package/chunks/chunk-FYJ7W2PI.js +194 -0
- package/chunks/{chunk-BULDBTYC.js → chunk-G7XXKQYS.js} +3 -28
- package/chunks/{chunk-LS77BEZP.js → chunk-GLCZKT5V.js} +1 -5
- package/chunks/{chunk-VRYUBFMC.js → chunk-GRUAVQQR.js} +1 -1
- package/chunks/{chunk-MVSUYZDT.js → chunk-GWV7DI3S.js} +4 -4
- package/chunks/{chunk-A5L3JMUA.js → chunk-HC45LTEN.js} +18 -4
- package/chunks/{chunk-PC6JANNU.js → chunk-HKRVXYDN.js} +4 -4
- package/chunks/{chunk-GZXCZHCT.js → chunk-I3G5JWBV.js} +1 -1
- package/chunks/{chunk-4WIZGAH3.js → chunk-I5BT7ADR.js} +6 -58
- package/chunks/{chunk-GSN55ZRI.js → chunk-ID3O7PRB.js} +19 -7
- package/chunks/{chunk-L5UHQJTJ.js → chunk-IGTHU3T4.js} +1 -1
- package/chunks/{chunk-BIQWWWJN.js → chunk-IIUGIWWY.js} +1 -1
- package/chunks/{chunk-RWTEFFPU.js → chunk-JCJ7LKNA.js} +6140 -5616
- package/chunks/{chunk-S3TWXGKA.js → chunk-JE7KQ2UP.js} +4 -2
- package/chunks/{chunk-PWTZEM3C.js → chunk-JXVC2PL3.js} +3 -37
- package/chunks/chunk-JYBU6YUE.js +378 -0
- package/chunks/{chunk-RF3EXIHJ.js → chunk-K3PFMM5U.js} +49 -26
- package/chunks/{chunk-JCW2R7WC.js → chunk-K623ENWT.js} +3 -79
- package/chunks/{chunk-T2NCM2ET.js → chunk-K6KS3LTN.js} +2 -749
- package/chunks/chunk-KWHKHSIS.js +81 -0
- package/chunks/{chunk-DHHOYAPR.js → chunk-L2E5GFAG.js} +7 -7
- package/chunks/{chunk-2W3OOD4W.js → chunk-L55JWS76.js} +6 -3
- package/chunks/{chunk-E5TUC6CA.js → chunk-LHKCY7DY.js} +3 -3
- package/chunks/{chunk-NH6KE4JX.js → chunk-LOY7RWQG.js} +3 -3
- package/chunks/{chunk-U7M2DMGW.js → chunk-M4MSAE7U.js} +130 -5
- package/chunks/{chunk-IJTOWOD7.js → chunk-MB32MS4U.js} +92 -9
- package/chunks/{chunk-PR75REBZ.js → chunk-MM7TH7ZM.js} +12 -82
- package/chunks/{chunk-FODK6UMO.js → chunk-MPHPFVKK.js} +0 -2
- package/chunks/{chunk-M5JM7OSF.js → chunk-N4ACHWNH.js} +2 -3
- package/chunks/{chunk-JESCGQM3.js → chunk-NAVJD2PQ.js} +8 -7
- package/chunks/{chunk-J56UI34H.js → chunk-NBD76HUW.js} +4 -2
- package/chunks/{chunk-2SCDWPXI.js → chunk-NC4U4I3Y.js} +5 -5
- package/chunks/{chunk-H4SBPHSA.js → chunk-NNL7WPPK.js} +3 -3
- package/chunks/{chunk-YBL3QUDD.js → chunk-NQCXWP5D.js} +1 -1
- package/chunks/{chunk-CIKQ7KKO.js → chunk-NVFSGPIF.js} +954 -444
- package/chunks/{chunk-6OUGMXDC.js → chunk-NWNEANAT.js} +7 -7
- package/chunks/chunk-O6GEWCJA.js +21 -0
- package/chunks/chunk-OCPBI7J5.js +18 -0
- package/chunks/{chunk-KIM5GUMA.js → chunk-OE6F6ZWQ.js} +589 -220
- package/chunks/{chunk-SQCQ4KO2.js → chunk-P5DEY3NF.js} +380 -317
- package/chunks/{chunk-2JZBVYTU.js → chunk-Q3T5KA2V.js} +1 -8
- package/chunks/{chunk-MB4MZHMJ.js → chunk-QARJNL2V.js} +211 -522
- package/chunks/{chunk-YH6G52F2.js → chunk-QCXGC7QB.js} +4 -4
- package/chunks/chunk-QDK4F2N5.js +1252 -0
- package/chunks/{chunk-VDDGDZMA.js → chunk-QHWCP53L.js} +14 -7
- package/chunks/{chunk-VULLI6WQ.js → chunk-QIERF2GQ.js} +6 -6
- package/chunks/{chunk-TGILQ3YH.js → chunk-QQTJK5GB.js} +200 -77
- package/chunks/{chunk-H5FFA6TH.js → chunk-QTHQ6Z5X.js} +16 -3
- package/chunks/{chunk-5I2IWRSH.js → chunk-R2XWGR75.js} +2 -2
- package/chunks/{chunk-YPE6A4GC.js → chunk-RT7FNC2O.js} +2 -2
- package/chunks/{chunk-OFDOK3VM.js → chunk-RX7NJOPE.js} +8 -13
- package/chunks/{chunk-6AM5D4ME.js → chunk-S6LOFUVP.js} +0 -12
- package/chunks/{chunk-K4XWPEWB.js → chunk-SHN4KHDK.js} +4 -33
- package/chunks/{chunk-VYPFXUCB.js → chunk-SZ3KHTDR.js} +1 -1
- package/chunks/chunk-T26EAKDL.js +13 -0
- package/chunks/chunk-T3CHYWJZ.js +758 -0
- package/chunks/{chunk-FNQ6T3CV.js → chunk-TEGJSJDF.js} +10 -7
- package/chunks/{chunk-RZIX2G32.js → chunk-THPORXSI.js} +1 -1
- package/chunks/{chunk-OHNBB4XR.js → chunk-THVU3RNH.js} +1 -1
- package/chunks/{record-artifact-RQKFYO5B.js → chunk-TIRRPCFS.js} +22 -7
- package/chunks/{chunk-ETSW4KLJ.js → chunk-TUCOXPHJ.js} +2 -2
- package/chunks/{chunk-63P4EL5V.js → chunk-TZTAV5RH.js} +1 -1
- package/chunks/{chunk-LK7CHLVP.js → chunk-U4VTUMMK.js} +0 -60
- package/chunks/{chunk-3RN6GBKS.js → chunk-U5CODIJW.js} +1 -1
- package/chunks/chunk-UU2B5YG6.js +2196 -0
- package/chunks/{chunk-R5AFZNQW.js → chunk-VAVHTGU4.js} +15 -8
- package/chunks/{chunk-2NH6DYI4.js → chunk-VHPFWR2O.js} +12 -12
- package/chunks/{chunk-IKYJHJNF.js → chunk-VOMQ2P6B.js} +3 -3
- package/chunks/{chunk-ZFDTEDCF.js → chunk-VX22DUW2.js} +6 -6
- package/chunks/{chunk-HTR4WV6U.js → chunk-W4RQUHY3.js} +31 -1
- package/chunks/{chunk-M4FMGVY4.js → chunk-WQP7BKWA.js} +3 -3
- package/chunks/{chunk-LH2BYDQ5.js → chunk-X2E5TFJ5.js} +18 -12
- package/chunks/{chunk-COH43MRJ.js → chunk-XCGIMOLN.js} +27 -1
- package/chunks/{chunk-YX324OPW.js → chunk-XDS22O52.js} +1 -1
- package/chunks/chunk-XP4L6KS3.js +463 -0
- package/chunks/{chunk-6FGBXPWM.js → chunk-XQK4XXTN.js} +38 -44
- package/chunks/{chunk-55DJUCI2.js → chunk-XWYPFDB5.js} +53 -43
- package/chunks/{chunk-Y34KJKDC.js → chunk-Y7BVNVVW.js} +1 -1
- package/chunks/{chunk-IPUUTYMV.js → chunk-YDLJGZHL.js} +1 -1
- package/chunks/{chunk-HIJQF5B5.js → chunk-YGE3IXJP.js} +1 -1
- package/chunks/{chunk-LQIW3YFY.js → chunk-YJFPRUWX.js} +9 -7
- package/chunks/{chunk-J24WCGIN.js → chunk-YQIIG4NA.js} +4 -4
- package/chunks/{chunk-BJX6ZSUK.js → chunk-YUFIEIWC.js} +2 -2
- package/chunks/{chunk-NIBLUX3Y.js → chunk-Z3S5EMOW.js} +148 -21
- package/chunks/{chunk-WCXCRJYB.js → chunk-Z3YLHKB7.js} +1 -1
- package/chunks/chunk-Z4X5MTRT.js +133 -0
- package/chunks/{chunk-UW5EOVUN.js → chunk-ZBVS26BY.js} +4 -4
- package/chunks/{chunk-HTO4JFDZ.js → chunk-ZPJWUGCS.js} +0 -1
- package/chunks/{chunk-X5XDDSSH.js → chunk-ZPZ7ZJEE.js} +28 -5
- package/chunks/{computer-use-SOQ4E3VX.js → computer-use-GOM42LNK.js} +53 -50
- package/chunks/{config-utils-7V7GGIW6.js → config-utils-WADIDWGG.js} +4 -3
- package/chunks/contextCommand-6LVPTIWD.js +83 -0
- package/chunks/core-runtime-253XV2DB.js +137 -0
- package/chunks/{create-sub-session-QRJLW5BV.js → create-sub-session-45POYEVP.js} +50 -47
- package/chunks/{create-sub-session-IWW2IZ2T.js → create-sub-session-62YZWVAY.js} +3 -3
- package/chunks/{cron-create-YIID5XAW.js → cron-create-6E7GIQTG.js} +6 -6
- package/chunks/{cron-delete-ZVHYCEP2.js → cron-delete-JD26XY3W.js} +5 -5
- package/chunks/{cron-list-XEGS463Q.js → cron-list-CUWFB44G.js} +6 -6
- package/chunks/{daemon-YO6433NF.js → daemon-PCNCI5YU.js} +428 -18
- package/chunks/daemon-status-provider-AKALDYJJ.js +93 -0
- package/chunks/daemon-trust-policy-XB7ZSQFQ.js +88 -0
- package/chunks/daemon-trust-policy-monitor-FUTKP42Q.js +175 -0
- package/chunks/{de-HGRCYDEJ.js → de-SY6O76BF.js} +6 -1
- package/chunks/deferred-core-runtime-RKLCO7V5.js +92 -0
- package/chunks/dist-26BIMQT6.js +4487 -0
- package/chunks/{dist-F6IBUDR4.js → dist-2PERFI23.js} +12 -9
- package/chunks/{dist-46NQKLTW.js → dist-OAOC5OV4.js} +2 -2
- package/chunks/{dist-YFNEUWSE.js → dist-PVEAFLHY.js} +5 -4
- package/chunks/{dist-AIKFMUKK.js → dist-SL2LUMML.js} +1449 -14
- package/chunks/dist-ULIG4M5H.js +13415 -0
- package/chunks/{dist-WEAHOXDM.js → dist-WGMNT3JQ.js} +2 -1
- package/chunks/{dist-BBLXMS3N.js → dist-ZHXOBXDN.js} +3 -3
- package/chunks/earlyInputCapture-FCWU47OB.js +85 -0
- package/chunks/{edit-OBDSQURM.js → edit-TTACM3LN.js} +51 -48
- package/chunks/{en-MTWBNGDO.js → en-NBK3JKCE.js} +9 -1
- package/chunks/{enter-worktree-U6MRPQ2P.js → enter-worktree-R34GFDX6.js} +51 -48
- package/chunks/{enterPlanMode-BC5QUZZ2.js → enterPlanMode-KJPBB6G5.js} +51 -48
- package/chunks/environment-IJG3N2PR.js +105 -0
- package/chunks/errors-MRON5OJD.js +91 -0
- package/chunks/esm-K5FARBNI.js +5548 -0
- package/chunks/{exit-worktree-DGNYMECB.js → exit-worktree-UBA66Y4I.js} +51 -48
- package/chunks/exitPlanMode-SMSPGNSK.js +76 -0
- package/chunks/{fast-path-JJZFJANL.js → fast-path-ZBAMZDCP.js} +16 -6
- package/chunks/{fr-45RLL55O.js → fr-4KG5V7UT.js} +6 -1
- package/chunks/{gemini-QS36EBZV.js → gemini-XFT7HRNL.js} +106 -99
- package/chunks/{geminiContentGenerator-AG4KB6CV.js → geminiContentGenerator-XD3MLYQX.js} +40 -11
- package/chunks/{getMachineId-bsd-V7W3GODC.js → getMachineId-bsd-FG7IUY6U.js} +1 -1
- package/chunks/{getMachineId-darwin-TDO75DQP.js → getMachineId-darwin-GLCJI2RA.js} +1 -1
- package/chunks/{getMachineId-linux-TF43WQT2.js → getMachineId-linux-O6OPPAKO.js} +1 -1
- package/chunks/{getMachineId-unsupported-ZGUO3TXT.js → getMachineId-unsupported-S6CKYVGC.js} +1 -1
- package/chunks/{getMachineId-win-ECFYZZFQ.js → getMachineId-win-X5SRNEH7.js} +1 -1
- package/chunks/{glob-V7R3PSK3.js → glob-HFKY7HXZ.js} +51 -48
- package/chunks/goal-tools-HGO6VXPB.js +335 -0
- package/chunks/{grep-QYPSK7OP.js → grep-EO5Z3PFV.js} +53 -49
- package/chunks/handleAutoUpdate-WRENFE6C.js +84 -0
- package/chunks/i18n-ZG5OTVSV.js +100 -0
- package/chunks/{image-gen-Z3VPGKRC.js → image-gen-CKWZ4MJI.js} +12 -12
- package/chunks/initializer-FYPLLRC7.js +89 -0
- package/chunks/installationInfo-5RV4HRMC.js +83 -0
- package/chunks/{ja-B7DF7DFG.js → ja-F3GSQXMF.js} +6 -1
- package/chunks/{keychain-token-storage-MDTG3WRM.js → keychain-token-storage-IKO4G53C.js} +3 -3
- package/chunks/lib-RUF3WZA6.js +9 -0
- package/chunks/list-ZNWVL3AT.js +92 -0
- package/chunks/{list-agents-5KJJHR6I.js → list-agents-PXJ7ZUFB.js} +3 -3
- package/chunks/loadedSettingsAdapter-GQGNHP5I.js +86 -0
- package/chunks/{loggingContentGenerator-HS3S5H3Q.js → loggingContentGenerator-MS5DFAWH.js} +78 -113
- package/chunks/{loop-wakeup-FXKNNYSY.js → loop-wakeup-Y26NQZ5I.js} +15 -8
- package/chunks/{ls-NTK6VOQJ.js → ls-ONQTTMQR.js} +5 -5
- package/chunks/{lsp-2JI24STP.js → lsp-YGHHRGMD.js} +3 -3
- package/chunks/{managed-npm-update-JYEMMXA3.js → managed-npm-update-67AK4GTL.js} +51 -48
- package/chunks/mcp-FVQ4VTLM.js +86 -0
- package/chunks/{monitor-R3ODH5U6.js → monitor-BXB33EOZ.js} +51 -48
- package/chunks/nonInteractiveCli-CN2GYSN3.js +148 -0
- package/chunks/{notebook-edit-BNOK452R.js → notebook-edit-FKYRBV4L.js} +51 -48
- package/chunks/{openaiContentGenerator-WMCU3O2H.js → openaiContentGenerator-UUXV5DGU.js} +26 -27
- package/chunks/pidfile-MV347TTZ.js +89 -0
- package/chunks/process-registry-2CHQBXH5.js +157 -0
- package/chunks/{processUtils-RT7UNCC2.js → processUtils-LKFG52RV.js} +2 -2
- package/chunks/{pt-22Q3FP73.js → pt-EQ33KWEN.js} +6 -1
- package/chunks/{qwenContentGenerator-HHCRK4SX.js → qwenContentGenerator-3WYI2HRW.js} +56 -53
- package/chunks/{qwenOAuth2-OWLB5AKH.js → qwenOAuth2-B46MW45O.js} +10 -10
- package/chunks/read-file-ACSHVWP3.js +29 -0
- package/chunks/{read-mcp-resource-4DKQWGHD.js → read-mcp-resource-U2IJN5HM.js} +4 -4
- package/chunks/record-artifact-MGPJ7EG4.js +21 -0
- package/chunks/resumeHistoryUtils-AMS4767B.js +94 -0
- package/chunks/ripGrep-BAPM2UKC.js +76 -0
- package/chunks/{ru-FZCNZHDC.js → ru-7OZAUKGG.js} +6 -1
- package/chunks/{run-qwen-serve-FU6HEM4J.js → run-qwen-serve-JEN6FO2A.js} +1018 -263
- package/chunks/runtime-WVP22ISH.js +122 -0
- package/chunks/{scheduler-G2ZS2Z7E.js → scheduler-HTX5ACVR.js} +50 -47
- package/chunks/{sdk-exporters-grpc-AK3LGHNO.js → sdk-exporters-grpc-54L4LS5L.js} +4 -4
- package/chunks/{sdk-exporters-http-FYBSUCPD.js → sdk-exporters-http-4BQANSJ6.js} +7 -7
- package/chunks/{sdk-impl-GMVPB7NB.js → sdk-impl-Z4VXWVFX.js} +14 -14
- package/chunks/{send-message-Q6OOR6BR.js → send-message-PMP4ATVM.js} +8 -13
- package/chunks/serve-ELQIVNWN.js +92 -0
- package/chunks/{server-4UMH7OIZ.js → server-JNW2NOSQ.js} +5288 -1364
- package/chunks/{session-K3O3Q2SV.js → session-NC356XNS.js} +102 -95
- package/chunks/{settings-CR2EWTBA.js → settings-73RMIOJ6.js} +54 -51
- package/chunks/shell-NMHF5TFG.js +86 -0
- package/chunks/{skill-I3SDA4MB.js → skill-XPGXHEKO.js} +22 -22
- package/chunks/skill-settings-5IGIJDGA.js +94 -0
- package/chunks/spawnChannel-T5THBHFN.js +85 -0
- package/chunks/standalone-update-ODXEPDLP.js +95 -0
- package/chunks/{startInteractiveUI-SLZGHRPH.js → startInteractiveUI-S27DXVAE.js} +1241 -905
- package/chunks/{syntheticOutput-I3757IWH.js → syntheticOutput-D7E6ZFKR.js} +4 -4
- package/chunks/task-create-NFCYD43L.js +26 -0
- package/chunks/{task-list-FOPULZEP.js → task-list-TAVMGEVD.js} +7 -7
- package/chunks/{task-stop-H6RHXFVQ.js → task-stop-ZDF2UJRM.js} +3 -3
- package/chunks/{task-update-M57TFZJT.js → task-update-6L7LHGEX.js} +12 -11
- package/chunks/{team-create-YJALH5D2.js → team-create-CTLQWTJ2.js} +53 -50
- package/chunks/{team-delete-QE2UXJL7.js → team-delete-DPGGRQBU.js} +7 -7
- package/chunks/{team-plan-approval-34QFYKGN.js → team-plan-approval-WKRUAPJ4.js} +51 -48
- package/chunks/theme-manager-XQHXQQX6.js +80 -0
- package/chunks/{todoWrite-VQ7FKOHL.js → todoWrite-2UO5G6G6.js} +34 -6
- package/chunks/{tool-search-NF7GB6LE.js → tool-search-45YINAJA.js} +21 -22
- package/chunks/total-session-admission-QPUKGHKO.js +88 -0
- package/chunks/trustedFolders-YMUTRHEQ.js +98 -0
- package/chunks/{update-relaunch-WBUZJC5O.js → update-relaunch-PZUXTVHC.js} +5 -5
- package/chunks/updateCheck-IZAN4XTB.js +95 -0
- package/chunks/useAutoAcceptIndicator-CGL2MAYE.js +96 -0
- package/chunks/{validateNonInterActiveAuth-3R223G3R.js → validateNonInterActiveAuth-GBGNJ65K.js} +97 -90
- package/chunks/{version-HS7YSFHV.js → version-Z7EX24NZ.js} +1 -1
- package/chunks/{web-fetch-NKCSG7ZE.js → web-fetch-ETTT2H3V.js} +19 -21
- package/chunks/{web-search-S62WAP4S.js → web-search-Y3ZSVRJ6.js} +13 -13
- package/chunks/{workflow-QAGU5RU4.js → workflow-ATRJSAO7.js} +52 -49
- package/chunks/workspace-providers-status-YM3WLW3N.js +89 -0
- package/chunks/{workspace-registration-store-24JMHDGF.js → workspace-registration-store-4EGNCIPG.js} +1 -1
- package/chunks/workspace-registry-NGZOZKQP.js +96 -0
- package/chunks/workspace-service-SVWOXX2B.js +103 -0
- package/chunks/workspace-skills-status-YZHZ3PT5.js +89 -0
- package/chunks/workspace-trust-reconciler-GGBQV2U5.js +349 -0
- package/chunks/write-file-HLGCEB72.js +78 -0
- package/chunks/xterm-headless-NTYVIBT3.js +3475 -0
- package/chunks/{zh-LUIGBD55.js → zh-H3YDK5QW.js} +9 -1
- package/chunks/{zh-TW-F5KG2IYD.js → zh-TW-JYCP7XUA.js} +9 -1
- package/chunks/zoom-image-LDECT475.js +224 -0
- package/cli.js +50 -16
- package/locales/ca.js +7 -2
- package/locales/de.js +7 -2
- package/locales/en.js +10 -2
- package/locales/fr.js +7 -2
- package/locales/ja.js +7 -2
- package/locales/pt.js +7 -2
- package/locales/ru.js +7 -2
- package/locales/zh-TW.js +10 -2
- package/locales/zh.js +10 -2
- package/package.json +5 -4
- package/web-shell/assets/{arc-DcbWnB9T.js → arc-Dpy_U6Bb.js} +1 -1
- package/web-shell/assets/{architectureDiagram-3BPJPVTR-kMMF5sud.js → architectureDiagram-3BPJPVTR-DgDOg-c5.js} +1 -1
- package/web-shell/assets/{blockDiagram-GPEHLZMM-Htl9vTJS.js → blockDiagram-GPEHLZMM-tADd9Ja3.js} +1 -1
- package/web-shell/assets/{c4Diagram-AAUBKEIU-BnZnm0mQ.js → c4Diagram-AAUBKEIU-68wj9MCU.js} +1 -1
- package/web-shell/assets/channel-Do7fFnFl.js +1 -0
- package/web-shell/assets/{chunk-2J33WTMH-DziB7kDG.js → chunk-2J33WTMH-DjJLOeVU.js} +1 -1
- package/web-shell/assets/{chunk-4BX2VUAB-CmkD8daw.js → chunk-4BX2VUAB-CMbzGeVC.js} +1 -1
- package/web-shell/assets/{chunk-55IACEB6-CHAd9A_U.js → chunk-55IACEB6-SlKgejv9.js} +1 -1
- package/web-shell/assets/{chunk-727SXJPM-Dqaam3fE.js → chunk-727SXJPM-CijXssHZ.js} +1 -1
- package/web-shell/assets/{chunk-AQP2D5EJ-D_-saBYM.js → chunk-AQP2D5EJ-D8w25nvR.js} +1 -1
- package/web-shell/assets/{chunk-FMBD7UC4-B9r_veWD.js → chunk-FMBD7UC4-Bv9dcx_e.js} +1 -1
- package/web-shell/assets/{chunk-ND2GUHAM-B3EaCSpL.js → chunk-ND2GUHAM-Bzf6sAOd.js} +1 -1
- package/web-shell/assets/{chunk-QZHKN3VN-CYq8x9mn.js → chunk-QZHKN3VN-whNoNeW5.js} +1 -1
- package/web-shell/assets/classDiagram-4FO5ZUOK-By_XOP3X.js +1 -0
- package/web-shell/assets/classDiagram-v2-Q7XG4LA2-By_XOP3X.js +1 -0
- package/web-shell/assets/{cose-bilkent-S5V4N54A-D0ng4uiB.js → cose-bilkent-S5V4N54A-rpQS44Lz.js} +1 -1
- package/web-shell/assets/{dagre-BM42HDAG-DCZollQv.js → dagre-BM42HDAG-Ck7VE6nT.js} +1 -1
- package/web-shell/assets/{diagram-2AECGRRQ-Dfk2pWS0.js → diagram-2AECGRRQ-CgRrsodR.js} +1 -1
- package/web-shell/assets/{diagram-5GNKFQAL-kX38ltWR.js → diagram-5GNKFQAL-CsTZtE5A.js} +1 -1
- package/web-shell/assets/{diagram-KO2AKTUF-CJz2vsXh.js → diagram-KO2AKTUF-D5EAdVq4.js} +1 -1
- package/web-shell/assets/{diagram-LMA3HP47-BvMLZm_7.js → diagram-LMA3HP47-DNrjHC7Z.js} +1 -1
- package/web-shell/assets/{diagram-OG6HWLK6-l7kfStkO.js → diagram-OG6HWLK6-ClJSJGgC.js} +1 -1
- package/web-shell/assets/{erDiagram-TEJ5UH35-BSVa8GGT.js → erDiagram-TEJ5UH35-DuVnos_y.js} +1 -1
- package/web-shell/assets/{flowDiagram-I6XJVG4X-CoawKIXH.js → flowDiagram-I6XJVG4X-DEpIVl1s.js} +1 -1
- package/web-shell/assets/{ganttDiagram-6RSMTGT7-DFUDH0zF.js → ganttDiagram-6RSMTGT7-COnQM2-C.js} +1 -1
- package/web-shell/assets/{gitGraphDiagram-PVQCEYII-Y2pvpT4e.js → gitGraphDiagram-PVQCEYII-C-lX5H3_.js} +1 -1
- package/web-shell/assets/index-C2GE3DAF.js +74 -0
- package/web-shell/assets/{index-D0GX0zZf.js → index-DfcyS2E7.js} +1 -1
- package/web-shell/assets/index-Qxt6kN7i.js +1700 -0
- package/web-shell/assets/index-bo0Z8hfu.css +5 -0
- package/web-shell/assets/{infoDiagram-5YYISTIA-CU8_zLiX.js → infoDiagram-5YYISTIA-D0WP-wmU.js} +1 -1
- package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-AVQiV0DU.js → ishikawaDiagram-YF4QCWOH-DgsI3Clu.js} +1 -1
- package/web-shell/assets/{journeyDiagram-JHISSGLW-DQ0VSKa3.js → journeyDiagram-JHISSGLW-4yCoMZO6.js} +1 -1
- package/web-shell/assets/{kanban-definition-UN3LZRKU-BqnWqsE_.js → kanban-definition-UN3LZRKU-D_05au1N.js} +1 -1
- package/web-shell/assets/{linear-BkoihsaA.js → linear-B38fDz0Q.js} +1 -1
- package/web-shell/assets/{mermaid.core-5RJs-31j.js → mermaid.core-aGNwTaHi.js} +5 -5
- package/web-shell/assets/{mindmap-definition-RKZ34NQL-D33Bxnpd.js → mindmap-definition-RKZ34NQL-C2yf_5WM.js} +1 -1
- package/web-shell/assets/{pieDiagram-4H26LBE5-BuEAw3BH.js → pieDiagram-4H26LBE5-DiHABBT-.js} +1 -1
- package/web-shell/assets/{quadrantDiagram-W4KKPZXB-Kox_usEq.js → quadrantDiagram-W4KKPZXB-W9xkeAGe.js} +1 -1
- package/web-shell/assets/{requirementDiagram-4Y6WPE33-CNjeUif0.js → requirementDiagram-4Y6WPE33-BGmRXl9k.js} +1 -1
- package/web-shell/assets/{sankeyDiagram-5OEKKPKP-BCd2OL_U.js → sankeyDiagram-5OEKKPKP-CvOmT43_.js} +1 -1
- package/web-shell/assets/{sequenceDiagram-3UESZ5HK-CF2ZTsz0.js → sequenceDiagram-3UESZ5HK-C8pdd0Z-.js} +1 -1
- package/web-shell/assets/{stateDiagram-AJRCARHV-qenSzHtm.js → stateDiagram-AJRCARHV-C-CYdFx2.js} +1 -1
- package/web-shell/assets/stateDiagram-v2-BHNVJYJU-BieEHeN9.js +1 -0
- package/web-shell/assets/{timeline-definition-PNZ67QCA-B5DyWdgs.js → timeline-definition-PNZ67QCA-w2KQn1cI.js} +1 -1
- package/web-shell/assets/{vennDiagram-CIIHVFJN-DqP4I_o_.js → vennDiagram-CIIHVFJN-DuorhRku.js} +1 -1
- package/web-shell/assets/{wardley-L42UT6IY-CJe2e4mg.js → wardley-L42UT6IY-BAXm2cWy.js} +1 -1
- package/web-shell/assets/{wardleyDiagram-YWT4CUSO-BMDSw-Rr.js → wardleyDiagram-YWT4CUSO-8PHaOXn5.js} +1 -1
- package/web-shell/assets/{xychartDiagram-2RQKCTM6-BTVZYkxD.js → xychartDiagram-2RQKCTM6-Do84JFSc.js} +1 -1
- package/web-shell/index.html +2 -2
- package/chunks/MaxSizedBox-5DPPWPGT.js +0 -85
- package/chunks/agent-6ODUANDO.js +0 -81
- package/chunks/agent-headless-7BYQTMHW.js +0 -75
- package/chunks/bridge-ZUB64FAE.js +0 -90
- package/chunks/chunk-LEH5C7FV.js +0 -232
- package/chunks/chunk-SZRN75WQ.js +0 -29
- package/chunks/chunk-UGYMA4EI.js +0 -219
- package/chunks/chunk-Z2BC6UJ5.js +0 -8575
- package/chunks/contextCommand-JLHYA34Z.js +0 -80
- package/chunks/daemon-status-provider-2233Q37D.js +0 -89
- package/chunks/earlyInputCapture-A7NDU3PF.js +0 -82
- package/chunks/environment-W5UFC2CH.js +0 -102
- package/chunks/errors-M7CLORXH.js +0 -88
- package/chunks/exitPlanMode-GXTBWQAR.js +0 -403
- package/chunks/handleAutoUpdate-6DBEZYPV.js +0 -81
- package/chunks/i18n-VUJJZIMU.js +0 -97
- package/chunks/initializer-UWAK5U5O.js +0 -86
- package/chunks/installationInfo-6O2YAA52.js +0 -80
- package/chunks/list-GB4ESM3T.js +0 -89
- package/chunks/loadedSettingsAdapter-OT6JVQ7U.js +0 -83
- package/chunks/mcp-6DBDJPFU.js +0 -83
- package/chunks/nonInteractiveCli-MOYCYBBU.js +0 -141
- package/chunks/pidfile-TFRZZZIO.js +0 -86
- package/chunks/read-file-APMO3PSX.js +0 -31
- package/chunks/resumeHistoryUtils-6KRYEAWZ.js +0 -91
- package/chunks/ripGrep-BEJDEDXW.js +0 -73
- package/chunks/runtime-XXRRTNP6.js +0 -118
- package/chunks/serve-7BSTXJ4T.js +0 -89
- package/chunks/shell-HH3PF3A2.js +0 -83
- package/chunks/spawnChannel-RWNDBXGA.js +0 -82
- package/chunks/src-GE4TTTML.js +0 -3147
- package/chunks/standalone-update-Q6WFRZZQ.js +0 -92
- package/chunks/task-create-N7WQSGYA.js +0 -25
- package/chunks/theme-manager-SWRILQHI.js +0 -77
- package/chunks/total-session-admission-DLHHHLD3.js +0 -84
- package/chunks/trustedFolders-KHXHY6PY.js +0 -93
- package/chunks/updateCheck-RKL6M5XN.js +0 -92
- package/chunks/useAutoAcceptIndicator-CFQ5BUJL.js +0 -93
- package/chunks/workspace-providers-status-QSVZUETE.js +0 -86
- package/chunks/workspace-registry-UT4RBNBM.js +0 -88
- package/chunks/workspace-service-JFWRUS4V.js +0 -98
- package/chunks/workspace-skills-status-ZBBKJOI2.js +0 -85
- package/chunks/write-file-VHIXW5M7.js +0 -73
- package/web-shell/assets/channel-Cq7YKtfC.js +0 -1
- package/web-shell/assets/classDiagram-4FO5ZUOK-CQ9aC1Tg.js +0 -1
- package/web-shell/assets/classDiagram-v2-Q7XG4LA2-CQ9aC1Tg.js +0 -1
- package/web-shell/assets/index-D9haPt0X.css +0 -5
- package/web-shell/assets/index-ckX9Pq5k.js +0 -1230
- package/web-shell/assets/stateDiagram-v2-BHNVJYJU-B7W4zlCr.js +0 -1
- package/chunks/{chunk-TARRHLLG.js → chunk-QUGAUQGJ.js} +25 -25
- package/chunks/{chunk-U7ZFW55U.js → chunk-VOQXFAY5.js} +977 -977
- /package/chunks/{chunk-LXXMOYPL.js → chunk-VXZBKKQR.js} +0 -0
|
@@ -0,0 +1,1252 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import {
|
|
4
|
+
createDebugLogger
|
|
5
|
+
} from "./chunk-E2BHWIDT.js";
|
|
6
|
+
import {
|
|
7
|
+
init_esbuild_shims
|
|
8
|
+
} from "./chunk-5O2XNYP6.js";
|
|
9
|
+
import {
|
|
10
|
+
__name
|
|
11
|
+
} from "./chunk-J2S4EL5Y.js";
|
|
12
|
+
|
|
13
|
+
// packages/core/src/telemetry/gen-ai-content.ts
|
|
14
|
+
init_esbuild_shims();
|
|
15
|
+
var DRAFT_07_TYPES = /* @__PURE__ */ new Set([
|
|
16
|
+
"array",
|
|
17
|
+
"boolean",
|
|
18
|
+
"integer",
|
|
19
|
+
"null",
|
|
20
|
+
"number",
|
|
21
|
+
"object",
|
|
22
|
+
"string"
|
|
23
|
+
]);
|
|
24
|
+
var debugLogger = createDebugLogger("GEN_AI_CONTENT");
|
|
25
|
+
function record(value) {
|
|
26
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
27
|
+
}
|
|
28
|
+
__name(record, "record");
|
|
29
|
+
function string(value) {
|
|
30
|
+
return typeof value === "string" ? value : void 0;
|
|
31
|
+
}
|
|
32
|
+
__name(string, "string");
|
|
33
|
+
function jsonValue(value, seen = /* @__PURE__ */ new Set()) {
|
|
34
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
if (typeof value === "number") {
|
|
38
|
+
return Number.isFinite(value) ? value : void 0;
|
|
39
|
+
}
|
|
40
|
+
if (typeof value !== "object") return void 0;
|
|
41
|
+
if (seen.has(value)) return void 0;
|
|
42
|
+
seen.add(value);
|
|
43
|
+
try {
|
|
44
|
+
const toJSON = value.toJSON;
|
|
45
|
+
if (typeof toJSON === "function") {
|
|
46
|
+
return jsonValue(toJSON.call(value), seen);
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
const result2 = [];
|
|
50
|
+
for (const item of value) {
|
|
51
|
+
const converted = jsonValue(item, seen);
|
|
52
|
+
if (converted === void 0) return void 0;
|
|
53
|
+
result2.push(converted);
|
|
54
|
+
}
|
|
55
|
+
return result2;
|
|
56
|
+
}
|
|
57
|
+
const result = {};
|
|
58
|
+
for (const [key, item] of Object.entries(value)) {
|
|
59
|
+
if (item === void 0) continue;
|
|
60
|
+
const converted = jsonValue(item, seen);
|
|
61
|
+
if (converted === void 0) return void 0;
|
|
62
|
+
Object.defineProperty(result, key, {
|
|
63
|
+
value: converted,
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
} finally {
|
|
71
|
+
seen.delete(value);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
__name(jsonValue, "jsonValue");
|
|
75
|
+
function modality(mimeType) {
|
|
76
|
+
if (mimeType?.startsWith("image/")) return "image";
|
|
77
|
+
if (mimeType?.startsWith("video/")) return "video";
|
|
78
|
+
if (mimeType?.startsWith("audio/")) return "audio";
|
|
79
|
+
if (mimeType?.startsWith("text/") || mimeType?.startsWith("application/")) {
|
|
80
|
+
return "document";
|
|
81
|
+
}
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
__name(modality, "modality");
|
|
85
|
+
function isDataUri(value) {
|
|
86
|
+
return /^data:/i.test(value);
|
|
87
|
+
}
|
|
88
|
+
__name(isDataUri, "isDataUri");
|
|
89
|
+
function dataUriBlob(uri, contentModality, fallbackMimeType) {
|
|
90
|
+
if (!isDataUri(uri)) return void 0;
|
|
91
|
+
const separator = uri.indexOf(",");
|
|
92
|
+
if (separator < 0) return void 0;
|
|
93
|
+
const metadata = uri.slice(5, separator);
|
|
94
|
+
const metadataParts = metadata.split(";");
|
|
95
|
+
if (!metadataParts.slice(1).some((part) => part.toLowerCase() === "base64")) {
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
const mimeType = metadataParts[0] || fallbackMimeType;
|
|
99
|
+
return {
|
|
100
|
+
type: "blob",
|
|
101
|
+
mime_type: mimeType,
|
|
102
|
+
modality: contentModality,
|
|
103
|
+
content: uri.slice(separator + 1)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
__name(dataUriBlob, "dataUriBlob");
|
|
107
|
+
function uriPart(uri, contentModality, mimeType = null) {
|
|
108
|
+
return {
|
|
109
|
+
type: "uri",
|
|
110
|
+
mime_type: mimeType,
|
|
111
|
+
modality: contentModality,
|
|
112
|
+
uri
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
__name(uriPart, "uriPart");
|
|
116
|
+
function parseArguments(value) {
|
|
117
|
+
if (typeof value !== "string") return jsonValue(value);
|
|
118
|
+
try {
|
|
119
|
+
return jsonValue(JSON.parse(value));
|
|
120
|
+
} catch {
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
__name(parseArguments, "parseArguments");
|
|
125
|
+
function genericPart(value) {
|
|
126
|
+
const type = string(value["type"]);
|
|
127
|
+
if (!type) return void 0;
|
|
128
|
+
const converted = jsonValue(value);
|
|
129
|
+
if (!converted || Array.isArray(converted) || typeof converted !== "object") {
|
|
130
|
+
return void 0;
|
|
131
|
+
}
|
|
132
|
+
return { ...converted, type };
|
|
133
|
+
}
|
|
134
|
+
__name(genericPart, "genericPart");
|
|
135
|
+
function openAiPart(value) {
|
|
136
|
+
if (typeof value === "string") {
|
|
137
|
+
return { part: { type: "text", content: value } };
|
|
138
|
+
}
|
|
139
|
+
const item = record(value);
|
|
140
|
+
if (!item) return void 0;
|
|
141
|
+
const type = string(item["type"]);
|
|
142
|
+
if (type === "text" || type === "input_text" || type === "output_text") {
|
|
143
|
+
const content = string(item["text"]) ?? string(item["content"]);
|
|
144
|
+
return content === void 0 ? void 0 : { part: { type: "text", content } };
|
|
145
|
+
}
|
|
146
|
+
if (type === "reasoning" || type === "thinking" || type === "reasoning_content") {
|
|
147
|
+
const content = string(item["text"]) ?? string(item["content"]);
|
|
148
|
+
return content === void 0 ? void 0 : { part: { type: "reasoning", content } };
|
|
149
|
+
}
|
|
150
|
+
if (type === "image_url") {
|
|
151
|
+
const image = record(item["image_url"]);
|
|
152
|
+
const uri = string(image?.["url"]) ?? string(item["image_url"]);
|
|
153
|
+
if (!uri) return void 0;
|
|
154
|
+
const blob = dataUriBlob(uri, "image", null);
|
|
155
|
+
if (isDataUri(uri) && !blob) return void 0;
|
|
156
|
+
return {
|
|
157
|
+
part: blob ?? uriPart(uri, "image")
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (type === "video_url") {
|
|
161
|
+
const video = record(item["video_url"]);
|
|
162
|
+
const uri = string(video?.["url"]) ?? string(item["video_url"]);
|
|
163
|
+
if (!uri) return void 0;
|
|
164
|
+
const blob = dataUriBlob(uri, "video", null);
|
|
165
|
+
if (isDataUri(uri) && !blob) return void 0;
|
|
166
|
+
return {
|
|
167
|
+
part: blob ?? uriPart(uri, "video")
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (type === "input_audio") {
|
|
171
|
+
const audio = record(item["input_audio"]);
|
|
172
|
+
const content = string(audio?.["data"]);
|
|
173
|
+
if (content === void 0) return void 0;
|
|
174
|
+
const format = string(audio?.["format"]);
|
|
175
|
+
const mimeType = format === "mp3" ? "audio/mpeg" : format ? `audio/${format}` : null;
|
|
176
|
+
const blob = dataUriBlob(content, "audio", mimeType);
|
|
177
|
+
if (isDataUri(content) && !blob) return void 0;
|
|
178
|
+
return {
|
|
179
|
+
part: blob ?? {
|
|
180
|
+
type: "blob",
|
|
181
|
+
mime_type: mimeType,
|
|
182
|
+
modality: "audio",
|
|
183
|
+
content
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
if (type === "file") {
|
|
188
|
+
const file = record(item["file"]);
|
|
189
|
+
const fileId = string(file?.["file_id"]) ?? string(item["file_id"]);
|
|
190
|
+
if (fileId) {
|
|
191
|
+
return {
|
|
192
|
+
part: {
|
|
193
|
+
type: "file",
|
|
194
|
+
mime_type: null,
|
|
195
|
+
modality: "document",
|
|
196
|
+
file_id: fileId
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const fileData = string(file?.["file_data"]) ?? string(item["file_data"]);
|
|
201
|
+
if (!fileData) return void 0;
|
|
202
|
+
const blob = dataUriBlob(fileData, "document", null);
|
|
203
|
+
if (blob) return { part: blob };
|
|
204
|
+
if (isDataUri(fileData)) return void 0;
|
|
205
|
+
if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(fileData)) {
|
|
206
|
+
return { part: uriPart(fileData, "document") };
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
part: {
|
|
210
|
+
type: "blob",
|
|
211
|
+
mime_type: null,
|
|
212
|
+
modality: "document",
|
|
213
|
+
content: fileData
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
if (type === "tool_result" || type === "tool_call_response") {
|
|
218
|
+
const response = jsonValue(item["response"] ?? item["content"]);
|
|
219
|
+
if (response === void 0) return void 0;
|
|
220
|
+
return {
|
|
221
|
+
role: "tool",
|
|
222
|
+
part: {
|
|
223
|
+
type: "tool_call_response",
|
|
224
|
+
...string(item["tool_call_id"]) || string(item["id"]) ? { id: string(item["tool_call_id"]) ?? string(item["id"]) } : {},
|
|
225
|
+
response
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
const part = genericPart(item);
|
|
230
|
+
return part ? { part } : void 0;
|
|
231
|
+
}
|
|
232
|
+
__name(openAiPart, "openAiPart");
|
|
233
|
+
function anthropicPart(value) {
|
|
234
|
+
if (typeof value === "string") {
|
|
235
|
+
return { part: { type: "text", content: value } };
|
|
236
|
+
}
|
|
237
|
+
const item = record(value);
|
|
238
|
+
if (!item) return void 0;
|
|
239
|
+
const type = string(item["type"]);
|
|
240
|
+
if (type === "text") {
|
|
241
|
+
const content = string(item["text"]);
|
|
242
|
+
return content === void 0 ? void 0 : { part: { type: "text", content } };
|
|
243
|
+
}
|
|
244
|
+
if (type === "thinking") {
|
|
245
|
+
const content = string(item["thinking"]) ?? string(item["text"]);
|
|
246
|
+
return content === void 0 ? void 0 : { part: { type: "reasoning", content } };
|
|
247
|
+
}
|
|
248
|
+
if (type === "redacted_thinking") {
|
|
249
|
+
const part2 = genericPart(item);
|
|
250
|
+
return part2 ? { part: part2 } : void 0;
|
|
251
|
+
}
|
|
252
|
+
if (type === "tool_use") {
|
|
253
|
+
const name = string(item["name"]);
|
|
254
|
+
if (!name) return void 0;
|
|
255
|
+
const argumentsValue = jsonValue(item["input"]);
|
|
256
|
+
return {
|
|
257
|
+
part: {
|
|
258
|
+
type: "tool_call",
|
|
259
|
+
...string(item["id"]) ? { id: string(item["id"]) } : {},
|
|
260
|
+
name,
|
|
261
|
+
...argumentsValue !== void 0 ? { arguments: argumentsValue } : {}
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
if (type === "tool_result") {
|
|
266
|
+
const response = jsonValue(item["content"]);
|
|
267
|
+
if (response === void 0) return void 0;
|
|
268
|
+
return {
|
|
269
|
+
role: "tool",
|
|
270
|
+
part: {
|
|
271
|
+
type: "tool_call_response",
|
|
272
|
+
...string(item["tool_use_id"]) ? { id: string(item["tool_use_id"]) } : {},
|
|
273
|
+
response
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
if (type === "image" || type === "document") {
|
|
278
|
+
const source = record(item["source"]);
|
|
279
|
+
const sourceType = string(source?.["type"]);
|
|
280
|
+
const mimeType = string(source?.["media_type"]);
|
|
281
|
+
const data = string(source?.["data"]);
|
|
282
|
+
if (sourceType === "base64" && data !== void 0) {
|
|
283
|
+
return {
|
|
284
|
+
part: {
|
|
285
|
+
type: "blob",
|
|
286
|
+
mime_type: mimeType ?? null,
|
|
287
|
+
modality: type === "image" ? "image" : "document",
|
|
288
|
+
content: data
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
const uri = string(source?.["url"]);
|
|
293
|
+
if (uri) {
|
|
294
|
+
return {
|
|
295
|
+
part: {
|
|
296
|
+
type: "uri",
|
|
297
|
+
mime_type: mimeType ?? null,
|
|
298
|
+
modality: type === "image" ? "image" : "document",
|
|
299
|
+
uri
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const part = genericPart(item);
|
|
305
|
+
return part ? { part } : void 0;
|
|
306
|
+
}
|
|
307
|
+
__name(anthropicPart, "anthropicPart");
|
|
308
|
+
function geminiPart(value) {
|
|
309
|
+
if (typeof value === "string") {
|
|
310
|
+
return { part: { type: "text", content: value } };
|
|
311
|
+
}
|
|
312
|
+
const item = record(value);
|
|
313
|
+
if (!item) return void 0;
|
|
314
|
+
const text = string(item["text"]);
|
|
315
|
+
if (text !== void 0) {
|
|
316
|
+
return {
|
|
317
|
+
part: {
|
|
318
|
+
type: item["thought"] === true ? "reasoning" : "text",
|
|
319
|
+
content: text
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
const call = record(item["functionCall"]);
|
|
324
|
+
if (call) {
|
|
325
|
+
const name = string(call["name"]);
|
|
326
|
+
if (!name) return void 0;
|
|
327
|
+
const argumentsValue = jsonValue(call["args"]);
|
|
328
|
+
return {
|
|
329
|
+
part: {
|
|
330
|
+
type: "tool_call",
|
|
331
|
+
...string(call["id"]) ? { id: string(call["id"]) } : {},
|
|
332
|
+
name,
|
|
333
|
+
...argumentsValue !== void 0 ? { arguments: argumentsValue } : {}
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
const response = record(item["functionResponse"]);
|
|
338
|
+
if (response) {
|
|
339
|
+
const responseValue = jsonValue(response["response"]);
|
|
340
|
+
if (responseValue === void 0) return void 0;
|
|
341
|
+
return {
|
|
342
|
+
role: "tool",
|
|
343
|
+
part: {
|
|
344
|
+
type: "tool_call_response",
|
|
345
|
+
...string(response["id"]) ? { id: string(response["id"]) } : {},
|
|
346
|
+
response: responseValue
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
const inlineData = record(item["inlineData"]);
|
|
351
|
+
if (inlineData) {
|
|
352
|
+
const content = string(inlineData["data"]);
|
|
353
|
+
if (content === void 0) return void 0;
|
|
354
|
+
const mimeType = string(inlineData["mimeType"]);
|
|
355
|
+
const contentModality = modality(mimeType);
|
|
356
|
+
if (!contentModality) return void 0;
|
|
357
|
+
return {
|
|
358
|
+
part: {
|
|
359
|
+
type: "blob",
|
|
360
|
+
mime_type: mimeType ?? null,
|
|
361
|
+
modality: contentModality,
|
|
362
|
+
content
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
const fileData = record(item["fileData"]);
|
|
367
|
+
if (fileData) {
|
|
368
|
+
const uri = string(fileData["fileUri"]);
|
|
369
|
+
if (!uri) return void 0;
|
|
370
|
+
const mimeType = string(fileData["mimeType"]);
|
|
371
|
+
const contentModality = modality(mimeType);
|
|
372
|
+
if (!contentModality) return void 0;
|
|
373
|
+
return {
|
|
374
|
+
part: {
|
|
375
|
+
type: "uri",
|
|
376
|
+
mime_type: mimeType ?? null,
|
|
377
|
+
modality: contentModality,
|
|
378
|
+
uri
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
const explicitType = string(item["type"]);
|
|
383
|
+
const part = explicitType ? genericPart(item) : void 0;
|
|
384
|
+
return part ? { part } : void 0;
|
|
385
|
+
}
|
|
386
|
+
__name(geminiPart, "geminiPart");
|
|
387
|
+
function messages(values, convertPart, roleMap) {
|
|
388
|
+
const items = Array.isArray(values) ? values : [values];
|
|
389
|
+
const result = [];
|
|
390
|
+
for (const value of items) {
|
|
391
|
+
if (typeof value === "string") {
|
|
392
|
+
result.push({
|
|
393
|
+
role: "user",
|
|
394
|
+
parts: [{ type: "text", content: value }]
|
|
395
|
+
});
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
const message = record(value);
|
|
399
|
+
const rawRole = string(message?.["role"]);
|
|
400
|
+
if (!message || !rawRole) return void 0;
|
|
401
|
+
const role = roleMap(rawRole);
|
|
402
|
+
const content = message["content"] ?? message["parts"];
|
|
403
|
+
const rawParts = content === void 0 || content === null ? [] : Array.isArray(content) ? content : [content];
|
|
404
|
+
let currentRole = role;
|
|
405
|
+
let currentParts = [];
|
|
406
|
+
let emitted = false;
|
|
407
|
+
const flush = /* @__PURE__ */ __name(() => {
|
|
408
|
+
if (currentParts.length === 0) return;
|
|
409
|
+
result.push({
|
|
410
|
+
role: currentRole,
|
|
411
|
+
parts: currentParts,
|
|
412
|
+
...string(message["name"]) ? { name: string(message["name"]) } : {}
|
|
413
|
+
});
|
|
414
|
+
currentParts = [];
|
|
415
|
+
emitted = true;
|
|
416
|
+
}, "flush");
|
|
417
|
+
const reasoning = string(message["reasoning_content"]) ?? string(message["reasoning"]) ?? string(message["thinking"]);
|
|
418
|
+
if (reasoning !== void 0) {
|
|
419
|
+
currentParts.push({ type: "reasoning", content: reasoning });
|
|
420
|
+
}
|
|
421
|
+
for (const rawPart of rawParts) {
|
|
422
|
+
const converted = convertPart(rawPart);
|
|
423
|
+
if (!converted) return void 0;
|
|
424
|
+
const nextRole = converted.role ?? role;
|
|
425
|
+
if (currentParts.length > 0 && nextRole !== currentRole) flush();
|
|
426
|
+
currentRole = nextRole;
|
|
427
|
+
currentParts.push(converted.part);
|
|
428
|
+
}
|
|
429
|
+
const refusal = string(message["refusal"]);
|
|
430
|
+
if (refusal !== void 0) {
|
|
431
|
+
currentParts.push({ type: "refusal", content: refusal });
|
|
432
|
+
}
|
|
433
|
+
const audio = record(message["audio"]);
|
|
434
|
+
if (audio) {
|
|
435
|
+
const converted = record(jsonValue(audio));
|
|
436
|
+
if (!converted) return void 0;
|
|
437
|
+
currentParts.push({ ...converted, type: "audio" });
|
|
438
|
+
}
|
|
439
|
+
if (Array.isArray(message["tool_calls"])) {
|
|
440
|
+
if (currentParts.length > 0 && currentRole !== role) flush();
|
|
441
|
+
currentRole = role;
|
|
442
|
+
for (const value2 of message["tool_calls"]) {
|
|
443
|
+
const toolCall = record(value2);
|
|
444
|
+
const fn = record(toolCall?.["function"]);
|
|
445
|
+
const name = string(fn?.["name"]);
|
|
446
|
+
if (!toolCall || !fn || !name) return void 0;
|
|
447
|
+
const argumentsValue = parseArguments(fn["arguments"]);
|
|
448
|
+
currentParts.push({
|
|
449
|
+
type: "tool_call",
|
|
450
|
+
...string(toolCall["id"]) ? { id: string(toolCall["id"]) } : {},
|
|
451
|
+
name,
|
|
452
|
+
...argumentsValue !== void 0 ? { arguments: argumentsValue } : {}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (role === "tool" && currentParts.length > 0 && currentParts.every((part) => part.type === "text")) {
|
|
457
|
+
currentParts = currentParts.map((part) => ({
|
|
458
|
+
type: "tool_call_response",
|
|
459
|
+
...string(message["tool_call_id"]) ? { id: string(message["tool_call_id"]) } : {},
|
|
460
|
+
response: part["content"] ?? null
|
|
461
|
+
}));
|
|
462
|
+
}
|
|
463
|
+
flush();
|
|
464
|
+
if (!emitted) {
|
|
465
|
+
result.push({
|
|
466
|
+
role,
|
|
467
|
+
parts: [],
|
|
468
|
+
...string(message["name"]) ? { name: string(message["name"]) } : {}
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return result;
|
|
473
|
+
}
|
|
474
|
+
__name(messages, "messages");
|
|
475
|
+
function systemParts(value, convertPart) {
|
|
476
|
+
if (value === void 0 || value === null) return void 0;
|
|
477
|
+
const content = record(value)?.["parts"] ?? value;
|
|
478
|
+
const values = Array.isArray(content) ? content : [content];
|
|
479
|
+
const result = [];
|
|
480
|
+
for (const item of values) {
|
|
481
|
+
const part = convertPart(item);
|
|
482
|
+
if (!part || part.role) return void 0;
|
|
483
|
+
result.push(part.part);
|
|
484
|
+
}
|
|
485
|
+
return result;
|
|
486
|
+
}
|
|
487
|
+
__name(systemParts, "systemParts");
|
|
488
|
+
function jsonIdentity(value) {
|
|
489
|
+
if (Array.isArray(value)) {
|
|
490
|
+
return `[${value.map(jsonIdentity).join(",")}]`;
|
|
491
|
+
}
|
|
492
|
+
if (value !== null && typeof value === "object") {
|
|
493
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${jsonIdentity(value[key])}`).join(",")}}`;
|
|
494
|
+
}
|
|
495
|
+
return JSON.stringify(value);
|
|
496
|
+
}
|
|
497
|
+
__name(jsonIdentity, "jsonIdentity");
|
|
498
|
+
function hasUniqueValues(values) {
|
|
499
|
+
return new Set(values.map(jsonIdentity)).size === values.length;
|
|
500
|
+
}
|
|
501
|
+
__name(hasUniqueValues, "hasUniqueValues");
|
|
502
|
+
function isValidRegex(value) {
|
|
503
|
+
try {
|
|
504
|
+
new RegExp(value, "u");
|
|
505
|
+
return true;
|
|
506
|
+
} catch {
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
__name(isValidRegex, "isValidRegex");
|
|
511
|
+
function isValidUri(value, allowReference) {
|
|
512
|
+
for (let index = 0; index < value.length; index++) {
|
|
513
|
+
const code = value.charCodeAt(index);
|
|
514
|
+
if (code <= 32 || code === 127) return false;
|
|
515
|
+
}
|
|
516
|
+
if (/%(?![0-9A-Fa-f]{2})/.test(value)) return false;
|
|
517
|
+
try {
|
|
518
|
+
new URL(value, allowReference ? "https://example.invalid/" : void 0);
|
|
519
|
+
return true;
|
|
520
|
+
} catch {
|
|
521
|
+
return false;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
__name(isValidUri, "isValidUri");
|
|
525
|
+
function normalizeSchema(value) {
|
|
526
|
+
const converted = jsonValue(value);
|
|
527
|
+
if (converted === void 0) return void 0;
|
|
528
|
+
function visitSchema(schema) {
|
|
529
|
+
return typeof schema === "boolean" || schema !== null && !Array.isArray(schema) && typeof schema === "object" && visit(schema);
|
|
530
|
+
}
|
|
531
|
+
__name(visitSchema, "visitSchema");
|
|
532
|
+
function visit(item) {
|
|
533
|
+
const schemaType = item["type"];
|
|
534
|
+
if (typeof schemaType === "string") {
|
|
535
|
+
const lower = schemaType.toLowerCase();
|
|
536
|
+
if (!DRAFT_07_TYPES.has(lower)) return false;
|
|
537
|
+
item["type"] = lower;
|
|
538
|
+
} else if (Array.isArray(schemaType)) {
|
|
539
|
+
if (schemaType.length === 0) return false;
|
|
540
|
+
const normalized = [];
|
|
541
|
+
for (const entry of schemaType) {
|
|
542
|
+
if (typeof entry !== "string") return false;
|
|
543
|
+
const lower = entry.toLowerCase();
|
|
544
|
+
if (!DRAFT_07_TYPES.has(lower)) return false;
|
|
545
|
+
normalized.push(lower);
|
|
546
|
+
}
|
|
547
|
+
if (new Set(normalized).size !== normalized.length) return false;
|
|
548
|
+
item["type"] = normalized;
|
|
549
|
+
} else if (schemaType !== void 0) {
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
for (const key of [
|
|
553
|
+
"$comment",
|
|
554
|
+
"title",
|
|
555
|
+
"description",
|
|
556
|
+
"format",
|
|
557
|
+
"contentMediaType",
|
|
558
|
+
"contentEncoding"
|
|
559
|
+
]) {
|
|
560
|
+
if (item[key] !== void 0 && typeof item[key] !== "string")
|
|
561
|
+
return false;
|
|
562
|
+
}
|
|
563
|
+
for (const key of ["readOnly", "uniqueItems"]) {
|
|
564
|
+
if (item[key] !== void 0 && typeof item[key] !== "boolean") {
|
|
565
|
+
return false;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (item["$id"] !== void 0 && (typeof item["$id"] !== "string" || !isValidUri(item["$id"], true)) || item["$ref"] !== void 0 && (typeof item["$ref"] !== "string" || !isValidUri(item["$ref"], true)) || item["$schema"] !== void 0 && (typeof item["$schema"] !== "string" || !isValidUri(item["$schema"], false)) || item["pattern"] !== void 0 && (typeof item["pattern"] !== "string" || !isValidRegex(item["pattern"]))) {
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
571
|
+
if (item["examples"] !== void 0 && !Array.isArray(item["examples"])) {
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
for (const key of [
|
|
575
|
+
"maximum",
|
|
576
|
+
"exclusiveMaximum",
|
|
577
|
+
"minimum",
|
|
578
|
+
"exclusiveMinimum"
|
|
579
|
+
]) {
|
|
580
|
+
if (item[key] !== void 0 && typeof item[key] !== "number")
|
|
581
|
+
return false;
|
|
582
|
+
}
|
|
583
|
+
if (item["multipleOf"] !== void 0 && (typeof item["multipleOf"] !== "number" || item["multipleOf"] <= 0)) {
|
|
584
|
+
return false;
|
|
585
|
+
}
|
|
586
|
+
for (const key of [
|
|
587
|
+
"maxLength",
|
|
588
|
+
"minLength",
|
|
589
|
+
"maxItems",
|
|
590
|
+
"minItems",
|
|
591
|
+
"maxProperties",
|
|
592
|
+
"minProperties"
|
|
593
|
+
]) {
|
|
594
|
+
const count = item[key];
|
|
595
|
+
if (count !== void 0 && (typeof count !== "number" || !Number.isInteger(count) || count < 0)) {
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
const required = item["required"];
|
|
600
|
+
if (required !== void 0 && (!Array.isArray(required) || !required.every((entry) => typeof entry === "string") || new Set(required).size !== required.length)) {
|
|
601
|
+
return false;
|
|
602
|
+
}
|
|
603
|
+
const enumValues = item["enum"];
|
|
604
|
+
if (enumValues !== void 0 && (!Array.isArray(enumValues) || enumValues.length === 0 || !hasUniqueValues(enumValues))) {
|
|
605
|
+
return false;
|
|
606
|
+
}
|
|
607
|
+
for (const key of ["properties", "patternProperties", "definitions"]) {
|
|
608
|
+
const map = item[key];
|
|
609
|
+
if (map === void 0) continue;
|
|
610
|
+
if (!map || Array.isArray(map) || typeof map !== "object") return false;
|
|
611
|
+
if (key === "patternProperties" && !Object.keys(map).every(isValidRegex)) {
|
|
612
|
+
return false;
|
|
613
|
+
}
|
|
614
|
+
for (const schema of Object.values(map)) {
|
|
615
|
+
if (!visitSchema(schema)) return false;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
for (const key of [
|
|
619
|
+
"additionalProperties",
|
|
620
|
+
"additionalItems",
|
|
621
|
+
"contains",
|
|
622
|
+
"propertyNames",
|
|
623
|
+
"not",
|
|
624
|
+
"if",
|
|
625
|
+
"then",
|
|
626
|
+
"else"
|
|
627
|
+
]) {
|
|
628
|
+
const schema = item[key];
|
|
629
|
+
if (schema !== void 0 && !visitSchema(schema)) return false;
|
|
630
|
+
}
|
|
631
|
+
const items = item["items"];
|
|
632
|
+
if (items !== void 0) {
|
|
633
|
+
const schemas = Array.isArray(items) ? items : [items];
|
|
634
|
+
if (schemas.length === 0 || !schemas.every(visitSchema)) return false;
|
|
635
|
+
}
|
|
636
|
+
for (const key of ["allOf", "anyOf", "oneOf"]) {
|
|
637
|
+
const schemas = item[key];
|
|
638
|
+
if (schemas === void 0) continue;
|
|
639
|
+
if (!Array.isArray(schemas) || schemas.length === 0 || !schemas.every(visitSchema)) {
|
|
640
|
+
return false;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
const dependencies = item["dependencies"];
|
|
644
|
+
if (dependencies !== void 0) {
|
|
645
|
+
if (!dependencies || Array.isArray(dependencies) || typeof dependencies !== "object") {
|
|
646
|
+
return false;
|
|
647
|
+
}
|
|
648
|
+
for (const dependency of Object.values(dependencies)) {
|
|
649
|
+
if (Array.isArray(dependency)) {
|
|
650
|
+
if (!dependency.every((entry) => typeof entry === "string") || new Set(dependency).size !== dependency.length) {
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
} else if (!visitSchema(dependency)) {
|
|
654
|
+
return false;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return true;
|
|
659
|
+
}
|
|
660
|
+
__name(visit, "visit");
|
|
661
|
+
return visitSchema(converted) ? converted : void 0;
|
|
662
|
+
}
|
|
663
|
+
__name(normalizeSchema, "normalizeSchema");
|
|
664
|
+
function definition(type, name, description, parameters) {
|
|
665
|
+
if (typeof type !== "string" || !type || typeof name !== "string" || !name) {
|
|
666
|
+
return void 0;
|
|
667
|
+
}
|
|
668
|
+
return {
|
|
669
|
+
type,
|
|
670
|
+
name,
|
|
671
|
+
...typeof description === "string" ? { description } : {},
|
|
672
|
+
...parameters !== void 0 ? { parameters: normalizeSchema(parameters) } : {}
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
__name(definition, "definition");
|
|
676
|
+
function compactUndefined(value) {
|
|
677
|
+
return Object.fromEntries(
|
|
678
|
+
Object.entries(value).filter(([, item]) => item !== void 0)
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
__name(compactUndefined, "compactUndefined");
|
|
682
|
+
function openAiTools(value) {
|
|
683
|
+
if (!Array.isArray(value)) return void 0;
|
|
684
|
+
const result = [];
|
|
685
|
+
for (const item of value) {
|
|
686
|
+
const tool = record(item);
|
|
687
|
+
if (!tool) return void 0;
|
|
688
|
+
const type = string(tool["type"]);
|
|
689
|
+
const fn = record(tool["function"]);
|
|
690
|
+
const entry = type === "function" && fn ? definition(
|
|
691
|
+
"function",
|
|
692
|
+
fn["name"],
|
|
693
|
+
fn["description"],
|
|
694
|
+
fn["parameters"]
|
|
695
|
+
) : definition(type, tool["name"], void 0, void 0);
|
|
696
|
+
if (!entry) return void 0;
|
|
697
|
+
result.push(compactUndefined(entry));
|
|
698
|
+
}
|
|
699
|
+
return result;
|
|
700
|
+
}
|
|
701
|
+
__name(openAiTools, "openAiTools");
|
|
702
|
+
function anthropicTools(value) {
|
|
703
|
+
if (!Array.isArray(value)) return void 0;
|
|
704
|
+
const result = [];
|
|
705
|
+
for (const item of value) {
|
|
706
|
+
const tool = record(item);
|
|
707
|
+
const entry = tool ? definition(
|
|
708
|
+
"function",
|
|
709
|
+
tool["name"],
|
|
710
|
+
tool["description"],
|
|
711
|
+
tool["input_schema"]
|
|
712
|
+
) : void 0;
|
|
713
|
+
if (!entry) return void 0;
|
|
714
|
+
result.push(compactUndefined(entry));
|
|
715
|
+
}
|
|
716
|
+
return result;
|
|
717
|
+
}
|
|
718
|
+
__name(anthropicTools, "anthropicTools");
|
|
719
|
+
function geminiTools(value) {
|
|
720
|
+
if (!Array.isArray(value)) return void 0;
|
|
721
|
+
const result = [];
|
|
722
|
+
for (const wrapper of value) {
|
|
723
|
+
const declarations = record(wrapper)?.["functionDeclarations"];
|
|
724
|
+
if (!Array.isArray(declarations)) return void 0;
|
|
725
|
+
for (const item of declarations) {
|
|
726
|
+
const tool = record(item);
|
|
727
|
+
const hasParameters = tool ? Object.hasOwn(tool, "parameters") : false;
|
|
728
|
+
const hasJsonSchema = tool ? Object.hasOwn(tool, "parametersJsonSchema") : false;
|
|
729
|
+
const parameters = hasParameters && hasJsonSchema ? void 0 : hasJsonSchema ? tool?.["parametersJsonSchema"] : tool?.["parameters"];
|
|
730
|
+
const entry = tool ? definition("function", tool["name"], tool["description"], parameters) : void 0;
|
|
731
|
+
if (!entry) return void 0;
|
|
732
|
+
result.push(compactUndefined(entry));
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return result;
|
|
736
|
+
}
|
|
737
|
+
__name(geminiTools, "geminiTools");
|
|
738
|
+
function extractOpenAiContent(request) {
|
|
739
|
+
const value = request;
|
|
740
|
+
return {
|
|
741
|
+
inputMessages: Object.hasOwn(value, "messages") ? messages(
|
|
742
|
+
value["messages"],
|
|
743
|
+
openAiPart,
|
|
744
|
+
(role) => role === "function" ? "tool" : role
|
|
745
|
+
) : void 0,
|
|
746
|
+
toolDefinitions: Object.hasOwn(value, "tools") ? openAiTools(value["tools"]) : void 0
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
__name(extractOpenAiContent, "extractOpenAiContent");
|
|
750
|
+
function extractAnthropicContent(request) {
|
|
751
|
+
const value = request;
|
|
752
|
+
return {
|
|
753
|
+
inputMessages: Object.hasOwn(value, "messages") ? messages(value["messages"], anthropicPart, (role) => role) : void 0,
|
|
754
|
+
systemInstructions: Object.hasOwn(value, "system") ? systemParts(value["system"], anthropicPart) : void 0,
|
|
755
|
+
toolDefinitions: Object.hasOwn(value, "tools") ? anthropicTools(value["tools"]) : void 0
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
__name(extractAnthropicContent, "extractAnthropicContent");
|
|
759
|
+
function extractGeminiContent(request) {
|
|
760
|
+
const value = request;
|
|
761
|
+
const config = record(value["config"]);
|
|
762
|
+
return {
|
|
763
|
+
inputMessages: Object.hasOwn(value, "contents") ? messages(
|
|
764
|
+
value["contents"],
|
|
765
|
+
geminiPart,
|
|
766
|
+
(role) => role === "model" ? "assistant" : role
|
|
767
|
+
) : void 0,
|
|
768
|
+
systemInstructions: config && Object.hasOwn(config, "systemInstruction") ? systemParts(config["systemInstruction"], geminiPart) : void 0,
|
|
769
|
+
toolDefinitions: config && Object.hasOwn(config, "tools") ? geminiTools(config["tools"]) : void 0
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
__name(extractGeminiContent, "extractGeminiContent");
|
|
773
|
+
function stringifyGenAiJson(value, maxLength, requireObject = false) {
|
|
774
|
+
const converted = jsonValue(value);
|
|
775
|
+
if (converted === void 0 || requireObject && (converted === null || Array.isArray(converted) || typeof converted !== "object")) {
|
|
776
|
+
return void 0;
|
|
777
|
+
}
|
|
778
|
+
try {
|
|
779
|
+
const serialized = JSON.stringify(converted);
|
|
780
|
+
return serialized.length <= maxLength ? serialized : void 0;
|
|
781
|
+
} catch {
|
|
782
|
+
return void 0;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
__name(stringifyGenAiJson, "stringifyGenAiJson");
|
|
786
|
+
var GenAiOutputAccumulator = class {
|
|
787
|
+
constructor(enabled, maxLength) {
|
|
788
|
+
this.enabled = enabled;
|
|
789
|
+
this.maxLength = maxLength;
|
|
790
|
+
}
|
|
791
|
+
static {
|
|
792
|
+
__name(this, "GenAiOutputAccumulator");
|
|
793
|
+
}
|
|
794
|
+
candidates = /* @__PURE__ */ new Map();
|
|
795
|
+
overflow = false;
|
|
796
|
+
observedResponse = false;
|
|
797
|
+
explicitEmpty = false;
|
|
798
|
+
estimatedLength = 2;
|
|
799
|
+
get finishReasons() {
|
|
800
|
+
const values = [...this.candidates.entries()].sort(([left], [right]) => left - right).map(([, candidate]) => candidate.finishReason).filter((value) => value !== void 0);
|
|
801
|
+
return values.length > 0 ? values : void 0;
|
|
802
|
+
}
|
|
803
|
+
recordOpenAiResponse(response) {
|
|
804
|
+
const choices = response["choices"];
|
|
805
|
+
if (!Array.isArray(choices)) return;
|
|
806
|
+
this.observedResponse = true;
|
|
807
|
+
this.explicitEmpty = choices.length === 0;
|
|
808
|
+
for (const [position, rawChoice] of choices.entries()) {
|
|
809
|
+
const choice = record(rawChoice);
|
|
810
|
+
if (!choice) {
|
|
811
|
+
if (this.enabled) this.markOverflow();
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
const index = typeof choice["index"] === "number" && Number.isSafeInteger(choice["index"]) ? choice["index"] : position;
|
|
815
|
+
const candidate = this.candidate(index);
|
|
816
|
+
const message = record(choice["message"]);
|
|
817
|
+
if (message && this.enabled) {
|
|
818
|
+
const converted = messages([message], openAiPart, () => "assistant");
|
|
819
|
+
if (converted?.[0]) this.setComplete(index, converted[0]);
|
|
820
|
+
else this.markOverflow();
|
|
821
|
+
} else if (this.enabled) {
|
|
822
|
+
this.markOverflow();
|
|
823
|
+
}
|
|
824
|
+
const finishReason = string(choice["finish_reason"]);
|
|
825
|
+
if (finishReason) candidate.finishReason = finishReason;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
recordOpenAiChunk(chunk) {
|
|
829
|
+
const choices = chunk["choices"];
|
|
830
|
+
if (!Array.isArray(choices)) return;
|
|
831
|
+
this.observedResponse = true;
|
|
832
|
+
if (choices.length === 0 && this.candidates.size === 0) {
|
|
833
|
+
this.explicitEmpty = true;
|
|
834
|
+
}
|
|
835
|
+
for (const [position, rawChoice] of choices.entries()) {
|
|
836
|
+
const choice = record(rawChoice);
|
|
837
|
+
if (!choice) {
|
|
838
|
+
if (this.enabled) this.markOverflow();
|
|
839
|
+
continue;
|
|
840
|
+
}
|
|
841
|
+
const index = typeof choice["index"] === "number" && Number.isSafeInteger(choice["index"]) ? choice["index"] : position;
|
|
842
|
+
const candidate = this.candidate(index);
|
|
843
|
+
const delta = record(choice["delta"]);
|
|
844
|
+
const reasoning = string(delta?.["reasoning_content"]) ?? string(delta?.["reasoning"]) ?? string(delta?.["thinking"]);
|
|
845
|
+
if (reasoning !== void 0) {
|
|
846
|
+
this.append(candidate, "reasoning", "reasoning", reasoning);
|
|
847
|
+
}
|
|
848
|
+
const content = string(delta?.["content"]);
|
|
849
|
+
if (content !== void 0) {
|
|
850
|
+
this.append(candidate, "text", "text", content);
|
|
851
|
+
}
|
|
852
|
+
const refusal = string(delta?.["refusal"]);
|
|
853
|
+
if (refusal !== void 0) {
|
|
854
|
+
this.append(candidate, "refusal", "refusal", refusal);
|
|
855
|
+
}
|
|
856
|
+
const audio = record(delta?.["audio"]);
|
|
857
|
+
if (audio) {
|
|
858
|
+
const converted = record(jsonValue(audio));
|
|
859
|
+
if (converted) {
|
|
860
|
+
this.setValue(candidate, "audio", {
|
|
861
|
+
...converted,
|
|
862
|
+
type: "audio"
|
|
863
|
+
});
|
|
864
|
+
} else {
|
|
865
|
+
this.markOverflow();
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
const toolCalls = delta?.["tool_calls"];
|
|
869
|
+
if (Array.isArray(toolCalls)) {
|
|
870
|
+
for (const [toolPosition, rawToolCall] of toolCalls.entries()) {
|
|
871
|
+
const toolCall = record(rawToolCall);
|
|
872
|
+
if (!toolCall) {
|
|
873
|
+
this.markOverflow();
|
|
874
|
+
continue;
|
|
875
|
+
}
|
|
876
|
+
const toolIndex = typeof toolCall["index"] === "number" && Number.isSafeInteger(toolCall["index"]) ? toolCall["index"] : toolPosition;
|
|
877
|
+
const key = `tool:${toolIndex}`;
|
|
878
|
+
const fn = record(toolCall["function"]);
|
|
879
|
+
const existing = candidate.parts.get(key);
|
|
880
|
+
const part = existing ?? {
|
|
881
|
+
type: "tool_call"
|
|
882
|
+
};
|
|
883
|
+
if (!existing && !this.reserve(JSON.stringify({ type: "tool_call" }).length)) {
|
|
884
|
+
continue;
|
|
885
|
+
}
|
|
886
|
+
const id = string(toolCall["id"]);
|
|
887
|
+
if (id !== void 0 && id !== part.id && !this.reserve(id.length - (part.id?.length ?? 0))) {
|
|
888
|
+
continue;
|
|
889
|
+
}
|
|
890
|
+
const name = string(fn?.["name"]);
|
|
891
|
+
if (name !== void 0 && name !== part.name && !this.reserve(name.length - (part.name?.length ?? 0))) {
|
|
892
|
+
continue;
|
|
893
|
+
}
|
|
894
|
+
part.id = id ?? part.id;
|
|
895
|
+
part.name = name ?? part.name;
|
|
896
|
+
const argumentsFragment = string(fn?.["arguments"]);
|
|
897
|
+
if (argumentsFragment !== void 0) {
|
|
898
|
+
const next = (part.arguments ?? "") + argumentsFragment;
|
|
899
|
+
if (!this.reserve(argumentsFragment.length)) continue;
|
|
900
|
+
part.arguments = next;
|
|
901
|
+
}
|
|
902
|
+
candidate.parts.set(key, part);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
const finishReason = string(choice["finish_reason"]);
|
|
906
|
+
if (finishReason) candidate.finishReason = finishReason;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
recordAnthropicResponse(response) {
|
|
910
|
+
this.observedResponse = true;
|
|
911
|
+
const value = response;
|
|
912
|
+
const candidate = this.candidate(0);
|
|
913
|
+
const content = value["content"];
|
|
914
|
+
if (Array.isArray(content) && this.enabled) {
|
|
915
|
+
const parts = [];
|
|
916
|
+
for (const item of content) {
|
|
917
|
+
const converted = anthropicPart(item);
|
|
918
|
+
if (!converted || converted.role) {
|
|
919
|
+
this.markOverflow();
|
|
920
|
+
break;
|
|
921
|
+
}
|
|
922
|
+
parts.push(converted.part);
|
|
923
|
+
}
|
|
924
|
+
if (!this.overflow) {
|
|
925
|
+
this.setComplete(0, { role: "assistant", parts });
|
|
926
|
+
}
|
|
927
|
+
} else if (this.enabled) {
|
|
928
|
+
this.markOverflow();
|
|
929
|
+
}
|
|
930
|
+
const finishReason = string(value["stop_reason"]);
|
|
931
|
+
if (finishReason) candidate.finishReason = finishReason;
|
|
932
|
+
}
|
|
933
|
+
recordAnthropicEvent(event) {
|
|
934
|
+
const value = event;
|
|
935
|
+
const type = string(value["type"]);
|
|
936
|
+
if (type !== "message_start" && type !== "content_block_start" && type !== "content_block_delta" && type !== "message_delta") {
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
this.observedResponse = true;
|
|
940
|
+
const index = typeof value["index"] === "number" && Number.isSafeInteger(value["index"]) ? value["index"] : 0;
|
|
941
|
+
const candidate = this.candidate(0);
|
|
942
|
+
if (type === "content_block_start") {
|
|
943
|
+
const block = record(value["content_block"]);
|
|
944
|
+
const blockType = string(block?.["type"]);
|
|
945
|
+
if (blockType === "text") {
|
|
946
|
+
this.append(
|
|
947
|
+
candidate,
|
|
948
|
+
`block:${index}`,
|
|
949
|
+
"text",
|
|
950
|
+
string(block?.["text"])
|
|
951
|
+
);
|
|
952
|
+
} else if (blockType === "thinking") {
|
|
953
|
+
this.append(
|
|
954
|
+
candidate,
|
|
955
|
+
`block:${index}`,
|
|
956
|
+
"reasoning",
|
|
957
|
+
string(block?.["thinking"]) ?? string(block?.["data"])
|
|
958
|
+
);
|
|
959
|
+
} else if (blockType === "redacted_thinking" && block) {
|
|
960
|
+
const converted = anthropicPart(block);
|
|
961
|
+
if (converted && !converted.role) {
|
|
962
|
+
this.setValue(candidate, `block:${index}`, converted.part);
|
|
963
|
+
} else {
|
|
964
|
+
this.markOverflow();
|
|
965
|
+
}
|
|
966
|
+
} else if (blockType === "tool_use") {
|
|
967
|
+
if (!this.reserve(JSON.stringify({ type: "tool_call" }).length)) return;
|
|
968
|
+
const id = string(block?.["id"]);
|
|
969
|
+
const name = string(block?.["name"]);
|
|
970
|
+
if (!this.reserve((id?.length ?? 0) + (name?.length ?? 0))) return;
|
|
971
|
+
const hasInput = block ? Object.hasOwn(block, "input") : false;
|
|
972
|
+
const input = hasInput ? jsonValue(block?.["input"]) : void 0;
|
|
973
|
+
if (hasInput && input === void 0) {
|
|
974
|
+
this.markOverflow();
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
const initialArguments = input === void 0 ? void 0 : JSON.stringify(input);
|
|
978
|
+
if (initialArguments !== void 0 && !this.reserve(initialArguments.length)) {
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
candidate.parts.set(`block:${index}`, {
|
|
982
|
+
type: "tool_call",
|
|
983
|
+
id,
|
|
984
|
+
name,
|
|
985
|
+
arguments: initialArguments,
|
|
986
|
+
argumentsFromStart: initialArguments !== void 0
|
|
987
|
+
});
|
|
988
|
+
} else if (blockType && block) {
|
|
989
|
+
const converted = anthropicPart(block);
|
|
990
|
+
if (converted && !converted.role) {
|
|
991
|
+
this.setValue(candidate, `block:${index}`, converted.part);
|
|
992
|
+
} else {
|
|
993
|
+
this.markOverflow();
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
} else if (type === "content_block_delta") {
|
|
997
|
+
const delta = record(value["delta"]);
|
|
998
|
+
const deltaType = string(delta?.["type"]);
|
|
999
|
+
if (deltaType === "text_delta") {
|
|
1000
|
+
this.append(
|
|
1001
|
+
candidate,
|
|
1002
|
+
`block:${index}`,
|
|
1003
|
+
"text",
|
|
1004
|
+
string(delta?.["text"])
|
|
1005
|
+
);
|
|
1006
|
+
} else if (deltaType === "thinking_delta" || deltaType === "signature_delta") {
|
|
1007
|
+
if (deltaType === "thinking_delta") {
|
|
1008
|
+
this.append(
|
|
1009
|
+
candidate,
|
|
1010
|
+
`block:${index}`,
|
|
1011
|
+
"reasoning",
|
|
1012
|
+
string(delta?.["thinking"])
|
|
1013
|
+
);
|
|
1014
|
+
}
|
|
1015
|
+
} else if (deltaType === "input_json_delta") {
|
|
1016
|
+
const part = candidate.parts.get(`block:${index}`);
|
|
1017
|
+
const fragment = string(delta?.["partial_json"]);
|
|
1018
|
+
if (part?.type === "tool_call" && fragment !== void 0) {
|
|
1019
|
+
const replacedLength = part.argumentsFromStart ? part.arguments?.length ?? 0 : 0;
|
|
1020
|
+
if (this.reserve(fragment.length - replacedLength)) {
|
|
1021
|
+
if (part.argumentsFromStart) {
|
|
1022
|
+
part.arguments = "";
|
|
1023
|
+
part.argumentsFromStart = false;
|
|
1024
|
+
}
|
|
1025
|
+
part.arguments = (part.arguments ?? "") + fragment;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
} else if (type === "message_delta") {
|
|
1030
|
+
const delta = record(value["delta"]);
|
|
1031
|
+
const finishReason = string(delta?.["stop_reason"]);
|
|
1032
|
+
if (finishReason) candidate.finishReason = finishReason;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
recordGeminiResponse(response) {
|
|
1036
|
+
const candidates = response["candidates"];
|
|
1037
|
+
if (!Array.isArray(candidates)) return;
|
|
1038
|
+
this.observedResponse = true;
|
|
1039
|
+
this.explicitEmpty = candidates.length === 0;
|
|
1040
|
+
for (const [position, rawCandidate] of candidates.entries()) {
|
|
1041
|
+
const candidate = record(rawCandidate);
|
|
1042
|
+
if (!candidate) {
|
|
1043
|
+
if (this.enabled) this.markOverflow();
|
|
1044
|
+
continue;
|
|
1045
|
+
}
|
|
1046
|
+
const index = typeof candidate["index"] === "number" && Number.isSafeInteger(candidate["index"]) ? candidate["index"] : position;
|
|
1047
|
+
const outputCandidate = this.candidate(index);
|
|
1048
|
+
const content = record(candidate["content"]);
|
|
1049
|
+
if (content && this.enabled) {
|
|
1050
|
+
const converted = messages(
|
|
1051
|
+
[content],
|
|
1052
|
+
geminiPart,
|
|
1053
|
+
(role) => role === "model" ? "assistant" : role
|
|
1054
|
+
);
|
|
1055
|
+
if (converted?.[0]) this.setComplete(index, converted[0]);
|
|
1056
|
+
else this.markOverflow();
|
|
1057
|
+
} else if (this.enabled) {
|
|
1058
|
+
this.setComplete(index, { role: "assistant", parts: [] });
|
|
1059
|
+
}
|
|
1060
|
+
const finishReason = string(candidate["finishReason"]);
|
|
1061
|
+
if (finishReason) outputCandidate.finishReason = finishReason;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
recordGeminiChunk(chunk) {
|
|
1065
|
+
const candidates = chunk["candidates"];
|
|
1066
|
+
if (!Array.isArray(candidates)) return;
|
|
1067
|
+
this.observedResponse = true;
|
|
1068
|
+
if (candidates.length === 0 && this.candidates.size === 0) {
|
|
1069
|
+
this.explicitEmpty = true;
|
|
1070
|
+
}
|
|
1071
|
+
for (const [position, rawCandidate] of candidates.entries()) {
|
|
1072
|
+
const value = record(rawCandidate);
|
|
1073
|
+
if (!value) {
|
|
1074
|
+
if (this.enabled) this.markOverflow();
|
|
1075
|
+
continue;
|
|
1076
|
+
}
|
|
1077
|
+
const index = typeof value["index"] === "number" && Number.isSafeInteger(value["index"]) ? value["index"] : position;
|
|
1078
|
+
const candidate = this.candidate(index);
|
|
1079
|
+
const content = record(value["content"]);
|
|
1080
|
+
const role = string(content?.["role"]);
|
|
1081
|
+
if (role) candidate.role = role === "model" ? "assistant" : role;
|
|
1082
|
+
const parts = content?.["parts"];
|
|
1083
|
+
if (Array.isArray(parts) && this.enabled && !this.overflow) {
|
|
1084
|
+
for (const [partIndex, rawPart] of parts.entries()) {
|
|
1085
|
+
const converted = geminiPart(rawPart);
|
|
1086
|
+
if (!converted || converted.role) {
|
|
1087
|
+
this.markOverflow();
|
|
1088
|
+
break;
|
|
1089
|
+
}
|
|
1090
|
+
const part = converted.part;
|
|
1091
|
+
const type = string(part["type"]);
|
|
1092
|
+
const key = `part:${partIndex}:${type ?? "unknown"}`;
|
|
1093
|
+
if (type === "text" || type === "reasoning") {
|
|
1094
|
+
this.append(candidate, key, type, string(part["content"]) ?? "");
|
|
1095
|
+
} else {
|
|
1096
|
+
this.setValue(candidate, key, part);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
const finishReason = string(value["finishReason"]);
|
|
1101
|
+
if (finishReason) candidate.finishReason = finishReason;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
finalize(success) {
|
|
1105
|
+
if (!success) {
|
|
1106
|
+
for (const candidate of this.candidates.values()) {
|
|
1107
|
+
candidate.finishReason ??= "error";
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
if (!this.enabled || this.overflow || !this.observedResponse) {
|
|
1111
|
+
return void 0;
|
|
1112
|
+
}
|
|
1113
|
+
if (this.explicitEmpty && this.candidates.size === 0) {
|
|
1114
|
+
return stringifyGenAiJson([], this.maxLength);
|
|
1115
|
+
}
|
|
1116
|
+
const output = [];
|
|
1117
|
+
for (const [, candidate] of [...this.candidates.entries()].sort(
|
|
1118
|
+
([left], [right]) => left - right
|
|
1119
|
+
)) {
|
|
1120
|
+
const finishReason = candidate.finishReason;
|
|
1121
|
+
if (!finishReason) {
|
|
1122
|
+
debugLogger.debug(
|
|
1123
|
+
"Omitting GenAI output messages because a candidate has no finish reason"
|
|
1124
|
+
);
|
|
1125
|
+
return void 0;
|
|
1126
|
+
}
|
|
1127
|
+
const parts = [];
|
|
1128
|
+
for (const part of candidate.parts.values()) {
|
|
1129
|
+
if (part.value) {
|
|
1130
|
+
parts.push(part.value);
|
|
1131
|
+
continue;
|
|
1132
|
+
}
|
|
1133
|
+
if (part.type === "tool_call") {
|
|
1134
|
+
if (!part.name) return void 0;
|
|
1135
|
+
const argumentsValue = part.arguments === void 0 ? void 0 : parseArguments(part.arguments);
|
|
1136
|
+
parts.push({
|
|
1137
|
+
type: "tool_call",
|
|
1138
|
+
...part.id ? { id: part.id } : {},
|
|
1139
|
+
name: part.name,
|
|
1140
|
+
...argumentsValue !== void 0 ? { arguments: argumentsValue } : {}
|
|
1141
|
+
});
|
|
1142
|
+
} else {
|
|
1143
|
+
parts.push({
|
|
1144
|
+
type: part.type,
|
|
1145
|
+
content: part.content ?? ""
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
output.push({
|
|
1150
|
+
role: candidate.role,
|
|
1151
|
+
parts,
|
|
1152
|
+
finish_reason: finishReason
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
return stringifyGenAiJson(output, this.maxLength);
|
|
1156
|
+
}
|
|
1157
|
+
discardContent() {
|
|
1158
|
+
this.markOverflow();
|
|
1159
|
+
}
|
|
1160
|
+
candidate(index) {
|
|
1161
|
+
let candidate = this.candidates.get(index);
|
|
1162
|
+
if (!candidate) {
|
|
1163
|
+
candidate = { role: "assistant", parts: /* @__PURE__ */ new Map() };
|
|
1164
|
+
this.candidates.set(index, candidate);
|
|
1165
|
+
}
|
|
1166
|
+
return candidate;
|
|
1167
|
+
}
|
|
1168
|
+
setComplete(index, message) {
|
|
1169
|
+
const candidate = this.candidate(index);
|
|
1170
|
+
candidate.role = string(message["role"]) ?? "assistant";
|
|
1171
|
+
candidate.parts.clear();
|
|
1172
|
+
const parts = message["parts"];
|
|
1173
|
+
if (!Array.isArray(parts)) {
|
|
1174
|
+
this.markOverflow();
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
for (const [partIndex, value] of parts.entries()) {
|
|
1178
|
+
const part = record(value);
|
|
1179
|
+
const type = string(part?.["type"]);
|
|
1180
|
+
if (!part || !type) {
|
|
1181
|
+
this.markOverflow();
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
if (type === "text" || type === "reasoning") {
|
|
1185
|
+
candidate.parts.set(`part:${partIndex}`, {
|
|
1186
|
+
type,
|
|
1187
|
+
content: string(part["content"]) ?? ""
|
|
1188
|
+
});
|
|
1189
|
+
} else if (type === "tool_call") {
|
|
1190
|
+
candidate.parts.set(`part:${partIndex}`, {
|
|
1191
|
+
type: "tool_call",
|
|
1192
|
+
id: string(part["id"]),
|
|
1193
|
+
name: string(part["name"]),
|
|
1194
|
+
arguments: part["arguments"] === void 0 ? void 0 : JSON.stringify(part["arguments"])
|
|
1195
|
+
});
|
|
1196
|
+
} else {
|
|
1197
|
+
candidate.parts.set(`part:${partIndex}`, {
|
|
1198
|
+
type,
|
|
1199
|
+
value: part
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
const serialized = stringifyGenAiJson(message, this.maxLength);
|
|
1204
|
+
if (serialized === void 0) this.markOverflow();
|
|
1205
|
+
}
|
|
1206
|
+
append(candidate, key, type, fragment) {
|
|
1207
|
+
if (fragment === void 0 || !this.enabled || this.overflow) return;
|
|
1208
|
+
const part = candidate.parts.get(key);
|
|
1209
|
+
if (part && part.type !== type) {
|
|
1210
|
+
this.markOverflow();
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
const newPartLength = part ? 0 : JSON.stringify({ type, content: "" }).length;
|
|
1214
|
+
if (!this.reserve(fragment.length + newPartLength)) return;
|
|
1215
|
+
if (part) {
|
|
1216
|
+
part.content = (part.content ?? "") + fragment;
|
|
1217
|
+
} else {
|
|
1218
|
+
candidate.parts.set(key, { type, content: fragment });
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
setValue(candidate, key, value) {
|
|
1222
|
+
const previous = candidate.parts.get(key)?.value;
|
|
1223
|
+
const previousLength = previous ? JSON.stringify(previous).length : 0;
|
|
1224
|
+
if (this.reserve(JSON.stringify(value).length - previousLength)) {
|
|
1225
|
+
candidate.parts.set(key, { type: value.type, value });
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
reserve(length) {
|
|
1229
|
+
if (!this.enabled || this.overflow) return false;
|
|
1230
|
+
this.estimatedLength += length;
|
|
1231
|
+
if (this.estimatedLength <= this.maxLength) return true;
|
|
1232
|
+
this.markOverflow();
|
|
1233
|
+
return false;
|
|
1234
|
+
}
|
|
1235
|
+
markOverflow() {
|
|
1236
|
+
this.overflow = true;
|
|
1237
|
+
for (const candidate of this.candidates.values()) candidate.parts.clear();
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
|
|
1241
|
+
export {
|
|
1242
|
+
extractOpenAiContent,
|
|
1243
|
+
extractAnthropicContent,
|
|
1244
|
+
extractGeminiContent,
|
|
1245
|
+
stringifyGenAiJson,
|
|
1246
|
+
GenAiOutputAccumulator
|
|
1247
|
+
};
|
|
1248
|
+
/**
|
|
1249
|
+
* @license
|
|
1250
|
+
* Copyright 2026 Qwen Team
|
|
1251
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1252
|
+
*/
|