@vibe-lark/larkpal 0.1.67 → 0.1.68
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 +30 -1
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -3918,6 +3918,32 @@ async function markRunTerminal(run, messageStore, status, params) {
|
|
|
3918
3918
|
await appendRunStatusMessage(run, messageStore);
|
|
3919
3919
|
return true;
|
|
3920
3920
|
}
|
|
3921
|
+
async function cleanupTerminalRunProcess(run, processManager, reason) {
|
|
3922
|
+
if (run.status === "running") return;
|
|
3923
|
+
const processInfo = processManager.getProcessInfo(run.sessionId);
|
|
3924
|
+
const adapterBusy = processManager.isSessionBusy?.(run.sessionId) ?? processInfo?.status === "running";
|
|
3925
|
+
run.adapterBusy = adapterBusy;
|
|
3926
|
+
run.processStatus = processInfo?.status;
|
|
3927
|
+
if (adapterBusy || processInfo?.status !== "running" && processInfo?.status !== "starting") return;
|
|
3928
|
+
try {
|
|
3929
|
+
await processManager.stopProcess(run.sessionId);
|
|
3930
|
+
run.processStatus = processManager.getProcessInfo(run.sessionId)?.status ?? "stopped";
|
|
3931
|
+
log$30.info("[stream] terminal run 已清理 runtime process", {
|
|
3932
|
+
sessionId: run.sessionId,
|
|
3933
|
+
runId: run.runId,
|
|
3934
|
+
reason,
|
|
3935
|
+
processStatus: processInfo.status
|
|
3936
|
+
});
|
|
3937
|
+
} catch (err) {
|
|
3938
|
+
log$30.error("[stream] terminal run 清理 runtime process 失败", {
|
|
3939
|
+
sessionId: run.sessionId,
|
|
3940
|
+
runId: run.runId,
|
|
3941
|
+
reason,
|
|
3942
|
+
processStatus: processInfo.status,
|
|
3943
|
+
error: err instanceof Error ? err.message : String(err)
|
|
3944
|
+
});
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3921
3947
|
async function reconcileRunWithAdapter(run, messageStore, processManager) {
|
|
3922
3948
|
if (run.status !== "running") return;
|
|
3923
3949
|
const processInfo = processManager.getProcessInfo(run.sessionId);
|
|
@@ -4318,6 +4344,7 @@ function createChatRouter(config) {
|
|
|
4318
4344
|
const finalText = run.text.trim() ? run.text : result.result || "";
|
|
4319
4345
|
run.text = finalText;
|
|
4320
4346
|
await markRunTerminal(run, messageStore, result.isError ? "failed" : "completed", { finalStatus: result.subtype });
|
|
4347
|
+
await cleanupTerminalRunProcess(run, processManager, "result");
|
|
4321
4348
|
await queueRunMessage(run, messageStore, {
|
|
4322
4349
|
sessionId,
|
|
4323
4350
|
role: "assistant",
|
|
@@ -4402,6 +4429,7 @@ function createChatRouter(config) {
|
|
|
4402
4429
|
finalStatus: "error",
|
|
4403
4430
|
error: error.message
|
|
4404
4431
|
});
|
|
4432
|
+
await cleanupTerminalRunProcess(run, processManager, "error");
|
|
4405
4433
|
broadcastRunEvent(run, "error", {
|
|
4406
4434
|
runId: run.runId,
|
|
4407
4435
|
message: error.message
|
|
@@ -4473,13 +4501,14 @@ function createChatRouter(config) {
|
|
|
4473
4501
|
finalStatus: "error",
|
|
4474
4502
|
error: errorMessage
|
|
4475
4503
|
});
|
|
4504
|
+
await cleanupTerminalRunProcess(run, processManager, "missing-result");
|
|
4476
4505
|
broadcastRunEvent(run, "error", {
|
|
4477
4506
|
runId: run.runId,
|
|
4478
4507
|
message: errorMessage
|
|
4479
4508
|
});
|
|
4480
4509
|
clearInterval(heartbeatTimer);
|
|
4481
4510
|
endRunClients(run);
|
|
4482
|
-
}
|
|
4511
|
+
} else await cleanupTerminalRunProcess(run, processManager, "execute-returned");
|
|
4483
4512
|
} catch (err) {
|
|
4484
4513
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
4485
4514
|
log$30.error("[stream] executePrompt 异常", {
|