/** * Deterministic prompt budgeting utilities for Hive. * * Limits history/context included in prompts to bound growth: * - Include only last N completed tasks * - Truncate each task summary to max M chars (with clear truncation marker) * - Apply max budget for inlined context (or switch to file references / name-only listing past a cap) * - Emit warnings when any budget causes truncation so it's never silent * * IMPORTANT: Never removes access to full info - always provides file paths the worker can read. */ /** * Input task for budgeting. */ export interface TaskInput { name: string; summary: string; } /** * Budgeted task with truncation info. */ export interface BudgetedTask { name: string; summary: string; truncated: boolean; originalLength?: number; } /** * Input context file for budgeting. */ export interface ContextInput { name: string; content: string; } /** * Budgeted context file with truncation info. */ export interface BudgetedContext { name: string; content: string; truncated: boolean; originalLength?: number; /** Hint for where to find full content */ pathHint?: string; } /** * Truncation event for observability. */ export interface TruncationEvent { type: 'tasks_dropped' | 'summary_truncated' | 'context_truncated' | 'context_names_only'; message: string; count?: number; /** Names of affected items */ affected?: string[]; } /** * Budget configuration. */ export interface BudgetConfig { /** Max number of previous tasks to include (default: 10) */ maxTasks?: number; /** Max chars per task summary (default: 2000) */ maxSummaryChars?: number; /** Max chars per context file (default: 20000) */ maxContextChars?: number; /** Max total chars for all context files combined (default: 60000) */ maxTotalContextChars?: number; /** Feature name for generating file path hints */ feature?: string; } /** * Result of applying task budget. */ export interface TaskBudgetResult { tasks: BudgetedTask[]; truncationEvents: TruncationEvent[]; /** Hint about dropped tasks and where to find them */ droppedTasksHint?: string; } /** * Result of applying context budget. */ export interface ContextBudgetResult { files: BudgetedContext[]; truncationEvents: TruncationEvent[]; /** Names of files that were converted to name-only */ namesOnlyFiles?: string[]; } /** * Default budget configuration. * * Conservative defaults that balance context richness with bounded growth. */ export declare const DEFAULT_BUDGET: Required>; /** * Apply budget limits to previous tasks. * * - Keeps only the last N tasks (most recent) * - Truncates summaries exceeding max chars * - Emits truncation events for observability * - Provides hints for accessing full info */ export declare function applyTaskBudget(tasks: TaskInput[], config?: BudgetConfig): TaskBudgetResult; /** * Apply budget limits to context files. * * - Truncates individual files exceeding max chars * - Switches to name-only listing when total exceeds budget * - Emits truncation events for observability * - Provides file path hints for accessing full content */ export declare function applyContextBudget(files: ContextInput[], config?: BudgetConfig): ContextBudgetResult;