惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 聂微东
月光博客
月光博客
博客园 - 司徒正美
爱范儿
爱范儿
aimingoo的专栏
aimingoo的专栏
量子位
Recent Announcements
Recent Announcements
V
V2EX
P
Proofpoint News Feed
小众软件
小众软件
云风的 BLOG
云风的 BLOG
腾讯CDC
宝玉的分享
宝玉的分享
Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
B
Blog
博客园_首页
GbyAI
GbyAI
博客园 - Franky

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(feishu): bound card action chat cache clocks · opencl...
steipete · 2026-05-30 · via Recent Commits to openclaw:main
1+

import {

2+

asDateTimestampMs,

3+

resolveExpiresAtMsFromDurationMs,

4+

} from "openclaw/plugin-sdk/number-runtime";

15

import type { ClawdbotConfig, RuntimeEnv } from "../runtime-api.js";

26

import { resolveFeishuRuntimeAccount } from "./accounts.js";

37

import { handleFeishuMessage, type FeishuMessageEvent } from "./bot.js";

@@ -47,6 +51,7 @@ export class FeishuRetryableCardActionError extends Error {

47514852

export function resetProcessedFeishuCardActionTokensForTests(): void {

4953

processedCardActionTokens.clear();

54+

resolvedChatTypeCache.clear();

5055

}

51565257

function pruneProcessedCardActionTokens(now: number): void {

@@ -185,8 +190,14 @@ const CHAT_TYPE_CACHE_TTL_MS = 30 * 60_000;

185190

const CHAT_TYPE_CACHE_MAX_SIZE = 5_000;

186191187192

function pruneChatTypeCache(now: number): void {

193+

const validNow = asDateTimestampMs(now);

194+

if (validNow === undefined) {

195+

resolvedChatTypeCache.clear();

196+

return;

197+

}

188198

for (const [key, entry] of resolvedChatTypeCache.entries()) {

189-

if (entry.expiresAt <= now) {

199+

const expiresAt = asDateTimestampMs(entry.expiresAt);

200+

if (expiresAt === undefined || expiresAt <= validNow) {

190201

resolvedChatTypeCache.delete(key);

191202

}

192203

}

@@ -206,6 +217,18 @@ function sanitizeLogValue(v: string): string {

206217

return v.replace(/[\r\n]/g, " ").slice(0, 500);

207218

}

208219220+

function cacheResolvedCardActionChatType(

221+

cacheKey: string,

222+

value: "p2p" | "group",

223+

now: number,

224+

): void {

225+

const expiresAt = resolveExpiresAtMsFromDurationMs(CHAT_TYPE_CACHE_TTL_MS, { nowMs: now });

226+

resolvedChatTypeCache.delete(cacheKey);

227+

if (expiresAt !== undefined) {

228+

resolvedChatTypeCache.set(cacheKey, { value, expiresAt });

229+

}

230+

}

231+209232

async function resolveCardActionChatType(params: {

210233

event: FeishuCardActionEvent;

211234

account: ReturnType<typeof resolveFeishuRuntimeAccount>;

@@ -226,9 +249,13 @@ async function resolveCardActionChatType(params: {

226249

const now = Date.now();

227250

pruneChatTypeCache(now);

228251

const cached = resolvedChatTypeCache.get(cacheKey);

229-

if (cached) {

252+

const cachedExpiresAt = cached ? asDateTimestampMs(cached.expiresAt) : undefined;

253+

if (cached && cachedExpiresAt !== undefined) {

230254

return cached.value;

231255

}

256+

if (cached) {

257+

resolvedChatTypeCache.delete(cacheKey);

258+

}

232259233260

try {

234261

const response = (await createFeishuClient(params.account).im.chat.get({

@@ -239,10 +266,7 @@ async function resolveCardActionChatType(params: {

239266

normalizeResolvedCardActionChatType(response.data?.chat_mode) ??

240267

normalizeResolvedCardActionChatType(response.data?.chat_type);

241268

if (resolvedChatType) {

242-

resolvedChatTypeCache.set(cacheKey, {

243-

value: resolvedChatType,

244-

expiresAt: now + CHAT_TYPE_CACHE_TTL_MS,

245-

});

269+

cacheResolvedCardActionChatType(cacheKey, resolvedChatType, now);

246270

return resolvedChatType;

247271

}

248272

params.log(