/** * Context budget packer for orchestrator mode. * * Greedy priority-first algorithm that packs context items into a token budget. * When a full item doesn't fit, the packer tries its summary (Artifact_Summary) * before excluding it entirely. * * Requirements: 19.4, 19.5, 25.7, 25.8 */ /** A context item to be considered for inclusion in a prompt. */ export interface ContextItem { /** Unique identifier for this item. */ id: string; /** Full content of this item. */ content: string; /** Priority 1-100, higher = more important. */ priority: number; /** Estimated token count for the full content. */ tokenEstimate: number; /** Optional shorter summary version (used when full content doesn't fit). */ summary?: string; } /** Result of packing context items into a budget. */ export interface PackResult { /** Items that fit in the budget (may use summary version). */ included: ContextItem[]; /** Items that didn't fit even as summaries. */ excluded: ContextItem[]; /** Total tokens used by included items. */ totalTokens: number; /** IDs of items where the summary was used instead of full content. */ usedSummary: string[]; } /** * Estimate the token count of a text string. * * Uses the simple heuristic of ~4 characters per token. * This is a rough approximation suitable for budget planning. */ export declare function estimateTokens(text: string): number; /** * Pack context items into a token budget using a greedy priority-first algorithm. * * Algorithm: * 1. Sort items by priority descending (stable sort preserves insertion order for ties) * 2. For each item (highest priority first): * a. If full content fits in remaining budget → include it * b. Else if summary exists and fits → include summary version * c. Else → exclude * 3. Return PackResult * * @param items - Context items to pack. * @param budgetTokens - Maximum token count for the packed result. * @returns PackResult describing which items were included/excluded. */ export declare function packContext(items: ContextItem[], budgetTokens: number): PackResult; //# sourceMappingURL=budget-packer.d.ts.map