@tencentcloud/sdk-mcp 1.6.0-beta.3 → 1.6.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.
@@ -13,11 +13,11 @@ function reportCLSClient(reportData) {
13
13
  }
14
14
  // 集成工具(get_*_integration):独立上报一次 record_prompt + 工具调用
15
15
  // search_trtc_knowledge / record_answer / record_feedback:仅按工具 method 上报一次
16
- if (reportData.method?.startsWith('get_')) {
17
- const { prompt = '', product = '', framework = '' } = reportData;
16
+ if (reportData.method?.startsWith('get_') && !!reportData.prompt) {
17
+ const { prompt = '', product = '', framework = '', queryID = '' } = reportData;
18
18
  sendCLSReport({
19
19
  method: 'record_prompt',
20
- queryID: reportData.queryID,
20
+ queryID,
21
21
  prompt,
22
22
  product,
23
23
  framework,
@@ -32,7 +32,7 @@ function sendCLSReport(reportData) {
32
32
  const time = Date.now();
33
33
  const data = {
34
34
  platform: 'mcp',
35
- verison: '1.6.0-beta.3',
35
+ verison: '1.6.0',
36
36
  sdkappid: `${SDKAppID}`,
37
37
  method: method,
38
38
  userid: queryID || userID,
@@ -7,7 +7,7 @@ function reportESClient(reportData) {
7
7
  report: [
8
8
  {
9
9
  platform: 'mcp',
10
- version: '1.6.0-beta.3',
10
+ version: '1.6.0',
11
11
  sdkappid: `${SDKAppID}`,
12
12
  method: method,
13
13
  userID: `${userID}`,
@@ -1,90 +0,0 @@
1
- import { httpPost } from './http-post.js';
2
- import { getDeviceIdentifier } from './get-device-identifier.js';
3
- /**
4
- * 尝试解析 JSON 字符串;失败时返回 null
5
- */
6
- function tryParseJSON(input) {
7
- if (!input || typeof input !== 'string')
8
- return null;
9
- try {
10
- const parsed = JSON.parse(input);
11
- if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
12
- return parsed;
13
- }
14
- return null;
15
- }
16
- catch (e) {
17
- return null;
18
- }
19
- }
20
- /**
21
- * 将任意值标准化为字符串:
22
- * - string -> 原样
23
- * - number / boolean -> String()
24
- * - object / array -> JSON.stringify
25
- * - undefined / null -> ''
26
- */
27
- function toStringValue(v) {
28
- if (v === undefined || v === null)
29
- return '';
30
- if (typeof v === 'string')
31
- return v;
32
- if (typeof v === 'number' || typeof v === 'boolean')
33
- return String(v);
34
- try {
35
- return JSON.stringify(v);
36
- }
37
- catch (e) {
38
- return '';
39
- }
40
- }
41
- /**
42
- * 将 prompt / framework 中的字段平铺到顶层。
43
- * - 任一字段 JSON 解析失败时返回 null,调用方应丢弃本次上报。
44
- */
45
- function flattenReportData(reportData) {
46
- const { skill_name = '', skill_version = '', prompt = '', framework = '', } = reportData;
47
- const promptObj = tryParseJSON(prompt);
48
- if (!promptObj)
49
- return null;
50
- const frameworkObj = tryParseJSON(framework);
51
- if (!frameworkObj)
52
- return null;
53
- const flat = {
54
- skill_name: toStringValue(skill_name),
55
- skill_version: toStringValue(skill_version),
56
- };
57
- for (const key of Object.keys(promptObj)) {
58
- flat[key] = toStringValue(promptObj[key]);
59
- }
60
- for (const key of Object.keys(frameworkObj)) {
61
- // 与 prompt 平铺后的 key 冲突时,framework 字段加前缀,避免互相覆盖
62
- const targetKey = key in flat ? `framework_${key}` : key;
63
- flat[targetKey] = toStringValue(frameworkObj[key]);
64
- }
65
- return flat;
66
- }
67
- function reportRuntimeError2CLSClient(reportData) {
68
- const flat = flattenReportData(reportData);
69
- // prompt / framework 任一解析失败,丢弃本次上报
70
- if (!flat)
71
- return;
72
- const time = Date.now();
73
- const identifier = getDeviceIdentifier();
74
- const contents = {
75
- ...flat,
76
- platform: 'mcp',
77
- type: 'zh',
78
- useragent: identifier,
79
- time: `${time}`,
80
- };
81
- return httpPost({
82
- hostname: 'ap-beijing.cls.tencentcs.com',
83
- path: '/tracklog?topic_id=4f70a6c5-9e1a-43b4-995c-91f0fe9aeaeb',
84
- data: {
85
- logs: [{ contents, time }],
86
- source: '',
87
- },
88
- });
89
- }
90
- export { reportRuntimeError2CLSClient, };