nolo-cli 0.107.0-alpha.4 → 0.107.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-UDCSOTD2.js → _executeModel-M573MKVE.js} +78 -70
- package/action-GVA5ARSJ.js +20 -0
- package/{addContentAction-MB2HHMDZ.js → addContentAction-M2WOWZCL.js} +13 -12
- package/{addDialogAgentAction-MCEABSBA.js → addDialogAgentAction-QMAQ5Z6N.js} +19 -20
- package/{agentDeleteCommand-OWYHN6D6.js → agentDeleteCommand-ZFHYRHBS.js} +118 -43
- package/{agentEmailCommands-AU5I4M4W.js → agentEmailCommands-X6AVPIVQ.js} +100 -90
- package/agentListCommands-PAD2CI2I.js +741 -0
- package/{agentMachineCommands-YMNME2L6.js → agentMachineCommands-UPH6RJCC.js} +50 -46
- package/{agentProviderCommands-GNPTL5XR.js → agentProviderCommands-CMVTBY5X.js} +97 -2
- package/{agentPullCommand-O5MPVJ5E.js → agentPullCommand-B4T2DJ5H.js} +1 -1
- package/agentRecordCommands-UMACPRAF.js +138 -0
- package/agentRunCommand-H6KKHHMU.js +167 -0
- package/{agentRunControl-AVJR4JW4.js → agentRunControl-3HWA2LLQ.js} +2 -2
- package/{agentRuntimeLocal-KCMC2TBD.js → agentRuntimeLocal-N4YGKL7M.js} +44 -40
- package/{agentSlice-R7PR6KYM.js → agentSlice-2LPP43XH.js} +15 -14
- package/{appDeleteCommands-JEPA3EWE.js → appDeleteCommands-7DAF33AM.js} +46 -42
- package/{appDeployCommands-UTB76XFM.js → appDeployCommands-ZPZSMFGZ.js} +46 -42
- package/{appDeployStatusCommands-LGHF2SBD.js → appDeployStatusCommands-FWBDSSS5.js} +46 -42
- package/{appGetCommands-PX2BFHOB.js → appGetCommands-SZZOHGEP.js} +46 -42
- package/{appListCommands-BSMPTWKC.js → appListCommands-FPMUBDPM.js} +46 -42
- package/{authCommand-YW42YZA4.js → authCommand-VL3G26NQ.js} +119 -25
- package/{authCommands-RGOGCPP6.js → authCommands-5RTUDYZW.js} +7 -5
- package/{builtinSkillRegistry-FUAVTRVZ.js → builtinSkillRegistry-ZK4K67Y5.js} +11 -9
- package/{chromeCommands-FZYAU75D.js → chromeCommands-AU5ZJXBG.js} +289 -37
- package/{chromeOpsCommands-62P2Q2YB.js → chromeOpsCommands-ZYTCMNHG.js} +156 -22
- package/{chunk-JEDZAO7L.js → chunk-2SYTUTLI.js} +257 -37
- package/{chunk-HVURBGF3.js → chunk-2U3NHADM.js} +6 -6
- package/{chunk-QTGQ2LTL.js → chunk-3DQY5IFB.js} +6 -10
- package/{chunk-XT35TTFG.js → chunk-3IXAHOJS.js} +19 -21
- package/{chunk-UVA7OYO3.js → chunk-3W67RV75.js} +29 -9
- package/chunk-4LCOCOR5.js +50 -0
- package/{chunk-JPGCXHNM.js → chunk-4LKMZ3RR.js} +1 -1
- package/{chunk-2GRGFCF6.js → chunk-4VJAC32I.js} +2 -1
- package/{chunk-6D6VBVEW.js → chunk-4W24JM32.js} +80 -14
- package/{chunk-MC4XLIJ7.js → chunk-523DITKR.js} +1 -1
- package/{chunk-E4MARS3Q.js → chunk-5GVBDNTO.js} +1 -1
- package/{chunk-C3M4465B.js → chunk-5HYJ3DSZ.js} +404 -659
- package/chunk-5MMAK75Q.js +15 -0
- package/{chunk-7S4YWN7P.js → chunk-5UUIGN6I.js} +4 -4
- package/{chunk-42V6BK2E.js → chunk-62IL3KQV.js} +4 -34
- package/{chunk-4MK3I7Y4.js → chunk-6MAW4XOF.js} +5 -5
- package/{chunk-3UZPUAES.js → chunk-74PPKIY2.js} +1 -1
- package/chunk-76HO2DP6.js +15 -0
- package/{chunk-ASIFZ2WY.js → chunk-7BBP7ZX3.js} +66 -54
- package/{chunk-VLTIYV3X.js → chunk-7I25CBT5.js} +34 -8
- package/{chunk-IBOZNTG2.js → chunk-7X5XZ34C.js} +23 -28
- package/chunk-AGIM7IMJ.js +147 -0
- package/{chunk-5UTFL4QJ.js → chunk-APO5TOXO.js} +1 -1
- package/{chunk-EEGDMATE.js → chunk-AZOVPTL6.js} +91 -81
- package/{chunk-6OZ36FXI.js → chunk-BIPGGSJS.js} +22 -4
- package/{chunk-EYAQT56M.js → chunk-BNQMNUKZ.js} +9 -6
- package/{chunk-62CATUYY.js → chunk-CBUMFIFE.js} +834 -962
- package/{chunk-OIVSQH2O.js → chunk-CDEEFJXN.js} +308 -11
- package/chunk-CHOZJMJS.js +78 -0
- package/{chunk-ETI2NYVF.js → chunk-CIP3AAMT.js} +4 -4
- package/{chunk-GBRG75BQ.js → chunk-D2MDMY2M.js} +1 -0
- package/{chunk-W7HLWAQ7.js → chunk-DE45KZNH.js} +118 -90
- package/{chunk-Q554LLSI.js → chunk-DMXLXZKL.js} +1 -1
- package/{chunk-3VNWWVKB.js → chunk-E3YWHWCR.js} +50 -18
- package/{chunk-HKNXJGEC.js → chunk-ECFHBYUW.js} +85 -50
- package/{chunk-ACTMNVHM.js → chunk-EHSYSKXV.js} +1 -1
- package/{chunk-WV42OMV7.js → chunk-ELUDRSRD.js} +8 -8
- package/{chunk-ABQYVJBJ.js → chunk-EV235ILT.js} +5 -5
- package/{chunk-TRV2MIDW.js → chunk-EXAJ6DCR.js} +1 -0
- package/{chunk-BFDFRLLQ.js → chunk-EZ4VZHAG.js} +5 -5
- package/{chunk-GO3Z72MT.js → chunk-FHLMQIU7.js} +65 -95
- package/{chunk-2F7RJC6L.js → chunk-FOXQ7BAB.js} +1 -1
- package/{chunk-SH43IESU.js → chunk-GGC55Q32.js} +199 -29
- package/chunk-GMZLP5DV.js +82 -0
- package/{chunk-FDTR4QJ6.js → chunk-H6A6X4EK.js} +32 -1
- package/{chunk-DVINR3PL.js → chunk-HDLLCBRF.js} +1 -1
- package/{chunk-QOKAKDPE.js → chunk-HIM3FCLF.js} +0 -1
- package/{chunk-ONXOABJR.js → chunk-HNGRBWYF.js} +3 -0
- package/{chunk-BNGW5ASC.js → chunk-I2RGRVQ7.js} +22 -2
- package/{chunk-O6OSWFZQ.js → chunk-IHPDK6UD.js} +6 -0
- package/{chunk-QDSINZM3.js → chunk-IXH3HKY2.js} +1 -22
- package/{chunk-GQBOR3G6.js → chunk-JBKHQOYK.js} +8 -4
- package/{chunk-XD2MJFUG.js → chunk-JEFXP73H.js} +1 -1
- package/{chunk-PBA4UJBK.js → chunk-JIXGJTBU.js} +4 -4
- package/{chunk-AEOE4Z6Q.js → chunk-K6L5PNXK.js} +39 -15
- package/{chunk-Z77CRGTW.js → chunk-KA5O5KQL.js} +1 -1
- package/{chunk-GPCZ7UXG.js → chunk-KD6D6BLA.js} +1 -1
- package/{chunk-4CR5I7BD.js → chunk-KFWDYYSS.js} +47 -67
- package/{chunk-UZGQNTVW.js → chunk-KHKTDMYG.js} +8 -6
- package/{chunk-JDPFV2JV.js → chunk-KWUKOQM2.js} +20 -11
- package/{chunk-MRIHM22T.js → chunk-LBFL6RZG.js} +58 -9
- package/{chunk-LS2ZANRJ.js → chunk-LOCNXNOU.js} +1 -1
- package/{chunk-DHDMC6FO.js → chunk-LUBFABMJ.js} +15 -14
- package/{chunk-NA35QHCF.js → chunk-LVBFKW65.js} +1 -1
- package/chunk-LWLNLZC5.js +265 -0
- package/chunk-N4NGJDT6.js +929 -0
- package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
- package/{chunk-FZGV4FGK.js → chunk-NUHHBEJC.js} +378 -187
- package/chunk-NWENLDMM.js +42 -0
- package/chunk-O7SVKKLY.js +875 -0
- package/chunk-OCZKATRC.js +129 -0
- package/{chunk-6Z7MY3V7.js → chunk-OEJLGVBL.js} +5 -5
- package/{chunk-VMFTFOWF.js → chunk-OKGVNZTL.js} +35 -8
- package/{chunk-GEPUP7OO.js → chunk-OR2UWD6X.js} +3 -3
- package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
- package/{chunk-J4MOO56S.js → chunk-PNXHPLRU.js} +10 -2
- package/{chunk-3BMYXEUW.js → chunk-R5AJODNI.js} +1 -1
- package/{chunk-P5EVSOPA.js → chunk-R6EBQEQE.js} +22 -29
- package/chunk-RQ6CTX2E.js +164 -0
- package/{chunk-MS7TSPZR.js → chunk-RU36ZYSG.js} +19 -17
- package/{chunk-ALXHV7NK.js → chunk-RWXLPUKI.js} +40 -4
- package/{chunk-KQ4ONNQD.js → chunk-RXA3HAVW.js} +190 -8
- package/{chunk-IIVGDG4I.js → chunk-SJKULPGX.js} +13 -7
- package/{chunk-Q67DOFOO.js → chunk-SZC4REES.js} +212 -105
- package/{chunk-JRQFUXY7.js → chunk-TBAXFWOS.js} +99 -22
- package/{chunk-PQFHGD77.js → chunk-TBM2RS3U.js} +161 -14
- package/{chunk-NOF3HDSN.js → chunk-TFOIJFCM.js} +11 -9
- package/{chunk-BYMV6QZG.js → chunk-TNIX77YM.js} +4 -0
- package/chunk-TY3TIUJK.js +89 -0
- package/{chunk-I3TQJXQ7.js → chunk-U3C3IA32.js} +9 -2
- package/{chunk-YYLHWIW6.js → chunk-UKZX3NHN.js} +1 -1
- package/chunk-UM7TA3K4.js +1008 -0
- package/{chunk-6YTOJY35.js → chunk-VBG7GWWR.js} +253 -8
- package/{chunk-GL3EHUR4.js → chunk-VHGYUYQ3.js} +69 -47
- package/chunk-VIWDGTDA.js +8 -0
- package/chunk-VJVNU77E.js +83 -0
- package/chunk-VM6IE2GN.js +8004 -0
- package/{chunk-UKWGR5SS.js → chunk-VY6VFGKR.js} +194 -1144
- package/chunk-VZLO4XJD.js +17 -0
- package/chunk-W32HPLTL.js +13692 -0
- package/{chunk-AHAHBQMU.js → chunk-WDLSZMTA.js} +2 -2
- package/{chunk-53HEEOTT.js → chunk-WF5X57VW.js} +83 -16
- package/{chunk-VRTTFDBM.js → chunk-WPHY3VPF.js} +35 -22
- package/{chunk-3L2WKC3W.js → chunk-XPWGOTBQ.js} +8 -1
- package/chunk-YV25TM3R.js +780 -0
- package/chunk-ZRAU6T47.js +56 -0
- package/{chunk-IBOOZVVD.js → chunk-ZTKZZY2A.js} +851 -279
- package/commandRegistry-ASW6IVZ3.js +833 -0
- package/{contentThunks-IV2T3EJC.js → contentThunks-4XNVOIR7.js} +39 -36
- package/{cooldownCommands-REAWYVTY.js → cooldownCommands-ZLEPIB4A.js} +2 -2
- package/{createAgentAutomationAction-JCOIEYY4.js → createAgentAutomationAction-NHHTCJMC.js} +40 -37
- package/createDialogAction-XEBTHDB3.js +70 -0
- package/{createPageAction-D2VOOLP3.js → createPageAction-VR3WW2AQ.js} +47 -43
- package/{chunk-FG3HKPQP.js → cursorProvider-YGGNMVWX.js} +2751 -10185
- package/{dbSlice-A6C6H32X.js → dbSlice-TG4MZ5EB.js} +12 -11
- package/{deleteFile-YG6QMJLU.js → deleteFile-KESP65GC.js} +7 -6
- package/{dialogCommands-H7FPUYUQ.js → dialogCommands-FJWQG3MX.js} +50 -47
- package/{dialogSlice-6JZOOTDS.js → dialogSlice-GVRDGCRG.js} +57 -37
- package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
- package/{docCreateCommands-WRG2JLGM.js → docCreateCommands-AZSK4NAG.js} +48 -44
- package/{docDeleteCommands-SHWJIBJS.js → docDeleteCommands-DDJMSMFZ.js} +49 -45
- package/{docReadCommands-WJN3WT6O.js → docReadCommands-5F5Q6EBZ.js} +47 -43
- package/{docStore-HUPQ2FSS.js → docStore-SUZUUWDI.js} +17 -13
- package/{docUpdateCommands-IE32IL6O.js → docUpdateCommands-XPNPVZOC.js} +48 -44
- package/{fetchMessages-EIU7UFFK.js → fetchMessages-3PXAHKCR.js} +5 -5
- package/{getPricing-LUSEABA6.js → getPricing-DOBBZLOK.js} +4 -4
- package/{handleSendMessageAction-DFPMQ7YM.js → handleSendMessageAction-VC6VTFKS.js} +109 -42
- package/index.js +87 -884
- package/{lib-FRRS27KN.js → lib-PU2G2MSO.js} +523 -191
- package/{localDialogRead-BTFJ4V2I.js → localDialogRead-UYCKO7YZ.js} +2 -2
- package/{localRuntimeAuthority-6IR6BBXE.js → localRuntimeAuthority-TU6OBC76.js} +9 -6
- package/{localRuntimeDb-SYQGUF4U.js → localRuntimeDb-VKWVOPPI.js} +1 -1
- package/{machineCommands-M2T2I5NF.js → machineCommands-M634V2L3.js} +98 -89
- package/machineWsRunDispatch-Z3HUSTFI.js +154 -0
- package/{memberThunks-P2ECUJ56.js → memberThunks-5S5D3N4U.js} +20 -18
- package/{models-T3SG6MJ5.js → models-PQU25T6Q.js} +2 -2
- package/oauthTokenStore-ITEB663N.js +23 -0
- package/package.json +1 -1
- package/processSpawn-SOAV3FEV.js +11 -0
- package/profileConfig-ZGOFORWV.js +43 -0
- package/{providerPresetApply-FG6NZ57W.js → providerPresetApply-HAQWVAQX.js} +7 -7
- package/{providerRegistry-757OWH3O.js → providerRegistry-5FGWB3X5.js} +11 -7
- package/{read-COE3ZYR6.js → read-LSYFLSIM.js} +8 -7
- package/{readDocTool-5USN4A6V.js → readDocTool-XWRXV3DR.js} +5 -3
- package/{readlineWorkspace-XQRDGWRZ.js → readlineWorkspace-J3YD3DNW.js} +2596 -2032
- package/{removeDialogAgentAction-J6X5QMTA.js → removeDialogAgentAction-4TEFC3VL.js} +22 -26
- package/{runAgentClientLoop-5ZA62FBA.js → runAgentClientLoop-APSMCLAF.js} +79 -72
- package/{runtimeDoctorCommands-X6WDBEQX.js → runtimeDoctorCommands-PIVSBZRZ.js} +4 -4
- package/runtimeModeArgs-2Y7BALTO.js +31 -0
- package/{setDialogExtraReferencesAction-WX5VTY6O.js → setDialogExtraReferencesAction-LSEN44OY.js} +16 -14
- package/{setPrimaryDialogAgentAction-FN22THHT.js → setPrimaryDialogAgentAction-SR366X5A.js} +23 -27
- package/{chunk-GP5LKBUZ.js → settingThunks-CTVPPGIN.js} +226 -940
- package/{skillDiscovery-CYUCJMAG.js → skillDiscovery-ZBU76COE.js} +3 -3
- package/{slateUtils-RIZES3PV.js → slateUtils-NGV2NMKM.js} +1 -1
- package/{spaceCommands-5GLCWZPO.js → spaceCommands-3UK63WPE.js} +51 -47
- package/{streamAgentChatTurn-6UZJMYRB.js → streamAgentChatTurn-DNY2PSRW.js} +215 -115
- package/{switchDialogAgentAction-LVTEV3FR.js → switchDialogAgentAction-M6NAFOOU.js} +19 -20
- package/{tableCommands-O6NWHFKV.js → tableCommands-6U4BMLRR.js} +10 -10
- package/{toolApiClient-QVJ6HDNN.js → toolApiClient-AD7CXTA4.js} +4 -3
- package/tools-X5UWATZK.js +117 -0
- package/{tuiSummaryLlmCaller-OHHFTHMG.js → tuiSummaryLlmCaller-DEH7ZEM6.js} +25 -23
- package/{updateCommands-2M74UL7P.js → updateCommands-4EHDLF5J.js} +3 -3
- package/{updateDialogTitleAction-QTKNIURB.js → updateDialogTitleAction-YSY5BF5A.js} +84 -45
- package/action-P4TNFGAD.js +0 -31
- package/agentListCommands-B2V4YAC4.js +0 -410
- package/agentRecordCommands-G4KK4R7H.js +0 -128
- package/agentRunCommand-UTZJA23G.js +0 -156
- package/browser-image-compression-MFDTD7K6.js +0 -1763
- package/chatQueueReduxAdapter-2P6NFX64.js +0 -186
- package/chunk-CQ3WA2NE.js +0 -299
- package/chunk-M76ECQRD.js +0 -13658
- package/chunk-MEYIRKDN.js +0 -8967
- package/chunk-PUOC4YRO.js +0 -394
- package/chunk-Q5FJJ6XI.js +0 -103
- package/chunk-S7Z2HMCN.js +0 -25
- package/chunk-T75QD6AB.js +0 -20923
- package/chunk-Y5GCAMGP.js +0 -9
- package/chunk-YPREESF4.js +0 -225
- package/createDialogAction-NGG7YVNU.js +0 -65
- package/machineWsRunDispatch-ISBKOOD7.js +0 -144
- package/settingSlice-P4ZW7K5X.js +0 -204
- package/syncMapping-N6RGXGBW.js +0 -437
- package/tools-KMGFWO43.js +0 -110
- package/{chunk-X7HHHIOZ.js → chunk-Y6ROFCZO.js} +0 -0
- package/{db-WK5MDZVN.js → db-VQSAOWAO.js} +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
findPotentialSecrets
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VJVNU77E.js";
|
|
4
4
|
import {
|
|
5
5
|
buildLocalRunEnv,
|
|
6
6
|
isFullstackCodingAgentRef,
|
|
@@ -10,9 +10,6 @@ import {
|
|
|
10
10
|
resolveServerUrl,
|
|
11
11
|
writeUsage
|
|
12
12
|
} from "./chunk-V7E4PXQD.js";
|
|
13
|
-
import {
|
|
14
|
-
resolveMachineId
|
|
15
|
-
} from "./chunk-ESHYE7WU.js";
|
|
16
13
|
import {
|
|
17
14
|
agentRunCardLabels,
|
|
18
15
|
createCliLocalRuntimeAdapter,
|
|
@@ -29,57 +26,57 @@ import {
|
|
|
29
26
|
resolveFileWriteGateEnabled,
|
|
30
27
|
resolveLocalUserId,
|
|
31
28
|
t,
|
|
32
|
-
toolLabel
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
createRunActivityTracker,
|
|
36
|
-
popSingleQueueMessage,
|
|
37
|
-
readRunRecord,
|
|
38
|
-
resolveRunQueuePath,
|
|
39
|
-
settleRunTerminalAuthoritatively,
|
|
40
|
-
spawnLocalBackgroundRun
|
|
41
|
-
} from "./chunk-I3TQJXQ7.js";
|
|
29
|
+
toolLabel,
|
|
30
|
+
toolLabelVariants
|
|
31
|
+
} from "./chunk-VM6IE2GN.js";
|
|
42
32
|
import {
|
|
43
33
|
clearCredentialAvailability,
|
|
44
34
|
readCredentialEntry,
|
|
45
|
-
recordCredentialProbe
|
|
46
|
-
|
|
47
|
-
} from "./chunk-42V6BK2E.js";
|
|
35
|
+
recordCredentialProbe
|
|
36
|
+
} from "./chunk-62IL3KQV.js";
|
|
48
37
|
import {
|
|
49
38
|
getReadableCliDb
|
|
50
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-LOCNXNOU.js";
|
|
40
|
+
import {
|
|
41
|
+
_appendEntityBatch,
|
|
42
|
+
_appendEvidenceBatch,
|
|
43
|
+
_appendRelationBatch,
|
|
44
|
+
_appendRetiredStateBatch,
|
|
45
|
+
_appendStateBatch,
|
|
46
|
+
getMemoryEntityVNext,
|
|
47
|
+
getMemoryEvidenceVNext,
|
|
48
|
+
getMemoryEvidenceVNextStrict,
|
|
49
|
+
getMemoryStateVNext,
|
|
50
|
+
listMemoryStatesForEntityVNext,
|
|
51
|
+
loadMemoryVNextCatalog,
|
|
52
|
+
putMemoryEvidenceVNext
|
|
53
|
+
} from "./chunk-TY3TIUJK.js";
|
|
51
54
|
import {
|
|
52
55
|
readDbRecord,
|
|
53
56
|
resolveAgentRecordFromHybridStore
|
|
54
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-K6L5PNXK.js";
|
|
55
58
|
import {
|
|
56
59
|
isLocalCliAgentKey
|
|
57
60
|
} from "./chunk-SV5IJK6K.js";
|
|
58
61
|
import {
|
|
59
62
|
CliProviderQuotaError
|
|
60
63
|
} from "./chunk-MP64VFGD.js";
|
|
64
|
+
import {
|
|
65
|
+
resolveMachineId
|
|
66
|
+
} from "./chunk-ESHYE7WU.js";
|
|
61
67
|
import {
|
|
62
68
|
applyModelLayerOverride,
|
|
63
69
|
buildModelLayerOverride
|
|
64
70
|
} from "./chunk-LTRXGFMS.js";
|
|
65
|
-
import {
|
|
66
|
-
formatAgentListCard
|
|
67
|
-
} from "./chunk-C3M4465B.js";
|
|
68
|
-
import {
|
|
69
|
-
isTransientFetchError
|
|
70
|
-
} from "./chunk-5UTFL4QJ.js";
|
|
71
71
|
import {
|
|
72
72
|
isGatewayHttpStatus
|
|
73
73
|
} from "./chunk-NF64D32W.js";
|
|
74
74
|
import {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
formatStopRunCard,
|
|
81
|
-
isAgentRunTerminalStatus
|
|
82
|
-
} from "./chunk-3VNWWVKB.js";
|
|
75
|
+
isTransientFetchError
|
|
76
|
+
} from "./chunk-APO5TOXO.js";
|
|
77
|
+
import {
|
|
78
|
+
parsePositiveFiniteNumberOrFallback
|
|
79
|
+
} from "./chunk-XPWGOTBQ.js";
|
|
83
80
|
import {
|
|
84
81
|
extractGoogleValidationLink
|
|
85
82
|
} from "./chunk-BMQ2MJUK.js";
|
|
@@ -88,37 +85,55 @@ import {
|
|
|
88
85
|
chooseMemoryOwners,
|
|
89
86
|
loadMemoryCandidatesFromDb,
|
|
90
87
|
resolveAgentMemoryPolicy
|
|
91
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-7X5XZ34C.js";
|
|
92
89
|
import {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
createRunActivityTracker,
|
|
91
|
+
popSingleQueueMessage,
|
|
92
|
+
readRunRecord,
|
|
93
|
+
resolveRunQueuePath,
|
|
94
|
+
settleRunTerminalAuthoritatively,
|
|
95
|
+
spawnLocalBackgroundRun
|
|
96
|
+
} from "./chunk-U3C3IA32.js";
|
|
96
97
|
import {
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
formatAgentListCard,
|
|
99
|
+
formatFinishedRunCard,
|
|
100
|
+
formatListRunsCard,
|
|
101
|
+
formatNotFoundRunCard,
|
|
102
|
+
formatStartRunCard,
|
|
103
|
+
formatStatusRunCard,
|
|
104
|
+
formatStopRunCard,
|
|
105
|
+
isAgentRunTerminalStatus
|
|
106
|
+
} from "./chunk-E3YWHWCR.js";
|
|
99
107
|
import {
|
|
100
108
|
isCliAuthorityBrokerProtocolError,
|
|
101
109
|
isCliAuthorityBrokerTimeoutError,
|
|
102
110
|
isCliAuthorityBrokerUnavailableError
|
|
103
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-EXAJ6DCR.js";
|
|
104
112
|
import {
|
|
105
113
|
getDefaultCliLocalRuntimeDb
|
|
106
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-FOXQ7BAB.js";
|
|
115
|
+
import {
|
|
116
|
+
API_REPORTED_COST_MULTIPLIER,
|
|
117
|
+
parseUiAskChoiceContent
|
|
118
|
+
} from "./chunk-W32HPLTL.js";
|
|
119
|
+
import {
|
|
120
|
+
isOAuthApiKeyRef
|
|
121
|
+
} from "./chunk-UKZX3NHN.js";
|
|
107
122
|
import {
|
|
108
123
|
buildSkillDiscoveryContextLayer
|
|
109
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-5GVBDNTO.js";
|
|
110
125
|
import {
|
|
111
126
|
parseExternalSkillMarkdown,
|
|
112
127
|
parseSkillDocProtocol
|
|
113
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-DMXLXZKL.js";
|
|
114
129
|
import {
|
|
115
130
|
LOCAL_AGENT_CONFIG_MISSING_CODE,
|
|
116
131
|
LOCAL_TURN_ABORTED_CODE,
|
|
117
132
|
readActionGate
|
|
118
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-CBUMFIFE.js";
|
|
119
134
|
import {
|
|
120
135
|
resolveAgentRuntimeConfigFromRecord
|
|
121
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-6MAW4XOF.js";
|
|
122
137
|
import {
|
|
123
138
|
createThinkParserState,
|
|
124
139
|
flushThinkParser,
|
|
@@ -129,57 +144,55 @@ import {
|
|
|
129
144
|
isQuotaExhaustedError,
|
|
130
145
|
isQuotaLimited403Body,
|
|
131
146
|
mergeAvailabilityDeadline,
|
|
132
|
-
resolveCooldownGate
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
isAntigravityOAuthAgent
|
|
136
|
-
} from "./chunk-UZGQNTVW.js";
|
|
137
|
-
import {
|
|
138
|
-
resolveClientVersion
|
|
139
|
-
} from "./chunk-6OZ36FXI.js";
|
|
147
|
+
resolveCooldownGate,
|
|
148
|
+
resolveCredentialKeyWithFallback
|
|
149
|
+
} from "./chunk-H6A6X4EK.js";
|
|
140
150
|
import {
|
|
141
151
|
DEFAULT_CONTEXT_WINDOW,
|
|
142
152
|
getModelContextWindow,
|
|
143
153
|
normalizeUsage
|
|
144
|
-
} from "./chunk-
|
|
154
|
+
} from "./chunk-ECFHBYUW.js";
|
|
145
155
|
import {
|
|
146
156
|
clipCompactText
|
|
147
|
-
} from "./chunk-
|
|
148
|
-
import {
|
|
149
|
-
findModelConfig
|
|
150
|
-
} from "./chunk-OIVSQH2O.js";
|
|
157
|
+
} from "./chunk-5MMAK75Q.js";
|
|
151
158
|
import {
|
|
152
159
|
compactWhitespace
|
|
153
160
|
} from "./chunk-DWLEOOGR.js";
|
|
154
|
-
import {
|
|
155
|
-
toErrorMessage
|
|
156
|
-
} from "./chunk-HNMXYYJR.js";
|
|
157
161
|
import {
|
|
158
162
|
buildAgentsMdLayer,
|
|
159
163
|
buildMemoryOverlayLayer,
|
|
160
164
|
buildMemoryUseGuidanceLayer,
|
|
161
165
|
partitionScopedBlocks,
|
|
162
166
|
renderTurnContextBlocksWithScope
|
|
163
|
-
} from "./chunk-
|
|
167
|
+
} from "./chunk-HDLLCBRF.js";
|
|
164
168
|
import {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
isAntigravityOAuthAgent
|
|
170
|
+
} from "./chunk-KHKTDMYG.js";
|
|
171
|
+
import {
|
|
172
|
+
resolveClientVersion
|
|
173
|
+
} from "./chunk-BIPGGSJS.js";
|
|
174
|
+
import {
|
|
175
|
+
findModelConfig
|
|
176
|
+
} from "./chunk-CDEEFJXN.js";
|
|
177
|
+
import {
|
|
178
|
+
toErrorMessage
|
|
179
|
+
} from "./chunk-HNMXYYJR.js";
|
|
180
|
+
import {
|
|
181
|
+
getLogger,
|
|
182
|
+
normalizeError
|
|
183
|
+
} from "./chunk-YV25TM3R.js";
|
|
168
184
|
import {
|
|
169
185
|
resolveAuthToken
|
|
170
186
|
} from "./chunk-A7GB5UGH.js";
|
|
187
|
+
import {
|
|
188
|
+
readPipeText,
|
|
189
|
+
spawnProcess
|
|
190
|
+
} from "./chunk-Y6ROFCZO.js";
|
|
171
191
|
import {
|
|
172
192
|
CLIENT_VERSION_TOO_OLD_CODE,
|
|
173
193
|
NOLO_CLIENT_VERSION_HEADER,
|
|
174
194
|
buildClientVersionUpgradeMessage
|
|
175
|
-
} from "./chunk-
|
|
176
|
-
import {
|
|
177
|
-
parsePositiveFiniteNumberOrFallback
|
|
178
|
-
} from "./chunk-Y5GCAMGP.js";
|
|
179
|
-
import {
|
|
180
|
-
createMemoryKey,
|
|
181
|
-
ulid
|
|
182
|
-
} from "./chunk-VMFTFOWF.js";
|
|
195
|
+
} from "./chunk-SZC4REES.js";
|
|
183
196
|
import {
|
|
184
197
|
asTrimmedLowercaseString
|
|
185
198
|
} from "./chunk-QSJ3HFEF.js";
|
|
@@ -187,13 +200,14 @@ import {
|
|
|
187
200
|
BUILTIN_NOLO_AGENT_KEY,
|
|
188
201
|
BUILTIN_NOLO_AGENT_NAME,
|
|
189
202
|
builtinAgentCatalogEntryById
|
|
190
|
-
} from "./chunk-
|
|
203
|
+
} from "./chunk-I2RGRVQ7.js";
|
|
191
204
|
import {
|
|
192
205
|
parsePublicAgentId
|
|
193
206
|
} from "./chunk-M2EJHDJP.js";
|
|
194
207
|
import {
|
|
195
|
-
|
|
196
|
-
|
|
208
|
+
createMemoryKey,
|
|
209
|
+
ulid
|
|
210
|
+
} from "./chunk-OKGVNZTL.js";
|
|
197
211
|
import {
|
|
198
212
|
asTrimmedString
|
|
199
213
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -8206,7 +8220,12 @@ function emitPlainGap(text, keywords, info, accent, warning, reset) {
|
|
|
8206
8220
|
var UNORDERED_LIST_RE = /^(\s*)([-*+])\s+(.+)$/;
|
|
8207
8221
|
var ORDERED_LIST_RE = /^(\s*)(\d+)\.\s+(.+)$/;
|
|
8208
8222
|
var TASK_LIST_RE = /^(\s*)([-*+])\s+\[([ xX])\]\s+(.+)$/;
|
|
8223
|
+
var THEMATIC_BREAK_PATTERN = "(?:(-[ \\t]*){3,}|(\\*[ \\t]*){3,}|(_[ \\t]*){3,})";
|
|
8224
|
+
var THEMATIC_BREAK_RE = new RegExp(`^[ ]{0,3}${THEMATIC_BREAK_PATTERN}$`);
|
|
8209
8225
|
function normalizeListLine(line) {
|
|
8226
|
+
if (THEMATIC_BREAK_RE.test(line)) {
|
|
8227
|
+
return line;
|
|
8228
|
+
}
|
|
8210
8229
|
const task = line.match(TASK_LIST_RE);
|
|
8211
8230
|
if (task) {
|
|
8212
8231
|
const checked = task[3] === "x" || task[3] === "X";
|
|
@@ -8222,12 +8241,99 @@ function normalizeListLine(line) {
|
|
|
8222
8241
|
}
|
|
8223
8242
|
return line;
|
|
8224
8243
|
}
|
|
8244
|
+
var TOOL_TREE_HEADER_RE = /^•\s+(.+?)\s+\((\d+)\)$/;
|
|
8245
|
+
var TOOL_TREE_LEAF_RE = /^([├└]──\s+)(.*?)\s{2}(✓|✗|!)(?:\s+(.*))?$/;
|
|
8246
|
+
var TOOL_SINGLE_RE = /^▸\s+(.+?)(?:\s+·\s+(.*?))?(?:\s{2}(✓|✗|!)(?:\s+(.*))?)$/;
|
|
8247
|
+
function plainToolLine(line) {
|
|
8248
|
+
return stripAnsi2(line);
|
|
8249
|
+
}
|
|
8250
|
+
var TOOL_TREE_GROUP_LABELS = new Set(
|
|
8251
|
+
["execShell", "readFile", "fetchWebpage", "exa_search"].flatMap(toolLabelVariants)
|
|
8252
|
+
);
|
|
8253
|
+
function isKnownToolGroupLabel(label) {
|
|
8254
|
+
return TOOL_TREE_GROUP_LABELS.has(label);
|
|
8255
|
+
}
|
|
8256
|
+
function toolTreeHeaderMatch(line) {
|
|
8257
|
+
const match = plainToolLine(line).match(TOOL_TREE_HEADER_RE);
|
|
8258
|
+
return match && isKnownToolGroupLabel(match[1]) ? match : null;
|
|
8259
|
+
}
|
|
8260
|
+
function isToolTreeHeaderLine(line) {
|
|
8261
|
+
return toolTreeHeaderMatch(line) !== null;
|
|
8262
|
+
}
|
|
8263
|
+
function isToolTreeLeafLine(line) {
|
|
8264
|
+
return TOOL_TREE_LEAF_RE.test(plainToolLine(line));
|
|
8265
|
+
}
|
|
8266
|
+
function isToolSingleLine(line) {
|
|
8267
|
+
return TOOL_SINGLE_RE.test(plainToolLine(line));
|
|
8268
|
+
}
|
|
8269
|
+
function isToolGroupBoundary(cur, next) {
|
|
8270
|
+
return isToolTreeLeafLine(cur) && isToolTreeHeaderLine(next);
|
|
8271
|
+
}
|
|
8272
|
+
function statusColorSeq(marker, brightness) {
|
|
8273
|
+
if (marker === "\u2713") return colorSeq("success", brightness);
|
|
8274
|
+
if (marker === "\u2717") return colorSeq("danger", brightness);
|
|
8275
|
+
return colorSeq("warning", brightness);
|
|
8276
|
+
}
|
|
8277
|
+
function styleTuiToolLine(line, brightness) {
|
|
8278
|
+
const plain = plainToolLine(line);
|
|
8279
|
+
const chrome = colorSeq("chrome", brightness);
|
|
8280
|
+
const muted = colorSeq("muted", brightness);
|
|
8281
|
+
const header = toolTreeHeaderMatch(plain);
|
|
8282
|
+
if (header) {
|
|
8283
|
+
return `${chrome}\u2022${STYLE.reset} ${STYLE.bold}${muted}${header[1]}${STYLE.reset} ${chrome}${STYLE.dim}(${header[2]})${STYLE.reset}`;
|
|
8284
|
+
}
|
|
8285
|
+
const leaf = plain.match(TOOL_TREE_LEAF_RE);
|
|
8286
|
+
if (leaf) {
|
|
8287
|
+
const [, connector, detail, marker, statusDetail] = leaf;
|
|
8288
|
+
let rendered = `${chrome}${connector}${STYLE.reset}${chrome}${detail}${STYLE.reset}`;
|
|
8289
|
+
rendered += ` ${statusColorSeq(marker, brightness)}${marker}${STYLE.reset}`;
|
|
8290
|
+
if (statusDetail) {
|
|
8291
|
+
const metaSeq = marker === "\u2713" ? chrome : statusColorSeq(marker, brightness);
|
|
8292
|
+
rendered += ` ${metaSeq}${STYLE.dim}${statusDetail}${STYLE.reset}`;
|
|
8293
|
+
}
|
|
8294
|
+
return rendered;
|
|
8295
|
+
}
|
|
8296
|
+
const single = plain.match(TOOL_SINGLE_RE);
|
|
8297
|
+
if (single) {
|
|
8298
|
+
const [, label, detail, marker, statusDetail] = single;
|
|
8299
|
+
let rendered = `${chrome}\u25B8${STYLE.reset} ${STYLE.bold}${muted}${label}${STYLE.reset}`;
|
|
8300
|
+
if (detail) rendered += ` ${chrome}\xB7 ${detail}${STYLE.reset}`;
|
|
8301
|
+
rendered += ` ${statusColorSeq(marker, brightness)}${marker}${STYLE.reset}`;
|
|
8302
|
+
if (statusDetail) {
|
|
8303
|
+
const metaSeq = marker === "\u2713" ? chrome : statusColorSeq(marker, brightness);
|
|
8304
|
+
rendered += ` ${metaSeq}${STYLE.dim}${statusDetail}${STYLE.reset}`;
|
|
8305
|
+
}
|
|
8306
|
+
return rendered;
|
|
8307
|
+
}
|
|
8308
|
+
return null;
|
|
8309
|
+
}
|
|
8225
8310
|
function isPolishListLikeLine(line) {
|
|
8226
|
-
return LIST_LIKE_RE_FOR_GUARD.test(normalizeListLine(line));
|
|
8311
|
+
return LIST_LIKE_RE_FOR_GUARD.test(normalizeListLine(plainToolLine(line)));
|
|
8312
|
+
}
|
|
8313
|
+
var LIST_LIKE_RE_FOR_GUARD = /^\s*(?:•|◦|☐|☑|\d+\.)\s|^\s*[\u2460-\u2473]|^\s*[├└]──\s|^\s*▸\s/;
|
|
8314
|
+
function isPolishFenceInteriorLine(line) {
|
|
8315
|
+
return /^\x00F\d+\x00$/.test(line);
|
|
8316
|
+
}
|
|
8317
|
+
function polishHeadingLevel(line) {
|
|
8318
|
+
const match = stripAnsi2(line).match(/^(#{1,6})\s/);
|
|
8319
|
+
return match ? match[1].length : null;
|
|
8320
|
+
}
|
|
8321
|
+
function isPolishHeadingLine(line) {
|
|
8322
|
+
return polishHeadingLevel(line) !== null;
|
|
8323
|
+
}
|
|
8324
|
+
function isPolishIntroLine(line) {
|
|
8325
|
+
const plain = stripAnsi2(line).trimEnd();
|
|
8326
|
+
return plain.endsWith("\uFF1A") || plain.endsWith(":");
|
|
8227
8327
|
}
|
|
8228
|
-
var LIST_LIKE_RE_FOR_GUARD = /^\s*(?:•|☐|☑|\d+\.)\s|^\s*[\u2460-\u2473]|^\s*[├└]──\s/;
|
|
8229
8328
|
function polishBreathInsertsBlankBetween(cur, next) {
|
|
8230
8329
|
if (cur === "" || next === "") return false;
|
|
8330
|
+
if (isPolishFenceInteriorLine(cur) || isPolishFenceInteriorLine(next)) {
|
|
8331
|
+
return false;
|
|
8332
|
+
}
|
|
8333
|
+
if (isPolishIntroLine(cur) && isPolishListLikeLine(next)) return false;
|
|
8334
|
+
if (isPolishHeadingLine(cur) || isPolishHeadingLine(next)) return false;
|
|
8335
|
+
if (isCodeFenceLine(cur) !== isCodeFenceLine(next)) return true;
|
|
8336
|
+
if (isToolGroupBoundary(cur, next)) return true;
|
|
8231
8337
|
return isPolishListLikeLine(cur) !== isPolishListLikeLine(next);
|
|
8232
8338
|
}
|
|
8233
8339
|
function convertMarkdownTablesForTerminal(text) {
|
|
@@ -8296,17 +8402,15 @@ function polishAssistantStructure(text, options = {}) {
|
|
|
8296
8402
|
}
|
|
8297
8403
|
return line;
|
|
8298
8404
|
});
|
|
8299
|
-
const afterHeading = maskedLines.join("\n").replace(/([^\n])\n(#{1,
|
|
8300
|
-
const LIST_LIKE = /^\s*(?:•|☐|☑|\d+\.)\s|^\s*[\u2460-\u2473]|^\s*[├└]──\s/;
|
|
8405
|
+
const afterHeading = maskedLines.join("\n").replace(/([^\n])\n(#{1,6} )/g, "$1\n\n$2").replace(/^(#{1,2} .+)\n(?!\n)/gm, "$1\n\n").replace(new RegExp(`([^\\n])\\n([ ]{0,3}${THEMATIC_BREAK_PATTERN})$`, "gm"), "$1\n\n$2").replace(new RegExp(`^([ ]{0,3}${THEMATIC_BREAK_PATTERN})\\n(?!\\n)`, "gm"), "$1\n\n").replace(/\n{3,}/g, "\n\n");
|
|
8301
8406
|
const headingLines = afterHeading.split("\n");
|
|
8302
8407
|
const breathed = [];
|
|
8303
8408
|
for (let i = 0; i < headingLines.length; i++) {
|
|
8304
8409
|
breathed.push(headingLines[i]);
|
|
8305
8410
|
const cur = headingLines[i];
|
|
8306
8411
|
const next = headingLines[i + 1];
|
|
8307
|
-
if (
|
|
8308
|
-
if (
|
|
8309
|
-
breathed.push("");
|
|
8412
|
+
if (next === void 0) continue;
|
|
8413
|
+
if (polishBreathInsertsBlankBetween(cur, next)) breathed.push("");
|
|
8310
8414
|
}
|
|
8311
8415
|
const polishedMasked = breathed.join("\n");
|
|
8312
8416
|
const polished = polishedMasked.replace(
|
|
@@ -8316,17 +8420,23 @@ function polishAssistantStructure(text, options = {}) {
|
|
|
8316
8420
|
return options.trimEdges === false ? polished : polished.trim();
|
|
8317
8421
|
}
|
|
8318
8422
|
function styleRichMarkdownLine(line, brightness) {
|
|
8319
|
-
const
|
|
8423
|
+
const toolLine = styleTuiToolLine(line, brightness);
|
|
8424
|
+
if (toolLine !== null) return toolLine;
|
|
8425
|
+
const heading = line.match(/^(#{1,6})\s+(.+)$/);
|
|
8320
8426
|
if (heading) {
|
|
8321
8427
|
const level = heading[1].length;
|
|
8322
8428
|
const title = heading[2];
|
|
8429
|
+
const styledTitle = styleInlineMarkdown(title, brightness);
|
|
8323
8430
|
if (level === 1) {
|
|
8324
|
-
return `${STYLE.bold}
|
|
8431
|
+
return `${STYLE.bold}${colorSeq("accent", brightness)}${styledTitle}${STYLE.reset}`;
|
|
8325
8432
|
}
|
|
8326
8433
|
if (level === 2) {
|
|
8327
|
-
return `${STYLE.bold}${colorSeq("warning", brightness)}${
|
|
8434
|
+
return `${STYLE.bold}${colorSeq("warning", brightness)}${styledTitle}${STYLE.reset}`;
|
|
8435
|
+
}
|
|
8436
|
+
if (level === 3) {
|
|
8437
|
+
return `${STYLE.bold}${colorSeq("info", brightness)}${styledTitle}${STYLE.reset}`;
|
|
8328
8438
|
}
|
|
8329
|
-
return `${STYLE.bold}${colorSeq("
|
|
8439
|
+
return `${STYLE.bold}${colorSeq("muted", brightness)}${styledTitle}${STYLE.reset}`;
|
|
8330
8440
|
}
|
|
8331
8441
|
if (line.startsWith("\u8FDB\u5165 nolo-plan")) {
|
|
8332
8442
|
return `${colorSeq("chrome", brightness)}${STYLE.dim}${line}${STYLE.reset}`;
|
|
@@ -8335,15 +8445,19 @@ function styleRichMarkdownLine(line, brightness) {
|
|
|
8335
8445
|
if (blockquote) {
|
|
8336
8446
|
const border = colorSeq("chrome", brightness);
|
|
8337
8447
|
const content = blockquote[1];
|
|
8338
|
-
|
|
8448
|
+
const styled = styleInlineMarkdown(content, brightness);
|
|
8449
|
+
return `${border}\u2502${STYLE.reset} ${STYLE.dim}${styled}${STYLE.reset}`;
|
|
8339
8450
|
}
|
|
8340
|
-
if (
|
|
8341
|
-
return `${colorSeq("chrome", brightness)}${"\u2500".repeat(
|
|
8451
|
+
if (THEMATIC_BREAK_RE.test(line)) {
|
|
8452
|
+
return `${colorSeq("chrome", brightness)}${STYLE.dim}${"\u2500".repeat(36)}${STYLE.reset}`;
|
|
8342
8453
|
}
|
|
8343
8454
|
const bullet = line.match(/^(\s*)(•)\s(.+)$/);
|
|
8344
8455
|
if (bullet) {
|
|
8456
|
+
const indent = bullet[1];
|
|
8345
8457
|
const styled = styleInlineMarkdown(bullet[3], brightness);
|
|
8346
|
-
|
|
8458
|
+
const marker = indent.length >= 2 ? "\u25E6" : "\u2022";
|
|
8459
|
+
const markerColor = indent.length >= 2 ? colorSeq("chrome", brightness) : colorSeq("accent", brightness);
|
|
8460
|
+
return `${indent}${markerColor}${marker}${STYLE.reset} ${styled}`;
|
|
8347
8461
|
}
|
|
8348
8462
|
const ordered = line.match(/^(\s*)(\d+\.)\s(.+)$/);
|
|
8349
8463
|
if (ordered) {
|
|
@@ -8467,16 +8581,28 @@ function emitFormattedAssistantBlock(write, text, trailingNewline = false) {
|
|
|
8467
8581
|
}
|
|
8468
8582
|
function classifyStreamLine(line) {
|
|
8469
8583
|
if (line === "") return "blank";
|
|
8470
|
-
|
|
8584
|
+
const plain = plainToolLine(line);
|
|
8585
|
+
if (isToolTreeHeaderLine(plain)) return "tool-header";
|
|
8586
|
+
if (isToolTreeLeafLine(plain)) return "tool-leaf";
|
|
8587
|
+
if (isToolSingleLine(plain)) return "tool";
|
|
8588
|
+
if (TASK_LIST_RE.test(plain) || UNORDERED_LIST_RE.test(plain) || ORDERED_LIST_RE.test(plain) || /^\s*(?:•|◦|☐|☑)\s/.test(plain) || /^\s*[\u2460-\u2473]/.test(plain)) {
|
|
8471
8589
|
return "list";
|
|
8472
8590
|
}
|
|
8591
|
+
if (isPolishListLikeLine(plain)) return "list";
|
|
8592
|
+
if (polishHeadingLevel(plain) !== null) return "heading";
|
|
8473
8593
|
return "prose";
|
|
8474
8594
|
}
|
|
8475
|
-
function
|
|
8595
|
+
function isStreamListLike(kind) {
|
|
8596
|
+
return kind === "list" || kind === "tool-header" || kind === "tool-leaf" || kind === "tool";
|
|
8597
|
+
}
|
|
8598
|
+
function needsListProseBreath(prev, next, prevLine = "") {
|
|
8476
8599
|
if (prev === null || prev === "blank" || next === "blank") return false;
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8600
|
+
if (next === "heading") return true;
|
|
8601
|
+
if (prev === "heading") return (polishHeadingLevel(prevLine) ?? 7) <= 2;
|
|
8602
|
+
if (prev === "fence" !== (next === "fence")) return true;
|
|
8603
|
+
if (isStreamListLike(next) && isPolishIntroLine(prevLine)) return false;
|
|
8604
|
+
if (prev === "tool-leaf" && next === "tool-header") return true;
|
|
8605
|
+
return isStreamListLike(prev) !== isStreamListLike(next);
|
|
8480
8606
|
}
|
|
8481
8607
|
function createRenderAwareStreamWriter(args) {
|
|
8482
8608
|
const brightness = resolveTuiBrightness();
|
|
@@ -8486,9 +8612,16 @@ function createRenderAwareStreamWriter(args) {
|
|
|
8486
8612
|
let inMermaid = false;
|
|
8487
8613
|
let mermaidBody = [];
|
|
8488
8614
|
let lastKind = null;
|
|
8615
|
+
let lastLine = "";
|
|
8616
|
+
let pendingBlankRow = false;
|
|
8489
8617
|
const PARTIAL_FLUSH_THRESHOLD = 48;
|
|
8490
8618
|
const emitBreathIfNeeded = (nextKind) => {
|
|
8491
|
-
if (
|
|
8619
|
+
if (pendingBlankRow) {
|
|
8620
|
+
args.write("\n");
|
|
8621
|
+
pendingBlankRow = false;
|
|
8622
|
+
lastKind = "blank";
|
|
8623
|
+
}
|
|
8624
|
+
if (needsListProseBreath(lastKind, nextKind, lastLine)) args.write("\n");
|
|
8492
8625
|
};
|
|
8493
8626
|
const flushPartialProse = () => {
|
|
8494
8627
|
if (inFence || buffer.length < PARTIAL_FLUSH_THRESHOLD) return;
|
|
@@ -8506,6 +8639,7 @@ function createRenderAwareStreamWriter(args) {
|
|
|
8506
8639
|
emitBreathIfNeeded("prose");
|
|
8507
8640
|
emitFormattedAssistantBlock(args.write, prefix, false);
|
|
8508
8641
|
lastKind = "prose";
|
|
8642
|
+
lastLine = prefix;
|
|
8509
8643
|
buffer = prefix.length === buffer.length ? "" : buffer.slice(prefix.length);
|
|
8510
8644
|
};
|
|
8511
8645
|
const flushCompleteBlocks = () => {
|
|
@@ -8521,10 +8655,11 @@ function createRenderAwareStreamWriter(args) {
|
|
|
8521
8655
|
inMermaid = false;
|
|
8522
8656
|
inFence = false;
|
|
8523
8657
|
fenceLang = "unknown";
|
|
8524
|
-
emitBreathIfNeeded("
|
|
8658
|
+
emitBreathIfNeeded("fence");
|
|
8525
8659
|
args.write(`${STYLE.dim}${firstLine}${STYLE.reset}
|
|
8526
8660
|
`);
|
|
8527
|
-
lastKind = "
|
|
8661
|
+
lastKind = "fence";
|
|
8662
|
+
lastLine = firstLine;
|
|
8528
8663
|
buffer = lines.slice(1).join("\n");
|
|
8529
8664
|
continue;
|
|
8530
8665
|
}
|
|
@@ -8540,10 +8675,11 @@ function createRenderAwareStreamWriter(args) {
|
|
|
8540
8675
|
}
|
|
8541
8676
|
inFence = true;
|
|
8542
8677
|
}
|
|
8543
|
-
emitBreathIfNeeded("
|
|
8678
|
+
emitBreathIfNeeded("fence");
|
|
8544
8679
|
args.write(`${STYLE.dim}${firstLine}${STYLE.reset}
|
|
8545
8680
|
`);
|
|
8546
|
-
lastKind = "
|
|
8681
|
+
lastKind = "fence";
|
|
8682
|
+
lastLine = firstLine;
|
|
8547
8683
|
buffer = lines.slice(1).join("\n");
|
|
8548
8684
|
continue;
|
|
8549
8685
|
}
|
|
@@ -8555,7 +8691,8 @@ function createRenderAwareStreamWriter(args) {
|
|
|
8555
8691
|
if (inFence) {
|
|
8556
8692
|
args.write(`${highlightCodeLine(firstLine, fenceLang, brightness)}
|
|
8557
8693
|
`);
|
|
8558
|
-
lastKind = "
|
|
8694
|
+
lastKind = "fence";
|
|
8695
|
+
lastLine = firstLine;
|
|
8559
8696
|
buffer = lines.slice(1).join("\n");
|
|
8560
8697
|
continue;
|
|
8561
8698
|
}
|
|
@@ -8568,6 +8705,7 @@ function createRenderAwareStreamWriter(args) {
|
|
|
8568
8705
|
const inner = trimmedFirst.slice(2, trimmedFirst.length - 2);
|
|
8569
8706
|
args.write(renderMathBlock(inner) + "\n");
|
|
8570
8707
|
lastKind = "other";
|
|
8708
|
+
lastLine = trimmedFirst;
|
|
8571
8709
|
buffer = lines.slice(1).join("\n");
|
|
8572
8710
|
continue;
|
|
8573
8711
|
}
|
|
@@ -8594,6 +8732,7 @@ function createRenderAwareStreamWriter(args) {
|
|
|
8594
8732
|
if (lastInner) innerParts.push(lastInner);
|
|
8595
8733
|
args.write(renderMathBlock(innerParts.join("\n")) + "\n");
|
|
8596
8734
|
lastKind = "other";
|
|
8735
|
+
lastLine = trimmedFirst;
|
|
8597
8736
|
buffer = lines.slice(closeIndex + 1).join("\n");
|
|
8598
8737
|
continue;
|
|
8599
8738
|
}
|
|
@@ -8614,14 +8753,23 @@ function createRenderAwareStreamWriter(args) {
|
|
|
8614
8753
|
true
|
|
8615
8754
|
);
|
|
8616
8755
|
lastKind = "list";
|
|
8756
|
+
lastLine = lines[end - 1] ?? firstLine;
|
|
8617
8757
|
buffer = lines.slice(end).join("\n");
|
|
8618
8758
|
continue;
|
|
8619
8759
|
}
|
|
8620
8760
|
}
|
|
8621
8761
|
const kind = classifyStreamLine(firstLine);
|
|
8762
|
+
if (kind === "blank") {
|
|
8763
|
+
if (lastKind !== null && lastKind !== "blank") pendingBlankRow = true;
|
|
8764
|
+
lastKind = "blank";
|
|
8765
|
+
lastLine = "";
|
|
8766
|
+
buffer = lines.slice(1).join("\n");
|
|
8767
|
+
continue;
|
|
8768
|
+
}
|
|
8622
8769
|
emitBreathIfNeeded(kind);
|
|
8623
8770
|
emitFormattedAssistantBlock(args.write, firstLine, true);
|
|
8624
8771
|
lastKind = kind;
|
|
8772
|
+
lastLine = firstLine;
|
|
8625
8773
|
buffer = lines.slice(1).join("\n");
|
|
8626
8774
|
}
|
|
8627
8775
|
};
|
|
@@ -9481,8 +9629,6 @@ function formatNormalToolDuration(elapsedMs) {
|
|
|
9481
9629
|
function formatNormalToolLine(event, pending, colorEnabled) {
|
|
9482
9630
|
if (event.type === "tool-call") return "";
|
|
9483
9631
|
const toolName = event.toolName || pending?.toolName || "tool";
|
|
9484
|
-
const todoBlock = formatTodoListForCli(event, colorEnabled);
|
|
9485
|
-
if (todoBlock) return todoBlock;
|
|
9486
9632
|
if (event.type === "tool-result" && (event.toolName === "ask_user" || event.metadata?.uiAskChoice)) {
|
|
9487
9633
|
const block = formatUiAskChoiceBlock(event, colorEnabled);
|
|
9488
9634
|
if (block) return block;
|
|
@@ -9545,39 +9691,6 @@ function resolveLoadSkillName(event) {
|
|
|
9545
9691
|
if (match?.[1]) return match[1];
|
|
9546
9692
|
return argName || "skill";
|
|
9547
9693
|
}
|
|
9548
|
-
function formatTodoListForCli(event, colorEnabled) {
|
|
9549
|
-
if (event.type !== "tool-result" || event.toolName !== "setTodoList") {
|
|
9550
|
-
return void 0;
|
|
9551
|
-
}
|
|
9552
|
-
let raw = event.metadata?.displayData;
|
|
9553
|
-
let parsed = typeof raw === "object" && raw !== null;
|
|
9554
|
-
if (typeof raw === "string") {
|
|
9555
|
-
try {
|
|
9556
|
-
raw = JSON.parse(raw);
|
|
9557
|
-
parsed = true;
|
|
9558
|
-
} catch {
|
|
9559
|
-
raw = void 0;
|
|
9560
|
-
}
|
|
9561
|
-
}
|
|
9562
|
-
if (!parsed && typeof event.content === "string") {
|
|
9563
|
-
try {
|
|
9564
|
-
raw = JSON.parse(event.content);
|
|
9565
|
-
parsed = true;
|
|
9566
|
-
} catch {
|
|
9567
|
-
raw = void 0;
|
|
9568
|
-
}
|
|
9569
|
-
}
|
|
9570
|
-
const todos = Array.isArray(raw?.todos) ? raw.todos : void 0;
|
|
9571
|
-
if (!todos) return void 0;
|
|
9572
|
-
if (todos.length === 0) return "\u2611 Todo\n (empty)\n";
|
|
9573
|
-
const lines = todos.map((todo) => {
|
|
9574
|
-
const status = todo?.status === "done" ? "\u2713" : todo?.status === "in_progress" ? "\u25D0" : "\u25CB";
|
|
9575
|
-
const title = typeof todo?.title === "string" ? todo.title : "Untitled task";
|
|
9576
|
-
return ` ${status} ${title}`;
|
|
9577
|
-
});
|
|
9578
|
-
const text = [`\u2611 Todo (${todos.length})`, ...lines].join("\n") + "\n";
|
|
9579
|
-
return colorEnabled ? themeText(text, "chrome") : text;
|
|
9580
|
-
}
|
|
9581
9694
|
function formatLoadSkillBlock(event, colorEnabled, opts) {
|
|
9582
9695
|
if (event.type !== "tool-result" || event.toolName !== "loadSkill") return null;
|
|
9583
9696
|
const skillName = resolveLoadSkillName(event);
|
|
@@ -9834,6 +9947,7 @@ ${this.text}
|
|
|
9834
9947
|
// packages/cli/client/agentRunOutput.ts
|
|
9835
9948
|
var IDENTITY_LABEL_SEPARATOR = " > ";
|
|
9836
9949
|
var THINKING_PREVIEW_BUFFER_LIMIT = 512;
|
|
9950
|
+
var TUI_PROGRESS_BUFFER_LIMIT = 1200;
|
|
9837
9951
|
function appendThinkingPreview(current, chunk, limit = THINKING_PREVIEW_BUFFER_LIMIT) {
|
|
9838
9952
|
if (limit <= 0) return "";
|
|
9839
9953
|
const combined = current + chunk;
|
|
@@ -9895,6 +10009,14 @@ function formatToolJsonEvent(event) {
|
|
|
9895
10009
|
})}
|
|
9896
10010
|
`;
|
|
9897
10011
|
}
|
|
10012
|
+
function shouldPromoteTuiNarration(text) {
|
|
10013
|
+
if (text.length >= TUI_PROGRESS_BUFFER_LIMIT) return true;
|
|
10014
|
+
return /(^|\n)\s*(?:#{1,3}\s|```|[-*+]\s|\d+[.)]\s)/.test(text);
|
|
10015
|
+
}
|
|
10016
|
+
function narrationActivityLabel(text) {
|
|
10017
|
+
const oneLine = stripAnsi2(text).replace(/[`*_#>]/g, "").replace(/\s+/g, " ").trim();
|
|
10018
|
+
return truncateThinkingHint(oneLine, 60);
|
|
10019
|
+
}
|
|
9898
10020
|
function createCliTurnOutput(params) {
|
|
9899
10021
|
const { options } = params;
|
|
9900
10022
|
const workingLabel = params.workingLabel ?? `${options.agentName} -> working`;
|
|
@@ -9903,14 +10025,36 @@ function createCliTurnOutput(params) {
|
|
|
9903
10025
|
tuiTrees: options.output.tuiTrees === true
|
|
9904
10026
|
});
|
|
9905
10027
|
const eventMode = resolveAgentEventMode(options);
|
|
9906
|
-
const
|
|
10028
|
+
const assistantLabelManaged = options.output.assistantLabelManaged === true;
|
|
10029
|
+
const showThinking = !assistantLabelManaged && options.showThinking !== false;
|
|
10030
|
+
const hidesRoutineTuiToolDetail = (event) => {
|
|
10031
|
+
if (!assistantLabelManaged || event.toolName !== "editFile") return false;
|
|
10032
|
+
if (event.type === "tool-error") return false;
|
|
10033
|
+
if (readActionGate(event.metadata?.actionGate)) return false;
|
|
10034
|
+
if (event.metadata?.timedOut || event.metadata?.failed || event.metadata?.error) return false;
|
|
10035
|
+
if (typeof event.metadata?.exitCode === "number" && event.metadata.exitCode !== 0) return false;
|
|
10036
|
+
return true;
|
|
10037
|
+
};
|
|
9907
10038
|
let streamedAssistantText = false;
|
|
9908
10039
|
let everStreamedAnyText = false;
|
|
9909
10040
|
let printedAssistantLabel = false;
|
|
9910
10041
|
let thinkState = createThinkParserState();
|
|
9911
10042
|
let thinkingFirstAt = null;
|
|
9912
10043
|
let thinkingPreview = "";
|
|
10044
|
+
let tuiThinkingReported = false;
|
|
10045
|
+
const clearTuiThinkingLabel = () => {
|
|
10046
|
+
if (!tuiThinkingReported) return;
|
|
10047
|
+
tuiThinkingReported = false;
|
|
10048
|
+
options.activityReporter?.(null);
|
|
10049
|
+
};
|
|
9913
10050
|
const markThinkingDelta = (chunk) => {
|
|
10051
|
+
if (assistantLabelManaged) {
|
|
10052
|
+
if (!tuiThinkingReported && !streamedAssistantText) {
|
|
10053
|
+
tuiThinkingReported = true;
|
|
10054
|
+
options.activityReporter?.(t("thinkingActive"));
|
|
10055
|
+
}
|
|
10056
|
+
return;
|
|
10057
|
+
}
|
|
9914
10058
|
if (!showThinking) return;
|
|
9915
10059
|
if (streamedAssistantText) return;
|
|
9916
10060
|
if (thinkingFirstAt === null) {
|
|
@@ -9928,6 +10072,7 @@ function createCliTurnOutput(params) {
|
|
|
9928
10072
|
options.activityReporter?.(label);
|
|
9929
10073
|
};
|
|
9930
10074
|
const endThinkingPhase = () => {
|
|
10075
|
+
clearTuiThinkingLabel();
|
|
9931
10076
|
if (thinkingFirstAt === null) return;
|
|
9932
10077
|
const seconds = Math.max(0, Math.round((Date.now() - thinkingFirstAt) / 1e3));
|
|
9933
10078
|
thinkingFirstAt = null;
|
|
@@ -9940,7 +10085,6 @@ function createCliTurnOutput(params) {
|
|
|
9940
10085
|
}
|
|
9941
10086
|
};
|
|
9942
10087
|
let compactionEvent = null;
|
|
9943
|
-
const assistantLabelManaged = options.output.assistantLabelManaged === true;
|
|
9944
10088
|
const writeToolOutput = (chunk) => {
|
|
9945
10089
|
if (!chunk) return;
|
|
9946
10090
|
if (typeof options.output.writeToolBlock === "function") {
|
|
@@ -9952,9 +10096,25 @@ function createCliTurnOutput(params) {
|
|
|
9952
10096
|
const renderWriter = createRenderAwareStreamWriter({
|
|
9953
10097
|
write: (chunk) => options.output.write(chunk)
|
|
9954
10098
|
});
|
|
10099
|
+
let pendingTuiNarration = "";
|
|
10100
|
+
let tuiNarrationPromoted = false;
|
|
10101
|
+
const flushPendingTuiNarration = () => {
|
|
10102
|
+
if (!pendingTuiNarration) return;
|
|
10103
|
+
formatToolEvent.reset?.();
|
|
10104
|
+
renderWriter.push(pendingTuiNarration);
|
|
10105
|
+
pendingTuiNarration = "";
|
|
10106
|
+
tuiNarrationPromoted = true;
|
|
10107
|
+
streamedAssistantText = true;
|
|
10108
|
+
options.activityReporter?.(null);
|
|
10109
|
+
};
|
|
10110
|
+
const dropPendingTuiProgress = () => {
|
|
10111
|
+
pendingTuiNarration = "";
|
|
10112
|
+
tuiNarrationPromoted = false;
|
|
10113
|
+
options.activityReporter?.(null);
|
|
10114
|
+
};
|
|
9955
10115
|
const writeVisibleAssistantChunk = (chunk) => {
|
|
9956
10116
|
if (!chunk) return;
|
|
9957
|
-
formatToolEvent.reset?.();
|
|
10117
|
+
if (!assistantLabelManaged) formatToolEvent.reset?.();
|
|
9958
10118
|
const parsed = processThinkChunk(chunk, thinkState);
|
|
9959
10119
|
thinkState = parsed.state;
|
|
9960
10120
|
if (!parsed.content && !parsed.reasoning) return;
|
|
@@ -9970,8 +10130,23 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
|
|
|
9970
10130
|
}
|
|
9971
10131
|
printedAssistantLabel = true;
|
|
9972
10132
|
}
|
|
9973
|
-
streamedAssistantText = true;
|
|
9974
10133
|
everStreamedAnyText = true;
|
|
10134
|
+
if (assistantLabelManaged) {
|
|
10135
|
+
if (tuiNarrationPromoted) {
|
|
10136
|
+
renderWriter.push(parsed.content);
|
|
10137
|
+
streamedAssistantText = true;
|
|
10138
|
+
return;
|
|
10139
|
+
}
|
|
10140
|
+
pendingTuiNarration += parsed.content;
|
|
10141
|
+
if (shouldPromoteTuiNarration(pendingTuiNarration)) {
|
|
10142
|
+
flushPendingTuiNarration();
|
|
10143
|
+
} else {
|
|
10144
|
+
const label = narrationActivityLabel(pendingTuiNarration);
|
|
10145
|
+
if (label) options.activityReporter?.(label);
|
|
10146
|
+
}
|
|
10147
|
+
return;
|
|
10148
|
+
}
|
|
10149
|
+
streamedAssistantText = true;
|
|
9975
10150
|
renderWriter.push(parsed.content);
|
|
9976
10151
|
};
|
|
9977
10152
|
const handleToolEvent = (event) => {
|
|
@@ -9987,13 +10162,19 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
|
|
|
9987
10162
|
return;
|
|
9988
10163
|
}
|
|
9989
10164
|
if (event.type === "tool-call") {
|
|
10165
|
+
if (assistantLabelManaged && pendingTuiNarration) {
|
|
10166
|
+
dropPendingTuiProgress();
|
|
10167
|
+
}
|
|
9990
10168
|
renderWriter.flush();
|
|
9991
|
-
|
|
10169
|
+
if (!hidesRoutineTuiToolDetail(event)) {
|
|
10170
|
+
formatToolEvent(event);
|
|
10171
|
+
}
|
|
9992
10172
|
endThinkingPhase();
|
|
9993
10173
|
if (streamedAssistantText) {
|
|
9994
10174
|
options.output.write("\n");
|
|
9995
10175
|
streamedAssistantText = false;
|
|
9996
10176
|
}
|
|
10177
|
+
if (assistantLabelManaged) tuiNarrationPromoted = false;
|
|
9997
10178
|
const activeLabel = formatConservativeActiveToolLabel(event);
|
|
9998
10179
|
spinner.show(activeLabel);
|
|
9999
10180
|
options.activityReporter?.(activeLabel);
|
|
@@ -10005,6 +10186,9 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
|
|
|
10005
10186
|
}
|
|
10006
10187
|
spinner.stop();
|
|
10007
10188
|
options.activityReporter?.(null);
|
|
10189
|
+
if (hidesRoutineTuiToolDetail(event)) {
|
|
10190
|
+
return;
|
|
10191
|
+
}
|
|
10008
10192
|
if (isLiveAgentRunObservation(event, parsedRunEvent)) {
|
|
10009
10193
|
formatToolEvent.consume?.(event);
|
|
10010
10194
|
return;
|
|
@@ -10017,6 +10201,26 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
|
|
|
10017
10201
|
return {
|
|
10018
10202
|
spinner,
|
|
10019
10203
|
eventMode,
|
|
10204
|
+
/**
|
|
10205
|
+
* Terminal cleanup for abort/error paths that never reach `finish()`.
|
|
10206
|
+
*
|
|
10207
|
+
* A user abort discards the transient TUI progress buffer: the user stopped
|
|
10208
|
+
* on purpose and the dock already showed that text as activity. A genuine
|
|
10209
|
+
* failure must not swallow prose that never got the chance to be *proven*
|
|
10210
|
+
* durable (only a following tool call proves "progress"), so it promotes the
|
|
10211
|
+
* pending buffer and flushes what was already promoted — otherwise a short
|
|
10212
|
+
* final answer followed by a transport error disappears from the transcript.
|
|
10213
|
+
*/
|
|
10214
|
+
cancel(cleanup) {
|
|
10215
|
+
if (assistantLabelManaged && cleanup?.preservePendingNarration) {
|
|
10216
|
+
flushPendingTuiNarration();
|
|
10217
|
+
if (streamedAssistantText) {
|
|
10218
|
+
renderWriter.flush();
|
|
10219
|
+
options.output.write("\n");
|
|
10220
|
+
}
|
|
10221
|
+
}
|
|
10222
|
+
dropPendingTuiProgress();
|
|
10223
|
+
},
|
|
10020
10224
|
pushText(chunk) {
|
|
10021
10225
|
writeVisibleAssistantChunk(chunk);
|
|
10022
10226
|
},
|
|
@@ -10024,10 +10228,6 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
|
|
|
10024
10228
|
markThinkingDelta(chunk);
|
|
10025
10229
|
},
|
|
10026
10230
|
handleToolEvent,
|
|
10027
|
-
/** 记录一条 compaction 观测事件(TUI 在 turn 结束时渲染一行 dim 摘要)。
|
|
10028
|
-
* 一轮内可能来多条(轮开始 + 每个 round),按显著性保留最高者:
|
|
10029
|
-
* 失败 > 新生成摘要 > 投影复用 > 跳过,避免末尾的例行跳过事件
|
|
10030
|
-
* 覆盖掉中途真正发生的压缩。 */
|
|
10031
10231
|
recordCompaction(event) {
|
|
10032
10232
|
const significance = (e) => e.failed ? 4 : e.summaryGenerated ? 3 : e.compressed ? 2 : 1;
|
|
10033
10233
|
if (!compactionEvent || significance(event) >= significance(compactionEvent)) {
|
|
@@ -10039,12 +10239,28 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
|
|
|
10039
10239
|
spinner.show(activeLabel);
|
|
10040
10240
|
options.activityReporter?.(activeLabel);
|
|
10041
10241
|
},
|
|
10242
|
+
/**
|
|
10243
|
+
* Pre-delta turn phase label (ctx-overflow-feedback batch 3).
|
|
10244
|
+
*
|
|
10245
|
+
* localLoop 在首个 provider delta 之前依次发出 turn-phase 事件
|
|
10246
|
+
* (validating-context → compacting → waiting-provider);此前 CLI 只有
|
|
10247
|
+
* llm-start 才进入明确 working 状态,压缩期间 spinner 停在通用
|
|
10248
|
+
* working 文案上,用户无法区分「卡在检查上下文 / 压缩 / 等模型」。
|
|
10249
|
+
* 两个显示面(bare CLI 的 spinner 与 TUI 的 dock activityReporter)与
|
|
10250
|
+
* showWorking 走同一条投影,保证两端文案不漂移。
|
|
10251
|
+
*/
|
|
10252
|
+
showPhase(phase) {
|
|
10253
|
+
const label = phase === "validating-context" ? t("contextChecking") : phase === "compacting" ? t("contextCompacting") : t("waitingForModel");
|
|
10254
|
+
spinner.show(label);
|
|
10255
|
+
options.activityReporter?.(label);
|
|
10256
|
+
},
|
|
10042
10257
|
finish(fallbackContent) {
|
|
10043
10258
|
const flushedThink = flushThinkParser(thinkState);
|
|
10044
10259
|
thinkState = flushedThink.state;
|
|
10045
10260
|
if (flushedThink.content) {
|
|
10046
10261
|
writeVisibleAssistantChunk(flushedThink.content);
|
|
10047
10262
|
}
|
|
10263
|
+
if (assistantLabelManaged) flushPendingTuiNarration();
|
|
10048
10264
|
endThinkingPhase();
|
|
10049
10265
|
spinner.stop();
|
|
10050
10266
|
options.activityReporter?.(null);
|
|
@@ -10149,6 +10365,7 @@ async function readStreamingAgentRun(options, res, existingSpinner) {
|
|
|
10149
10365
|
let content = "";
|
|
10150
10366
|
let dialogId;
|
|
10151
10367
|
let usage;
|
|
10368
|
+
let sawDone = false;
|
|
10152
10369
|
const handlePayload = (payload) => {
|
|
10153
10370
|
if (typeof payload?.dialogId === "string" && payload.dialogId.trim()) {
|
|
10154
10371
|
dialogId = payload.dialogId;
|
|
@@ -10161,6 +10378,7 @@ async function readStreamingAgentRun(options, res, existingSpinner) {
|
|
|
10161
10378
|
}
|
|
10162
10379
|
if (payload?.type === "done") {
|
|
10163
10380
|
usage = payload.usage;
|
|
10381
|
+
sawDone = true;
|
|
10164
10382
|
return;
|
|
10165
10383
|
}
|
|
10166
10384
|
if (payload?.type === "dialog" || payload?.type === "status") {
|
|
@@ -10214,6 +10432,9 @@ async function readStreamingAgentRun(options, res, existingSpinner) {
|
|
|
10214
10432
|
}
|
|
10215
10433
|
} catch (error) {
|
|
10216
10434
|
turnOutput.spinner.stop();
|
|
10435
|
+
turnOutput.cancel({
|
|
10436
|
+
preservePendingNarration: !options.abortSignal?.aborted
|
|
10437
|
+
});
|
|
10217
10438
|
if (options.abortSignal?.aborted) {
|
|
10218
10439
|
return {
|
|
10219
10440
|
exitCode: 0,
|
|
@@ -10243,6 +10464,15 @@ ${describeClientVersionTooOldFailure(message, error)}`);
|
|
|
10243
10464
|
`);
|
|
10244
10465
|
return { exitCode: 1 };
|
|
10245
10466
|
}
|
|
10467
|
+
if (options.abortSignal?.aborted && !sawDone) {
|
|
10468
|
+
turnOutput.spinner.stop();
|
|
10469
|
+
turnOutput.cancel();
|
|
10470
|
+
return {
|
|
10471
|
+
exitCode: 0,
|
|
10472
|
+
...dialogId ? { dialogId } : {},
|
|
10473
|
+
streamInterrupted: true
|
|
10474
|
+
};
|
|
10475
|
+
}
|
|
10246
10476
|
turnOutput.finish(content);
|
|
10247
10477
|
const usageText = formatUsage(usage, dialogId);
|
|
10248
10478
|
if (usageText && shouldShowUsage(options.env))
|
|
@@ -10459,7 +10689,7 @@ function findCollapsedPasteSpanAt(buffer, pos, opts = {}) {
|
|
|
10459
10689
|
// packages/cli/client/agentRun.ts
|
|
10460
10690
|
import { ulid as ulid2 } from "ulid";
|
|
10461
10691
|
async function loadRunLocalAgentTurn() {
|
|
10462
|
-
const { runLocalAgentTurn } = await import("./agentRuntimeLocal-
|
|
10692
|
+
const { runLocalAgentTurn } = await import("./agentRuntimeLocal-N4YGKL7M.js");
|
|
10463
10693
|
return runLocalAgentTurn;
|
|
10464
10694
|
}
|
|
10465
10695
|
var stripDebugNoise = (s) => s.replace(/\s*raw="[\s\S]*"/g, "").replace(/\s*raw=\S+/g, "").replace(/\s*headers=\[[^\]]*\]/g, "").replace(/\s*headers=\S+/g, "").trim();
|
|
@@ -10779,7 +11009,8 @@ function classifyLocalRunError(message) {
|
|
|
10779
11009
|
}
|
|
10780
11010
|
return { kind: "generic" };
|
|
10781
11011
|
}
|
|
10782
|
-
var HISTORY_REPLAY_REJECTION_RE = /
|
|
11012
|
+
var HISTORY_REPLAY_REJECTION_RE = /invalid\s+tool\s+call\s+arguments?/i;
|
|
11013
|
+
var REASONING_REPLAY_CONTRACT_RE = /reasoning_content[^.]*must be passed back/i;
|
|
10783
11014
|
var RUN_UNAVAILABLE_PREFIX = "[nolo] auto runtime: local run unavailable";
|
|
10784
11015
|
var NO_FALLBACK = "Not falling back to server.";
|
|
10785
11016
|
var SERVER_FALLBACK_HINT = "or use --server to run on the server explicitly.";
|
|
@@ -10788,27 +11019,30 @@ function buildAuthFailure(ctx) {
|
|
|
10788
11019
|
const fix = platformNoToken ? `This install is not logged in \u2014 run \`nolo login\`, or set AUTH_TOKEN / NOLO_SERVER` : ctx.where === "server chat proxy" ? `Check the agent's provider/api-key settings on nolo.chat` : `Fix the local credential/config and retry`;
|
|
10789
11020
|
const { url: validationUrl, text: validationText } = extractGoogleValidationLink(ctx.message);
|
|
10790
11021
|
const validationLabel = validationText || "Verify your account";
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
${formatCliHyperlink(
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
11022
|
+
if (validationUrl) {
|
|
11023
|
+
const linkLine = `
|
|
11024
|
+
${formatCliHyperlink(validationUrl, validationLabel)}`;
|
|
11025
|
+
const rawLine = resolveCliHyperlinkEnabled() ? `
|
|
11026
|
+
\u70B9\u4E0D\u4E86\u5C31\u590D\u5236\u8FD9\u884C: ${validationUrl}` : "";
|
|
11027
|
+
const verifyHint = `
|
|
11028
|
+
\u24D8 \u60F3\u4E00\u952E\u6253\u5F00\uFF1F\u8DD1 \`nolo auth antigravity --verify\` \u2014\u2014 \u5B83\u4F1A\u7528\u672C\u5730\u51ED\u8BC1\u62FF\u5230\u5F53\u524D\u9A8C\u8BC1\u94FE\u63A5\u5E76\u76F4\u63A5\u62C9\u8D77\u6D4F\u89C8\u5668\u3002`;
|
|
11029
|
+
const retryLine = `
|
|
11030
|
+
\u9A8C\u8BC1\u5B8C\u6210\u540E\u76F4\u63A5\u91CD\u8BD5\u521A\u624D\u7684\u547D\u4EE4\u5373\u53EF\uFF0Ctoken \u4E0D\u7528\u91CD\u65B0\u767B\u5F55\u3002`;
|
|
11031
|
+
return `${RUN_UNAVAILABLE_PREFIX} (${ctx.where} returned HTTP ${ctx.status}: Google requires a one-time account verification \u2014 your credential is fine).
|
|
11032
|
+
Open this link in a browser signed into ${ctx.credentialAccountId ? `\`${ctx.credentialAccountId}\`` : "the Google account behind this credential"}:${linkLine}${rawLine}${verifyHint}${retryLine}
|
|
11033
|
+
Detail: ${ctx.message} ${NO_FALLBACK} Use --server to run on the server explicitly.
|
|
11034
|
+
`;
|
|
11035
|
+
}
|
|
11036
|
+
return `${RUN_UNAVAILABLE_PREFIX} (${ctx.where} returned HTTP ${ctx.status}, auth rejected). Detail: ${ctx.message} ${NO_FALLBACK} ${fix}, ${SERVER_FALLBACK_HINT}.
|
|
10804
11037
|
`;
|
|
10805
11038
|
}
|
|
10806
11039
|
function isAuthNoTokenBody(message) {
|
|
10807
11040
|
return /"authCode"\s*:\s*"AUTH_NO_TOKEN"/i.test(message) || /no authentication token provided/i.test(message);
|
|
10808
11041
|
}
|
|
10809
11042
|
function buildRejectedPayloadFailure(ctx) {
|
|
10810
|
-
const
|
|
10811
|
-
const
|
|
11043
|
+
const looksLikeReasoningReplay = REASONING_REPLAY_CONTRACT_RE.test(ctx.message);
|
|
11044
|
+
const looksLikeHistoryReplay = !looksLikeReasoningReplay && HISTORY_REPLAY_REJECTION_RE.test(ctx.message);
|
|
11045
|
+
const cause = looksLikeReasoningReplay ? ` This is a thinking-mode replay contract violation: the history contains an assistant tool-call turn without reasoning_content, but this model requires every such turn to pass reasoning back to the API. The upstream may not have returned reasoning for that turn, or the history came from a different model.` : looksLikeHistoryReplay ? ` This usually happens when the dialog history contains tool_calls or reasoning produced by a different model/provider (e.g. after /switch); the new provider rejects that history. Start a fresh dialog, or clean the offending history.` : "";
|
|
10812
11046
|
return `${RUN_UNAVAILABLE_PREFIX} (${ctx.where} returned HTTP ${ctx.status}, the provider rejected the request body \u2014 this is NOT a local credential/config issue). Detail: ${ctx.message}${cause} ${NO_FALLBACK} Use --server to run on the server explicitly, or start a fresh dialog.
|
|
10813
11047
|
`;
|
|
10814
11048
|
}
|
|
@@ -10835,6 +11069,17 @@ function buildUpstreamFailure(ctx) {
|
|
|
10835
11069
|
return `${RUN_UNAVAILABLE_PREFIX} (${ctx.where} returned HTTP ${ctx.status}). Detail: ${ctx.message} ${NO_FALLBACK} ${fix}, ${SERVER_FALLBACK_HINT}.
|
|
10836
11070
|
`;
|
|
10837
11071
|
}
|
|
11072
|
+
function formatLocalTurnFailureLine(error) {
|
|
11073
|
+
const message = toErrorMessage(error);
|
|
11074
|
+
if (error?.code === "LLM_REQUEST_TIMEOUT") {
|
|
11075
|
+
const msMatch = /after (\d+)ms/.exec(message);
|
|
11076
|
+
const deadline = msMatch && Number.isFinite(Number(msMatch[1])) ? formatElapsed(Math.round(Number(msMatch[1]) / 1e3)) : "the configured window";
|
|
11077
|
+
return `[nolo] ${t("llmRequestTimedOut", deadline)}
|
|
11078
|
+
`;
|
|
11079
|
+
}
|
|
11080
|
+
return `[nolo] Local agent run failed: ${message}
|
|
11081
|
+
`;
|
|
11082
|
+
}
|
|
10838
11083
|
var FAILURE_BUILDERS = {
|
|
10839
11084
|
auth: buildAuthFailure,
|
|
10840
11085
|
"rejected-payload": buildRejectedPayloadFailure,
|
|
@@ -10843,6 +11088,7 @@ var FAILURE_BUILDERS = {
|
|
|
10843
11088
|
upstream: buildUpstreamFailure
|
|
10844
11089
|
};
|
|
10845
11090
|
function describeLocalRunFailure(message, rawError) {
|
|
11091
|
+
const credentialAccountId = rawError && typeof rawError === "object" && typeof rawError.credentialAccountId === "string" ? rawError.credentialAccountId.trim() || void 0 : void 0;
|
|
10846
11092
|
if (rawError && typeof rawError === "object" && "code" in rawError && rawError.code === "PLATFORM_STREAM_INTERRUPTED") {
|
|
10847
11093
|
return "[nolo] The platform LLM stream was interrupted before the turn completed. Your conversation was preserved. Send another message to continue.\n";
|
|
10848
11094
|
}
|
|
@@ -10891,6 +11137,10 @@ function describeLocalRunFailure(message, rawError) {
|
|
|
10891
11137
|
}
|
|
10892
11138
|
if (/CLI authority broker could not attach or take ownership/i.test(message)) {
|
|
10893
11139
|
const cleaned = stripDebugNoise(message);
|
|
11140
|
+
if (/EADDRINUSE/i.test(message)) {
|
|
11141
|
+
return `${RUN_UNAVAILABLE_PREFIX} (${cleaned}). ${NO_FALLBACK} Use --server to run on the server explicitly.
|
|
11142
|
+
`;
|
|
11143
|
+
}
|
|
10894
11144
|
return `${RUN_UNAVAILABLE_PREFIX} (${cleaned}). ${NO_FALLBACK} The local runtime could not attach to an existing broker or take database ownership. Check running broker processes holding the local authority store or retry, ${SERVER_FALLBACK_HINT}.
|
|
10895
11145
|
`;
|
|
10896
11146
|
}
|
|
@@ -10920,7 +11170,8 @@ function describeLocalRunFailure(message, rawError) {
|
|
|
10920
11170
|
status: cls.status,
|
|
10921
11171
|
...cls.statusInferred ? { statusInferred: true } : {},
|
|
10922
11172
|
...cls.quotaExhausted ? { quotaExhausted: true } : {},
|
|
10923
|
-
...cooldownUntil ? { cooldownUntil } : {}
|
|
11173
|
+
...cooldownUntil ? { cooldownUntil } : {},
|
|
11174
|
+
...credentialAccountId ? { credentialAccountId } : {}
|
|
10924
11175
|
};
|
|
10925
11176
|
return FAILURE_BUILDERS[cls.kind](ctx);
|
|
10926
11177
|
}
|
|
@@ -11237,6 +11488,18 @@ async function runLocalAgentTurnForCli(options, settings) {
|
|
|
11237
11488
|
if (event.kind === "llm-start") {
|
|
11238
11489
|
turnOutput.showWorking();
|
|
11239
11490
|
}
|
|
11491
|
+
if (event.kind === "turn-phase") {
|
|
11492
|
+
turnOutput.showPhase(event.phase);
|
|
11493
|
+
}
|
|
11494
|
+
if (event.kind === "compaction-start") {
|
|
11495
|
+
turnOutput.showPhase("compacting");
|
|
11496
|
+
}
|
|
11497
|
+
if (event.kind === "compaction-end" || // 压缩失败(timeout/provider-error)时 localLoop 按失败原子性语义
|
|
11498
|
+
// 带着裁剪后的历史继续本轮,切回等待模型文案;aborted 时 turn 随即
|
|
11499
|
+
// 结束,不再切文案(终态由 abort 路径收尾)。
|
|
11500
|
+
event.kind === "compaction-failed" && event.reason !== "aborted") {
|
|
11501
|
+
turnOutput.showPhase("waiting-provider");
|
|
11502
|
+
}
|
|
11240
11503
|
if (event.kind === "image-downgraded") {
|
|
11241
11504
|
options.output.write(
|
|
11242
11505
|
"[nolo] \u5F53\u524D agent \u88AB\u914D\u7F6E\u4E3A\u4E0D\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF0C\u56FE\u7247\u5DF2\u7528\u5360\u4F4D\u6587\u672C\u66FF\u4EE3\u3002\u8BF7\u68C0\u67E5\u6A21\u578B\u7684\u56FE\u7247\u80FD\u529B\u914D\u7F6E\uFF0C\u6216\u7528 /switch \u9009\u62E9\u652F\u6301\u56FE\u7247\u7684 agent \u540E\u91CD\u65B0\u53D1\u9001\u56FE\u7247\u3002\n"
|
|
@@ -11282,6 +11545,9 @@ async function runLocalAgentTurnForCli(options, settings) {
|
|
|
11282
11545
|
};
|
|
11283
11546
|
} catch (error) {
|
|
11284
11547
|
turnOutput.spinner.stop();
|
|
11548
|
+
turnOutput.cancel({
|
|
11549
|
+
preservePendingNarration: error?.code !== LOCAL_TURN_ABORTED_CODE && !options.abortSignal?.aborted
|
|
11550
|
+
});
|
|
11285
11551
|
const savedDialogId = error?.dialogId;
|
|
11286
11552
|
const abortedUsageRecords = error?.usageRecords;
|
|
11287
11553
|
const abortedTurnCredits = sumPlatformCredits(abortedUsageRecords);
|
|
@@ -11305,10 +11571,12 @@ async function runLocalAgentTurnForCli(options, settings) {
|
|
|
11305
11571
|
error.cooldownUntil = cooldownUntil;
|
|
11306
11572
|
}
|
|
11307
11573
|
if (settings.reportFailure) {
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11574
|
+
const failureLine = formatLocalTurnFailureLine(error);
|
|
11575
|
+
if (typeof options.output.writeErr === "function") {
|
|
11576
|
+
options.output.writeErr(failureLine);
|
|
11577
|
+
} else {
|
|
11578
|
+
options.output.write(failureLine);
|
|
11579
|
+
}
|
|
11312
11580
|
if (cooldownUntil) {
|
|
11313
11581
|
options.output.write(
|
|
11314
11582
|
`[nolo] \u5DF2\u6807\u8BB0\u51B7\u5374\u81F3 ${cooldownUntil}\uFF0C\u5230\u671F\u524D\u6D3E\u53D1\u8BE5 agent \u4F1A\u88AB\u51B7\u5374\u95E8\u63A7\u62E6\u622A\u3002
|
|
@@ -11446,7 +11714,7 @@ async function runAgentTurn(options) {
|
|
|
11446
11714
|
return { exitCode: 1 };
|
|
11447
11715
|
}
|
|
11448
11716
|
const localAvailability = await checkLocalAvailabilityBeforeHttpDispatch(options);
|
|
11449
|
-
if (localAvailability
|
|
11717
|
+
if (localAvailability && "exitCode" in localAvailability) {
|
|
11450
11718
|
return { exitCode: localAvailability.exitCode };
|
|
11451
11719
|
}
|
|
11452
11720
|
const httpResult = await runHttpAgentTurn(options, authToken);
|
|
@@ -12188,72 +12456,6 @@ var rankMemoryCandidates = (items, query, context) => {
|
|
|
12188
12456
|
});
|
|
12189
12457
|
};
|
|
12190
12458
|
|
|
12191
|
-
// packages/ai/memory/vnext/store.ts
|
|
12192
|
-
var enc = (value) => encodeURIComponent(value).replace(/-/g, "%2D");
|
|
12193
|
-
var rangeOf = (prefix) => ({ gte: prefix, lte: `${prefix}\uFFFF` });
|
|
12194
|
-
var entityKey = (ownerId, id) => `mem2-e-${enc(ownerId)}-${enc(id)}`;
|
|
12195
|
-
var entityOwnerPrefix = (ownerId) => `mem2-e-${enc(ownerId)}-`;
|
|
12196
|
-
var stateKey = (ownerId, id) => `mem2-s-${enc(ownerId)}-${enc(id)}`;
|
|
12197
|
-
var stateEntityIndexKey = (ownerId, entityId, stateId) => `mem2-si-${enc(ownerId)}-${enc(entityId)}-${enc(stateId)}`;
|
|
12198
|
-
var stateEntityIndexPrefix = (ownerId, entityId) => `mem2-si-${enc(ownerId)}-${enc(entityId)}-`;
|
|
12199
|
-
var evidenceKey = (ownerId, id) => `mem2-v-${enc(ownerId)}-${enc(id)}`;
|
|
12200
|
-
var relationKey = (ownerId, id) => `mem2-r-${enc(ownerId)}-${enc(id)}`;
|
|
12201
|
-
var relationFromIndexKey = (ownerId, from, relationId) => `mem2-rf-${enc(ownerId)}-${enc(from)}-${enc(relationId)}`;
|
|
12202
|
-
var relationToIndexKey = (ownerId, to, relationId) => `mem2-rt-${enc(ownerId)}-${enc(to)}-${enc(relationId)}`;
|
|
12203
|
-
var readIndexed = async (db, prefix) => {
|
|
12204
|
-
const refs = [];
|
|
12205
|
-
for await (const [, value] of db.iterator({ ...rangeOf(prefix), reverse: false })) {
|
|
12206
|
-
if (typeof value?.key === "string") refs.push(value.key);
|
|
12207
|
-
}
|
|
12208
|
-
const rows = await Promise.all(refs.map((key) => db.get(key).catch(() => null)));
|
|
12209
|
-
return rows.filter((row) => !!row);
|
|
12210
|
-
};
|
|
12211
|
-
var getMemoryEntityVNext = async (db, ownerId, entityId) => db.get(entityKey(ownerId, entityId)).catch(() => null);
|
|
12212
|
-
var listMemoryEntitiesVNext = async (db, ownerId) => {
|
|
12213
|
-
const rows = [];
|
|
12214
|
-
for await (const [, value] of db.iterator({
|
|
12215
|
-
...rangeOf(entityOwnerPrefix(ownerId)),
|
|
12216
|
-
reverse: false
|
|
12217
|
-
})) {
|
|
12218
|
-
if (value) rows.push(value);
|
|
12219
|
-
}
|
|
12220
|
-
return rows;
|
|
12221
|
-
};
|
|
12222
|
-
var getMemoryStateVNext = async (db, ownerId, stateId) => db.get(stateKey(ownerId, stateId)).catch(() => null);
|
|
12223
|
-
var listMemoryStatesForEntityVNext = (db, ownerId, entityId) => readIndexed(db, stateEntityIndexPrefix(ownerId, entityId));
|
|
12224
|
-
var putMemoryEvidenceVNext = async (db, evidence) => {
|
|
12225
|
-
await db.put(evidenceKey(evidence.ownerId, evidence.id), evidence);
|
|
12226
|
-
};
|
|
12227
|
-
var getMemoryEvidenceVNext = async (db, ownerId, evidenceId) => db.get(evidenceKey(ownerId, evidenceId)).catch(() => null);
|
|
12228
|
-
var getMemoryEvidenceVNextStrict = async (db, ownerId, evidenceId) => {
|
|
12229
|
-
try {
|
|
12230
|
-
return await db.get(evidenceKey(ownerId, evidenceId));
|
|
12231
|
-
} catch (error) {
|
|
12232
|
-
if (isLevelNotFoundError(error)) return null;
|
|
12233
|
-
throw error;
|
|
12234
|
-
}
|
|
12235
|
-
};
|
|
12236
|
-
var _appendEntityBatch = (batch, entity) => {
|
|
12237
|
-
batch.put(entityKey(entity.ownerId, entity.id), entity);
|
|
12238
|
-
};
|
|
12239
|
-
var _appendEvidenceBatch = (batch, evidence) => {
|
|
12240
|
-
batch.put(evidenceKey(evidence.ownerId, evidence.id), evidence);
|
|
12241
|
-
};
|
|
12242
|
-
var _appendStateBatch = (batch, state2) => {
|
|
12243
|
-
const key = stateKey(state2.ownerId, state2.id);
|
|
12244
|
-
batch.put(key, state2);
|
|
12245
|
-
batch.put(stateEntityIndexKey(state2.ownerId, state2.entityId, state2.id), { key });
|
|
12246
|
-
};
|
|
12247
|
-
var _appendRetiredStateBatch = (batch, state2) => {
|
|
12248
|
-
batch.put(stateKey(state2.ownerId, state2.id), state2);
|
|
12249
|
-
};
|
|
12250
|
-
var _appendRelationBatch = (batch, relation) => {
|
|
12251
|
-
const key = relationKey(relation.ownerId, relation.id);
|
|
12252
|
-
batch.put(key, relation);
|
|
12253
|
-
batch.put(relationFromIndexKey(relation.ownerId, relation.from, relation.id), { key });
|
|
12254
|
-
batch.put(relationToIndexKey(relation.ownerId, relation.to, relation.id), { key });
|
|
12255
|
-
};
|
|
12256
|
-
|
|
12257
12459
|
// packages/ai/memory/vnext/recall.ts
|
|
12258
12460
|
var MAX_RECALL_REFS = 6;
|
|
12259
12461
|
var stripFence = (raw) => {
|
|
@@ -12283,14 +12485,6 @@ var parseSelection = (raw) => {
|
|
|
12283
12485
|
reason: obj.reason
|
|
12284
12486
|
};
|
|
12285
12487
|
};
|
|
12286
|
-
var buildCatalog = async (db, ownerId) => {
|
|
12287
|
-
const entities = await listMemoryEntitiesVNext(db, ownerId);
|
|
12288
|
-
const states = [];
|
|
12289
|
-
for (const entity of entities) {
|
|
12290
|
-
states.push(...await listMemoryStatesForEntityVNext(db, ownerId, entity.id));
|
|
12291
|
-
}
|
|
12292
|
-
return { entities, states };
|
|
12293
|
-
};
|
|
12294
12488
|
var catalogText = (entities, states) => JSON.stringify(
|
|
12295
12489
|
{
|
|
12296
12490
|
entities: entities.map((entity) => ({
|
|
@@ -12316,7 +12510,7 @@ var catalogText = (entities, states) => JSON.stringify(
|
|
|
12316
12510
|
);
|
|
12317
12511
|
var createMemoryVNextRecall = (input) => async (query) => {
|
|
12318
12512
|
const startedAt = performance.now();
|
|
12319
|
-
const { entities, states } = await
|
|
12513
|
+
const { entities, states } = await loadMemoryVNextCatalog(input.db, input.ownerId);
|
|
12320
12514
|
if (entities.length === 0 && states.length === 0) {
|
|
12321
12515
|
return {
|
|
12322
12516
|
query,
|
|
@@ -13187,14 +13381,74 @@ var shortError2 = (error) => {
|
|
|
13187
13381
|
return message.length > ERROR_MESSAGE_MAX2 ? `${message.slice(0, ERROR_MESSAGE_MAX2)}\u2026` : message;
|
|
13188
13382
|
};
|
|
13189
13383
|
var loadExistingContext = async (db, ownerId) => {
|
|
13190
|
-
const entities = await
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
|
|
13196
|
-
|
|
13384
|
+
const { entities, states } = await loadMemoryVNextCatalog(db, ownerId);
|
|
13385
|
+
return { entityIds: entities.map((entity) => entity.id), states };
|
|
13386
|
+
};
|
|
13387
|
+
var currentStatesCitingEvidence = (states, evidenceId) => states.filter((state2) => !state2.retiredAt && (state2.evidenceIds ?? []).includes(evidenceId));
|
|
13388
|
+
var isEvidenceCoveredByCurrentStates = (states, evidenceId) => currentStatesCitingEvidence(states, evidenceId).length > 0;
|
|
13389
|
+
var memoryVNextContextFingerprint = (existing) => {
|
|
13390
|
+
const states = existing.states ?? [];
|
|
13391
|
+
const entityIds = existing.entityIds ?? [];
|
|
13392
|
+
const canonical = [
|
|
13393
|
+
...entityIds.map((id) => `e\0${id}`),
|
|
13394
|
+
...states.map((state2) => `s\0${state2.id}\0${state2.updatedAt}\0${state2.retiredAt ?? ""}`)
|
|
13395
|
+
].sort().join("");
|
|
13396
|
+
let hash = 2166136261;
|
|
13397
|
+
for (let i = 0; i < canonical.length; i++) {
|
|
13398
|
+
hash ^= canonical.charCodeAt(i);
|
|
13399
|
+
hash = Math.imul(hash, 16777619);
|
|
13400
|
+
}
|
|
13401
|
+
return `${entityIds.length}.${states.length}:${(hash >>> 0).toString(16)}`;
|
|
13402
|
+
};
|
|
13403
|
+
var MAX_NOOP_SUPPRESSIONS = 512;
|
|
13404
|
+
var noOpSuppressions = /* @__PURE__ */ new Map();
|
|
13405
|
+
var suppressionKey = (ownerId, evidenceId) => `${ownerId}\0${evidenceId}`;
|
|
13406
|
+
var recordNoOpSuppression = (ownerId, evidenceId, fingerprint) => {
|
|
13407
|
+
const key = suppressionKey(ownerId, evidenceId);
|
|
13408
|
+
noOpSuppressions.delete(key);
|
|
13409
|
+
noOpSuppressions.set(key, fingerprint);
|
|
13410
|
+
while (noOpSuppressions.size > MAX_NOOP_SUPPRESSIONS) {
|
|
13411
|
+
noOpSuppressions.delete(noOpSuppressions.keys().next().value);
|
|
13412
|
+
}
|
|
13413
|
+
};
|
|
13414
|
+
var noOpHistory = (ownerId, evidenceId, fingerprint) => {
|
|
13415
|
+
const recorded = noOpSuppressions.get(suppressionKey(ownerId, evidenceId));
|
|
13416
|
+
if (recorded === void 0) return "fresh";
|
|
13417
|
+
return recorded === fingerprint ? "suppressed" : "stale";
|
|
13418
|
+
};
|
|
13419
|
+
var pickFirstUncoveredLazyPromotionItem = async (db, selected) => {
|
|
13420
|
+
const contextByOwner = /* @__PURE__ */ new Map();
|
|
13421
|
+
const contextFor = (ownerId) => {
|
|
13422
|
+
let pending = contextByOwner.get(ownerId);
|
|
13423
|
+
if (!pending) {
|
|
13424
|
+
pending = loadExistingContext(db, ownerId).then((existing) => ({
|
|
13425
|
+
states: existing.states ?? [],
|
|
13426
|
+
fingerprint: memoryVNextContextFingerprint(existing)
|
|
13427
|
+
}));
|
|
13428
|
+
contextByOwner.set(ownerId, pending);
|
|
13429
|
+
}
|
|
13430
|
+
return pending;
|
|
13197
13431
|
};
|
|
13432
|
+
let skippedCoveredCount = 0;
|
|
13433
|
+
let skippedNoOpCount = 0;
|
|
13434
|
+
let firstStale = null;
|
|
13435
|
+
for (const [selectedIndex, item] of selected.entries()) {
|
|
13436
|
+
const evidence = buildLegacyMemoryEvidence(item);
|
|
13437
|
+
const context = await contextFor(evidence.ownerId);
|
|
13438
|
+
if (isEvidenceCoveredByCurrentStates(context.states, evidence.id)) {
|
|
13439
|
+
skippedCoveredCount++;
|
|
13440
|
+
continue;
|
|
13441
|
+
}
|
|
13442
|
+
const history = noOpHistory(evidence.ownerId, evidence.id, context.fingerprint);
|
|
13443
|
+
if (history === "fresh") {
|
|
13444
|
+
return { item, selectedIndex, skippedCoveredCount, skippedNoOpCount };
|
|
13445
|
+
}
|
|
13446
|
+
if (history === "stale" && !firstStale) {
|
|
13447
|
+
firstStale = { item, selectedIndex, skippedCoveredCount, skippedNoOpCount };
|
|
13448
|
+
}
|
|
13449
|
+
skippedNoOpCount++;
|
|
13450
|
+
}
|
|
13451
|
+
return firstStale;
|
|
13198
13452
|
};
|
|
13199
13453
|
var withoutImportedEvidence = (mutation, importedEvidenceId) => ({
|
|
13200
13454
|
...mutation,
|
|
@@ -13210,6 +13464,11 @@ var runMemoryVNextLazyPromotion = async (input) => {
|
|
|
13210
13464
|
}));
|
|
13211
13465
|
const finish = (partial) => {
|
|
13212
13466
|
const observation = {
|
|
13467
|
+
legacyItemId: input.item.id,
|
|
13468
|
+
evidenceId: deterministicEvidence.id,
|
|
13469
|
+
...input.selectedIndex === void 0 ? {} : { selectedIndex: input.selectedIndex },
|
|
13470
|
+
...input.skippedCoveredCount === void 0 ? {} : { skippedCoveredCount: input.skippedCoveredCount },
|
|
13471
|
+
...input.skippedNoOpCount === void 0 ? {} : { skippedNoOpCount: input.skippedNoOpCount },
|
|
13213
13472
|
...partial,
|
|
13214
13473
|
latencyMs: Math.round((clock() - startedAt) * 10) / 10
|
|
13215
13474
|
};
|
|
@@ -13232,8 +13491,9 @@ var runMemoryVNextLazyPromotion = async (input) => {
|
|
|
13232
13491
|
}
|
|
13233
13492
|
const evidence = evidenceResult.evidence;
|
|
13234
13493
|
const existing = await loadExistingContext(input.db, evidence.ownerId);
|
|
13235
|
-
const alreadyCovered = (
|
|
13236
|
-
|
|
13494
|
+
const alreadyCovered = isEvidenceCoveredByCurrentStates(
|
|
13495
|
+
existing.states ?? [],
|
|
13496
|
+
evidence.id
|
|
13237
13497
|
);
|
|
13238
13498
|
if (alreadyCovered) {
|
|
13239
13499
|
return finish({ status: "already_covered" });
|
|
@@ -13248,6 +13508,11 @@ var runMemoryVNextLazyPromotion = async (input) => {
|
|
|
13248
13508
|
});
|
|
13249
13509
|
const semanticMutation = withoutImportedEvidence(interpreted.mutation, evidence.id);
|
|
13250
13510
|
if (!hasWrites(semanticMutation)) {
|
|
13511
|
+
recordNoOpSuppression(
|
|
13512
|
+
evidence.ownerId,
|
|
13513
|
+
evidence.id,
|
|
13514
|
+
memoryVNextContextFingerprint(existing)
|
|
13515
|
+
);
|
|
13251
13516
|
return finish({ status: "no_op", action: semanticMutation.action });
|
|
13252
13517
|
}
|
|
13253
13518
|
await applyMemoryInterpreterMutation(input.db, evidence.ownerId, semanticMutation);
|
|
@@ -13260,6 +13525,179 @@ var runMemoryVNextLazyPromotion = async (input) => {
|
|
|
13260
13525
|
};
|
|
13261
13526
|
var isMemoryVNextLazyPromotionEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_LAZY_PROMOTION === "1" || env.NOLO_MEMORY_VNEXT_LAZY_PROMOTION === "true";
|
|
13262
13527
|
|
|
13528
|
+
// packages/ai/memory/vnext/pureReadGate.ts
|
|
13529
|
+
var isMemoryVNextPureReadEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_PURE_READ === "1" || env.NOLO_MEMORY_VNEXT_PURE_READ === "true";
|
|
13530
|
+
|
|
13531
|
+
// packages/ai/memory/vnext/localRecall.ts
|
|
13532
|
+
var MIN_SHARED_TOKENS = 2;
|
|
13533
|
+
var MAX_LOCAL_RECALL_STATES = 8;
|
|
13534
|
+
var SAFE_TECHNICAL_SYNONYMS = {
|
|
13535
|
+
pr: ["\u5BA1\u67E5", "\u4EE3\u7801\u5BA1\u67E5", "diff"],
|
|
13536
|
+
diff: ["\u5BA1\u67E5", "\u4EE3\u7801\u5BA1\u67E5"],
|
|
13537
|
+
review: ["\u5BA1\u67E5", "\u4EE3\u7801\u5BA1\u67E5"],
|
|
13538
|
+
deploy: ["\u90E8\u7F72", "\u53D1\u7248"],
|
|
13539
|
+
release: ["\u53D1\u7248", "\u53D1\u5E03"],
|
|
13540
|
+
desktop: ["\u684C\u9762", "\u684C\u9762\u7AEF"]
|
|
13541
|
+
};
|
|
13542
|
+
var distinctTokens = (text) => new Set(tokenize2(text).filter((token) => token.length >= 2));
|
|
13543
|
+
var recallMemoryVNextLocal = (input) => {
|
|
13544
|
+
const rawTokens = distinctTokens(input.query);
|
|
13545
|
+
if (rawTokens.size === 0) return [];
|
|
13546
|
+
const queryTokens = new Set(rawTokens);
|
|
13547
|
+
for (const token of rawTokens) {
|
|
13548
|
+
const syns = SAFE_TECHNICAL_SYNONYMS[token.toLowerCase()];
|
|
13549
|
+
if (syns) {
|
|
13550
|
+
for (const syn of syns) {
|
|
13551
|
+
for (const t2 of distinctTokens(syn)) queryTokens.add(t2);
|
|
13552
|
+
}
|
|
13553
|
+
}
|
|
13554
|
+
}
|
|
13555
|
+
const entityById = new Map(input.entities.map((entity) => [entity.id, entity]));
|
|
13556
|
+
const hits = [];
|
|
13557
|
+
for (const state2 of input.states) {
|
|
13558
|
+
if (state2.retiredAt || !state2.text.trim()) continue;
|
|
13559
|
+
const entity = entityById.get(state2.entityId);
|
|
13560
|
+
const haystack = distinctTokens(
|
|
13561
|
+
[state2.facet, state2.text, entity?.name ?? "", ...entity?.aliases ?? []].join(" ")
|
|
13562
|
+
);
|
|
13563
|
+
let sharedTokens = 0;
|
|
13564
|
+
for (const token of queryTokens) if (haystack.has(token)) sharedTokens++;
|
|
13565
|
+
if (sharedTokens >= MIN_SHARED_TOKENS) hits.push({ state: state2, sharedTokens });
|
|
13566
|
+
}
|
|
13567
|
+
return hits.sort((a, b) => b.sharedTokens - a.sharedTokens || a.state.id.localeCompare(b.state.id)).slice(0, input.limit ?? MAX_LOCAL_RECALL_STATES);
|
|
13568
|
+
};
|
|
13569
|
+
|
|
13570
|
+
// packages/ai/memory/vnext/pureVNextRuntime.ts
|
|
13571
|
+
var buildSynthesizedStateItem = (state2, entity, ownerType, ownerId) => ({
|
|
13572
|
+
id: `vnext-state-${state2.id}`,
|
|
13573
|
+
ownerType,
|
|
13574
|
+
ownerId,
|
|
13575
|
+
visibility: "private",
|
|
13576
|
+
subjectType: "user",
|
|
13577
|
+
subjectId: ownerId,
|
|
13578
|
+
kind: "semantic",
|
|
13579
|
+
content: state2.text.trim(),
|
|
13580
|
+
createdAt: state2.createdAt,
|
|
13581
|
+
lastActivatedAt: state2.createdAt,
|
|
13582
|
+
activationCount: 1,
|
|
13583
|
+
importance: 0.9,
|
|
13584
|
+
confidence: 0.9,
|
|
13585
|
+
resident: state2.facet === "preference" || state2.facet === "style"
|
|
13586
|
+
});
|
|
13587
|
+
async function resolvePureVNextRuntime(input) {
|
|
13588
|
+
const { db, owners, userInput } = input;
|
|
13589
|
+
if (owners.length === 0 || !userInput.trim()) {
|
|
13590
|
+
return { selectedItems: [], promptBlock: null, recalledStateCount: 0 };
|
|
13591
|
+
}
|
|
13592
|
+
const ownerIds = owners.map((o) => `${o.ownerType}:${encodeURIComponent(o.ownerId)}`);
|
|
13593
|
+
const catalogs = await Promise.all(
|
|
13594
|
+
ownerIds.map((ownerId) => loadMemoryVNextCatalog(db, ownerId))
|
|
13595
|
+
);
|
|
13596
|
+
const selectedItems = [];
|
|
13597
|
+
const seenStateKeys = /* @__PURE__ */ new Set();
|
|
13598
|
+
for (let i = 0; i < owners.length; i++) {
|
|
13599
|
+
const owner = owners[i];
|
|
13600
|
+
const catalog = catalogs[i];
|
|
13601
|
+
const currentStates = catalog.states.filter((s) => !s.retiredAt && s.text.trim());
|
|
13602
|
+
const hits = recallMemoryVNextLocal({
|
|
13603
|
+
query: userInput,
|
|
13604
|
+
entities: catalog.entities,
|
|
13605
|
+
states: currentStates
|
|
13606
|
+
});
|
|
13607
|
+
const entityById = new Map(catalog.entities.map((e) => [e.id, e]));
|
|
13608
|
+
for (const hit of hits) {
|
|
13609
|
+
const stateKey = `${hit.state.ownerId}\0${hit.state.id}`;
|
|
13610
|
+
if (seenStateKeys.has(stateKey)) continue;
|
|
13611
|
+
seenStateKeys.add(stateKey);
|
|
13612
|
+
selectedItems.push(
|
|
13613
|
+
buildSynthesizedStateItem(hit.state, entityById.get(hit.state.entityId), owner.ownerType, owner.ownerId)
|
|
13614
|
+
);
|
|
13615
|
+
}
|
|
13616
|
+
}
|
|
13617
|
+
const promptBlock = selectedItems.length === 0 ? null : buildMemoryOverlay(selectedItems, {
|
|
13618
|
+
maxTokens: input.maxTokens ?? DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET
|
|
13619
|
+
});
|
|
13620
|
+
return {
|
|
13621
|
+
selectedItems,
|
|
13622
|
+
promptBlock,
|
|
13623
|
+
recalledStateCount: selectedItems.length
|
|
13624
|
+
};
|
|
13625
|
+
}
|
|
13626
|
+
|
|
13627
|
+
// packages/ai/memory/vnext/primaryRead.ts
|
|
13628
|
+
var MEMORY_VNEXT_PRIMARY_READ_TIMEOUT_MS = 300;
|
|
13629
|
+
var isMemoryVNextPrimaryReadEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_PRIMARY_READ === "1" || env.NOLO_MEMORY_VNEXT_PRIMARY_READ === "true";
|
|
13630
|
+
var buildSynthesizedStateItem2 = (state2, entity, ownerType, ownerId) => ({
|
|
13631
|
+
id: `vnext-state-${state2.id}`,
|
|
13632
|
+
ownerType,
|
|
13633
|
+
ownerId,
|
|
13634
|
+
visibility: "private",
|
|
13635
|
+
subjectType: "user",
|
|
13636
|
+
subjectId: ownerId,
|
|
13637
|
+
kind: "semantic",
|
|
13638
|
+
content: state2.text.trim(),
|
|
13639
|
+
createdAt: state2.createdAt,
|
|
13640
|
+
importance: 0.9,
|
|
13641
|
+
confidence: 0.9,
|
|
13642
|
+
// Flag resident preferences so they flow into overlay's resident section.
|
|
13643
|
+
resident: state2.facet === "preference" || state2.facet === "style",
|
|
13644
|
+
lastActivatedAt: state2.createdAt,
|
|
13645
|
+
activationCount: 1
|
|
13646
|
+
});
|
|
13647
|
+
var resolveMemoryVNextM4Selection = async (input) => {
|
|
13648
|
+
const { db, owners, query, selected } = input;
|
|
13649
|
+
const ownerIds = owners.map((o) => `${o.ownerType}:${encodeURIComponent(o.ownerId)}`);
|
|
13650
|
+
const catalogs = new Map(
|
|
13651
|
+
await Promise.all(
|
|
13652
|
+
ownerIds.map(async (ownerId) => [
|
|
13653
|
+
ownerId,
|
|
13654
|
+
await loadMemoryVNextCatalog(db, ownerId)
|
|
13655
|
+
])
|
|
13656
|
+
)
|
|
13657
|
+
);
|
|
13658
|
+
const recalledStates = [];
|
|
13659
|
+
const recalledStateIds = /* @__PURE__ */ new Set();
|
|
13660
|
+
for (const owner of owners) {
|
|
13661
|
+
const principalId = `${owner.ownerType}:${encodeURIComponent(owner.ownerId)}`;
|
|
13662
|
+
const catalog = catalogs.get(principalId);
|
|
13663
|
+
if (!catalog) continue;
|
|
13664
|
+
const currentStates = catalog.states.filter((s) => !s.retiredAt && s.text.trim());
|
|
13665
|
+
const hits = recallMemoryVNextLocal({
|
|
13666
|
+
query,
|
|
13667
|
+
entities: catalog.entities,
|
|
13668
|
+
states: currentStates
|
|
13669
|
+
});
|
|
13670
|
+
const entityById = new Map(catalog.entities.map((e) => [e.id, e]));
|
|
13671
|
+
for (const hit of hits) {
|
|
13672
|
+
if (recalledStateIds.has(hit.state.id)) continue;
|
|
13673
|
+
recalledStateIds.add(hit.state.id);
|
|
13674
|
+
recalledStates.push(
|
|
13675
|
+
buildSynthesizedStateItem2(hit.state, entityById.get(hit.state.entityId), owner.ownerType, owner.ownerId)
|
|
13676
|
+
);
|
|
13677
|
+
}
|
|
13678
|
+
}
|
|
13679
|
+
const uncoveredLegacy = [];
|
|
13680
|
+
let coveredSuppressedCount = 0;
|
|
13681
|
+
for (const item of selected) {
|
|
13682
|
+
const evidence = buildLegacyMemoryEvidence(item);
|
|
13683
|
+
const catalog = catalogs.get(evidence.ownerId);
|
|
13684
|
+
const states = catalog?.states ?? [];
|
|
13685
|
+
const covering = currentStatesCitingEvidence(states, evidence.id);
|
|
13686
|
+
if (covering.length > 0) {
|
|
13687
|
+
coveredSuppressedCount++;
|
|
13688
|
+
} else {
|
|
13689
|
+
uncoveredLegacy.push(item);
|
|
13690
|
+
}
|
|
13691
|
+
}
|
|
13692
|
+
const renderItems = [...recalledStates, ...uncoveredLegacy];
|
|
13693
|
+
return {
|
|
13694
|
+
renderItems,
|
|
13695
|
+
recalledStateCount: recalledStates.length,
|
|
13696
|
+
uncoveredLegacyCount: uncoveredLegacy.length,
|
|
13697
|
+
coveredSuppressedCount
|
|
13698
|
+
};
|
|
13699
|
+
};
|
|
13700
|
+
|
|
13263
13701
|
// packages/ai/memory/runtime.ts
|
|
13264
13702
|
var COLD_STORAGE_CONFIDENCE = 0.3;
|
|
13265
13703
|
var MEMORY_OVERLAY_TOKEN_BUDGET = DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET;
|
|
@@ -13382,6 +13820,18 @@ var resolveMemoryRuntime = async (input) => {
|
|
|
13382
13820
|
if (owners.length === 0) {
|
|
13383
13821
|
return { selectedItems: [], promptBlock: null };
|
|
13384
13822
|
}
|
|
13823
|
+
if (isMemoryVNextPureReadEnabled()) {
|
|
13824
|
+
const pure = await resolvePureVNextRuntime({
|
|
13825
|
+
db: input.db,
|
|
13826
|
+
owners,
|
|
13827
|
+
userInput: input.userInput,
|
|
13828
|
+
maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET
|
|
13829
|
+
});
|
|
13830
|
+
return {
|
|
13831
|
+
selectedItems: pure.selectedItems,
|
|
13832
|
+
promptBlock: pure.promptBlock
|
|
13833
|
+
};
|
|
13834
|
+
}
|
|
13385
13835
|
const policy = resolveAgentMemoryPolicy({ agentKey: input.agentKey });
|
|
13386
13836
|
const legacyStartedAt = performance.now();
|
|
13387
13837
|
const candidates = await loadMemoryCandidatesFromDb(input.db, {
|
|
@@ -13411,10 +13861,62 @@ var resolveMemoryRuntime = async (input) => {
|
|
|
13411
13861
|
);
|
|
13412
13862
|
const selected = [...residentItems, ...ranked];
|
|
13413
13863
|
const legacyLatencyMs = Math.round((performance.now() - legacyStartedAt) * 10) / 10;
|
|
13414
|
-
const
|
|
13415
|
-
|
|
13864
|
+
const renderOverlay = (items) => items.length === 0 ? null : buildMemoryOverlay(items, { maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET });
|
|
13865
|
+
let promptBlock = renderOverlay(selected);
|
|
13866
|
+
const primaryRead = isMemoryVNextPrimaryReadEnabled();
|
|
13867
|
+
let allCoveredByVNext = false;
|
|
13868
|
+
if (primaryRead) {
|
|
13869
|
+
const emitPrimary = (observation) => {
|
|
13870
|
+
try {
|
|
13871
|
+
(input.primaryReadEmit ?? ((o) => console.info("[memory] vnext primary read", { event: "memory_vnext_primary_read", ...o })))(observation);
|
|
13872
|
+
} catch {
|
|
13873
|
+
}
|
|
13874
|
+
};
|
|
13875
|
+
const base = { legacyHitCount: selected.length, legacyLatencyMs };
|
|
13876
|
+
const vnextStartedAt = performance.now();
|
|
13877
|
+
const vnextLatency = () => Math.round((performance.now() - vnextStartedAt) * 10) / 10;
|
|
13878
|
+
if (selected.length === 0) {
|
|
13879
|
+
emitPrimary({ ...base, source: "none" });
|
|
13880
|
+
} else {
|
|
13881
|
+
try {
|
|
13882
|
+
let timer;
|
|
13883
|
+
const m4 = await Promise.race([
|
|
13884
|
+
resolveMemoryVNextM4Selection({ db: input.db, owners, query: input.userInput, selected }),
|
|
13885
|
+
new Promise((_, reject) => {
|
|
13886
|
+
timer = setTimeout(
|
|
13887
|
+
() => reject(Object.assign(new Error("timeout"), { name: "TimeoutError" })),
|
|
13888
|
+
MEMORY_VNEXT_PRIMARY_READ_TIMEOUT_MS
|
|
13889
|
+
);
|
|
13890
|
+
})
|
|
13891
|
+
]).finally(() => clearTimeout(timer));
|
|
13892
|
+
promptBlock = renderOverlay(m4.renderItems);
|
|
13893
|
+
allCoveredByVNext = m4.uncoveredLegacyCount === 0 && m4.recalledStateCount > 0;
|
|
13894
|
+
const source = m4.recalledStateCount > 0 ? m4.uncoveredLegacyCount === 0 ? "vnext" : "hybrid" : m4.uncoveredLegacyCount > 0 ? "legacy_fallback" : "none";
|
|
13895
|
+
emitPrimary({
|
|
13896
|
+
...base,
|
|
13897
|
+
source,
|
|
13898
|
+
uncoveredLegacyCount: m4.uncoveredLegacyCount,
|
|
13899
|
+
coveredSuppressedCount: m4.coveredSuppressedCount,
|
|
13900
|
+
recalledStateCount: m4.recalledStateCount,
|
|
13901
|
+
vnextLatencyMs: vnextLatency(),
|
|
13902
|
+
contextChars: promptBlock?.length ?? 0,
|
|
13903
|
+
...source === "legacy_fallback" ? { fallbackReason: "no_vnext_context" } : {}
|
|
13904
|
+
});
|
|
13905
|
+
} catch (error) {
|
|
13906
|
+
emitPrimary({
|
|
13907
|
+
...base,
|
|
13908
|
+
source: "legacy_fallback",
|
|
13909
|
+
vnextLatencyMs: vnextLatency(),
|
|
13910
|
+
contextChars: promptBlock?.length ?? 0,
|
|
13911
|
+
fallbackReason: "vnext_error",
|
|
13912
|
+
error: error instanceof Error ? error.name : "UnknownError"
|
|
13913
|
+
});
|
|
13914
|
+
}
|
|
13915
|
+
}
|
|
13916
|
+
}
|
|
13917
|
+
const shadowEnabled = !primaryRead && input.vNextShadowProvider != null && isMemoryVNextShadowReadEnabled();
|
|
13416
13918
|
if (shadowEnabled) {
|
|
13417
|
-
|
|
13919
|
+
void runMemoryVNextShadowRead({
|
|
13418
13920
|
ctx: {
|
|
13419
13921
|
db: input.db,
|
|
13420
13922
|
owners,
|
|
@@ -13424,17 +13926,28 @@ var resolveMemoryRuntime = async (input) => {
|
|
|
13424
13926
|
legacyItems: selected,
|
|
13425
13927
|
legacyLatencyMs,
|
|
13426
13928
|
legacyContextChars: promptBlock?.length ?? 0
|
|
13929
|
+
}).catch(() => {
|
|
13427
13930
|
});
|
|
13428
13931
|
}
|
|
13429
|
-
const promotionCandidate = selected[0];
|
|
13430
13932
|
const lazyPromotionEnabled = input.vNextShadowProvider != null && isMemoryVNextLazyPromotionEnabled();
|
|
13431
|
-
if (lazyPromotionEnabled &&
|
|
13432
|
-
void
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13933
|
+
if (lazyPromotionEnabled && selected.length > 0 && !allCoveredByVNext) {
|
|
13934
|
+
void (async () => {
|
|
13935
|
+
const promotionPick = await pickFirstUncoveredLazyPromotionItem(
|
|
13936
|
+
input.db,
|
|
13937
|
+
selected
|
|
13938
|
+
);
|
|
13939
|
+
if (promotionPick) {
|
|
13940
|
+
await runMemoryVNextLazyPromotion({
|
|
13941
|
+
db: input.db,
|
|
13942
|
+
item: promotionPick.item,
|
|
13943
|
+
selectedIndex: promotionPick.selectedIndex,
|
|
13944
|
+
skippedCoveredCount: promotionPick.skippedCoveredCount,
|
|
13945
|
+
skippedNoOpCount: promotionPick.skippedNoOpCount,
|
|
13946
|
+
provider: input.vNextShadowProvider,
|
|
13947
|
+
...input.lazyPromotionEmit ? { emit: input.lazyPromotionEmit } : {}
|
|
13948
|
+
});
|
|
13949
|
+
}
|
|
13950
|
+
})().catch(() => {
|
|
13438
13951
|
});
|
|
13439
13952
|
}
|
|
13440
13953
|
if (selected.length === 0) {
|
|
@@ -13448,6 +13961,52 @@ var resolveMemoryRuntime = async (input) => {
|
|
|
13448
13961
|
};
|
|
13449
13962
|
|
|
13450
13963
|
// packages/cli/memoryRecall.ts
|
|
13964
|
+
var logger = getLogger("cli.memoryRecall");
|
|
13965
|
+
var DEDUP_WINDOW_MS = 5 * 60 * 1e3;
|
|
13966
|
+
var DEDUP_MAX_KEYS = 100;
|
|
13967
|
+
var dedupMap = /* @__PURE__ */ new Map();
|
|
13968
|
+
function evictDedupIfNeeded() {
|
|
13969
|
+
if (dedupMap.size < DEDUP_MAX_KEYS) return;
|
|
13970
|
+
let oldestKey = null;
|
|
13971
|
+
let oldestTs = Infinity;
|
|
13972
|
+
for (const [k, v] of dedupMap) {
|
|
13973
|
+
if (v.lastLog < oldestTs) {
|
|
13974
|
+
oldestTs = v.lastLog;
|
|
13975
|
+
oldestKey = k;
|
|
13976
|
+
}
|
|
13977
|
+
}
|
|
13978
|
+
if (oldestKey !== null) dedupMap.delete(oldestKey);
|
|
13979
|
+
}
|
|
13980
|
+
function logDeduped(level, fingerprint, message, error) {
|
|
13981
|
+
const now = Date.now();
|
|
13982
|
+
const entry = dedupMap.get(fingerprint);
|
|
13983
|
+
if (!entry) {
|
|
13984
|
+
evictDedupIfNeeded();
|
|
13985
|
+
dedupMap.set(fingerprint, { count: 1, suppressed: 0, lastLog: now });
|
|
13986
|
+
if (error !== void 0) logger[level](message, error);
|
|
13987
|
+
else logger[level](message);
|
|
13988
|
+
return;
|
|
13989
|
+
}
|
|
13990
|
+
entry.count += 1;
|
|
13991
|
+
if (now - entry.lastLog >= DEDUP_WINDOW_MS) {
|
|
13992
|
+
const suppressed = entry.suppressed;
|
|
13993
|
+
const summary = `${message} (deduplicated: ${entry.count} occurrences, ${suppressed} suppressed over ${Math.round((now - entry.lastLog) / 1e3)}s)`;
|
|
13994
|
+
if (error !== void 0) logger[level](summary, error);
|
|
13995
|
+
else logger[level](summary);
|
|
13996
|
+
entry.count = 1;
|
|
13997
|
+
entry.suppressed = 0;
|
|
13998
|
+
entry.lastLog = now;
|
|
13999
|
+
} else {
|
|
14000
|
+
entry.suppressed += 1;
|
|
14001
|
+
}
|
|
14002
|
+
}
|
|
14003
|
+
function fingerprintFor(kind, detail) {
|
|
14004
|
+
const d = detail === void 0 ? "" : sanitizeFp(String(detail));
|
|
14005
|
+
return `mem-${kind}:${d}`;
|
|
14006
|
+
}
|
|
14007
|
+
function sanitizeFp(s) {
|
|
14008
|
+
return s.replace(/\s+/g, " ").slice(0, 80);
|
|
14009
|
+
}
|
|
13451
14010
|
var queryRemoteMemory = async (serverUrl, authToken, agentKey, userInput, spaceId) => {
|
|
13452
14011
|
try {
|
|
13453
14012
|
const response = await fetch(`${serverUrl}/api/memory/query`, {
|
|
@@ -13464,10 +14023,10 @@ var queryRemoteMemory = async (serverUrl, authToken, agentKey, userInput, spaceI
|
|
|
13464
14023
|
signal: AbortSignal.timeout(5e3)
|
|
13465
14024
|
});
|
|
13466
14025
|
if (!response.ok) {
|
|
13467
|
-
|
|
13468
|
-
"
|
|
13469
|
-
response.status,
|
|
13470
|
-
|
|
14026
|
+
logDeduped(
|
|
14027
|
+
"warn",
|
|
14028
|
+
fingerprintFor("remote-nonok", response.status),
|
|
14029
|
+
`remote query returned non-ok status ${response.status} \u2014 falling back to local`
|
|
13471
14030
|
);
|
|
13472
14031
|
return null;
|
|
13473
14032
|
}
|
|
@@ -13475,7 +14034,12 @@ var queryRemoteMemory = async (serverUrl, authToken, agentKey, userInput, spaceI
|
|
|
13475
14034
|
const block = typeof payload?.promptBlock === "string" ? payload.promptBlock.trim() : "";
|
|
13476
14035
|
return block || null;
|
|
13477
14036
|
} catch (error) {
|
|
13478
|
-
|
|
14037
|
+
logDeduped(
|
|
14038
|
+
"info",
|
|
14039
|
+
fingerprintFor("remote-failed", error instanceof Error ? error.name : void 0),
|
|
14040
|
+
"remote query failed, falling back to local",
|
|
14041
|
+
normalizeError(error)
|
|
14042
|
+
);
|
|
13479
14043
|
return null;
|
|
13480
14044
|
}
|
|
13481
14045
|
};
|
|
@@ -13511,7 +14075,12 @@ var resolveCliMemory = async (input) => {
|
|
|
13511
14075
|
input.spaceId
|
|
13512
14076
|
);
|
|
13513
14077
|
} catch (error) {
|
|
13514
|
-
|
|
14078
|
+
logDeduped(
|
|
14079
|
+
"warn",
|
|
14080
|
+
fingerprintFor("local-failed", error instanceof Error ? error.name : void 0),
|
|
14081
|
+
"local recall failed, omitting memory layer",
|
|
14082
|
+
normalizeError(error)
|
|
14083
|
+
);
|
|
13515
14084
|
return null;
|
|
13516
14085
|
}
|
|
13517
14086
|
};
|
|
@@ -13566,7 +14135,10 @@ async function resolveAgentRunAgentKey(args) {
|
|
|
13566
14135
|
}
|
|
13567
14136
|
async function runAgentRunCommand(args, deps) {
|
|
13568
14137
|
const env = deps.env ?? process.env;
|
|
13569
|
-
const output = deps.output ??
|
|
14138
|
+
const output = deps.output ?? {
|
|
14139
|
+
write: (chunk) => process.stdout.write(chunk),
|
|
14140
|
+
writeErr: (chunk) => process.stderr.write(chunk)
|
|
14141
|
+
};
|
|
13570
14142
|
if (args.includes("--help") || args.includes("-h")) {
|
|
13571
14143
|
writeUsage(output, deps.commandPath);
|
|
13572
14144
|
return 0;
|
|
@@ -14108,12 +14680,6 @@ function isBalanceExhaustedError(error) {
|
|
|
14108
14680
|
}
|
|
14109
14681
|
|
|
14110
14682
|
export {
|
|
14111
|
-
resolveAgentModelIdentity,
|
|
14112
|
-
resolveAgentContextWindow,
|
|
14113
|
-
platformCreditsFromUsage,
|
|
14114
|
-
formatCreditsChip,
|
|
14115
|
-
formatTokenCount,
|
|
14116
|
-
renderTokenStatus,
|
|
14117
14683
|
resolveCliColorEnabled,
|
|
14118
14684
|
dimCliText,
|
|
14119
14685
|
ANSI_ESCAPE_REGEX,
|
|
@@ -14154,6 +14720,12 @@ export {
|
|
|
14154
14720
|
formatAssistantDisplay,
|
|
14155
14721
|
redactSecrets,
|
|
14156
14722
|
TUI_TREE_MARKER,
|
|
14723
|
+
resolveAgentModelIdentity,
|
|
14724
|
+
resolveAgentContextWindow,
|
|
14725
|
+
platformCreditsFromUsage,
|
|
14726
|
+
formatCreditsChip,
|
|
14727
|
+
formatTokenCount,
|
|
14728
|
+
renderTokenStatus,
|
|
14157
14729
|
COLLAPSED_PASTE_PLACEHOLDER_RE,
|
|
14158
14730
|
shouldCollapsePaste,
|
|
14159
14731
|
createCollapsedPasteStore,
|
|
@@ -14165,14 +14737,14 @@ export {
|
|
|
14165
14737
|
expandRangeToCollapsedPasteChips,
|
|
14166
14738
|
findCollapsedPasteSpanAt,
|
|
14167
14739
|
runAgentTurn,
|
|
14168
|
-
readAgentsMdLayerFromDisk,
|
|
14169
14740
|
resolveWorkflowReference,
|
|
14170
14741
|
resolveSkillReference,
|
|
14171
14742
|
buildSkillContextBlocks,
|
|
14172
14743
|
prependSubjectDialogMarker,
|
|
14173
14744
|
normalizeCliImageInput,
|
|
14174
|
-
|
|
14745
|
+
readAgentsMdLayerFromDisk,
|
|
14175
14746
|
resolveCliMemory,
|
|
14747
|
+
inspectLocalRunWorkspace,
|
|
14176
14748
|
resolveRunOutcome,
|
|
14177
14749
|
isRunResultStalledOrTruncated,
|
|
14178
14750
|
resolveRunSettlementNote,
|