UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

28 lines (27 loc) • 1.13 kB
import { s as asFiniteNumber } from "../../number-coercion-D6u-4YD8.mjs"; //#region src/hooks/bundled/compaction-notifier/handler.ts const handler = async (e) => { try { const t = e.context; if (e.type === "session" && e.action === "compact:before") { const n = asFiniteNumber(t.messageCount); const r = n !== void 0 && n >= 0 ? ` (${n} messages)` : ""; e.messages.push(`🧹 Compacting context${r} so I can continue without losing history…`); return; } if (e.type === "session" && e.action === "compact:after") { if (t.compactionOutcome === "skipped") { e.messages.push("✅ Nothing to compact. Continuing from where I left off."); return; } const n = asFiniteNumber(t.tokensBefore); const r = asFiniteNumber(t.tokensAfter); const i = n !== void 0 && r !== void 0 ? ` (${n.toLocaleString()} → ${r.toLocaleString()} tokens)` : ""; e.messages.push(`✅ Context compacted${i}. Continuing from where I left off.`); } } catch (e) { console.warn(`[compaction-notifier] failed: ${e instanceof Error ? e.message : String(e)}`); } }; //#endregion export { handler as default };