nolo-cli 0.254.0-alpha.1 → 0.255.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{_executeModel-OMDET3E2.js → _executeModel-XD2EAFVG.js} +44 -43
- package/{action-4MADDU52.js → action-C6IQAKN4.js} +5 -5
- package/{addContentAction-MT4BECXT.js → addContentAction-53364YDW.js} +8 -8
- package/{addDialogAgentAction-ZZTJ5GBD.js → addDialogAgentAction-U5DD5EN5.js} +7 -7
- package/{agentDeleteCommand-5WXEECFH.js → agentDeleteCommand-AI2AAFA4.js} +59 -58
- package/{agentEmailCommands-3QWBB2JL.js → agentEmailCommands-I544I2MU.js} +60 -59
- package/{agentListCommands-WTEF5RKJ.js → agentListCommands-3NB4FDIJ.js} +26 -25
- package/{agentMachineCommands-DP44GKA6.js → agentMachineCommands-RZEHM6NS.js} +22 -21
- package/{agentRecordCommands-4I7P34GJ.js → agentRecordCommands-X2AVD6Y2.js} +59 -58
- package/{agentRunCommand-VAKWFXJV.js → agentRunCommand-XU5TL3WO.js} +63 -59
- package/{agentRunControl-5ABAIBQT.js → agentRunControl-3TIVJ3SR.js} +3 -2
- package/{agentRuntimeLocal-IO3GGTCJ.js → agentRuntimeLocal-3MAEFYSB.js} +18 -17
- package/{agentSlice-5ZSVWJHV.js → agentSlice-ZFY3PT3D.js} +9 -9
- package/{appDeleteCommands-ZQ4ZEKTC.js → appDeleteCommands-J5BTYVPC.js} +24 -23
- package/{appDeployCommands-4XT7PFW5.js → appDeployCommands-I3JIN7TN.js} +24 -23
- package/{appDeployStatusCommands-5RVMRYQW.js → appDeployStatusCommands-BKJVLIOV.js} +24 -23
- package/{appGetCommands-VH5W3RFK.js → appGetCommands-67JTU36H.js} +24 -23
- package/{appListCommands-TAHZLAL3.js → appListCommands-HF4GFCN4.js} +24 -23
- package/{authCommand-HBO5G6RL.js → authCommand-Y3CXNAYM.js} +4 -4
- package/{builtinSkillRegistry-66PEOD4Y.js → builtinSkillRegistry-FVEEO4U2.js} +3 -3
- package/{chromeOpsCommands-AA555ANS.js → chromeOpsCommands-W5I2AEOV.js} +1 -1
- package/{chunk-D3WOFN6N.js → chunk-223KZUJ6.js} +1 -1
- package/{chunk-MICGEDCN.js → chunk-24Z44WHO.js} +27 -27
- package/{chunk-MR72IIX5.js → chunk-2BHHT2TR.js} +4 -4
- package/{chunk-NXNHG3QT.js → chunk-3W2J3LFB.js} +21 -10
- package/{chunk-2RCMFPUZ.js → chunk-46FETNLF.js} +2 -2
- package/{chunk-CO6E7YK6.js → chunk-5P3PPQVP.js} +1 -1
- package/{chunk-KR4W72OK.js → chunk-6FONTXR7.js} +45 -25
- package/{chunk-KWARDHBI.js → chunk-6N4IKMTH.js} +37 -2
- package/{chunk-M7GMJBQJ.js → chunk-6VEO7Z3Y.js} +3 -3
- package/{chunk-2VYX3ZCR.js → chunk-6VNBJ7GI.js} +5 -5
- package/{chunk-GK772DEV.js → chunk-7BIJFGKS.js} +3 -3
- package/{chunk-3SEBCWLD.js → chunk-7EUJ65PF.js} +2057 -223
- package/{chunk-4GWNEPY6.js → chunk-7PTWFSZZ.js} +1 -1
- package/{chunk-CIAV4WK2.js → chunk-7WHCIA5V.js} +2 -2
- package/{chunk-MCQXBKC6.js → chunk-AAYDROBM.js} +2 -2
- package/{chunk-53UOBNTI.js → chunk-ADYWV732.js} +8 -8
- package/{chunk-WLHUANWZ.js → chunk-AIFQKNPP.js} +1 -1
- package/{chunk-GFXPPQZN.js → chunk-AKBNCTPY.js} +1 -1
- package/{chunk-HEUHCHAR.js → chunk-BD22OFDQ.js} +3 -3
- package/{chunk-SID2TFMV.js → chunk-BXGU6274.js} +104 -55
- package/{chunk-SCY2O7CU.js → chunk-BZMDWGQQ.js} +2 -2
- package/{chunk-YYHWEVBI.js → chunk-CAPHUP3M.js} +2 -2
- package/{chunk-JKO32CCL.js → chunk-CBIGMWMI.js} +1 -1
- package/{chunk-JP2BH4NC.js → chunk-CEKRIR22.js} +1 -1
- package/{chunk-6AJIU6OC.js → chunk-D53SPVAC.js} +3 -3
- package/{chunk-HS4JGZQH.js → chunk-DWES4SXY.js} +1 -1
- package/{chunk-3272HU62.js → chunk-E47JZP2R.js} +1 -1
- package/{chunk-D4CUS6NT.js → chunk-E4HBZDV6.js} +3 -3
- package/{chunk-2G3XMM3O.js → chunk-EXD7S7QW.js} +41 -5
- package/{chunk-YGDYYFRX.js → chunk-GYX6XTAI.js} +3 -5
- package/{chunk-HKPIFK7F.js → chunk-H3KLIPAL.js} +5 -5
- package/{chunk-NEDBPW44.js → chunk-H6EKTB6X.js} +2 -2
- package/{chunk-VYRTLHIT.js → chunk-HDKMVYNJ.js} +1 -1
- package/chunk-HEVRQGGH.js +106 -0
- package/{chunk-4CL6QIQZ.js → chunk-HPDLPEUG.js} +2 -2
- package/{chunk-YW5L3XOO.js → chunk-HZQGCFPJ.js} +10 -10
- package/{chunk-7STRX24O.js → chunk-JAAYO52G.js} +8 -7
- package/{chunk-QV32GSVO.js → chunk-JPZKKSGT.js} +1 -1
- package/{chunk-Z2ZCKNKX.js → chunk-JW6OURKM.js} +261 -228
- package/{chunk-TA2JQUWA.js → chunk-K5X4D2TS.js} +156 -1767
- package/{chunk-IGK4OXAO.js → chunk-KF7M2UEK.js} +499 -7
- package/{chunk-VZCBYCHV.js → chunk-KG27JIG4.js} +2 -2
- package/{chunk-PTY2VZM5.js → chunk-KO5GO2BC.js} +6 -8
- package/{chunk-GJKEOBCV.js → chunk-KRDG2XCI.js} +10 -10
- package/{chunk-OLS2J3WE.js → chunk-LLUBUHNT.js} +1 -1
- package/{chunk-ZAKWT4XQ.js → chunk-LQ4CQKTS.js} +3 -3
- package/{chunk-52M4RYVP.js → chunk-MDHI2LWF.js} +1 -1
- package/{chunk-XWR2YD4L.js → chunk-MLK3FEXG.js} +1 -1
- package/{chunk-KQBGXCKM.js → chunk-MNFUKRRU.js} +3 -3
- package/{chunk-FRC2DNTN.js → chunk-NAW2SN54.js} +1 -1
- package/{chunk-UHW6SCVK.js → chunk-NUHQO3RB.js} +1 -1
- package/{chunk-CYGFNMCH.js → chunk-OKAXQFON.js} +1 -1
- package/{chunk-P4JX7YMQ.js → chunk-ONTHDYFU.js} +22 -2
- package/{chunk-PR25J652.js → chunk-PNBQ5JTA.js} +1 -1
- package/{chunk-MW3XUUYS.js → chunk-PVHY7Y6T.js} +6 -6
- package/{chunk-K4LLTJUO.js → chunk-Q2MPKE4B.js} +5 -105
- package/{chunk-AX63ZU2W.js → chunk-Q66O5LN3.js} +4 -4
- package/{chunk-6WI4PFPP.js → chunk-QEVT4LQ3.js} +68 -54
- package/{chunk-OMIXG25B.js → chunk-QGFLVQ6E.js} +1 -1
- package/{chunk-25BDZGD7.js → chunk-QJKDHR4Y.js} +2 -2
- package/{chunk-IDCGMZLC.js → chunk-QNZRR3NT.js} +9 -9
- package/{chunk-WMMKHEGQ.js → chunk-R3FZHW4Q.js} +12 -12
- package/{chunk-KZAT2M2V.js → chunk-RIWKZT7E.js} +22 -0
- package/{chunk-OWXOXKH7.js → chunk-SCAC3NM5.js} +2 -2
- package/{chunk-EG3JTV7H.js → chunk-TCAAHWCY.js} +2 -2
- package/{chunk-NMGG3NUB.js → chunk-U6QNVOR5.js} +1 -1
- package/{chunk-5UYDG6HP.js → chunk-V5NK6KMF.js} +8 -13
- package/{chunk-AIHNB5QH.js → chunk-VQR2ACSC.js} +6 -4
- package/{chunk-HEQJ5XND.js → chunk-WS36XPJD.js} +2 -2
- package/{chunk-MRYKRL2V.js → chunk-WSLL7VV4.js} +2 -2
- package/{dialogUsageCommand-3JMINURR.js → chunk-Y2TCTNUD.js} +19 -12
- package/{chunk-4Z7Q4QZF.js → chunk-YKCFDOO4.js} +765 -29
- package/{chunk-DNY33GGQ.js → chunk-YN23INFZ.js} +1 -1
- package/{chunk-5HUO7SEX.js → chunk-YQLAFJRQ.js} +1 -1
- package/{chunk-VPSPVLCM.js → chunk-ZMJMHXYX.js} +3 -3
- package/{chunk-W4S5FQWQ.js → chunk-ZTHAJU3O.js} +1 -1
- package/{cliAgentConfigHelpers-FKBPFPKR.js → cliAgentConfigHelpers-BXHQ3PXP.js} +2 -2
- package/{cliLocalAgentRecordReader-2WBUVRVD.js → cliLocalAgentRecordReader-Q6677YID.js} +22 -21
- package/{commandRegistry-DONNI3FW.js → commandRegistry-YCKR4SWB.js} +82 -78
- package/{contentThunks-THSXC6WQ.js → contentThunks-R2ZLM2Z3.js} +20 -20
- package/{cooldownCommands-PT5L4LNB.js → cooldownCommands-TVZBWUN3.js} +1 -1
- package/{createAgentAutomationAction-WNQOJ4DG.js → createAgentAutomationAction-Q665HFZS.js} +20 -20
- package/{createDialogAction-YORDQFFC.js → createDialogAction-VOGA6VXH.js} +21 -21
- package/{createPageAction-2S7V5OCW.js → createPageAction-FICG35GF.js} +21 -21
- package/{dbSlice-HXFRXGI3.js → dbSlice-RWPSVHBC.js} +7 -7
- package/{deleteFile-QDSZVTUJ.js → deleteFile-ECU6FU5C.js} +5 -5
- package/{dialogCommands-MEH4CVRL.js → dialogCommands-TCIB4AMT.js} +28 -25
- package/{dialogNotifyCommand-JKYVSR6K.js → dialogNotifyCommand-IASQGEMW.js} +3 -3
- package/{dialogSlice-JOICDGQU.js → dialogSlice-SCZJH2Q3.js} +18 -18
- package/dialogTraceCommand-E3BYXL3D.js +961 -0
- package/dialogUsageCommand-WJ3U6KZU.js +27 -0
- package/{docCreateCommands-MVAYVGQ5.js → docCreateCommands-UHY2QSEL.js} +23 -22
- package/{docDeleteCommands-TKXPRA3O.js → docDeleteCommands-JX53B6VB.js} +24 -23
- package/{docReadCommands-MR2YKCZP.js → docReadCommands-H5XZBEYD.js} +23 -22
- package/{docStore-NKVLWCXX.js → docStore-KTTOVQLL.js} +8 -8
- package/{docUpdateCommands-VJ6A6F7F.js → docUpdateCommands-YYYU6CHT.js} +23 -22
- package/{handleSendMessageAction-SNNYOQ4P.js → handleSendMessageAction-FRGNSG6B.js} +32 -32
- package/{hostCredentialCreate-SDQUFL23.js → hostCredentialCreate-V5EDFPAV.js} +59 -58
- package/index.js +7 -7
- package/{localRuntimeAdapter-JHYH5ZIR.js → localRuntimeAdapter-VMGFXQOJ.js} +58 -57
- package/{machineCommands-BXSBRM7L.js → machineCommands-AUPY2QB6.js} +59 -58
- package/{machineWsRunDispatch-KEXSHGSD.js → machineWsRunDispatch-KNOARY66.js} +59 -58
- package/{mcpLocalAuthorizeCommand-Y3SOZFXT.js → mcpLocalAuthorizeCommand-RBXJDE6J.js} +2 -2
- package/{memberThunks-ZXEUM6DH.js → memberThunks-43B7UYC5.js} +9 -9
- package/package.json +1 -1
- package/{projectArchive-FDYE7VNC.js → projectArchive-KON534LA.js} +21 -21
- package/{read-T5WPCAY7.js → read-KG6INYUT.js} +5 -5
- package/{readDocTool-DW4DCRQG.js → readDocTool-N3GA52JR.js} +1 -1
- package/{readlineWorkspace-ME2C64XI.js → readlineWorkspace-MHYNJR5O.js} +599 -840
- package/{removeDialogAgentAction-MXJEB77K.js → removeDialogAgentAction-EEVSOQOJ.js} +9 -9
- package/{runAgentClientLoop-UAGXVYW5.js → runAgentClientLoop-YRGQCRC4.js} +51 -40
- package/{secretCommands-BXAQEOES.js → secretCommands-POD67M6Y.js} +2 -2
- package/{setDialogExtraReferencesAction-BILVMHM7.js → setDialogExtraReferencesAction-DNO5POHA.js} +8 -8
- package/{setPrimaryDialogAgentAction-CUBBWACR.js → setPrimaryDialogAgentAction-QABBEO4C.js} +9 -9
- package/{settingThunks-BRBBAGEK.js → settingThunks-DVKG4X4S.js} +10 -10
- package/{skillDiscovery-MDDKPTW3.js → skillDiscovery-5GEGWJ6N.js} +3 -3
- package/{spaceCommands-K4HHG7OO.js → spaceCommands-USN52WYJ.js} +22 -21
- package/{streamAgentChatTurn-RZUB6JTH.js → streamAgentChatTurn-EQO3ULUB.js} +62 -50
- package/{switchDialogAgentAction-SSI2CSNE.js → switchDialogAgentAction-KYWJSGOO.js} +7 -7
- package/{tableCommands-C3P2HHKK.js → tableCommands-EFA754RE.js} +2 -2
- package/{tools-23F5EEVM.js → tools-UME4HYSH.js} +36 -35
- package/{tuiRestart-7IKI6JZK.js → tuiRestart-VN5F4GYU.js} +4 -3
- package/tuiSummaryLlmCaller-HROLGN4F.js +1 -1
- package/{updateCommands-BZ4YDHNM.js → updateCommands-L32TVOI7.js} +3 -3
- package/{updateDialogTitleAction-TJWT4LXL.js → updateDialogTitleAction-NZIGJL5Q.js} +20 -20
- package/{usageCommand-HVCMX7BG.js → usageCommand-WI6SQOPB.js} +1 -1
- package/{usageRebuildCommand-VMPIZ2ME.js → usageRebuildCommand-WQRLLZAT.js} +2 -2
- package/{windowsSelfUpdate-4BAXX7C3.js → windowsSelfUpdate-AGVLDVQS.js} +2 -2
- package/lib-62SWPXNF.js +0 -21042
|
@@ -0,0 +1,961 @@
|
|
|
1
|
+
import {
|
|
2
|
+
collectDialogUsageRecords
|
|
3
|
+
} from "./chunk-Y2TCTNUD.js";
|
|
4
|
+
import "./chunk-TZXPT53C.js";
|
|
5
|
+
import {
|
|
6
|
+
readDialogSnapshot,
|
|
7
|
+
resolveDialogReadTarget
|
|
8
|
+
} from "./chunk-JAAYO52G.js";
|
|
9
|
+
import "./chunk-ID4G2MAR.js";
|
|
10
|
+
import "./chunk-Y5GCAMGP.js";
|
|
11
|
+
import "./chunk-7PTWFSZZ.js";
|
|
12
|
+
import "./chunk-AKBNCTPY.js";
|
|
13
|
+
import "./chunk-LKZPX6YH.js";
|
|
14
|
+
import "./chunk-E4HBZDV6.js";
|
|
15
|
+
import "./chunk-VQR2ACSC.js";
|
|
16
|
+
import "./chunk-AMWMV56B.js";
|
|
17
|
+
import "./chunk-DXWGFL2Z.js";
|
|
18
|
+
import "./chunk-3L2WKC3W.js";
|
|
19
|
+
import {
|
|
20
|
+
listRunRecords
|
|
21
|
+
} from "./chunk-ONTHDYFU.js";
|
|
22
|
+
import "./chunk-S25VJYXV.js";
|
|
23
|
+
import "./chunk-UEILX4EV.js";
|
|
24
|
+
import "./chunk-QQ56R7KS.js";
|
|
25
|
+
import "./chunk-GBWGPTA7.js";
|
|
26
|
+
import "./chunk-OQFOE4SJ.js";
|
|
27
|
+
import "./chunk-TRRXYFTR.js";
|
|
28
|
+
import "./chunk-JLZJL3WC.js";
|
|
29
|
+
import "./chunk-3A5NNQCN.js";
|
|
30
|
+
import "./chunk-R3MV2GII.js";
|
|
31
|
+
import "./chunk-SQL7YNED.js";
|
|
32
|
+
import "./chunk-CVMMWN6P.js";
|
|
33
|
+
import "./chunk-GLKOYSRU.js";
|
|
34
|
+
import "./chunk-CBIGMWMI.js";
|
|
35
|
+
import "./chunk-7EUJ65PF.js";
|
|
36
|
+
import "./chunk-ZNFJWEN4.js";
|
|
37
|
+
import "./chunk-LHCGKAFO.js";
|
|
38
|
+
import "./chunk-OOV5JN25.js";
|
|
39
|
+
import "./chunk-2E4BYAUE.js";
|
|
40
|
+
import "./chunk-AL3TYDIF.js";
|
|
41
|
+
import "./chunk-PIVTQRX6.js";
|
|
42
|
+
import "./chunk-HNUWUO75.js";
|
|
43
|
+
import "./chunk-CHOZJMJS.js";
|
|
44
|
+
import "./chunk-DMPZMYH4.js";
|
|
45
|
+
import "./chunk-MLK3FEXG.js";
|
|
46
|
+
import "./chunk-BYXBJQAS.js";
|
|
47
|
+
import "./chunk-BZLGPM5B.js";
|
|
48
|
+
import "./chunk-AIFQKNPP.js";
|
|
49
|
+
import "./chunk-56GBUMO5.js";
|
|
50
|
+
import "./chunk-BXGU6274.js";
|
|
51
|
+
import "./chunk-Q2MPKE4B.js";
|
|
52
|
+
import "./chunk-LS5KAVFQ.js";
|
|
53
|
+
import "./chunk-FXEPZKNJ.js";
|
|
54
|
+
import "./chunk-X4O7FJF5.js";
|
|
55
|
+
import "./chunk-TLE77UJ5.js";
|
|
56
|
+
import {
|
|
57
|
+
sanitizeToolOutputText,
|
|
58
|
+
scrubSecrets
|
|
59
|
+
} from "./chunk-KO5GO2BC.js";
|
|
60
|
+
import "./chunk-KXOPLLFP.js";
|
|
61
|
+
import "./chunk-DNNPARJK.js";
|
|
62
|
+
import "./chunk-2MBTWINN.js";
|
|
63
|
+
import "./chunk-7WHCIA5V.js";
|
|
64
|
+
import "./chunk-5ZUL4CUO.js";
|
|
65
|
+
import "./chunk-2FZVXOFX.js";
|
|
66
|
+
import "./chunk-H57T64RA.js";
|
|
67
|
+
import "./chunk-UKZX3NHN.js";
|
|
68
|
+
import "./chunk-SR4FE5VD.js";
|
|
69
|
+
import "./chunk-5MMAK75Q.js";
|
|
70
|
+
import "./chunk-USGHJSGO.js";
|
|
71
|
+
import "./chunk-E6A5NHDH.js";
|
|
72
|
+
import "./chunk-KX6YBIHG.js";
|
|
73
|
+
import "./chunk-6N4IKMTH.js";
|
|
74
|
+
import {
|
|
75
|
+
resolveModelTier
|
|
76
|
+
} from "./chunk-HEVRQGGH.js";
|
|
77
|
+
import "./chunk-EWQ3HGNZ.js";
|
|
78
|
+
import "./chunk-PSCNXBYA.js";
|
|
79
|
+
import "./chunk-IVK2KT3H.js";
|
|
80
|
+
import "./chunk-DWLEOOGR.js";
|
|
81
|
+
import "./chunk-7DPNBQSV.js";
|
|
82
|
+
import "./chunk-OW765XBU.js";
|
|
83
|
+
import "./chunk-YQLAFJRQ.js";
|
|
84
|
+
import "./chunk-GYX6XTAI.js";
|
|
85
|
+
import "./chunk-2SXN7LAY.js";
|
|
86
|
+
import "./chunk-G7Y4GXTY.js";
|
|
87
|
+
import "./chunk-6UBGXX2W.js";
|
|
88
|
+
import "./chunk-BV3FLP2L.js";
|
|
89
|
+
import "./chunk-4ZCTKB27.js";
|
|
90
|
+
import "./chunk-JW6OURKM.js";
|
|
91
|
+
import "./chunk-EUGTFFO6.js";
|
|
92
|
+
import "./chunk-AETZ7AD6.js";
|
|
93
|
+
import "./chunk-5P3PPQVP.js";
|
|
94
|
+
import "./chunk-KHCLMKZZ.js";
|
|
95
|
+
import "./chunk-SYTHYBMI.js";
|
|
96
|
+
import {
|
|
97
|
+
parseDialogKey
|
|
98
|
+
} from "./chunk-OJKUU3LP.js";
|
|
99
|
+
import "./chunk-YZMNK53S.js";
|
|
100
|
+
import "./chunk-QGFLVQ6E.js";
|
|
101
|
+
import "./chunk-BR3GT6MR.js";
|
|
102
|
+
import "./chunk-JCQ3WCQ3.js";
|
|
103
|
+
import "./chunk-UUCYUN6Y.js";
|
|
104
|
+
import "./chunk-YLAHYLDQ.js";
|
|
105
|
+
import "./chunk-RIWKZT7E.js";
|
|
106
|
+
import {
|
|
107
|
+
extractCustomId
|
|
108
|
+
} from "./chunk-M2EJHDJP.js";
|
|
109
|
+
import "./chunk-I42VC5KR.js";
|
|
110
|
+
import "./chunk-U6VC4MU4.js";
|
|
111
|
+
import "./chunk-EYLGAEB4.js";
|
|
112
|
+
import {
|
|
113
|
+
resolveAuthToken
|
|
114
|
+
} from "./chunk-BIDSIRTS.js";
|
|
115
|
+
import "./chunk-OLZBQWZU.js";
|
|
116
|
+
import "./chunk-LCBAMY2M.js";
|
|
117
|
+
import "./chunk-4O22PGNQ.js";
|
|
118
|
+
import "./chunk-V5NK6KMF.js";
|
|
119
|
+
import "./chunk-EJQE5HB7.js";
|
|
120
|
+
import "./chunk-6SOWMEAY.js";
|
|
121
|
+
import {
|
|
122
|
+
toErrorMessage
|
|
123
|
+
} from "./chunk-HNMXYYJR.js";
|
|
124
|
+
import "./chunk-LVZVSLKO.js";
|
|
125
|
+
import "./chunk-2JHGUL5K.js";
|
|
126
|
+
import "./chunk-3EUW3WEO.js";
|
|
127
|
+
import "./chunk-WWC7I6TA.js";
|
|
128
|
+
import "./chunk-OKH74FML.js";
|
|
129
|
+
import "./chunk-JRTNUU5Z.js";
|
|
130
|
+
import "./chunk-KUG52IAP.js";
|
|
131
|
+
import "./chunk-G3SUCT4W.js";
|
|
132
|
+
import "./chunk-4SN6J65J.js";
|
|
133
|
+
import "./chunk-CF7PE763.js";
|
|
134
|
+
import "./chunk-JPXACKSW.js";
|
|
135
|
+
import "./chunk-QSJ3HFEF.js";
|
|
136
|
+
import "./chunk-U67V476Y.js";
|
|
137
|
+
|
|
138
|
+
// packages/cli/dialogTrace.ts
|
|
139
|
+
var DIALOG_TRACE_SCHEMA_VERSION = 1;
|
|
140
|
+
var DIALOG_TRACE_SUMMARY_MAX_CHARS = 120;
|
|
141
|
+
var TOOL_CALL_PART_TYPES = /* @__PURE__ */ new Set([
|
|
142
|
+
"tool-call",
|
|
143
|
+
"tool_call",
|
|
144
|
+
"tool-call-request",
|
|
145
|
+
"tool-call-response",
|
|
146
|
+
"function_call"
|
|
147
|
+
]);
|
|
148
|
+
var asRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
149
|
+
var asString = (value) => typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
150
|
+
var asCount = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : void 0;
|
|
151
|
+
var asTimeIso = (value) => {
|
|
152
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) {
|
|
153
|
+
const ms = value < 1e11 ? value * 1e3 : value;
|
|
154
|
+
const date = new Date(ms);
|
|
155
|
+
return Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
|
|
156
|
+
}
|
|
157
|
+
if (typeof value === "string" && value.trim()) {
|
|
158
|
+
const ms = Date.parse(value.trim());
|
|
159
|
+
return Number.isNaN(ms) ? void 0 : new Date(ms).toISOString();
|
|
160
|
+
}
|
|
161
|
+
return void 0;
|
|
162
|
+
};
|
|
163
|
+
var round4 = (value) => Math.round(value * 1e4) / 1e4;
|
|
164
|
+
var ratioOrNull = (inputTokens, cachedTokens) => inputTokens > 0 ? round4(cachedTokens / inputTokens) : null;
|
|
165
|
+
var MULTILINE_QUOTED_PASSWORD_RE = /\b((?:DB_|DATABASE_|ADMIN_|ROOT_|MYSQL_|POSTGRES_)?(?:PASSWORD|PASSWD|SECRET_KEY))\s*=\s*(?:"(?:\\[\s\S]|[^"\\])*(?:"|\\?$)|'(?:\\[\s\S]|[^'\\])*(?:'|\\?$))/gi;
|
|
166
|
+
var UNCLOSED_PEM_RE = /-----BEGIN (?:[A-Z0-9 ]+)?PRIVATE KEY-----[\s\S]*$/;
|
|
167
|
+
var redactMultilineSecrets = (text) => text.replace(MULTILINE_QUOTED_PASSWORD_RE, "$1=[REDACTED:PASSWORD]").replace(UNCLOSED_PEM_RE, "[REDACTED:PRIVATE_KEY]");
|
|
168
|
+
var scrubTextForTrace = (text) => scrubSecrets(redactMultilineSecrets(sanitizeToolOutputText(text))).cleaned;
|
|
169
|
+
var summarizeForTrace = (text) => {
|
|
170
|
+
const raw = typeof text === "string" ? text : "";
|
|
171
|
+
const scrubbed = raw ? scrubTextForTrace(raw) : raw;
|
|
172
|
+
const collapsed = scrubbed.replace(/\s+/g, " ").trim();
|
|
173
|
+
if (!collapsed) return raw.trim() ? "(\u5DF2\u8131\u654F)" : "(\u65E0\u6587\u672C)";
|
|
174
|
+
if (collapsed.length <= DIALOG_TRACE_SUMMARY_MAX_CHARS) return collapsed;
|
|
175
|
+
return `${collapsed.slice(0, DIALOG_TRACE_SUMMARY_MAX_CHARS - 1)}\u2026`;
|
|
176
|
+
};
|
|
177
|
+
var textOfContent = (content) => {
|
|
178
|
+
if (typeof content === "string") return content;
|
|
179
|
+
if (!Array.isArray(content)) return "";
|
|
180
|
+
const parts = [];
|
|
181
|
+
for (const part of content) {
|
|
182
|
+
if (typeof part === "string") {
|
|
183
|
+
parts.push(part);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const record = asRecord(part);
|
|
187
|
+
if (!record) continue;
|
|
188
|
+
const text = asString(record.text) ?? asString(record.content);
|
|
189
|
+
if (text) parts.push(text);
|
|
190
|
+
}
|
|
191
|
+
return parts.join(" ");
|
|
192
|
+
};
|
|
193
|
+
var toolCallNameOf = (value) => {
|
|
194
|
+
const record = asRecord(value);
|
|
195
|
+
if (!record) return void 0;
|
|
196
|
+
const fn = asRecord(record.function);
|
|
197
|
+
return asString(record.toolName) ?? asString(record.name) ?? asString(fn?.name) ?? asString(record.tool);
|
|
198
|
+
};
|
|
199
|
+
var toolNamesOf = (message) => {
|
|
200
|
+
const names = [];
|
|
201
|
+
if (Array.isArray(message.content)) {
|
|
202
|
+
for (const part of message.content) {
|
|
203
|
+
const record = asRecord(part);
|
|
204
|
+
if (!record) continue;
|
|
205
|
+
const type = asString(record.type)?.toLowerCase();
|
|
206
|
+
if (!type || !TOOL_CALL_PART_TYPES.has(type)) continue;
|
|
207
|
+
const name = toolCallNameOf(record);
|
|
208
|
+
if (name) names.push(name);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
for (const key of ["tool_calls", "toolCalls"]) {
|
|
212
|
+
const list = message[key];
|
|
213
|
+
if (!Array.isArray(list)) continue;
|
|
214
|
+
for (const item of list) {
|
|
215
|
+
const name = toolCallNameOf(item);
|
|
216
|
+
if (name) names.push(name);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return names;
|
|
220
|
+
};
|
|
221
|
+
var roleOf = (message) => {
|
|
222
|
+
const raw = asString(message.role) ?? asString(message.authorRole) ?? asString(asRecord(message.author)?.role) ?? "";
|
|
223
|
+
return raw.toLowerCase();
|
|
224
|
+
};
|
|
225
|
+
var messageTimeOf = (message) => asTimeIso(message.createdAt) ?? asTimeIso(message.timestamp) ?? asTimeIso(message.at) ?? asTimeIso(message.time);
|
|
226
|
+
var emptyAggregate = () => ({
|
|
227
|
+
llmCalls: 0,
|
|
228
|
+
inputTokens: 0,
|
|
229
|
+
cachedTokens: 0,
|
|
230
|
+
uncachedInputTokens: 0,
|
|
231
|
+
outputTokens: 0,
|
|
232
|
+
inputUnknownRecords: 0,
|
|
233
|
+
cachedUnknownRecords: 0,
|
|
234
|
+
outputUnknownRecords: 0
|
|
235
|
+
});
|
|
236
|
+
var readUsageRecordCached = (record) => asCount(record.cache_read_input_tokens) ?? asCount(record.cached_tokens) ?? asCount(record.prompt_cache_hit_tokens) ?? asCount(asRecord(record.input_tokens_details)?.cached_tokens);
|
|
237
|
+
var usageRecordModelOf = (record) => asString(record.model) ?? asString(record.billing_model) ?? "(unknown)";
|
|
238
|
+
var aggregateUsageRecords = (records) => {
|
|
239
|
+
const aggregate = emptyAggregate();
|
|
240
|
+
for (const raw of records) {
|
|
241
|
+
const record = asRecord(raw);
|
|
242
|
+
if (!record) continue;
|
|
243
|
+
aggregate.llmCalls += 1;
|
|
244
|
+
const input = asCount(record.input_tokens) ?? asCount(record.prompt_tokens);
|
|
245
|
+
if (input === void 0) aggregate.inputUnknownRecords += 1;
|
|
246
|
+
else aggregate.inputTokens += input;
|
|
247
|
+
const cached = readUsageRecordCached(record);
|
|
248
|
+
if (cached === void 0) aggregate.cachedUnknownRecords += 1;
|
|
249
|
+
else aggregate.cachedTokens += cached;
|
|
250
|
+
if (input !== void 0 && cached !== void 0) {
|
|
251
|
+
aggregate.uncachedInputTokens += Math.max(0, input - cached);
|
|
252
|
+
}
|
|
253
|
+
const output = asCount(record.output_tokens) ?? asCount(record.completion_tokens);
|
|
254
|
+
if (output === void 0) aggregate.outputUnknownRecords += 1;
|
|
255
|
+
else aggregate.outputTokens += output;
|
|
256
|
+
}
|
|
257
|
+
return aggregate;
|
|
258
|
+
};
|
|
259
|
+
var toTraceUsage = (aggregate) => ({
|
|
260
|
+
inputTokens: aggregate.inputTokens,
|
|
261
|
+
cachedTokens: aggregate.cachedTokens,
|
|
262
|
+
uncachedInputTokens: aggregate.uncachedInputTokens,
|
|
263
|
+
outputTokens: aggregate.outputTokens,
|
|
264
|
+
cacheHitRatio: aggregate.inputUnknownRecords === 0 && aggregate.cachedUnknownRecords === 0 && aggregate.inputTokens > 0 ? round4(aggregate.cachedTokens / aggregate.inputTokens) : null
|
|
265
|
+
});
|
|
266
|
+
var pickEarliest = (values) => {
|
|
267
|
+
let best;
|
|
268
|
+
let bestMs = Number.POSITIVE_INFINITY;
|
|
269
|
+
for (const value of values) {
|
|
270
|
+
if (!value) continue;
|
|
271
|
+
const ms = Date.parse(value);
|
|
272
|
+
if (Number.isNaN(ms) || ms >= bestMs) continue;
|
|
273
|
+
best = value;
|
|
274
|
+
bestMs = ms;
|
|
275
|
+
}
|
|
276
|
+
return best;
|
|
277
|
+
};
|
|
278
|
+
var pickLatest = (values) => {
|
|
279
|
+
let best;
|
|
280
|
+
let bestMs = Number.NEGATIVE_INFINITY;
|
|
281
|
+
for (const value of values) {
|
|
282
|
+
if (!value) continue;
|
|
283
|
+
const ms = Date.parse(value);
|
|
284
|
+
if (Number.isNaN(ms) || ms <= bestMs) continue;
|
|
285
|
+
best = value;
|
|
286
|
+
bestMs = ms;
|
|
287
|
+
}
|
|
288
|
+
return best;
|
|
289
|
+
};
|
|
290
|
+
var durationBetween = (startedAt, endedAt) => {
|
|
291
|
+
if (!startedAt || !endedAt) return void 0;
|
|
292
|
+
const start = Date.parse(startedAt);
|
|
293
|
+
const end = Date.parse(endedAt);
|
|
294
|
+
if (Number.isNaN(start) || Number.isNaN(end)) return void 0;
|
|
295
|
+
return Math.max(0, end - start);
|
|
296
|
+
};
|
|
297
|
+
var resolveRunTier = (run) => {
|
|
298
|
+
const declared = run.modelTier ?? run.selectionCheck?.modelTier;
|
|
299
|
+
if (declared && declared !== "unknown") return declared;
|
|
300
|
+
const derived = resolveModelTier(run.model);
|
|
301
|
+
if (derived !== "unknown") return derived;
|
|
302
|
+
return declared ?? "unknown";
|
|
303
|
+
};
|
|
304
|
+
var FAILED_RUN_STATUSES = /* @__PURE__ */ new Set(["failed", "killed", "stalled", "error"]);
|
|
305
|
+
var selectSubagentRuns = (runs, dialogKey, dialogId) => {
|
|
306
|
+
const targetKey = dialogKey.trim();
|
|
307
|
+
const targetId = dialogId.trim();
|
|
308
|
+
const targetUserId = parseDialogKey(targetKey)?.userId?.trim() || void 0;
|
|
309
|
+
const conflictsTargetOwner = (run) => {
|
|
310
|
+
if (!targetUserId) return false;
|
|
311
|
+
const scopeUserId = asString(run.evidenceScope?.userId);
|
|
312
|
+
return Boolean(scopeUserId && scopeUserId !== targetUserId);
|
|
313
|
+
};
|
|
314
|
+
const belongsToTargetUser = (run) => {
|
|
315
|
+
if (!targetUserId) return false;
|
|
316
|
+
return asString(run.evidenceScope?.userId) === targetUserId;
|
|
317
|
+
};
|
|
318
|
+
const included = /* @__PURE__ */ new Map();
|
|
319
|
+
let direct = 0;
|
|
320
|
+
let unattributedBareParentRuns = 0;
|
|
321
|
+
let conflictingAttributionRuns = 0;
|
|
322
|
+
for (const run of runs) {
|
|
323
|
+
if (!run?.runId) continue;
|
|
324
|
+
if (conflictsTargetOwner(run)) {
|
|
325
|
+
conflictingAttributionRuns += 1;
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
const parent = asString(run.parentDialogId);
|
|
329
|
+
if (!parent) continue;
|
|
330
|
+
if (parent === targetKey) {
|
|
331
|
+
included.set(run.runId, run);
|
|
332
|
+
direct += 1;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (parent !== targetId) continue;
|
|
336
|
+
if (belongsToTargetUser(run)) {
|
|
337
|
+
included.set(run.runId, run);
|
|
338
|
+
direct += 1;
|
|
339
|
+
} else {
|
|
340
|
+
unattributedBareParentRuns += 1;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
let changed = true;
|
|
344
|
+
while (changed) {
|
|
345
|
+
changed = false;
|
|
346
|
+
const batchIds = new Set(
|
|
347
|
+
[...included.values()].map((run) => run.batchId).filter((value) => Boolean(value))
|
|
348
|
+
);
|
|
349
|
+
for (const run of runs) {
|
|
350
|
+
if (!run?.runId || included.has(run.runId)) continue;
|
|
351
|
+
if (conflictsTargetOwner(run)) continue;
|
|
352
|
+
const parent = asString(run.parentDialogId);
|
|
353
|
+
if (parent && parent !== targetKey) continue;
|
|
354
|
+
const continuedFromIncluded = run.continuedFrom ? included.has(run.continuedFrom) : false;
|
|
355
|
+
const sameBatch = Boolean(run.batchId) && batchIds.has(run.batchId);
|
|
356
|
+
if (!continuedFromIncluded && !sameBatch) continue;
|
|
357
|
+
included.set(run.runId, run);
|
|
358
|
+
changed = true;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const selected = [...included.values()].sort((a, b) => {
|
|
362
|
+
const aMs = a.startedAt ? Date.parse(a.startedAt) : Number.POSITIVE_INFINITY;
|
|
363
|
+
const bMs = b.startedAt ? Date.parse(b.startedAt) : Number.POSITIVE_INFINITY;
|
|
364
|
+
return (Number.isNaN(aMs) ? Number.POSITIVE_INFINITY : aMs) - (Number.isNaN(bMs) ? Number.POSITIVE_INFINITY : bMs);
|
|
365
|
+
});
|
|
366
|
+
return {
|
|
367
|
+
runs: selected,
|
|
368
|
+
chainedWithoutDirectParent: Math.max(0, selected.length - direct),
|
|
369
|
+
unattributedBareParentRuns,
|
|
370
|
+
conflictingAttributionRuns
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
var toSubagent = (run) => {
|
|
374
|
+
const inputTokens = asCount(run.inputTokens);
|
|
375
|
+
const outputTokens = asCount(run.outputTokens);
|
|
376
|
+
const cachedTokens = asCount(run.cacheCachedTokens ?? void 0);
|
|
377
|
+
const rawTitle = asString(run.title);
|
|
378
|
+
const title = rawTitle ? scrubTextForTrace(rawTitle).trim() : "";
|
|
379
|
+
const llmCalls = asCount(run.activity?.counters?.llmCalls);
|
|
380
|
+
const toolCalls = asCount(run.activity?.counters?.toolCalls) ?? asCount(run.toolCallCount);
|
|
381
|
+
const fileEdits = asCount(run.activity?.counters?.fileEdits);
|
|
382
|
+
const startedAt = asTimeIso(run.startedAt);
|
|
383
|
+
const endedAt = asTimeIso(run.endedAt);
|
|
384
|
+
const derivedRatio = inputTokens !== void 0 && cachedTokens !== void 0 ? ratioOrNull(inputTokens, cachedTokens) : null;
|
|
385
|
+
return {
|
|
386
|
+
runId: run.runId,
|
|
387
|
+
...title ? { title } : {},
|
|
388
|
+
...asString(run.agentKey) ? { agentKey: run.agentKey.trim() } : {},
|
|
389
|
+
...asString(run.agentName) ? { agentName: run.agentName.trim() } : {},
|
|
390
|
+
...asString(run.model) ? { model: run.model.trim() } : {},
|
|
391
|
+
modelTier: resolveRunTier(run),
|
|
392
|
+
...asString(run.credentialGroup) ? { credentialGroup: run.credentialGroup.trim() } : {},
|
|
393
|
+
...asString(run.selectionCheck?.difficulty) ? { difficulty: run.selectionCheck.difficulty.trim() } : {},
|
|
394
|
+
...asString(run.batchId) ? { batchId: run.batchId.trim() } : {},
|
|
395
|
+
...asString(run.continuedFrom) ? { continuedFrom: run.continuedFrom.trim() } : {},
|
|
396
|
+
...asString(run.dialogId) ? { childDialogId: run.dialogId.trim() } : {},
|
|
397
|
+
status: asString(run.status) ?? "unknown",
|
|
398
|
+
...startedAt ? { startedAt } : {},
|
|
399
|
+
...endedAt ? { endedAt } : {},
|
|
400
|
+
...durationBetween(startedAt, endedAt) !== void 0 ? { durationMs: durationBetween(startedAt, endedAt) } : {},
|
|
401
|
+
...llmCalls !== void 0 ? { llmCalls } : {},
|
|
402
|
+
...toolCalls !== void 0 ? { toolCalls } : {},
|
|
403
|
+
...fileEdits !== void 0 ? { fileEdits } : {},
|
|
404
|
+
...inputTokens !== void 0 ? { inputTokens } : {},
|
|
405
|
+
...cachedTokens !== void 0 ? { cachedTokens } : {},
|
|
406
|
+
...inputTokens !== void 0 && cachedTokens !== void 0 ? { uncachedInputTokens: Math.max(0, inputTokens - cachedTokens) } : {},
|
|
407
|
+
...outputTokens !== void 0 ? { outputTokens } : {},
|
|
408
|
+
...typeof run.cacheHitRatio === "number" || run.cacheHitRatio === null ? { cacheHitRatio: run.cacheHitRatio } : cachedTokens !== void 0 ? { cacheHitRatio: derivedRatio } : {},
|
|
409
|
+
...run.escalated === true ? { escalated: true } : {},
|
|
410
|
+
...asString(run.reviewVerdict) ? { reviewVerdict: run.reviewVerdict.trim() } : {},
|
|
411
|
+
...asString(run.failureClass) ? { failureClass: run.failureClass.trim() } : {},
|
|
412
|
+
...typeof run.credits === "number" && Number.isFinite(run.credits) ? { credits: run.credits } : {}
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
var resolveDialogIdFromKey = (dialogKey) => parseDialogKey(dialogKey)?.dialogId ?? (dialogKey.startsWith("dialog-") ? extractCustomId(dialogKey) : dialogKey);
|
|
416
|
+
function buildDialogTraceReport(input) {
|
|
417
|
+
const dialogKey = input.dialogKey?.trim() ?? "";
|
|
418
|
+
const dialogId = (input.dialogId?.trim() || resolveDialogIdFromKey(dialogKey)).trim();
|
|
419
|
+
const messages = input.messages ?? [];
|
|
420
|
+
const usageRecords = input.usageRecords ?? [];
|
|
421
|
+
const dataNotes = [...input.notes ?? []];
|
|
422
|
+
let userMessages = 0;
|
|
423
|
+
let assistantMessages = 0;
|
|
424
|
+
const toolMessageCounts = {};
|
|
425
|
+
const assistantPartCounts = {};
|
|
426
|
+
const messageTimes = [];
|
|
427
|
+
const timeline = [];
|
|
428
|
+
for (const raw of messages) {
|
|
429
|
+
const message = asRecord(raw);
|
|
430
|
+
if (!message) continue;
|
|
431
|
+
const role = roleOf(message);
|
|
432
|
+
const at = messageTimeOf(message);
|
|
433
|
+
messageTimes.push(at);
|
|
434
|
+
const callNames = toolNamesOf(message);
|
|
435
|
+
for (const name of callNames) {
|
|
436
|
+
assistantPartCounts[name] = (assistantPartCounts[name] ?? 0) + 1;
|
|
437
|
+
}
|
|
438
|
+
if (role === "tool") {
|
|
439
|
+
const toolName = asString(message.toolName) ?? asString(message.name);
|
|
440
|
+
if (toolName) {
|
|
441
|
+
toolMessageCounts[toolName] = (toolMessageCounts[toolName] ?? 0) + 1;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (role === "user") {
|
|
445
|
+
userMessages += 1;
|
|
446
|
+
timeline.push({
|
|
447
|
+
...at ? { at } : {},
|
|
448
|
+
kind: "user",
|
|
449
|
+
summary: summarizeForTrace(textOfContent(message.content) || message.text)
|
|
450
|
+
});
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
if (role === "assistant") {
|
|
454
|
+
assistantMessages += 1;
|
|
455
|
+
timeline.push({
|
|
456
|
+
...at ? { at } : {},
|
|
457
|
+
kind: "assistant",
|
|
458
|
+
summary: summarizeForTrace(
|
|
459
|
+
textOfContent(message.content) || message.text
|
|
460
|
+
),
|
|
461
|
+
...callNames.length > 0 ? { toolNames: [...new Set(callNames)] } : {}
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
const useToolMessages = Object.keys(toolMessageCounts).length > 0;
|
|
466
|
+
const toolCallsByName = useToolMessages ? toolMessageCounts : assistantPartCounts;
|
|
467
|
+
let toolCallsTotal = 0;
|
|
468
|
+
for (const count of Object.values(toolCallsByName)) toolCallsTotal += count;
|
|
469
|
+
const usedAssistantPartFallback = !useToolMessages && Object.keys(assistantPartCounts).length > 0;
|
|
470
|
+
const rootAggregate = aggregateUsageRecords(usageRecords);
|
|
471
|
+
const usageByModel = /* @__PURE__ */ new Map();
|
|
472
|
+
const usageRecordTimes = [];
|
|
473
|
+
for (const raw of usageRecords) {
|
|
474
|
+
const record = asRecord(raw);
|
|
475
|
+
if (!record) continue;
|
|
476
|
+
usageRecordTimes.push(
|
|
477
|
+
asTimeIso(record.createdAt) ?? asTimeIso(record.timestamp)
|
|
478
|
+
);
|
|
479
|
+
const model = usageRecordModelOf(record);
|
|
480
|
+
const bucket = usageByModel.get(model) ?? emptyAggregate();
|
|
481
|
+
const single = aggregateUsageRecords([record]);
|
|
482
|
+
bucket.llmCalls += single.llmCalls;
|
|
483
|
+
bucket.inputTokens += single.inputTokens;
|
|
484
|
+
bucket.cachedTokens += single.cachedTokens;
|
|
485
|
+
bucket.uncachedInputTokens += single.uncachedInputTokens;
|
|
486
|
+
bucket.outputTokens += single.outputTokens;
|
|
487
|
+
bucket.inputUnknownRecords += single.inputUnknownRecords;
|
|
488
|
+
bucket.cachedUnknownRecords += single.cachedUnknownRecords;
|
|
489
|
+
bucket.outputUnknownRecords += single.outputUnknownRecords;
|
|
490
|
+
usageByModel.set(model, bucket);
|
|
491
|
+
}
|
|
492
|
+
const byModel = [...usageByModel.entries()].map(([model, aggregate]) => ({
|
|
493
|
+
model,
|
|
494
|
+
modelTier: resolveModelTier(model),
|
|
495
|
+
llmCalls: aggregate.llmCalls,
|
|
496
|
+
...toTraceUsage(aggregate)
|
|
497
|
+
})).sort((a, b) => b.inputTokens - a.inputTokens || b.llmCalls - a.llmCalls);
|
|
498
|
+
const selection = selectSubagentRuns(input.runs ?? [], dialogKey, dialogId);
|
|
499
|
+
const subagents = selection.runs.map(toSubagent);
|
|
500
|
+
const runStarts = selection.runs.map((run) => asTimeIso(run.startedAt));
|
|
501
|
+
const runEnds = selection.runs.map((run) => asTimeIso(run.endedAt));
|
|
502
|
+
const startedAt = pickEarliest([
|
|
503
|
+
...messageTimes,
|
|
504
|
+
...usageRecordTimes,
|
|
505
|
+
...runStarts
|
|
506
|
+
]);
|
|
507
|
+
const endedAt = pickLatest([
|
|
508
|
+
...messageTimes,
|
|
509
|
+
...usageRecordTimes,
|
|
510
|
+
...runEnds,
|
|
511
|
+
...runStarts
|
|
512
|
+
]);
|
|
513
|
+
const durationMs = durationBetween(startedAt, endedAt);
|
|
514
|
+
const messageTimestampsMissing = messages.length > 0 && messageTimes.every((value) => !value);
|
|
515
|
+
for (const subagent of subagents) {
|
|
516
|
+
const tokens = subagent.inputTokens !== void 0 || subagent.cachedTokens !== void 0 || subagent.outputTokens !== void 0 ? {
|
|
517
|
+
...subagent.inputTokens !== void 0 ? { input: subagent.inputTokens } : {},
|
|
518
|
+
...subagent.cachedTokens !== void 0 ? { cached: subagent.cachedTokens } : {},
|
|
519
|
+
...subagent.outputTokens !== void 0 ? { output: subagent.outputTokens } : {}
|
|
520
|
+
} : void 0;
|
|
521
|
+
timeline.push({
|
|
522
|
+
...subagent.startedAt ? { at: subagent.startedAt } : {},
|
|
523
|
+
kind: "subagent_start",
|
|
524
|
+
summary: summarizeForTrace(
|
|
525
|
+
`\u6D3E\u53D1 ${subagent.agentName ?? subagent.agentKey ?? subagent.runId}${subagent.model ? ` \xB7 ${subagent.model}` : ""}${subagent.title ? ` \u2014 ${subagent.title}` : ""}`
|
|
526
|
+
),
|
|
527
|
+
runId: subagent.runId,
|
|
528
|
+
...subagent.model ? { model: subagent.model } : {},
|
|
529
|
+
...tokens ? { tokens } : {}
|
|
530
|
+
});
|
|
531
|
+
timeline.push({
|
|
532
|
+
...subagent.endedAt ? { at: subagent.endedAt } : {},
|
|
533
|
+
kind: "subagent_end",
|
|
534
|
+
summary: summarizeForTrace(
|
|
535
|
+
`${subagent.runId} ${subagent.status}${subagent.reviewVerdict ? ` \xB7 ${subagent.reviewVerdict}` : ""}${subagent.failureClass ? ` \xB7 ${subagent.failureClass}` : ""}`
|
|
536
|
+
),
|
|
537
|
+
runId: subagent.runId,
|
|
538
|
+
...subagent.model ? { model: subagent.model } : {}
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
const timeValue = (at) => at ? Date.parse(at) : Number.POSITIVE_INFINITY;
|
|
542
|
+
timeline.sort((a, b) => {
|
|
543
|
+
const aMs = timeValue(a.at);
|
|
544
|
+
const bMs = timeValue(b.at);
|
|
545
|
+
const aSafe = Number.isNaN(aMs) ? Number.POSITIVE_INFINITY : aMs;
|
|
546
|
+
const bSafe = Number.isNaN(bMs) ? Number.POSITIVE_INFINITY : bMs;
|
|
547
|
+
return aSafe - bSafe;
|
|
548
|
+
});
|
|
549
|
+
let combinedInputTokens = rootAggregate.inputTokens;
|
|
550
|
+
let combinedCachedTokens = rootAggregate.cachedTokens;
|
|
551
|
+
let combinedUncachedInputTokens = rootAggregate.uncachedInputTokens;
|
|
552
|
+
let combinedOutputTokens = rootAggregate.outputTokens;
|
|
553
|
+
let runInputMissing = 0;
|
|
554
|
+
let runOutputMissing = 0;
|
|
555
|
+
let runCachedMissing = 0;
|
|
556
|
+
let runLlmCallsMissing = 0;
|
|
557
|
+
let runCachedWithoutInput = 0;
|
|
558
|
+
let unknownTierRuns = 0;
|
|
559
|
+
const byTier = {};
|
|
560
|
+
const byCredentialGroup = {};
|
|
561
|
+
let subagentLlmCalls = 0;
|
|
562
|
+
let failedOrEscalatedRuns = 0;
|
|
563
|
+
for (const subagent of subagents) {
|
|
564
|
+
if (subagent.inputTokens === void 0) runInputMissing += 1;
|
|
565
|
+
else combinedInputTokens += subagent.inputTokens;
|
|
566
|
+
if (subagent.cachedTokens === void 0) {
|
|
567
|
+
runCachedMissing += 1;
|
|
568
|
+
} else if (subagent.inputTokens === void 0) {
|
|
569
|
+
runCachedWithoutInput += 1;
|
|
570
|
+
} else {
|
|
571
|
+
combinedCachedTokens += subagent.cachedTokens;
|
|
572
|
+
}
|
|
573
|
+
if (subagent.outputTokens === void 0) runOutputMissing += 1;
|
|
574
|
+
else combinedOutputTokens += subagent.outputTokens;
|
|
575
|
+
if (subagent.inputTokens !== void 0 && subagent.cachedTokens !== void 0) {
|
|
576
|
+
combinedUncachedInputTokens += Math.max(
|
|
577
|
+
0,
|
|
578
|
+
subagent.inputTokens - subagent.cachedTokens
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
if (subagent.modelTier === "unknown") unknownTierRuns += 1;
|
|
582
|
+
if (typeof subagent.llmCalls === "number") subagentLlmCalls += subagent.llmCalls;
|
|
583
|
+
else runLlmCallsMissing += 1;
|
|
584
|
+
if (subagent.escalated === true || subagent.failureClass !== void 0 || FAILED_RUN_STATUSES.has(subagent.status)) {
|
|
585
|
+
failedOrEscalatedRuns += 1;
|
|
586
|
+
}
|
|
587
|
+
const tierKey = subagent.modelTier;
|
|
588
|
+
const tier = byTier[tierKey] ?? {
|
|
589
|
+
runs: 0,
|
|
590
|
+
llmCalls: 0,
|
|
591
|
+
inputTokens: 0,
|
|
592
|
+
cachedTokens: 0,
|
|
593
|
+
uncachedInputTokens: 0,
|
|
594
|
+
outputTokens: 0
|
|
595
|
+
};
|
|
596
|
+
tier.runs += 1;
|
|
597
|
+
tier.llmCalls += subagent.llmCalls ?? 0;
|
|
598
|
+
tier.inputTokens += subagent.inputTokens ?? 0;
|
|
599
|
+
tier.cachedTokens += subagent.cachedTokens ?? 0;
|
|
600
|
+
tier.uncachedInputTokens += subagent.uncachedInputTokens ?? 0;
|
|
601
|
+
tier.outputTokens += subagent.outputTokens ?? 0;
|
|
602
|
+
byTier[tierKey] = tier;
|
|
603
|
+
const groupKey = subagent.credentialGroup ?? "(unknown)";
|
|
604
|
+
const group = byCredentialGroup[groupKey] ?? {
|
|
605
|
+
runs: 0,
|
|
606
|
+
inputTokens: 0,
|
|
607
|
+
outputTokens: 0
|
|
608
|
+
};
|
|
609
|
+
group.runs += 1;
|
|
610
|
+
group.inputTokens += subagent.inputTokens ?? 0;
|
|
611
|
+
group.outputTokens += subagent.outputTokens ?? 0;
|
|
612
|
+
byCredentialGroup[groupKey] = group;
|
|
613
|
+
}
|
|
614
|
+
const rootInputMissingCount = rootAggregate.inputUnknownRecords;
|
|
615
|
+
const rootOutputMissingCount = rootAggregate.outputUnknownRecords;
|
|
616
|
+
const rootCachedMissingCount = rootAggregate.cachedUnknownRecords;
|
|
617
|
+
const combinedCachedKnown = rootInputMissingCount === 0 && rootCachedMissingCount === 0 && runCachedMissing === 0 && runCachedWithoutInput === 0 && runInputMissing === 0 && combinedInputTokens > 0;
|
|
618
|
+
const totalLlmCalls = rootAggregate.llmCalls + subagentLlmCalls;
|
|
619
|
+
const rootUsageKnown = rootAggregate.llmCalls > 0;
|
|
620
|
+
const rootInputComplete = rootUsageKnown && rootInputMissingCount === 0 && runInputMissing === 0 && combinedInputTokens > 0;
|
|
621
|
+
const rootOutputComplete = rootUsageKnown && rootOutputMissingCount === 0 && runOutputMissing === 0 && combinedOutputTokens > 0;
|
|
622
|
+
const rootLlmCallsComplete = rootUsageKnown && runLlmCallsMissing === 0;
|
|
623
|
+
const uncachedCoverageIncomplete = rootCachedMissingCount > 0 || runCachedMissing > 0 || runCachedWithoutInput > 0 || runInputMissing > 0;
|
|
624
|
+
const totals = {
|
|
625
|
+
combinedInputTokens,
|
|
626
|
+
combinedCachedTokens,
|
|
627
|
+
combinedUncachedInputTokens,
|
|
628
|
+
combinedOutputTokens,
|
|
629
|
+
combinedCacheHitRatio: combinedCachedKnown ? ratioOrNull(combinedInputTokens, combinedCachedTokens) : null,
|
|
630
|
+
totalSubagentRuns: subagents.length,
|
|
631
|
+
failedOrEscalatedRuns,
|
|
632
|
+
byTier,
|
|
633
|
+
byCredentialGroup,
|
|
634
|
+
rootShare: {
|
|
635
|
+
inputRatio: rootInputComplete ? round4(rootAggregate.inputTokens / combinedInputTokens) : null,
|
|
636
|
+
outputRatio: rootOutputComplete ? round4(rootAggregate.outputTokens / combinedOutputTokens) : null,
|
|
637
|
+
llmCallRatio: rootLlmCallsComplete && totalLlmCalls > 0 ? round4(rootAggregate.llmCalls / totalLlmCalls) : null
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
if (messages.length === 0) {
|
|
641
|
+
dataNotes.push(
|
|
642
|
+
"\u672A\u8BFB\u53D6\u5230 dialog \u6D88\u606F\uFF1Aroot \u7684\u6D88\u606F\u4E0E\u5DE5\u5177\u8C03\u7528\u7EDF\u8BA1\u4E3A 0 \u8868\u793A\u300C\u65E0\u6570\u636E\u300D\uFF0C\u4E0D\u662F\u300C\u5B9E\u6D4B 0 \u6B21\u8C03\u7528\u300D"
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
if (messageTimestampsMissing) {
|
|
646
|
+
dataNotes.push(
|
|
647
|
+
"\u6D88\u606F\u8BB0\u5F55\u7F3A\u5C11\u65F6\u95F4\u6233\uFF1AstartedAt/endedAt \u7531 token \u8BB0\u5F55\u4E0E\u5B50 run \u65F6\u95F4\u63A8\u7B97"
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
if (usageRecords.length === 0) {
|
|
651
|
+
dataNotes.push(
|
|
652
|
+
"\u672A\u627E\u5230\u8BE5\u5BF9\u8BDD\u7684\u9010\u6B21 token \u8BB0\u5F55\uFF08\u8FDC\u7AEF\u4E0E\u672C\u5730\u5747\u65E0\uFF09\uFF1Aroot.usage \u5168 0 \u8868\u793A\u300C\u65E0\u8BB0\u5F55\u300D"
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
if (rootInputMissingCount > 0) {
|
|
656
|
+
dataNotes.push(
|
|
657
|
+
`${rootInputMissingCount} \u6761 token \u8BB0\u5F55\u7F3A\u5C11 input_tokens\uFF1Aroot.usage.inputTokens \u53EA\u7D2F\u52A0\u5DF2\u77E5\u90E8\u5206\uFF08\u90E8\u5206\u8986\u76D6\uFF09\uFF0CrootShare.inputRatio \u4E0E combinedCacheHitRatio \u5747\u7F6E null`
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
if (rootCachedMissingCount > 0) {
|
|
661
|
+
dataNotes.push(
|
|
662
|
+
`${rootCachedMissingCount} \u6761 token \u8BB0\u5F55\u7F3A\u5C11 cache_read_input_tokens\uFF1AcachedTokens \u53EA\u7D2F\u52A0\u5DF2\u77E5\u90E8\u5206\uFF08\u90E8\u5206\u8986\u76D6\uFF09\uFF0CcacheHitRatio \u4E0E combinedCacheHitRatio \u5747\u7F6E null`
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
if (rootOutputMissingCount > 0) {
|
|
666
|
+
dataNotes.push(
|
|
667
|
+
`${rootOutputMissingCount} \u6761 token \u8BB0\u5F55\u7F3A\u5C11 output_tokens\uFF1Aroot.usage.outputTokens \u53EA\u7D2F\u52A0\u5DF2\u77E5\u90E8\u5206\uFF08\u90E8\u5206\u8986\u76D6\uFF09\uFF0CrootShare.outputRatio \u7F6E null`
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
if (usageRecords.length > 0) {
|
|
671
|
+
dataNotes.push(
|
|
672
|
+
"token \u8BB0\u5F55\u4E0D\u542B messageId\uFF1Atimeline \u7684 user/assistant \u6761\u76EE\u4E0D\u5E26 per-message tokens\uFF08\u9010\u4E2A\u8C03\u7528\u7684\u7528\u91CF\u53EA\u5728 root.usage / byModel \u91CC\uFF09"
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
if (runInputMissing > 0) {
|
|
676
|
+
dataNotes.push(
|
|
677
|
+
`${runInputMissing} \u6761\u5B50 run \u7F3A\u5C11 inputTokens\uFF08\u65E7\u8BB0\u5F55\u672A\u5199\u8BE5\u5B57\u6BB5\uFF09\uFF1Acombined / byTier / byCredentialGroup \u7684 input \u53EA\u542B\u5DF2\u77E5\u90E8\u5206`
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
if (runOutputMissing > 0) {
|
|
681
|
+
dataNotes.push(
|
|
682
|
+
`${runOutputMissing} \u6761\u5B50 run \u7F3A\u5C11 outputTokens\uFF08\u65E7\u8BB0\u5F55\u672A\u5199\u8BE5\u5B57\u6BB5\uFF09\uFF1Acombined / byTier / byCredentialGroup \u7684 output \u53EA\u542B\u5DF2\u77E5\u90E8\u5206`
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
if (runCachedWithoutInput > 0) {
|
|
686
|
+
dataNotes.push(
|
|
687
|
+
`${runCachedWithoutInput} \u6761\u5B50 run \u6709 cachedTokens \u4F46\u7F3A inputTokens\uFF1A\u8FD9\u4E9B cached \u672A\u8BA1\u5165 combinedCachedTokens\uFF08\u5426\u5219 cached \u4F1A\u5927\u4E8E input\uFF0C\u53E3\u5F84\u4E0D\u4E00\u81F4\uFF09`
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
if (runCachedMissing > 0) {
|
|
691
|
+
dataNotes.push(
|
|
692
|
+
`${runCachedMissing} \u6761\u5B50 run \u7F3A\u5C11 cachedTokens\uFF1AcombinedCachedTokens \u53EA\u542B\u5DF2\u77E5\u90E8\u5206\uFF0CcombinedCacheHitRatio \u7F6E null`
|
|
693
|
+
);
|
|
694
|
+
}
|
|
695
|
+
if (unknownTierRuns > 0) {
|
|
696
|
+
dataNotes.push(
|
|
697
|
+
`${unknownTierRuns} \u6761\u5B50 run \u7684\u6A21\u578B\u6863\u4F4D\u65E0\u6CD5\u5224\u5B9A\uFF08modelTier=unknown\uFF09\uFF1A\u672A\u4ECE\u6A21\u578B\u540D\u6216 selectionCheck \u63A8\u65AD\u51FA\u6863\u4F4D`
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
if (usedAssistantPartFallback) {
|
|
701
|
+
dataNotes.push(
|
|
702
|
+
"\u8BE5\u5BF9\u8BDD\u6CA1\u6709 tool \u7ED3\u679C\u6D88\u606F\uFF1A\u5DE5\u5177\u8C03\u7528\u6570\u53D6\u81EA assistant \u7684 tool-call \u90E8\u4EF6\uFF08\u4E00\u6B21\u8C03\u7528\u53EF\u80FD\u5BF9\u5E94\u591A\u6761\u90E8\u4EF6\uFF0C\u5C5E\u8FD1\u4F3C\u8BA1\u6570\uFF09"
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
if (selection.chainedWithoutDirectParent > 0) {
|
|
706
|
+
dataNotes.push(
|
|
707
|
+
`${selection.chainedWithoutDirectParent} \u6761\u5B50 run \u7ECF batchId / continuedFrom \u4E32\u8054\u6536\u5165\uFF08\u5176 parentDialogId \u672A\u547D\u4E2D\u8BE5\u5BF9\u8BDD\uFF09`
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
if (selection.unattributedBareParentRuns > 0) {
|
|
711
|
+
dataNotes.push(
|
|
712
|
+
`${selection.unattributedBareParentRuns} \u6761 run \u7684 parentDialogId \u53EA\u662F\u88F8 dialog id \u4E14\u65E0\u540C userId \u8BC1\u636E\uFF08evidenceScope.userId \u7F3A\u5931\u6216\u6307\u5411\u4ED6\u4EBA\uFF09\uFF1A\u8DF3\u8FC7\u4E86\u65E0\u6CD5\u9A8C\u8BC1\u5F52\u5C5E\u7684\u88F8 ID run\uFF0C\u4E0D\u7EB3\u5165\u5B50 run \u5217\u8868\uFF08\u6267\u884C\u8005 agentKey \u4E0E callerAgentKey \u524D\u7F00\u90FD\u4E0D\u662F\u7236\u5BF9\u8BDD owner \u7684\u8BC1\u636E\uFF0C\u4E0D\u53C2\u4E0E\u5224\u65AD\uFF09`
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
if (selection.conflictingAttributionRuns > 0) {
|
|
716
|
+
dataNotes.push(
|
|
717
|
+
`${selection.conflictingAttributionRuns} \u6761 run \u7684\u53EF\u4FE1\u5F52\u5C5E\u8BC1\u636E\u6307\u5411\u53E6\u4E00\u4E2A\u7528\u6237\uFF08evidenceScope.userId \u4E0E\u76EE\u6807\u5BF9\u8BDD owner \u7CBE\u786E\u4E0D\u7B49\uFF09\uFF1A\u5148\u4E8E parentDialogId \u5339\u914D\u4E0E batchId \u4E32\u8054\u88AB\u6392\u9664`
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
if (uncachedCoverageIncomplete) {
|
|
721
|
+
dataNotes.push(
|
|
722
|
+
"\u5B58\u5728\u7F3A\u5C11 cachedTokens \u7684\u8BB0\u5F55\uFF08\u7F13\u5B58\u8986\u76D6\u4E0D\u5168\uFF09\uFF1AcombinedUncachedInputTokens \u53EA\u7D2F\u52A0 input \u4E0E cached \u540C\u65F6\u5DF2\u77E5\u7684\u8BB0\u5F55\uFF08\u5DF2\u77E5\u7F13\u5B58\u5B50\u96C6\u7684\u5408\u8BA1\uFF09\uFF0C\u4E0D\u628A\u672A\u77E5\u7F13\u5B58\u5F53\u6210 100% \u672A\u547D\u4E2D\uFF0C\u56E0\u6B64\u5B83\u4F4E\u4E8E\u771F\u5B9E\u672A\u547D\u4E2D\u91CF\uFF1B\u53E3\u5F84\u4E0E byTier \u5B8C\u5168\u4E00\u81F4\uFF0CcombinedCacheHitRatio \u540C\u6B65\u4E3A null"
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
if (!combinedCachedKnown && usageRecords.length > 0) {
|
|
726
|
+
dataNotes.push(
|
|
727
|
+
`combinedCacheHitRatio \u7F6E null\uFF1A\u6839\u7AEF\u7F3A input ${rootInputMissingCount} \u6761 / \u7F3A cached ${rootCachedMissingCount} \u6761\uFF0C\u5B50 run \u7F3A input ${runInputMissing} \u6761 / \u7F3A cached ${runCachedMissing} \u6761\uFF08\u90E8\u5206\u8986\u76D6\uFF0C\u4E0D\u6309\u5DF2\u77E5\u90E8\u5206\u4F2A\u9020\u5B8C\u6574\u6BD4\u7387\uFF09`
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
if (!rootInputComplete) {
|
|
731
|
+
dataNotes.push(
|
|
732
|
+
"\u4E3B\u5BF9\u8BDD usage \u4E0D\u5168\uFF08\u542B\u6839\u7AEF\u8BB0\u5F55\u7F3A input_tokens\uFF09\u6216\u5B58\u5728\u5B50 run \u7F3A\u5C11 inputTokens\uFF1ArootShare.inputRatio \u8FD4\u56DE null\uFF08\u5206\u5B50/\u5206\u6BCD\u4E0D\u5B8C\u6574\uFF0C\u4E0D\u62A5\u544A\u5360\u6BD4\uFF09"
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
if (!rootOutputComplete) {
|
|
736
|
+
dataNotes.push(
|
|
737
|
+
"\u5B58\u5728\u5B50 run \u7F3A\u5C11 outputTokens\uFF1ArootShare.outputRatio \u8FD4\u56DE null\uFF08\u5206\u5B50/\u5206\u6BCD\u4E0D\u5B8C\u6574\uFF0C\u4E0D\u62A5\u544A\u5360\u6BD4\uFF09"
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
if (!rootLlmCallsComplete) {
|
|
741
|
+
dataNotes.push(
|
|
742
|
+
"\u5B58\u5728\u5B50 run \u7F3A\u5C11 llmCalls\uFF1ArootShare.llmCallRatio \u8FD4\u56DE null\uFF08\u5206\u5B50/\u5206\u6BCD\u4E0D\u5B8C\u6574\uFF0C\u4E0D\u62A5\u544A\u5360\u6BD4\uFF09"
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
return {
|
|
746
|
+
schemaVersion: DIALOG_TRACE_SCHEMA_VERSION,
|
|
747
|
+
dialogKey,
|
|
748
|
+
dialogId,
|
|
749
|
+
...startedAt ? { startedAt } : {},
|
|
750
|
+
...endedAt ? { endedAt } : {},
|
|
751
|
+
...durationMs !== void 0 ? { durationMs } : {},
|
|
752
|
+
root: {
|
|
753
|
+
userMessages,
|
|
754
|
+
assistantMessages,
|
|
755
|
+
toolCallsTotal,
|
|
756
|
+
toolCallsByName,
|
|
757
|
+
llmCalls: rootAggregate.llmCalls,
|
|
758
|
+
usage: toTraceUsage(rootAggregate),
|
|
759
|
+
byModel
|
|
760
|
+
},
|
|
761
|
+
subagents,
|
|
762
|
+
totals,
|
|
763
|
+
timeline,
|
|
764
|
+
dataNotes
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
var formatRatio = (value) => typeof value === "number" ? `${(value * 100).toFixed(1)}%` : "\u672A\u77E5";
|
|
768
|
+
function formatDialogTraceReport(report) {
|
|
769
|
+
const lines = [];
|
|
770
|
+
lines.push(`Dialog: ${report.dialogKey}`);
|
|
771
|
+
lines.push(
|
|
772
|
+
`\u65F6\u95F4: ${report.startedAt ?? "\u672A\u77E5"} \u2192 ${report.endedAt ?? "\u672A\u77E5"}${report.durationMs !== void 0 ? `\uFF08${report.durationMs} ms\uFF09` : ""}`
|
|
773
|
+
);
|
|
774
|
+
lines.push(
|
|
775
|
+
`\u4E3B\u5BF9\u8BDD: user=${report.root.userMessages}, assistant=${report.root.assistantMessages}, toolCalls=${report.root.toolCallsTotal}, llmCalls=${report.root.llmCalls}`
|
|
776
|
+
);
|
|
777
|
+
const toolNames = Object.entries(report.root.toolCallsByName).sort((a, b) => b[1] - a[1]).map(([name, count]) => `${name}\xD7${count}`);
|
|
778
|
+
if (toolNames.length > 0) lines.push(` \u5DE5\u5177: ${toolNames.join(", ")}`);
|
|
779
|
+
lines.push(
|
|
780
|
+
`\u4E3B\u5BF9\u8BDD tokens: input=${report.root.usage.inputTokens}, cached=${report.root.usage.cachedTokens}, uncached=${report.root.usage.uncachedInputTokens}, output=${report.root.usage.outputTokens}, \u547D\u4E2D\u7387=${formatRatio(report.root.usage.cacheHitRatio)}`
|
|
781
|
+
);
|
|
782
|
+
for (const bucket of report.root.byModel) {
|
|
783
|
+
lines.push(
|
|
784
|
+
` model ${bucket.model} [${bucket.modelTier}]: calls=${bucket.llmCalls}, input=${bucket.inputTokens}, output=${bucket.outputTokens}, \u547D\u4E2D\u7387=${formatRatio(bucket.cacheHitRatio)}`
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
lines.push(
|
|
788
|
+
`\u5B50 Agent: ${report.totals.totalSubagentRuns} \u4E2A run\uFF08\u5931\u8D25/\u5347\u7EA7 ${report.totals.failedOrEscalatedRuns}\uFF09`
|
|
789
|
+
);
|
|
790
|
+
for (const subagent of report.subagents) {
|
|
791
|
+
const parts = [
|
|
792
|
+
subagent.runId,
|
|
793
|
+
subagent.status,
|
|
794
|
+
subagent.agentName ?? subagent.agentKey ?? "?",
|
|
795
|
+
subagent.modelTier,
|
|
796
|
+
...subagent.credentialGroup ? [`\u51ED\u8BC1\u7EC4=${subagent.credentialGroup}`] : [],
|
|
797
|
+
...subagent.inputTokens !== void 0 ? [`in=${subagent.inputTokens}`] : [],
|
|
798
|
+
...subagent.outputTokens !== void 0 ? [`out=${subagent.outputTokens}`] : [],
|
|
799
|
+
...subagent.llmCalls !== void 0 ? [`llm=${subagent.llmCalls}`] : [],
|
|
800
|
+
...subagent.escalated ? ["escalated"] : [],
|
|
801
|
+
...subagent.reviewVerdict ? [subagent.reviewVerdict] : []
|
|
802
|
+
];
|
|
803
|
+
lines.push(` - ${parts.join(" \xB7 ")}`);
|
|
804
|
+
}
|
|
805
|
+
lines.push(
|
|
806
|
+
`\u5408\u8BA1 tokens: input=${report.totals.combinedInputTokens}, cached=${report.totals.combinedCachedTokens}, uncached=${report.totals.combinedUncachedInputTokens}, output=${report.totals.combinedOutputTokens}`
|
|
807
|
+
);
|
|
808
|
+
lines.push(
|
|
809
|
+
`\u4E3B\u5BF9\u8BDD\u5360\u6BD4: input=${formatRatio(report.totals.rootShare.inputRatio)}, output=${formatRatio(report.totals.rootShare.outputRatio)}, llmCalls=${formatRatio(report.totals.rootShare.llmCallRatio)}`
|
|
810
|
+
);
|
|
811
|
+
const tiers = Object.entries(report.totals.byTier).sort((a, b) => b[1].runs - a[1].runs).map(
|
|
812
|
+
([tier, value]) => `${tier}: runs=${value.runs}, input=${value.inputTokens}, output=${value.outputTokens}`
|
|
813
|
+
);
|
|
814
|
+
if (tiers.length > 0) lines.push(`\u6309\u6863\u4F4D: ${tiers.join("; ")}`);
|
|
815
|
+
const groups = Object.entries(report.totals.byCredentialGroup).sort((a, b) => b[1].runs - a[1].runs).map(
|
|
816
|
+
([group, value]) => `${group}: runs=${value.runs}, input=${value.inputTokens}, output=${value.outputTokens}`
|
|
817
|
+
);
|
|
818
|
+
if (groups.length > 0) lines.push(`\u6309\u51ED\u8BC1\u7EC4: ${groups.join("; ")}`);
|
|
819
|
+
lines.push(`timeline: ${report.timeline.length} \u6761\uFF08--json \u770B\u5B8C\u6574\u7ED3\u6784\uFF09`);
|
|
820
|
+
if (report.dataNotes.length > 0) {
|
|
821
|
+
lines.push("\u6570\u636E\u8BF4\u660E:");
|
|
822
|
+
for (const note of report.dataNotes) lines.push(` - ${note}`);
|
|
823
|
+
}
|
|
824
|
+
return `${lines.join("\n")}
|
|
825
|
+
`;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
// packages/cli/dialogTraceCommand.ts
|
|
829
|
+
var TRACE_USAGE = "Usage: nolo dialog trace <dialogKey|dialogId> [--json] [--server-url <url>]\n --json Print the full DialogTraceReport as JSON (pipe into jq).\n";
|
|
830
|
+
async function runDialogTraceCommand(args, deps = {}) {
|
|
831
|
+
const env = deps.env ?? process.env;
|
|
832
|
+
const output = deps.output ?? process.stdout;
|
|
833
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
834
|
+
output.write(TRACE_USAGE);
|
|
835
|
+
return 0;
|
|
836
|
+
}
|
|
837
|
+
const json = args.includes("--json");
|
|
838
|
+
const fail = (code, message) => {
|
|
839
|
+
if (json) {
|
|
840
|
+
output.write(
|
|
841
|
+
`${JSON.stringify({ ok: false, error: { code, message } })}
|
|
842
|
+
`
|
|
843
|
+
);
|
|
844
|
+
} else if (code === "missing_argument") {
|
|
845
|
+
output.write(TRACE_USAGE);
|
|
846
|
+
} else {
|
|
847
|
+
output.write(`[nolo] dialog trace failed: ${message}
|
|
848
|
+
`);
|
|
849
|
+
}
|
|
850
|
+
return 1;
|
|
851
|
+
};
|
|
852
|
+
const authToken = resolveAuthToken(args, env);
|
|
853
|
+
if (!authToken) {
|
|
854
|
+
return fail(
|
|
855
|
+
"unauthorized",
|
|
856
|
+
"dialog trace requires an auth token. Run `nolo login` or set AUTH_TOKEN."
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
let target;
|
|
860
|
+
try {
|
|
861
|
+
target = resolveDialogReadTarget(args, env, authToken);
|
|
862
|
+
} catch (error) {
|
|
863
|
+
return fail(
|
|
864
|
+
"invalid_target",
|
|
865
|
+
`dialog trace failed: ${scrubTextForTrace(toErrorMessage(error))}`
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
if (!target) {
|
|
869
|
+
return fail(
|
|
870
|
+
"missing_argument",
|
|
871
|
+
"dialog trace requires a <dialogKey|dialogId> argument."
|
|
872
|
+
);
|
|
873
|
+
}
|
|
874
|
+
const notes = [];
|
|
875
|
+
let messages = [];
|
|
876
|
+
let snapshotFailure;
|
|
877
|
+
let hasValidSnapshot = false;
|
|
878
|
+
let usageServerBase = target.base;
|
|
879
|
+
try {
|
|
880
|
+
const snapshot = await (deps.readSnapshot ?? readDialogSnapshot)({
|
|
881
|
+
authToken,
|
|
882
|
+
base: target.base,
|
|
883
|
+
dialogId: target.dialogId,
|
|
884
|
+
dialogKey: target.dialogKey,
|
|
885
|
+
fetchImpl: deps.fetchImpl ?? fetch,
|
|
886
|
+
limit: 0,
|
|
887
|
+
readLocalDialog: deps.readLocalDialog,
|
|
888
|
+
readLocalDialogAtDbPath: deps.readLocalDialogAtDbPath
|
|
889
|
+
});
|
|
890
|
+
const resolvedBase = typeof snapshot?.resolvedBase === "string" ? snapshot.resolvedBase.trim() : "";
|
|
891
|
+
if (snapshot?.source === "http" && resolvedBase) usageServerBase = resolvedBase;
|
|
892
|
+
hasValidSnapshot = Boolean(snapshot && Array.isArray(snapshot.msgs));
|
|
893
|
+
const rawMessages = Array.isArray(snapshot?.msgs) ? [...snapshot.msgs].reverse() : snapshot?.messages;
|
|
894
|
+
if (Array.isArray(rawMessages)) {
|
|
895
|
+
messages = rawMessages;
|
|
896
|
+
} else {
|
|
897
|
+
notes.push("dialog \u5FEB\u7167\u672A\u5305\u542B\u6D88\u606F\u6570\u7EC4\uFF08msgs\uFF09\uFF1A\u6D88\u606F\u7EDF\u8BA1\u6309\u7A7A\u5904\u7406");
|
|
898
|
+
}
|
|
899
|
+
} catch (error) {
|
|
900
|
+
snapshotFailure = scrubTextForTrace(toErrorMessage(error));
|
|
901
|
+
notes.push(`\u8BFB\u53D6 dialog \u6D88\u606F\u5931\u8D25\uFF1A${snapshotFailure}`);
|
|
902
|
+
}
|
|
903
|
+
let usage = {
|
|
904
|
+
dialogKey: target.dialogKey,
|
|
905
|
+
dialogId: target.dialogId,
|
|
906
|
+
records: [],
|
|
907
|
+
source: "remote"
|
|
908
|
+
};
|
|
909
|
+
let usageFailure;
|
|
910
|
+
try {
|
|
911
|
+
usage = await (deps.collectUsage ?? collectDialogUsageRecords)(
|
|
912
|
+
args,
|
|
913
|
+
deps,
|
|
914
|
+
{
|
|
915
|
+
dialogKey: target.dialogKey,
|
|
916
|
+
dialogId: target.dialogId
|
|
917
|
+
},
|
|
918
|
+
usageServerBase
|
|
919
|
+
);
|
|
920
|
+
if (usage.source === "local") {
|
|
921
|
+
notes.push(
|
|
922
|
+
"\u8FDC\u7AEF\u672A\u8FD4\u56DE usage records\uFF1Atoken \u660E\u7EC6\u53D6\u81EA\u672C\u673A LevelDB\uFF08\u4E0E\u8FDC\u7AEF\u540C\u6E90\u540C\u53E3\u5F84\uFF09"
|
|
923
|
+
);
|
|
924
|
+
}
|
|
925
|
+
} catch (error) {
|
|
926
|
+
usageFailure = scrubTextForTrace(toErrorMessage(error));
|
|
927
|
+
notes.push(
|
|
928
|
+
`\u8BFB\u53D6 token \u660E\u7EC6\u5931\u8D25\uFF08root.usage \u6309\u300C\u65E0\u8BB0\u5F55\u300D\u5904\u7406\uFF09\uFF1A${usageFailure}`
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
let runs = [];
|
|
932
|
+
try {
|
|
933
|
+
runs = deps.listRuns ? deps.listRuns(env) : listRunRecords({ env });
|
|
934
|
+
} catch (error) {
|
|
935
|
+
notes.push(
|
|
936
|
+
`\u8BFB\u53D6 ~/.nolo/runs \u5931\u8D25\uFF08\u5B50 run \u5217\u8868\u6309\u7A7A\u5904\u7406\uFF09\uFF1A${scrubTextForTrace(toErrorMessage(error))}`
|
|
937
|
+
);
|
|
938
|
+
}
|
|
939
|
+
const report = buildDialogTraceReport({
|
|
940
|
+
dialogKey: target.dialogKey,
|
|
941
|
+
dialogId: target.dialogId,
|
|
942
|
+
messages,
|
|
943
|
+
usageRecords: usage.records,
|
|
944
|
+
runs,
|
|
945
|
+
notes
|
|
946
|
+
});
|
|
947
|
+
if (!hasValidSnapshot && usage.records.length === 0 && report.subagents.length === 0) {
|
|
948
|
+
return fail(
|
|
949
|
+
"dialog_unreadable",
|
|
950
|
+
`dialog trace failed: \u76EE\u6807\u5BF9\u8BDD ${target.dialogKey} \u5B8C\u5168\u672A\u8BFB\u5230\uFF08\u6D88\u606F\u5FEB\u7167\uFF1A${snapshotFailure ?? "\u672A\u8FD4\u56DE msgs \u6570\u7EC4"}\uFF1B\u7528\u91CF\uFF1A${usageFailure ?? "\u65E0\u8BB0\u5F55"}\uFF1B\u5B50 run\uFF1A\u65E0\u5339\u914D\uFF09`
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
output.write(
|
|
954
|
+
json ? `${JSON.stringify(report, null, 2)}
|
|
955
|
+
` : formatDialogTraceReport(report)
|
|
956
|
+
);
|
|
957
|
+
return 0;
|
|
958
|
+
}
|
|
959
|
+
export {
|
|
960
|
+
runDialogTraceCommand
|
|
961
|
+
};
|