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

推荐订阅源

月光博客
月光博客
小众软件
小众软件
爱范儿
爱范儿
Y
Y Combinator Blog
博客园 - Franky
美团技术团队
博客园 - 【当耐特】
The Cloudflare Blog
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
IT之家
IT之家
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
WordPress大学
WordPress大学
V
Visual Studio Blog
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
有赞技术团队
有赞技术团队

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
refactor: centralize channel history window · openclaw/op...
steipete · 2026-05-15 · via Recent Commits to openclaw:main

@@ -0,0 +1,89 @@

1+

import {

2+

buildInboundHistoryFromMap,

3+

buildPendingHistoryContextFromMap,

4+

clearHistoryEntriesIfEnabled,

5+

recordPendingHistoryEntryIfEnabled,

6+

recordPendingHistoryEntryWithMedia,

7+

} from "../../auto-reply/reply/history.js";

8+

import type { HistoryEntry, HistoryMediaEntry } from "../../auto-reply/reply/history.types.js";

9+10+

type MaybePromise<T> = T | Promise<T>;

11+12+

export type ChannelHistoryWindow = {

13+

record: (params: {

14+

historyKey: string;

15+

entry?: HistoryEntry | null;

16+

limit: number;

17+

}) => HistoryEntry[];

18+

recordWithMedia: (params: {

19+

historyKey: string;

20+

entry?: HistoryEntry | null;

21+

limit: number;

22+

media?:

23+

| readonly HistoryMediaEntry[]

24+

| null

25+

| (() => MaybePromise<readonly HistoryMediaEntry[] | null | undefined>);

26+

mediaLimit?: number;

27+

messageId?: string;

28+

shouldRecord?: () => boolean;

29+

}) => Promise<HistoryEntry[]>;

30+

buildPendingContext: (params: {

31+

historyKey: string;

32+

limit: number;

33+

currentMessage: string;

34+

formatEntry: (entry: HistoryEntry) => string;

35+

lineBreak?: string;

36+

}) => string;

37+

buildInboundHistory: (params: {

38+

historyKey: string;

39+

limit: number;

40+

}) => HistoryEntry[] | undefined;

41+

clear: (params: { historyKey: string; limit: number }) => void;

42+

};

43+44+

export function createChannelHistoryWindow(params: {

45+

historyMap: Map<string, HistoryEntry[]>;

46+

}): ChannelHistoryWindow {

47+

const { historyMap } = params;

48+

return {

49+

record: (recordParams) =>

50+

recordPendingHistoryEntryIfEnabled({

51+

historyMap,

52+

historyKey: recordParams.historyKey,

53+

limit: recordParams.limit,

54+

entry: recordParams.entry,

55+

}),

56+

recordWithMedia: (recordParams) =>

57+

recordPendingHistoryEntryWithMedia({

58+

historyMap,

59+

historyKey: recordParams.historyKey,

60+

limit: recordParams.limit,

61+

entry: recordParams.entry,

62+

media: recordParams.media,

63+

mediaLimit: recordParams.mediaLimit,

64+

messageId: recordParams.messageId,

65+

shouldRecord: recordParams.shouldRecord,

66+

}),

67+

buildPendingContext: (contextParams) =>

68+

buildPendingHistoryContextFromMap({

69+

historyMap,

70+

historyKey: contextParams.historyKey,

71+

limit: contextParams.limit,

72+

currentMessage: contextParams.currentMessage,

73+

formatEntry: contextParams.formatEntry,

74+

lineBreak: contextParams.lineBreak,

75+

}),

76+

buildInboundHistory: (historyParams) =>

77+

buildInboundHistoryFromMap({

78+

historyMap,

79+

historyKey: historyParams.historyKey,

80+

limit: historyParams.limit,

81+

}),

82+

clear: (clearParams) =>

83+

clearHistoryEntriesIfEnabled({

84+

historyMap,

85+

historyKey: clearParams.historyKey,

86+

limit: clearParams.limit,

87+

}),

88+

};

89+

}