@vibe-lark/larkpal 0.1.64 → 0.1.65

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.
Files changed (2) hide show
  1. package/dist/main.mjs +31 -3
  2. package/package.json +1 -1
package/dist/main.mjs CHANGED
@@ -3777,6 +3777,30 @@ function serializeChatRun(run) {
3777
3777
  staleReason: run.staleReason
3778
3778
  };
3779
3779
  }
3780
+ function serializeRuntimeProcessInfo(processInfo, processManager) {
3781
+ return {
3782
+ ...processInfo,
3783
+ startedAt: processInfo.startedAt.toISOString(),
3784
+ lastActiveAt: processInfo.lastActiveAt.toISOString(),
3785
+ busy: processManager.isSessionBusy?.(processInfo.sessionId) ?? processInfo.status === "running"
3786
+ };
3787
+ }
3788
+ function buildOrphanedRunDiagnostic(sessionId, processManager) {
3789
+ const processInfo = processManager.getProcessInfo(sessionId);
3790
+ const adapterBusy = processManager.isSessionBusy?.(sessionId) ?? processInfo?.status === "running";
3791
+ if (!processInfo && !adapterBusy) return null;
3792
+ return {
3793
+ runId: null,
3794
+ sessionId,
3795
+ status: adapterBusy ? "orphaned" : "inconsistent",
3796
+ finalStatus: adapterBusy ? "orphaned" : "inconsistent",
3797
+ reasonCode: "RUN_REGISTRY_MISSING",
3798
+ reason: "Runtime process exists or reports busy, but gateway chat run registry has no visible run for this session.",
3799
+ processStatus: processInfo?.status,
3800
+ adapterBusy,
3801
+ process: processInfo ? serializeRuntimeProcessInfo(processInfo, processManager) : void 0
3802
+ };
3803
+ }
3780
3804
  function getRuntimeEventDedupeKey(event) {
3781
3805
  const record = event;
3782
3806
  const eventId = record.eventId;
@@ -4465,12 +4489,14 @@ function createChatRouter(config) {
4465
4489
  openId: chatUser.openId
4466
4490
  }) ? run : void 0;
4467
4491
  if (visibleRun) await reconcileRunWithAdapter(visibleRun, messageStore, processManager);
4492
+ const runDiagnostic = visibleRun ? null : buildOrphanedRunDiagnostic(sessionId, processManager);
4468
4493
  res.json({
4469
4494
  messages: result.messages,
4470
4495
  nextCursor: result.nextCursor,
4471
4496
  sessionId,
4472
4497
  activeRun: visibleRun?.status === "running" ? serializeChatRun(visibleRun) : null,
4473
- latestRun: visibleRun ? serializeChatRun(visibleRun) : null
4498
+ latestRun: visibleRun ? serializeChatRun(visibleRun) : runDiagnostic,
4499
+ runDiagnostic
4474
4500
  });
4475
4501
  } catch (err) {
4476
4502
  const errorMessage = err instanceof Error ? err.message : String(err);
@@ -4493,10 +4519,12 @@ function createChatRouter(config) {
4493
4519
  tenantKey: chatUser.tenantKey,
4494
4520
  openId: chatUser.openId
4495
4521
  })) {
4522
+ const runDiagnostic = buildOrphanedRunDiagnostic(sessionId, processManager);
4496
4523
  res.json({
4497
4524
  sessionId,
4498
- run: null,
4499
- activeRun: null
4525
+ run: runDiagnostic,
4526
+ activeRun: null,
4527
+ runDiagnostic
4500
4528
  });
4501
4529
  return;
4502
4530
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-lark/larkpal",
3
- "version": "0.1.64",
3
+ "version": "0.1.65",
4
4
  "description": "LarkPal - Lark/Feishu bot service",
5
5
  "type": "module",
6
6
  "main": "./dist/main.mjs",