/** * CostGovernor — Pre-flight budget prediction for task DAGs. * * Walks a TaskDAG, estimates per-node token spend using a pluggable cost * model, and checks the total against FederatedBudget before execution. * * @module CostGovernor */ /** Per-node cost estimate */ export interface NodeCostEstimate { taskId: string; agent: string; action: string; estimatedTokens: number; confidence: number; } /** Full DAG cost prediction */ export interface DAGCostPrediction { /** Total estimated tokens across all nodes */ totalTokens: number; /** Per-node breakdown */ nodes: NodeCostEstimate[]; /** Whether the prediction fits within the budget */ withinBudget: boolean; /** Budget remaining after predicted spend */ budgetRemaining: number; /** Current budget ceiling */ budgetCeiling: number; /** Per-agent totals */ perAgent: Record; /** Agents that would exceed their per-agent ceiling */ overBudgetAgents: string[]; /** Average confidence across estimates */ averageConfidence: number; } /** Cost model: maps (agent, action, params) → estimated tokens */ export interface CostModel { estimate(agent: string, action: string, params: Record): { tokens: number; confidence: number; }; } /** Minimal DAG shape — avoids importing from goal-decomposer */ export interface CostDAGNode { id: string; agent: string; action: string; params: Record; } /** Minimal budget interface */ export interface CostBudget { remaining(): number; getCeiling(): number; getAgentSpent(agentId: string): number; getPerAgentCeiling(): number | undefined; } /** * Lookup-based cost model. Register per-agent or per-action token estimates. * Falls back to a configurable default. */ export declare class LookupCostModel implements CostModel { private agentDefaults; private actionOverrides; private defaultTokens; constructor(defaultTokens?: number); /** Set default token estimate for an agent */ setAgentDefault(agent: string, tokens: number): void; /** Set token estimate for a specific agent:action pair */ setActionEstimate(agent: string, action: string, tokens: number): void; estimate(agent: string, action: string, _params: Record): { tokens: number; confidence: number; }; } /** * Pre-flight budget check for task DAGs. * * @example * ```ts * const governor = new CostGovernor(budget, new LookupCostModel(1000)); * const prediction = governor.predict(dag.nodes); * if (!prediction.withinBudget) { * console.log('DAG would exceed budget by', -prediction.budgetRemaining, 'tokens'); * } * * // As approval callback: * const options = { approvalCallback: (dag) => governor.approve(dag.nodes) }; * ``` */ export declare class CostGovernor { private budget; private model; constructor(budget: CostBudget, model?: CostModel); /** Replace the cost model */ setCostModel(model: CostModel): void; /** * Predict the total cost of a DAG and check against budget. */ predict(nodes: CostDAGNode[]): DAGCostPrediction; /** * Approval callback for TeamRunner — returns true if DAG fits budget. */ approve(nodes: CostDAGNode[]): Promise; } //# sourceMappingURL=cost-governor.d.ts.map