mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
0e792b6de3
* refactor(channels): centralize inbound turn orchestration * refactor(runtime): remove stale compatibility paths * chore(guards): reject internal deprecated API use * refactor(channels): simplify core turn planning * chore(guards): keep deprecated checks boundary-focused * refactor(memory): keep modern config off compat barrel * fix(msteams): preserve feedback learning * test(channels): align modern inbound fixtures * refactor(channels): finish modern inbound migration * refactor(channels): tighten core inbound kernel * fix(channels): preserve turn assembly narrowing * test(sdk): keep runtime mock binding immutable * test(matrix): isolate read policy runtime * test(msteams): mock canonical reply factory * test(slack): mock core inbound turn dispatch * test(telegram): inject core session recorder * test(signal): inject core session recorder * test(googlechat): assert canonical inbound routing * test(synology-chat): align core turn fixture * fix(sdk): preserve direct DM runtime compat * refactor(channels): own inbound envelope compat in core * refactor(channels): trim inbound dispatch seams * refactor(channels): remove redundant async wrappers * test(synology-chat): type canonical dispatcher mock * refactor(channels): remove remaining dead compat seams * chore(sdk): refresh API baseline after rebase * fix(channels): preserve direct DM identity metadata
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import crypto from "node:crypto";
|
|
import { getMSTeamsRuntime } from "./runtime.js";
|
|
|
|
const LEARNINGS_NAMESPACE = "feedback-learnings";
|
|
const MAX_LEARNING_ENTRIES = 10_000;
|
|
|
|
type FeedbackLearningEntry = {
|
|
sessionKey: string;
|
|
learnings: string[];
|
|
updatedAt: number;
|
|
};
|
|
|
|
function learningStoreKey(storePath: string, sessionKey: string): string {
|
|
return crypto.createHash("sha256").update(`${storePath}\0${sessionKey}`, "utf8").digest("hex");
|
|
}
|
|
|
|
export async function storeSessionLearning(params: {
|
|
storePath: string;
|
|
sessionKey: string;
|
|
learning: string;
|
|
}): Promise<void> {
|
|
const store = getMSTeamsRuntime().state.openKeyedStore<FeedbackLearningEntry>({
|
|
namespace: LEARNINGS_NAMESPACE,
|
|
maxEntries: MAX_LEARNING_ENTRIES,
|
|
});
|
|
const key = learningStoreKey(params.storePath, params.sessionKey);
|
|
if (!store.update) {
|
|
throw new Error("plugin state atomic update is unavailable");
|
|
}
|
|
await store.update(key, (existing) => ({
|
|
sessionKey: params.sessionKey,
|
|
learnings: [...(existing?.learnings ?? []), params.learning].slice(-10),
|
|
updatedAt: Date.now(),
|
|
}));
|
|
}
|