nexus-agents 6.3.2 → 6.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{child-mcp-config-6UXFBHW5.js → child-mcp-config-HGD32ADZ.js} +2 -2
- package/dist/{chunk-DZQWHHGI.js → chunk-3FPHHCY5.js} +4 -4
- package/dist/{chunk-UONHQ3Q3.js → chunk-5FHJAPIR.js} +2 -2
- package/dist/chunk-AQBOZVBW.js +7 -0
- package/dist/{chunk-2TP7YLBC.js → chunk-BE6FQ7XI.js} +2 -2
- package/dist/{chunk-XJ76EMQV.js → chunk-CLIZCXWB.js} +5 -5
- package/dist/{chunk-XHKHC44U.js → chunk-DJN4XAQO.js} +47 -43
- package/dist/{chunk-XHKHC44U.js.map → chunk-DJN4XAQO.js.map} +1 -1
- package/dist/{chunk-BT534KOS.js → chunk-DPFRPNAC.js} +7 -7
- package/dist/{chunk-MFORQ7FO.js → chunk-E6LGFJQE.js} +2 -2
- package/dist/{chunk-GVRDLRJM.js → chunk-ECHZGAZO.js} +49 -4
- package/dist/chunk-ECHZGAZO.js.map +1 -0
- package/dist/{chunk-47TTP5PC.js → chunk-FQQYGPMC.js} +2 -2
- package/dist/{chunk-5LREI4NO.js → chunk-GRLN6WL5.js} +3 -3
- package/dist/{chunk-5M3ZAK2V.js → chunk-HJUL6YRG.js} +4 -4
- package/dist/{chunk-LX4DUS4M.js → chunk-ITB2NBB7.js} +6 -6
- package/dist/{chunk-E2TILOO3.js → chunk-JLA2YAGY.js} +5 -5
- package/dist/{chunk-T7NTJNCG.js → chunk-JLE24ZSP.js} +2 -2
- package/dist/{chunk-XWKL7QDH.js → chunk-KNBIEADY.js} +2 -2
- package/dist/{chunk-QOF5S5Z5.js → chunk-KYHZYRMR.js} +2 -2
- package/dist/{chunk-5F36KKHM.js → chunk-LB4UH4FF.js} +25 -4
- package/dist/chunk-LB4UH4FF.js.map +1 -0
- package/dist/{chunk-ZT6RBA7L.js → chunk-LMIR62SG.js} +2 -2
- package/dist/{chunk-QEZ5CS5H.js → chunk-LPBGCX6H.js} +2 -2
- package/dist/{chunk-JYTDEFY6.js → chunk-NQ2CC67G.js} +2 -2
- package/dist/{chunk-ZCNB6YJ3.js → chunk-NXHPOKIO.js} +4 -4
- package/dist/{chunk-M2TFLYPC.js → chunk-Q3DEXAOB.js} +7 -7
- package/dist/{chunk-LM5ZSWYB.js → chunk-QZJR42BR.js} +4 -4
- package/dist/{chunk-5YZF5DUW.js → chunk-R6YU33TY.js} +8 -8
- package/dist/{chunk-ZTH7YD3J.js → chunk-RIMEO4AY.js} +3 -3
- package/dist/{chunk-VE6ZMLCT.js → chunk-SPRQFHVR.js} +2 -2
- package/dist/{chunk-W3VI2AAJ.js → chunk-TOQVL64J.js} +3 -3
- package/dist/{chunk-KFKI2M4X.js → chunk-UCW7IIX6.js} +2 -2
- package/dist/{chunk-YZDCUGPS.js → chunk-Y5ATK7BS.js} +2 -2
- package/dist/{chunk-6THNSXDV.js → chunk-YBG6Y2UN.js} +8 -8
- package/dist/{chunk-EPIRYAU3.js → chunk-Z2EUE6E6.js} +2 -2
- package/dist/{chunk-64LODBD3.js → chunk-ZNPUVXMB.js} +2 -2
- package/dist/{cli-circuit-breaker-U2CTVGQ7.js → cli-circuit-breaker-NPISC6Q4.js} +3 -3
- package/dist/cli.js +41 -41
- package/dist/{composite-router-GQOZMVH7.js → composite-router-ULU3C7ZA.js} +2 -2
- package/dist/{consensus-vote-YUVGQZL7.js → consensus-vote-5XRP2OY4.js} +17 -17
- package/dist/{context-retriever-FHHESJMM.js → context-retriever-UDMXESPP.js} +8 -8
- package/dist/{doctor-deep-Y65MN57O.js → doctor-deep-E2UHOIOS.js} +3 -3
- package/dist/{doctor-live-SWFNSL5Y.js → doctor-live-52MCZLBK.js} +9 -9
- package/dist/{expert-bridge-Y75TQIEO.js → expert-bridge-KMJQGVUM.js} +4 -4
- package/dist/{factory-7BW4S6PR.js → factory-LCKPBDL2.js} +5 -5
- package/dist/{factory-EBM7Z7MP.js → factory-RPWJNOET.js} +9 -9
- package/dist/{improvement-review-QKDI3QDL.js → improvement-review-2R6UZ4PF.js} +6 -6
- package/dist/index.js +31 -31
- package/dist/{init-opencode-SSEA3UCA.js → init-opencode-AFES5ZQD.js} +6 -6
- package/dist/issue-triage-VVEGWHXP.js +17 -0
- package/dist/{pr-reviewer-helpers-245UWBYB.js → pr-reviewer-helpers-EJIWNM3Z.js} +4 -4
- package/dist/{registry-command-TPLFFKVI.js → registry-command-45SBK736.js} +2 -2
- package/dist/{repo-security-plan-C4JE7ZKQ.js → repo-security-plan-Z25BUZGY.js} +3 -3
- package/dist/{research-helpers-synthesize-ZZRDEX7R.js → research-helpers-synthesize-ILCLFNSL.js} +4 -4
- package/dist/{routing-memory-MLMNEIZD.js → routing-memory-SE3MTQSU.js} +2 -2
- package/dist/{session-memory-43TLUGSP.js → session-memory-JOJ5SHVX.js} +3 -3
- package/dist/{setup-config-LZWSAEL7.js → setup-config-IVLUCSF2.js} +3 -3
- package/dist/{setup-custom-api-UIIB2OYQ.js → setup-custom-api-G24JS2HB.js} +4 -4
- package/dist/setup-data-dir-VN2PMSVM.js +29 -0
- package/dist/{tool-memory-6HM6HC2C.js → tool-memory-O4XK27UO.js} +5 -5
- package/dist/{unified-registry-YYHYITVO.js → unified-registry-DPOXBGFQ.js} +10 -10
- package/dist/{weather-report-WCWQRH3K.js → weather-report-5SMT3RHJ.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-5F36KKHM.js.map +0 -1
- package/dist/chunk-5STSWEDG.js +0 -7
- package/dist/chunk-GVRDLRJM.js.map +0 -1
- package/dist/issue-triage-HQQ2TR4C.js +0 -17
- package/dist/setup-data-dir-NNBWZ2BK.js +0 -29
- /package/dist/{child-mcp-config-6UXFBHW5.js.map → child-mcp-config-HGD32ADZ.js.map} +0 -0
- /package/dist/{chunk-DZQWHHGI.js.map → chunk-3FPHHCY5.js.map} +0 -0
- /package/dist/{chunk-UONHQ3Q3.js.map → chunk-5FHJAPIR.js.map} +0 -0
- /package/dist/{chunk-5STSWEDG.js.map → chunk-AQBOZVBW.js.map} +0 -0
- /package/dist/{chunk-2TP7YLBC.js.map → chunk-BE6FQ7XI.js.map} +0 -0
- /package/dist/{chunk-XJ76EMQV.js.map → chunk-CLIZCXWB.js.map} +0 -0
- /package/dist/{chunk-BT534KOS.js.map → chunk-DPFRPNAC.js.map} +0 -0
- /package/dist/{chunk-MFORQ7FO.js.map → chunk-E6LGFJQE.js.map} +0 -0
- /package/dist/{chunk-47TTP5PC.js.map → chunk-FQQYGPMC.js.map} +0 -0
- /package/dist/{chunk-5LREI4NO.js.map → chunk-GRLN6WL5.js.map} +0 -0
- /package/dist/{chunk-5M3ZAK2V.js.map → chunk-HJUL6YRG.js.map} +0 -0
- /package/dist/{chunk-LX4DUS4M.js.map → chunk-ITB2NBB7.js.map} +0 -0
- /package/dist/{chunk-E2TILOO3.js.map → chunk-JLA2YAGY.js.map} +0 -0
- /package/dist/{chunk-T7NTJNCG.js.map → chunk-JLE24ZSP.js.map} +0 -0
- /package/dist/{chunk-XWKL7QDH.js.map → chunk-KNBIEADY.js.map} +0 -0
- /package/dist/{chunk-QOF5S5Z5.js.map → chunk-KYHZYRMR.js.map} +0 -0
- /package/dist/{chunk-ZT6RBA7L.js.map → chunk-LMIR62SG.js.map} +0 -0
- /package/dist/{chunk-QEZ5CS5H.js.map → chunk-LPBGCX6H.js.map} +0 -0
- /package/dist/{chunk-JYTDEFY6.js.map → chunk-NQ2CC67G.js.map} +0 -0
- /package/dist/{chunk-ZCNB6YJ3.js.map → chunk-NXHPOKIO.js.map} +0 -0
- /package/dist/{chunk-M2TFLYPC.js.map → chunk-Q3DEXAOB.js.map} +0 -0
- /package/dist/{chunk-LM5ZSWYB.js.map → chunk-QZJR42BR.js.map} +0 -0
- /package/dist/{chunk-5YZF5DUW.js.map → chunk-R6YU33TY.js.map} +0 -0
- /package/dist/{chunk-ZTH7YD3J.js.map → chunk-RIMEO4AY.js.map} +0 -0
- /package/dist/{chunk-VE6ZMLCT.js.map → chunk-SPRQFHVR.js.map} +0 -0
- /package/dist/{chunk-W3VI2AAJ.js.map → chunk-TOQVL64J.js.map} +0 -0
- /package/dist/{chunk-KFKI2M4X.js.map → chunk-UCW7IIX6.js.map} +0 -0
- /package/dist/{chunk-YZDCUGPS.js.map → chunk-Y5ATK7BS.js.map} +0 -0
- /package/dist/{chunk-6THNSXDV.js.map → chunk-YBG6Y2UN.js.map} +0 -0
- /package/dist/{chunk-EPIRYAU3.js.map → chunk-Z2EUE6E6.js.map} +0 -0
- /package/dist/{chunk-64LODBD3.js.map → chunk-ZNPUVXMB.js.map} +0 -0
- /package/dist/{cli-circuit-breaker-U2CTVGQ7.js.map → cli-circuit-breaker-NPISC6Q4.js.map} +0 -0
- /package/dist/{composite-router-GQOZMVH7.js.map → composite-router-ULU3C7ZA.js.map} +0 -0
- /package/dist/{consensus-vote-YUVGQZL7.js.map → consensus-vote-5XRP2OY4.js.map} +0 -0
- /package/dist/{context-retriever-FHHESJMM.js.map → context-retriever-UDMXESPP.js.map} +0 -0
- /package/dist/{doctor-deep-Y65MN57O.js.map → doctor-deep-E2UHOIOS.js.map} +0 -0
- /package/dist/{doctor-live-SWFNSL5Y.js.map → doctor-live-52MCZLBK.js.map} +0 -0
- /package/dist/{expert-bridge-Y75TQIEO.js.map → expert-bridge-KMJQGVUM.js.map} +0 -0
- /package/dist/{factory-7BW4S6PR.js.map → factory-LCKPBDL2.js.map} +0 -0
- /package/dist/{factory-EBM7Z7MP.js.map → factory-RPWJNOET.js.map} +0 -0
- /package/dist/{improvement-review-QKDI3QDL.js.map → improvement-review-2R6UZ4PF.js.map} +0 -0
- /package/dist/{init-opencode-SSEA3UCA.js.map → init-opencode-AFES5ZQD.js.map} +0 -0
- /package/dist/{issue-triage-HQQ2TR4C.js.map → issue-triage-VVEGWHXP.js.map} +0 -0
- /package/dist/{pr-reviewer-helpers-245UWBYB.js.map → pr-reviewer-helpers-EJIWNM3Z.js.map} +0 -0
- /package/dist/{registry-command-TPLFFKVI.js.map → registry-command-45SBK736.js.map} +0 -0
- /package/dist/{repo-security-plan-C4JE7ZKQ.js.map → repo-security-plan-Z25BUZGY.js.map} +0 -0
- /package/dist/{research-helpers-synthesize-ZZRDEX7R.js.map → research-helpers-synthesize-ILCLFNSL.js.map} +0 -0
- /package/dist/{routing-memory-MLMNEIZD.js.map → routing-memory-SE3MTQSU.js.map} +0 -0
- /package/dist/{session-memory-43TLUGSP.js.map → session-memory-JOJ5SHVX.js.map} +0 -0
- /package/dist/{setup-config-LZWSAEL7.js.map → setup-config-IVLUCSF2.js.map} +0 -0
- /package/dist/{setup-custom-api-UIIB2OYQ.js.map → setup-custom-api-G24JS2HB.js.map} +0 -0
- /package/dist/{setup-data-dir-NNBWZ2BK.js.map → setup-data-dir-VN2PMSVM.js.map} +0 -0
- /package/dist/{tool-memory-6HM6HC2C.js.map → tool-memory-O4XK27UO.js.map} +0 -0
- /package/dist/{unified-registry-YYHYITVO.js.map → unified-registry-DPOXBGFQ.js.map} +0 -0
- /package/dist/{weather-report-WCWQRH3K.js.map → weather-report-5SMT3RHJ.js.map} +0 -0
package/dist/chunk-5STSWEDG.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/learning/usage-log.ts"],"sourcesContent":["/**\n * usage-log — append-only per-call usage events with cost.\n *\n * Source: Issue #2469 (epic #2467 child).\n *\n * For operators running against metered API gateways, per-call cost +\n * tokens + latency is the data they need to manage spend. This module\n * provides three things:\n *\n * 1. `recordUsageEvent(event)` — append a per-call record to a JSONL\n * log under <NEXUS_DATA_DIR>/usage/usage-YYYY-MM.jsonl.\n * 2. `loadUsageEvents({...})` — read events for a window, filtered\n * by model / category.\n * 3. `computeCostDetail(modelId, inputTokens, outputTokens)` (and its\n * thin wrapper `computeCostUSD`) — compute cost from the FULL model\n * registry pricing chain (manifest > in-tree > models.dev > generated\n * LiteLLM catalog), including the #4164 normalized/identity resolution\n * tier for decorated gateway model ids. A model with no pricing\n * anywhere in the chain is reported as `priced: false` so consumers\n * can treat the missing cost as UNMEASURED (#3855), never a real $0.\n *\n * The `usage` CLI command (cli/usage-command.ts) consumes this for the\n * operator dashboard. Existing OutcomeStore is intentionally untouched\n * — its schema is for routing/learning signals, not billing.\n */\n\nimport { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';\nimport { computeTokenCost, roundToMicroUsd } from './token-cost-core.js';\nimport { dirname, join } from 'node:path';\n\nimport { getNexusDataDir } from '../config/nexus-data-dir.js';\n// NOTE: only the FUNCTION is imported here — `getDefaultRegistry()` must never\n// be CALLED at module scope (#3185 bootstrap hazard: first construction reads\n// the manifest overlay/snapshot from disk). All calls happen at invocation\n// time inside computeCostDetail.\nimport { getDefaultRegistry, type MatchedVia } from '../config/model-registry.js';\nimport type { PriceBasis } from '../core/price-basis.js';\n\nexport interface UsageEvent {\n /** ISO 8601 timestamp of the call. */\n readonly timestamp: string;\n /** Model identifier (e.g., 'claude-sonnet-4', 'gpt-4o'). */\n readonly modelId: string;\n /** Provider/adapter (e.g., 'anthropic', 'openai', 'openai-compat'). */\n readonly providerId: string;\n /** Token counts. */\n readonly inputTokens: number;\n readonly outputTokens: number;\n /**\n * Cost in USD. Computed at write time from the full model-registry pricing\n * chain (see `computeCostDetail`). 0 with `priced: false` means the model\n * was UNPRICED (cost unknown), not a real $0 — check `priced` before\n * treating this as a measured figure.\n */\n readonly usdCost: number;\n /** Wall-clock latency in milliseconds. */\n readonly latencyMs: number;\n /** Whether the call succeeded. */\n readonly success: boolean;\n /**\n * Optional task category — populated when the call was made on behalf of\n * a routed task (so aggregation can roll up by category).\n */\n readonly category?: string;\n /** Optional failure code when success === false. */\n readonly errorCode?: string;\n /**\n * Whether pricing data existed for the model at write time (#4165), so\n * audit can distinguish a real $0 from an unpriced model. Absent on lines\n * written before this field existed.\n */\n readonly priced?: boolean;\n /**\n * Pricing provenance: the canonical registry id whose pricing was applied\n * (the entry's `resolvedFrom` when the #4164 fuzzy tier matched a decorated\n * id, else the caller's model id). Present only when `priced` is true.\n */\n readonly priceSource?: string;\n}\n\n/** Result of a pricing-aware cost computation (#4165). */\nexport interface CostDetail {\n /** Cost in USD. Always 0 when `priced` is false — an unknown, not a $0. */\n readonly costUsd: number;\n /** Whether the resolved registry entry carried pricing data. */\n readonly priced: boolean;\n /**\n * Canonical id the pricing/metadata came from: the entry's `resolvedFrom`\n * when the #4164 fuzzy tier matched a decorated id, else the caller's id.\n */\n readonly resolvedId: string;\n /** Fuzzy-resolution provenance (#4164), passed through from the entry. */\n readonly matchedVia?: MatchedVia;\n}\n\n/**\n * Compute cost in USD given a model and token counts, with pricing\n * provenance. Reads the FULL registry chain via\n * `getDefaultRegistry().getEntry()` — manifest > in-tree > models.dev >\n * generated LiteLLM catalog, plus the #4164 normalized/identity tier that\n * resolves decorated model names from OpenAI-compatible gateways to their\n * canonical entry's pricing.\n *\n * `priced: false` (with `costUsd: 0`) means NO pricing existed anywhere in\n * the chain — consumers must treat the cost as UNMEASURED (#3855), never a\n * real $0. Operators can add pricing for gateway-only models via the\n * models-manifest overlay.\n */\nexport function computeCostDetail(\n modelId: string,\n inputTokens: number,\n outputTokens: number\n): CostDetail {\n // Registry read happens at INVOCATION time, never module load — first\n // construction touches the filesystem (#3185 bootstrap hazard).\n const entry = getDefaultRegistry().getEntry(modelId);\n const resolvedId = entry.resolvedFrom ?? modelId;\n const provenance = entry.matchedVia !== undefined ? { matchedVia: entry.matchedVia } : {};\n if (entry.pricing === undefined) {\n return { costUsd: 0, priced: false, resolvedId, ...provenance };\n }\n // The arithmetic lives in the shared core (#5122); this function is the\n // REGISTRY-BACKED, LEDGER-ROUNDED wrapper over it. Rounding to micro-USD\n // stays here rather than in the core: it exists so this log's JSONL does not\n // drift into floating-point noise across many small calls, which is a ledger\n // requirement, not a property of cost.\n const { costUsd } = computeTokenCost(\n { input: inputTokens, output: outputTokens },\n { inputPer1M: entry.pricing.inputPer1M, outputPer1M: entry.pricing.outputPer1M }\n );\n return { costUsd: roundToMicroUsd(costUsd), priced: true, resolvedId, ...provenance };\n}\n\n/**\n * The {@link PriceBasis} the cost in a {@link CostDetail} rests on (#4406).\n *\n * DELIBERATELY derived rather than stored, because `CostDetail.priced` already\n * carries the only distinction the current two-member union can express: the\n * chain resolved a rate, or it did not. A `priceBasis` property beside `priced`\n * would be a second spelling of the same boolean.\n *\n * WHAT THE `'list'` VALUE ASSERTS. Only that a rate was resolved, and that it\n * should be read as an assumed published rate. It is NOT a guarantee that the\n * number is a vendor's advertised public rate — at least two paths put\n * something else behind the label, and one puts a real published rate behind\n * `'unknown'`:\n *\n * - The operator manifest overlay is the highest-precedence tier and passes\n * `pricing` through; overriding pricing is its purpose. A negotiated rate\n * entered there reports `'list'`, and the caveat then warns the reader their\n * contract may differ over the contract rate.\n * - The normalized/fuzzy identity tier lets a decorated gateway id inherit a\n * DIFFERENT canonical entry's rate.\n * - `config/models-generated-loader.ts` discards a published $0/$0 rate unless\n * the id ends `:free`, so `'unknown'` does not mean no price exists.\n *\n * The derivation is therefore an assumption about the chain, not a fact about\n * it — conservative in the right direction (it invites a caveat rather than\n * suppressing one), and honest only if described this way. Narrowing it needs a\n * per-entry label the registry does not carry today; see {@link PriceBasis}.\n *\n * `priceSource`, the other provenance field, answers a different question: WHICH\n * registry entry supplied the number, not what KIND of rate it is. It does not\n * encode the basis, which is why the basis has to travel separately into records\n * (the decision-cost store) that persist neither field.\n */\nexport function priceBasisOf(detail: CostDetail): PriceBasis {\n return detail.priced ? 'list' : 'unknown';\n}\n\n/**\n * Thin wrapper over {@link computeCostDetail} returning only the USD figure.\n * Returns 0 both for a genuinely free model and for a model with no pricing\n * data — callers that must tell those apart (unpriced ⇒ UNMEASURED, #3855)\n * should use `computeCostDetail` and check `priced`.\n */\nexport function computeCostUSD(modelId: string, inputTokens: number, outputTokens: number): number {\n return computeCostDetail(modelId, inputTokens, outputTokens).costUsd;\n}\n\n/** Resolve the active usage log path for the current month. */\nexport function getUsageLogPath(date: Date = new Date()): string {\n const year = date.getUTCFullYear();\n const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n return join(getNexusDataDir(), 'usage', `usage-${String(year)}-${month}.jsonl`);\n}\n\n/**\n * Append a usage event to the current month's log. Best-effort — failures\n * are silent (we don't want to fail a successful model call because we\n * couldn't write a log line).\n */\nexport function recordUsageEvent(event: UsageEvent): void {\n try {\n const path = getUsageLogPath(new Date(event.timestamp));\n mkdirSync(dirname(path), { recursive: true });\n appendFileSync(path, `${JSON.stringify(event)}\\n`, 'utf-8');\n } catch {\n // Intentionally silent — telemetry must not break user calls.\n }\n}\n\nexport interface LoadUsageOptions {\n /** Restrict to events at or after this ISO timestamp. */\n readonly sinceIso?: string;\n /** Restrict to events before this ISO timestamp. */\n readonly untilIso?: string;\n /** Only events for this model. */\n readonly modelId?: string;\n /** Only events for this category. */\n readonly category?: string;\n}\n\nfunction listUsageFiles(dir: string): readonly string[] {\n if (!existsSync(dir)) return [];\n try {\n return readdirSync(dir).filter((f) => f.startsWith('usage-') && f.endsWith('.jsonl'));\n } catch {\n return [];\n }\n}\n\ninterface LoadFilter {\n readonly sinceMs: number;\n readonly untilMs: number;\n readonly modelId: string | undefined;\n readonly category: string | undefined;\n}\n\nfunction eventMatches(parsed: UsageEvent, f: LoadFilter): boolean {\n const ts = Date.parse(parsed.timestamp);\n if (ts < f.sinceMs || ts >= f.untilMs) return false;\n if (f.modelId !== undefined && parsed.modelId !== f.modelId) return false;\n if (f.category !== undefined && parsed.category !== f.category) return false;\n return true;\n}\n\nfunction parseFileLines(filePath: string, filter: LoadFilter): readonly UsageEvent[] {\n let content: string;\n try {\n content = readFileSync(filePath, 'utf-8');\n } catch {\n return [];\n }\n const out: UsageEvent[] = [];\n for (const line of content.split('\\n')) {\n if (line.trim() === '') continue;\n try {\n const parsed = JSON.parse(line) as UsageEvent;\n if (eventMatches(parsed, filter)) out.push(parsed);\n } catch {\n // Skip malformed line; keep reading.\n continue;\n }\n }\n return out;\n}\n\n/**\n * Load all usage events from disk that match the filter. Reads every\n * monthly log file under the data dir; for sub-second filtering at scale\n * a future PR can index by month, but linear scan is fine at the\n * \"operator dashboard\" scale this command targets.\n */\nexport function loadUsageEvents(opts: LoadUsageOptions = {}): readonly UsageEvent[] {\n const dir = join(getNexusDataDir(), 'usage');\n const files = listUsageFiles(dir);\n if (files.length === 0) return [];\n const filter: LoadFilter = {\n sinceMs: opts.sinceIso !== undefined ? Date.parse(opts.sinceIso) : Number.NEGATIVE_INFINITY,\n untilMs: opts.untilIso !== undefined ? Date.parse(opts.untilIso) : Number.POSITIVE_INFINITY,\n modelId: opts.modelId,\n category: opts.category,\n };\n const events: UsageEvent[] = [];\n for (const f of files) {\n events.push(...parseFileLines(join(dir, f), filter));\n }\n return events;\n}\n\nexport interface ModelRollup {\n readonly modelId: string;\n readonly providerId: string;\n readonly callCount: number;\n readonly successCount: number;\n readonly successRate: number;\n readonly totalInputTokens: number;\n readonly totalOutputTokens: number;\n readonly totalUsdCost: number;\n readonly avgLatencyMs: number;\n readonly costPerSuccessUsd: number;\n}\n\n/**\n * Aggregate events into per-model rollups. Sorted by total cost descending\n * — the model burning the most money at top. Useful for \"where is my spend\n * going?\" investigations.\n */\nexport function rollupByModel(events: readonly UsageEvent[]): readonly ModelRollup[] {\n const groups = new Map<string, UsageEvent[]>();\n for (const e of events) {\n const arr = groups.get(e.modelId);\n if (arr === undefined) groups.set(e.modelId, [e]);\n else arr.push(e);\n }\n const rollups: ModelRollup[] = [];\n for (const [modelId, group] of groups) {\n const callCount = group.length;\n const successCount = group.filter((e) => e.success).length;\n const totalInputTokens = group.reduce((s, e) => s + e.inputTokens, 0);\n const totalOutputTokens = group.reduce((s, e) => s + e.outputTokens, 0);\n const totalUsdCost = group.reduce((s, e) => s + e.usdCost, 0);\n const totalLatency = group.reduce((s, e) => s + e.latencyMs, 0);\n const successRate = callCount === 0 ? 0 : successCount / callCount;\n const avgLatencyMs = callCount === 0 ? 0 : totalLatency / callCount;\n const costPerSuccessUsd = successCount === 0 ? totalUsdCost : totalUsdCost / successCount;\n rollups.push({\n modelId,\n providerId: group[0]?.providerId ?? 'unknown',\n callCount,\n successCount,\n successRate,\n totalInputTokens,\n totalOutputTokens,\n totalUsdCost,\n avgLatencyMs,\n costPerSuccessUsd,\n });\n }\n return rollups.sort((a, b) => b.totalUsdCost - a.totalUsdCost);\n}\n"],"mappings":";;;;;;;;;;AA0BA,SAAS,gBAAgB,YAAY,WAAW,cAAc,mBAAmB;AAEjF,SAAS,SAAS,YAAY;AAgFvB,SAAS,kBACd,SACA,aACA,cACY;AAGZ,QAAM,QAAQ,mBAAmB,EAAE,SAAS,OAAO;AACnD,QAAM,aAAa,MAAM,gBAAgB;AACzC,QAAM,aAAa,MAAM,eAAe,SAAY,EAAE,YAAY,MAAM,WAAW,IAAI,CAAC;AACxF,MAAI,MAAM,YAAY,QAAW;AAC/B,WAAO,EAAE,SAAS,GAAG,QAAQ,OAAO,YAAY,GAAG,WAAW;AAAA,EAChE;AAMA,QAAM,EAAE,QAAQ,IAAI;AAAA,IAClB,EAAE,OAAO,aAAa,QAAQ,aAAa;AAAA,IAC3C,EAAE,YAAY,MAAM,QAAQ,YAAY,aAAa,MAAM,QAAQ,YAAY;AAAA,EACjF;AACA,SAAO,EAAE,SAAS,gBAAgB,OAAO,GAAG,QAAQ,MAAM,YAAY,GAAG,WAAW;AACtF;AAmCO,SAAS,aAAa,QAAgC;AAC3D,SAAO,OAAO,SAAS,SAAS;AAClC;AAaO,SAAS,gBAAgB,OAAa,oBAAI,KAAK,GAAW;AAC/D,QAAM,OAAO,KAAK,eAAe;AACjC,QAAM,QAAQ,OAAO,KAAK,YAAY,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AAC5D,SAAO,KAAK,gBAAgB,GAAG,SAAS,SAAS,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;AAChF;AAOO,SAAS,iBAAiB,OAAyB;AACxD,MAAI;AACF,UAAM,OAAO,gBAAg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AAK;AAAA,MACX;AAAA,MACA,YAAY,MAAM,CAAC,GAAG,cAAc;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO,QAAQ,KAAK,CAAC,GAAG,MAAM,EAAE,eAAe,EAAE,YAAY;AAC/D;","names":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IssueTriage,
|
|
3
|
-
createIssueTriage
|
|
4
|
-
} from "./chunk-LX4DUS4M.js";
|
|
5
|
-
import "./chunk-KFKI2M4X.js";
|
|
6
|
-
import "./chunk-JYTDEFY6.js";
|
|
7
|
-
import "./chunk-QOF5S5Z5.js";
|
|
8
|
-
import "./chunk-YZDCUGPS.js";
|
|
9
|
-
import "./chunk-5F36KKHM.js";
|
|
10
|
-
import "./chunk-GBHJ37V3.js";
|
|
11
|
-
import "./chunk-OGHEKPLD.js";
|
|
12
|
-
import "./chunk-ZPWHCABL.js";
|
|
13
|
-
export {
|
|
14
|
-
IssueTriage,
|
|
15
|
-
createIssueTriage
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=issue-triage-HQQ2TR4C.js.map
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NEXUS_DATA_DIR,
|
|
3
|
-
describeDataDirFix,
|
|
4
|
-
initDataDirectories
|
|
5
|
-
} from "./chunk-BT534KOS.js";
|
|
6
|
-
import "./chunk-E2TILOO3.js";
|
|
7
|
-
import "./chunk-GVRDLRJM.js";
|
|
8
|
-
import "./chunk-OQB3XC5O.js";
|
|
9
|
-
import "./chunk-5STSWEDG.js";
|
|
10
|
-
import "./chunk-6T3EPABN.js";
|
|
11
|
-
import "./chunk-5YZF5DUW.js";
|
|
12
|
-
import "./chunk-UONHQ3Q3.js";
|
|
13
|
-
import "./chunk-QEZ5CS5H.js";
|
|
14
|
-
import "./chunk-EPIRYAU3.js";
|
|
15
|
-
import "./chunk-4OW67KT2.js";
|
|
16
|
-
import "./chunk-XWKL7QDH.js";
|
|
17
|
-
import "./chunk-QZUG667L.js";
|
|
18
|
-
import "./chunk-T7NTJNCG.js";
|
|
19
|
-
import "./chunk-ZT6RBA7L.js";
|
|
20
|
-
import "./chunk-5F36KKHM.js";
|
|
21
|
-
import "./chunk-GBHJ37V3.js";
|
|
22
|
-
import "./chunk-OGHEKPLD.js";
|
|
23
|
-
import "./chunk-ZPWHCABL.js";
|
|
24
|
-
export {
|
|
25
|
-
NEXUS_DATA_DIR,
|
|
26
|
-
describeDataDirFix,
|
|
27
|
-
initDataDirectories
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=setup-data-dir-NNBWZ2BK.js.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|