@colinlu50/openclaw-lark-stream 260328.1.1 → 260328.1.2

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/index.js CHANGED
@@ -115681,31 +115681,38 @@ var init_streaming_card_controller = __esm({
115681
115681
  return footer.tokens || footer.cache || footer.context || footer.model;
115682
115682
  }
115683
115683
  async getFooterSessionMetrics() {
115684
- try {
115685
- const storePath = path3.join(homedir(), ".openclaw", "agents", this.deps.agentId, "sessions", "sessions.json");
115686
- const raw = await readFile(storePath, "utf8");
115687
- const store2 = JSON.parse(raw);
115688
- const key = this.deps.sessionKey.trim().toLowerCase();
115689
- const prefixedKey = `agent:${this.deps.agentId}:${key}`;
115690
- const entry = store2[prefixedKey] ?? store2[key];
115691
- if (!entry || typeof entry !== "object") {
115692
- log17.debug("footer metrics: session entry not found", { prefixedKey, key });
115684
+ const storePath = path3.join(homedir(), ".openclaw", "agents", this.deps.agentId, "sessions", "sessions.json");
115685
+ const key = this.deps.sessionKey.trim().toLowerCase();
115686
+ const prefixedKey = `agent:${this.deps.agentId}:${key}`;
115687
+ const readMetrics = /* @__PURE__ */ __name(async () => {
115688
+ try {
115689
+ const raw = await readFile(storePath, "utf8");
115690
+ const store2 = JSON.parse(raw);
115691
+ const entry = store2[prefixedKey] ?? store2[key];
115692
+ if (!entry || typeof entry !== "object") {
115693
+ log17.debug("footer metrics: session entry not found", { prefixedKey, key });
115694
+ return void 0;
115695
+ }
115696
+ return {
115697
+ inputTokens: typeof entry.inputTokens === "number" ? entry.inputTokens : void 0,
115698
+ outputTokens: typeof entry.outputTokens === "number" ? entry.outputTokens : void 0,
115699
+ cacheRead: typeof entry.cacheRead === "number" ? entry.cacheRead : void 0,
115700
+ cacheWrite: typeof entry.cacheWrite === "number" ? entry.cacheWrite : void 0,
115701
+ totalTokens: typeof entry.totalTokens === "number" ? entry.totalTokens : void 0,
115702
+ totalTokensFresh: typeof entry.totalTokensFresh === "boolean" ? entry.totalTokensFresh : void 0,
115703
+ contextTokens: typeof entry.contextTokens === "number" ? entry.contextTokens : void 0,
115704
+ model: typeof entry.model === "string" ? entry.model : void 0
115705
+ };
115706
+ } catch (err) {
115707
+ log17.warn("footer metrics lookup failed", { error: String(err), sessionKey: this.deps.sessionKey });
115693
115708
  return void 0;
115694
115709
  }
115695
- return {
115696
- inputTokens: typeof entry.inputTokens === "number" ? entry.inputTokens : void 0,
115697
- outputTokens: typeof entry.outputTokens === "number" ? entry.outputTokens : void 0,
115698
- cacheRead: typeof entry.cacheRead === "number" ? entry.cacheRead : void 0,
115699
- cacheWrite: typeof entry.cacheWrite === "number" ? entry.cacheWrite : void 0,
115700
- totalTokens: typeof entry.totalTokens === "number" ? entry.totalTokens : void 0,
115701
- totalTokensFresh: typeof entry.totalTokensFresh === "boolean" ? entry.totalTokensFresh : void 0,
115702
- contextTokens: typeof entry.contextTokens === "number" ? entry.contextTokens : void 0,
115703
- model: typeof entry.model === "string" ? entry.model : void 0
115704
- };
115705
- } catch (err) {
115706
- log17.warn("footer metrics lookup failed", { error: String(err), sessionKey: this.deps.sessionKey });
115707
- return void 0;
115708
- }
115710
+ }, "readMetrics");
115711
+ const first = await readMetrics();
115712
+ if (first?.inputTokens != null) return first;
115713
+ log17.debug("footer metrics: inputTokens missing, retrying after delay", { prefixedKey });
115714
+ await new Promise((resolve4) => setTimeout(resolve4, 800));
115715
+ return readMetrics();
115709
115716
  }
115710
115717
  constructor(deps) {
115711
115718
  this.deps = deps;
@@ -117037,6 +117044,7 @@ async function dispatchPermissionNotification(dc, permissionError, replyToMessag
117037
117044
  } = createFeishuReplyDispatcher({
117038
117045
  cfg: dc.accountScopedCfg,
117039
117046
  agentId: dc.route.agentId,
117047
+ sessionKey: dc.threadSessionKey ?? dc.route.sessionKey,
117040
117048
  chatId: dc.ctx.chatId,
117041
117049
  replyToMessageId: replyToMessageId ?? dc.ctx.messageId,
117042
117050
  accountId: dc.account.accountId,
@@ -119852,6 +119860,7 @@ async function dispatchNormalMessage(dc, ctxPayload, chatHistories, historyKey,
119852
119860
  const { dispatcher, replyOptions, markDispatchIdle, markFullyComplete, abortCard } = createFeishuReplyDispatcher({
119853
119861
  cfg: dc.accountScopedCfg,
119854
119862
  agentId: dc.route.agentId,
119863
+ sessionKey: dc.threadSessionKey ?? dc.route.sessionKey,
119855
119864
  chatId: dc.ctx.chatId,
119856
119865
  replyToMessageId: replyToMessageId ?? dc.ctx.messageId,
119857
119866
  accountId: dc.account.accountId,