@vibe-lark/larkpal 0.1.22 → 0.1.23
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/dist/main.mjs +51 -1
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -957,10 +957,15 @@ var SessionProcessManager = class {
|
|
|
957
957
|
*/
|
|
958
958
|
async executePrompt(config, callbacks) {
|
|
959
959
|
const { sessionId } = config;
|
|
960
|
+
const t0 = Date.now();
|
|
960
961
|
const prevLock = this.sessionLocks.get(sessionId);
|
|
961
962
|
if (prevLock) {
|
|
962
963
|
log$25.info("等待上一条消息处理完成", { sessionId });
|
|
963
964
|
await prevLock;
|
|
965
|
+
log$25.info("[perf] 串行锁等待完成", {
|
|
966
|
+
sessionId,
|
|
967
|
+
waitMs: Date.now() - t0
|
|
968
|
+
});
|
|
964
969
|
}
|
|
965
970
|
const completionPromise = this.createMessageCompletionPromise(sessionId);
|
|
966
971
|
this.sessionLocks.set(sessionId, completionPromise);
|
|
@@ -970,11 +975,16 @@ var SessionProcessManager = class {
|
|
|
970
975
|
log$25.info("向常驻进程发送消息", {
|
|
971
976
|
sessionId,
|
|
972
977
|
promptLength: config.prompt.length,
|
|
973
|
-
pid: existing.childProcess.pid
|
|
978
|
+
pid: existing.childProcess.pid,
|
|
979
|
+
prepareMs: Date.now() - t0
|
|
974
980
|
});
|
|
975
981
|
this.sendMessage(sessionId, config.prompt);
|
|
976
982
|
this.resetIdleTimer(sessionId);
|
|
977
983
|
await completionPromise;
|
|
984
|
+
log$25.info("[perf] executePrompt 完成(热进程)", {
|
|
985
|
+
sessionId,
|
|
986
|
+
totalMs: Date.now() - t0
|
|
987
|
+
});
|
|
978
988
|
return;
|
|
979
989
|
}
|
|
980
990
|
if (existing && (existing.status === "stopped" || existing.status === "crashed")) {
|
|
@@ -990,8 +1000,17 @@ var SessionProcessManager = class {
|
|
|
990
1000
|
await this.stopProcess(sessionId);
|
|
991
1001
|
this.sessionLocks.set(sessionId, completionPromise);
|
|
992
1002
|
}
|
|
1003
|
+
const tStart = Date.now();
|
|
993
1004
|
await this.startPersistentProcess(config);
|
|
1005
|
+
log$25.info("[perf] 冷启动进程完成", {
|
|
1006
|
+
sessionId,
|
|
1007
|
+
coldStartMs: Date.now() - tStart
|
|
1008
|
+
});
|
|
994
1009
|
await completionPromise;
|
|
1010
|
+
log$25.info("[perf] executePrompt 完成(冷启动)", {
|
|
1011
|
+
sessionId,
|
|
1012
|
+
totalMs: Date.now() - t0
|
|
1013
|
+
});
|
|
995
1014
|
}
|
|
996
1015
|
/**
|
|
997
1016
|
* 启动常驻 CC 进程
|
|
@@ -1207,10 +1226,31 @@ var SessionProcessManager = class {
|
|
|
1207
1226
|
*/
|
|
1208
1227
|
bindParserToCallbackProxy(parser, sessionId) {
|
|
1209
1228
|
const getCallbacks = () => this.activeCallbacks.get(sessionId);
|
|
1229
|
+
let firstTokenLogged = false;
|
|
1230
|
+
let messageSentAt = Date.now();
|
|
1231
|
+
const proc = this.processes.get(sessionId);
|
|
1232
|
+
if (proc) proc._resetPerfTimer = () => {
|
|
1233
|
+
firstTokenLogged = false;
|
|
1234
|
+
messageSentAt = Date.now();
|
|
1235
|
+
};
|
|
1210
1236
|
parser.on("textDelta", (text) => {
|
|
1237
|
+
if (!firstTokenLogged) {
|
|
1238
|
+
firstTokenLogged = true;
|
|
1239
|
+
log$25.info("[perf] 首 token (text)", {
|
|
1240
|
+
sessionId,
|
|
1241
|
+
ttftMs: Date.now() - messageSentAt
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1211
1244
|
getCallbacks()?.onTextDelta?.(text);
|
|
1212
1245
|
});
|
|
1213
1246
|
parser.on("thinkingDelta", (text) => {
|
|
1247
|
+
if (!firstTokenLogged) {
|
|
1248
|
+
firstTokenLogged = true;
|
|
1249
|
+
log$25.info("[perf] 首 token (thinking)", {
|
|
1250
|
+
sessionId,
|
|
1251
|
+
ttftMs: Date.now() - messageSentAt
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1214
1254
|
getCallbacks()?.onThinkingDelta?.(text);
|
|
1215
1255
|
});
|
|
1216
1256
|
parser.on("toolUseStart", (toolName, toolInput) => {
|
|
@@ -1223,9 +1263,18 @@ var SessionProcessManager = class {
|
|
|
1223
1263
|
getCallbacks()?.onToolProgress?.(toolName, elapsedSeconds);
|
|
1224
1264
|
});
|
|
1225
1265
|
parser.on("turnEnd", (stopReason) => {
|
|
1266
|
+
log$25.info("[perf] turnEnd", {
|
|
1267
|
+
sessionId,
|
|
1268
|
+
stopReason,
|
|
1269
|
+
sinceMessageMs: Date.now() - messageSentAt
|
|
1270
|
+
});
|
|
1226
1271
|
getCallbacks()?.onTurnEnd?.(stopReason);
|
|
1227
1272
|
});
|
|
1228
1273
|
parser.on("result", (result) => {
|
|
1274
|
+
log$25.info("[perf] result 事件", {
|
|
1275
|
+
sessionId,
|
|
1276
|
+
sinceMessageMs: Date.now() - messageSentAt
|
|
1277
|
+
});
|
|
1229
1278
|
getCallbacks()?.onResult?.(result);
|
|
1230
1279
|
this.resolveMessageCompletion(sessionId);
|
|
1231
1280
|
});
|
|
@@ -1249,6 +1298,7 @@ var SessionProcessManager = class {
|
|
|
1249
1298
|
log$25.error("无法发送消息:进程不存在或 stdin 不可用", { sessionId });
|
|
1250
1299
|
return;
|
|
1251
1300
|
}
|
|
1301
|
+
proc._resetPerfTimer?.();
|
|
1252
1302
|
const userMessageId = v4();
|
|
1253
1303
|
this.lastUserMessageIds.set(sessionId, userMessageId);
|
|
1254
1304
|
const payload = JSON.stringify({
|