/** * Context formatter — converts engram observations into an XML context block * suitable for injection into agent prompts. * * Faithfully ported from plugin/engram/hooks/user-prompt.js with TypeScript types. */ import type { Observation, RuleRouterPayload } from '../client.js'; interface FormatterOptions { /** Token budget (~4 chars per token). Default: 2000. */ tokenBudget?: number; } export interface FormatResult { /** Formatted XML context string, or empty string if nothing to inject. */ context: string; /** IDs of observations that made it into the context (after dedup + budget trim). */ injectedIds: number[]; /** Number of observations trimmed by token budget. */ trimmedCount: number; } /** * Format always_inject observations into a compact behavioral rules block. * * These are observations marked always_inject=true on the server. They represent * standing behavioral rules (e.g., "always use X", "never do Y") that must be * injected into every turn regardless of query relevance. * * Rendered as a lightweight XML block separate from the main engram-context so * the agent can distinguish standing rules from query-matched knowledge. * * @param observations - The always_inject observations from the search response. * @returns A non-empty XML block string, or '' if nothing to render. */ export declare function formatAlwaysInject(observations: Observation[]): string; /** * Format bounded rule-router packets. Router-mode packets are already selected * by the server and must not be relabeled as legacy always-active rules. */ export declare function formatRuleRouter(router?: RuleRouterPayload | null): string; export declare function isRouterPayloadEnabled(router?: RuleRouterPayload | null): boolean; /** * Format an array of engram observations into an XML context block. * * Steps: * 1. Filter credentials * 2. Sort by similarity (descending) * 3. Jaccard dedup (>0.8 title word overlap) * 4. Group by type (decisions → patterns → changes → general) * 5. Apply token budget * 6. Re-group and render XML */ export declare function formatContext(observations: Observation[], options?: FormatterOptions): FormatResult; export declare function safePromptScalar(value: unknown): string; export declare function quotedPromptScalar(value: unknown): string; export declare function safePromptPayload(value: unknown): string; export declare function quotedPromptPayload(value: unknown): string; export {}; //# sourceMappingURL=formatter.d.ts.map