nolo-cli 0.258.0-alpha.1 → 0.260.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-E2LL7FPO.js → _executeModel-EO6JFCOF.js} +97 -83
- package/accountResolver-NGICIMEE.js +1 -1
- package/{action-C6IQAKN4.js → action-WIA56QT4.js} +12 -10
- package/{addContentAction-53364YDW.js → addContentAction-OCMWZLYG.js} +14 -13
- package/{addDialogAgentAction-U5DD5EN5.js → addDialogAgentAction-ER2NZ7BC.js} +20 -24
- package/{agentDeleteCommand-ORNRRKJO.js → agentDeleteCommand-KSXSNPAU.js} +184 -146
- package/{agentEmailCommands-2ALVFOD5.js → agentEmailCommands-NXRWS7NS.js} +142 -126
- package/{agentGrantCommands-L6O2HVJI.js → agentGrantCommands-D2S7LCTU.js} +8 -5
- package/{agentListCommands-6I4NQPR4.js → agentListCommands-PFXGZZ3Y.js} +87 -68
- package/{agentMachineCommands-PNHTIJ6A.js → agentMachineCommands-2Q55CSL4.js} +68 -59
- package/{agentProviderCommands-QLTABYR7.js → agentProviderCommands-EUNS7Y2Z.js} +10 -7
- package/{agentPullCommand-2EYJ5ENC.js → agentPullCommand-S2VMPSWL.js} +9 -6
- package/agentRecordCommands-FUFI526H.js +210 -0
- package/agentRun-ZNMUPDHF.js +250 -0
- package/agentRunCommand-ISVQ2UYC.js +248 -0
- package/{agentRunControl-3TIVJ3SR.js → agentRunControl-NEK44LDM.js} +19 -12
- package/{agentRuntimeLocal-3MAEFYSB.js → agentRuntimeLocal-SST4EPLT.js} +62 -49
- package/{agentSlice-KOQXUPKT.js → agentSlice-4ZJJJN4M.js} +15 -18
- package/appConfigCommands-MPHS6FHD.js +417 -0
- package/{appDeleteCommands-FEPN62UR.js → appDeleteCommands-W26WGENW.js} +68 -58
- package/{appDeployCommands-DPFEWFYZ.js → appDeployCommands-ER7IOF5E.js} +74 -59
- package/{appDeployStatusCommands-LQ5X5KVX.js → appDeployStatusCommands-VKLL3A77.js} +68 -58
- package/{appGetCommands-W3JBBIF7.js → appGetCommands-P6GXJNUD.js} +74 -58
- package/{appListCommands-LUHZS7JU.js → appListCommands-ACA2IZZM.js} +74 -58
- package/appMigrateCommands-OGF4E2W6.js +230 -0
- package/appSourceCommands-GAHVBRUM.js +279 -0
- package/{authCommand-HKSXJT3J.js → authCommand-PXE7NZTQ.js} +26 -40
- package/{authCommands-T5FODCEG.js → authCommands-AZPYXTUB.js} +20 -17
- package/{builtinSkillRegistry-FVEEO4U2.js → builtinSkillRegistry-6XUWMAV5.js} +8 -6
- package/{chromeOpsCommands-4UIKH26F.js → chromeOpsCommands-7UKKUOBU.js} +68 -18
- package/{chunk-KO5PFS74.js → chunk-2CKFROQS.js} +2454 -1115
- package/{chunk-6N4IKMTH.js → chunk-2I4R6ZRV.js} +40 -26
- 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-ZYPXOQS2.js → chunk-3EPED3UO.js} +1 -1
- package/{chunk-DNNPARJK.js → chunk-3QMN3T6L.js} +50 -37
- package/{chunk-DMPZMYH4.js → chunk-3R4AYHJR.js} +13 -1
- package/{chunk-HPDLPEUG.js → chunk-42JZNSAY.js} +267 -234
- 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-OKAXQFON.js → chunk-52BNL6GP.js} +4 -4
- package/{chunk-KZ4A7EIV.js → chunk-56OAS5RZ.js} +1 -1
- package/{chunk-QGFLVQ6E.js → chunk-6KUTNAPU.js} +4 -14
- package/{chunk-MNFUKRRU.js → chunk-6XAAKRJB.js} +7 -7
- package/{chunk-P27E22MA.js → chunk-6Z6DGDPI.js} +1 -1
- package/chunk-72VWN4VK.js +51 -0
- package/{chunk-2RZBFJEG.js → chunk-75FZ2Z7C.js} +16027 -17392
- package/{chunk-ADYWV732.js → chunk-76B6YUQS.js} +264 -177
- package/{chunk-AKBNCTPY.js → chunk-76K4GTY5.js} +1 -1
- package/{chunk-ZMJMHXYX.js → chunk-7HUCUD2I.js} +3 -3
- package/chunk-7LR2IFUH.js +100 -0
- package/{chunk-S73EPYNC.js → chunk-7LS5ATRP.js} +20 -6
- package/{chunk-Y2TCTNUD.js → chunk-7QO6YSA4.js} +4 -4
- package/{chunk-TF427WGH.js → chunk-7RYH7YIY.js} +19 -27
- package/{chunk-KHYSFS3W.js → chunk-A454UXB6.js} +148 -73
- package/chunk-AMNZPQCY.js +635 -0
- package/chunk-AMTF6FJD.js +356 -0
- package/{chunk-MUDMYJCM.js → chunk-AQNWWJLH.js} +2 -56
- package/{chunk-WSLL7VV4.js → chunk-B4NA5UJR.js} +9 -9
- package/{chunk-LHCGKAFO.js → chunk-BKP325XS.js} +184 -112
- package/{chunk-PENRYZ4D.js → chunk-BPB3T5EU.js} +4 -7
- package/{chunk-46FETNLF.js → chunk-BTIFQBYW.js} +7 -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-AIFQKNPP.js → chunk-CL33RFD7.js} +1 -1
- package/{chunk-JAGD4PSH.js → chunk-CRGPRAJ4.js} +46 -42
- package/{chunk-P4R5KXU7.js → chunk-CW6LRDSF.js} +5 -5
- package/{chunk-BD22OFDQ.js → chunk-CZHIOBBK.js} +8 -3
- package/chunk-D3ONA3FP.js +762 -0
- package/chunk-D3SAQ6T7.js +1697 -0
- package/{chunk-PIVTQRX6.js → chunk-DDKA6V6X.js} +111 -12
- package/{chunk-KQHEGELM.js → chunk-DEAII55O.js} +16 -6
- package/{chunk-J55F3IEZ.js → chunk-DKJQEFNG.js} +1 -1
- 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-EJHLDJWZ.js +58 -0
- package/{chunk-E4HBZDV6.js → chunk-EMFZXJTN.js} +15 -47
- package/chunk-ER6NTALN.js +34 -0
- package/chunk-EUHMI5KG.js +101 -0
- package/{chunk-YQLAFJRQ.js → chunk-FBNVJ2TO.js} +1 -1
- package/{chunk-EXD7S7QW.js → chunk-FF5ZRKW7.js} +12 -7
- package/{chunk-7PTWFSZZ.js → chunk-FGD4NMTP.js} +4 -4
- package/{chunk-6XIE5ZGI.js → chunk-FGFJUFPS.js} +5 -6
- package/chunk-FI4DPLR7.js +902 -0
- package/chunk-FKVLQNGJ.js +25 -0
- package/{chunk-JCQ3WCQ3.js → chunk-FOC4TORM.js} +69 -3
- package/{chunk-JPXACKSW.js → chunk-G22P2J7O.js} +30 -81
- package/{chunk-7WHCIA5V.js → chunk-G5IAIGGD.js} +3 -8
- package/{chunk-IZHENZQ5.js → chunk-G5JGA5YM.js} +180 -31
- package/{chunk-7EUJ65PF.js → chunk-GMBWWBSJ.js} +782 -449
- package/{chunk-WS36XPJD.js → chunk-GYFKKTDI.js} +82 -6
- package/{chunk-APXC3SQO.js → chunk-GZ4I5EMM.js} +9 -9
- package/{chunk-324FWHUA.js → chunk-HHXF57CL.js} +12 -3
- package/chunk-HJTI7RZV.js +94 -0
- package/{chunk-JGVWHUYK.js → chunk-HPIY372N.js} +7 -7
- package/{chunk-Q2MPKE4B.js → chunk-HVRG27HI.js} +76 -26
- package/{chunk-HDKMVYNJ.js → chunk-I3NWAILT.js} +6 -4
- package/{chunk-MD7O2NN2.js → chunk-IM7HCFB4.js} +313 -275
- package/{chunk-DWES4SXY.js → chunk-INN2PBW7.js} +1 -1
- package/chunk-IV6VUVLJ.js +88 -0
- package/chunk-J42X32PV.js +472 -0
- package/{chunk-V6S5OZSP.js → chunk-JHQNWV2C.js} +4441 -2569
- package/{chunk-R7XWZDOH.js → chunk-JUMQJSQF.js} +1423 -282
- package/{chunk-BIDSIRTS.js → chunk-JUNYPVL6.js} +10 -16
- package/chunk-JVEKCQAP.js +222 -0
- package/{chunk-JW6OURKM.js → chunk-KAHYBAEN.js} +215 -473
- package/chunk-KDDXC2IH.js +148 -0
- package/chunk-KGKTN2NX.js +25 -0
- package/chunk-KGWE224L.js +246 -0
- package/chunk-L3UFGEDU.js +17157 -0
- package/{chunk-CBIGMWMI.js → chunk-LHJB4BXJ.js} +1 -1
- package/{chunk-DCTQJDDQ.js → chunk-LIH7WSX5.js} +23 -379
- package/chunk-LJOPY4TL.js +443 -0
- package/{chunk-TRRXYFTR.js → chunk-LOFRSJX2.js} +1 -0
- package/{chunk-SQL7YNED.js → chunk-LPXBBC32.js} +71 -5
- package/chunk-LXP53WGF.js +168 -0
- package/chunk-MDAYRIP7.js +1889 -0
- package/chunk-MRACVEPZ.js +7 -0
- package/chunk-NHLLXINQ.js +8 -0
- package/{chunk-VQR2ACSC.js → chunk-NTBTVKKB.js} +17 -25
- package/{chunk-LVZVSLKO.js → chunk-O7ZY6SUK.js} +5 -22
- package/{chunk-APQBEIOQ.js → chunk-P4XAHM4B.js} +1 -1
- package/chunk-PL5RKESU.js +40 -0
- package/{chunk-U2H426FE.js → chunk-PQ3QZMJK.js} +20 -4
- package/chunk-Q5FJJ6XI.js +103 -0
- package/{createAgentAutomationAction-HEZ3G5L4.js → chunk-QKM55LP2.js} +3 -160
- package/{chunk-SIHOY5YI.js → chunk-QZCLCAYC.js} +170 -164
- package/{chunk-FE7G6DSP.js → chunk-R72QWIFO.js} +14 -4
- package/{chunk-JLZJL3WC.js → chunk-RDZ5OIAT.js} +370 -39
- package/{chunk-5RGU3J7P.js → chunk-REAE2SZK.js} +0 -1
- package/chunk-RF576RYE.js +117 -0
- package/chunk-RI7SXDJW.js +1317 -0
- package/{chunk-JOJH3KWV.js → chunk-RIOAPUGV.js} +242 -25
- package/{chunk-7B55IVLF.js → chunk-RL6H2A2Z.js} +2561 -4059
- package/{chunk-BZLGPM5B.js → chunk-RNLKWUVY.js} +7 -12
- package/{chunk-BB76X6O4.js → chunk-RWXHGPWJ.js} +1 -1
- package/chunk-S7BF2OGX.js +432 -0
- package/{chunk-6VEO7Z3Y.js → chunk-SD4MBKZ7.js} +6 -6
- package/{chunk-PNBQ5JTA.js → chunk-SGEBRBF3.js} +7 -4
- package/{chunk-6SOWMEAY.js → chunk-SR57FDTX.js} +2 -258
- package/{chunk-CEKRIR22.js → chunk-SU4NCTW4.js} +1 -1
- package/{chunk-LJ6WIQZO.js → chunk-SX6PDLBZ.js} +279 -149
- package/{chunk-6VNBJ7GI.js → chunk-T4WU747C.js} +5 -5
- package/{chunk-53W5BXLN.js → chunk-TCOHWKDM.js} +54 -55
- package/{chunk-KO5GO2BC.js → chunk-TXMFSGRY.js} +1 -1
- package/{chunk-UUCYUN6Y.js → chunk-UB7NV7NN.js} +1 -1
- package/{chunk-CVDJUPBN.js → chunk-UOLGGEEC.js} +774 -119
- package/{chunk-ADUCBH4M.js → chunk-USFG4EWQ.js} +51 -42
- package/{chunk-LLUBUHNT.js → chunk-UYZOBSSO.js} +5 -9
- package/{chunk-ONTHDYFU.js → chunk-VDC3BW24.js} +24 -10
- package/chunk-VH356OQ3.js +425 -0
- package/{chunk-U6QNVOR5.js → chunk-VKM7DOYB.js} +130 -6
- package/{chunk-3GGVFHWI.js → chunk-VPAO5WQX.js} +17 -14
- package/{chunk-OYUMJMC5.js → chunk-W2RQYNPI.js} +5 -0
- package/{chunk-C63KMRJE.js → chunk-W2Z5E2R7.js} +126 -698
- package/{chunk-4ZCTKB27.js → chunk-W5GKF5ZW.js} +1 -0
- package/{chunk-NUHQO3RB.js → chunk-WIVVNJUS.js} +1 -1
- package/chunk-WLJNHFEB.js +1710 -0
- package/chunk-WMBJDXMY.js +408 -0
- package/chunk-WSQLCWLQ.js +201 -0
- package/{chunk-YN23INFZ.js → chunk-WXD6Y7DW.js} +23 -2
- package/{chunk-RQKTCHQM.js → chunk-WY6DMHMG.js} +1 -1
- package/{chunk-MLK3FEXG.js → chunk-XJW6SLBZ.js} +3 -3
- package/{chunk-7BIJFGKS.js → chunk-XQFDCRG3.js} +105 -51
- package/chunk-XT6C2QZW.js +46 -0
- package/{chunk-NRUYSNSZ.js → chunk-Y7THFNVJ.js} +9 -9
- package/{chunk-ZEZC7IIM.js → chunk-YFSM2366.js} +35 -35
- package/{chunk-RD3QLZQV.js → chunk-YM5XULB2.js} +324 -2
- package/{chunk-BD5YJJLJ.js → chunk-YNP3ITPU.js} +19 -12
- package/{chunk-U35UUM5K.js → chunk-YOUSQIIK.js} +1 -1
- package/{chunk-RIWKZT7E.js → chunk-YRPIUIEQ.js} +11 -9
- package/{chunk-Z3JZ2R5F.js → chunk-YU235GGN.js} +25 -8
- package/chunk-YWEZSBLL.js +790 -0
- package/chunk-Z3KTXWWB.js +76 -0
- package/{chunk-YLAHYLDQ.js → chunk-ZC3CMUKU.js} +2 -89
- package/chunk-ZD7OULYZ.js +368 -0
- package/{chunk-5P3PPQVP.js → chunk-ZQAADXSF.js} +1 -1
- package/{chunk-HQUGB2HM.js → chunk-ZTCMXPIS.js} +62 -50
- package/{cliAgentConfigHelpers-BXHQ3PXP.js → cliAgentConfigHelpers-KMXS7JP5.js} +20 -14
- package/{cliAuthorityBrokerClient-TFNXJLXL.js → cliAuthorityBrokerClient-3SKOA7OZ.js} +3 -1
- package/cliAuthorityBrokerProcess-DCCUT4YQ.js +34 -0
- package/{cliEnvHelpers-CNMP3RDX.js → cliEnvHelpers-YDGDHIEE.js} +5 -2
- package/{cliExecutor-K6FDZTQ2.js → cliExecutor-Z62UBJ5S.js} +12 -6
- package/cliLocalAgentRecordReader-X2YHEBWI.js +113 -0
- package/cloudAutomationCommands-C6Q3BFRB.js +310 -0
- package/{commandRegistry-QKOJ5FIC.js → commandRegistry-TYYYTW5E.js} +263 -120
- package/{contentThunks-ZDBDDZP3.js → contentThunks-E6BJ5YSX.js} +45 -43
- package/{cooldownCommands-Y4ZQQ35D.js → cooldownCommands-FPAFS7XG.js} +1 -1
- package/createAgentAutomationAction-L3NLCIIW.js +172 -0
- package/{createDialogAction-DK62W5VA.js → createDialogAction-QSWKRPWQ.js} +46 -42
- package/{createPageAction-W6NXHVKO.js → createPageAction-ZVVUT4CZ.js} +49 -45
- package/{db-VR74ADGC.js → db-KTQ3LL2Q.js} +3 -3
- package/{dbSlice-RWPSVHBC.js → dbSlice-SEVKNA7A.js} +21 -16
- package/deleteDbKey-43MTK2DI.js +86 -0
- package/{dialogCommands-Z24IDINY.js → dialogCommands-UVMTIFSA.js} +80 -66
- package/{dialogMessageRecord-OAV77LT7.js → dialogMessageRecord-2HJTEXQX.js} +1 -1
- package/{dialogNotifyCommand-IASQGEMW.js → dialogNotifyCommand-LMWF7EQI.js} +22 -14
- package/dialogPortabilityCommands-PAMLEBST.js +3036 -0
- package/{dialogSlice-62GISS77.js → dialogSlice-VHPXENDZ.js} +43 -42
- package/{dialogTraceCommand-FDINAIZ6.js → dialogTraceCommand-SO2WKAXW.js} +83 -69
- package/{dialogUsageCommand-WJ3U6KZU.js → dialogUsageCommand-EUO6JXTD.js} +6 -3
- package/{docCreateCommands-SXA4TMGJ.js → docCreateCommands-H4RLIUNX.js} +68 -59
- package/{docDeleteCommands-ELXSZK3F.js → docDeleteCommands-OVAKCBMT.js} +68 -59
- package/{docReadCommands-DFLAQPI4.js → docReadCommands-KFISIUVA.js} +67 -58
- package/{docStore-UWF2PMCB.js → docStore-X7BEA735.js} +16 -17
- package/{docUpdateCommands-KB6M5HUH.js → docUpdateCommands-VOEER36L.js} +68 -59
- package/ebookDownloaderAgentCommand-2DHPGEOQ.js +674 -0
- package/{fetchMessages-TQEUZD7H.js → fetchMessages-RGPIYEPZ.js} +2 -2
- package/{getPricing-5BLZRPTM.js → getPricing-BK6CUBAE.js} +8 -4
- package/{handleSendMessageAction-ZV6OQPQG.js → handleSendMessageAction-GQ2KKOET.js} +265 -119
- package/{hostCredentialCreate-3IA5IJFG.js → hostCredentialCreate-PJAIKZQP.js} +138 -122
- package/index.js +35 -21
- package/{keys-RWF7UCB4.js → keys-FXEGMKSG.js} +2 -2
- package/localAutomationCommands-UU66LOWB.js +198 -0
- package/localAutomationRuntime-SW4R42SZ.js +60 -0
- package/{localDialogRead-BJJT3TF5.js → localDialogRead-W2EVXISA.js} +2 -2
- package/{localRuntimeAdapter-SSG5ORLZ.js → localRuntimeAdapter-WRBLXFUZ.js} +136 -119
- package/localRuntimeAuthority-3YDFZD3L.js +44 -0
- package/{localRuntimeDb-ZJFGNHML.js → localRuntimeDb-CJWJK47G.js} +1 -1
- package/{machineCommands-4WKJ3TLO.js → machineCommands-JFYED66N.js} +251 -357
- package/{machineInfo-LWHTEBHJ.js → machineInfo-BJIU3WQ5.js} +4 -2
- package/machineWsRunDispatch-CZUV2FXE.js +227 -0
- package/{mcpLocalAuthorizeCommand-RBXJDE6J.js → mcpLocalAuthorizeCommand-HLU72QME.js} +40 -22
- package/mcpLocalManageCommands-OHHU6F5C.js +212 -0
- package/{memberThunks-43B7UYC5.js → memberThunks-FJW4GPM5.js} +102 -22
- package/{memoryCommands-BC6REPQB.js → memoryCommands-2RLHDMU2.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-7EWR34P3.js +613 -0
- package/{projectArchive-JN43WW4E.js → projectArchive-JIVRMXVV.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-6YR57D6V.js} +11 -10
- package/{readDocTool-N3GA52JR.js → readDocTool-NKOGL2MW.js} +5 -1
- package/{readlineWorkspace-D6EUSB2Q.js → readlineWorkspace-V26AN2FL.js} +926 -572
- package/{rememberExplicit-CPAPONSI.js → rememberExplicit-7KX4HXQC.js} +4 -4
- package/remove-BF33RCTH.js +32 -0
- package/{removeDialogAgentAction-EEVSOQOJ.js → removeDialogAgentAction-GWHBWF4W.js} +22 -26
- package/{runAgentClientLoop-FEZTSUSJ.js → runAgentClientLoop-EKD2EEEA.js} +117 -82
- package/{runtimeDoctorCommands-V3M3JTUV.js → runtimeDoctorCommands-IALUR5BZ.js} +23 -16
- package/{secretCommands-53NZFD4T.js → secretCommands-CSTQYB6T.js} +2 -2
- package/{setDialogExtraReferencesAction-DNO5POHA.js → setDialogExtraReferencesAction-RL6FGO7T.js} +16 -17
- package/{setPrimaryDialogAgentAction-QABBEO4C.js → setPrimaryDialogAgentAction-XJASBB3K.js} +23 -27
- package/{settingThunks-DVKG4X4S.js → settingThunks-ZT7ZYXXL.js} +170 -497
- package/{skillDiscovery-5GEGWJ6N.js → skillDiscovery-IUEZZG2B.js} +3 -3
- package/{spaceCommands-4ACQQNZL.js → spaceCommands-65WQHVOI.js} +194 -90
- package/spacePruneCommand-PTMRUWYJ.js +233 -0
- package/{store-Z53ICFL3.js → store-WSAVTR32.js} +3 -1
- package/{streamAgentChatTurn-I425SVYJ.js → streamAgentChatTurn-B5NICHZW.js} +225 -137
- package/{switchDialogAgentAction-KYWJSGOO.js → switchDialogAgentAction-X6DFOIAX.js} +19 -23
- package/{tableCommands-EFA754RE.js → tableCommands-6E77VD73.js} +28 -49
- package/{toolApiClient-N5PYW2R3.js → toolApiClient-GTTWEV6P.js} +15 -4
- package/{tools-WBPFTSMK.js → tools-UMCPIQX6.js} +73 -63
- package/{tuiRestart-VN5F4GYU.js → tuiRestart-O7UDLNQU.js} +20 -13
- package/tuiSummaryLlmCaller-7APIUIIV.js +52 -0
- package/{updateCommands-VQEBBIGO.js → updateCommands-DXDIAQFS.js} +12 -7
- package/{updateDialogTitleAction-VB5DTVXV.js → updateDialogTitleAction-HZLKWVKM.js} +57 -58
- package/{usageCommand-WI6SQOPB.js → usageCommand-WYLNBDHB.js} +6 -8
- package/{usageRebuildCommand-WQRLLZAT.js → usageRebuildCommand-AEUPY2PE.js} +11 -15
- package/{windowsSelfUpdate-ZEZKGX4M.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-BEZPBYBM.js +0 -194
- package/agentRunCommand-2T72V5KY.js +0 -232
- package/chunk-2MBTWINN.js +0 -89
- package/chunk-523DITKR.js +0 -32
- package/chunk-BUDVRYES.js +0 -2213
- package/chunk-BXGU6274.js +0 -862
- 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-WFEWP352.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-ZTHAJU3O.js +0 -2537
- package/cliAuthorityBrokerProcess-5ZFBTHLB.js +0 -22
- package/cliLocalAgentRecordReader-Q6677YID.js +0 -104
- package/deleteFile-ECU6FU5C.js +0 -55
- package/localRuntimeAuthority-UF2DAQ3F.js +0 -28
- package/machineWsRunDispatch-7PROH7E7.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
|
@@ -0,0 +1,1697 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MACHINE_SHELL_LOCAL_REFUSAL_MESSAGE,
|
|
3
|
+
attachLocalCommandObservations,
|
|
4
|
+
buildModelLayerOverride,
|
|
5
|
+
captureLocalRunBase,
|
|
6
|
+
formatLocalRunSummary,
|
|
7
|
+
inspectLocalRunWorkspace,
|
|
8
|
+
resolveCliMemory,
|
|
9
|
+
resolveCliWorkContext,
|
|
10
|
+
runAgentTurn,
|
|
11
|
+
shouldPrintLocalRunSummary,
|
|
12
|
+
unknownLocalRunAcceptance
|
|
13
|
+
} from "./chunk-75FZ2Z7C.js";
|
|
14
|
+
import {
|
|
15
|
+
getReadableCliDb
|
|
16
|
+
} from "./chunk-3EPED3UO.js";
|
|
17
|
+
import {
|
|
18
|
+
INSTABOX_RUN_CONFIG_ENV,
|
|
19
|
+
buildLocalRunEnv,
|
|
20
|
+
hashInstaboxDeliveryManifest,
|
|
21
|
+
isFullstackCodingAgentRef,
|
|
22
|
+
isInstaboxBillingPolicy,
|
|
23
|
+
normalizeCliRunImages,
|
|
24
|
+
parseAgentRunArgs,
|
|
25
|
+
readFlagValue,
|
|
26
|
+
resolveBoundMachineId,
|
|
27
|
+
resolveRawAgentInput,
|
|
28
|
+
resolveServerUrl,
|
|
29
|
+
validateInstaboxWorkspaceSelection,
|
|
30
|
+
writeUsage
|
|
31
|
+
} from "./chunk-JHQNWV2C.js";
|
|
32
|
+
import {
|
|
33
|
+
CliProviderQuotaError
|
|
34
|
+
} from "./chunk-JUMQJSQF.js";
|
|
35
|
+
import {
|
|
36
|
+
parsePositiveFiniteNumberOrFallback
|
|
37
|
+
} from "./chunk-Y5GCAMGP.js";
|
|
38
|
+
import {
|
|
39
|
+
readDbRecord,
|
|
40
|
+
resolveAgentRecordFromHybridStore
|
|
41
|
+
} from "./chunk-EMFZXJTN.js";
|
|
42
|
+
import {
|
|
43
|
+
awaitLocalWriterChild,
|
|
44
|
+
createMcpApprovalChild,
|
|
45
|
+
createRunActivityTracker,
|
|
46
|
+
createShellApprovalChild,
|
|
47
|
+
getRunResultHeaderMeta,
|
|
48
|
+
isHistoryIntegrityFailure,
|
|
49
|
+
popSingleQueueMessage,
|
|
50
|
+
readRunRecord,
|
|
51
|
+
recordRunStartup,
|
|
52
|
+
registerLocalForegroundWriter,
|
|
53
|
+
reportRunProcessIdentity,
|
|
54
|
+
resolveRunQueuePath,
|
|
55
|
+
resolveRunsDir,
|
|
56
|
+
settleRunTerminalAuthoritatively,
|
|
57
|
+
spawnLocalBackgroundRun,
|
|
58
|
+
transitionRunToTerminal
|
|
59
|
+
} from "./chunk-VDC3BW24.js";
|
|
60
|
+
import {
|
|
61
|
+
buildSkillDiscoveryContextLayer
|
|
62
|
+
} from "./chunk-WIVVNJUS.js";
|
|
63
|
+
import {
|
|
64
|
+
readAgentsMdLayerFromDisk
|
|
65
|
+
} from "./chunk-GMBWWBSJ.js";
|
|
66
|
+
import {
|
|
67
|
+
readCacheReadInputTokensOrNull
|
|
68
|
+
} from "./chunk-CEIWXKHP.js";
|
|
69
|
+
import {
|
|
70
|
+
normalizeRuntimeToolPolicyOverride,
|
|
71
|
+
resolveEffectiveRuntimeToolPolicy
|
|
72
|
+
} from "./chunk-GX2MFKF3.js";
|
|
73
|
+
import {
|
|
74
|
+
workspaceChildEnv
|
|
75
|
+
} from "./chunk-2I4R6ZRV.js";
|
|
76
|
+
import {
|
|
77
|
+
isQuotaExhaustedError
|
|
78
|
+
} from "./chunk-EWQ3HGNZ.js";
|
|
79
|
+
import {
|
|
80
|
+
buildMemoryOverlayLayer,
|
|
81
|
+
buildMemoryUseGuidanceLayer,
|
|
82
|
+
partitionScopedBlocks,
|
|
83
|
+
renderTurnContextBlocksWithScope
|
|
84
|
+
} from "./chunk-FBNVJ2TO.js";
|
|
85
|
+
import {
|
|
86
|
+
toErrorMessage
|
|
87
|
+
} from "./chunk-HNMXYYJR.js";
|
|
88
|
+
import {
|
|
89
|
+
parseExternalSkillMarkdown,
|
|
90
|
+
parseSkillDocProtocol
|
|
91
|
+
} from "./chunk-AETZ7AD6.js";
|
|
92
|
+
import {
|
|
93
|
+
isLocalCliAgentKey
|
|
94
|
+
} from "./chunk-BR3GT6MR.js";
|
|
95
|
+
import {
|
|
96
|
+
isSubtaskRun
|
|
97
|
+
} from "./chunk-FOC4TORM.js";
|
|
98
|
+
import {
|
|
99
|
+
BUILTIN_NOLO_AGENT_KEY
|
|
100
|
+
} from "./chunk-YRPIUIEQ.js";
|
|
101
|
+
import {
|
|
102
|
+
exitCliFromWatchdog
|
|
103
|
+
} from "./chunk-E36V7MPY.js";
|
|
104
|
+
import {
|
|
105
|
+
RuntimeProtocolMismatchError,
|
|
106
|
+
RuntimeVersionMismatchError,
|
|
107
|
+
resolveAuthToken,
|
|
108
|
+
validateAgentRunProtocol
|
|
109
|
+
} from "./chunk-JUNYPVL6.js";
|
|
110
|
+
import {
|
|
111
|
+
asOptionalTrimmedString
|
|
112
|
+
} from "./chunk-G3SUCT4W.js";
|
|
113
|
+
import {
|
|
114
|
+
t
|
|
115
|
+
} from "./chunk-RIOAPUGV.js";
|
|
116
|
+
|
|
117
|
+
// packages/cli/agentRunCommand.ts
|
|
118
|
+
import { createHash } from "node:crypto";
|
|
119
|
+
|
|
120
|
+
// packages/cli/client/instaboxRunConfigWrite.ts
|
|
121
|
+
import { randomUUID } from "node:crypto";
|
|
122
|
+
import { lstatSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
123
|
+
import { isAbsolute, join, normalize, resolve } from "node:path";
|
|
124
|
+
var InstaboxRunConfigWriteError = class extends Error {
|
|
125
|
+
code;
|
|
126
|
+
constructor(code, message) {
|
|
127
|
+
super(`instabox_run_config_write:${code}: ${message}`);
|
|
128
|
+
this.name = "InstaboxRunConfigWriteError";
|
|
129
|
+
this.code = `instabox_run_config_write:${code}`;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var fail = (code, msg) => {
|
|
133
|
+
throw new InstaboxRunConfigWriteError(code, msg);
|
|
134
|
+
};
|
|
135
|
+
function writeInstaboxRunConfig(options) {
|
|
136
|
+
const { workspaceMode, artifactDir, manifestPath, allowRemoteRelease } = options;
|
|
137
|
+
if (workspaceMode !== "empty" && workspaceMode !== "snapshot") {
|
|
138
|
+
fail("invalid_workspace_mode", 'workspaceMode \u5FC5\u987B\u662F "empty" \u6216 "snapshot"');
|
|
139
|
+
}
|
|
140
|
+
const trimmedArtifactDir = artifactDir?.trim();
|
|
141
|
+
if (!trimmedArtifactDir) {
|
|
142
|
+
fail("missing_artifact_dir", "artifactDir \u5FC5\u987B\u662F\u975E\u7A7A\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u672A\u914D\u7F6E\u6216\u9ED8\u8BA4\u5747\u88AB\u62D2\u7EDD");
|
|
143
|
+
}
|
|
144
|
+
if (!isAbsolute(trimmedArtifactDir) || trimmedArtifactDir.includes("\0") || trimmedArtifactDir.split("/").includes("..")) {
|
|
145
|
+
fail("invalid_artifact_dir", `artifactDir \u5FC5\u987B\u4E3A\u5408\u6CD5\u7684\u7EDD\u5BF9\u8DEF\u5F84\u4E14\u4E0D\u80FD\u5305\u542B .. \u6216\u7A7A\u5B57\u7B26: "${trimmedArtifactDir}"`);
|
|
146
|
+
}
|
|
147
|
+
const approvalId = `appr-${randomUUID()}`;
|
|
148
|
+
const bindingId = `bind-${randomUUID()}`;
|
|
149
|
+
const freeCreateEvidenceId = `fce-${randomUUID()}`;
|
|
150
|
+
const workspaceAuthorizationId = `wauth-${randomUUID()}`;
|
|
151
|
+
const recoverySupportId = `rcv-${randomUUID()}`;
|
|
152
|
+
let manifest = null;
|
|
153
|
+
let manifestSha256 = null;
|
|
154
|
+
let allowedPaths = [];
|
|
155
|
+
if (workspaceMode === "snapshot") {
|
|
156
|
+
const rawPath = manifestPath ? manifestPath.trim() : "";
|
|
157
|
+
if (!rawPath) {
|
|
158
|
+
fail("missing_manifest_path", 'workspaceMode \u4E3A "snapshot" \u65F6\u5FC5\u987B\u63D0\u4F9B manifest \u6587\u4EF6\u8DEF\u5F84');
|
|
159
|
+
}
|
|
160
|
+
const resolvedManifestPath = resolve(rawPath);
|
|
161
|
+
let rawText = "";
|
|
162
|
+
try {
|
|
163
|
+
const reader = options.readTextFile ?? ((p) => readFileSync(p, "utf8"));
|
|
164
|
+
rawText = reader(resolvedManifestPath);
|
|
165
|
+
} catch (err) {
|
|
166
|
+
fail(
|
|
167
|
+
"manifest_read_failed",
|
|
168
|
+
`\u8BFB\u53D6 manifest \u6587\u4EF6\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
let parsedManifest;
|
|
172
|
+
try {
|
|
173
|
+
parsedManifest = JSON.parse(rawText);
|
|
174
|
+
} catch (err) {
|
|
175
|
+
fail(
|
|
176
|
+
"invalid_manifest_json",
|
|
177
|
+
`manifest \u6587\u4EF6 JSON \u89E3\u6790\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
manifestSha256 = hashInstaboxDeliveryManifest(parsedManifest);
|
|
182
|
+
validateInstaboxWorkspaceSelection({
|
|
183
|
+
workspaceMode: "approved-snapshot",
|
|
184
|
+
manifest: parsedManifest,
|
|
185
|
+
approval: {
|
|
186
|
+
id: approvalId,
|
|
187
|
+
manifestSha256
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
} catch (err) {
|
|
191
|
+
fail(
|
|
192
|
+
"invalid_manifest_selection",
|
|
193
|
+
`manifest \u6821\u9A8C\u672A\u901A\u8FC7: ${err instanceof Error ? err.message : String(err)}`
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
manifest = parsedManifest;
|
|
197
|
+
allowedPaths = parsedManifest.files.map((f) => f.path);
|
|
198
|
+
} else {
|
|
199
|
+
if (manifestPath && manifestPath.trim()) {
|
|
200
|
+
fail("unexpected_manifest", 'workspaceMode \u4E3A "empty" \u65F6\u4E0D\u5F97\u63D0\u4F9B manifest');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const rawBillingPolicy = options.billingPolicy ?? (options.allowPaid ? "allow-paid" : "free-only");
|
|
204
|
+
if (!isInstaboxBillingPolicy(rawBillingPolicy)) {
|
|
205
|
+
fail("invalid_billing_policy", `billingPolicy \u5FC5\u987B\u4E3A "free-only" \u6216 "allow-paid"\uFF0C\u6536\u5230 "${rawBillingPolicy}"`);
|
|
206
|
+
}
|
|
207
|
+
const billingPolicy = rawBillingPolicy;
|
|
208
|
+
const env = options.env ?? process.env;
|
|
209
|
+
const isPaid = options.isPaidAccount === true || options.account?.isPaid === true || options.account?.kind === "paid" || options.account?.accountKind === "paid" || env?.INSTABOX_ACCOUNT_KIND === "paid" || env?.INSTABOX_ACCOUNT_TYPE === "paid" || env?.INSTABOX_PAID_ACCOUNT === "true" || env?.INSTABOX_PAID_ACCOUNT === "1";
|
|
210
|
+
if (isPaid && billingPolicy !== "allow-paid") {
|
|
211
|
+
fail("paid_account_disallowed", "\u4ED8\u8D39 Instabox \u8D26\u53F7\u9700\u663E\u5F0F --instabox-allow-paid");
|
|
212
|
+
}
|
|
213
|
+
const config = {
|
|
214
|
+
bindingId,
|
|
215
|
+
freeCreateEvidenceId,
|
|
216
|
+
workspaceAuthorizationId,
|
|
217
|
+
recoverySupportId,
|
|
218
|
+
workspaceMode: workspaceMode === "snapshot" ? "approved-snapshot" : "empty",
|
|
219
|
+
billingPolicy,
|
|
220
|
+
approvalId,
|
|
221
|
+
artifactRoot: trimmedArtifactDir,
|
|
222
|
+
allowRemoteRelease: Boolean(allowRemoteRelease),
|
|
223
|
+
allowedPaths
|
|
224
|
+
};
|
|
225
|
+
if (workspaceMode === "snapshot" && manifest && manifestSha256) {
|
|
226
|
+
config.manifest = manifest;
|
|
227
|
+
config.manifestSha256 = manifestSha256;
|
|
228
|
+
}
|
|
229
|
+
const runsDir = options.runsDir ?? resolveRunsDir(env);
|
|
230
|
+
const normalizedRunsDir = normalize(resolve(runsDir));
|
|
231
|
+
try {
|
|
232
|
+
mkdirSync(normalizedRunsDir, { recursive: true, mode: 448 });
|
|
233
|
+
} catch (err) {
|
|
234
|
+
fail("mkdir_failed", `\u521B\u5EFA runs \u76EE\u5F55\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
235
|
+
}
|
|
236
|
+
const fileName = `instabox-run-${randomUUID()}.json`;
|
|
237
|
+
const targetPath = join(normalizedRunsDir, fileName);
|
|
238
|
+
try {
|
|
239
|
+
writeFileSync(targetPath, JSON.stringify(config, null, 2), {
|
|
240
|
+
flag: "wx",
|
|
241
|
+
mode: 384
|
|
242
|
+
});
|
|
243
|
+
} catch (err) {
|
|
244
|
+
fail("file_write_failed", `\u72EC\u5360\u521B\u5EFA\u53D7\u63A7\u914D\u7F6E\u6587\u4EF6\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
const stats = lstatSync(targetPath);
|
|
248
|
+
if (stats.isSymbolicLink() || !stats.isFile()) {
|
|
249
|
+
fail("symlink_rejected", `\u914D\u7F6E\u6587\u4EF6\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\u6216\u975E\u5E38\u89C4\u6587\u4EF6: ${targetPath}`);
|
|
250
|
+
}
|
|
251
|
+
} catch (err) {
|
|
252
|
+
if (err instanceof InstaboxRunConfigWriteError) throw err;
|
|
253
|
+
fail("file_stat_failed", `\u68C0\u9A8C\u914D\u7F6E\u6587\u4EF6\u72B6\u6001\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
254
|
+
}
|
|
255
|
+
process.env[INSTABOX_RUN_CONFIG_ENV] = targetPath;
|
|
256
|
+
if (options.env) {
|
|
257
|
+
options.env[INSTABOX_RUN_CONFIG_ENV] = targetPath;
|
|
258
|
+
}
|
|
259
|
+
return { configPath: targetPath, config };
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// packages/cli/client/terminalProgramStatus.ts
|
|
263
|
+
var TERMINAL_PROGRAM_STATUS_APP = "nolo";
|
|
264
|
+
var KNOWN_STATES = /* @__PURE__ */ new Set([
|
|
265
|
+
"idle",
|
|
266
|
+
"working",
|
|
267
|
+
"blocked",
|
|
268
|
+
"done",
|
|
269
|
+
"error"
|
|
270
|
+
]);
|
|
271
|
+
var KNOWN_KINDS = /* @__PURE__ */ new Set([
|
|
272
|
+
"permission",
|
|
273
|
+
"question",
|
|
274
|
+
"auth"
|
|
275
|
+
]);
|
|
276
|
+
function encodeTerminalProgramStatus(report) {
|
|
277
|
+
const state = report?.state;
|
|
278
|
+
if (typeof state !== "string" || !KNOWN_STATES.has(state)) return null;
|
|
279
|
+
const pairs = [`state=${state}`, `app=${TERMINAL_PROGRAM_STATUS_APP}`];
|
|
280
|
+
if (state === "blocked" && typeof report.kind === "string" && KNOWN_KINDS.has(report.kind)) {
|
|
281
|
+
pairs.push(`kind=${report.kind}`);
|
|
282
|
+
}
|
|
283
|
+
return `\x1B]7501;${pairs.join(":")}\x1B\\`;
|
|
284
|
+
}
|
|
285
|
+
function emitTerminalProgramStatus(output, report) {
|
|
286
|
+
if (!output || typeof output.write !== "function") return false;
|
|
287
|
+
if (output.isTTY !== true) return false;
|
|
288
|
+
const sequence = encodeTerminalProgramStatus(report);
|
|
289
|
+
if (sequence === null) return false;
|
|
290
|
+
try {
|
|
291
|
+
output.write(sequence);
|
|
292
|
+
return true;
|
|
293
|
+
} catch {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// packages/cli/client/terminalRunStatus.ts
|
|
299
|
+
var FAILED_EMPTY_ASSISTANT_REASONS = /* @__PURE__ */ new Set([
|
|
300
|
+
"length_truncated",
|
|
301
|
+
"stream_truncated",
|
|
302
|
+
"repetition_loop",
|
|
303
|
+
"stagnant_tool_calls"
|
|
304
|
+
]);
|
|
305
|
+
var isRunResultStalledOrTruncated = (result) => !result.emptyAssistantOutputUsable && FAILED_EMPTY_ASSISTANT_REASONS.has(result.emptyAssistantFallbackReason ?? "");
|
|
306
|
+
function resolveTerminalProgramStatusState(input) {
|
|
307
|
+
if (input.interrupted) return "idle";
|
|
308
|
+
if (input.stalledOrTruncated || input.exitCode !== 0) return "error";
|
|
309
|
+
return "done";
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// packages/cli/client/oneShotTerminalStatus.ts
|
|
313
|
+
function resolveOneShotTerminalState(result) {
|
|
314
|
+
return resolveTerminalProgramStatusState({
|
|
315
|
+
exitCode: result.exitCode,
|
|
316
|
+
interrupted: result.streamInterrupted,
|
|
317
|
+
stalledOrTruncated: result.stalledOrTruncated
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
function createOneShotTerminalStatus(output) {
|
|
321
|
+
let last;
|
|
322
|
+
let terminal = false;
|
|
323
|
+
const report = (state) => {
|
|
324
|
+
if (!output || terminal || last === state) return;
|
|
325
|
+
last = state;
|
|
326
|
+
if (state === "done" || state === "error") terminal = true;
|
|
327
|
+
emitTerminalProgramStatus(output, { state });
|
|
328
|
+
};
|
|
329
|
+
return {
|
|
330
|
+
working: () => report("working"),
|
|
331
|
+
settle: (result) => report(resolveOneShotTerminalState(result)),
|
|
332
|
+
fail: () => report("error")
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// packages/cli/agentRunCommand.ts
|
|
337
|
+
import * as nodeFs from "node:fs";
|
|
338
|
+
|
|
339
|
+
// packages/cli/client/autoModelRouter.ts
|
|
340
|
+
var CLI_AUTO_ROUTE_AGENT_KEY = BUILTIN_NOLO_AGENT_KEY;
|
|
341
|
+
|
|
342
|
+
// packages/agent-runtime/hostEnvironment.ts
|
|
343
|
+
import { existsSync, readFileSync as readFileSync2 } from "node:fs";
|
|
344
|
+
import os from "node:os";
|
|
345
|
+
function parseLinuxOsRelease(content) {
|
|
346
|
+
let prettyName;
|
|
347
|
+
let name;
|
|
348
|
+
let version;
|
|
349
|
+
for (const line of content.split("\n")) {
|
|
350
|
+
const trimmed = line.trim();
|
|
351
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
352
|
+
const eqIdx = trimmed.indexOf("=");
|
|
353
|
+
if (eqIdx === -1) continue;
|
|
354
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
355
|
+
let val = trimmed.slice(eqIdx + 1).trim();
|
|
356
|
+
if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
|
|
357
|
+
val = val.slice(1, -1);
|
|
358
|
+
}
|
|
359
|
+
if (key === "PRETTY_NAME") {
|
|
360
|
+
prettyName = val;
|
|
361
|
+
} else if (key === "NAME") {
|
|
362
|
+
name = val;
|
|
363
|
+
} else if (key === "VERSION") {
|
|
364
|
+
version = val;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (prettyName) return prettyName;
|
|
368
|
+
if (name && version) return `${name} ${version}`;
|
|
369
|
+
return name;
|
|
370
|
+
}
|
|
371
|
+
function probeHostEnvironment(options) {
|
|
372
|
+
const platform = options?.platform ?? process.platform;
|
|
373
|
+
const arch = options?.arch ?? os.arch();
|
|
374
|
+
const release = options?.release ?? os.release();
|
|
375
|
+
const env = options?.env ?? process.env;
|
|
376
|
+
let osName = `${platform} ${release}`;
|
|
377
|
+
if (platform === "linux") {
|
|
378
|
+
let osReleaseText = options?.osReleaseContent;
|
|
379
|
+
if (osReleaseText === void 0) {
|
|
380
|
+
try {
|
|
381
|
+
if (existsSync("/etc/os-release")) {
|
|
382
|
+
osReleaseText = readFileSync2("/etc/os-release", "utf8");
|
|
383
|
+
} else if (existsSync("/usr/lib/os-release")) {
|
|
384
|
+
osReleaseText = readFileSync2("/usr/lib/os-release", "utf8");
|
|
385
|
+
}
|
|
386
|
+
} catch {
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
if (osReleaseText) {
|
|
390
|
+
const parsed = parseLinuxOsRelease(osReleaseText);
|
|
391
|
+
if (parsed) {
|
|
392
|
+
osName = parsed;
|
|
393
|
+
} else {
|
|
394
|
+
osName = `Linux ${release}`;
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
osName = `Linux ${release}`;
|
|
398
|
+
}
|
|
399
|
+
} else if (platform === "darwin") {
|
|
400
|
+
osName = `macOS (${release})`;
|
|
401
|
+
} else if (platform === "win32") {
|
|
402
|
+
osName = `Windows (${release})`;
|
|
403
|
+
}
|
|
404
|
+
const desktop = env.XDG_CURRENT_DESKTOP || env.XDG_SESSION_DESKTOP || env.DESKTOP_SESSION || void 0;
|
|
405
|
+
const sessionType = env.XDG_SESSION_TYPE || void 0;
|
|
406
|
+
const shell = env.SHELL || (platform === "win32" ? env.COMSPEC || "PowerShell" : void 0);
|
|
407
|
+
return {
|
|
408
|
+
platform,
|
|
409
|
+
osName,
|
|
410
|
+
arch,
|
|
411
|
+
desktop,
|
|
412
|
+
sessionType,
|
|
413
|
+
shell
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
function formatHostEnvironmentContent(details) {
|
|
417
|
+
const lines = ["--- \u5BBF\u4E3B\u73AF\u5883\uFF08Host Environment\uFF09---"];
|
|
418
|
+
lines.push(`\u64CD\u4F5C\u7CFB\u7EDF: ${details.osName} (${details.arch})`);
|
|
419
|
+
if (details.desktop || details.sessionType) {
|
|
420
|
+
const desktopParts = [];
|
|
421
|
+
if (details.desktop) desktopParts.push(details.desktop);
|
|
422
|
+
if (details.sessionType) desktopParts.push(details.sessionType);
|
|
423
|
+
lines.push(`\u684C\u9762\u73AF\u5883: ${desktopParts.join(" / ")}`);
|
|
424
|
+
}
|
|
425
|
+
if (details.shell) {
|
|
426
|
+
lines.push(`\u9ED8\u8BA4 Shell: ${details.shell}`);
|
|
427
|
+
}
|
|
428
|
+
return lines.join("\n");
|
|
429
|
+
}
|
|
430
|
+
var cachedLayer = null;
|
|
431
|
+
function buildHostEnvironmentLayer(options) {
|
|
432
|
+
if (!options && cachedLayer) {
|
|
433
|
+
return cachedLayer;
|
|
434
|
+
}
|
|
435
|
+
const details = probeHostEnvironment(options);
|
|
436
|
+
const content = formatHostEnvironmentContent(details);
|
|
437
|
+
const layer = {
|
|
438
|
+
id: "host-environment",
|
|
439
|
+
owner: "runtime",
|
|
440
|
+
cacheScope: "session",
|
|
441
|
+
content
|
|
442
|
+
};
|
|
443
|
+
if (!options) {
|
|
444
|
+
cachedLayer = layer;
|
|
445
|
+
}
|
|
446
|
+
return layer;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// packages/ai/token/cacheRunSummary.ts
|
|
450
|
+
var finiteCount = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : void 0;
|
|
451
|
+
var isUsageObject = (usage) => Boolean(usage) && typeof usage === "object";
|
|
452
|
+
var readInputTokens = (usage) => finiteCount(usage.input_tokens) ?? finiteCount(usage.prompt_tokens) ?? 0;
|
|
453
|
+
var readOutputTokens = (usage) => finiteCount(usage.output_tokens) ?? finiteCount(usage.completion_tokens);
|
|
454
|
+
var computeCacheHitRatio = (inputTokens, cachedTokens) => {
|
|
455
|
+
if (cachedTokens === null) return null;
|
|
456
|
+
if (!Number.isFinite(inputTokens) || inputTokens <= 0) return 0;
|
|
457
|
+
return Math.round(cachedTokens / inputTokens * 1e4) / 1e4;
|
|
458
|
+
};
|
|
459
|
+
var withRatio = (inputTokens, cachedTokens, outputTokens) => ({
|
|
460
|
+
input_tokens: inputTokens,
|
|
461
|
+
cached_tokens: cachedTokens,
|
|
462
|
+
cache_hit_ratio: computeCacheHitRatio(inputTokens, cachedTokens),
|
|
463
|
+
...typeof outputTokens === "number" && Number.isFinite(outputTokens) ? { output_tokens: Math.max(0, Math.floor(outputTokens)) } : {}
|
|
464
|
+
});
|
|
465
|
+
var summarizeCacheUsage = (usage) => {
|
|
466
|
+
if (!isUsageObject(usage)) return void 0;
|
|
467
|
+
if (Object.keys(usage).length === 0) return void 0;
|
|
468
|
+
return withRatio(
|
|
469
|
+
readInputTokens(usage),
|
|
470
|
+
readCacheReadInputTokensOrNull(usage),
|
|
471
|
+
readOutputTokens(usage)
|
|
472
|
+
);
|
|
473
|
+
};
|
|
474
|
+
var summarizeCacheUsageRecords = (records) => {
|
|
475
|
+
if (!records || records.length === 0) return void 0;
|
|
476
|
+
let inputTokens = 0;
|
|
477
|
+
let cachedTokens = 0;
|
|
478
|
+
let outputTokens = 0;
|
|
479
|
+
let sawOutput = false;
|
|
480
|
+
let sawUsage = false;
|
|
481
|
+
for (const record of records) {
|
|
482
|
+
const summary = summarizeCacheUsage(record?.usage);
|
|
483
|
+
if (!summary) continue;
|
|
484
|
+
sawUsage = true;
|
|
485
|
+
inputTokens += summary.input_tokens;
|
|
486
|
+
cachedTokens = cachedTokens === null || summary.cached_tokens === null ? null : cachedTokens + summary.cached_tokens;
|
|
487
|
+
if (typeof summary.output_tokens === "number") {
|
|
488
|
+
sawOutput = true;
|
|
489
|
+
outputTokens += summary.output_tokens;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (!sawUsage) return void 0;
|
|
493
|
+
return withRatio(inputTokens, cachedTokens, sawOutput ? outputTokens : void 0);
|
|
494
|
+
};
|
|
495
|
+
var mergeCacheUsageSummaries = (left, right) => {
|
|
496
|
+
if (!left) return right;
|
|
497
|
+
if (!right) return left;
|
|
498
|
+
const inputTokens = left.input_tokens + right.input_tokens;
|
|
499
|
+
const cachedTokens = left.cached_tokens === null || right.cached_tokens === null ? null : left.cached_tokens + right.cached_tokens;
|
|
500
|
+
const outputTokens = typeof left.output_tokens === "number" && typeof right.output_tokens === "number" ? left.output_tokens + right.output_tokens : typeof left.output_tokens === "number" ? left.output_tokens : right.output_tokens;
|
|
501
|
+
return withRatio(inputTokens, cachedTokens, outputTokens);
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
// packages/cli/agentRunDoD.ts
|
|
505
|
+
import { spawnSync as nodeSpawnSync } from "node:child_process";
|
|
506
|
+
var DOD_COMMAND_TIMEOUT_MS = 12e4;
|
|
507
|
+
function extractTailLines(text, count) {
|
|
508
|
+
if (!text) return [];
|
|
509
|
+
const lines = String(text).split("\n");
|
|
510
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === "") lines.pop();
|
|
511
|
+
return lines.slice(-count);
|
|
512
|
+
}
|
|
513
|
+
function executeDoDCommand(cmd, cwd, deps = {}) {
|
|
514
|
+
const spawnSync = deps.spawnSync ?? nodeSpawnSync;
|
|
515
|
+
try {
|
|
516
|
+
const res = spawnSync(cmd, {
|
|
517
|
+
shell: true,
|
|
518
|
+
windowsHide: true,
|
|
519
|
+
cwd: cwd || process.cwd(),
|
|
520
|
+
env: workspaceChildEnv(deps.env),
|
|
521
|
+
timeout: DOD_COMMAND_TIMEOUT_MS,
|
|
522
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
523
|
+
encoding: "utf8"
|
|
524
|
+
});
|
|
525
|
+
if (res.error) {
|
|
526
|
+
const errCode = res.error.code;
|
|
527
|
+
const timedOut = errCode === "ETIMEDOUT" || res.signal === "SIGTERM" || res.signal === "SIGKILL";
|
|
528
|
+
return {
|
|
529
|
+
command: cmd,
|
|
530
|
+
exitCode: timedOut ? "timeout" : "error",
|
|
531
|
+
stdoutTail: extractTailLines(res.stdout, 20),
|
|
532
|
+
stderrTail: extractTailLines(res.stderr || res.error.message, 10)
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
if (res.status === null && (res.signal === "SIGTERM" || res.signal === "SIGKILL")) {
|
|
536
|
+
return {
|
|
537
|
+
command: cmd,
|
|
538
|
+
exitCode: "timeout",
|
|
539
|
+
stdoutTail: extractTailLines(res.stdout, 20),
|
|
540
|
+
stderrTail: extractTailLines(res.stderr, 10)
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
return {
|
|
544
|
+
command: cmd,
|
|
545
|
+
exitCode: typeof res.status === "number" ? res.status : "error",
|
|
546
|
+
stdoutTail: extractTailLines(res.stdout, 20),
|
|
547
|
+
stderrTail: extractTailLines(res.stderr, 10)
|
|
548
|
+
};
|
|
549
|
+
} catch (err) {
|
|
550
|
+
return {
|
|
551
|
+
command: cmd,
|
|
552
|
+
exitCode: "error",
|
|
553
|
+
stdoutTail: [],
|
|
554
|
+
stderrTail: extractTailLines(err instanceof Error ? err.message : String(err), 10)
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
function runDoDCommands(commands, cwd, deps = {}) {
|
|
559
|
+
if (!commands || commands.length === 0) return void 0;
|
|
560
|
+
return commands.map((cmd) => executeDoDCommand(cmd, cwd, deps));
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// packages/cli/agentRunPrompts.ts
|
|
564
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3, readdirSync, statSync } from "node:fs";
|
|
565
|
+
import { dirname, extname, isAbsolute as isAbsolute2, join as join2, relative as relativePath, resolve as resolve2, sep } from "node:path";
|
|
566
|
+
function workflowRefToCandidatePath(cwd, ref) {
|
|
567
|
+
const normalized = ref.trim();
|
|
568
|
+
if (!normalized) return "";
|
|
569
|
+
if (normalized.endsWith(".md") || normalized.includes("/") || normalized.includes("\\")) {
|
|
570
|
+
const directPath = resolve2(cwd, normalized);
|
|
571
|
+
if (existsSync2(directPath)) return directPath;
|
|
572
|
+
}
|
|
573
|
+
const fileName = normalized.replace(/[^a-zA-Z0-9一-鿿]+/g, "-").replace(/^-+|-+$/g, "");
|
|
574
|
+
return resolve2(cwd, "docs", "workflows", `${fileName}.md`);
|
|
575
|
+
}
|
|
576
|
+
var SKILL_SEARCH_DIRS = [
|
|
577
|
+
".agents/skills"
|
|
578
|
+
];
|
|
579
|
+
function skillRefToCandidatePath(cwd, ref) {
|
|
580
|
+
const normalized = ref.trim();
|
|
581
|
+
if (!normalized) return "";
|
|
582
|
+
if (normalized.endsWith(".md") || normalized.includes("/") || normalized.includes("\\")) {
|
|
583
|
+
const directPath = resolve2(cwd, normalized);
|
|
584
|
+
if (existsSync2(directPath)) return directPath;
|
|
585
|
+
}
|
|
586
|
+
const fileName = normalized.replace(/[^a-zA-Z0-9一-鿿]+/g, "-").replace(/^-+|-+$/g, "");
|
|
587
|
+
for (const dir of SKILL_SEARCH_DIRS) {
|
|
588
|
+
const skillMdPath = resolve2(cwd, dir, fileName, "SKILL.md");
|
|
589
|
+
if (existsSync2(skillMdPath)) return skillMdPath;
|
|
590
|
+
}
|
|
591
|
+
return resolve2(cwd, ".agents", "skills", fileName, "SKILL.md");
|
|
592
|
+
}
|
|
593
|
+
async function resolveWorkflowReference(ref, cwd = process.cwd()) {
|
|
594
|
+
const path = workflowRefToCandidatePath(cwd, ref);
|
|
595
|
+
if (!path || !existsSync2(path)) {
|
|
596
|
+
throw new Error(`Workflow reference not found: ${ref}`);
|
|
597
|
+
}
|
|
598
|
+
const markdown = readFileSync3(path, "utf8");
|
|
599
|
+
const parsed = parseSkillDocProtocol(markdown);
|
|
600
|
+
return {
|
|
601
|
+
ref,
|
|
602
|
+
content: parsed.content,
|
|
603
|
+
...parsed.meta?.workflowConfig ? { config: parsed.meta.workflowConfig } : {}
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
function inlineRelativeRefs(body, skillDir) {
|
|
607
|
+
const refPattern = /\[([^\]]+)\]\((\.\/[^)]+|[^)]+\/[^)]+)\)/g;
|
|
608
|
+
const normalizedSkillDir = resolve2(skillDir) + sep;
|
|
609
|
+
return body.replace(refPattern, (match, label, relPath) => {
|
|
610
|
+
const cleaned = relPath.trim();
|
|
611
|
+
if (!cleaned.startsWith("./") && !cleaned.startsWith("../")) return match;
|
|
612
|
+
const absPath = resolve2(skillDir, cleaned);
|
|
613
|
+
const relative = relativePath(normalizedSkillDir, absPath);
|
|
614
|
+
if (relative.startsWith("..") || isAbsolute2(relative)) return match;
|
|
615
|
+
if (!existsSync2(absPath) || !absPath.endsWith(".md")) return match;
|
|
616
|
+
const refContent = readFileSync3(absPath, "utf8");
|
|
617
|
+
return `
|
|
618
|
+
|
|
619
|
+
### ${label}
|
|
620
|
+
|
|
621
|
+
${refContent}
|
|
622
|
+
|
|
623
|
+
`;
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
function listSkillScripts(skillDir) {
|
|
627
|
+
const scriptsDir = join2(skillDir, "scripts");
|
|
628
|
+
if (!existsSync2(scriptsDir) || !statSync(scriptsDir).isDirectory()) return null;
|
|
629
|
+
const entries = readdirSync(scriptsDir).filter((e) => !e.startsWith("."));
|
|
630
|
+
if (entries.length === 0) return null;
|
|
631
|
+
return [
|
|
632
|
+
"",
|
|
633
|
+
"--- Available scripts (use execShell/readFile to access) ---",
|
|
634
|
+
...entries.map((e) => `- scripts/${e}`)
|
|
635
|
+
].join("\n");
|
|
636
|
+
}
|
|
637
|
+
async function resolveSkillReference(ref, options = {}) {
|
|
638
|
+
const isDbKey = /^(page|doc)-[0-9a-z]+-/i.test(ref);
|
|
639
|
+
let markdown = "";
|
|
640
|
+
let skillDir;
|
|
641
|
+
let filePath;
|
|
642
|
+
if (isDbKey) {
|
|
643
|
+
if (!options.readDbRecord) {
|
|
644
|
+
throw new Error("skill dbKey requires server access");
|
|
645
|
+
}
|
|
646
|
+
const record = await options.readDbRecord(ref);
|
|
647
|
+
const contentText = record?.content ?? record?.prompt ?? record?.text;
|
|
648
|
+
if (contentText === void 0 || contentText === null || contentText === "") {
|
|
649
|
+
throw new Error(`Skill reference has no content: ${ref}`);
|
|
650
|
+
}
|
|
651
|
+
markdown = String(contentText);
|
|
652
|
+
} else {
|
|
653
|
+
const cwd = options.cwd ?? process.cwd();
|
|
654
|
+
const path = skillRefToCandidatePath(cwd, ref);
|
|
655
|
+
if (!path || !existsSync2(path)) {
|
|
656
|
+
throw new Error(`Skill reference not found: ${ref}`);
|
|
657
|
+
}
|
|
658
|
+
markdown = readFileSync3(path, "utf8");
|
|
659
|
+
filePath = path;
|
|
660
|
+
skillDir = dirname(path);
|
|
661
|
+
}
|
|
662
|
+
const parsed = parseSkillDocProtocol(markdown);
|
|
663
|
+
const name = parsed.meta?.skillConfig?.name;
|
|
664
|
+
const promptPatch = parsed.meta?.skillConfig?.promptPatch;
|
|
665
|
+
const externalParsed = parseExternalSkillMarkdown(markdown);
|
|
666
|
+
const allowedTools = externalParsed.allowedTools;
|
|
667
|
+
const effectiveName = name ?? externalParsed.name;
|
|
668
|
+
let effectiveContent = parsed.content;
|
|
669
|
+
if (skillDir) {
|
|
670
|
+
effectiveContent = inlineRelativeRefs(effectiveContent, skillDir);
|
|
671
|
+
const scriptsHint = listSkillScripts(skillDir);
|
|
672
|
+
if (scriptsHint) effectiveContent += scriptsHint;
|
|
673
|
+
}
|
|
674
|
+
return {
|
|
675
|
+
ref,
|
|
676
|
+
content: effectiveContent,
|
|
677
|
+
...effectiveName ? { name: effectiveName } : {},
|
|
678
|
+
...promptPatch ? { promptPatch } : {},
|
|
679
|
+
...allowedTools && allowedTools.length > 0 ? { allowedTools } : {},
|
|
680
|
+
...skillDir ? { skillDir } : {}
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
function buildSkillContextBlocks(skills) {
|
|
684
|
+
if (!skills || !skills.length) return [];
|
|
685
|
+
const seen = /* @__PURE__ */ new Set();
|
|
686
|
+
const blocks = [];
|
|
687
|
+
for (const skill of skills) {
|
|
688
|
+
const dedupKey = skill.name ?? skill.ref;
|
|
689
|
+
if (seen.has(dedupKey)) continue;
|
|
690
|
+
seen.add(dedupKey);
|
|
691
|
+
const header = `## ${dedupKey}`;
|
|
692
|
+
const patch = skill.promptPatch ? `${skill.promptPatch}
|
|
693
|
+
` : "";
|
|
694
|
+
blocks.push(`${header}
|
|
695
|
+
${patch}${skill.content}`);
|
|
696
|
+
}
|
|
697
|
+
return blocks;
|
|
698
|
+
}
|
|
699
|
+
var OUTPUT_FORMAT_GUIDANCE = [
|
|
700
|
+
"Output format guidance:",
|
|
701
|
+
"- Use semantic Markdown by default.",
|
|
702
|
+
"- Use tables for genuinely multi-column structured data.",
|
|
703
|
+
"- Use $...$ or $$...$$ for mathematical expressions.",
|
|
704
|
+
"- Use ```mermaid fenced blocks for process flows, sequences, state transitions, class/entity relations and architecture \u2014 they render as diagrams; skip when a sentence or list explains it better.",
|
|
705
|
+
"- Use language-tagged fenced blocks for code.",
|
|
706
|
+
"- Do not add tables or Mermaid for decoration; when complex syntax is uncertain, prefer plain Markdown or text.",
|
|
707
|
+
""
|
|
708
|
+
].join("\n");
|
|
709
|
+
function prependOutputFormatGuidance(message) {
|
|
710
|
+
if (message.startsWith(OUTPUT_FORMAT_GUIDANCE)) return message;
|
|
711
|
+
return `${OUTPUT_FORMAT_GUIDANCE}${message}`;
|
|
712
|
+
}
|
|
713
|
+
function prependWorkflowReferencePrompt(message, workflow) {
|
|
714
|
+
if (!workflow) return message;
|
|
715
|
+
const config = workflow.config;
|
|
716
|
+
return [
|
|
717
|
+
"AI-native workflow reference:",
|
|
718
|
+
"- This reference is guidance for the agent, not a central workflow engine.",
|
|
719
|
+
`- ref: ${workflow.ref}`,
|
|
720
|
+
...config?.id ? [`- id: ${config.id}`] : [],
|
|
721
|
+
...config?.name ? [`- name: ${config.name}`] : [],
|
|
722
|
+
...config?.defaultAgent ? [`- suggested defaultAgent: ${config.defaultAgent}`] : [],
|
|
723
|
+
...config?.inputs?.length ? [`- inputs: ${config.inputs.join(", ")}`] : [],
|
|
724
|
+
...config?.recommendedTools?.length ? [`- recommendedTools: ${config.recommendedTools.join(", ")}`] : [],
|
|
725
|
+
...config?.requiredTools?.length ? [`- requiredTools: ${config.requiredTools.join(", ")}`] : [],
|
|
726
|
+
...config?.requiredOutputs?.length ? [`- requiredOutputs: ${config.requiredOutputs.join(", ")}`] : [],
|
|
727
|
+
...config?.gates?.length ? [`- gates: ${config.gates.join(", ")}`] : [],
|
|
728
|
+
...config?.contextStrategy ? [`- contextStrategy: ${config.contextStrategy}`] : [],
|
|
729
|
+
...config?.failureProtocol ? [`- failureProtocol: ${config.failureProtocol}`] : [],
|
|
730
|
+
"",
|
|
731
|
+
"Reference body:",
|
|
732
|
+
workflow.content,
|
|
733
|
+
"",
|
|
734
|
+
"User task:",
|
|
735
|
+
message
|
|
736
|
+
].join("\n");
|
|
737
|
+
}
|
|
738
|
+
function prependFeatureWorktreeInstruction(message, enabled) {
|
|
739
|
+
if (!enabled) return message;
|
|
740
|
+
return [
|
|
741
|
+
"Local execution rule:",
|
|
742
|
+
"- You are running in the current git checkout with shell access.",
|
|
743
|
+
"- For read-only checks, smoke tests, or answering questions, stay in the current directory.",
|
|
744
|
+
"- Before developing a new feature or making non-trivial code changes, create a separate git worktree yourself with git worktree and do the edits there.",
|
|
745
|
+
"- Commit and push only when the user explicitly asks or the task requires it.",
|
|
746
|
+
"",
|
|
747
|
+
"User task:",
|
|
748
|
+
message
|
|
749
|
+
].join("\n");
|
|
750
|
+
}
|
|
751
|
+
function prependSubjectDialogMarker(message, subjectDialogKey) {
|
|
752
|
+
if (!subjectDialogKey) return message;
|
|
753
|
+
return [
|
|
754
|
+
`Subject dialog for this run: ${subjectDialogKey}`,
|
|
755
|
+
"If the user asks to evaluate the referenced dialog, call readDialog with this id/key first.",
|
|
756
|
+
"",
|
|
757
|
+
message
|
|
758
|
+
].join("\n");
|
|
759
|
+
}
|
|
760
|
+
function normalizeCliImageInput(input) {
|
|
761
|
+
if (/^(https?:|data:|file:)/i.test(input)) return input;
|
|
762
|
+
const absolutePath = resolve2(input);
|
|
763
|
+
if (!existsSync2(absolutePath)) return input;
|
|
764
|
+
const base64 = readFileSync3(absolutePath).toString("base64");
|
|
765
|
+
return `data:${imageMimeTypeForPath(absolutePath)};base64,${base64}`;
|
|
766
|
+
}
|
|
767
|
+
function imageMimeTypeForPath(path) {
|
|
768
|
+
switch (extname(path).toLowerCase()) {
|
|
769
|
+
case ".jpg":
|
|
770
|
+
case ".jpeg":
|
|
771
|
+
return "image/jpeg";
|
|
772
|
+
case ".webp":
|
|
773
|
+
return "image/webp";
|
|
774
|
+
case ".gif":
|
|
775
|
+
return "image/gif";
|
|
776
|
+
default:
|
|
777
|
+
return "image/png";
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// packages/cli/agentRunCommand.ts
|
|
782
|
+
function resolvePositiveMs(value, fallback) {
|
|
783
|
+
return parsePositiveFiniteNumberOrFallback(value, fallback);
|
|
784
|
+
}
|
|
785
|
+
function resolveRunOutcome(input) {
|
|
786
|
+
switch (input.kind) {
|
|
787
|
+
case "stall":
|
|
788
|
+
return { status: "failed", exitCode: 1 };
|
|
789
|
+
case "timeout":
|
|
790
|
+
return { status: "timeout", exitCode: 124 };
|
|
791
|
+
case "result": {
|
|
792
|
+
const failed = input.isStalledOrTruncated || input.exitCode !== 0;
|
|
793
|
+
if (!failed) {
|
|
794
|
+
return { status: "done", exitCode: 0 };
|
|
795
|
+
}
|
|
796
|
+
return { status: "failed", exitCode: input.exitCode !== 0 ? input.exitCode : 1 };
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
var resolveRunSettlementNote = (result) => {
|
|
801
|
+
const reason = result.emptyAssistantFallbackReason;
|
|
802
|
+
if (!reason || !FAILED_EMPTY_ASSISTANT_REASONS.has(reason)) return {};
|
|
803
|
+
if (result.emptyAssistantOutputUsable) {
|
|
804
|
+
return { note: `output complete but stream lacked finish frame: ${reason}` };
|
|
805
|
+
}
|
|
806
|
+
return { note: `empty assistant output: ${reason}` };
|
|
807
|
+
};
|
|
808
|
+
async function resolveAgentRunAgentKey(args) {
|
|
809
|
+
if (!args.agentInput.trim() || args.agentInput.startsWith("agent-")) {
|
|
810
|
+
return void 0;
|
|
811
|
+
}
|
|
812
|
+
const db = await getReadableCliDb(args.output);
|
|
813
|
+
const resolved = await resolveAgentRecordFromHybridStore({
|
|
814
|
+
agentInput: args.agentInput,
|
|
815
|
+
cliArgs: args.cliArgs,
|
|
816
|
+
env: args.env,
|
|
817
|
+
db,
|
|
818
|
+
fetchImpl: fetch
|
|
819
|
+
});
|
|
820
|
+
return resolved?.agentKey;
|
|
821
|
+
}
|
|
822
|
+
var MACHINE_SHELL_REQUESTED_POLICY = { runtimeTools: ["execShell"] };
|
|
823
|
+
async function resolveAgentBoundMachineIdFromRecord(args) {
|
|
824
|
+
const db = await getReadableCliDb(args.output);
|
|
825
|
+
const record = await resolveAgentRecordFromHybridStore({
|
|
826
|
+
agentInput: args.agentKey,
|
|
827
|
+
cliArgs: args.cliArgs,
|
|
828
|
+
env: args.env,
|
|
829
|
+
db,
|
|
830
|
+
fetchImpl: fetch
|
|
831
|
+
}).catch(() => null);
|
|
832
|
+
return resolveBoundMachineId(record) || void 0;
|
|
833
|
+
}
|
|
834
|
+
async function runAgentRunCommand(args, deps) {
|
|
835
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
836
|
+
writeUsage(deps.output ?? process.stdout, deps.commandPath);
|
|
837
|
+
return 0;
|
|
838
|
+
}
|
|
839
|
+
const env = deps.env ?? process.env;
|
|
840
|
+
const runId = env.NOLO_AGENT_RUN_ID;
|
|
841
|
+
const controlDeps = { env, homedir: deps.homedir, fs: deps.fs, now: deps.now };
|
|
842
|
+
const failStartup = async (error) => {
|
|
843
|
+
if (!runId) return;
|
|
844
|
+
const record = readRunRecord(runId, controlDeps);
|
|
845
|
+
if (record?.status !== "running" || record.pid != null && record.pid !== process.pid) return;
|
|
846
|
+
const result = await settleRunTerminalAuthoritatively(runId, {
|
|
847
|
+
status: "failed",
|
|
848
|
+
exitCode: 1,
|
|
849
|
+
failureReason: error instanceof RuntimeProtocolMismatchError ? "runtime_protocol_mismatch" : error instanceof RuntimeVersionMismatchError ? "runtime_version_mismatch" : "startup_failed",
|
|
850
|
+
note: error ? toErrorMessage(error) : "Child initialization returned without terminal result"
|
|
851
|
+
}, controlDeps, (id, update, d, opts) => transitionRunToTerminal(id, update, d, {
|
|
852
|
+
...opts?.expectedPid != null ? { expectedPid: opts.expectedPid } : {}
|
|
853
|
+
}), { expectedPid: process.pid });
|
|
854
|
+
if (result.kind === "contended") throw new Error(`Startup settlement lock busy: ${runId}`);
|
|
855
|
+
};
|
|
856
|
+
try {
|
|
857
|
+
if (runId) {
|
|
858
|
+
const record = readRunRecord(runId, controlDeps);
|
|
859
|
+
if (record?.pid != null && record.pid !== process.pid) throw new Error(`Run ${runId} belongs to PID ${record.pid}, not ${process.pid}`);
|
|
860
|
+
if (!record) throw new Error("[local-writer-resource] missing child binding");
|
|
861
|
+
await recordRunStartup(runId, "initializing", controlDeps);
|
|
862
|
+
validateAgentRunProtocol(env.NOLO_AGENT_RUN_PROTOCOL);
|
|
863
|
+
await recordRunStartup(runId, "protocol_validated", controlDeps);
|
|
864
|
+
}
|
|
865
|
+
const code = await runAgentRunCommandImpl(args, deps);
|
|
866
|
+
if (runId) await failStartup();
|
|
867
|
+
return code;
|
|
868
|
+
} catch (error) {
|
|
869
|
+
await failStartup(error);
|
|
870
|
+
throw error;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
async function runAgentRunCommandImpl(args, deps) {
|
|
874
|
+
const env = deps.env ?? process.env;
|
|
875
|
+
const output = deps.output ?? {
|
|
876
|
+
write: (chunk) => process.stdout.write(chunk),
|
|
877
|
+
writeErr: (chunk) => process.stderr.write(chunk)
|
|
878
|
+
};
|
|
879
|
+
let parsed;
|
|
880
|
+
try {
|
|
881
|
+
parsed = parseAgentRunArgs(args, { commandPath: deps.commandPath });
|
|
882
|
+
} catch (error) {
|
|
883
|
+
output.write(`[nolo] ${toErrorMessage(error)}
|
|
884
|
+
`);
|
|
885
|
+
return 1;
|
|
886
|
+
}
|
|
887
|
+
if (!parsed) {
|
|
888
|
+
writeUsage(output, deps.commandPath);
|
|
889
|
+
return 1;
|
|
890
|
+
}
|
|
891
|
+
const rawRunner = deps.runner ?? runAgentTurn;
|
|
892
|
+
let modelPhaseRecorded = false;
|
|
893
|
+
const watchdogAbort = new AbortController();
|
|
894
|
+
let activeRunner;
|
|
895
|
+
const runner = (options) => {
|
|
896
|
+
activeRunner = Promise.resolve().then(async () => {
|
|
897
|
+
if (env.NOLO_AGENT_RUN_ID && !modelPhaseRecorded) {
|
|
898
|
+
await recordRunStartup(env.NOLO_AGENT_RUN_ID, "model", { env, homedir: deps.homedir, fs: deps.fs, now: deps.now });
|
|
899
|
+
modelPhaseRecorded = true;
|
|
900
|
+
}
|
|
901
|
+
return rawRunner({ ...options, abortSignal: watchdogAbort.signal });
|
|
902
|
+
}).then((result) => {
|
|
903
|
+
watchdogAbort.signal.throwIfAborted();
|
|
904
|
+
return result;
|
|
905
|
+
});
|
|
906
|
+
return activeRunner;
|
|
907
|
+
};
|
|
908
|
+
const stopWatchdogRunner = async () => {
|
|
909
|
+
watchdogAbort.abort(new Error("watchdog_stop"));
|
|
910
|
+
if (!activeRunner) return true;
|
|
911
|
+
let timer;
|
|
912
|
+
try {
|
|
913
|
+
return await Promise.race([
|
|
914
|
+
activeRunner.then(() => true, () => true),
|
|
915
|
+
new Promise((resolve3) => {
|
|
916
|
+
timer = setTimeout(() => resolve3(false), 100);
|
|
917
|
+
})
|
|
918
|
+
]);
|
|
919
|
+
} finally {
|
|
920
|
+
if (timer) clearTimeout(timer);
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
const nowMs = () => deps.now ? deps.now().getTime() : Date.now();
|
|
924
|
+
let childRunId = env.NOLO_AGENT_RUN_ID;
|
|
925
|
+
let hasRegistry = typeof childRunId === "string" && childRunId.length > 0;
|
|
926
|
+
const hostPolicy = () => ({
|
|
927
|
+
runtimeKey: "local",
|
|
928
|
+
hostWritesAuthorized: args.includes("--allow-host-writes"),
|
|
929
|
+
readOnly: args.includes("--read-only"),
|
|
930
|
+
...parsed.allowedToolNames ? { allowedToolNames: parsed.allowedToolNames } : {},
|
|
931
|
+
...parsed.blockedToolNames ? { blockedToolNames: parsed.blockedToolNames } : {},
|
|
932
|
+
provenance: "cli-command-authorized"
|
|
933
|
+
});
|
|
934
|
+
const locatedExecution = hasRegistry ? readRunRecord(childRunId, { env, homedir: deps.homedir, fs: deps.fs })?.execution : void 0;
|
|
935
|
+
if (hasRegistry && (parsed.runtimeKey?.trim() === "local" || locatedExecution?.state === "known")) {
|
|
936
|
+
const implicitReadonlyHost = !parsed.runtimeKey && args.includes("--read-only") && locatedExecution?.state === "known" && locatedExecution.runtimeKey === "local" && locatedExecution.permissions.readOnly;
|
|
937
|
+
if (parsed.runtimeKey?.trim() !== "local" && !implicitReadonlyHost) throw new Error("[local-writer-resource] child binding runtime mismatch");
|
|
938
|
+
const { blockedToolNames } = await awaitLocalWriterChild(childRunId, parsed.cwd ?? process.cwd(), hostPolicy(), { env, homedir: deps.homedir, fs: deps.fs });
|
|
939
|
+
parsed.blockedToolNames = blockedToolNames;
|
|
940
|
+
}
|
|
941
|
+
if (hasRegistry && parsed.runtimeKey?.trim() !== "local" && locatedExecution?.state !== "known") reportRunProcessIdentity(childRunId, { env, homedir: deps.homedir, fs: deps.fs, now: deps.now });
|
|
942
|
+
const processExit = deps.processExit ?? ((code) => process.exit(code));
|
|
943
|
+
const stallTimeoutMs = resolvePositiveMs(
|
|
944
|
+
deps.stallTimeoutMs ?? env.NOLO_LOCAL_RUN_STALL_TIMEOUT_MS,
|
|
945
|
+
5 * 6e4
|
|
946
|
+
);
|
|
947
|
+
const stallEnvExplicitlySet = typeof env.NOLO_LOCAL_RUN_STALL_TIMEOUT_MS === "string" && env.NOLO_LOCAL_RUN_STALL_TIMEOUT_MS.trim().length > 0;
|
|
948
|
+
const armStallWatchdog = hasRegistry || stallEnvExplicitlySet;
|
|
949
|
+
const armTimeoutWatchdog = typeof parsed.timeoutMs === "number" && parsed.timeoutMs > 0;
|
|
950
|
+
let timedOut = false;
|
|
951
|
+
let stalled = false;
|
|
952
|
+
let timeoutTimer;
|
|
953
|
+
let stallTimer;
|
|
954
|
+
const activityTracker = armStallWatchdog ? createRunActivityTracker(childRunId ?? "__foreground__", {
|
|
955
|
+
env,
|
|
956
|
+
homedir: deps.homedir,
|
|
957
|
+
fs: deps.fs,
|
|
958
|
+
now: deps.now
|
|
959
|
+
}) : void 0;
|
|
960
|
+
const clearWatchdogs = () => {
|
|
961
|
+
if (timeoutTimer !== void 0) clearTimeout(timeoutTimer);
|
|
962
|
+
if (stallTimer !== void 0) clearInterval(stallTimer);
|
|
963
|
+
activityTracker?.flush();
|
|
964
|
+
activityTracker?.dispose();
|
|
965
|
+
};
|
|
966
|
+
let rejectOnWatchdogFailure;
|
|
967
|
+
const watchdogFailure = armStallWatchdog || armTimeoutWatchdog ? new Promise((_, reject) => {
|
|
968
|
+
rejectOnWatchdogFailure = reject;
|
|
969
|
+
}) : void 0;
|
|
970
|
+
const terminalStatus = createOneShotTerminalStatus(
|
|
971
|
+
parsed.eventsMode || parsed.background || hasRegistry ? null : deps.output ? deps.output : {
|
|
972
|
+
write: (chunk) => process.stdout.write(chunk),
|
|
973
|
+
isTTY: process.stdout.isTTY === true
|
|
974
|
+
}
|
|
975
|
+
);
|
|
976
|
+
const raceWithWatchdog = (work) => {
|
|
977
|
+
const raced = watchdogFailure ? Promise.race([work, watchdogFailure]) : work;
|
|
978
|
+
return raced.catch((error) => {
|
|
979
|
+
terminalStatus.fail();
|
|
980
|
+
throw error;
|
|
981
|
+
});
|
|
982
|
+
};
|
|
983
|
+
const exitFromWatchdog = async (code) => {
|
|
984
|
+
try {
|
|
985
|
+
await exitCliFromWatchdog(code, processExit, stopWatchdogRunner);
|
|
986
|
+
} catch {
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
const finalizeWatchdogOutcome = async (outcome, note, extra) => {
|
|
990
|
+
if (!hasRegistry) return;
|
|
991
|
+
const currentActivity = activityTracker?.getActivity();
|
|
992
|
+
const rawToolCount = extra?.toolCallCount ?? currentActivity?.counters?.toolCalls;
|
|
993
|
+
const toolCallCount = typeof rawToolCount === "number" && rawToolCount > 0 ? rawToolCount : void 0;
|
|
994
|
+
await settleRunTerminalAuthoritatively(
|
|
995
|
+
childRunId,
|
|
996
|
+
{
|
|
997
|
+
status: outcome.status,
|
|
998
|
+
exitCode: outcome.exitCode,
|
|
999
|
+
note,
|
|
1000
|
+
...extra?.failureReason ? { failureReason: extra.failureReason } : {},
|
|
1001
|
+
...toolCallCount !== void 0 ? { toolCallCount } : {},
|
|
1002
|
+
...extra?.lastAssistantText ? { lastAssistantText: extra.lastAssistantText } : {}
|
|
1003
|
+
},
|
|
1004
|
+
{ env, homedir: deps.homedir, fs: deps.fs, now: deps.now, sleep: deps.sleep },
|
|
1005
|
+
// Test seam: stubbed transitions keep their single-attempt semantics.
|
|
1006
|
+
deps.transitionRunToTerminal,
|
|
1007
|
+
{ expectedPid: process.pid }
|
|
1008
|
+
);
|
|
1009
|
+
};
|
|
1010
|
+
if (armStallWatchdog) {
|
|
1011
|
+
stallTimer = setInterval(async () => {
|
|
1012
|
+
if (timedOut || stalled) return;
|
|
1013
|
+
const activity = activityTracker?.getActivity();
|
|
1014
|
+
if (activity?.inFlight?.kind === "tool") {
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
const lastProgressAt = activity?.lastProgressAt ?? activity?.lastEventAt;
|
|
1018
|
+
const lastProgressAtMs = lastProgressAt ? new Date(lastProgressAt).getTime() : nowMs();
|
|
1019
|
+
const elapsedSinceProgress = nowMs() - lastProgressAtMs;
|
|
1020
|
+
if (elapsedSinceProgress >= stallTimeoutMs) {
|
|
1021
|
+
stalled = true;
|
|
1022
|
+
clearWatchdogs();
|
|
1023
|
+
const note = `stalled: no progress for ${stallTimeoutMs}ms`;
|
|
1024
|
+
output.write(`[nolo] local run ${note}
|
|
1025
|
+
`);
|
|
1026
|
+
terminalStatus.fail();
|
|
1027
|
+
const outcome = resolveRunOutcome({ kind: "stall" });
|
|
1028
|
+
const currentActivity = activityTracker?.getActivity();
|
|
1029
|
+
await finalizeWatchdogOutcome(outcome, note, {
|
|
1030
|
+
failureReason: "stalled",
|
|
1031
|
+
toolCallCount: currentActivity?.counters?.toolCalls
|
|
1032
|
+
});
|
|
1033
|
+
await exitFromWatchdog(outcome.exitCode);
|
|
1034
|
+
rejectOnWatchdogFailure?.(new Error(`[nolo] local run ${note}`));
|
|
1035
|
+
}
|
|
1036
|
+
}, Math.min(stallTimeoutMs, 1e4));
|
|
1037
|
+
}
|
|
1038
|
+
if (armTimeoutWatchdog) {
|
|
1039
|
+
timeoutTimer = setTimeout(async () => {
|
|
1040
|
+
timedOut = true;
|
|
1041
|
+
clearWatchdogs();
|
|
1042
|
+
const note = `timed out after ${parsed.timeoutMs}ms`;
|
|
1043
|
+
output.write(`[nolo] local run ${note}
|
|
1044
|
+
`);
|
|
1045
|
+
terminalStatus.fail();
|
|
1046
|
+
const outcome = resolveRunOutcome({ kind: "timeout" });
|
|
1047
|
+
await finalizeWatchdogOutcome(outcome, note);
|
|
1048
|
+
await exitFromWatchdog(outcome.exitCode);
|
|
1049
|
+
rejectOnWatchdogFailure?.(new Error(`[nolo] local run ${note}`));
|
|
1050
|
+
}, parsed.timeoutMs);
|
|
1051
|
+
}
|
|
1052
|
+
const wantsFallbackSuggestions = parsed.fallbackAgentKeys && parsed.fallbackAgentKeys.length > 0;
|
|
1053
|
+
const rawAgentInput = resolveRawAgentInput(args, deps.commandPath) ?? parsed.agentKey;
|
|
1054
|
+
const fullstackLocal = isFullstackCodingAgentRef(rawAgentInput, parsed.agentKey);
|
|
1055
|
+
const explicitLocalCli = isLocalCliAgentKey(parsed.agentKey);
|
|
1056
|
+
const dockerRuntimeLocal = typeof parsed.runtimeKey === "string" && /^docker(:.+)?$/.test(parsed.runtimeKey.trim());
|
|
1057
|
+
const instaboxRuntimeLocal = typeof parsed.runtimeKey === "string" && parsed.runtimeKey.trim() === "instabox";
|
|
1058
|
+
const hostRuntimeLocal = typeof parsed.runtimeKey === "string" && parsed.runtimeKey.trim() === "local" || !parsed.runtimeKey && args.includes("--read-only") && locatedExecution?.state === "known" && locatedExecution.runtimeKey === "local" && locatedExecution.permissions.readOnly;
|
|
1059
|
+
if (hostRuntimeLocal && !args.includes("--read-only") && !args.includes("--allow-host-writes")) {
|
|
1060
|
+
output.write(t("agentRun.hostWriteGuard"));
|
|
1061
|
+
return 1;
|
|
1062
|
+
}
|
|
1063
|
+
const isLocalRun = (dockerRuntimeLocal || instaboxRuntimeLocal || hostRuntimeLocal || !parsed.runtimeKey) && (parsed.runtimeMode === "local" || hostRuntimeLocal || !parsed.runtimeMode && (fullstackLocal || explicitLocalCli || args.includes("--dangerously-allow-shell")));
|
|
1064
|
+
if (wantsFallbackSuggestions && !isLocalRun) {
|
|
1065
|
+
output.write("[nolo] --fallback-agent (suggestions) is only supported for local CLI runs (use --local)\n");
|
|
1066
|
+
return 1;
|
|
1067
|
+
}
|
|
1068
|
+
let effectiveMessage = parsed.message;
|
|
1069
|
+
if (wantsFallbackSuggestions) {
|
|
1070
|
+
effectiveMessage = `${parsed.message}
|
|
1071
|
+
|
|
1072
|
+
[Quota fallback context for agent decision: If this execution for ${parsed.agentKey} hits subscription quota, YOU (the agent) must decide the next agent to use. Do not rely on automatic wrapper. Reason based on the specific task (complexity, length, domain), agent strengths, cost, previous attempt results. Suggested alternatives: ${parsed.fallbackAgentKeys.join(", ")}. Update the task row with attempt history and dispatch the chosen next (via startAgentRun \u5F02\u6B65\u6D3E\u53D1)).]`;
|
|
1073
|
+
}
|
|
1074
|
+
const resolvedAgentKey = parsed.runtimeMode !== "local" && !hostRuntimeLocal ? await (deps.resolveAgentRunAgentKey ?? resolveAgentRunAgentKey)({
|
|
1075
|
+
agentInput: resolveRawAgentInput(args, deps.commandPath) ?? parsed.agentKey,
|
|
1076
|
+
cliArgs: args,
|
|
1077
|
+
env,
|
|
1078
|
+
output
|
|
1079
|
+
}).catch(() => void 0) : void 0;
|
|
1080
|
+
const agentKey = resolvedAgentKey ?? parsed.agentKey;
|
|
1081
|
+
let machineShellOverride;
|
|
1082
|
+
if (parsed.machineShell) {
|
|
1083
|
+
const envRuntimeMode = env.NOLO_RUNTIME_MODE;
|
|
1084
|
+
const requestedRuntimeMode = parsed.runtimeMode ? parsed.runtimeMode : envRuntimeMode === "local" || envRuntimeMode === "server" || envRuntimeMode === "auto" ? envRuntimeMode : void 0;
|
|
1085
|
+
if (requestedRuntimeMode === "local") {
|
|
1086
|
+
output.write(MACHINE_SHELL_LOCAL_REFUSAL_MESSAGE);
|
|
1087
|
+
return 1;
|
|
1088
|
+
}
|
|
1089
|
+
const machineId = await (deps.resolveAgentBoundMachineId ?? resolveAgentBoundMachineIdFromRecord)({
|
|
1090
|
+
agentKey,
|
|
1091
|
+
cliArgs: args,
|
|
1092
|
+
env,
|
|
1093
|
+
output
|
|
1094
|
+
}).catch(() => void 0);
|
|
1095
|
+
if (!machineId) {
|
|
1096
|
+
output.write(
|
|
1097
|
+
`[nolo] --machine-shell requires ${agentKey} to be bound to a machine (runtimeBinding.machineId); none found.
|
|
1098
|
+
[nolo] bind it with \`nolo agent bind-current ${agentKey}\` on the target computer, then retry.
|
|
1099
|
+
`
|
|
1100
|
+
);
|
|
1101
|
+
return 1;
|
|
1102
|
+
}
|
|
1103
|
+
machineShellOverride = normalizeRuntimeToolPolicyOverride(
|
|
1104
|
+
MACHINE_SHELL_REQUESTED_POLICY
|
|
1105
|
+
);
|
|
1106
|
+
const baselinePolicy = resolveEffectiveRuntimeToolPolicy({
|
|
1107
|
+
agentConfig: { runtimeToolPolicy: machineShellOverride },
|
|
1108
|
+
host: "web"
|
|
1109
|
+
});
|
|
1110
|
+
output.write(
|
|
1111
|
+
`[nolo] machine-shell: dispatch=server(required) machine=${machineId} runtimeTools=${(machineShellOverride?.runtimeTools ?? []).join(",") || "-"} sandbox=${baselinePolicy?.isolation?.mode ?? "-"} approval=${baselinePolicy?.shell?.commandPolicy ?? "-"} networkPolicy=${baselinePolicy?.shell?.networkPolicy ?? "-"} policySource=web-runtime-safety-baseline
|
|
1112
|
+
`
|
|
1113
|
+
);
|
|
1114
|
+
}
|
|
1115
|
+
let effectiveAgentKey = agentKey;
|
|
1116
|
+
let modelOverride = null;
|
|
1117
|
+
const autoRouteRequested = deps.commandPath?.join(" ") === "chat" && !parsed.continueDialogId && (args.includes("--auto-route") || env.NOLO_AUTO_ROUTE === "1") && env.NOLO_AUTO_ROUTE !== "0";
|
|
1118
|
+
if (autoRouteRequested) {
|
|
1119
|
+
const hasExplicitAgent = Boolean(readFlagValue(args, "--agent"));
|
|
1120
|
+
if (hasExplicitAgent) {
|
|
1121
|
+
modelOverride = buildModelLayerOverride(
|
|
1122
|
+
await readDbRecord({
|
|
1123
|
+
dbKey: agentKey,
|
|
1124
|
+
authToken: resolveAuthToken(args, env),
|
|
1125
|
+
serverUrl: resolveServerUrl(env),
|
|
1126
|
+
fetchImpl: fetch
|
|
1127
|
+
}).catch(() => null)
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
if (hasExplicitAgent && !modelOverride) {
|
|
1131
|
+
output.write(
|
|
1132
|
+
t("agentRun.autoRouteOverrideFailed")
|
|
1133
|
+
);
|
|
1134
|
+
} else {
|
|
1135
|
+
effectiveAgentKey = CLI_AUTO_ROUTE_AGENT_KEY;
|
|
1136
|
+
if (modelOverride) {
|
|
1137
|
+
output.write(t("agentRun.autoRouteModelOverride", agentKey));
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
let workflowReference;
|
|
1142
|
+
if (parsed.workflowRef) {
|
|
1143
|
+
try {
|
|
1144
|
+
workflowReference = await (deps.resolveWorkflowReference ?? resolveWorkflowReference)(
|
|
1145
|
+
parsed.workflowRef
|
|
1146
|
+
);
|
|
1147
|
+
} catch (error) {
|
|
1148
|
+
output.write(`[nolo] ${toErrorMessage(error)}
|
|
1149
|
+
`);
|
|
1150
|
+
return 1;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
let skillReferences;
|
|
1154
|
+
let skillAllowedToolOverride;
|
|
1155
|
+
if (parsed.skillRefs?.length) {
|
|
1156
|
+
const skills = [];
|
|
1157
|
+
const authToken = resolveAuthToken(args, env);
|
|
1158
|
+
const serverUrl = resolveServerUrl(env);
|
|
1159
|
+
for (const ref of parsed.skillRefs) {
|
|
1160
|
+
try {
|
|
1161
|
+
const resolved = await resolveSkillReference(ref, {
|
|
1162
|
+
cwd: parsed.cwd,
|
|
1163
|
+
readDbRecord: async (dbKey) => {
|
|
1164
|
+
return readDbRecord({
|
|
1165
|
+
dbKey,
|
|
1166
|
+
authToken,
|
|
1167
|
+
serverUrl,
|
|
1168
|
+
fetchImpl: fetch
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
});
|
|
1172
|
+
skills.push(resolved);
|
|
1173
|
+
} catch (error) {
|
|
1174
|
+
output.write(`[nolo] ${toErrorMessage(error)}
|
|
1175
|
+
`);
|
|
1176
|
+
return 1;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
skillReferences = skills;
|
|
1180
|
+
const skillToolLists = skills.map((s) => s.allowedTools).filter((t2) => !!t2 && t2.length > 0);
|
|
1181
|
+
if (skillToolLists.length > 0) {
|
|
1182
|
+
const skillAllowed = skillToolLists.reduce(
|
|
1183
|
+
(acc, tools) => acc.filter((t2) => tools.includes(t2))
|
|
1184
|
+
);
|
|
1185
|
+
if (skillAllowed.length === 0) {
|
|
1186
|
+
output.write(`[nolo] warning: attached skills declare incompatible allowed-tools; this run has no tools
|
|
1187
|
+
`);
|
|
1188
|
+
}
|
|
1189
|
+
skillAllowedToolOverride = parsed.allowedToolNames?.length ? parsed.allowedToolNames.filter((t2) => skillAllowed.includes(t2)) : skillAllowed;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
let localRuntimeCwd = parsed.cwd;
|
|
1193
|
+
if (!localRuntimeCwd && (parsed.runtimeMode === "local" || hostRuntimeLocal)) {
|
|
1194
|
+
localRuntimeCwd = process.cwd();
|
|
1195
|
+
}
|
|
1196
|
+
const acceptanceCwd = localRuntimeCwd && (parsed.runtimeMode === "local" || hostRuntimeLocal) ? localRuntimeCwd : void 0;
|
|
1197
|
+
const acceptanceBase = acceptanceCwd ? await (deps.captureLocalRunBase ?? captureLocalRunBase)(acceptanceCwd, deps.localRunBaseCaptureOptions) : null;
|
|
1198
|
+
let finalWorkspaceInspection;
|
|
1199
|
+
if (parsed.runtimeKey === "instabox") {
|
|
1200
|
+
try {
|
|
1201
|
+
writeInstaboxRunConfig({
|
|
1202
|
+
workspaceMode: parsed.instaboxWorkspace,
|
|
1203
|
+
artifactDir: parsed.instaboxArtifactDir,
|
|
1204
|
+
manifestPath: parsed.instaboxManifestPath,
|
|
1205
|
+
allowRemoteRelease: parsed.instaboxAllowRemoteRelease,
|
|
1206
|
+
allowPaid: parsed.instaboxAllowPaid,
|
|
1207
|
+
env
|
|
1208
|
+
});
|
|
1209
|
+
} catch (err) {
|
|
1210
|
+
output.write(t("agentRun.instaboxConfigFailed", toErrorMessage(err)));
|
|
1211
|
+
return 1;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
const runEnv = buildLocalRunEnv({
|
|
1215
|
+
env,
|
|
1216
|
+
allowShell: parsed.allowShell
|
|
1217
|
+
});
|
|
1218
|
+
if (parsed.background && isLocalRun) {
|
|
1219
|
+
const { runId, pid, logPath } = await (deps.spawnLocalBackgroundRun ?? spawnLocalBackgroundRun)(
|
|
1220
|
+
{
|
|
1221
|
+
rawArgs: args,
|
|
1222
|
+
commandPath: deps.commandPath,
|
|
1223
|
+
cliEntrypointPath: deps.cliEntrypointPath,
|
|
1224
|
+
agentKey,
|
|
1225
|
+
cwd: localRuntimeCwd,
|
|
1226
|
+
...hostRuntimeLocal ? { localExecution: {
|
|
1227
|
+
runtimeKey: "local",
|
|
1228
|
+
hostWritesAuthorized: args.includes("--allow-host-writes"),
|
|
1229
|
+
readOnly: args.includes("--read-only"),
|
|
1230
|
+
...parsed.allowedToolNames ? { allowedToolNames: parsed.allowedToolNames } : {},
|
|
1231
|
+
...parsed.blockedToolNames ? { blockedToolNames: parsed.blockedToolNames } : {},
|
|
1232
|
+
provenance: "cli-command-authorized"
|
|
1233
|
+
} } : {},
|
|
1234
|
+
// Explicit host target is authorized above; read-only retains its existing tool restrictions.
|
|
1235
|
+
...hostRuntimeLocal && !args.includes("--read-only") ? { claimLocalWrites: true } : {},
|
|
1236
|
+
msgFile: readFlagValue(args, "--msg-file"),
|
|
1237
|
+
message: parsed.message,
|
|
1238
|
+
timeoutMs: parsed.timeoutMs,
|
|
1239
|
+
...parsed.ephemeral ? { ephemeral: true } : {},
|
|
1240
|
+
...parsed.dodCommands?.length ? { dodCommands: parsed.dodCommands } : {},
|
|
1241
|
+
output
|
|
1242
|
+
},
|
|
1243
|
+
{
|
|
1244
|
+
env,
|
|
1245
|
+
homedir: deps.homedir,
|
|
1246
|
+
spawn: deps.spawn,
|
|
1247
|
+
fs: deps.fs,
|
|
1248
|
+
now: deps.now,
|
|
1249
|
+
generateRunId: deps.generateRunId,
|
|
1250
|
+
shellApprovalHost: deps.shellApprovalHost,
|
|
1251
|
+
mcpApprovalHost: deps.mcpApprovalHost
|
|
1252
|
+
}
|
|
1253
|
+
);
|
|
1254
|
+
output.write(`[nolo] runId=${runId}
|
|
1255
|
+
`);
|
|
1256
|
+
output.write(`[nolo] pid=${pid ?? "-"}
|
|
1257
|
+
`);
|
|
1258
|
+
output.write(`[nolo] log=${logPath}
|
|
1259
|
+
`);
|
|
1260
|
+
output.write(`[nolo] status: nolo agent status ${runId}
|
|
1261
|
+
`);
|
|
1262
|
+
output.write(`[nolo] stop: nolo agent stop ${runId}
|
|
1263
|
+
`);
|
|
1264
|
+
return 0;
|
|
1265
|
+
}
|
|
1266
|
+
const cliCwd = parsed.cwd ?? process.cwd();
|
|
1267
|
+
const isSubtask = isSubtaskRun(env);
|
|
1268
|
+
const scopedLayers = [];
|
|
1269
|
+
const skillContentBlocks = [];
|
|
1270
|
+
if (hostRuntimeLocal && !parsed.background) {
|
|
1271
|
+
const policy = { ...hostPolicy(), ...skillAllowedToolOverride !== void 0 ? { allowedToolNames: skillAllowedToolOverride } : {} };
|
|
1272
|
+
if (hasRegistry) {
|
|
1273
|
+
const { blockedToolNames } = await awaitLocalWriterChild(childRunId, localRuntimeCwd, policy, { env, homedir: deps.homedir, fs: deps.fs });
|
|
1274
|
+
parsed.blockedToolNames = blockedToolNames;
|
|
1275
|
+
} else if (!policy.readOnly) {
|
|
1276
|
+
childRunId = registerLocalForegroundWriter(localRuntimeCwd, policy, agentKey, { env, homedir: deps.homedir, fs: deps.fs, now: deps.now });
|
|
1277
|
+
hasRegistry = true;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
const extraContextBlocks = [];
|
|
1281
|
+
const contextBlockScopes = [];
|
|
1282
|
+
let memoryPromptBlock = null;
|
|
1283
|
+
let memoryOverlayLayer = null;
|
|
1284
|
+
let memoryUseGuidanceLayer = null;
|
|
1285
|
+
const recallVerifiedLocalWork = (dialogId) => resolveCliWorkContext({
|
|
1286
|
+
env,
|
|
1287
|
+
dialogId,
|
|
1288
|
+
spaceId: parsed.spaceId ?? null,
|
|
1289
|
+
requireLocalDialogAccess: true,
|
|
1290
|
+
userInput: effectiveMessage
|
|
1291
|
+
});
|
|
1292
|
+
if (!isSubtask) {
|
|
1293
|
+
const agentsMdLayer = readAgentsMdLayerFromDisk(cliCwd);
|
|
1294
|
+
if (agentsMdLayer) scopedLayers.push(agentsMdLayer);
|
|
1295
|
+
skillContentBlocks.push(...buildSkillContextBlocks(skillReferences));
|
|
1296
|
+
scopedLayers.push(buildSkillDiscoveryContextLayer(cliCwd));
|
|
1297
|
+
scopedLayers.push(buildHostEnvironmentLayer());
|
|
1298
|
+
if (!deps.memoryRecallDisabled) {
|
|
1299
|
+
try {
|
|
1300
|
+
memoryPromptBlock = await resolveCliMemory({
|
|
1301
|
+
serverUrl: resolveServerUrl(env),
|
|
1302
|
+
authToken: resolveAuthToken(args, env),
|
|
1303
|
+
agentKey: effectiveAgentKey,
|
|
1304
|
+
userInput: effectiveMessage,
|
|
1305
|
+
...parsed.spaceId ? { spaceId: parsed.spaceId } : {},
|
|
1306
|
+
env
|
|
1307
|
+
});
|
|
1308
|
+
} catch (memoryError) {
|
|
1309
|
+
console.warn("[cli-memory] memory recall failed, omitting memory layer:", memoryError);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
const workContextBlock = !deps.memoryRecallDisabled && parsed.continueDialogId && !parsed.ephemeral ? await recallVerifiedLocalWork(parsed.continueDialogId) : null;
|
|
1313
|
+
memoryOverlayLayer = buildMemoryOverlayLayer({ promptBlock: memoryPromptBlock });
|
|
1314
|
+
memoryUseGuidanceLayer = buildMemoryUseGuidanceLayer({ promptBlock: memoryPromptBlock });
|
|
1315
|
+
contextBlockScopes.push(
|
|
1316
|
+
...partitionScopedBlocks([
|
|
1317
|
+
...renderTurnContextBlocksWithScope([
|
|
1318
|
+
...scopedLayers,
|
|
1319
|
+
memoryUseGuidanceLayer
|
|
1320
|
+
]),
|
|
1321
|
+
...skillContentBlocks.map((content) => content.trim()).filter((content) => content.length > 0).map((content) => ({ content, cacheScope: "turn" })),
|
|
1322
|
+
...renderTurnContextBlocksWithScope([memoryOverlayLayer]),
|
|
1323
|
+
...workContextBlock ? [{ content: workContextBlock, cacheScope: "turn" }] : []
|
|
1324
|
+
])
|
|
1325
|
+
);
|
|
1326
|
+
extraContextBlocks.push(...contextBlockScopes.map((block) => block.content));
|
|
1327
|
+
}
|
|
1328
|
+
const runRecordParentDialogId = !parsed.parentDialogId && typeof childRunId === "string" && childRunId.length > 0 ? asOptionalTrimmedString(
|
|
1329
|
+
(deps.readRunRecord ?? readRunRecord)(childRunId, {
|
|
1330
|
+
env,
|
|
1331
|
+
homedir: deps.homedir,
|
|
1332
|
+
fs: deps.fs
|
|
1333
|
+
})?.parentDialogId
|
|
1334
|
+
) : void 0;
|
|
1335
|
+
const effectiveParentDialogId = parsed.parentDialogId ?? runRecordParentDialogId;
|
|
1336
|
+
const formatTurnMessage = (msg) => prependWorkflowReferencePrompt(
|
|
1337
|
+
prependSubjectDialogMarker(
|
|
1338
|
+
prependFeatureWorktreeInstruction(
|
|
1339
|
+
prependOutputFormatGuidance(msg),
|
|
1340
|
+
parsed.injectFeatureWorktreeInstruction
|
|
1341
|
+
),
|
|
1342
|
+
parsed.subjectDialogKey
|
|
1343
|
+
),
|
|
1344
|
+
workflowReference
|
|
1345
|
+
);
|
|
1346
|
+
const mcpApprovalChild = process.connected && typeof process.send === "function" ? createMcpApprovalChild(process) : void 0;
|
|
1347
|
+
const shellApprovalChild = process.connected && typeof process.send === "function" ? createShellApprovalChild(process) : void 0;
|
|
1348
|
+
try {
|
|
1349
|
+
const imageUrls = await normalizeCliRunImages(parsed.imageUrls, normalizeCliImageInput);
|
|
1350
|
+
const buildRunOptions = (targetAgentKey, turnMessage = effectiveMessage, turnScopes = contextBlockScopes) => ({
|
|
1351
|
+
...mcpApprovalChild ? {
|
|
1352
|
+
mcpConfirmation: targetAgentKey === agentKey ? mcpApprovalChild.confirm : async () => "unavailable",
|
|
1353
|
+
mcpApprovalSignal: mcpApprovalChild.signal
|
|
1354
|
+
} : {},
|
|
1355
|
+
...shellApprovalChild ? { execShellApproval: targetAgentKey === agentKey ? shellApprovalChild.authority : {
|
|
1356
|
+
request: async () => {
|
|
1357
|
+
throw new Error("Shell approval agent binding mismatch");
|
|
1358
|
+
},
|
|
1359
|
+
consume: () => {
|
|
1360
|
+
throw new Error("Shell approval agent binding mismatch");
|
|
1361
|
+
}
|
|
1362
|
+
} } : {},
|
|
1363
|
+
agentName: targetAgentKey,
|
|
1364
|
+
agentKey: targetAgentKey,
|
|
1365
|
+
// 当前执行链未提供可靠的最终展示能力,按约定使用 unknown(只注入行为段,不猜
|
|
1366
|
+
// 宽/窄屏;`stdout.isTTY` 只说明是不是终端,说明不了宽度)。这不表示宿主永远
|
|
1367
|
+
// 无法获得尺寸:将来接入时应传展示能力,不应由调用方拼接准则文本。
|
|
1368
|
+
// 放在 buildRunOptions 这个唯一构造点上,首轮 / quota fallback / 队列 drain
|
|
1369
|
+
// 三处 runner(...) 调用自动一致;远端分支走 server 线,不读该字段。
|
|
1370
|
+
responseViewport: "unknown",
|
|
1371
|
+
serverUrl: resolveServerUrl(env),
|
|
1372
|
+
message: formatTurnMessage(turnMessage),
|
|
1373
|
+
imageUrls,
|
|
1374
|
+
scriptDir: deps.scriptDir,
|
|
1375
|
+
env: runEnv,
|
|
1376
|
+
output,
|
|
1377
|
+
...deps.localRuntimeAdapterFactory ? { localRuntimeAdapterFactory: deps.localRuntimeAdapterFactory } : {},
|
|
1378
|
+
...localRuntimeCwd ? { localRuntimeCwd } : {},
|
|
1379
|
+
// `--machine-shell` 强制锁定 server 派发:绑定校验通过后 runtimeMode 一律为
|
|
1380
|
+
// "server"(+ requireRemoteDispatch 在派发层再兜一次),既不给 auto→local 早退
|
|
1381
|
+
// 留口子,也不受 NOLO_RUNTIME_MODE=local 覆盖(resolveRequestedRuntimeMode 以
|
|
1382
|
+
// options.runtimeMode 优先)。这是在唯一构造 runner 参数的入口做的,quota
|
|
1383
|
+
// fallback / 重试等复用 buildRunOptions 的路径同样被锁住。
|
|
1384
|
+
// 非 machine-shell 时保留本地通道判定:显式 runtimeMode 优先,其次
|
|
1385
|
+
// docker/host 本地目标在本地 run 上回落 runtimeMode=local。
|
|
1386
|
+
...parsed.machineShell ? { runtimeMode: "server", requireRemoteDispatch: true } : parsed.runtimeMode ? { runtimeMode: parsed.runtimeMode } : (dockerRuntimeLocal || instaboxRuntimeLocal || hostRuntimeLocal) && isLocalRun ? { runtimeMode: "local" } : {},
|
|
1387
|
+
// runtimeKey 与 machine-shell 的组合已在 parseAgentRunArgs 入口显式拒绝,
|
|
1388
|
+
// 这里直接透传即可(不再静默丢弃参数)。
|
|
1389
|
+
...parsed.runtimeKey ? { runtimeKey: parsed.runtimeKey } : {},
|
|
1390
|
+
...parsed.dockerWorkspaceMode ? { dockerWorkspaceMode: parsed.dockerWorkspaceMode } : {},
|
|
1391
|
+
...parsed.continueDialogId ? { continueDialogId: parsed.continueDialogId } : {},
|
|
1392
|
+
...parsed.strictContinueHistory ? { strictContinueHistory: true } : {},
|
|
1393
|
+
...parsed.spaceId ? { spaceId: parsed.spaceId } : {},
|
|
1394
|
+
...parsed.category ? { category: parsed.category } : {},
|
|
1395
|
+
...parsed.inheritedFromDialogKey ? { inheritedFromDialogKey: parsed.inheritedFromDialogKey } : {},
|
|
1396
|
+
...effectiveParentDialogId ? { parentDialogId: effectiveParentDialogId } : {},
|
|
1397
|
+
...parsed.parentWakeOnTerminal ? { parentWakeOnTerminal: true } : {},
|
|
1398
|
+
...parsed.subjectDialogKey ? { subjectDialogKey: parsed.subjectDialogKey } : {},
|
|
1399
|
+
...parsed.subjectRefs?.length ? { subjectRefs: parsed.subjectRefs } : {},
|
|
1400
|
+
...skillAllowedToolOverride !== void 0 ? { allowedToolNames: skillAllowedToolOverride } : parsed.allowedToolNames?.length ? { allowedToolNames: parsed.allowedToolNames } : {},
|
|
1401
|
+
...parsed.blockedToolNames?.length ? { blockedToolNames: parsed.blockedToolNames } : {},
|
|
1402
|
+
...machineShellOverride ? { runtimeToolPolicyOverride: machineShellOverride } : {},
|
|
1403
|
+
...activityTracker ? {
|
|
1404
|
+
onLoopEvent: activityTracker.onLoopEvent,
|
|
1405
|
+
onPartialText: activityTracker.onPartialText
|
|
1406
|
+
} : {},
|
|
1407
|
+
background: parsed.background,
|
|
1408
|
+
noStream: parsed.noStream,
|
|
1409
|
+
ephemeral: parsed.ephemeral,
|
|
1410
|
+
...typeof parsed.timeoutMs === "number" ? { timeoutMs: parsed.timeoutMs } : {},
|
|
1411
|
+
traceTools: parsed.traceTools,
|
|
1412
|
+
...parsed.eventsMode ? { eventsMode: parsed.eventsMode } : {},
|
|
1413
|
+
...parsed.taskEvidence ? { taskEvidence: parsed.taskEvidence } : {},
|
|
1414
|
+
...turnScopes.length > 0 ? { contextBlockScopes: turnScopes } : extraContextBlocks.length > 0 ? { extraContextBlocks } : {}
|
|
1415
|
+
});
|
|
1416
|
+
const freshWorkRecall = !deps.memoryRecallDisabled && !isSubtask && !parsed.continueDialogId && !parsed.ephemeral && !parsed.background && !parsed.spaceId ? { freshLocalWorkRecallQuery: effectiveMessage } : {};
|
|
1417
|
+
terminalStatus.working();
|
|
1418
|
+
let result = await raceWithWatchdog(
|
|
1419
|
+
runner({
|
|
1420
|
+
...buildRunOptions(effectiveAgentKey),
|
|
1421
|
+
...freshWorkRecall,
|
|
1422
|
+
...parsed.freshDialog ? { freshDialog: true } : {},
|
|
1423
|
+
...modelOverride ? { modelOverride } : {},
|
|
1424
|
+
// `--reasoning-effort`:本次 run 的有效推理档覆盖(内存生效,不写回记录)。
|
|
1425
|
+
...parsed.reasoningEffort ? { reasoningEffortOverride: parsed.reasoningEffort } : {}
|
|
1426
|
+
})
|
|
1427
|
+
);
|
|
1428
|
+
clearWatchdogs();
|
|
1429
|
+
const runCommandObservations = [...getRunResultHeaderMeta(result).commandObservations ?? []];
|
|
1430
|
+
let runCreditsTotal = result.turnCredits;
|
|
1431
|
+
let runCacheUsage = summarizeCacheUsageRecords(result.usageRecords);
|
|
1432
|
+
if (result.exitCode !== 0 && isQuotaExhaustedError(result.localError) && isLocalRun && parsed.fallbackAgentKeys && parsed.fallbackAgentKeys.length > 0) {
|
|
1433
|
+
const fallbackAgentKey = parsed.fallbackAgentKeys[0];
|
|
1434
|
+
output.write(
|
|
1435
|
+
`[nolo] quota exhausted on ${agentKey}, falling back to ${fallbackAgentKey}
|
|
1436
|
+
`
|
|
1437
|
+
);
|
|
1438
|
+
const fallbackWorkBlock = result.dialogId && freshWorkRecall.freshLocalWorkRecallQuery !== void 0 ? await recallVerifiedLocalWork(result.dialogId) : null;
|
|
1439
|
+
const fallbackScopes = fallbackWorkBlock ? [...contextBlockScopes, { content: fallbackWorkBlock, cacheScope: "turn" }] : contextBlockScopes;
|
|
1440
|
+
const fallbackResult = await raceWithWatchdog(
|
|
1441
|
+
runner({
|
|
1442
|
+
...buildRunOptions(fallbackAgentKey, effectiveMessage, fallbackScopes),
|
|
1443
|
+
...result.dialogId ? { continueDialogId: result.dialogId } : freshWorkRecall
|
|
1444
|
+
})
|
|
1445
|
+
);
|
|
1446
|
+
clearWatchdogs();
|
|
1447
|
+
runCommandObservations.push(...getRunResultHeaderMeta(fallbackResult).commandObservations ?? []);
|
|
1448
|
+
if (fallbackResult.exitCode === 0) {
|
|
1449
|
+
result = fallbackResult;
|
|
1450
|
+
}
|
|
1451
|
+
if (fallbackResult.turnCredits !== void 0) {
|
|
1452
|
+
runCreditsTotal = (runCreditsTotal ?? 0) + fallbackResult.turnCredits;
|
|
1453
|
+
}
|
|
1454
|
+
runCacheUsage = mergeCacheUsageSummaries(
|
|
1455
|
+
runCacheUsage,
|
|
1456
|
+
summarizeCacheUsageRecords(fallbackResult.usageRecords)
|
|
1457
|
+
);
|
|
1458
|
+
if (fallbackResult.exitCode !== 0) {
|
|
1459
|
+
result = {
|
|
1460
|
+
...fallbackResult,
|
|
1461
|
+
...fallbackResult.dialogId || result.dialogId ? { dialogId: fallbackResult.dialogId ?? result.dialogId } : {}
|
|
1462
|
+
};
|
|
1463
|
+
output.write(
|
|
1464
|
+
`[nolo] fallback to ${fallbackAgentKey} also failed: ${fallbackResult.localError instanceof Error ? fallbackResult.localError.message : String(fallbackResult.localError ?? "unknown error")}
|
|
1465
|
+
`
|
|
1466
|
+
);
|
|
1467
|
+
}
|
|
1468
|
+
} else if (result.localError instanceof CliProviderQuotaError) {
|
|
1469
|
+
output.write(`
|
|
1470
|
+
[nolo] Quota limit hit for ${parsed.agentKey} (CliProviderQuotaError).
|
|
1471
|
+
`);
|
|
1472
|
+
if (parsed.fallbackAgentKeys && parsed.fallbackAgentKeys.length > 0) {
|
|
1473
|
+
output.write(`Suggested alternatives for your decision: ${parsed.fallbackAgentKeys.join(", ")}
|
|
1474
|
+
`);
|
|
1475
|
+
}
|
|
1476
|
+
output.write(`As the orchestrating agent, decide next based on task and re-dispatch (update task state with this attempt).
|
|
1477
|
+
`);
|
|
1478
|
+
}
|
|
1479
|
+
const queueFilePath = parsed.queueFile ?? (childRunId ? resolveRunQueuePath(childRunId, env, deps.homedir) : void 0);
|
|
1480
|
+
const queueFs = deps.fs ?? nodeFs;
|
|
1481
|
+
if (queueFilePath && queueFs.existsSync(queueFilePath) && result.dialogId && result.exitCode === 0) {
|
|
1482
|
+
const MAX_DRAIN_TURNS = 200;
|
|
1483
|
+
let drainTurns = 0;
|
|
1484
|
+
const popSingle = deps.popSingleQueueMessage ?? popSingleQueueMessage;
|
|
1485
|
+
while (drainTurns < MAX_DRAIN_TURNS && queueFs.existsSync(queueFilePath)) {
|
|
1486
|
+
const nextEntry = await popSingle(queueFilePath, deps);
|
|
1487
|
+
if (!nextEntry) {
|
|
1488
|
+
break;
|
|
1489
|
+
}
|
|
1490
|
+
drainTurns += 1;
|
|
1491
|
+
try {
|
|
1492
|
+
const turnResult = await raceWithWatchdog(
|
|
1493
|
+
runner({
|
|
1494
|
+
...buildRunOptions(effectiveAgentKey, nextEntry.text),
|
|
1495
|
+
continueDialogId: result.dialogId,
|
|
1496
|
+
...modelOverride ? { modelOverride } : {},
|
|
1497
|
+
// `--reasoning-effort`:本次 run 的有效推理档覆盖(内存生效,不写回记录)。
|
|
1498
|
+
...parsed.reasoningEffort ? { reasoningEffortOverride: parsed.reasoningEffort } : {}
|
|
1499
|
+
})
|
|
1500
|
+
);
|
|
1501
|
+
clearWatchdogs();
|
|
1502
|
+
runCommandObservations.push(...getRunResultHeaderMeta(turnResult).commandObservations ?? []);
|
|
1503
|
+
result = turnResult;
|
|
1504
|
+
if (turnResult.turnCredits !== void 0) {
|
|
1505
|
+
runCreditsTotal = (runCreditsTotal ?? 0) + turnResult.turnCredits;
|
|
1506
|
+
}
|
|
1507
|
+
runCacheUsage = mergeCacheUsageSummaries(
|
|
1508
|
+
runCacheUsage,
|
|
1509
|
+
summarizeCacheUsageRecords(turnResult.usageRecords)
|
|
1510
|
+
);
|
|
1511
|
+
if (result.exitCode !== 0) {
|
|
1512
|
+
break;
|
|
1513
|
+
}
|
|
1514
|
+
} catch (drainError) {
|
|
1515
|
+
clearWatchdogs();
|
|
1516
|
+
console.error(`[nolo] queue turn failed with exception: ${toErrorMessage(drainError)}`);
|
|
1517
|
+
result = {
|
|
1518
|
+
...result,
|
|
1519
|
+
exitCode: 1,
|
|
1520
|
+
localError: drainError
|
|
1521
|
+
};
|
|
1522
|
+
break;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
if (drainTurns >= MAX_DRAIN_TURNS) {
|
|
1526
|
+
console.error(
|
|
1527
|
+
`[nolo] Warning: queue drain loop reached defensive limit of ${MAX_DRAIN_TURNS} turns, stopping.`
|
|
1528
|
+
);
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
if (result.dialogId) {
|
|
1532
|
+
if (parsed.background) {
|
|
1533
|
+
output.write(`
|
|
1534
|
+
[nolo] background dialog ${result.dialogId}
|
|
1535
|
+
`);
|
|
1536
|
+
output.write(`[nolo] read: nolo dialog read ${result.dialogId}
|
|
1537
|
+
`);
|
|
1538
|
+
} else {
|
|
1539
|
+
output.write(`
|
|
1540
|
+
[nolo] dialog ${result.dialogId}
|
|
1541
|
+
`);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
if (acceptanceCwd || shouldPrintLocalRunSummary({ parsed, localRuntimeCwd })) {
|
|
1545
|
+
try {
|
|
1546
|
+
const inspect = deps.inspectLocalRunWorkspace ?? inspectLocalRunWorkspace;
|
|
1547
|
+
const inspection = await inspect(localRuntimeCwd, {}, acceptanceCwd ? acceptanceBase : void 0);
|
|
1548
|
+
finalWorkspaceInspection = inspection;
|
|
1549
|
+
if (shouldPrintLocalRunSummary({ parsed, localRuntimeCwd })) output.write(formatLocalRunSummary({
|
|
1550
|
+
dialogId: result.dialogId,
|
|
1551
|
+
inspection
|
|
1552
|
+
}));
|
|
1553
|
+
} catch (error) {
|
|
1554
|
+
output.write(
|
|
1555
|
+
`
|
|
1556
|
+
[nolo] local run summary unavailable: ${toErrorMessage(error)}
|
|
1557
|
+
`
|
|
1558
|
+
);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
if (typeof childRunId === "string" && childRunId.length > 0) {
|
|
1562
|
+
const childRecordForDoD = (deps.readRunRecord ?? readRunRecord)(childRunId, {
|
|
1563
|
+
env,
|
|
1564
|
+
homedir: deps.homedir,
|
|
1565
|
+
fs: deps.fs
|
|
1566
|
+
});
|
|
1567
|
+
const isStalledOrTruncated = isRunResultStalledOrTruncated(result);
|
|
1568
|
+
const truncationNote = resolveRunSettlementNote(result);
|
|
1569
|
+
const outcome = resolveRunOutcome({
|
|
1570
|
+
kind: "result",
|
|
1571
|
+
exitCode: result.exitCode,
|
|
1572
|
+
isStalledOrTruncated
|
|
1573
|
+
});
|
|
1574
|
+
let dodResults;
|
|
1575
|
+
try {
|
|
1576
|
+
dodResults = (deps.runDoDCommands ?? runDoDCommands)(
|
|
1577
|
+
childRecordForDoD?.dodCommands,
|
|
1578
|
+
childRecordForDoD?.cwd,
|
|
1579
|
+
{ env }
|
|
1580
|
+
);
|
|
1581
|
+
} catch (dodError) {
|
|
1582
|
+
console.warn(`[nolo] DoD verification failed to run for ${childRunId}:`, dodError);
|
|
1583
|
+
}
|
|
1584
|
+
let failureReason;
|
|
1585
|
+
let toolCallCount;
|
|
1586
|
+
if (outcome.status === "failed") {
|
|
1587
|
+
if (result.emptyAssistantFallbackReason === "repetition_loop" || result.emptyAssistantFallbackReason === "stagnant_tool_calls") {
|
|
1588
|
+
failureReason = "stalled";
|
|
1589
|
+
} else if (result.localError && isHistoryIntegrityFailure(toErrorMessage(result.localError))) {
|
|
1590
|
+
failureReason = "history_integrity";
|
|
1591
|
+
} else if (result.localError && isQuotaExhaustedError(result.localError)) {
|
|
1592
|
+
failureReason = "provider_rate_limited";
|
|
1593
|
+
} else if (result.localError) {
|
|
1594
|
+
const errMsg = toErrorMessage(result.localError).toLowerCase();
|
|
1595
|
+
if (errMsg.includes("config_unresolved") || errMsg.includes("unresolved config")) {
|
|
1596
|
+
failureReason = "config_unresolved";
|
|
1597
|
+
} else {
|
|
1598
|
+
failureReason = "provider_error";
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
const currentActivity = activityTracker?.getActivity();
|
|
1602
|
+
const rawToolCount = currentActivity?.counters?.toolCalls ?? childRecordForDoD?.activity?.counters?.toolCalls;
|
|
1603
|
+
if (typeof rawToolCount === "number" && rawToolCount > 0) {
|
|
1604
|
+
toolCallCount = rawToolCount;
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
const acceptance = acceptanceCwd ? finalWorkspaceInspection?.acceptance ?? unknownLocalRunAcceptance(acceptanceCwd, acceptanceBase) : void 0;
|
|
1608
|
+
if (acceptance && dodResults?.length) {
|
|
1609
|
+
acceptance.checks.observations = dodResults.map((check, index) => ({
|
|
1610
|
+
// Command lines/output can contain credentials. Persist only a digest
|
|
1611
|
+
// here; the pre-existing registry is the execution evidence reference.
|
|
1612
|
+
commandFingerprint: `sha256:${createHash("sha256").update(check.command).digest("hex")}`,
|
|
1613
|
+
cwd: childRecordForDoD?.cwd || process.cwd(),
|
|
1614
|
+
exitCode: check.exitCode,
|
|
1615
|
+
evidence: `${childRunId}.json#/dodResults/${index}`,
|
|
1616
|
+
versionBinding: "unknown"
|
|
1617
|
+
}));
|
|
1618
|
+
}
|
|
1619
|
+
if (acceptance) attachLocalCommandObservations(
|
|
1620
|
+
acceptance,
|
|
1621
|
+
runCommandObservations,
|
|
1622
|
+
`${childRunId}.result.md`
|
|
1623
|
+
);
|
|
1624
|
+
let settlement;
|
|
1625
|
+
try {
|
|
1626
|
+
settlement = await settleRunTerminalAuthoritatively(
|
|
1627
|
+
childRunId,
|
|
1628
|
+
{
|
|
1629
|
+
status: outcome.status,
|
|
1630
|
+
exitCode: outcome.exitCode,
|
|
1631
|
+
dialogId: result.dialogId,
|
|
1632
|
+
...dodResults ? { dodResults } : {},
|
|
1633
|
+
// run 级累计的平台积分(主轮 + fallback + drain 轮):dock 行据此显示
|
|
1634
|
+
// 「⚡ x.xx」,让派发任务的消耗可见。undefined = 全程无平台计费。
|
|
1635
|
+
...runCreditsTotal !== void 0 ? { credits: runCreditsTotal } : {},
|
|
1636
|
+
// run 级缓存命中汇总:只进 .result.md 的 front matter(cached_tokens
|
|
1637
|
+
// 为 null 表示 provider 未报缓存指标,与「命中 0」严格区分)。
|
|
1638
|
+
...runCacheUsage ? { cacheUsage: runCacheUsage } : {},
|
|
1639
|
+
...failureReason ? { failureReason } : {},
|
|
1640
|
+
...toolCallCount !== void 0 ? { toolCallCount } : {},
|
|
1641
|
+
...acceptance ? { acceptance } : {},
|
|
1642
|
+
...result.finalText ? { lastAssistantText: result.finalText } : {},
|
|
1643
|
+
// 仅用于 .result.md 头(front matter):旁路读取,不改 result 形状。
|
|
1644
|
+
...getRunResultHeaderMeta(result),
|
|
1645
|
+
...truncationNote
|
|
1646
|
+
},
|
|
1647
|
+
{
|
|
1648
|
+
env,
|
|
1649
|
+
homedir: deps.homedir,
|
|
1650
|
+
fs: deps.fs,
|
|
1651
|
+
now: deps.now,
|
|
1652
|
+
sleep: deps.sleep
|
|
1653
|
+
},
|
|
1654
|
+
deps.transitionRunToTerminal,
|
|
1655
|
+
{ expectedPid: process.pid }
|
|
1656
|
+
);
|
|
1657
|
+
} catch (error) {
|
|
1658
|
+
terminalStatus.fail();
|
|
1659
|
+
output.write(`[nolo] terminal settlement failed: ${error instanceof Error ? error.message : String(error)}
|
|
1660
|
+
`);
|
|
1661
|
+
return 1;
|
|
1662
|
+
}
|
|
1663
|
+
if (settlement && (settlement.kind === "transitioned" || settlement.kind === "kept" || settlement.kind === "contended") && settlement.record.status !== "done" && result.exitCode === 0) {
|
|
1664
|
+
result = { ...result, exitCode: settlement.record.exitCode || 1 };
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
terminalStatus.settle({
|
|
1668
|
+
exitCode: result.exitCode,
|
|
1669
|
+
streamInterrupted: result.streamInterrupted,
|
|
1670
|
+
stalledOrTruncated: isRunResultStalledOrTruncated(result)
|
|
1671
|
+
});
|
|
1672
|
+
return result.exitCode;
|
|
1673
|
+
} catch (error) {
|
|
1674
|
+
terminalStatus.fail();
|
|
1675
|
+
throw error;
|
|
1676
|
+
} finally {
|
|
1677
|
+
mcpApprovalChild?.close();
|
|
1678
|
+
shellApprovalChild?.close();
|
|
1679
|
+
if ((shellApprovalChild || mcpApprovalChild) && process.connected) process.disconnect();
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
export {
|
|
1684
|
+
emitTerminalProgramStatus,
|
|
1685
|
+
resolveWorkflowReference,
|
|
1686
|
+
resolveSkillReference,
|
|
1687
|
+
buildSkillContextBlocks,
|
|
1688
|
+
prependSubjectDialogMarker,
|
|
1689
|
+
normalizeCliImageInput,
|
|
1690
|
+
buildHostEnvironmentLayer,
|
|
1691
|
+
FAILED_EMPTY_ASSISTANT_REASONS,
|
|
1692
|
+
isRunResultStalledOrTruncated,
|
|
1693
|
+
resolveTerminalProgramStatusState,
|
|
1694
|
+
resolveRunOutcome,
|
|
1695
|
+
resolveRunSettlementNote,
|
|
1696
|
+
runAgentRunCommand
|
|
1697
|
+
};
|