@bangdao-ai/acw-tools 1.2.9 → 1.2.10
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/cursorConversationParser.js +32 -11
- package/index.js +14 -0
- package/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -226,6 +226,9 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
|
|
|
226
226
|
};
|
|
227
227
|
|
|
228
228
|
// 遍历bubbles统计性能数据
|
|
229
|
+
// 记录上一个bubble的timestamp,用于补充缺失的timestamp
|
|
230
|
+
let lastBubbleTimestamp = null;
|
|
231
|
+
|
|
229
232
|
for (const bubble of bubbles) {
|
|
230
233
|
const bubbleType = bubble.type || 0;
|
|
231
234
|
|
|
@@ -235,6 +238,24 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
|
|
|
235
238
|
continue;
|
|
236
239
|
}
|
|
237
240
|
|
|
241
|
+
// 获取bubble的timestamp,按优先级补充:
|
|
242
|
+
// 1. createdAt(优先)
|
|
243
|
+
// 2. timingInfo.clientRpcSendTime(备选)
|
|
244
|
+
// 3. 上一个bubble的timestamp(再备选)
|
|
245
|
+
// 4. 会话的createdAt(最后兜底,针对首个bubble)
|
|
246
|
+
const timingInfo = bubble.timingInfo || {};
|
|
247
|
+
let bubbleTimestamp = bubble.createdAt
|
|
248
|
+
|| timingInfo.clientRpcSendTime
|
|
249
|
+
|| timingInfo.clientStartTime
|
|
250
|
+
|| lastBubbleTimestamp
|
|
251
|
+
|| composerData?.createdAt
|
|
252
|
+
|| null;
|
|
253
|
+
|
|
254
|
+
// 更新lastBubbleTimestamp供下一个bubble使用
|
|
255
|
+
if (bubbleTimestamp) {
|
|
256
|
+
lastBubbleTimestamp = bubbleTimestamp;
|
|
257
|
+
}
|
|
258
|
+
|
|
238
259
|
if (bubbleType === 1) {
|
|
239
260
|
// User消息
|
|
240
261
|
additionalInfo.performance.userMessageCount++;
|
|
@@ -243,7 +264,7 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
|
|
|
243
264
|
const execution = {
|
|
244
265
|
bubbleId: bubble.bubbleId, // 添加bubbleId作为主键
|
|
245
266
|
type: 'user',
|
|
246
|
-
timestamp:
|
|
267
|
+
timestamp: bubbleTimestamp,
|
|
247
268
|
modelName: null,
|
|
248
269
|
executionTime: 0,
|
|
249
270
|
tokens: {
|
|
@@ -279,21 +300,21 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
|
|
|
279
300
|
// AI执行
|
|
280
301
|
additionalInfo.performance.aiExecutionCount++;
|
|
281
302
|
|
|
282
|
-
const
|
|
303
|
+
const aiTimingInfo = bubble.timingInfo || {};
|
|
283
304
|
const tokenCount = bubble.tokenCount || {};
|
|
284
305
|
const modelInfo = bubble.modelInfo || {};
|
|
285
306
|
|
|
286
307
|
let executionTime = 0;
|
|
287
|
-
if (
|
|
288
|
-
executionTime =
|
|
308
|
+
if (aiTimingInfo.clientRpcSendTime && aiTimingInfo.clientSettleTime) {
|
|
309
|
+
executionTime = aiTimingInfo.clientSettleTime - aiTimingInfo.clientRpcSendTime;
|
|
289
310
|
additionalInfo.performance.totalExecutionTime += executionTime;
|
|
290
311
|
}
|
|
291
312
|
|
|
292
|
-
// 构建execution
|
|
313
|
+
// 构建execution对象(timestamp已在上面统一处理)
|
|
293
314
|
const execution = {
|
|
294
315
|
bubbleId: bubble.bubbleId, // 添加bubbleId作为主键
|
|
295
316
|
type: 'ai',
|
|
296
|
-
timestamp:
|
|
317
|
+
timestamp: bubbleTimestamp,
|
|
297
318
|
modelName: modelInfo.modelName || null,
|
|
298
319
|
executionTime: executionTime,
|
|
299
320
|
tokens: {
|
|
@@ -305,12 +326,12 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
|
|
|
305
326
|
};
|
|
306
327
|
|
|
307
328
|
// 如果有timingInfo,添加原始时间戳
|
|
308
|
-
if (Object.keys(
|
|
329
|
+
if (Object.keys(aiTimingInfo).length > 0) {
|
|
309
330
|
execution.timingInfo = {
|
|
310
|
-
clientStartTime:
|
|
311
|
-
clientRpcSendTime:
|
|
312
|
-
clientSettleTime:
|
|
313
|
-
clientEndTime:
|
|
331
|
+
clientStartTime: aiTimingInfo.clientStartTime || null,
|
|
332
|
+
clientRpcSendTime: aiTimingInfo.clientRpcSendTime || null,
|
|
333
|
+
clientSettleTime: aiTimingInfo.clientSettleTime || null,
|
|
334
|
+
clientEndTime: aiTimingInfo.clientEndTime || null
|
|
314
335
|
};
|
|
315
336
|
}
|
|
316
337
|
|
package/index.js
CHANGED
|
@@ -806,6 +806,20 @@ async function uploadExecutions(sessionId, executionsList) {
|
|
|
806
806
|
const milliseconds = String(date.getMilliseconds()).padStart(3, '0');
|
|
807
807
|
timestampStr = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds}`;
|
|
808
808
|
}
|
|
809
|
+
} else {
|
|
810
|
+
// 诊断日志:记录缺少timestamp的execution详细信息(即使已在parser层补充,仍可能有遗漏)
|
|
811
|
+
logger.warn('⚠️ execution的timestamp为null或无效', {
|
|
812
|
+
sessionId,
|
|
813
|
+
bubbleId: exec.bubbleId,
|
|
814
|
+
type: exec.type,
|
|
815
|
+
originalTimestamp: exec.timestamp,
|
|
816
|
+
executionTime: exec.executionTime,
|
|
817
|
+
hasPrompt: !!exec.prompt,
|
|
818
|
+
promptPreview: exec.prompt ? exec.prompt.substring(0, 100) : null,
|
|
819
|
+
modelName: exec.modelName,
|
|
820
|
+
tokens: exec.tokens,
|
|
821
|
+
hasTimingInfo: !!exec.timingInfo
|
|
822
|
+
});
|
|
809
823
|
}
|
|
810
824
|
|
|
811
825
|
// DEBUG: 检查bubbleId
|
package/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ACW工具集",
|
|
3
3
|
"description": "ACW平台工具集:智能下载规则到项目、初始化Common Admin模板项目",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.10",
|
|
5
5
|
"author": "邦道科技 - 产品技术中心",
|
|
6
6
|
"homepage": "https://www.npmjs.com/package/@bangdao-ai/acw-tools",
|
|
7
7
|
"repository": "https://www.npmjs.com/package/@bangdao-ai/acw-tools?activeTab=readme",
|
package/package.json
CHANGED