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

推荐订阅源

Y
Y Combinator Blog
GbyAI
GbyAI
爱范儿
爱范儿
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Check Point Blog
M
MIT News - Artificial intelligence
量子位
宝玉的分享
宝玉的分享
MongoDB | Blog
MongoDB | Blog
V
Visual Studio Blog
罗磊的独立博客
F
Fortinet All Blogs
美团技术团队
博客园_首页
博客园 - 【当耐特】
L
LangChain Blog
月光博客
月光博客
腾讯CDC
The Cloudflare Blog
D
Docker
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

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(telegram): centralize safe thread id parsing · opencl...
steipete · 2026-05-29 · via Recent Commits to openclaw:main

@@ -2,10 +2,7 @@ import { createHash } from "node:crypto";

22

import fs from "node:fs";

33

import type { Message } from "grammy/types";

44

import { formatLocationText } from "openclaw/plugin-sdk/channel-inbound";

5-

import {

6-

parseStrictNonNegativeInteger,

7-

parseStrictPositiveInteger,

8-

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

5+

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

96

import type { MsgContext } from "openclaw/plugin-sdk/reply-runtime";

107

import { logVerbose } from "openclaw/plugin-sdk/runtime-env";

118

import { appendRegularFileSync, replaceFileAtomicSync } from "openclaw/plugin-sdk/security-runtime";

@@ -17,6 +14,7 @@ import {

1714

getTelegramTextParts,

1815

normalizeForwardedContext,

1916

} from "./bot/helpers.js";

17+

import { parseTelegramMessageThreadId } from "./outbound-params.js";

2018

import { getOptionalTelegramRuntime } from "./runtime.js";

21192220

export type TelegramReplyChainEntry = NonNullable<MsgContext["ReplyChain"]>[number];

@@ -166,6 +164,7 @@ function normalizeMessageNode(

166164

const forwardedFrom = normalizeForwardedContext(msg);

167165

const replyMessage = resolveReplyMessage(msg);

168166

const body = resolveMessageBody(msg);

167+

const threadId = normalizeTelegramCacheThreadId(params.threadId);

169168

return {

170169

sourceMessage: msg,

171170

messageId: String(msg.message_id),

@@ -181,7 +180,7 @@ function normalizeMessageNode(

181180

...(forwardedFrom?.fromId ? { forwardedFromId: forwardedFrom.fromId } : {}),

182181

...(forwardedFrom?.fromUsername ? { forwardedFromUsername: forwardedFrom.fromUsername } : {}),

183182

...(forwardedFrom?.date ? { forwardedDate: forwardedFrom.date * 1000 } : {}),

184-

...(params.threadId != null ? { threadId: String(params.threadId) } : {}),

183+

...(threadId !== undefined ? { threadId: String(threadId) } : {}),

185184

};

186185

}

187186

@@ -198,9 +197,7 @@ function normalizeRequiredMessageNode(

198197199198

function resolveMessageThreadId(msg: Message): number | undefined {

200199

const threadId = (msg as { message_thread_id?: unknown }).message_thread_id;

201-

return typeof threadId === "number" && Number.isFinite(threadId)

202-

? Math.trunc(threadId)

203-

: undefined;

200+

return normalizeTelegramCacheThreadId(threadId);

204201

}

205202206203

function normalizeMessageNodes(

@@ -246,7 +243,11 @@ function parseSafeMessageId(value: string | undefined): number | undefined {

246243

}

247244248245

function parseCachedThreadId(value: unknown): number | undefined {

249-

return parseStrictNonNegativeInteger(value);

246+

return normalizeTelegramCacheThreadId(value);

247+

}

248+249+

function normalizeTelegramCacheThreadId(value: unknown): number | undefined {

250+

return parseTelegramMessageThreadId(value);

250251

}

251252252253

function isTelegramSourceMessage(value: unknown): value is Message {

@@ -754,7 +755,11 @@ export function createTelegramMessageCache(params?: {

754755

}) => {

755756

await hydrateMessageCacheBucket(bucket, maxMessages, scopeKey);

756757

const prefix = telegramMessageCacheKeyPrefix({ scopeKey, ...params });

757-

const threadId = params.threadId != null ? String(params.threadId) : undefined;

758+

const normalizedThreadId = normalizeTelegramCacheThreadId(params.threadId);

759+

if (params.threadId != null && normalizedThreadId === undefined) {

760+

return [];

761+

}

762+

const threadId = normalizedThreadId !== undefined ? String(normalizedThreadId) : undefined;

758763

return Array.from(messages, ([key, node]) => ({ key, node }))

759764

.filter(({ key, node }) => {

760765

if (!key.startsWith(prefix)) {