alertLevel (cost/budget.ts)

ruflo · plugins/ruflo-mods/hooks/cost/budget.ts · typescript · MIT
payments

TypeScript module exposing budget alert levels and utilities for cost tracking.

// Source: https://github.com/ruvnet/ruflo | License: MIT | Copyright 2024-2026 ruvnet
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * The ruflo-cost-tracker budget ladder (scripts/budget.mjs `alertLevel`),
 * applied to the session's live cost as `session.measure` pushes it, with no
 * jsonl parse and no node spawn. The parity test reads the thresholds out of
 * budget.mjs.
 */

export type BudgetLevel = 'OK' | 'INFO' | 'WARNING' | 'CRITICAL' | 'HARD_STOP'

export const LEVELS: ReadonlyArray<{ readonly level: BudgetLevel; readonly at: number }> = [
  { level: 'HARD_STOP', at: 1.0 },
  { level: 'CRITICAL', at: 0.9 },
  { level: 'WARNING', at: 0.75 },
  { level: 'INFO', at: 0.5 },
]

const ORDER: Record<BudgetLevel, number> = { OK: 0, INFO: 1, WARNING: 2, CRITICAL: 3

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key