/** * 一次 LLM 调用的真原子记录 (来自 agent trajectory) * 跨 agent / 跨 provider 统一 schema */ export interface LocalUsageRecord { /** 唯一 ID — 用于去重 (基于 agent+session+turn 哈希) */ id: string; /** ISO 8601 时间戳 */ timestamp: string; /** Agent harness 类型 — openclaw / claude-code / cursor / codex / aider / other */ agent_harness: AgentHarness; /** Agent session ID (各 harness 自己的) */ session_id: string; /** Provider — anthropic / openai / deepseek / doubao / qwen / kimi / minimax / ollama / other */ provider: string; /** Model ID (各 provider 自己的, 如 'claude-sonnet-4-6' / 'gpt-4o' / 'MiniMax-M2.7') */ model_id: string; /** 输入 token (uncached) */ input_tokens: number; /** 输出 token */ output_tokens: number; /** Cache 读 token (cache hit, 通常便宜 10x) */ cache_read_tokens: number; /** Cache 写 token (创建 cache, Anthropic 收 1.25x 价) */ cache_write_tokens: number; /** 总 token (= input + output, 不含 cache_read) — 兼容历史字段 */ total_tokens: number; /** 估算成本 USD (基于 model-pricing.ts 真价目) */ estimated_cost_usd: number; /** 估算成本 CNY (= USD × 7.3) */ estimated_cost_cny: number; /** trajectory 文件路径 (用于 debug / dedup) */ source_file: string; } export type AgentHarness = 'openclaw' | 'claude-code' | 'cursor' | 'codex' | 'aider' | 'continue' | 'other'; /** * 时序聚合查询结果 (按 day / week / month 分组) */ export interface UsageAggregation { /** 时间窗口 ISO 8601 起始 */ window_start: string; /** 时间窗口 ISO 8601 结束 */ window_end: string; /** 总 input token */ input_tokens: number; /** 总 output token */ output_tokens: number; /** 总 cache read */ cache_read_tokens: number; /** 总 cache write */ cache_write_tokens: number; /** 估算总成本 USD */ total_cost_usd: number; /** 估算总成本 CNY */ total_cost_cny: number; /** 调用次数 */ call_count: number; } /** * 按 provider 分组的聚合 */ export interface UsageByProvider extends UsageAggregation { provider: string; } /** * 按 agent harness 分组的聚合 */ export interface UsageByAgent extends UsageAggregation { agent_harness: AgentHarness; } /** * 按 model 分组的聚合 */ export interface UsageByModel extends UsageAggregation { provider: string; model_id: string; } /** * Watcher 配置 */ export interface WatcherConfig { /** 监听的 trajectory 目录 (各 harness 路径) */ watch_paths: WatchPath[]; /** sqlite db 文件路径 (默认 ~/.skillfm/usage-local.db) */ db_path: string; /** 是否启用 verbose 日志 */ verbose: boolean; } export interface WatchPath { agent_harness: AgentHarness; /** glob 路径 (例: `~/.openclaw/agents//sessions/.trajectory.jsonl`) */ glob: string; } //# sourceMappingURL=types.d.ts.map