/** * Keyword Optimization Service * * Applies LLM optimization results (ADD/UPDATE/REMOVE mutations) to the * correction keyword store. Invoked by the correction observer service * when optimization results are available. */ import type { CorrectionObserverOutputV1 as CorrectionObserverResult } from '@principles/core/runtime-v2'; import type { PluginLogger } from '../openclaw-sdk.js'; /** * Applies CorrectionObserverResult mutations to the keyword store. * - ADD: calls learner.add() with new keyword * - UPDATE: updates weight on existing keyword * - REMOVE: removes keyword from store */ export declare class KeywordOptimizationService { private readonly stateDir; private readonly workspaceDir; private readonly logger; constructor(stateDir: string, workspaceDir: string, logger: PluginLogger); applyResult(result: CorrectionObserverResult): void; /** * Builds trajectory history for payload: * - Calls TrajectoryDatabase.listUserTurnsForSession() for recent sessions * - Filters to turns where correctionDetected=true * - Returns last 50 correction events */ buildTrajectoryHistory(sessionIds: string[]): Promise; private static _instances; static get(stateDir: string, workspaceDir: string, logger: PluginLogger): KeywordOptimizationService; static reset(): void; } /** * Internal type mirroring the trajectoryHistory field in CorrectionObserverPayload. * Exported here so buildTrajectoryHistory can reference it without a circular import. */ export type TrajectoryHistoryEntry = { sessionId: string; timestamp: string; term: string; userMessage: string; }; /** Re-export CorrectionObserverPayload for convenience */ export type { CorrectionObserverPayload } from '@principles/core/runtime-v2';