nolo-cli 0.259.0-alpha.1 → 0.261.0-alpha.1
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/README.md +1 -1
- package/{_executeModel-MTM4BJK3.js → _executeModel-PODMRXJJ.js} +97 -83
- package/accountResolver-NGICIMEE.js +1 -1
- package/{action-C6IQAKN4.js → action-NJTYNXXR.js} +12 -10
- package/{addContentAction-53364YDW.js → addContentAction-RUPXLROG.js} +14 -13
- package/{addDialogAgentAction-U5DD5EN5.js → addDialogAgentAction-57EJ2UBC.js} +20 -24
- package/{agentDeleteCommand-53NN3VSK.js → agentDeleteCommand-DRFCOTYP.js} +185 -147
- package/{agentEmailCommands-KOGGIT6I.js → agentEmailCommands-FHENHUBF.js} +143 -127
- package/{agentGrantCommands-L6O2HVJI.js → agentGrantCommands-BMVKNYIY.js} +9 -6
- package/{agentListCommands-62UYUQDI.js → agentListCommands-W66W5K3V.js} +88 -69
- package/{agentMachineCommands-W6TNJXEA.js → agentMachineCommands-C3BUBCXU.js} +69 -60
- package/{agentProviderCommands-QLTABYR7.js → agentProviderCommands-VIWKP7DM.js} +11 -8
- package/{agentPullCommand-2EYJ5ENC.js → agentPullCommand-5SNSXOY7.js} +10 -7
- package/agentRecordCommands-DYMHWTID.js +210 -0
- package/agentRun-QVFG3CI4.js +250 -0
- package/agentRunCommand-YV4V5HSL.js +248 -0
- package/{agentRunControl-LXMADX3N.js → agentRunControl-RGBHKPKJ.js} +19 -12
- package/{agentRuntimeLocal-YGNJMQW3.js → agentRuntimeLocal-LVEMOYS2.js} +62 -49
- package/{agentSlice-3HHYUQLM.js → agentSlice-OJCM7OUX.js} +15 -18
- package/appConfigCommands-ZUXQLE7L.js +417 -0
- package/{appDeleteCommands-5COJ6CSG.js → appDeleteCommands-L5UKUMXY.js} +68 -58
- package/{appDeployCommands-3JPAT3XO.js → appDeployCommands-KX2BRQUW.js} +74 -59
- package/{appDeployStatusCommands-RHZKF3G4.js → appDeployStatusCommands-7LHRSWW7.js} +68 -58
- package/{appGetCommands-73DXOAQW.js → appGetCommands-F7SDFCUK.js} +74 -58
- package/{appListCommands-HD5LOQ3G.js → appListCommands-U4NJKSMZ.js} +74 -58
- package/appMigrateCommands-JAPOLYSW.js +230 -0
- package/appSourceCommands-TLXPWXUH.js +279 -0
- package/authCommand-AU3GZBZ2.js +65 -0
- package/{authCommands-T5FODCEG.js → authCommands-JKBWMUQ4.js} +20 -17
- package/{builtinSkillRegistry-EDHD2UHU.js → builtinSkillRegistry-6XUWMAV5.js} +8 -6
- package/{chromeOpsCommands-3SSTDFRF.js → chromeOpsCommands-F47WYQWF.js} +68 -18
- package/{chunk-5YS6QHGT.js → chunk-2FGFY72B.js} +9 -9
- package/{chunk-MJBLXJMP.js → chunk-2I4R6ZRV.js} +12 -9
- package/{chunk-FXEPZKNJ.js → chunk-2MIZHEND.js} +506 -64
- package/{chunk-TLE77UJ5.js → chunk-2OROOEOQ.js} +0 -1
- package/{chunk-6RSNVJGO.js → chunk-2ZBPWX7N.js} +4 -4
- package/chunk-35JIFLIG.js +30 -0
- package/{chunk-7OVOZRZF.js → chunk-3B7OTHDW.js} +23 -379
- package/{chunk-DNNPARJK.js → chunk-3QMN3T6L.js} +50 -37
- package/{chunk-DMPZMYH4.js → chunk-3R4AYHJR.js} +13 -1
- package/{chunk-XNNBXUEM.js → chunk-3TII7WCF.js} +5 -5
- package/{chunk-223KZUJ6.js → chunk-4HZCBA4Q.js} +18 -15
- package/{chunk-C5A54QS7.js → chunk-4INJGWE3.js} +18 -5
- package/chunk-4IVMDQBA.js +261 -0
- package/chunk-4Y6CZ2N4.js +82 -0
- package/{chunk-KZ4A7EIV.js → chunk-56OAS5RZ.js} +1 -1
- package/{chunk-KQHEGELM.js → chunk-63G7JWEA.js} +16 -6
- package/{chunk-4EACJPZI.js → chunk-6BBXJGIQ.js} +51 -42
- package/chunk-72VWN4VK.js +51 -0
- package/chunk-7LR2IFUH.js +100 -0
- package/{chunk-S73EPYNC.js → chunk-7LS5ATRP.js} +20 -6
- package/{chunk-XPETQ4MR.js → chunk-7X4BFUJV.js} +24 -10
- package/{chunk-KHYSFS3W.js → chunk-A454UXB6.js} +148 -73
- package/chunk-A4O76A6V.js +432 -0
- package/chunk-AMNZPQCY.js +635 -0
- package/{chunk-4MXYCQBS.js → chunk-AQNWWJLH.js} +2 -56
- package/{chunk-LHCGKAFO.js → chunk-BKP325XS.js} +184 -112
- package/{chunk-PENRYZ4D.js → chunk-BPB3T5EU.js} +4 -7
- package/{chunk-U6QNVOR5.js → chunk-BUGLH2A7.js} +130 -6
- package/{chunk-2JHGUL5K.js → chunk-BVYHE6QD.js} +2 -2
- package/{chunk-KXOPLLFP.js → chunk-CA7LGAHV.js} +69 -9
- package/{chunk-2FZVXOFX.js → chunk-CEIWXKHP.js} +112 -200
- package/{chunk-Y2TCTNUD.js → chunk-CK2LMTYO.js} +4 -4
- package/{chunk-AIFQKNPP.js → chunk-CL33RFD7.js} +1 -1
- package/{chunk-57V4PADY.js → chunk-CNYPQYXT.js} +781 -449
- package/{chunk-P4R5KXU7.js → chunk-CW6LRDSF.js} +5 -5
- package/chunk-D3ONA3FP.js +762 -0
- package/{chunk-PIVTQRX6.js → chunk-DDKA6V6X.js} +111 -12
- package/chunk-DLXL4NSL.js +1179 -0
- package/{chunk-EJQE5HB7.js → chunk-DSBRIUX5.js} +4 -2
- package/{chunk-XRGBJHZX.js → chunk-E36V7MPY.js} +9 -5
- package/{chunk-4YPH5KRA.js → chunk-EDKMRDET.js} +1 -1
- package/{chunk-DBJODIZ6.js → chunk-EQOWWSNQ.js} +19 -27
- package/chunk-ER6NTALN.js +34 -0
- package/{chunk-L4XST72F.js → chunk-ERCSHBUD.js} +16027 -17392
- package/chunk-EUHMI5KG.js +101 -0
- package/{chunk-YQLAFJRQ.js → chunk-FBNVJ2TO.js} +1 -1
- package/{chunk-Q2EERN52.js → chunk-FF5ZRKW7.js} +12 -7
- package/{chunk-6XIE5ZGI.js → chunk-FGFJUFPS.js} +5 -6
- package/chunk-FI4DPLR7.js +902 -0
- package/{chunk-HDKMVYNJ.js → chunk-FNLT7NKG.js} +7 -11
- package/{chunk-JCQ3WCQ3.js → chunk-FOC4TORM.js} +69 -3
- package/chunk-FP46RAJQ.js +58 -0
- package/{chunk-JPXACKSW.js → chunk-G22P2J7O.js} +30 -81
- package/{chunk-7WHCIA5V.js → chunk-G5IAIGGD.js} +3 -8
- package/{chunk-FZENZCIA.js → chunk-GEC4CHS2.js} +19 -12
- package/chunk-GF4LYNNZ.js +25 -0
- package/{chunk-IYLUK67R.js → chunk-GH6SS2DZ.js} +25 -8
- package/chunk-HAZ6UVH4.js +368 -0
- package/{chunk-OKAXQFON.js → chunk-HB4J5HA6.js} +4 -4
- package/{chunk-324FWHUA.js → chunk-HHXF57CL.js} +12 -3
- package/chunk-HJTI7RZV.js +94 -0
- package/{chunk-HQUGB2HM.js → chunk-HMFKYZKP.js} +62 -50
- package/{chunk-Q2MPKE4B.js → chunk-HVRG27HI.js} +76 -26
- package/{chunk-46FETNLF.js → chunk-IN4B6Z2D.js} +7 -6
- package/chunk-IV6VUVLJ.js +88 -0
- package/{chunk-LLUBUHNT.js → chunk-IWWJSSST.js} +5 -9
- package/{chunk-7BIJFGKS.js → chunk-J22PFCQN.js} +106 -52
- package/chunk-J42X32PV.js +472 -0
- package/{chunk-LCBAMY2M.js → chunk-JKVOKKMQ.js} +0 -7
- package/{chunk-KT7S7ANZ.js → chunk-JPYOHIHX.js} +9 -9
- package/{chunk-R7XWZDOH.js → chunk-JUMQJSQF.js} +1423 -282
- package/{chunk-KVMLM5VD.js → chunk-KAHYBAEN.js} +211 -472
- package/{chunk-KLMBM6P6.js → chunk-KALCFXQO.js} +2454 -1115
- package/chunk-KDDXC2IH.js +148 -0
- package/chunk-KGKTN2NX.js +25 -0
- package/chunk-KGWE224L.js +246 -0
- package/{chunk-OYUMJMC5.js → chunk-KSV6T4AH.js} +6 -1
- package/{chunk-P27E22MA.js → chunk-L43DGEPZ.js} +1 -1
- package/{chunk-5BIDJVNX.js → chunk-L45P4JTE.js} +180 -31
- package/chunk-LHCIIUCX.js +222 -0
- package/{chunk-CBIGMWMI.js → chunk-LHJB4BXJ.js} +1 -1
- package/{chunk-TRRXYFTR.js → chunk-LOFRSJX2.js} +1 -0
- package/{chunk-SQL7YNED.js → chunk-LPXBBC32.js} +71 -5
- package/{chunk-BIDSIRTS.js → chunk-LTCZOOAM.js} +11 -17
- package/chunk-LUTSMSIL.js +425 -0
- package/chunk-LXP53WGF.js +168 -0
- package/{chunk-2CT2J3O6.js → chunk-M7VNNPVX.js} +2493 -4055
- package/chunk-MDAYRIP7.js +1889 -0
- package/{chunk-6B2OBX5B.js → chunk-MMXHIHJZ.js} +15 -47
- package/{chunk-HPDLPEUG.js → chunk-MPWQI36J.js} +267 -234
- package/chunk-MRACVEPZ.js +7 -0
- package/{chunk-ZYPXOQS2.js → chunk-MSFKHPA6.js} +1 -1
- package/chunk-NHLLXINQ.js +8 -0
- package/{chunk-QXTEEEIN.js → chunk-NJCTPWJU.js} +8 -8
- package/chunk-NLS7F5DW.js +1697 -0
- package/{chunk-FP37ELBT.js → chunk-NTBTVKKB.js} +17 -25
- package/{chunk-JLZJL3WC.js → chunk-O77F26YB.js} +370 -39
- package/{chunk-LVZVSLKO.js → chunk-O7ZY6SUK.js} +5 -22
- package/{chunk-YN23INFZ.js → chunk-OIOMBPCA.js} +23 -2
- package/{chunk-CJOOF4L5.js → chunk-OSZNERNW.js} +17 -14
- package/{chunk-JZO7KUF3.js → chunk-P4I55ASV.js} +313 -275
- package/{chunk-2C5VN7NH.js → chunk-P4XAHM4B.js} +1 -1
- package/chunk-PL5RKESU.js +40 -0
- package/chunk-Q5FJJ6XI.js +103 -0
- package/{chunk-WS36XPJD.js → chunk-Q5IXZF3S.js} +82 -6
- package/{createAgentAutomationAction-GRZ6XY7Q.js → chunk-QKM55LP2.js} +3 -160
- package/{chunk-WSLL7VV4.js → chunk-QXWXRBOL.js} +9 -9
- package/{chunk-MXA54TQM.js → chunk-QZYQ3Y3G.js} +1 -1
- package/{chunk-FE7G6DSP.js → chunk-R72QWIFO.js} +14 -4
- package/{chunk-5RGU3J7P.js → chunk-REAE2SZK.js} +0 -1
- package/chunk-RF576RYE.js +117 -0
- package/chunk-RI7SXDJW.js +1317 -0
- package/{chunk-FEIVARWR.js → chunk-RIOAPUGV.js} +238 -25
- package/{chunk-BZLGPM5B.js → chunk-RNLKWUVY.js} +7 -12
- package/{chunk-J7JRCOIW.js → chunk-RWXHGPWJ.js} +1 -1
- package/{chunk-J55F3IEZ.js → chunk-SARJZIGR.js} +1 -1
- package/chunk-SJFL32RD.js +356 -0
- package/{chunk-6SOWMEAY.js → chunk-SR57FDTX.js} +2 -258
- package/{chunk-MPGR4ZNR.js → chunk-SRVLHMES.js} +46 -42
- package/{chunk-CEKRIR22.js → chunk-SU4NCTW4.js} +1 -1
- package/{chunk-RD3QLZQV.js → chunk-SWJRX4M5.js} +324 -2
- package/{chunk-R3TUHCSJ.js → chunk-T3Y2NA4H.js} +8 -3
- package/{chunk-53W5BXLN.js → chunk-TCOHWKDM.js} +54 -55
- package/{chunk-KWNVPY6M.js → chunk-TJXO66M2.js} +8 -5
- package/{chunk-QIGQFON2.js → chunk-TXMFSGRY.js} +1 -1
- package/{chunk-ADYWV732.js → chunk-U5PSCTMR.js} +264 -177
- package/{chunk-UUCYUN6Y.js → chunk-UB7NV7NN.js} +1 -1
- package/{chunk-QGFLVQ6E.js → chunk-UBOTXA3Z.js} +4 -14
- package/{chunk-6YX2RAQN.js → chunk-UEZL3RBG.js} +89 -164
- package/{chunk-NCFKHYDM.js → chunk-UJL23HBL.js} +774 -119
- package/chunk-ULPU4C43.js +1710 -0
- package/{chunk-UA3QTA2S.js → chunk-VC3MAT33.js} +4442 -2570
- package/{chunk-VNHZJEQN.js → chunk-VCESLFF4.js} +3 -3
- package/chunk-VOO3YQQP.js +17157 -0
- package/{chunk-Y2GWUBNS.js → chunk-VZDSNDUD.js} +279 -149
- package/{chunk-6BMTKYAO.js → chunk-W2Z5E2R7.js} +126 -698
- package/{chunk-4ZCTKB27.js → chunk-W5GKF5ZW.js} +1 -0
- package/chunk-WEEB2JKA.js +443 -0
- package/{chunk-NUHQO3RB.js → chunk-WIVVNJUS.js} +1 -1
- package/chunk-WMBJDXMY.js +408 -0
- package/chunk-WSQLCWLQ.js +201 -0
- package/{chunk-OOVOAG4Q.js → chunk-WY6DMHMG.js} +1 -1
- package/{chunk-6K32PBRY.js → chunk-XJW6SLBZ.js} +3 -3
- package/{chunk-MNFUKRRU.js → chunk-XKNDVHF5.js} +7 -7
- package/{chunk-MHKPUGPD.js → chunk-XREMPMNK.js} +20 -4
- package/chunk-XT6C2QZW.js +46 -0
- package/chunk-XUDXQT7R.js +790 -0
- package/{chunk-ZEZC7IIM.js → chunk-YFSM2366.js} +35 -35
- package/{chunk-RIWKZT7E.js → chunk-YRPIUIEQ.js} +11 -9
- package/{chunk-U35UUM5K.js → chunk-YVOUSIIA.js} +1 -1
- package/{chunk-6VEO7Z3Y.js → chunk-Z27AH6A5.js} +6 -6
- package/chunk-Z3KTXWWB.js +76 -0
- package/{chunk-UWWOWTW2.js → chunk-Z7EP5HDL.js} +1 -1
- package/{chunk-YFEK7ACQ.js → chunk-ZB2E724W.js} +4 -4
- package/{chunk-YLAHYLDQ.js → chunk-ZC3CMUKU.js} +2 -89
- package/{chunk-5P3PPQVP.js → chunk-ZQAADXSF.js} +1 -1
- package/{cliAgentConfigHelpers-BXHQ3PXP.js → cliAgentConfigHelpers-BJJEXHSZ.js} +20 -14
- package/{cliAuthorityBrokerClient-TFNXJLXL.js → cliAuthorityBrokerClient-3SKOA7OZ.js} +3 -1
- package/cliAuthorityBrokerProcess-VIJEKQSX.js +34 -0
- package/{cliEnvHelpers-CNMP3RDX.js → cliEnvHelpers-NDMKN4X2.js} +6 -3
- package/{cliExecutor-K6FDZTQ2.js → cliExecutor-Z62UBJ5S.js} +12 -6
- package/cliLocalAgentRecordReader-KCZS2MZU.js +113 -0
- package/cloudAutomationCommands-2WQUGQSW.js +310 -0
- package/{commandRegistry-IFYQLPGM.js → commandRegistry-C64JBZJ3.js} +288 -121
- package/{contentThunks-QCFCD2X3.js → contentThunks-G3HEIRXC.js} +45 -43
- package/{cooldownCommands-WDOI5VD7.js → cooldownCommands-FPAFS7XG.js} +1 -1
- package/createAgentAutomationAction-DSBL3X3A.js +172 -0
- package/createDialogAction-OHFUHC53.js +86 -0
- package/{createPageAction-QCVBMP4C.js → createPageAction-E6JZSZLU.js} +49 -45
- package/{db-VR74ADGC.js → db-KTQ3LL2Q.js} +3 -3
- package/{dbSlice-RWPSVHBC.js → dbSlice-U3GPLEL3.js} +21 -16
- package/deleteDbKey-DRXKWJX5.js +86 -0
- package/{dialogCommands-4IEQUALS.js → dialogCommands-4EX2OTIC.js} +80 -66
- package/{dialogMessageRecord-OAV77LT7.js → dialogMessageRecord-2HJTEXQX.js} +1 -1
- package/dialogNotifyCommand-4SCE2Z2R.js +44 -0
- package/dialogPortabilityCommands-ZSFFHRX4.js +3036 -0
- package/{dialogSlice-XFYID6KE.js → dialogSlice-PRZCIJCH.js} +43 -42
- package/{dialogTraceCommand-Y67NRFCV.js → dialogTraceCommand-RKB76OVX.js} +84 -70
- package/{dialogUsageCommand-WJ3U6KZU.js → dialogUsageCommand-BP7HMRYP.js} +7 -4
- package/{docCreateCommands-QLRIWRQE.js → docCreateCommands-JGPNGIZ7.js} +68 -59
- package/{docDeleteCommands-XPRYA532.js → docDeleteCommands-XRJTNRDH.js} +68 -59
- package/{docReadCommands-EXQI7ETH.js → docReadCommands-6GFO4ARS.js} +67 -58
- package/{docStore-MWFUKZL2.js → docStore-QRLIWFTU.js} +16 -17
- package/{docUpdateCommands-EFBFQV77.js → docUpdateCommands-W2GXMUXW.js} +68 -59
- package/{ebookDownloaderAgentCommand-DYSKF5ZY.js → ebookDownloaderAgentCommand-2DHPGEOQ.js} +14 -17
- package/{fetchMessages-TQEUZD7H.js → fetchMessages-RGPIYEPZ.js} +2 -2
- package/{getPricing-5BLZRPTM.js → getPricing-BK6CUBAE.js} +8 -4
- package/{handleSendMessageAction-GG3TR62X.js → handleSendMessageAction-DHGWURJZ.js} +265 -119
- package/{hostCredentialCreate-26S6DDJ5.js → hostCredentialCreate-FPUZ7RMI.js} +138 -122
- package/index.js +36 -22
- package/{keys-RWF7UCB4.js → keys-FXEGMKSG.js} +2 -2
- package/localAutomationCommands-ZMU22RQJ.js +198 -0
- package/localAutomationRuntime-MU5FGJ3V.js +60 -0
- package/{localDialogRead-BJJT3TF5.js → localDialogRead-W2EVXISA.js} +2 -2
- package/{localRuntimeAdapter-VREWZWPC.js → localRuntimeAdapter-YBXQBV4G.js} +136 -119
- package/localRuntimeAuthority-LDXMEDO5.js +44 -0
- package/{localRuntimeDb-ZJFGNHML.js → localRuntimeDb-6TQZDLNU.js} +1 -1
- package/{machineCommands-CL5XK5UC.js → machineCommands-57RTUYRV.js} +251 -357
- package/{machineInfo-LWHTEBHJ.js → machineInfo-BJIU3WQ5.js} +4 -2
- package/machineWsRunDispatch-VBKV3FFE.js +227 -0
- package/{mcpLocalAuthorizeCommand-RBXJDE6J.js → mcpLocalAuthorizeCommand-J76SOJVZ.js} +40 -22
- package/mcpLocalManageCommands-USETIMHB.js +212 -0
- package/{memberThunks-43B7UYC5.js → memberThunks-7UERUEMI.js} +102 -22
- package/{memoryCommands-BC6REPQB.js → memoryCommands-N7NHEE55.js} +25 -34
- package/{models-ZX2BYIMB.js → models-TOXYINNM.js} +3 -2
- package/{offlineMarxistsAgentCommand-XVXUE6G5.js → offlineMarxistsAgentCommand-WZBJBCPZ.js} +16 -22
- package/package.json +3 -3
- package/parityCommands-LYDLWSLK.js +613 -0
- package/{projectArchive-OC63TWTD.js → projectArchive-KCNQDVWJ.js} +49 -45
- package/{providerPresetApply-NTJUINI6.js → providerPresetApply-IRJ56XIZ.js} +12 -16
- package/{providerRegistry-W45SLUV6.js → providerRegistry-26PAUYH2.js} +3 -13
- package/{read-KG6INYUT.js → read-SPSQ6NLR.js} +11 -10
- package/{readDocTool-N3GA52JR.js → readDocTool-ENUL2GNL.js} +5 -1
- package/{readlineWorkspace-2NO6D6IZ.js → readlineWorkspace-MKS7TAEF.js} +927 -573
- package/{rememberExplicit-CPAPONSI.js → rememberExplicit-7KX4HXQC.js} +4 -4
- package/remove-TNNDO635.js +32 -0
- package/{removeDialogAgentAction-EEVSOQOJ.js → removeDialogAgentAction-POPUZ3WU.js} +22 -26
- package/{runAgentClientLoop-U7V32UTD.js → runAgentClientLoop-KVILXQNI.js} +117 -82
- package/{runtimeDoctorCommands-V3M3JTUV.js → runtimeDoctorCommands-4J2DP4LZ.js} +23 -16
- package/{secretCommands-KVVZS7A6.js → secretCommands-CSTQYB6T.js} +2 -2
- package/{setDialogExtraReferencesAction-DNO5POHA.js → setDialogExtraReferencesAction-35THMVBP.js} +16 -17
- package/{setPrimaryDialogAgentAction-QABBEO4C.js → setPrimaryDialogAgentAction-WLXBNIG7.js} +23 -27
- package/{settingThunks-DVKG4X4S.js → settingThunks-6Y5U5M5N.js} +170 -497
- package/{skillDiscovery-5GEGWJ6N.js → skillDiscovery-IUEZZG2B.js} +3 -3
- package/{spaceCommands-7QKXKBDQ.js → spaceCommands-LXNJBO2U.js} +293 -58
- package/spacePruneCommand-2ITUFYBM.js +233 -0
- package/{store-Z53ICFL3.js → store-WSAVTR32.js} +3 -1
- package/{streamAgentChatTurn-UAGFOXNJ.js → streamAgentChatTurn-EY6MFKCA.js} +225 -137
- package/{switchDialogAgentAction-KYWJSGOO.js → switchDialogAgentAction-TG6BQRDA.js} +19 -23
- package/{tableCommands-EFA754RE.js → tableCommands-35G34R4B.js} +28 -49
- package/{toolApiClient-N5PYW2R3.js → toolApiClient-MPQIFYXP.js} +15 -4
- package/{tools-2Q2LBDUC.js → tools-CSLTRRUR.js} +73 -63
- package/{tuiRestart-4QDWLHYZ.js → tuiRestart-ALR4Q3JM.js} +20 -13
- package/tuiSummaryLlmCaller-3Y3JEXJK.js +52 -0
- package/{updateCommands-GJGRS6JK.js → updateCommands-GHQVP6Z5.js} +13 -8
- package/{updateDialogTitleAction-GGNTTI5L.js → updateDialogTitleAction-LFAWF5EW.js} +57 -58
- package/{usageCommand-WI6SQOPB.js → usageCommand-5VKW6T4C.js} +6 -8
- package/{usageRebuildCommand-WQRLLZAT.js → usageRebuildCommand-VUQETFMW.js} +11 -15
- package/{windowsSelfUpdate-C7LGVWYX.js → windowsSelfUpdate-SXSVXK4X.js} +2 -2
- package/workContext-ZAW6VXT7.js +18 -0
- package/workContextQueryProjection-CACY5VFE.js +23 -0
- package/{workloadLifecycle-DYX5ZMAT.js → workloadLifecycle-P2SJVV3S.js} +1 -1
- package/agentFavoriteCommands-7LOP3HUD.js +0 -186
- package/agentRecordCommands-TPE7NSZ6.js +0 -194
- package/agentRunCommand-DMVGBPLI.js +0 -232
- package/authCommand-V6EOMZX6.js +0 -79
- package/chunk-2MBTWINN.js +0 -89
- package/chunk-523DITKR.js +0 -32
- package/chunk-BUDVRYES.js +0 -2213
- package/chunk-BZMDWGQQ.js +0 -47
- package/chunk-GAHJLSDO.js +0 -107
- package/chunk-GYX6XTAI.js +0 -84
- package/chunk-HNUWUO75.js +0 -93
- package/chunk-HSBHS6KT.js +0 -33401
- package/chunk-KG27JIG4.js +0 -136
- package/chunk-OB4FBZXJ.js +0 -364
- package/chunk-OKH74FML.js +0 -3746
- package/chunk-OLZBQWZU.js +0 -6
- package/chunk-OOV5JN25.js +0 -1317
- package/chunk-OQFOE4SJ.js +0 -405
- package/chunk-PXYBUFDB.js +0 -53
- package/chunk-R3FZHW4Q.js +0 -103
- package/chunk-R3MV2GII.js +0 -106
- package/chunk-SCAC3NM5.js +0 -11751
- package/chunk-SR4FE5VD.js +0 -9
- package/chunk-SYTHYBMI.js +0 -3558
- package/chunk-UKZX3NHN.js +0 -48
- package/chunk-UVLYNWIE.js +0 -74
- package/chunk-VQX5JJNI.js +0 -861
- package/chunk-X4O7FJF5.js +0 -160
- package/chunk-YJPK35HB.js +0 -175
- package/chunk-YNIYE47Z.js +0 -105
- package/chunk-Z4PCXPUE.js +0 -127
- package/chunk-ZR5IVL4N.js +0 -862
- package/chunk-ZTHAJU3O.js +0 -2537
- package/cliAuthorityBrokerProcess-5ZFBTHLB.js +0 -22
- package/cliLocalAgentRecordReader-34UKRBLY.js +0 -104
- package/createDialogAction-ZAJERW62.js +0 -82
- package/deleteFile-ECU6FU5C.js +0 -55
- package/dialogNotifyCommand-IASQGEMW.js +0 -36
- package/localRuntimeAuthority-UF2DAQ3F.js +0 -28
- package/machineWsRunDispatch-TBVOYOAH.js +0 -209
- package/markdownToSlate-PXYAIBVL.js +0 -8
- package/tuiSummaryLlmCaller-HROLGN4F.js +0 -45
- package/webapi-QVV65DQF.js +0 -2487
- package/workContext-Y3ADAPZU.js +0 -14
- package/{chunk-USGHJSGO.js → chunk-GX2MFKF3.js} +3 -3
- package/{chunk-PHREU2KZ.js → chunk-WX266G2C.js} +0 -0
- package/{chunk-DXWGFL2Z.js → chunk-YY7IGJMN.js} +3 -3
package/chunk-OOV5JN25.js
DELETED
|
@@ -1,1317 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
streamSseDataValues
|
|
3
|
-
} from "./chunk-HNUWUO75.js";
|
|
4
|
-
import {
|
|
5
|
-
resolveToolImagePolicy
|
|
6
|
-
} from "./chunk-BZLGPM5B.js";
|
|
7
|
-
import {
|
|
8
|
-
projectOpenAiToolImages
|
|
9
|
-
} from "./chunk-X4O7FJF5.js";
|
|
10
|
-
import {
|
|
11
|
-
getAntigravityUserAgent,
|
|
12
|
-
readAntigravityProjectId,
|
|
13
|
-
resolveAntigravityCloudCodeBaseUrl
|
|
14
|
-
} from "./chunk-6SOWMEAY.js";
|
|
15
|
-
import {
|
|
16
|
-
asOptionalTrimmedString
|
|
17
|
-
} from "./chunk-G3SUCT4W.js";
|
|
18
|
-
|
|
19
|
-
// packages/agent-runtime/types.ts
|
|
20
|
-
var AGENT_PROMPT_IN_MESSAGES = Symbol("agent-prompt-in-messages");
|
|
21
|
-
function hasAssembledAgentPrompt(messages) {
|
|
22
|
-
return messages.some((raw) => {
|
|
23
|
-
if (!raw || typeof raw !== "object") return false;
|
|
24
|
-
const message = raw;
|
|
25
|
-
return message.role === "system" && message[AGENT_PROMPT_IN_MESSAGES] === true;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// packages/core/chat/upstreamErrorBody.ts
|
|
30
|
-
function parseUpstreamErrorBody(errorText, statusText) {
|
|
31
|
-
if (errorText) {
|
|
32
|
-
try {
|
|
33
|
-
const parsed = JSON.parse(errorText);
|
|
34
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
35
|
-
const error = parsed.error;
|
|
36
|
-
if (error && typeof error === "object" && !Array.isArray(error)) {
|
|
37
|
-
return parsed;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
} catch {
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return { error: { message: errorText || statusText } };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// packages/agent-runtime/antigravityCloudCodeProvider.ts
|
|
47
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
48
|
-
|
|
49
|
-
// packages/agent-runtime/antigravityWireModel.ts
|
|
50
|
-
var WIRE_PROFILES = {
|
|
51
|
-
// Antigravity discovery exposes 3.7 Flash as one tiered wire model.
|
|
52
|
-
// The UI labels its effort variants (Low/Medium/High), but the literal
|
|
53
|
-
// -medium/-high ids return 404 from streamGenerateContent.
|
|
54
|
-
"gemini-3.7-flash-tiered": {
|
|
55
|
-
modelEnum: "MODEL_PLACEHOLDER_M301",
|
|
56
|
-
maxOutputTokens: 65536
|
|
57
|
-
},
|
|
58
|
-
// Gemini 3.8 Flash 沿用 3.7 的 tiered 兼容策略:仓库内暂无 Antigravity discovery
|
|
59
|
-
// 证据确认 3.8 的 wire modelEnum,禁止虚构,先只声明同档输出上限;enum 待
|
|
60
|
-
// discovery 证据到位后补齐。
|
|
61
|
-
"gemini-3.8-flash-tiered": { maxOutputTokens: 65536 },
|
|
62
|
-
// Discovery (2026-11-16) exposes separate enabled Argon effort variants.
|
|
63
|
-
"gemini-4-argon-low": {
|
|
64
|
-
modelEnum: "MODEL_PLACEHOLDER_M419",
|
|
65
|
-
maxOutputTokens: 65536
|
|
66
|
-
},
|
|
67
|
-
"gemini-4-argon-medium": {
|
|
68
|
-
modelEnum: "MODEL_PLACEHOLDER_M418",
|
|
69
|
-
maxOutputTokens: 65536
|
|
70
|
-
},
|
|
71
|
-
"gemini-4-argon-high": {
|
|
72
|
-
modelEnum: "MODEL_PLACEHOLDER_M417",
|
|
73
|
-
maxOutputTokens: 65536
|
|
74
|
-
},
|
|
75
|
-
// Discovery (2026-11-17) exposes Carbon effort variants with their own enums and a
|
|
76
|
-
// 262144 output cap (Argon caps at 65536). 裸 gemini-4-carbon 不在 discovery 里,
|
|
77
|
-
// 必须折叠到 effort 变体,否则上游回 404。
|
|
78
|
-
"gemini-4-carbon-low": {
|
|
79
|
-
modelEnum: "MODEL_PLACEHOLDER_M438",
|
|
80
|
-
maxOutputTokens: 262144
|
|
81
|
-
},
|
|
82
|
-
"gemini-4-carbon-medium": {
|
|
83
|
-
modelEnum: "MODEL_PLACEHOLDER_M437",
|
|
84
|
-
maxOutputTokens: 262144
|
|
85
|
-
},
|
|
86
|
-
"gemini-4-carbon-high": {
|
|
87
|
-
modelEnum: "MODEL_PLACEHOLDER_M427",
|
|
88
|
-
maxOutputTokens: 262144
|
|
89
|
-
},
|
|
90
|
-
// Antigravity discovery 暴露 -medium / -high 变体;尚无 modelEnum 证据时不虚构 enum,仅声明 65536 输出上限。
|
|
91
|
-
"gemini-4-hydrogen-medium": { maxOutputTokens: 65536 },
|
|
92
|
-
"gemini-4-hydrogen-high": { maxOutputTokens: 65536 },
|
|
93
|
-
// Gemini 4 Neon(官方 2026-11-18 发布;仅 Google AI Pro / Ultra / Enterprise)**不登记 profile**:
|
|
94
|
-
// 2026-11-19 订阅档账号强制刷新 token 后跑 fetchAvailableModels(UA `antigravity/hub/2.26.0`),
|
|
95
|
-
// 四个 effort 变体 `gemini-4-neon-low` / `-medium` / `-high` / `-xhigh` 全部 enabled,
|
|
96
|
-
// 与官方 Antigravity 模型列表同形;同一批里仍没有裸 `gemini-4-neon`,free-tier 账号
|
|
97
|
-
// 依旧只看到 `gemini-4-neon-disabled`(MODEL_PLACEHOLDER_M536,tagDescription
|
|
98
|
-
// 「currently available to paid Pro and Ultra subscribers」)。
|
|
99
|
-
// 这批 discovery 没有给出四个变体的 modelEnum,也没有给出各自的输出窗口,因此这里**不写
|
|
100
|
-
// WIRE_PROFILES**:不虚构 enum、不复用 disabled 占位符的 262144 窗口、不折叠到
|
|
101
|
-
// Hydrogen / Carbon 冒充。四个变体按 wire id 原样透传,输出上限回落 agentConfig.max_tokens。
|
|
102
|
-
"gemini-3.6-flash-low": { maxOutputTokens: 65536 },
|
|
103
|
-
"gemini-3.6-flash-medium": { maxOutputTokens: 65536 },
|
|
104
|
-
"gemini-3.6-flash-high": { maxOutputTokens: 65536 },
|
|
105
|
-
// 旧模型 wire 映射保留:存量自定义 agent 仍可能引用(注册表已下线不影响此处)。
|
|
106
|
-
"gemini-3.5-flash-extra-low": {
|
|
107
|
-
modelEnum: "MODEL_PLACEHOLDER_M187",
|
|
108
|
-
maxOutputTokens: 65536
|
|
109
|
-
},
|
|
110
|
-
"gemini-3.5-flash-low": {
|
|
111
|
-
modelEnum: "MODEL_PLACEHOLDER_M20",
|
|
112
|
-
maxOutputTokens: 65536
|
|
113
|
-
},
|
|
114
|
-
"gemini-3-flash-agent": {
|
|
115
|
-
modelEnum: "MODEL_PLACEHOLDER_M132",
|
|
116
|
-
maxOutputTokens: 65536
|
|
117
|
-
},
|
|
118
|
-
"gemini-3.1-pro-low": {
|
|
119
|
-
modelEnum: "MODEL_PLACEHOLDER_M36",
|
|
120
|
-
maxOutputTokens: 65535
|
|
121
|
-
},
|
|
122
|
-
"gemini-pro-agent": {
|
|
123
|
-
modelEnum: "MODEL_PLACEHOLDER_M16",
|
|
124
|
-
maxOutputTokens: 65535
|
|
125
|
-
},
|
|
126
|
-
"claude-sonnet-5": { maxOutputTokens: 64e3 },
|
|
127
|
-
"claude-sonnet-4-6": { maxOutputTokens: 64e3 },
|
|
128
|
-
"claude-opus-4-6-thinking": { maxOutputTokens: 64e3 },
|
|
129
|
-
"gemini-2.5-flash": { maxOutputTokens: 65536 },
|
|
130
|
-
"gemini-2.5-pro": { maxOutputTokens: 65536 }
|
|
131
|
-
};
|
|
132
|
-
function resolveAntigravityWireModel(logicalModelId, reasoningEffort) {
|
|
133
|
-
const id = logicalModelId.trim();
|
|
134
|
-
const lower = id.toLowerCase();
|
|
135
|
-
if (lower === "gemini-3.5-flash") {
|
|
136
|
-
const wireModelId = "gemini-3.5-flash-low";
|
|
137
|
-
return { wireModelId, profile: WIRE_PROFILES[wireModelId] };
|
|
138
|
-
}
|
|
139
|
-
if (lower === "gemini-3.7-flash" || [
|
|
140
|
-
"gemini-3.7-flash-low",
|
|
141
|
-
"gemini-3.7-flash-medium",
|
|
142
|
-
"gemini-3.7-flash-high"
|
|
143
|
-
].includes(lower)) {
|
|
144
|
-
const wireModelId = "gemini-3.7-flash-tiered";
|
|
145
|
-
return { wireModelId, profile: WIRE_PROFILES[wireModelId] };
|
|
146
|
-
}
|
|
147
|
-
if (lower === "gemini-3.8-flash" || [
|
|
148
|
-
"gemini-3.8-flash-low",
|
|
149
|
-
"gemini-3.8-flash-medium",
|
|
150
|
-
"gemini-3.8-flash-high"
|
|
151
|
-
].includes(lower)) {
|
|
152
|
-
const wireModelId = "gemini-3.8-flash-tiered";
|
|
153
|
-
return { wireModelId, profile: WIRE_PROFILES[wireModelId] };
|
|
154
|
-
}
|
|
155
|
-
const gemini4 = /^gemini-4-(argon|carbon)(?:-(low|medium|high))?$/.exec(
|
|
156
|
-
lower
|
|
157
|
-
);
|
|
158
|
-
if (gemini4) {
|
|
159
|
-
const family = gemini4[1] ?? "argon";
|
|
160
|
-
const explicitEffort = gemini4[2];
|
|
161
|
-
const effort = reasoningEffort?.trim().toLowerCase();
|
|
162
|
-
const selected = explicitEffort ?? (effort === "low" || effort === "high" ? effort : "medium");
|
|
163
|
-
const wireModelId = `gemini-4-${family}-${selected}`;
|
|
164
|
-
return { wireModelId, profile: WIRE_PROFILES[wireModelId] };
|
|
165
|
-
}
|
|
166
|
-
const hydrogen = /^gemini-4-hydrogen(?:-(medium|high))?$/.exec(lower);
|
|
167
|
-
if (hydrogen) {
|
|
168
|
-
const explicitEffort = hydrogen[1];
|
|
169
|
-
const effort = reasoningEffort?.trim().toLowerCase();
|
|
170
|
-
const selected = explicitEffort ?? (effort === "high" ? "high" : "medium");
|
|
171
|
-
const wireModelId = `gemini-4-hydrogen-${selected}`;
|
|
172
|
-
return { wireModelId, profile: WIRE_PROFILES[wireModelId] };
|
|
173
|
-
}
|
|
174
|
-
if (lower === "gemini-3.6-flash") {
|
|
175
|
-
const wireModelId = "gemini-3.6-flash-low";
|
|
176
|
-
return { wireModelId, profile: WIRE_PROFILES[wireModelId] };
|
|
177
|
-
}
|
|
178
|
-
if (lower === "gemini-3.1-pro" || lower === "gemini-3.1-pro-preview") {
|
|
179
|
-
const wireModelId = "gemini-3.1-pro-low";
|
|
180
|
-
return { wireModelId, profile: WIRE_PROFILES[wireModelId] };
|
|
181
|
-
}
|
|
182
|
-
if (WIRE_PROFILES[id]) {
|
|
183
|
-
return { wireModelId: id, profile: WIRE_PROFILES[id] };
|
|
184
|
-
}
|
|
185
|
-
return { wireModelId: id };
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// packages/agent-runtime/sseDataLine.ts
|
|
189
|
-
function parseSseDataLineJson(line) {
|
|
190
|
-
const trimmed = line.trim();
|
|
191
|
-
if (!trimmed.startsWith("data:")) return null;
|
|
192
|
-
const payload = trimmed.slice(5).trim();
|
|
193
|
-
if (!payload || payload === "[DONE]") return null;
|
|
194
|
-
try {
|
|
195
|
-
return JSON.parse(payload);
|
|
196
|
-
} catch {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
function parseSseDataLineObject(line) {
|
|
201
|
-
const parsed = parseSseDataLineJson(line);
|
|
202
|
-
return parsed && typeof parsed === "object" ? parsed : null;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// packages/agent-runtime/geminiNativeShared.ts
|
|
206
|
-
var SKIP_THOUGHT_SIGNATURE = "skip_thought_signature_validator";
|
|
207
|
-
function resolveGeminiModelQuirks(modelId) {
|
|
208
|
-
const lower = modelId.toLowerCase();
|
|
209
|
-
const isGemini3 = lower.includes("gemini-3");
|
|
210
|
-
const isStrictSignatureModel = lower.includes("gemini-3.5") || lower.includes("flash-preview");
|
|
211
|
-
const isClaude = lower.includes("claude");
|
|
212
|
-
return {
|
|
213
|
-
requiresThoughtSignature: isGemini3,
|
|
214
|
-
allowsThoughtSignatureSentinel: isGemini3 && !isStrictSignatureModel,
|
|
215
|
-
isClaudeCrossModel: isClaude
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
function isGemini3Model(modelId) {
|
|
219
|
-
return resolveGeminiModelQuirks(modelId).requiresThoughtSignature;
|
|
220
|
-
}
|
|
221
|
-
function messageText(content) {
|
|
222
|
-
if (typeof content === "string") return content;
|
|
223
|
-
if (!Array.isArray(content)) return "";
|
|
224
|
-
return content.filter(
|
|
225
|
-
(part) => part?.type === "text"
|
|
226
|
-
).map((part) => part.text).join("\n").trim();
|
|
227
|
-
}
|
|
228
|
-
function parseDataUrlToInlineData(url) {
|
|
229
|
-
const match = /^data:([A-Za-z0-9.+-]+\/[A-Za-z0-9.+-]+);base64,([A-Za-z0-9+/=]*)$/.exec(
|
|
230
|
-
url
|
|
231
|
-
);
|
|
232
|
-
if (!match) return null;
|
|
233
|
-
return { mimeType: match[1], data: match[2] };
|
|
234
|
-
}
|
|
235
|
-
function filterOrphanedToolMessages(messages) {
|
|
236
|
-
if (!Array.isArray(messages)) return [];
|
|
237
|
-
const result = [];
|
|
238
|
-
let pendingFunctionCalls = [];
|
|
239
|
-
let toolCallIndex = 0;
|
|
240
|
-
for (const raw of messages) {
|
|
241
|
-
if (!raw || typeof raw !== "object" || !("role" in raw)) continue;
|
|
242
|
-
const role = String(raw.role);
|
|
243
|
-
if (role === "system") {
|
|
244
|
-
result.push(raw);
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
if (role === "user") {
|
|
248
|
-
pendingFunctionCalls = [];
|
|
249
|
-
result.push(raw);
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
|
-
if (role === "assistant" || role === "model") {
|
|
253
|
-
pendingFunctionCalls = [];
|
|
254
|
-
const calls = "tool_calls" in raw && Array.isArray(raw.tool_calls) ? raw.tool_calls : [];
|
|
255
|
-
for (const call of calls) {
|
|
256
|
-
if (!call || typeof call !== "object") continue;
|
|
257
|
-
const name = call.function?.name || `tool_${++toolCallIndex}`;
|
|
258
|
-
const id = typeof call.id === "string" ? call.id : "";
|
|
259
|
-
pendingFunctionCalls.push({ name, id });
|
|
260
|
-
}
|
|
261
|
-
result.push(raw);
|
|
262
|
-
continue;
|
|
263
|
-
}
|
|
264
|
-
if (role === "tool") {
|
|
265
|
-
const toolCallId = "tool_call_id" in raw && typeof raw.tool_call_id === "string" ? raw.tool_call_id : "";
|
|
266
|
-
const rawName = "name" in raw && typeof raw.name === "string" ? raw.name.trim() : "";
|
|
267
|
-
const pendingIndex = pendingFunctionCalls.findIndex(
|
|
268
|
-
(p) => toolCallId ? p.id === toolCallId : rawName ? p.name === rawName : true
|
|
269
|
-
);
|
|
270
|
-
if (pendingIndex === -1) {
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
pendingFunctionCalls.splice(pendingIndex, 1);
|
|
274
|
-
result.push(raw);
|
|
275
|
-
continue;
|
|
276
|
-
}
|
|
277
|
-
result.push(raw);
|
|
278
|
-
}
|
|
279
|
-
return result;
|
|
280
|
-
}
|
|
281
|
-
function convertOpenAiMessagesToGemini(messages, options) {
|
|
282
|
-
const sanitizedMessages = filterOrphanedToolMessages(
|
|
283
|
-
messages ?? []
|
|
284
|
-
);
|
|
285
|
-
const effectiveMessages = projectOpenAiToolImages(
|
|
286
|
-
sanitizedMessages,
|
|
287
|
-
options.supportsToolImages === true,
|
|
288
|
-
options.maxImagesPerRequest
|
|
289
|
-
);
|
|
290
|
-
const contents = [];
|
|
291
|
-
const systemTexts = [];
|
|
292
|
-
let toolCallIndex = 0;
|
|
293
|
-
let pendingFunctionCalls = [];
|
|
294
|
-
const pushOrMergeContent = (role, parts) => {
|
|
295
|
-
if (parts.length === 0) return;
|
|
296
|
-
const last = contents[contents.length - 1];
|
|
297
|
-
if (last && last.role === role) {
|
|
298
|
-
last.parts.push(...parts);
|
|
299
|
-
} else {
|
|
300
|
-
contents.push({ role, parts });
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
const flushPendingFunctionCalls = () => {
|
|
304
|
-
if (pendingFunctionCalls.length === 0) return;
|
|
305
|
-
const dummyResponses = pendingFunctionCalls.map(
|
|
306
|
-
({ name, id }) => ({
|
|
307
|
-
functionResponse: {
|
|
308
|
-
name,
|
|
309
|
-
response: { output: "{}" },
|
|
310
|
-
...id ? { id } : {}
|
|
311
|
-
}
|
|
312
|
-
})
|
|
313
|
-
);
|
|
314
|
-
pendingFunctionCalls = [];
|
|
315
|
-
pushOrMergeContent("user", dummyResponses);
|
|
316
|
-
};
|
|
317
|
-
for (const raw of effectiveMessages) {
|
|
318
|
-
if (!raw || typeof raw !== "object" || !("role" in raw)) continue;
|
|
319
|
-
const role = String(raw.role);
|
|
320
|
-
const content = "content" in raw ? raw.content : null;
|
|
321
|
-
if (role === "system") {
|
|
322
|
-
const text = messageText(
|
|
323
|
-
content
|
|
324
|
-
);
|
|
325
|
-
if (text) systemTexts.push(text);
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
if (role === "user") {
|
|
329
|
-
flushPendingFunctionCalls();
|
|
330
|
-
const parts = [];
|
|
331
|
-
if (typeof content === "string") {
|
|
332
|
-
const text = content.trim();
|
|
333
|
-
if (text) parts.push({ text });
|
|
334
|
-
} else if (Array.isArray(content)) {
|
|
335
|
-
for (const part of content) {
|
|
336
|
-
if (!part || typeof part !== "object") continue;
|
|
337
|
-
if (part.type === "text" && typeof part.text === "string" && part.text.trim()) {
|
|
338
|
-
parts.push({ text: part.text });
|
|
339
|
-
} else if (part.type === "image_url") {
|
|
340
|
-
const url = part.image_url?.url;
|
|
341
|
-
if (typeof url === "string" && url.trim()) {
|
|
342
|
-
const inline = parseDataUrlToInlineData(url);
|
|
343
|
-
if (inline) parts.push({ inlineData: inline });
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
if (parts.length === 0) continue;
|
|
349
|
-
pushOrMergeContent("user", parts);
|
|
350
|
-
continue;
|
|
351
|
-
}
|
|
352
|
-
if (role === "assistant") {
|
|
353
|
-
flushPendingFunctionCalls();
|
|
354
|
-
const text = messageText(
|
|
355
|
-
content
|
|
356
|
-
);
|
|
357
|
-
const toolCalls = "tool_calls" in raw && Array.isArray(raw.tool_calls) ? raw.tool_calls ?? [] : [];
|
|
358
|
-
const parts = [];
|
|
359
|
-
if (text) {
|
|
360
|
-
parts.push({ text });
|
|
361
|
-
}
|
|
362
|
-
for (const call of toolCalls) {
|
|
363
|
-
const name = call?.function?.name?.trim();
|
|
364
|
-
if (!name) continue;
|
|
365
|
-
const id = call.id?.trim() || `${name}_${toolCallIndex++}`;
|
|
366
|
-
pendingFunctionCalls.push({ name, id });
|
|
367
|
-
const realSignature = typeof call.thought_signature === "string" && call.thought_signature ? call.thought_signature : void 0;
|
|
368
|
-
const isFirstFunctionCallPart = !parts.some(
|
|
369
|
-
(p) => "functionCall" in p
|
|
370
|
-
);
|
|
371
|
-
const signature = realSignature ?? (options.attachSkipThoughtSignature && isFirstFunctionCallPart ? SKIP_THOUGHT_SIGNATURE : void 0);
|
|
372
|
-
const part = {
|
|
373
|
-
functionCall: {
|
|
374
|
-
name,
|
|
375
|
-
args: parseToolArgs(call.function?.arguments),
|
|
376
|
-
...id ? { id } : {}
|
|
377
|
-
},
|
|
378
|
-
...signature ? { thoughtSignature: signature } : {}
|
|
379
|
-
};
|
|
380
|
-
parts.push(part);
|
|
381
|
-
}
|
|
382
|
-
pushOrMergeContent("model", parts);
|
|
383
|
-
continue;
|
|
384
|
-
}
|
|
385
|
-
if (role === "tool") {
|
|
386
|
-
const toolCallId = "tool_call_id" in raw && typeof raw.tool_call_id === "string" ? raw.tool_call_id : "";
|
|
387
|
-
const rawName = "name" in raw && typeof raw.name === "string" ? raw.name.trim() : "";
|
|
388
|
-
const pendingIndex = pendingFunctionCalls.findIndex(
|
|
389
|
-
(p) => toolCallId ? p.id === toolCallId : rawName ? p.name === rawName : true
|
|
390
|
-
);
|
|
391
|
-
if (pendingIndex === -1) continue;
|
|
392
|
-
const [{ name, id }] = pendingFunctionCalls.splice(pendingIndex, 1);
|
|
393
|
-
const output = messageText(content) || "{}";
|
|
394
|
-
pushOrMergeContent("user", [
|
|
395
|
-
{
|
|
396
|
-
functionResponse: {
|
|
397
|
-
name,
|
|
398
|
-
response: { output },
|
|
399
|
-
// 保留 OpenAI tool_call_id:antigravity Cloud Code Assist 网关把
|
|
400
|
-
// Gemini contents 转成 Claude messages 时需要 functionResponse →
|
|
401
|
-
// tool_result 的 tool_use_id;缺 id 时网关报
|
|
402
|
-
// "tool_result.tool_use_id: Field required"(HTTP 400)。
|
|
403
|
-
...id ? { id } : {}
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
]);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
flushPendingFunctionCalls();
|
|
410
|
-
if (contents.length > 0 && contents[0]?.role === "model") {
|
|
411
|
-
contents.unshift({
|
|
412
|
-
role: "user",
|
|
413
|
-
parts: [{ text: "Continue the conversation." }]
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
return { contents, systemTexts };
|
|
417
|
-
}
|
|
418
|
-
function parseToolArgs(raw) {
|
|
419
|
-
if (typeof raw === "string") {
|
|
420
|
-
try {
|
|
421
|
-
const parsed = JSON.parse(raw);
|
|
422
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
423
|
-
return parsed;
|
|
424
|
-
}
|
|
425
|
-
} catch {
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
429
|
-
return raw;
|
|
430
|
-
}
|
|
431
|
-
return {};
|
|
432
|
-
}
|
|
433
|
-
function sanitizeGeminiSchemaNode(node, active) {
|
|
434
|
-
const out = {};
|
|
435
|
-
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
436
|
-
return { type: "string" };
|
|
437
|
-
}
|
|
438
|
-
if (active?.has(node)) {
|
|
439
|
-
return { type: "object", description: "(circular schema reference)" };
|
|
440
|
-
}
|
|
441
|
-
const seen = active ?? /* @__PURE__ */ new WeakSet();
|
|
442
|
-
seen.add(node);
|
|
443
|
-
try {
|
|
444
|
-
return sanitizeGeminiSchemaNodeInner(node, out, seen);
|
|
445
|
-
} finally {
|
|
446
|
-
seen.delete(node);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
var enumMetaByNode = /* @__PURE__ */ new WeakMap();
|
|
450
|
-
function enumMetaOf(node) {
|
|
451
|
-
return node && typeof node === "object" ? enumMetaByNode.get(node) : void 0;
|
|
452
|
-
}
|
|
453
|
-
function rawEnumValues(src) {
|
|
454
|
-
if (Array.isArray(src.enum) && src.enum.length > 0) return src.enum;
|
|
455
|
-
if ("const" in src && src.const !== void 0) return [src.const];
|
|
456
|
-
return void 0;
|
|
457
|
-
}
|
|
458
|
-
function geminiEnumFields(values, baseDescription) {
|
|
459
|
-
if (values.every((v) => typeof v === "string")) {
|
|
460
|
-
return {
|
|
461
|
-
enum: [...new Set(values)],
|
|
462
|
-
description: baseDescription
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
if (values.every((v) => typeof v === "number" || typeof v === "boolean")) {
|
|
466
|
-
const allowed2 = [...new Set(values.map((v) => String(v)))].join(", ");
|
|
467
|
-
const note2 = `(allowed: ${allowed2})`;
|
|
468
|
-
return {
|
|
469
|
-
description: baseDescription ? `${baseDescription} ${note2}` : note2
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
const allowed = [...new Set(values.map(geminiEnumLiteral))].join(", ");
|
|
473
|
-
const note = `(allowed: ${allowed})`;
|
|
474
|
-
return {
|
|
475
|
-
description: baseDescription ? `${baseDescription} ${note}` : note
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
function geminiEnumLiteral(value) {
|
|
479
|
-
const json = JSON.stringify(value);
|
|
480
|
-
return json === void 0 ? String(value) : json;
|
|
481
|
-
}
|
|
482
|
-
function applyGeminiEnum(out, fields) {
|
|
483
|
-
if (fields.enum) out.enum = fields.enum;
|
|
484
|
-
if (fields.description !== void 0) out.description = fields.description;
|
|
485
|
-
}
|
|
486
|
-
function sanitizeGeminiSchemaNodeInner(src, out, seen) {
|
|
487
|
-
if (Array.isArray(src.type)) {
|
|
488
|
-
const firstNonNull = src.type.find((t) => t !== "null");
|
|
489
|
-
if (typeof firstNonNull === "string") out.type = firstNonNull;
|
|
490
|
-
out.nullable = true;
|
|
491
|
-
} else if (typeof src.type === "string") {
|
|
492
|
-
out.type = src.type === "null" ? "string" : src.type;
|
|
493
|
-
if (src.type === "null") out.nullable = true;
|
|
494
|
-
}
|
|
495
|
-
if (typeof src.description === "string") out.description = src.description;
|
|
496
|
-
if (typeof src.minimum === "number") out.minimum = src.minimum;
|
|
497
|
-
if (typeof src.maximum === "number") out.maximum = src.maximum;
|
|
498
|
-
if (src.nullable === true) out.nullable = true;
|
|
499
|
-
const enumValues = rawEnumValues(src);
|
|
500
|
-
if (enumValues) {
|
|
501
|
-
const baseDescription = typeof src.description === "string" ? src.description : void 0;
|
|
502
|
-
enumMetaByNode.set(out, { values: enumValues, baseDescription });
|
|
503
|
-
applyGeminiEnum(out, geminiEnumFields(enumValues, baseDescription));
|
|
504
|
-
}
|
|
505
|
-
if (src.type === "null") {
|
|
506
|
-
out.description = [out.description, "null only"].filter(Boolean).join("\n");
|
|
507
|
-
}
|
|
508
|
-
const variantBranches = [
|
|
509
|
-
...Array.isArray(src.oneOf) ? src.oneOf : [],
|
|
510
|
-
...Array.isArray(src.anyOf) ? src.anyOf : []
|
|
511
|
-
];
|
|
512
|
-
if (variantBranches.length > 0) {
|
|
513
|
-
const rawBranches = variantBranches.map(
|
|
514
|
-
(branch) => branch && typeof branch === "object" && !Array.isArray(branch) ? branch : {}
|
|
515
|
-
);
|
|
516
|
-
const allSanitized = variantBranches.map(
|
|
517
|
-
(branch) => sanitizeGeminiSchemaNode(branch, seen)
|
|
518
|
-
);
|
|
519
|
-
if (rawBranches.some(
|
|
520
|
-
(branch, index) => branch.type === "null" || allSanitized[index]?.nullable === true || rawEnumValues(branch)?.includes(null)
|
|
521
|
-
)) out.nullable = true;
|
|
522
|
-
const nonNullIndices = rawBranches.flatMap(
|
|
523
|
-
(branch, index) => branch.type === "null" ? [] : [index]
|
|
524
|
-
);
|
|
525
|
-
const branches = nonNullIndices.map((index) => rawBranches[index]);
|
|
526
|
-
const sanitizedBranches = nonNullIndices.map((index) => allSanitized[index]);
|
|
527
|
-
const inferType = (branch) => {
|
|
528
|
-
if (typeof branch.type === "string") return branch.type;
|
|
529
|
-
const values = rawEnumValues(branch)?.filter((value) => value !== null);
|
|
530
|
-
if (!values?.length) return void 0;
|
|
531
|
-
if (values.every((value) => typeof value === "number")) {
|
|
532
|
-
return values.every((value) => Number.isInteger(value)) ? "integer" : "number";
|
|
533
|
-
}
|
|
534
|
-
if (values.every((value) => typeof value === "boolean")) return "boolean";
|
|
535
|
-
if (values.every((value) => typeof value === "string")) return "string";
|
|
536
|
-
return void 0;
|
|
537
|
-
};
|
|
538
|
-
const candidateTypes = (branch, active = /* @__PURE__ */ new Set()) => {
|
|
539
|
-
if (active.has(branch)) return [];
|
|
540
|
-
active.add(branch);
|
|
541
|
-
const nested = [branch.oneOf, branch.anyOf].flatMap((value) => Array.isArray(value) ? value : []);
|
|
542
|
-
const type = inferType(branch);
|
|
543
|
-
const types = [
|
|
544
|
-
...type && type !== "null" ? [type] : [],
|
|
545
|
-
...nested.flatMap((value) => value && typeof value === "object" ? candidateTypes(value, active) : [])
|
|
546
|
-
];
|
|
547
|
-
active.delete(branch);
|
|
548
|
-
return types;
|
|
549
|
-
};
|
|
550
|
-
const unconstrainedBranch = branches.some(
|
|
551
|
-
(branch) => branch.type === void 0 && rawEnumValues(branch) === void 0 && branch.properties === void 0 && branch.oneOf === void 0 && branch.anyOf === void 0 && branch.allOf === void 0 && branch.$ref === void 0
|
|
552
|
-
);
|
|
553
|
-
if (sanitizedBranches.every(
|
|
554
|
-
(branch) => branch.properties === void 0 && branch.required === void 0
|
|
555
|
-
)) {
|
|
556
|
-
const types = [...new Set(branches.flatMap((branch) => candidateTypes(branch)))];
|
|
557
|
-
const first = sanitizedBranches[0] ?? {};
|
|
558
|
-
const baseDescription = typeof out.description === "string" ? out.description : typeof branches[0]?.description === "string" ? branches[0].description : void 0;
|
|
559
|
-
const scalar = {
|
|
560
|
-
...first,
|
|
561
|
-
type: types.length > 0 && types.every((type) => type === "integer" || type === "number") ? types.includes("number") ? "number" : "integer" : types[0] ?? "string",
|
|
562
|
-
...out
|
|
563
|
-
};
|
|
564
|
-
delete scalar.description;
|
|
565
|
-
if (baseDescription !== void 0) scalar.description = baseDescription;
|
|
566
|
-
if (!enumValues) {
|
|
567
|
-
delete scalar.enum;
|
|
568
|
-
const values = branches.flatMap(
|
|
569
|
-
(branch, index) => rawEnumValues(branch) ?? enumMetaOf(sanitizedBranches[index])?.values ?? []
|
|
570
|
-
);
|
|
571
|
-
const allEnum = branches.length > 0 && branches.every(
|
|
572
|
-
(branch, index) => rawEnumValues(branch) !== void 0 || enumMetaOf(sanitizedBranches[index]) !== void 0
|
|
573
|
-
);
|
|
574
|
-
if (values.length > 0) {
|
|
575
|
-
if (allEnum) {
|
|
576
|
-
if (typeof out.type !== "string") {
|
|
577
|
-
scalar.type = inferType({ enum: values }) ?? "string";
|
|
578
|
-
}
|
|
579
|
-
applyGeminiEnum(scalar, geminiEnumFields(values, baseDescription));
|
|
580
|
-
enumMetaByNode.set(out, { values, baseDescription });
|
|
581
|
-
} else {
|
|
582
|
-
scalar.description = [
|
|
583
|
-
baseDescription,
|
|
584
|
-
`Candidates: ${[...new Set(values.map(geminiEnumLiteral))].join(", ")}`
|
|
585
|
-
].filter(Boolean).join("\n");
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
const conflictingRanges = [];
|
|
590
|
-
for (const key of ["minimum", "maximum", "minLength", "maxLength"]) {
|
|
591
|
-
if (typeof src[key] === "number") {
|
|
592
|
-
scalar[key] = src[key];
|
|
593
|
-
continue;
|
|
594
|
-
}
|
|
595
|
-
const values = branches.map((branch) => branch[key]).filter((value) => typeof value === "number");
|
|
596
|
-
if (values.length !== branches.length || new Set(values).size > 1) {
|
|
597
|
-
delete scalar[key];
|
|
598
|
-
if (values.length > 0 && conflictingRanges.length === 0) {
|
|
599
|
-
conflictingRanges.push(...branches.map((branch) => Object.fromEntries(
|
|
600
|
-
["minimum", "maximum", "minLength", "maxLength"].flatMap(
|
|
601
|
-
(name) => typeof branch[name] === "number" ? [[name, branch[name]]] : []
|
|
602
|
-
)
|
|
603
|
-
)));
|
|
604
|
-
}
|
|
605
|
-
} else if (values.length > 0) scalar[key] = values[0];
|
|
606
|
-
}
|
|
607
|
-
if (conflictingRanges.length > 0) {
|
|
608
|
-
scalar.description = [
|
|
609
|
-
scalar.description,
|
|
610
|
-
`Original ranges: ${conflictingRanges.map((range) => JSON.stringify(range)).join(" | ")}`
|
|
611
|
-
].filter(Boolean).join("\n");
|
|
612
|
-
}
|
|
613
|
-
const stableValue = (value) => {
|
|
614
|
-
if (Array.isArray(value)) return value.map(stableValue);
|
|
615
|
-
if (value && typeof value === "object") return Object.fromEntries(
|
|
616
|
-
Object.keys(value).sort().map((key) => [key, stableValue(value[key])])
|
|
617
|
-
);
|
|
618
|
-
return value;
|
|
619
|
-
};
|
|
620
|
-
if (src.items === void 0 && branches.some((branch) => branch.items !== void 0)) {
|
|
621
|
-
const firstItems = branches[0]?.items;
|
|
622
|
-
const sameItems = firstItems !== void 0 && branches.every(
|
|
623
|
-
(branch) => branch.items !== void 0 && JSON.stringify(stableValue(branch.items)) === JSON.stringify(stableValue(firstItems))
|
|
624
|
-
);
|
|
625
|
-
if (!sameItems) {
|
|
626
|
-
const itemTypes = branches.map((branch) => {
|
|
627
|
-
const items = branch.items;
|
|
628
|
-
return items && typeof items === "object" && !Array.isArray(items) ? items.type : void 0;
|
|
629
|
-
});
|
|
630
|
-
const commonType = itemTypes[0];
|
|
631
|
-
const fallbackType = typeof commonType === "string" && ["string", "integer", "number", "boolean", "object", "array"].includes(commonType) && itemTypes.every((type) => type === commonType) ? commonType : "string";
|
|
632
|
-
scalar.items = fallbackType === "array" ? { type: "array", items: { type: "string" } } : { type: fallbackType };
|
|
633
|
-
scalar.description = [
|
|
634
|
-
scalar.description,
|
|
635
|
-
`Original items: ${branches.map((branch) => branch.items === void 0 ? "unconstrained" : geminiEnumLiteral(branch.items)).join(" | ")}`
|
|
636
|
-
].filter(Boolean).join("\n");
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
const originalConstraints = branches.map((branch) => Object.fromEntries(
|
|
640
|
-
["pattern", "format"].flatMap((key) => branch[key] !== void 0 ? [[key, branch[key]]] : [])
|
|
641
|
-
));
|
|
642
|
-
if (originalConstraints.some((constraints) => Object.keys(constraints).length > 0)) {
|
|
643
|
-
scalar.description = [
|
|
644
|
-
scalar.description,
|
|
645
|
-
`Original constraints: ${originalConstraints.map((value) => JSON.stringify(value)).join(" | ")}`
|
|
646
|
-
].filter(Boolean).join("\n");
|
|
647
|
-
}
|
|
648
|
-
for (let index = 0; index < branches.length; index++) {
|
|
649
|
-
if ((branches[index].oneOf || branches[index].anyOf) && sanitizedBranches[index].description) {
|
|
650
|
-
scalar.description = [
|
|
651
|
-
scalar.description,
|
|
652
|
-
`Branch ${index + 1}: ${sanitizedBranches[index].description}`
|
|
653
|
-
].filter(Boolean).join("\n");
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
if (types.length > 1) {
|
|
657
|
-
scalar.description = [scalar.description, `One of: ${types.join(" | ")}`].filter(Boolean).join("\n");
|
|
658
|
-
}
|
|
659
|
-
if (branches.length === 0) {
|
|
660
|
-
scalar.description = [scalar.description, "null only"].filter(Boolean).join("\n");
|
|
661
|
-
} else if (branches.some((branch) => inferType(branch) === void 0 && rawEnumValues(branch)?.some((value) => value !== null))) {
|
|
662
|
-
scalar.description = [scalar.description, "Mixed enum types; using a fallback type"].filter(Boolean).join("\n");
|
|
663
|
-
}
|
|
664
|
-
Object.assign(out, scalar);
|
|
665
|
-
} else {
|
|
666
|
-
const mergedProperties = {};
|
|
667
|
-
let requiredIntersection;
|
|
668
|
-
for (const sanitized of sanitizedBranches) {
|
|
669
|
-
const branchProperties = sanitized.properties ?? {};
|
|
670
|
-
for (const [key, value] of Object.entries(branchProperties)) {
|
|
671
|
-
const previous = mergedProperties[key];
|
|
672
|
-
const prevMeta = enumMetaOf(previous);
|
|
673
|
-
const nextMeta = enumMetaOf(value);
|
|
674
|
-
if (prevMeta && nextMeta) {
|
|
675
|
-
const values = [...prevMeta.values, ...nextMeta.values];
|
|
676
|
-
const baseDescription = nextMeta.baseDescription ?? prevMeta.baseDescription;
|
|
677
|
-
const node = {
|
|
678
|
-
...value
|
|
679
|
-
};
|
|
680
|
-
delete node.enum;
|
|
681
|
-
delete node.description;
|
|
682
|
-
applyGeminiEnum(node, geminiEnumFields(values, baseDescription));
|
|
683
|
-
enumMetaByNode.set(node, { values, baseDescription });
|
|
684
|
-
mergedProperties[key] = node;
|
|
685
|
-
} else {
|
|
686
|
-
mergedProperties[key] = value;
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
const branchRequired = Array.isArray(sanitized.required) ? sanitized.required : [];
|
|
690
|
-
requiredIntersection = requiredIntersection === void 0 ? [...branchRequired] : requiredIntersection.filter((r) => branchRequired.includes(r));
|
|
691
|
-
}
|
|
692
|
-
const combinedProperties = {
|
|
693
|
-
...out.properties ?? {},
|
|
694
|
-
...mergedProperties
|
|
695
|
-
};
|
|
696
|
-
out.properties = Object.fromEntries(
|
|
697
|
-
Object.keys(combinedProperties).sort().map((key) => [key, combinedProperties[key]])
|
|
698
|
-
);
|
|
699
|
-
if (requiredIntersection !== void 0 && requiredIntersection.length > 0) {
|
|
700
|
-
out.required = requiredIntersection;
|
|
701
|
-
}
|
|
702
|
-
if (typeof out.type !== "string") out.type = "object";
|
|
703
|
-
if (sanitizedBranches.some((branch) => branch.properties === void 0)) {
|
|
704
|
-
const types = [...new Set(branches.flatMap(
|
|
705
|
-
(branch) => branch.properties !== void 0 ? ["object"] : candidateTypes(branch)
|
|
706
|
-
))].sort();
|
|
707
|
-
if (rawBranches.some((branch) => branch.type === "null")) types.push("null");
|
|
708
|
-
out.description = [
|
|
709
|
-
out.description,
|
|
710
|
-
`One of: ${types.join(" | ")}. This declaration represents only one branch of the union; other candidates are not structurally represented.`
|
|
711
|
-
].filter(Boolean).join("\n");
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
if (unconstrainedBranch) {
|
|
715
|
-
out.description = [
|
|
716
|
-
out.description,
|
|
717
|
-
"An unconstrained branch accepts any JSON value (any value, including null). This declaration uses a fallback type and cannot express the full union."
|
|
718
|
-
].filter(Boolean).join("\n");
|
|
719
|
-
if (src.type === void 0) out.nullable = true;
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
if (Array.isArray(src.allOf)) {
|
|
723
|
-
for (const branch of src.allOf) {
|
|
724
|
-
const sanitized = sanitizeGeminiSchemaNode(branch, seen);
|
|
725
|
-
if (out.type === void 0 || out.type === "object" || out.properties || sanitized.properties) {
|
|
726
|
-
const merged = {
|
|
727
|
-
...out.properties ?? {},
|
|
728
|
-
...sanitized.properties ?? {}
|
|
729
|
-
};
|
|
730
|
-
out.properties = Object.fromEntries(
|
|
731
|
-
Object.keys(merged).sort().map((key) => [key, merged[key]])
|
|
732
|
-
);
|
|
733
|
-
}
|
|
734
|
-
if (Array.isArray(sanitized.required)) {
|
|
735
|
-
out.required = [
|
|
736
|
-
.../* @__PURE__ */ new Set([
|
|
737
|
-
...out.required ?? [],
|
|
738
|
-
...sanitized.required ?? []
|
|
739
|
-
])
|
|
740
|
-
];
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
if (typeof out.type !== "string") out.type = "object";
|
|
744
|
-
}
|
|
745
|
-
if (src.properties && typeof src.properties === "object") {
|
|
746
|
-
const rawProperties = src.properties;
|
|
747
|
-
const properties = {};
|
|
748
|
-
for (const key of Object.keys(rawProperties).sort()) {
|
|
749
|
-
properties[key] = sanitizeGeminiSchemaNode(rawProperties[key], seen);
|
|
750
|
-
}
|
|
751
|
-
out.properties = properties;
|
|
752
|
-
if (typeof out.type !== "string") out.type = "object";
|
|
753
|
-
}
|
|
754
|
-
if (Array.isArray(src.required)) {
|
|
755
|
-
const properties = out.properties ?? {};
|
|
756
|
-
const required = [...new Set(src.required)].filter(
|
|
757
|
-
(r) => typeof r === "string" && r in properties
|
|
758
|
-
);
|
|
759
|
-
if (required.length > 0) out.required = required;
|
|
760
|
-
}
|
|
761
|
-
if (src.items !== void 0) {
|
|
762
|
-
out.items = sanitizeGeminiSchemaNode(src.items, seen);
|
|
763
|
-
if (typeof out.type !== "string") out.type = "array";
|
|
764
|
-
}
|
|
765
|
-
if (typeof out.type !== "string") out.type = "object";
|
|
766
|
-
if (out.type === "array" && !out.items) out.items = { type: "string" };
|
|
767
|
-
if (out.type !== "object" && !out.properties) {
|
|
768
|
-
const dropped = Object.fromEntries(["minLength", "maxLength", "pattern", "format"].flatMap(
|
|
769
|
-
(key) => src[key] !== void 0 && out[key] === void 0 ? [[key, src[key]]] : []
|
|
770
|
-
));
|
|
771
|
-
if (Object.keys(dropped).length > 0) out.description = [
|
|
772
|
-
out.description,
|
|
773
|
-
`Original constraints: ${JSON.stringify(dropped)}`
|
|
774
|
-
].filter(Boolean).join("\n");
|
|
775
|
-
}
|
|
776
|
-
return out;
|
|
777
|
-
}
|
|
778
|
-
function convertOpenAiToolsToGemini(tools) {
|
|
779
|
-
if (!Array.isArray(tools) || tools.length === 0) return void 0;
|
|
780
|
-
const declarations = [];
|
|
781
|
-
for (const tool of tools) {
|
|
782
|
-
if (!tool || typeof tool !== "object" || !("function" in tool)) continue;
|
|
783
|
-
const fn = tool.function;
|
|
784
|
-
const name = typeof fn.name === "string" ? fn.name : "";
|
|
785
|
-
if (!name) continue;
|
|
786
|
-
declarations.push({
|
|
787
|
-
name,
|
|
788
|
-
description: typeof fn.description === "string" ? fn.description : "",
|
|
789
|
-
parameters: sanitizeGeminiSchemaNode(
|
|
790
|
-
fn.parameters ?? { type: "object", properties: {} }
|
|
791
|
-
)
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
if (declarations.length === 0) return void 0;
|
|
795
|
-
declarations.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
796
|
-
return [{ functionDeclarations: declarations }];
|
|
797
|
-
}
|
|
798
|
-
function createGeminiAccumulatorState() {
|
|
799
|
-
return {
|
|
800
|
-
text: "",
|
|
801
|
-
toolCalls: [],
|
|
802
|
-
reasoning: "",
|
|
803
|
-
events: []
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
function applyGeminiChunk(chunk, state, options) {
|
|
807
|
-
if (!chunk || typeof chunk !== "object") return;
|
|
808
|
-
const response = "response" in chunk && chunk.response && typeof chunk.response === "object" ? chunk.response : chunk;
|
|
809
|
-
if ("usageMetadata" in response && response.usageMetadata && typeof response.usageMetadata === "object") {
|
|
810
|
-
const meta = response.usageMetadata;
|
|
811
|
-
const hasPromptTokenCount = typeof meta.promptTokenCount === "number" && Number.isFinite(meta.promptTokenCount);
|
|
812
|
-
const hasCachedContentTokenCount = typeof meta.cachedContentTokenCount === "number" && Number.isFinite(meta.cachedContentTokenCount);
|
|
813
|
-
const prompt = hasPromptTokenCount ? meta.promptTokenCount : 0;
|
|
814
|
-
const candidates2 = typeof meta.candidatesTokenCount === "number" ? meta.candidatesTokenCount : 0;
|
|
815
|
-
const total = typeof meta.totalTokenCount === "number" ? meta.totalTokenCount : prompt + candidates2;
|
|
816
|
-
const clampedPrompt = Math.max(0, Math.floor(prompt));
|
|
817
|
-
const cached = hasCachedContentTokenCount ? (
|
|
818
|
-
// cached ⊆ prompt;对畸形上游防御性钳位,避免 cache_read > input 破坏归一化与计费
|
|
819
|
-
Math.min(
|
|
820
|
-
Math.max(0, Math.floor(meta.cachedContentTokenCount)),
|
|
821
|
-
clampedPrompt
|
|
822
|
-
)
|
|
823
|
-
) : 0;
|
|
824
|
-
const thoughts = typeof meta.thoughtsTokenCount === "number" ? meta.thoughtsTokenCount : Array.isArray(meta.candidatesTokensDetails) && typeof meta.candidatesTokensDetails[0]?.tokensCount === "number" ? meta.candidatesTokensDetails[0].tokensCount : void 0;
|
|
825
|
-
state.usage = {
|
|
826
|
-
prompt_tokens: prompt,
|
|
827
|
-
completion_tokens: candidates2,
|
|
828
|
-
total_tokens: total,
|
|
829
|
-
...hasPromptTokenCount || hasCachedContentTokenCount ? { cache_read_input_tokens: cached } : {},
|
|
830
|
-
...thoughts !== void 0 ? {
|
|
831
|
-
completion_tokens_details: {
|
|
832
|
-
reasoning_tokens: thoughts
|
|
833
|
-
}
|
|
834
|
-
} : {}
|
|
835
|
-
};
|
|
836
|
-
state.events.push({ kind: "usage", usage: state.usage });
|
|
837
|
-
}
|
|
838
|
-
const candidates = Array.isArray(response.candidates) ? response.candidates : [];
|
|
839
|
-
for (const candidate of candidates) {
|
|
840
|
-
if (!candidate || typeof candidate !== "object") continue;
|
|
841
|
-
const candidateFinishReason = candidate.finishReason;
|
|
842
|
-
if (typeof candidateFinishReason === "string" && candidateFinishReason.trim()) {
|
|
843
|
-
state.finishReason = candidateFinishReason.trim();
|
|
844
|
-
state.events.push({ kind: "finish", reason: state.finishReason });
|
|
845
|
-
}
|
|
846
|
-
const parts = Array.isArray(
|
|
847
|
-
candidate.content?.parts
|
|
848
|
-
) ? candidate.content.parts : [];
|
|
849
|
-
for (const part of parts) {
|
|
850
|
-
if (!part || typeof part !== "object") continue;
|
|
851
|
-
const partSignature = part.thoughtSignature;
|
|
852
|
-
const isThought = Boolean(part.thought);
|
|
853
|
-
if ("text" in part && typeof part.text === "string") {
|
|
854
|
-
const piece = part.text;
|
|
855
|
-
if (!isThought) {
|
|
856
|
-
state.text += piece;
|
|
857
|
-
if (piece) {
|
|
858
|
-
state.events.push({ kind: "text", text: piece });
|
|
859
|
-
if (options?.onTextDelta) options.onTextDelta(piece);
|
|
860
|
-
}
|
|
861
|
-
} else {
|
|
862
|
-
state.reasoning += piece;
|
|
863
|
-
if (piece) {
|
|
864
|
-
state.events.push({ kind: "reasoning", text: piece });
|
|
865
|
-
if (options?.onReasoningDelta) options.onReasoningDelta(piece);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
if (isThought && typeof partSignature === "string" && partSignature) {
|
|
870
|
-
state.pendingThoughtSignature = partSignature;
|
|
871
|
-
}
|
|
872
|
-
if ("functionCall" in part && part.functionCall) {
|
|
873
|
-
const call = part.functionCall;
|
|
874
|
-
const name = typeof call.name === "string" ? call.name : "tool";
|
|
875
|
-
const id = typeof call.id === "string" ? call.id : `${name}_${state.toolCalls.length}`;
|
|
876
|
-
const argsObj = call.args && typeof call.args === "object" ? call.args : {};
|
|
877
|
-
const resolvedSignature = typeof partSignature === "string" && partSignature ? partSignature : state.pendingThoughtSignature;
|
|
878
|
-
state.pendingThoughtSignature = void 0;
|
|
879
|
-
const toolCall = {
|
|
880
|
-
id,
|
|
881
|
-
type: "function",
|
|
882
|
-
function: { name, arguments: JSON.stringify(argsObj) },
|
|
883
|
-
...typeof resolvedSignature === "string" && resolvedSignature ? { thought_signature: resolvedSignature } : {}
|
|
884
|
-
};
|
|
885
|
-
state.toolCalls.push(toolCall);
|
|
886
|
-
state.events.push({ kind: "tool_call", toolCall });
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
function accumulateGeminiChunks(chunks, options) {
|
|
892
|
-
const state = createGeminiAccumulatorState();
|
|
893
|
-
for (const chunk of chunks) {
|
|
894
|
-
applyGeminiChunk(chunk, state, options);
|
|
895
|
-
}
|
|
896
|
-
return {
|
|
897
|
-
text: state.text,
|
|
898
|
-
toolCalls: state.toolCalls,
|
|
899
|
-
usage: state.usage,
|
|
900
|
-
finishReason: state.finishReason,
|
|
901
|
-
reasoningContent: state.reasoning,
|
|
902
|
-
events: state.events
|
|
903
|
-
};
|
|
904
|
-
}
|
|
905
|
-
async function accumulateGeminiStream(stream, options) {
|
|
906
|
-
const state = createGeminiAccumulatorState();
|
|
907
|
-
for await (const chunk of stream) {
|
|
908
|
-
applyGeminiChunk(chunk, state, options);
|
|
909
|
-
}
|
|
910
|
-
return {
|
|
911
|
-
text: state.text,
|
|
912
|
-
toolCalls: state.toolCalls,
|
|
913
|
-
usage: state.usage,
|
|
914
|
-
finishReason: state.finishReason,
|
|
915
|
-
reasoningContent: state.reasoning,
|
|
916
|
-
events: state.events
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
function shouldUseGeminiNativeToolRoute(provider, model, tools, isImageModel) {
|
|
920
|
-
return provider === "google" && !isImageModel(model) && isGemini3Model(model) && Array.isArray(tools) && tools.length > 0;
|
|
921
|
-
}
|
|
922
|
-
function buildGeminiGenerateContentRequest(args) {
|
|
923
|
-
const toolImagePolicy = resolveToolImagePolicy(args.toolImagePolicy ?? {
|
|
924
|
-
routeKind: "gemini-native",
|
|
925
|
-
hasVision: args.supportsToolImages,
|
|
926
|
-
legacySupportsToolImages: args.supportsToolImages ?? false
|
|
927
|
-
});
|
|
928
|
-
const { contents, systemTexts } = convertOpenAiMessagesToGemini(
|
|
929
|
-
args.messages,
|
|
930
|
-
{
|
|
931
|
-
attachSkipThoughtSignature: args.attachSkipThoughtSignature,
|
|
932
|
-
supportsToolImages: toolImagePolicy.supportsToolImages,
|
|
933
|
-
maxImagesPerRequest: toolImagePolicy.maxImagesPerRequest
|
|
934
|
-
}
|
|
935
|
-
);
|
|
936
|
-
const request = {};
|
|
937
|
-
if (systemTexts.length > 0) {
|
|
938
|
-
request.systemInstruction = {
|
|
939
|
-
role: "user",
|
|
940
|
-
parts: systemTexts.map((text) => ({ text }))
|
|
941
|
-
};
|
|
942
|
-
}
|
|
943
|
-
const toolsResult = convertOpenAiToolsToGemini(args.tools);
|
|
944
|
-
if (toolsResult) {
|
|
945
|
-
request.tools = toolsResult;
|
|
946
|
-
request.toolConfig = { functionCallingConfig: { mode: "AUTO" } };
|
|
947
|
-
}
|
|
948
|
-
request.contents = contents;
|
|
949
|
-
const generationConfig = {};
|
|
950
|
-
if (typeof args.maxTokens === "number" && args.maxTokens > 0) {
|
|
951
|
-
generationConfig.maxOutputTokens = args.maxTokens;
|
|
952
|
-
}
|
|
953
|
-
if (typeof args.temperature === "number") {
|
|
954
|
-
generationConfig.temperature = args.temperature;
|
|
955
|
-
}
|
|
956
|
-
if (Object.keys(generationConfig).length > 0) {
|
|
957
|
-
request.generationConfig = generationConfig;
|
|
958
|
-
}
|
|
959
|
-
return request;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
// packages/agent-runtime/antigravityCloudCodeProvider.ts
|
|
963
|
-
var STREAM_PATH = "/v1internal:streamGenerateContent?alt=sse";
|
|
964
|
-
function firstUserText(messages) {
|
|
965
|
-
for (const raw of messages) {
|
|
966
|
-
if (!raw || typeof raw !== "object") continue;
|
|
967
|
-
const message = raw;
|
|
968
|
-
if (message.role !== "user") continue;
|
|
969
|
-
const content = message.content;
|
|
970
|
-
if (typeof content === "string") return content.trim();
|
|
971
|
-
if (Array.isArray(content)) {
|
|
972
|
-
return content.map(
|
|
973
|
-
(part) => part && typeof part === "object" && typeof part.text === "string" ? part.text : ""
|
|
974
|
-
).join("").trim();
|
|
975
|
-
}
|
|
976
|
-
return "";
|
|
977
|
-
}
|
|
978
|
-
return "";
|
|
979
|
-
}
|
|
980
|
-
var ANTIGRAVITY_SESSION_SALT = "nolo.antigravity.session.v1";
|
|
981
|
-
function antigravitySessionIdFor(messages) {
|
|
982
|
-
const seed = firstUserText(messages);
|
|
983
|
-
if (!seed) return `-${Math.floor(Math.random() * 9e15)}`;
|
|
984
|
-
const digest = createHash("sha256").update(ANTIGRAVITY_SESSION_SALT).update("\0").update(seed).digest();
|
|
985
|
-
return `-${digest.readUIntBE(0, 6)}`;
|
|
986
|
-
}
|
|
987
|
-
function buildCloudCodeAssistPayload(args) {
|
|
988
|
-
const projectId = readAntigravityProjectId(args.metadata);
|
|
989
|
-
if (!projectId) {
|
|
990
|
-
throw new Error(
|
|
991
|
-
"Antigravity OAuth credential is missing metadata.projectId. Re-run `nolo auth antigravity`."
|
|
992
|
-
);
|
|
993
|
-
}
|
|
994
|
-
const logicalModel = asOptionalTrimmedString(args.openAiBody.model) ?? asOptionalTrimmedString(args.agentConfig.model) ?? "gemini-3.1-pro";
|
|
995
|
-
const { wireModelId: model, profile } = resolveAntigravityWireModel(
|
|
996
|
-
logicalModel,
|
|
997
|
-
asOptionalTrimmedString(args.openAiBody.reasoning_effort) ?? args.agentConfig.reasoning_effort
|
|
998
|
-
);
|
|
999
|
-
const rawMessages = Array.isArray(args.openAiBody.messages) ? args.openAiBody.messages : [];
|
|
1000
|
-
const quirks = resolveGeminiModelQuirks(model);
|
|
1001
|
-
const isClaude = quirks.isClaudeCrossModel;
|
|
1002
|
-
const toolImagePolicy = resolveToolImagePolicy({
|
|
1003
|
-
...args.agentConfig,
|
|
1004
|
-
routeKind: "antigravity",
|
|
1005
|
-
model,
|
|
1006
|
-
hasVision: args.agentConfig.hasVision
|
|
1007
|
-
});
|
|
1008
|
-
const { contents, systemTexts } = convertOpenAiMessagesToGemini(rawMessages, {
|
|
1009
|
-
attachSkipThoughtSignature: quirks.allowsThoughtSignatureSentinel,
|
|
1010
|
-
...toolImagePolicy
|
|
1011
|
-
});
|
|
1012
|
-
if (contents.length === 0) {
|
|
1013
|
-
throw new Error("Antigravity Cloud Code Assist request has no user/model contents.");
|
|
1014
|
-
}
|
|
1015
|
-
const prompt = args.agentConfig.prompt?.trim();
|
|
1016
|
-
if (prompt && !hasAssembledAgentPrompt(rawMessages)) systemTexts.unshift(prompt);
|
|
1017
|
-
const request = {};
|
|
1018
|
-
if (systemTexts.length > 0) {
|
|
1019
|
-
request.systemInstruction = {
|
|
1020
|
-
role: "user",
|
|
1021
|
-
parts: systemTexts.map((text) => ({ text }))
|
|
1022
|
-
};
|
|
1023
|
-
}
|
|
1024
|
-
const tools = convertOpenAiToolsToGemini(
|
|
1025
|
-
Array.isArray(args.openAiBody.tools) ? args.openAiBody.tools : void 0
|
|
1026
|
-
);
|
|
1027
|
-
if (tools) {
|
|
1028
|
-
request.tools = tools;
|
|
1029
|
-
request.toolConfig = { functionCallingConfig: { mode: "AUTO" } };
|
|
1030
|
-
}
|
|
1031
|
-
request.contents = contents;
|
|
1032
|
-
const generationConfig = {};
|
|
1033
|
-
if (profile?.maxOutputTokens) {
|
|
1034
|
-
generationConfig.maxOutputTokens = profile.maxOutputTokens;
|
|
1035
|
-
} else if (typeof args.agentConfig.max_tokens === "number" && args.agentConfig.max_tokens > 0) {
|
|
1036
|
-
generationConfig.maxOutputTokens = args.agentConfig.max_tokens;
|
|
1037
|
-
}
|
|
1038
|
-
if (typeof args.agentConfig.temperature === "number") {
|
|
1039
|
-
generationConfig.temperature = args.agentConfig.temperature;
|
|
1040
|
-
}
|
|
1041
|
-
if (Object.keys(generationConfig).length > 0) {
|
|
1042
|
-
request.generationConfig = generationConfig;
|
|
1043
|
-
}
|
|
1044
|
-
const agentId = randomUUID();
|
|
1045
|
-
const trajectoryId = randomUUID();
|
|
1046
|
-
const step = 2;
|
|
1047
|
-
const requestId = `agent/${agentId}/${Date.now()}/${trajectoryId}/${step}`;
|
|
1048
|
-
const labels = {
|
|
1049
|
-
trajectory_id: trajectoryId,
|
|
1050
|
-
last_step_index: String(step - 1),
|
|
1051
|
-
used_claude: String(isClaude),
|
|
1052
|
-
used_claude_conservative: String(isClaude)
|
|
1053
|
-
};
|
|
1054
|
-
if (profile?.modelEnum) {
|
|
1055
|
-
labels.model_enum = profile.modelEnum;
|
|
1056
|
-
}
|
|
1057
|
-
request.labels = labels;
|
|
1058
|
-
request.sessionId = antigravitySessionIdFor(rawMessages);
|
|
1059
|
-
return {
|
|
1060
|
-
url: `${resolveAntigravityCloudCodeBaseUrl(args.agentConfig.customProviderUrl)}${STREAM_PATH}`,
|
|
1061
|
-
envelope: {
|
|
1062
|
-
project: projectId,
|
|
1063
|
-
model,
|
|
1064
|
-
request,
|
|
1065
|
-
requestId,
|
|
1066
|
-
requestType: "agent",
|
|
1067
|
-
userAgent: "antigravity"
|
|
1068
|
-
}
|
|
1069
|
-
};
|
|
1070
|
-
}
|
|
1071
|
-
function resolveAntigravityFinishReason(upstream) {
|
|
1072
|
-
const normalized = (upstream ?? "").trim().toUpperCase();
|
|
1073
|
-
if (normalized === "MAX_TOKENS") return "length";
|
|
1074
|
-
if (normalized === "SAFETY" || normalized === "RECITATION" || normalized === "PROHIBITED_CONTENT" || normalized === "BLOCKLIST") {
|
|
1075
|
-
return "content_filter";
|
|
1076
|
-
}
|
|
1077
|
-
return "stop";
|
|
1078
|
-
}
|
|
1079
|
-
function normalizeAntigravityCompletion(decoded) {
|
|
1080
|
-
const { text, toolCalls, usage, finishReason, reasoningContent, events } = decoded;
|
|
1081
|
-
const normalizedFinishReason = (finishReason ?? "").trim().toUpperCase();
|
|
1082
|
-
if (!text && !reasoningContent && toolCalls.length === 0 && !finishReason && !usage) {
|
|
1083
|
-
const body = {
|
|
1084
|
-
error: {
|
|
1085
|
-
message: "antigravity upstream returned an empty stream (no content, finishReason or usage); channel degradation, not model emptiness"
|
|
1086
|
-
},
|
|
1087
|
-
provider_events: events
|
|
1088
|
-
};
|
|
1089
|
-
return {
|
|
1090
|
-
status: 502,
|
|
1091
|
-
text: "",
|
|
1092
|
-
toolCalls: [],
|
|
1093
|
-
providerEvents: events,
|
|
1094
|
-
body
|
|
1095
|
-
};
|
|
1096
|
-
}
|
|
1097
|
-
if (normalizedFinishReason === "MALFORMED_FUNCTION_CALL") {
|
|
1098
|
-
const message2 = "antigravity upstream returned MALFORMED_FUNCTION_CALL (model generated an invalid function call or tool arguments were rejected by upstream)";
|
|
1099
|
-
const providerFailure = {
|
|
1100
|
-
kind: "provider_failure",
|
|
1101
|
-
provider: "antigravity",
|
|
1102
|
-
code: "MALFORMED_FUNCTION_CALL",
|
|
1103
|
-
message: message2,
|
|
1104
|
-
providerReason: "MALFORMED_FUNCTION_CALL",
|
|
1105
|
-
retryable: false,
|
|
1106
|
-
status: 502
|
|
1107
|
-
};
|
|
1108
|
-
return {
|
|
1109
|
-
status: 502,
|
|
1110
|
-
text: "",
|
|
1111
|
-
toolCalls: [],
|
|
1112
|
-
finishReason,
|
|
1113
|
-
providerEvents: events,
|
|
1114
|
-
providerFailure,
|
|
1115
|
-
runtimeProviderFailure: {
|
|
1116
|
-
message: providerFailure.message,
|
|
1117
|
-
retryable: providerFailure.retryable
|
|
1118
|
-
},
|
|
1119
|
-
body: {
|
|
1120
|
-
error: {
|
|
1121
|
-
message: message2,
|
|
1122
|
-
code: "MALFORMED_FUNCTION_CALL",
|
|
1123
|
-
category: "malformed_function_call",
|
|
1124
|
-
providerReason: "MALFORMED_FUNCTION_CALL",
|
|
1125
|
-
retryable: false
|
|
1126
|
-
},
|
|
1127
|
-
provider_failure: providerFailure,
|
|
1128
|
-
provider_events: events
|
|
1129
|
-
}
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
1132
|
-
const message = {
|
|
1133
|
-
role: "assistant",
|
|
1134
|
-
content: text || null
|
|
1135
|
-
};
|
|
1136
|
-
if (toolCalls.length > 0) message.tool_calls = toolCalls;
|
|
1137
|
-
if (reasoningContent) message.reasoning_content = reasoningContent;
|
|
1138
|
-
return {
|
|
1139
|
-
status: 200,
|
|
1140
|
-
text,
|
|
1141
|
-
...reasoningContent ? { reasoningContent } : {},
|
|
1142
|
-
toolCalls,
|
|
1143
|
-
...usage ? { usage } : {},
|
|
1144
|
-
...finishReason ? { finishReason } : {},
|
|
1145
|
-
providerEvents: events,
|
|
1146
|
-
body: {
|
|
1147
|
-
choices: [{
|
|
1148
|
-
index: 0,
|
|
1149
|
-
message,
|
|
1150
|
-
finish_reason: toolCalls.length > 0 ? "tool_calls" : resolveAntigravityFinishReason(finishReason)
|
|
1151
|
-
}],
|
|
1152
|
-
...usage ? { usage } : {},
|
|
1153
|
-
provider_events: events
|
|
1154
|
-
}
|
|
1155
|
-
};
|
|
1156
|
-
}
|
|
1157
|
-
async function fetchAntigravityCloudCodeCompletion(args) {
|
|
1158
|
-
const fetchImpl = args.fetchImpl ?? fetch;
|
|
1159
|
-
const { url, envelope } = buildCloudCodeAssistPayload(args);
|
|
1160
|
-
const response = await fetchImpl(url, {
|
|
1161
|
-
method: "POST",
|
|
1162
|
-
headers: {
|
|
1163
|
-
Authorization: `Bearer ${args.accessToken}`,
|
|
1164
|
-
"Content-Type": "application/json",
|
|
1165
|
-
"User-Agent": getAntigravityUserAgent()
|
|
1166
|
-
},
|
|
1167
|
-
body: JSON.stringify(envelope),
|
|
1168
|
-
signal: args.signal
|
|
1169
|
-
});
|
|
1170
|
-
if (!response.ok) {
|
|
1171
|
-
const errorText = await response.text();
|
|
1172
|
-
return {
|
|
1173
|
-
status: response.status,
|
|
1174
|
-
text: "",
|
|
1175
|
-
toolCalls: [],
|
|
1176
|
-
providerEvents: [],
|
|
1177
|
-
// 保留上游结构:Antigravity 的限流 body 同样携带结构化的重置信息,
|
|
1178
|
-
// 压成字符串会让冷却退化成 5 分钟默认值。
|
|
1179
|
-
body: parseUpstreamErrorBody(errorText, response.statusText)
|
|
1180
|
-
};
|
|
1181
|
-
}
|
|
1182
|
-
const chunkStream = streamSseDataValues(response, parseSseDataLineJson);
|
|
1183
|
-
const { text, toolCalls, usage, finishReason, reasoningContent, events } = await accumulateGeminiStream(chunkStream, {
|
|
1184
|
-
onTextDelta: args.onTextDelta,
|
|
1185
|
-
onReasoningDelta: args.onReasoningDelta
|
|
1186
|
-
});
|
|
1187
|
-
const normalized = normalizeAntigravityCompletion({
|
|
1188
|
-
text,
|
|
1189
|
-
toolCalls,
|
|
1190
|
-
usage,
|
|
1191
|
-
finishReason,
|
|
1192
|
-
reasoningContent,
|
|
1193
|
-
events
|
|
1194
|
-
});
|
|
1195
|
-
if (normalized.status !== 200 || !text && toolCalls.length === 0) {
|
|
1196
|
-
console.warn(
|
|
1197
|
-
`[antigravity] empty completion: finishReason=${JSON.stringify(finishReason)} reasoningLen=${reasoningContent?.length ?? 0} usage=${JSON.stringify(usage) ?? "none"} model=${String(envelope.model)} base=${new URL(url).host}`
|
|
1198
|
-
);
|
|
1199
|
-
}
|
|
1200
|
-
return normalized;
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
// packages/agent-runtime/devinOAuth.ts
|
|
1204
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
1205
|
-
import { homedir } from "node:os";
|
|
1206
|
-
import { join } from "node:path";
|
|
1207
|
-
var DEVIN_CONNECT_URL = "https://server.codeium.com/exa.api_server_pb.ApiServerService/GetChatMessage";
|
|
1208
|
-
function buildDevinAuthUrl(orgId) {
|
|
1209
|
-
const cleanOrg = orgId?.trim();
|
|
1210
|
-
if (cleanOrg) {
|
|
1211
|
-
return `https://app.devin.ai/org/${encodeURIComponent(cleanOrg)}/settings/keys`;
|
|
1212
|
-
}
|
|
1213
|
-
return "https://app.devin.ai/settings/keys";
|
|
1214
|
-
}
|
|
1215
|
-
function extractDevinToken(input) {
|
|
1216
|
-
const raw = input?.trim();
|
|
1217
|
-
if (!raw) return null;
|
|
1218
|
-
if (/^https?:\/\//i.test(raw)) {
|
|
1219
|
-
try {
|
|
1220
|
-
const url = new URL(raw);
|
|
1221
|
-
const queryToken = url.searchParams.get("token") || url.searchParams.get("access_token") || url.searchParams.get("auth_token");
|
|
1222
|
-
if (queryToken?.trim()) return queryToken.trim();
|
|
1223
|
-
if (url.hash) {
|
|
1224
|
-
const hashParams = new URLSearchParams(url.hash.replace(/^#/, ""));
|
|
1225
|
-
const hashToken = hashParams.get("token") || hashParams.get("access_token") || hashParams.get("auth_token");
|
|
1226
|
-
if (hashToken?.trim()) return hashToken.trim();
|
|
1227
|
-
}
|
|
1228
|
-
} catch {
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
return raw || null;
|
|
1232
|
-
}
|
|
1233
|
-
function parseDevinCredentialsToml(content) {
|
|
1234
|
-
for (const line of content.split(/\r?\n/)) {
|
|
1235
|
-
const cogMatch = line.match(/(cog_[A-Za-z0-9_-]+)/);
|
|
1236
|
-
if (cogMatch?.[1]) {
|
|
1237
|
-
return cogMatch[1].trim();
|
|
1238
|
-
}
|
|
1239
|
-
const match = line.match(
|
|
1240
|
-
/^\s*(?:windsurf_api_key|devin_api_key|api_key|api_token|token)\s*=\s*"([^"]+)"\s*$/i
|
|
1241
|
-
);
|
|
1242
|
-
if (match?.[1]) {
|
|
1243
|
-
return match[1].trim();
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
return null;
|
|
1247
|
-
}
|
|
1248
|
-
function detectLocalDevinCredentials(options) {
|
|
1249
|
-
const baseHome = options?.homeDir || homedir();
|
|
1250
|
-
const xdgData = process.env.XDG_DATA_HOME;
|
|
1251
|
-
const candidateCliPaths = [
|
|
1252
|
-
xdgData ? join(xdgData, "devin", "credentials.toml") : null,
|
|
1253
|
-
join(baseHome, ".local", "share", "devin", "credentials.toml"),
|
|
1254
|
-
process.env.APPDATA ? join(process.env.APPDATA, "devin", "credentials.toml") : null
|
|
1255
|
-
].filter((p) => Boolean(p));
|
|
1256
|
-
for (const credPath of candidateCliPaths) {
|
|
1257
|
-
if (existsSync(credPath)) {
|
|
1258
|
-
try {
|
|
1259
|
-
const content = readFileSync(credPath, "utf-8");
|
|
1260
|
-
const token = parseDevinCredentialsToml(content);
|
|
1261
|
-
if (token) {
|
|
1262
|
-
return {
|
|
1263
|
-
found: true,
|
|
1264
|
-
token,
|
|
1265
|
-
source: "devin-cli",
|
|
1266
|
-
sourcePath: credPath
|
|
1267
|
-
};
|
|
1268
|
-
}
|
|
1269
|
-
} catch {
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
const codeiumPath = join(baseHome, ".codeium", "config.json");
|
|
1274
|
-
if (existsSync(codeiumPath)) {
|
|
1275
|
-
try {
|
|
1276
|
-
const parsed = JSON.parse(readFileSync(codeiumPath, "utf-8"));
|
|
1277
|
-
const token = parsed.apiKey || parsed.api_key;
|
|
1278
|
-
if (token?.trim()) {
|
|
1279
|
-
return {
|
|
1280
|
-
found: true,
|
|
1281
|
-
token: token.trim(),
|
|
1282
|
-
source: "codeium-config",
|
|
1283
|
-
sourcePath: codeiumPath
|
|
1284
|
-
};
|
|
1285
|
-
}
|
|
1286
|
-
} catch {
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
return { found: false };
|
|
1290
|
-
}
|
|
1291
|
-
function buildDevinOAuthCredential(token, now = Date.now()) {
|
|
1292
|
-
return {
|
|
1293
|
-
provider: "devin",
|
|
1294
|
-
accessToken: token.trim(),
|
|
1295
|
-
obtainedAt: now
|
|
1296
|
-
};
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
export {
|
|
1300
|
-
AGENT_PROMPT_IN_MESSAGES,
|
|
1301
|
-
hasAssembledAgentPrompt,
|
|
1302
|
-
parseSseDataLineJson,
|
|
1303
|
-
parseSseDataLineObject,
|
|
1304
|
-
parseUpstreamErrorBody,
|
|
1305
|
-
resolveGeminiModelQuirks,
|
|
1306
|
-
isGemini3Model,
|
|
1307
|
-
accumulateGeminiChunks,
|
|
1308
|
-
shouldUseGeminiNativeToolRoute,
|
|
1309
|
-
buildGeminiGenerateContentRequest,
|
|
1310
|
-
resolveAntigravityFinishReason,
|
|
1311
|
-
fetchAntigravityCloudCodeCompletion,
|
|
1312
|
-
DEVIN_CONNECT_URL,
|
|
1313
|
-
buildDevinAuthUrl,
|
|
1314
|
-
extractDevinToken,
|
|
1315
|
-
detectLocalDevinCredentials,
|
|
1316
|
-
buildDevinOAuthCredential
|
|
1317
|
-
};
|