/** * Budget Service Type Definitions * * Types for API usage tracking and budget management. * * @module types/budget.types */ /** * Record of API usage for a single operation */ export interface UsageRecord { /** Unique identifier for the agent */ agentId: string; /** Session name of the agent */ sessionName: string; /** Project path */ projectPath: string; /** Timestamp of the usage */ timestamp: string; /** Number of input tokens used */ inputTokens: number; /** Number of output tokens generated */ outputTokens: number; /** Model used for the operation */ model: string; /** Type of operation (task, continuation, memory, etc.) */ operation: BudgetOperationType; /** Associated task ID, if applicable */ taskId?: string; /** Estimated cost in USD (calculated after recording) */ estimatedCost?: number; } /** * Types of budget operations */ export type BudgetOperationType = 'task' | 'continuation' | 'memory' | 'sop' | 'quality_gate' | 'prompt_building' | 'other'; /** * Summary of usage over a period */ export interface UsageSummary { /** Total input tokens used */ totalInputTokens: number; /** Total output tokens generated */ totalOutputTokens: number; /** Total tokens (input + output) */ totalTokens: number; /** Estimated cost in USD */ estimatedCost: number; /** Breakdown by operation type */ operationBreakdown: Record; /** Breakdown by model */ modelBreakdown: Record; } /** * Scope of budget configuration */ export type BudgetScope = 'global' | 'project' | 'agent'; /** * Budget configuration */ export interface BudgetConfig { /** Scope of the budget (global, project, or agent) */ scope: BudgetScope; /** Identifier for the scope (project path or agent ID) */ scopeId: string; /** Daily spending limit in USD */ dailyLimit?: number; /** Weekly spending limit in USD */ weeklyLimit?: number; /** Monthly spending limit in USD */ monthlyLimit?: number; /** Maximum tokens per task */ maxTokensPerTask?: number; /** Percentage (0-1) at which to trigger warning */ warningThreshold: number; } /** * Current budget status */ export interface BudgetStatus { /** Whether usage is within budget */ withinBudget: boolean; /** Amount used today in USD */ dailyUsed: number; /** Daily limit in USD */ dailyLimit: number; /** Percentage of budget used (0-1) */ percentUsed: number; /** Estimated remaining runway description */ estimatedRunway: string; } /** * Budget alert types */ export type BudgetAlertType = 'warning' | 'exceeded'; /** * Budget alert event */ export interface BudgetAlert { /** Type of alert */ type: BudgetAlertType; /** Scope of the budget */ scope: BudgetScope; /** Scope identifier */ scopeId: string; /** Current usage in USD */ currentUsage: number; /** Budget limit in USD */ limit: number; /** Timestamp of the alert */ timestamp: string; } /** * Time period for reports */ export type BudgetPeriod = 'day' | 'week' | 'month'; /** * Parameters for generating a budget report */ export interface ReportParams { /** Time period to report on */ period: BudgetPeriod; /** Optional project path to filter by */ projectPath?: string; /** Optional agent ID to filter by */ agentId?: string; } /** * Agent usage summary for reports */ export interface AgentUsageSummary extends UsageSummary { /** Agent identifier */ agentId: string; } /** * Complete budget report */ export interface BudgetReport { /** Time period covered */ period: BudgetPeriod; /** When the report was generated */ generatedAt: string; /** Total cost in USD */ totalCost: number; /** Total tokens used */ totalTokens: number; /** Breakdown by agent */ agentBreakdown: AgentUsageSummary[]; } /** * Stored budget configuration file format */ export interface BudgetConfigFile { /** Global budget settings */ global?: Omit; /** Project-specific budgets */ projects?: Record>; /** Agent-specific budgets */ agents?: Record>; } /** * Token cost rates per model */ export interface TokenCostRates { /** Cost per input token in USD */ input: number; /** Cost per output token in USD */ output: number; } /** * Budget-related constants */ export declare const BUDGET_CONSTANTS: { /** Default configuration values */ readonly DEFAULTS: { readonly DAILY_LIMIT: 50; readonly WEEKLY_LIMIT: 200; readonly MONTHLY_LIMIT: 500; readonly WARNING_THRESHOLD: 0.8; readonly MAX_TOKENS_PER_TASK: 100000; }; /** Token cost rates by model (USD per token) */ readonly TOKEN_COSTS: Record; /** File paths */ readonly PATHS: { readonly USAGE_DIR: "usage"; readonly BUDGETS_FILE: "budgets.json"; readonly BUDGETS_YAML_FILE: "budgets.yaml"; }; /** Operation types */ readonly OPERATIONS: { readonly TASK: BudgetOperationType; readonly CONTINUATION: BudgetOperationType; readonly MEMORY: BudgetOperationType; readonly SOP: BudgetOperationType; readonly QUALITY_GATE: BudgetOperationType; readonly PROMPT_BUILDING: BudgetOperationType; readonly OTHER: BudgetOperationType; }; }; /** * Default global budget configuration */ export declare const DEFAULT_BUDGET_CONFIG: BudgetConfig; /** * All budget operation types */ export declare const ALL_BUDGET_OPERATIONS: BudgetOperationType[]; /** * All budget scopes */ export declare const ALL_BUDGET_SCOPES: BudgetScope[]; /** * All budget periods */ export declare const ALL_BUDGET_PERIODS: BudgetPeriod[]; //# sourceMappingURL=budget.types.d.ts.map