nolo-cli 0.228.0 → 0.228.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-GIFVXKDT.js → _executeModel-AKCTHGMP.js} +62 -61
- package/{action-WZTKEF5H.js → action-C6IQAKN4.js} +6 -6
- package/{addContentAction-MLI6GOBV.js → addContentAction-53364YDW.js} +10 -10
- package/{addDialogAgentAction-ARGQM22H.js → addDialogAgentAction-U5DD5EN5.js} +9 -9
- package/{agentDeleteCommand-UF7XVELS.js → agentDeleteCommand-2E5FAGUO.js} +99 -93
- package/{agentEmailCommands-SFHRPQYC.js → agentEmailCommands-UGZZAH7E.js} +99 -93
- package/{agentListCommands-IXKBP3W5.js → agentListCommands-JCTW3J2K.js} +240 -52
- package/{agentMachineCommands-7NX6PWQ6.js → agentMachineCommands-QPG5ZXF4.js} +45 -41
- package/{agentProviderCommands-C5T7C5KZ.js → agentProviderCommands-QLTABYR7.js} +2 -2
- package/{agentPullCommand-4EQZYHU4.js → agentPullCommand-2EYJ5ENC.js} +1 -1
- package/{agentRecordCommands-IUNX6XD6.js → agentRecordCommands-4NTVR6MZ.js} +98 -92
- package/{agentRunCommand-LCR4XADM.js → agentRunCommand-VHF34PYC.js} +103 -94
- package/{agentRunControl-RN2P6AOD.js → agentRunControl-QYTXUQGY.js} +10 -7
- package/{agentRuntimeLocal-LVXPQ7QA.js → agentRuntimeLocal-U54AKHXH.js} +38 -36
- package/{agentSlice-ZGMOH6TE.js → agentSlice-4JGDEXWK.js} +10 -10
- package/{appDeleteCommands-BESCJOQM.js → appDeleteCommands-XBE5QJ6P.js} +46 -42
- package/{appDeployCommands-LPTR6IOX.js → appDeployCommands-QIYLXXGA.js} +46 -42
- package/{appDeployStatusCommands-BZ7KZ5RD.js → appDeployStatusCommands-JXS6ZQZZ.js} +46 -42
- package/{appGetCommands-EDWGJV4S.js → appGetCommands-SZS7SJPK.js} +46 -42
- package/{appListCommands-OPRWYPM6.js → appListCommands-B3GBJSNV.js} +46 -42
- package/{authCommand-3C3RN4OU.js → authCommand-V6EOMZX6.js} +15 -15
- package/{authCommands-ZMVEDCQD.js → authCommands-T5FODCEG.js} +2 -2
- package/{builtinSkillRegistry-VRCMQ77Q.js → builtinSkillRegistry-ZQC3IIO2.js} +4 -3
- package/{chromeOpsCommands-NZITLHWO.js → chromeOpsCommands-OFX7ZGKP.js} +2 -2
- package/{chunk-MZVCFV3T.js → chunk-223KZUJ6.js} +4 -4
- package/{chunk-UF6J7NXV.js → chunk-2C5VN7NH.js} +1 -1
- package/{chunk-MAA42MMV.js → chunk-2FZVXOFX.js} +4 -4
- package/{chunk-ESN4WNWU.js → chunk-2JHGUL5K.js} +2 -2
- package/chunk-3A5NNQCN.js +64 -0
- package/chunk-3F2FRLIO.js +372 -0
- package/{chunk-V4IYI3SB.js → chunk-46FETNLF.js} +2 -2
- package/{chunk-RR3MB26M.js → chunk-4GYVS4PM.js} +8 -6
- package/{chunk-ZQ6K57FJ.js → chunk-4YPH5KRA.js} +1 -1
- package/{chunk-Y4NPF2UN.js → chunk-5AYP5QBB.js} +5 -5
- package/{chunk-4OXPN3WC.js → chunk-5ISNPTQH.js} +4 -4
- package/{chunk-CO6E7YK6.js → chunk-5P3PPQVP.js} +1 -1
- package/{chunk-6TVYUQRM.js → chunk-6BMTKYAO.js} +2 -2
- package/{chunk-KLAMJNKQ.js → chunk-6PAHSSD2.js} +15 -8
- package/{chunk-CTWCZKNS.js → chunk-6SOWMEAY.js} +4 -4
- package/{chunk-ARFCL53U.js → chunk-6VEO7Z3Y.js} +5 -5
- package/{chunk-ZM5AZTQG.js → chunk-7BIJFGKS.js} +20 -8
- package/{chunk-BAH3BAUZ.js → chunk-7OVOZRZF.js} +5 -5
- package/{chunk-N74XL3NI.js → chunk-7PON4LBY.js} +42 -24
- package/{chunk-LTVEOOZL.js → chunk-7WHCIA5V.js} +16 -3
- package/{chunk-HZDK56EK.js → chunk-ADYWV732.js} +34 -12
- package/{chunk-2FK2KZSL.js → chunk-AIFQKNPP.js} +1 -1
- package/{chunk-VTHWBTRE.js → chunk-BPB3T5EU.js} +5 -8
- package/{chunk-SX6AWTNK.js → chunk-BZLGPM5B.js} +3 -3
- package/{chunk-MTM4LRVG.js → chunk-BZMDWGQQ.js} +2 -2
- package/{chunk-JP2BH4NC.js → chunk-CEKRIR22.js} +1 -1
- package/{chunk-5HUO7SEX.js → chunk-D634SL2Y.js} +1 -1
- package/{chunk-SCMYAGQE.js → chunk-DHRPLRIR.js} +294 -159
- package/{chunk-VUHKG4KS.js → chunk-DNNPARJK.js} +9 -5
- package/{chunk-X22AUZKL.js → chunk-E3LSO6EI.js} +189 -88
- package/{chunk-LHCGKAFO.js → chunk-EHFBP6IK.js} +100 -48
- package/{chunk-6ASGEP5D.js → chunk-EJQE5HB7.js} +1 -1
- package/{chunk-2BKNICGK.js → chunk-EL5NRJHI.js} +1 -1
- package/chunk-EUGTFFO6.js +42 -0
- package/{chunk-YFW4H6DL.js → chunk-EVHTYVD2.js} +821 -131
- package/{chunk-6XRPBZRS.js → chunk-EYLGAEB4.js} +0 -134
- package/{chunk-E5RYFR7E.js → chunk-FEIVARWR.js} +49 -15
- package/{chunk-3DJJ4CFG.js → chunk-FLBJ7IJI.js} +9 -9
- package/{chunk-W3HSD32M.js → chunk-FXEPZKNJ.js} +2 -2
- package/{chunk-VKCPKCSS.js → chunk-FYAMUU55.js} +625 -62
- package/{chunk-JEWMQR6J.js → chunk-FZANZZ63.js} +1 -1
- package/{chunk-WWTSEBDF.js → chunk-GIXWVN2W.js} +1 -1
- package/{chunk-YHNUDTU4.js → chunk-HDKMVYNJ.js} +4 -4
- package/chunk-HEVRQGGH.js +106 -0
- package/{chunk-PBPXXMWZ.js → chunk-HFHJPHFK.js} +1 -1
- package/{chunk-WQDTSK5U.js → chunk-HPDLPEUG.js} +11 -5
- package/{chunk-SPU3L3OR.js → chunk-HQUGB2HM.js} +3 -3
- package/chunk-IVK2KT3H.js +209 -0
- package/{chunk-73PZD7JZ.js → chunk-IYLUK67R.js} +2 -2
- package/{chunk-BFKJ2RS3.js → chunk-J55F3IEZ.js} +1 -1
- package/{chunk-ADOOL3PG.js → chunk-J7JRCOIW.js} +1 -1
- package/{chunk-AEZBAFC6.js → chunk-JAKRY74O.js} +138 -8
- package/{chunk-NEG5LYK5.js → chunk-JCQ3WCQ3.js} +3 -1
- package/{chunk-W6T4FNZP.js → chunk-JLZJL3WC.js} +219 -351
- package/{chunk-PQ63BDV3.js → chunk-JPXACKSW.js} +9 -1
- package/{chunk-IIOSZAJX.js → chunk-KDBDOXOM.js} +137 -53
- package/{chunk-CIGCTSBF.js → chunk-KDDHQMSH.js} +1 -1
- package/{chunk-OAZP4TSA.js → chunk-KG27JIG4.js} +2 -2
- package/{chunk-RHBD22LV.js → chunk-KHYSFS3W.js} +80 -4
- package/{chunk-7UVVLYKC.js → chunk-KKIQAVDR.js} +5 -5
- package/{chunk-HS7MLR74.js → chunk-KZ4A7EIV.js} +3 -5
- package/{chunk-OLGFIQN2.js → chunk-LLUBUHNT.js} +1 -1
- package/{chunk-QJTZ76CP.js → chunk-LS5KAVFQ.js} +1 -0
- package/{chunk-K26XPZRB.js → chunk-LVZVSLKO.js} +29 -9
- package/{chunk-XJSEST7D.js → chunk-MNFUKRRU.js} +3 -3
- package/{chunk-R5NRFXGD.js → chunk-O3A2CHAL.js} +5 -5
- package/{chunk-4IQN6FWY.js → chunk-OB4FBZXJ.js} +4 -4
- package/{chunk-J2VIGDJN.js → chunk-OJSJJKHF.js} +3 -3
- package/{chunk-OHUYN3YU.js → chunk-OKAXQFON.js} +1 -1
- package/{chunk-CD2DK5JA.js → chunk-OKH74FML.js} +2 -1
- package/{chunk-MYYNZG2M.js → chunk-OOV5JN25.js} +4 -4
- package/{chunk-TMRJGSK2.js → chunk-OOVOAG4Q.js} +1 -1
- package/chunk-OQFOE4SJ.js +405 -0
- package/{chunk-AS6L5KSD.js → chunk-P4R5KXU7.js} +2 -2
- package/{chunk-VIYVRPMJ.js → chunk-PHREU2KZ.js} +5 -3
- package/{chunk-EDT65EUE.js → chunk-PIVTQRX6.js} +45 -15
- package/{chunk-QMNVV3YM.js → chunk-PJL7OJRC.js} +12 -11
- package/{chunk-XCA4WHX5.js → chunk-PNLDLUMO.js} +315 -360
- package/{chunk-UPOW5HTG.js → chunk-QGFLVQ6E.js} +3 -3
- package/{chunk-JU7VN4LF.js → chunk-QONAOHVW.js} +6 -6
- package/{chunk-UOUMPHS5.js → chunk-R3FZHW4Q.js} +13 -13
- package/{chunk-K7VIXYTZ.js → chunk-R3MV2GII.js} +1 -45
- package/{chunk-FE7G6DSP.js → chunk-R72QWIFO.js} +14 -4
- package/{chunk-KZAT2M2V.js → chunk-RIWKZT7E.js} +22 -0
- package/{chunk-RMWDKLBE.js → chunk-S7H4KTMB.js} +1099 -71
- package/{chunk-IJZC2KIJ.js → chunk-SA356NGW.js} +1 -1
- package/{chunk-BVEDT6DM.js → chunk-SCAC3NM5.js} +3 -3
- package/{chunk-EQZQUQ33.js → chunk-SLUN7W6S.js} +5 -5
- package/{chunk-KK3FCYZM.js → chunk-SQL7YNED.js} +7 -4
- package/{chunk-LMGFVH65.js → chunk-SSOR2EDT.js} +10 -10
- package/chunk-TRRXYFTR.js +46 -0
- package/{chunk-XNTZD4AE.js → chunk-TUOHSUK5.js} +19367 -17503
- package/chunk-TYJCIA2O.js +835 -0
- package/{chunk-FTWAOKFU.js → chunk-U3BUWDUP.js} +415 -1962
- package/{chunk-CD64YXRB.js → chunk-U6QNVOR5.js} +1 -1
- package/chunk-UAF5VQCE.js +77 -0
- package/{chunk-CIUZXD5D.js → chunk-UFGUJ2IH.js} +5 -5
- package/{chunk-CTIEJRTP.js → chunk-UP7KBWLE.js} +81 -29
- package/{chunk-GX6DITLQ.js → chunk-UUCYUN6Y.js} +1 -1
- package/{chunk-UHW6SCVK.js → chunk-UZKBVQUX.js} +1 -1
- package/{chunk-XSRSAU3O.js → chunk-V5TI7HJH.js} +3 -3
- package/{chunk-WFGNWWJI.js → chunk-VH7UO6E5.js} +252 -114
- package/{chunk-ITBX27W6.js → chunk-VJFDG3ZG.js} +30 -122
- package/{chunk-6MTVACLN.js → chunk-WC3J5SL2.js} +277 -293
- package/{chunk-HCCQEMTK.js → chunk-WD5547ZF.js} +15 -12
- package/{chunk-X3OZ655T.js → chunk-WS36XPJD.js} +2 -2
- package/{chunk-JFRJEPFI.js → chunk-WSLL7VV4.js} +2 -2
- package/chunk-XRGBJHZX.js +136 -0
- package/{chunk-KZ5OD2MO.js → chunk-Y2KWJTOZ.js} +3 -3
- package/{dialogUsageCommand-6RW2FY6K.js → chunk-Y2TCTNUD.js} +24 -17
- package/{chunk-FFFKAOJN.js → chunk-YN23INFZ.js} +1 -1
- package/{chunk-ODBYGVO2.js → chunk-YXK3GJF5.js} +5 -5
- package/{chunk-6CXQ3YNJ.js → chunk-Z2OWAYMI.js} +53 -31
- package/{chunk-6XVPMGXK.js → chunk-ZTHAJU3O.js} +10 -4
- package/{chunk-D25ONVOH.js → chunk-ZYPXOQS2.js} +1 -1
- package/{cliAgentConfigHelpers-37ZNEY5Y.js → cliAgentConfigHelpers-BXHQ3PXP.js} +8 -8
- package/{cliAuthorityBrokerClient-SFPC3WVK.js → cliAuthorityBrokerClient-TFNXJLXL.js} +1 -1
- package/cliAuthorityBrokerProcess-5ZFBTHLB.js +22 -0
- package/{cliLocalAgentRecordReader-MCQVRWBR.js → cliLocalAgentRecordReader-47PXMHPH.js} +43 -41
- package/{commandRegistry-NTH5IAN5.js → commandRegistry-CTMPAQH2.js} +93 -156
- package/{contentThunks-SPXTX5U2.js → contentThunks-CAHIIZO5.js} +25 -25
- package/{cooldownCommands-TIFCHCUN.js → cooldownCommands-WDOI5VD7.js} +3 -3
- package/{createAgentAutomationAction-KUQKCOXB.js → createAgentAutomationAction-M25XZSPD.js} +25 -25
- package/{createDialogAction-HJN5U3XS.js → createDialogAction-4SN7FKI7.js} +26 -26
- package/{createPageAction-ZAHRDOAU.js → createPageAction-N7QPDN3M.js} +28 -28
- package/{db-CMUTP3W5.js → db-VR74ADGC.js} +7 -2
- package/{dbSlice-656PMWR2.js → dbSlice-RWPSVHBC.js} +9 -9
- package/{deleteFile-ZCQESEEQ.js → deleteFile-ECU6FU5C.js} +12 -7
- package/{dialogCommands-KZTZLWPZ.js → dialogCommands-BBHWCKDP.js} +57 -47
- package/{dialogNotifyCommand-PST75COP.js → dialogNotifyCommand-IASQGEMW.js} +9 -9
- package/{dialogSlice-BXIERQHO.js → dialogSlice-JI3J22RV.js} +23 -23
- package/dialogTraceCommand-EW2KK6A4.js +961 -0
- package/dialogUsageCommand-WJ3U6KZU.js +27 -0
- package/{docCreateCommands-26HJ5NAY.js → docCreateCommands-QSX3X5U4.js} +45 -41
- package/{docDeleteCommands-UAOHH5XK.js → docDeleteCommands-63JBG2HQ.js} +46 -42
- package/{docReadCommands-4ADG7YE6.js → docReadCommands-CQFKRQUI.js} +45 -41
- package/{docStore-FZ75HWP2.js → docStore-XLBKGGNM.js} +10 -10
- package/{docUpdateCommands-OGFJZENF.js → docUpdateCommands-534LUK25.js} +45 -41
- package/ebookDownloaderAgentCommand-DYSKF5ZY.js +677 -0
- package/{getPricing-FCHYVRJU.js → getPricing-5BLZRPTM.js} +3 -3
- package/{handleSendMessageAction-KP6GGBFY.js → handleSendMessageAction-Q2VMEVOR.js} +90 -48
- package/{hostCredentialCreate-23TX56G7.js → hostCredentialCreate-C57T7YPE.js} +99 -93
- package/index.js +23 -11
- package/{localDialogRead-CIOTQM5T.js → localDialogRead-BJJT3TF5.js} +1 -1
- package/{localRuntimeAdapter-MTUWOYPN.js → localRuntimeAdapter-OALZPFZU.js} +96 -90
- package/{localRuntimeAuthority-TYHQCTZN.js → localRuntimeAuthority-UF2DAQ3F.js} +13 -3
- package/{localRuntimeDb-BO7IVWAZ.js → localRuntimeDb-ZJFGNHML.js} +1 -1
- package/{machineCommands-4WJUJQHW.js → machineCommands-N6IVWRZT.js} +109 -92
- package/{machineWsRunDispatch-V3U4JM67.js → machineWsRunDispatch-PDWYB33B.js} +97 -91
- package/{markdownToSlate-KIYM7B3P.js → markdownToSlate-PXYAIBVL.js} +1 -1
- package/{mcpLocalAuthorizeCommand-TI656UWC.js → mcpLocalAuthorizeCommand-KYI4EGF5.js} +17 -13
- package/{memberThunks-JFYC4Z5L.js → memberThunks-43B7UYC5.js} +11 -11
- package/{models-EP7VG6N2.js → models-ZX2BYIMB.js} +2 -2
- package/package.json +2 -1
- package/{projectArchive-NU2Z5HOR.js → projectArchive-TJNW5DLM.js} +28 -28
- package/{providerPresetApply-4H7YP5D7.js → providerPresetApply-NTJUINI6.js} +35 -16
- package/{providerRegistry-F3UPOTIY.js → providerRegistry-W45SLUV6.js} +5 -5
- package/{read-BRZHXUJ6.js → read-KG6INYUT.js} +12 -7
- package/{readDocTool-N7RVFQEE.js → readDocTool-N3GA52JR.js} +1 -1
- package/{readlineWorkspace-T56MRMS5.js → readlineWorkspace-PJZJVGA5.js} +1296 -1056
- package/{removeDialogAgentAction-J7XU7OUX.js → removeDialogAgentAction-EEVSOQOJ.js} +11 -11
- package/{runAgentClientLoop-O2GRCGRZ.js → runAgentClientLoop-3VC5TCDW.js} +69 -58
- package/{runtimeDoctorCommands-RDRJXMXC.js → runtimeDoctorCommands-V3M3JTUV.js} +14 -11
- package/{secretCommands-2FEMRUFM.js → secretCommands-KVVZS7A6.js} +2 -2
- package/{setDialogExtraReferencesAction-Q4V2ZZW2.js → setDialogExtraReferencesAction-DNO5POHA.js} +10 -10
- package/{setPrimaryDialogAgentAction-742H5S6T.js → setPrimaryDialogAgentAction-QABBEO4C.js} +11 -11
- package/{settingThunks-T4FXSV6M.js → settingThunks-DVKG4X4S.js} +13 -17
- package/{skillDiscovery-MDDKPTW3.js → skillDiscovery-ZMJH36AK.js} +3 -3
- package/{spaceCommands-W5TAVFDT.js → spaceCommands-AGGZXPY3.js} +218 -77
- package/{streamAgentChatTurn-OWDJMU5E.js → streamAgentChatTurn-4GTLL2OF.js} +111 -95
- package/{switchDialogAgentAction-HLDLHRRA.js → switchDialogAgentAction-KYWJSGOO.js} +9 -9
- package/{tableCommands-44GC4N6J.js → tableCommands-EFA754RE.js} +3 -3
- package/{tools-O7SGGVA3.js → tools-5AGPOPLW.js} +48 -47
- package/{tuiRestart-EOGC2BYY.js → tuiRestart-77E7PL4R.js} +9 -8
- package/{tuiSummaryLlmCaller-TM5BU73J.js → tuiSummaryLlmCaller-HROLGN4F.js} +12 -12
- package/{updateCommands-FBYA5WVG.js → updateCommands-GJGRS6JK.js} +3 -3
- package/{updateDialogTitleAction-EXSZGTLL.js → updateDialogTitleAction-5OSEDGRK.js} +25 -25
- package/{usageCommand-L4OFWXEU.js → usageCommand-WI6SQOPB.js} +2 -2
- package/{usageRebuildCommand-7JR33UHS.js → usageRebuildCommand-WQRLLZAT.js} +3 -3
- package/{windowsSelfUpdate-M4V77OUB.js → windowsSelfUpdate-C7LGVWYX.js} +2 -2
- package/{workloadLifecycle-ZCSQCHG3.js → workloadLifecycle-P2SJVV3S.js} +2 -2
- package/chunk-FGHEF6WI.js +0 -34
- package/chunk-U5LOKQ2R.js +0 -176
- package/chunk-YDRRGVT5.js +0 -142
- package/chunk-YGDYYFRX.js +0 -86
- package/chunk-Z7KE4K3H.js +0 -758
- package/lib-62SWPXNF.js +0 -21042
- /package/{chunk-ANUP75N2.js → chunk-2E4BYAUE.js} +0 -0
|
@@ -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-PJL7OJRC.js";
|
|
9
|
+
import "./chunk-ID4G2MAR.js";
|
|
10
|
+
import "./chunk-Y5GCAMGP.js";
|
|
11
|
+
import "./chunk-FZANZZ63.js";
|
|
12
|
+
import "./chunk-KDDHQMSH.js";
|
|
13
|
+
import "./chunk-LKZPX6YH.js";
|
|
14
|
+
import "./chunk-UFGUJ2IH.js";
|
|
15
|
+
import "./chunk-PNLDLUMO.js";
|
|
16
|
+
import "./chunk-AMWMV56B.js";
|
|
17
|
+
import "./chunk-DXWGFL2Z.js";
|
|
18
|
+
import "./chunk-3L2WKC3W.js";
|
|
19
|
+
import {
|
|
20
|
+
listRunRecords
|
|
21
|
+
} from "./chunk-JAKRY74O.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-SA356NGW.js";
|
|
35
|
+
import "./chunk-TUOHSUK5.js";
|
|
36
|
+
import "./chunk-ZNFJWEN4.js";
|
|
37
|
+
import "./chunk-EHFBP6IK.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-5ISNPTQH.js";
|
|
46
|
+
import "./chunk-BYXBJQAS.js";
|
|
47
|
+
import "./chunk-BZLGPM5B.js";
|
|
48
|
+
import "./chunk-AIFQKNPP.js";
|
|
49
|
+
import "./chunk-56GBUMO5.js";
|
|
50
|
+
import "./chunk-TYJCIA2O.js";
|
|
51
|
+
import "./chunk-VJFDG3ZG.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-VH7UO6E5.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-UP7KBWLE.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-D634SL2Y.js";
|
|
84
|
+
import "./chunk-UAF5VQCE.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-WC3J5SL2.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-FEIVARWR.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
|
+
};
|