@jerry_aurora/sky-monitor-sdk 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +355 -0
- package/dist/chunk-2EV6VMEO.js +2 -0
- package/dist/chunk-2EV6VMEO.js.map +1 -0
- package/dist/chunk-2R7LNQYV.js +4 -0
- package/dist/chunk-2R7LNQYV.js.map +1 -0
- package/dist/chunk-4DK7RV2K.js +2 -0
- package/dist/chunk-4DK7RV2K.js.map +1 -0
- package/dist/chunk-4GL6IXHZ.cjs +2 -0
- package/dist/chunk-4GL6IXHZ.cjs.map +1 -0
- package/dist/chunk-4K5NIPXS.cjs +2 -0
- package/dist/chunk-4K5NIPXS.cjs.map +1 -0
- package/dist/chunk-5RS6LIZN.js +2 -0
- package/dist/chunk-5RS6LIZN.js.map +1 -0
- package/dist/chunk-5VYMD33V.cjs +2 -0
- package/dist/chunk-5VYMD33V.cjs.map +1 -0
- package/dist/chunk-647GK2XE.js +2 -0
- package/dist/chunk-647GK2XE.js.map +1 -0
- package/dist/chunk-6KJXTS2V.js +2 -0
- package/dist/chunk-6KJXTS2V.js.map +1 -0
- package/dist/chunk-6YTKBMJD.cjs +2 -0
- package/dist/chunk-6YTKBMJD.cjs.map +1 -0
- package/dist/chunk-ACIPNVBT.cjs +2 -0
- package/dist/chunk-ACIPNVBT.cjs.map +1 -0
- package/dist/chunk-BEGDR54W.js +2 -0
- package/dist/chunk-BEGDR54W.js.map +1 -0
- package/dist/chunk-BVOILM65.cjs +2 -0
- package/dist/chunk-BVOILM65.cjs.map +1 -0
- package/dist/chunk-FBQC6XIY.cjs +2 -0
- package/dist/chunk-FBQC6XIY.cjs.map +1 -0
- package/dist/chunk-GBREIA45.js +2 -0
- package/dist/chunk-GBREIA45.js.map +1 -0
- package/dist/chunk-GU7O5MWM.js +2 -0
- package/dist/chunk-GU7O5MWM.js.map +1 -0
- package/dist/chunk-JMHMJVBJ.cjs +2 -0
- package/dist/chunk-JMHMJVBJ.cjs.map +1 -0
- package/dist/chunk-LAATIQ3Y.cjs +2 -0
- package/dist/chunk-LAATIQ3Y.cjs.map +1 -0
- package/dist/chunk-LFJTX6FJ.cjs +2 -0
- package/dist/chunk-LFJTX6FJ.cjs.map +1 -0
- package/dist/chunk-LKBNR7RI.js +2 -0
- package/dist/chunk-LKBNR7RI.js.map +1 -0
- package/dist/chunk-NM4RALDJ.cjs +2 -0
- package/dist/chunk-NM4RALDJ.cjs.map +1 -0
- package/dist/chunk-O32X45L3.js +2 -0
- package/dist/chunk-O32X45L3.js.map +1 -0
- package/dist/chunk-S3ROE6GJ.js +2 -0
- package/dist/chunk-S3ROE6GJ.js.map +1 -0
- package/dist/chunk-SNOBW3V4.js +2 -0
- package/dist/chunk-SNOBW3V4.js.map +1 -0
- package/dist/chunk-XOLMXHFL.js +2 -0
- package/dist/chunk-XOLMXHFL.js.map +1 -0
- package/dist/chunk-Y2IWAJSY.cjs +4 -0
- package/dist/chunk-Y2IWAJSY.cjs.map +1 -0
- package/dist/chunk-Y46XWPAC.cjs +2 -0
- package/dist/chunk-Y46XWPAC.cjs.map +1 -0
- package/dist/chunk-ZIKPTR2L.cjs +2 -0
- package/dist/chunk-ZIKPTR2L.cjs.map +1 -0
- package/dist/index-Bh5S5dim.d.ts +203 -0
- package/dist/index-D6soZ1u6.d.cts +203 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/platforms/browser.cjs +2 -0
- package/dist/platforms/browser.cjs.map +1 -0
- package/dist/platforms/browser.d.cts +10 -0
- package/dist/platforms/browser.d.ts +10 -0
- package/dist/platforms/browser.js +2 -0
- package/dist/platforms/browser.js.map +1 -0
- package/dist/plugins/dedupe.cjs +2 -0
- package/dist/plugins/dedupe.cjs.map +1 -0
- package/dist/plugins/dedupe.d.cts +39 -0
- package/dist/plugins/dedupe.d.ts +39 -0
- package/dist/plugins/dedupe.js +2 -0
- package/dist/plugins/dedupe.js.map +1 -0
- package/dist/plugins/error.cjs +2 -0
- package/dist/plugins/error.cjs.map +1 -0
- package/dist/plugins/error.d.cts +51 -0
- package/dist/plugins/error.d.ts +51 -0
- package/dist/plugins/error.js +2 -0
- package/dist/plugins/error.js.map +1 -0
- package/dist/plugins/fetch.cjs +2 -0
- package/dist/plugins/fetch.cjs.map +1 -0
- package/dist/plugins/fetch.d.cts +35 -0
- package/dist/plugins/fetch.d.ts +35 -0
- package/dist/plugins/fetch.js +2 -0
- package/dist/plugins/fetch.js.map +1 -0
- package/dist/plugins/offline-queue.cjs +2 -0
- package/dist/plugins/offline-queue.cjs.map +1 -0
- package/dist/plugins/offline-queue.d.cts +93 -0
- package/dist/plugins/offline-queue.d.ts +93 -0
- package/dist/plugins/offline-queue.js +2 -0
- package/dist/plugins/offline-queue.js.map +1 -0
- package/dist/plugins/performance.cjs +2 -0
- package/dist/plugins/performance.cjs.map +1 -0
- package/dist/plugins/performance.d.cts +31 -0
- package/dist/plugins/performance.d.ts +31 -0
- package/dist/plugins/performance.js +2 -0
- package/dist/plugins/performance.js.map +1 -0
- package/dist/plugins/replay.cjs +77 -0
- package/dist/plugins/replay.cjs.map +1 -0
- package/dist/plugins/replay.js +77 -0
- package/dist/plugins/replay.js.map +1 -0
- package/dist/plugins/sampling.cjs +2 -0
- package/dist/plugins/sampling.cjs.map +1 -0
- package/dist/plugins/sampling.d.cts +56 -0
- package/dist/plugins/sampling.d.ts +56 -0
- package/dist/plugins/sampling.js +2 -0
- package/dist/plugins/sampling.js.map +1 -0
- package/dist/plugins/session.cjs +2 -0
- package/dist/plugins/session.cjs.map +1 -0
- package/dist/plugins/session.d.cts +74 -0
- package/dist/plugins/session.d.ts +74 -0
- package/dist/plugins/session.js +2 -0
- package/dist/plugins/session.js.map +1 -0
- package/dist/plugins/trace.cjs +2 -0
- package/dist/plugins/trace.cjs.map +1 -0
- package/dist/plugins/trace.d.cts +125 -0
- package/dist/plugins/trace.d.ts +125 -0
- package/dist/plugins/trace.js +2 -0
- package/dist/plugins/trace.js.map +1 -0
- package/dist/plugins/transport.cjs +2 -0
- package/dist/plugins/transport.cjs.map +1 -0
- package/dist/plugins/transport.d.cts +231 -0
- package/dist/plugins/transport.d.ts +231 -0
- package/dist/plugins/transport.js +2 -0
- package/dist/plugins/transport.js.map +1 -0
- package/dist/plugins/xhr.cjs +2 -0
- package/dist/plugins/xhr.cjs.map +1 -0
- package/dist/plugins/xhr.d.cts +35 -0
- package/dist/plugins/xhr.d.ts +35 -0
- package/dist/plugins/xhr.js +2 -0
- package/dist/plugins/xhr.js.map +1 -0
- package/dist/presets.cjs +2 -0
- package/dist/presets.cjs.map +1 -0
- package/dist/presets.d.cts +45 -0
- package/dist/presets.d.ts +45 -0
- package/dist/presets.js +2 -0
- package/dist/presets.js.map +1 -0
- package/dist/sky-monitor-replay.umd.js +77 -0
- package/dist/sky-monitor-replay.umd.js.map +1 -0
- package/dist/sky-monitor.umd.js +4 -0
- package/dist/sky-monitor.umd.js.map +1 -0
- package/dist/types-BGUJGEpp.d.cts +90 -0
- package/dist/types-BGUJGEpp.d.ts +90 -0
- package/package.json +122 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"sampling.cjs"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { P as Plugin, I as IMonitor, a as MonitorEvent } from '../types-BGUJGEpp.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sampling 插件 - 智能采样
|
|
5
|
+
*
|
|
6
|
+
* 支持:
|
|
7
|
+
* - 按用户/会话采样(同一用户要么全采要么不采)
|
|
8
|
+
* - 按事件类型差异化采样率
|
|
9
|
+
* - 重要事件(error/vital)默认全量
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** 采样模式 */
|
|
13
|
+
type SamplingMode = 'random' | 'user' | 'session';
|
|
14
|
+
/** 事件类型采样率配置 */
|
|
15
|
+
type TypeRates = Record<string, number>;
|
|
16
|
+
interface SamplingPluginOptions {
|
|
17
|
+
/** 默认采样率 0-1,默认 1.0(全量) */
|
|
18
|
+
rate?: number;
|
|
19
|
+
/** 采样模式,默认 'session' */
|
|
20
|
+
mode?: SamplingMode;
|
|
21
|
+
/** 按事件类型的采样率(覆盖默认) */
|
|
22
|
+
typeRates?: TypeRates;
|
|
23
|
+
/** 始终采样的事件类型(不受采样率影响) */
|
|
24
|
+
alwaysSample?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 采样插件
|
|
28
|
+
*/
|
|
29
|
+
declare class SamplingPlugin implements Plugin {
|
|
30
|
+
name: string;
|
|
31
|
+
priority: number;
|
|
32
|
+
private _rate;
|
|
33
|
+
private _mode;
|
|
34
|
+
private _typeRates;
|
|
35
|
+
private _alwaysSample;
|
|
36
|
+
private _shouldSample;
|
|
37
|
+
constructor(options?: SamplingPluginOptions);
|
|
38
|
+
/**
|
|
39
|
+
* 插件初始化
|
|
40
|
+
*/
|
|
41
|
+
setupOnce(_monitor: IMonitor): void;
|
|
42
|
+
/**
|
|
43
|
+
* 事件处理:采样过滤
|
|
44
|
+
*/
|
|
45
|
+
processEvent(event: MonitorEvent): MonitorEvent | null;
|
|
46
|
+
/**
|
|
47
|
+
* 决定是否采样(用户/会话级)
|
|
48
|
+
*/
|
|
49
|
+
private _decideSampling;
|
|
50
|
+
/**
|
|
51
|
+
* 重置采样决策(新会话时调用)
|
|
52
|
+
*/
|
|
53
|
+
resetSampling(): void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { type SamplingMode, SamplingPlugin, type SamplingPluginOptions, type TypeRates };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { P as Plugin, I as IMonitor, a as MonitorEvent } from '../types-BGUJGEpp.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sampling 插件 - 智能采样
|
|
5
|
+
*
|
|
6
|
+
* 支持:
|
|
7
|
+
* - 按用户/会话采样(同一用户要么全采要么不采)
|
|
8
|
+
* - 按事件类型差异化采样率
|
|
9
|
+
* - 重要事件(error/vital)默认全量
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** 采样模式 */
|
|
13
|
+
type SamplingMode = 'random' | 'user' | 'session';
|
|
14
|
+
/** 事件类型采样率配置 */
|
|
15
|
+
type TypeRates = Record<string, number>;
|
|
16
|
+
interface SamplingPluginOptions {
|
|
17
|
+
/** 默认采样率 0-1,默认 1.0(全量) */
|
|
18
|
+
rate?: number;
|
|
19
|
+
/** 采样模式,默认 'session' */
|
|
20
|
+
mode?: SamplingMode;
|
|
21
|
+
/** 按事件类型的采样率(覆盖默认) */
|
|
22
|
+
typeRates?: TypeRates;
|
|
23
|
+
/** 始终采样的事件类型(不受采样率影响) */
|
|
24
|
+
alwaysSample?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 采样插件
|
|
28
|
+
*/
|
|
29
|
+
declare class SamplingPlugin implements Plugin {
|
|
30
|
+
name: string;
|
|
31
|
+
priority: number;
|
|
32
|
+
private _rate;
|
|
33
|
+
private _mode;
|
|
34
|
+
private _typeRates;
|
|
35
|
+
private _alwaysSample;
|
|
36
|
+
private _shouldSample;
|
|
37
|
+
constructor(options?: SamplingPluginOptions);
|
|
38
|
+
/**
|
|
39
|
+
* 插件初始化
|
|
40
|
+
*/
|
|
41
|
+
setupOnce(_monitor: IMonitor): void;
|
|
42
|
+
/**
|
|
43
|
+
* 事件处理:采样过滤
|
|
44
|
+
*/
|
|
45
|
+
processEvent(event: MonitorEvent): MonitorEvent | null;
|
|
46
|
+
/**
|
|
47
|
+
* 决定是否采样(用户/会话级)
|
|
48
|
+
*/
|
|
49
|
+
private _decideSampling;
|
|
50
|
+
/**
|
|
51
|
+
* 重置采样决策(新会话时调用)
|
|
52
|
+
*/
|
|
53
|
+
resetSampling(): void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { type SamplingMode, SamplingPlugin, type SamplingPluginOptions, type TypeRates };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"sampling.js"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk6YTKBMJD_cjs=require('../chunk-6YTKBMJD.cjs');require('../chunk-Y46XWPAC.cjs');Object.defineProperty(exports,"Session",{enumerable:true,get:function(){return chunk6YTKBMJD_cjs.a}});Object.defineProperty(exports,"SessionPlugin",{enumerable:true,get:function(){return chunk6YTKBMJD_cjs.b}});//# sourceMappingURL=session.cjs.map
|
|
2
|
+
//# sourceMappingURL=session.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"session.cjs"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { I as IMonitor, P as Plugin, a as MonitorEvent } from '../types-BGUJGEpp.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Session 插件类型定义
|
|
5
|
+
*/
|
|
6
|
+
/** 会话统计数据 */
|
|
7
|
+
interface SessionStats {
|
|
8
|
+
/** 会话 ID */
|
|
9
|
+
sessionId: string;
|
|
10
|
+
/** 会话时长(毫秒) */
|
|
11
|
+
duration: number;
|
|
12
|
+
/** 对话轮次 */
|
|
13
|
+
traceCount: number;
|
|
14
|
+
/** 工具使用频次 */
|
|
15
|
+
toolUsage: Record<string, number>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Session 类 - 会话级埋点
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 会话管理类
|
|
24
|
+
*/
|
|
25
|
+
declare class Session {
|
|
26
|
+
private _sessionId;
|
|
27
|
+
private _startTime;
|
|
28
|
+
private _traceCount;
|
|
29
|
+
private _toolUsage;
|
|
30
|
+
private _visible;
|
|
31
|
+
private _monitor;
|
|
32
|
+
private _ended;
|
|
33
|
+
constructor(monitor: IMonitor);
|
|
34
|
+
get sessionId(): string;
|
|
35
|
+
get id(): string;
|
|
36
|
+
get ended(): boolean;
|
|
37
|
+
start(): void;
|
|
38
|
+
end(): void;
|
|
39
|
+
incrementTraceCount(): void;
|
|
40
|
+
incrementToolUsage(toolName: string): void;
|
|
41
|
+
setVisible(visible: boolean): void;
|
|
42
|
+
getStats(): SessionStats;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Session 插件 - 会话管理
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Session 插件
|
|
51
|
+
* 提供会话级埋点能力
|
|
52
|
+
*/
|
|
53
|
+
declare class SessionPlugin implements Plugin {
|
|
54
|
+
name: string;
|
|
55
|
+
priority: number;
|
|
56
|
+
private _session;
|
|
57
|
+
private _platformAdapter;
|
|
58
|
+
constructor();
|
|
59
|
+
/**
|
|
60
|
+
* 插件初始化
|
|
61
|
+
*/
|
|
62
|
+
setupOnce(monitor: IMonitor): void;
|
|
63
|
+
/**
|
|
64
|
+
* 事件处理:关联 sessionId
|
|
65
|
+
*/
|
|
66
|
+
processEvent(event: MonitorEvent): MonitorEvent;
|
|
67
|
+
/**
|
|
68
|
+
* 插件销毁
|
|
69
|
+
*/
|
|
70
|
+
teardown(): void;
|
|
71
|
+
private _setupAutoListeners;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { Session, SessionPlugin, type SessionStats };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { I as IMonitor, P as Plugin, a as MonitorEvent } from '../types-BGUJGEpp.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Session 插件类型定义
|
|
5
|
+
*/
|
|
6
|
+
/** 会话统计数据 */
|
|
7
|
+
interface SessionStats {
|
|
8
|
+
/** 会话 ID */
|
|
9
|
+
sessionId: string;
|
|
10
|
+
/** 会话时长(毫秒) */
|
|
11
|
+
duration: number;
|
|
12
|
+
/** 对话轮次 */
|
|
13
|
+
traceCount: number;
|
|
14
|
+
/** 工具使用频次 */
|
|
15
|
+
toolUsage: Record<string, number>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Session 类 - 会话级埋点
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 会话管理类
|
|
24
|
+
*/
|
|
25
|
+
declare class Session {
|
|
26
|
+
private _sessionId;
|
|
27
|
+
private _startTime;
|
|
28
|
+
private _traceCount;
|
|
29
|
+
private _toolUsage;
|
|
30
|
+
private _visible;
|
|
31
|
+
private _monitor;
|
|
32
|
+
private _ended;
|
|
33
|
+
constructor(monitor: IMonitor);
|
|
34
|
+
get sessionId(): string;
|
|
35
|
+
get id(): string;
|
|
36
|
+
get ended(): boolean;
|
|
37
|
+
start(): void;
|
|
38
|
+
end(): void;
|
|
39
|
+
incrementTraceCount(): void;
|
|
40
|
+
incrementToolUsage(toolName: string): void;
|
|
41
|
+
setVisible(visible: boolean): void;
|
|
42
|
+
getStats(): SessionStats;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Session 插件 - 会话管理
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Session 插件
|
|
51
|
+
* 提供会话级埋点能力
|
|
52
|
+
*/
|
|
53
|
+
declare class SessionPlugin implements Plugin {
|
|
54
|
+
name: string;
|
|
55
|
+
priority: number;
|
|
56
|
+
private _session;
|
|
57
|
+
private _platformAdapter;
|
|
58
|
+
constructor();
|
|
59
|
+
/**
|
|
60
|
+
* 插件初始化
|
|
61
|
+
*/
|
|
62
|
+
setupOnce(monitor: IMonitor): void;
|
|
63
|
+
/**
|
|
64
|
+
* 事件处理:关联 sessionId
|
|
65
|
+
*/
|
|
66
|
+
processEvent(event: MonitorEvent): MonitorEvent;
|
|
67
|
+
/**
|
|
68
|
+
* 插件销毁
|
|
69
|
+
*/
|
|
70
|
+
teardown(): void;
|
|
71
|
+
private _setupAutoListeners;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { Session, SessionPlugin, type SessionStats };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"session.js"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk5VYMD33V_cjs=require('../chunk-5VYMD33V.cjs');require('../chunk-Y46XWPAC.cjs');Object.defineProperty(exports,"Trace",{enumerable:true,get:function(){return chunk5VYMD33V_cjs.a}});Object.defineProperty(exports,"TracePlugin",{enumerable:true,get:function(){return chunk5VYMD33V_cjs.b}});//# sourceMappingURL=trace.cjs.map
|
|
2
|
+
//# sourceMappingURL=trace.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"trace.cjs"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { I as IMonitor, P as Plugin, a as MonitorEvent } from '../types-BGUJGEpp.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Trace 插件类型定义
|
|
5
|
+
*/
|
|
6
|
+
/** Trace 配置选项 */
|
|
7
|
+
interface TraceOptions {
|
|
8
|
+
/** AI 消息 ID */
|
|
9
|
+
aiMessageId: string;
|
|
10
|
+
}
|
|
11
|
+
/** 扩展的 Trace 配置选项 */
|
|
12
|
+
interface TraceOptionsExtended extends TraceOptions {
|
|
13
|
+
/** 重试时的前一个 traceId */
|
|
14
|
+
previousTraceId?: string;
|
|
15
|
+
/** 卡顿检测阈值(毫秒),默认 5000 */
|
|
16
|
+
stallThreshold?: number;
|
|
17
|
+
}
|
|
18
|
+
/** Trace 状态 */
|
|
19
|
+
type TraceState = 'idle' | 'started' | 'ended';
|
|
20
|
+
/** 对话阶段 */
|
|
21
|
+
type Phase = 'thinking' | 'answer';
|
|
22
|
+
/** 工具调用结果 */
|
|
23
|
+
interface ToolResult {
|
|
24
|
+
/** 是否成功 */
|
|
25
|
+
success: boolean;
|
|
26
|
+
/** 工具调用 ID(用于匹配并发工具) */
|
|
27
|
+
toolCallId?: string;
|
|
28
|
+
/** 图片 URL(generate_image 结果) */
|
|
29
|
+
imageUrl?: string;
|
|
30
|
+
/** 图片宽度 */
|
|
31
|
+
width?: number;
|
|
32
|
+
/** 图片高度 */
|
|
33
|
+
height?: number;
|
|
34
|
+
/** 搜索结果数量 */
|
|
35
|
+
resultCount?: number;
|
|
36
|
+
/** 搜索来源 */
|
|
37
|
+
sources?: Array<{
|
|
38
|
+
title: string;
|
|
39
|
+
url: string;
|
|
40
|
+
snippet?: string;
|
|
41
|
+
}>;
|
|
42
|
+
/** 失败原因 */
|
|
43
|
+
error?: string;
|
|
44
|
+
}
|
|
45
|
+
/** 图片加载结果 */
|
|
46
|
+
interface ImageLoadResult {
|
|
47
|
+
/** 是否成功 */
|
|
48
|
+
success: boolean;
|
|
49
|
+
/** 图片大小(字节) */
|
|
50
|
+
size?: number;
|
|
51
|
+
/** 失败原因 */
|
|
52
|
+
error?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Trace 类 - SSE 链路追踪
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* SSE 链路追踪类
|
|
61
|
+
*/
|
|
62
|
+
declare class Trace {
|
|
63
|
+
private _traceId;
|
|
64
|
+
private _aiMessageId;
|
|
65
|
+
private _state;
|
|
66
|
+
private _monitor;
|
|
67
|
+
private _startTime;
|
|
68
|
+
private _firstChunkTime;
|
|
69
|
+
private _phases;
|
|
70
|
+
private _tools;
|
|
71
|
+
private _imageLoads;
|
|
72
|
+
private _previousTraceId?;
|
|
73
|
+
private _lastChunkTime;
|
|
74
|
+
private _stallTimer;
|
|
75
|
+
private _stallThreshold;
|
|
76
|
+
private _isStalled;
|
|
77
|
+
constructor(monitor: IMonitor, options: TraceOptions | TraceOptionsExtended);
|
|
78
|
+
get id(): string;
|
|
79
|
+
get traceId(): string;
|
|
80
|
+
get state(): TraceState;
|
|
81
|
+
start(): void;
|
|
82
|
+
firstChunk(): void;
|
|
83
|
+
complete(): void;
|
|
84
|
+
error(message: string): void;
|
|
85
|
+
abort(reason?: string): void;
|
|
86
|
+
phaseStart(phase: Phase): void;
|
|
87
|
+
phaseEnd(phase: Phase): void;
|
|
88
|
+
toolStart(name: string, args?: Record<string, unknown>, externalToolCallId?: string): string;
|
|
89
|
+
toolEnd(name: string, result: ToolResult): void;
|
|
90
|
+
imageLoadStart(imageUrl: string): void;
|
|
91
|
+
imageLoadEnd(imageUrl: string, result: ImageLoadResult): void;
|
|
92
|
+
recordChunk(): void;
|
|
93
|
+
private _startStallDetection;
|
|
94
|
+
private _stopStallDetection;
|
|
95
|
+
private _onStall;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Trace 插件 - AI 对话链路追踪
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Trace 插件
|
|
104
|
+
* 提供 AI 对话链路追踪能力
|
|
105
|
+
*/
|
|
106
|
+
declare class TracePlugin implements Plugin {
|
|
107
|
+
name: string;
|
|
108
|
+
priority: number;
|
|
109
|
+
private _monitor;
|
|
110
|
+
private _currentTrace;
|
|
111
|
+
/**
|
|
112
|
+
* 插件初始化
|
|
113
|
+
*/
|
|
114
|
+
setupOnce(monitor: IMonitor): void;
|
|
115
|
+
/**
|
|
116
|
+
* 事件处理:关联 traceId
|
|
117
|
+
*/
|
|
118
|
+
processEvent(event: MonitorEvent): MonitorEvent;
|
|
119
|
+
/**
|
|
120
|
+
* 插件销毁
|
|
121
|
+
*/
|
|
122
|
+
teardown(): void;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { type ImageLoadResult, type Phase, type ToolResult, Trace, type TraceOptions, type TraceOptionsExtended, TracePlugin, type TraceState };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { I as IMonitor, P as Plugin, a as MonitorEvent } from '../types-BGUJGEpp.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Trace 插件类型定义
|
|
5
|
+
*/
|
|
6
|
+
/** Trace 配置选项 */
|
|
7
|
+
interface TraceOptions {
|
|
8
|
+
/** AI 消息 ID */
|
|
9
|
+
aiMessageId: string;
|
|
10
|
+
}
|
|
11
|
+
/** 扩展的 Trace 配置选项 */
|
|
12
|
+
interface TraceOptionsExtended extends TraceOptions {
|
|
13
|
+
/** 重试时的前一个 traceId */
|
|
14
|
+
previousTraceId?: string;
|
|
15
|
+
/** 卡顿检测阈值(毫秒),默认 5000 */
|
|
16
|
+
stallThreshold?: number;
|
|
17
|
+
}
|
|
18
|
+
/** Trace 状态 */
|
|
19
|
+
type TraceState = 'idle' | 'started' | 'ended';
|
|
20
|
+
/** 对话阶段 */
|
|
21
|
+
type Phase = 'thinking' | 'answer';
|
|
22
|
+
/** 工具调用结果 */
|
|
23
|
+
interface ToolResult {
|
|
24
|
+
/** 是否成功 */
|
|
25
|
+
success: boolean;
|
|
26
|
+
/** 工具调用 ID(用于匹配并发工具) */
|
|
27
|
+
toolCallId?: string;
|
|
28
|
+
/** 图片 URL(generate_image 结果) */
|
|
29
|
+
imageUrl?: string;
|
|
30
|
+
/** 图片宽度 */
|
|
31
|
+
width?: number;
|
|
32
|
+
/** 图片高度 */
|
|
33
|
+
height?: number;
|
|
34
|
+
/** 搜索结果数量 */
|
|
35
|
+
resultCount?: number;
|
|
36
|
+
/** 搜索来源 */
|
|
37
|
+
sources?: Array<{
|
|
38
|
+
title: string;
|
|
39
|
+
url: string;
|
|
40
|
+
snippet?: string;
|
|
41
|
+
}>;
|
|
42
|
+
/** 失败原因 */
|
|
43
|
+
error?: string;
|
|
44
|
+
}
|
|
45
|
+
/** 图片加载结果 */
|
|
46
|
+
interface ImageLoadResult {
|
|
47
|
+
/** 是否成功 */
|
|
48
|
+
success: boolean;
|
|
49
|
+
/** 图片大小(字节) */
|
|
50
|
+
size?: number;
|
|
51
|
+
/** 失败原因 */
|
|
52
|
+
error?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Trace 类 - SSE 链路追踪
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* SSE 链路追踪类
|
|
61
|
+
*/
|
|
62
|
+
declare class Trace {
|
|
63
|
+
private _traceId;
|
|
64
|
+
private _aiMessageId;
|
|
65
|
+
private _state;
|
|
66
|
+
private _monitor;
|
|
67
|
+
private _startTime;
|
|
68
|
+
private _firstChunkTime;
|
|
69
|
+
private _phases;
|
|
70
|
+
private _tools;
|
|
71
|
+
private _imageLoads;
|
|
72
|
+
private _previousTraceId?;
|
|
73
|
+
private _lastChunkTime;
|
|
74
|
+
private _stallTimer;
|
|
75
|
+
private _stallThreshold;
|
|
76
|
+
private _isStalled;
|
|
77
|
+
constructor(monitor: IMonitor, options: TraceOptions | TraceOptionsExtended);
|
|
78
|
+
get id(): string;
|
|
79
|
+
get traceId(): string;
|
|
80
|
+
get state(): TraceState;
|
|
81
|
+
start(): void;
|
|
82
|
+
firstChunk(): void;
|
|
83
|
+
complete(): void;
|
|
84
|
+
error(message: string): void;
|
|
85
|
+
abort(reason?: string): void;
|
|
86
|
+
phaseStart(phase: Phase): void;
|
|
87
|
+
phaseEnd(phase: Phase): void;
|
|
88
|
+
toolStart(name: string, args?: Record<string, unknown>, externalToolCallId?: string): string;
|
|
89
|
+
toolEnd(name: string, result: ToolResult): void;
|
|
90
|
+
imageLoadStart(imageUrl: string): void;
|
|
91
|
+
imageLoadEnd(imageUrl: string, result: ImageLoadResult): void;
|
|
92
|
+
recordChunk(): void;
|
|
93
|
+
private _startStallDetection;
|
|
94
|
+
private _stopStallDetection;
|
|
95
|
+
private _onStall;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Trace 插件 - AI 对话链路追踪
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Trace 插件
|
|
104
|
+
* 提供 AI 对话链路追踪能力
|
|
105
|
+
*/
|
|
106
|
+
declare class TracePlugin implements Plugin {
|
|
107
|
+
name: string;
|
|
108
|
+
priority: number;
|
|
109
|
+
private _monitor;
|
|
110
|
+
private _currentTrace;
|
|
111
|
+
/**
|
|
112
|
+
* 插件初始化
|
|
113
|
+
*/
|
|
114
|
+
setupOnce(monitor: IMonitor): void;
|
|
115
|
+
/**
|
|
116
|
+
* 事件处理:关联 traceId
|
|
117
|
+
*/
|
|
118
|
+
processEvent(event: MonitorEvent): MonitorEvent;
|
|
119
|
+
/**
|
|
120
|
+
* 插件销毁
|
|
121
|
+
*/
|
|
122
|
+
teardown(): void;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { type ImageLoadResult, type Phase, type ToolResult, Trace, type TraceOptions, type TraceOptionsExtended, TracePlugin, type TraceState };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"trace.js"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkJMHMJVBJ_cjs=require('../chunk-JMHMJVBJ.cjs');require('../chunk-BVOILM65.cjs');Object.defineProperty(exports,"PriorityQueue",{enumerable:true,get:function(){return chunkJMHMJVBJ_cjs.b}});Object.defineProperty(exports,"RetryScheduler",{enumerable:true,get:function(){return chunkJMHMJVBJ_cjs.c}});Object.defineProperty(exports,"TransportPlugin",{enumerable:true,get:function(){return chunkJMHMJVBJ_cjs.d}});//# sourceMappingURL=transport.cjs.map
|
|
2
|
+
//# sourceMappingURL=transport.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"transport.cjs"}
|