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

推荐订阅源

WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
MyScale Blog
MyScale Blog
博客园_首页
G
Google Developers Blog
博客园 - 【当耐特】
美团技术团队
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Vercel News
Vercel News
小众软件
小众软件
博客园 - 司徒正美
雷峰网
雷峰网
T
Tailwind CSS Blog
V
V2EX
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
罗磊的独立博客
量子位
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog

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 streaming token expiry · openclaw/open...
steipete · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -342,6 +342,65 @@ describe("FeishuStreamingSession", () => {

342342

"Final replace failed: Error: Replace card content failed with HTTP 500",

343343

);

344344

});

345+
346+

it("bounds streaming token cache lifetime when token expiry overflows", async () => {

347+

vi.useFakeTimers();

348+

vi.setSystemTime(new Date("2026-05-29T12:00:00.000Z"));

349+

const release = vi.fn(async () => {});

350+

const authTokens: string[] = [];

351+

fetchWithSsrFGuardMock.mockImplementation(

352+

async ({ url }: { url: string; init?: { body?: string } }) => {

353+

if (url.includes("/auth/")) {

354+

const token = `token-${authTokens.length + 1}`;

355+

authTokens.push(token);

356+

return {

357+

response: {

358+

ok: true,

359+

json: async () => ({

360+

code: 0,

361+

msg: "ok",

362+

tenant_access_token: token,

363+

expire: Number.MAX_SAFE_INTEGER,

364+

}),

365+

},

366+

release,

367+

};

368+

}

369+

return {

370+

response: {

371+

ok: true,

372+

json: async () => ({

373+

code: 0,

374+

msg: "ok",

375+

data: { card_id: `card-${authTokens.length}` },

376+

}),

377+

},

378+

release,

379+

};

380+

},

381+

);

382+

const client = {

383+

im: {

384+

message: {

385+

create: vi.fn(async () => ({ code: 0, msg: "ok", data: { message_id: "om_1" } })),

386+

},

387+

},

388+

} as never;

389+
390+

await new FeishuStreamingSession(client, {

391+

appId: "app_unsafe_token_expiry",

392+

appSecret: "secret",

393+

}).start("chat_id", "open_id");

394+

expect(authTokens).toEqual(["token-1"]);

395+
396+

vi.setSystemTime(Date.now() + 7200 * 1000 - 60_000 + 1);

397+

await new FeishuStreamingSession(client, {

398+

appId: "app_unsafe_token_expiry",

399+

appSecret: "secret",

400+

}).start("chat_id", "open_id");

401+
402+

expect(authTokens).toEqual(["token-1", "token-2"]);

403+

});

345404

});

346405
347406

describe("mergeStreamingText", () => {

Original file line numberDiff line numberDiff line change

@@ -3,6 +3,7 @@

33

*/

44
55

import type { Client } from "@larksuiteoapi/node-sdk";

6+

import { resolveExpiresAtMsFromDurationSeconds } from "openclaw/plugin-sdk/number-runtime";

67

import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";

78

import { getFeishuUserAgent } from "./client.js";

89

import { resolveFeishuCardTemplate, type CardHeaderConfig } from "./send.js";

@@ -42,10 +43,21 @@ type StreamingStartOptions = {

4243
4344

const STREAMING_UPDATE_THROTTLE_MS = 160;

4445

const STREAMING_SIGNIFICANT_DELTA_CHARS = 18;

46+

const FEISHU_STREAMING_TOKEN_DEFAULT_LIFETIME_SECONDS = 7200;

4547
4648

// Token cache (keyed by domain + appId)

4749

const tokenCache = new Map<string, { token: string; expiresAt: number }>();

4850
51+

function resolveStreamingTokenExpiresAt(value: unknown): number {

52+

if (typeof value === "number" && Number.isFinite(value) && value <= 0) {

53+

return Date.now();

54+

}

55+

return (

56+

resolveExpiresAtMsFromDurationSeconds(value) ??

57+

Date.now() + FEISHU_STREAMING_TOKEN_DEFAULT_LIFETIME_SECONDS * 1000

58+

);

59+

}

60+
4961

function resolveApiBase(domain?: FeishuDomain): string {

5062

if (domain === "lark") {

5163

return "https://open.larksuite.com/open-apis";

@@ -103,7 +115,7 @@ async function getToken(creds: Credentials): Promise<string> {

103115

}

104116

tokenCache.set(key, {

105117

token: data.tenant_access_token,

106-

expiresAt: Date.now() + (data.expire ?? 7200) * 1000,

118+

expiresAt: resolveStreamingTokenExpiresAt(data.expire),

107119

});

108120

return data.tenant_access_token;

109121

}