@ironbee-ai/cli 0.6.1 → 0.7.0
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/CHANGELOG.md +12 -0
- package/README.md +167 -39
- package/dist/analysis/code-changes.js +3 -3
- package/dist/analysis/code-changes.js.map +1 -1
- package/dist/analysis/cross-session.js.map +1 -1
- package/dist/analysis/fix-effectiveness.js.map +1 -1
- package/dist/analysis/time-analysis.js.map +1 -1
- package/dist/analysis/verdict-details.js.map +1 -1
- package/dist/analysis/verification-quality.js.map +1 -1
- package/dist/analytics/classifier.d.ts +99 -0
- package/dist/analytics/classifier.d.ts.map +1 -0
- package/dist/analytics/classifier.js +380 -0
- package/dist/analytics/classifier.js.map +1 -0
- package/dist/analytics/emit.d.ts +67 -0
- package/dist/analytics/emit.d.ts.map +1 -0
- package/dist/analytics/emit.js +901 -0
- package/dist/analytics/emit.js.map +1 -0
- package/dist/analytics/errors.d.ts +33 -0
- package/dist/analytics/errors.d.ts.map +1 -0
- package/dist/analytics/errors.js +93 -0
- package/dist/analytics/errors.js.map +1 -0
- package/dist/analytics/hook-trigger.d.ts +39 -0
- package/dist/analytics/hook-trigger.d.ts.map +1 -0
- package/dist/analytics/hook-trigger.js +127 -0
- package/dist/analytics/hook-trigger.js.map +1 -0
- package/dist/analytics/log.d.ts +44 -0
- package/dist/analytics/log.d.ts.map +1 -0
- package/dist/analytics/log.js +158 -0
- package/dist/analytics/log.js.map +1 -0
- package/dist/analytics/merge.d.ts +40 -0
- package/dist/analytics/merge.d.ts.map +1 -0
- package/dist/analytics/merge.js +527 -0
- package/dist/analytics/merge.js.map +1 -0
- package/dist/analytics/pricing.d.ts +149 -0
- package/dist/analytics/pricing.d.ts.map +1 -0
- package/dist/analytics/pricing.js +179 -0
- package/dist/analytics/pricing.js.map +1 -0
- package/dist/analytics/projection.d.ts +356 -0
- package/dist/analytics/projection.d.ts.map +1 -0
- package/dist/analytics/projection.js +2281 -0
- package/dist/analytics/projection.js.map +1 -0
- package/dist/analytics/spawn.d.ts +28 -0
- package/dist/analytics/spawn.d.ts.map +1 -0
- package/dist/analytics/spawn.js +57 -0
- package/dist/analytics/spawn.js.map +1 -0
- package/dist/analytics/state.d.ts +58 -0
- package/dist/analytics/state.d.ts.map +1 -0
- package/dist/analytics/state.js +329 -0
- package/dist/analytics/state.js.map +1 -0
- package/dist/analytics/transcript.d.ts +150 -0
- package/dist/analytics/transcript.d.ts.map +1 -0
- package/dist/analytics/transcript.js +276 -0
- package/dist/analytics/transcript.js.map +1 -0
- package/dist/analytics/types.d.ts +875 -0
- package/dist/analytics/types.d.ts.map +1 -0
- package/dist/analytics/types.js +31 -0
- package/dist/analytics/types.js.map +1 -0
- package/dist/clients/base.d.ts +21 -2
- package/dist/clients/base.d.ts.map +1 -1
- package/dist/clients/claude/commands/ironbee-verify.md +15 -7
- package/dist/clients/claude/fragments/command-verify.node.md +33 -0
- package/dist/clients/claude/fragments/rule.node.md +29 -0
- package/dist/clients/claude/fragments/skill.node.md +77 -0
- package/dist/clients/claude/hooks/activity-end.d.ts +13 -0
- package/dist/clients/claude/hooks/activity-end.d.ts.map +1 -0
- package/dist/clients/claude/hooks/activity-end.js +42 -0
- package/dist/clients/claude/hooks/activity-end.js.map +1 -0
- package/dist/clients/claude/hooks/clear-verdict.d.ts +9 -4
- package/dist/clients/claude/hooks/clear-verdict.d.ts.map +1 -1
- package/dist/clients/claude/hooks/clear-verdict.js +50 -12
- package/dist/clients/claude/hooks/clear-verdict.js.map +1 -1
- package/dist/clients/claude/hooks/require-verdict.d.ts +8 -3
- package/dist/clients/claude/hooks/require-verdict.d.ts.map +1 -1
- package/dist/clients/claude/hooks/require-verdict.js +17 -6
- package/dist/clients/claude/hooks/require-verdict.js.map +1 -1
- package/dist/clients/claude/hooks/require-verification.d.ts +7 -4
- package/dist/clients/claude/hooks/require-verification.d.ts.map +1 -1
- package/dist/clients/claude/hooks/require-verification.js +44 -22
- package/dist/clients/claude/hooks/require-verification.js.map +1 -1
- package/dist/clients/claude/hooks/session-end.d.ts.map +1 -1
- package/dist/clients/claude/hooks/session-end.js +17 -2
- package/dist/clients/claude/hooks/session-end.js.map +1 -1
- package/dist/clients/claude/hooks/session-start.d.ts.map +1 -1
- package/dist/clients/claude/hooks/session-start.js +2 -1
- package/dist/clients/claude/hooks/session-start.js.map +1 -1
- package/dist/clients/claude/hooks/track-action-monitor.d.ts +27 -0
- package/dist/clients/claude/hooks/track-action-monitor.d.ts.map +1 -0
- package/dist/clients/claude/hooks/track-action-monitor.js +126 -0
- package/dist/clients/claude/hooks/track-action-monitor.js.map +1 -0
- package/dist/clients/claude/hooks/track-action.d.ts.map +1 -1
- package/dist/clients/claude/hooks/track-action.js +29 -20
- package/dist/clients/claude/hooks/track-action.js.map +1 -1
- package/dist/clients/claude/hooks/verify-gate.d.ts.map +1 -1
- package/dist/clients/claude/hooks/verify-gate.js +18 -1
- package/dist/clients/claude/hooks/verify-gate.js.map +1 -1
- package/dist/clients/claude/index.d.ts +4 -1
- package/dist/clients/claude/index.d.ts.map +1 -1
- package/dist/clients/claude/index.js +185 -94
- package/dist/clients/claude/index.js.map +1 -1
- package/dist/clients/claude/rules/ironbee-verification.md +41 -33
- package/dist/clients/claude/skills/ironbee-verification.md +93 -76
- package/dist/clients/cursor/commands/ironbee-verify/SKILL.md +18 -10
- package/dist/clients/cursor/fragments/command-verify.node.md +33 -0
- package/dist/clients/cursor/fragments/rule.node.md +29 -0
- package/dist/clients/cursor/fragments/skill.node.md +77 -0
- package/dist/clients/cursor/hooks/activity-end.d.ts +14 -0
- package/dist/clients/cursor/hooks/activity-end.d.ts.map +1 -0
- package/dist/clients/cursor/hooks/activity-end.js +45 -0
- package/dist/clients/cursor/hooks/activity-end.js.map +1 -0
- package/dist/clients/cursor/hooks/clear-verdict.d.ts +13 -4
- package/dist/clients/cursor/hooks/clear-verdict.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/clear-verdict.js +59 -14
- package/dist/clients/cursor/hooks/clear-verdict.js.map +1 -1
- package/dist/clients/cursor/hooks/require-verdict.d.ts +8 -3
- package/dist/clients/cursor/hooks/require-verdict.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/require-verdict.js +17 -6
- package/dist/clients/cursor/hooks/require-verdict.js.map +1 -1
- package/dist/clients/cursor/hooks/require-verification.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/require-verification.js +42 -16
- package/dist/clients/cursor/hooks/require-verification.js.map +1 -1
- package/dist/clients/cursor/hooks/session-end.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/session-end.js +18 -2
- package/dist/clients/cursor/hooks/session-end.js.map +1 -1
- package/dist/clients/cursor/hooks/session-start.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/session-start.js +2 -1
- package/dist/clients/cursor/hooks/session-start.js.map +1 -1
- package/dist/clients/cursor/hooks/track-action-monitor.d.ts +27 -0
- package/dist/clients/cursor/hooks/track-action-monitor.d.ts.map +1 -0
- package/dist/clients/cursor/hooks/track-action-monitor.js +133 -0
- package/dist/clients/cursor/hooks/track-action-monitor.js.map +1 -0
- package/dist/clients/cursor/hooks/track-action.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/track-action.js +51 -23
- package/dist/clients/cursor/hooks/track-action.js.map +1 -1
- package/dist/clients/cursor/hooks/verify-gate.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/verify-gate.js +14 -1
- package/dist/clients/cursor/hooks/verify-gate.js.map +1 -1
- package/dist/clients/cursor/index.d.ts +4 -1
- package/dist/clients/cursor/index.d.ts.map +1 -1
- package/dist/clients/cursor/index.js +131 -65
- package/dist/clients/cursor/index.js.map +1 -1
- package/dist/clients/cursor/rules/ironbee-verification.mdc +37 -29
- package/dist/clients/cursor/skills/ironbee-verification.md +93 -76
- package/dist/clients/registry.d.ts +14 -0
- package/dist/clients/registry.d.ts.map +1 -1
- package/dist/clients/registry.js +34 -0
- package/dist/clients/registry.js.map +1 -1
- package/dist/commands/analyze.d.ts.map +1 -1
- package/dist/commands/analyze.js +40 -0
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/backend-toggle.d.ts +45 -0
- package/dist/commands/backend-toggle.d.ts.map +1 -0
- package/dist/commands/backend-toggle.js +192 -0
- package/dist/commands/backend-toggle.js.map +1 -0
- package/dist/commands/disable-backend.d.ts +14 -0
- package/dist/commands/disable-backend.d.ts.map +1 -0
- package/dist/commands/disable-backend.js +34 -0
- package/dist/commands/disable-backend.js.map +1 -0
- package/dist/commands/disable-verification.d.ts +16 -0
- package/dist/commands/disable-verification.d.ts.map +1 -0
- package/dist/commands/disable-verification.js +36 -0
- package/dist/commands/disable-verification.js.map +1 -0
- package/dist/commands/enable-backend.d.ts +15 -0
- package/dist/commands/enable-backend.d.ts.map +1 -0
- package/dist/commands/enable-backend.js +35 -0
- package/dist/commands/enable-backend.js.map +1 -0
- package/dist/commands/enable-verification.d.ts +14 -0
- package/dist/commands/enable-verification.d.ts.map +1 -0
- package/dist/commands/enable-verification.js +34 -0
- package/dist/commands/enable-verification.js.map +1 -0
- package/dist/commands/hook.d.ts.map +1 -1
- package/dist/commands/hook.js +60 -0
- package/dist/commands/hook.js.map +1 -1
- package/dist/commands/import.d.ts +39 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +369 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +15 -20
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/process-analytics.d.ts +18 -0
- package/dist/commands/process-analytics.d.ts.map +1 -0
- package/dist/commands/process-analytics.js +57 -0
- package/dist/commands/process-analytics.js.map +1 -0
- package/dist/commands/queue.d.ts +2 -3
- package/dist/commands/queue.d.ts.map +1 -1
- package/dist/commands/queue.js +2 -3
- package/dist/commands/queue.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +29 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/verification-toggle.d.ts +47 -0
- package/dist/commands/verification-toggle.d.ts.map +1 -0
- package/dist/commands/verification-toggle.js +113 -0
- package/dist/commands/verification-toggle.js.map +1 -0
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +28 -0
- package/dist/commands/verify.js.map +1 -1
- package/dist/hooks/core/actions.d.ts +77 -70
- package/dist/hooks/core/actions.d.ts.map +1 -1
- package/dist/hooks/core/actions.js +45 -30
- package/dist/hooks/core/actions.js.map +1 -1
- package/dist/hooks/core/activity-end.d.ts +20 -0
- package/dist/hooks/core/activity-end.d.ts.map +1 -0
- package/dist/hooks/core/activity-end.js +23 -0
- package/dist/hooks/core/activity-end.js.map +1 -0
- package/dist/hooks/core/file-diff.d.ts +19 -0
- package/dist/hooks/core/file-diff.d.ts.map +1 -0
- package/dist/hooks/core/file-diff.js +39 -0
- package/dist/hooks/core/file-diff.js.map +1 -0
- package/dist/hooks/core/required-tools.d.ts +30 -0
- package/dist/hooks/core/required-tools.d.ts.map +1 -0
- package/dist/hooks/core/required-tools.js +70 -0
- package/dist/hooks/core/required-tools.js.map +1 -0
- package/dist/hooks/core/session-state.d.ts +12 -3
- package/dist/hooks/core/session-state.d.ts.map +1 -1
- package/dist/hooks/core/session-state.js +59 -0
- package/dist/hooks/core/session-state.js.map +1 -1
- package/dist/hooks/core/submit-verdict.d.ts.map +1 -1
- package/dist/hooks/core/submit-verdict.js +16 -12
- package/dist/hooks/core/submit-verdict.js.map +1 -1
- package/dist/hooks/core/tool-use-stash.d.ts +41 -0
- package/dist/hooks/core/tool-use-stash.d.ts.map +1 -0
- package/dist/hooks/core/tool-use-stash.js +82 -0
- package/dist/hooks/core/tool-use-stash.js.map +1 -0
- package/dist/hooks/core/verify-gate.d.ts +17 -3
- package/dist/hooks/core/verify-gate.d.ts.map +1 -1
- package/dist/hooks/core/verify-gate.js +315 -119
- package/dist/hooks/core/verify-gate.js.map +1 -1
- package/dist/import/claude/analytics-runner.d.ts +42 -0
- package/dist/import/claude/analytics-runner.d.ts.map +1 -0
- package/dist/import/claude/analytics-runner.js +213 -0
- package/dist/import/claude/analytics-runner.js.map +1 -0
- package/dist/import/claude/discovery.d.ts +22 -0
- package/dist/import/claude/discovery.d.ts.map +1 -0
- package/dist/import/claude/discovery.js +197 -0
- package/dist/import/claude/discovery.js.map +1 -0
- package/dist/import/claude/encoding.d.ts +50 -0
- package/dist/import/claude/encoding.d.ts.map +1 -0
- package/dist/import/claude/encoding.js +110 -0
- package/dist/import/claude/encoding.js.map +1 -0
- package/dist/import/claude/events/file-change.d.ts +28 -0
- package/dist/import/claude/events/file-change.d.ts.map +1 -0
- package/dist/import/claude/events/file-change.js +112 -0
- package/dist/import/claude/events/file-change.js.map +1 -0
- package/dist/import/claude/events/tool-call.d.ts +61 -0
- package/dist/import/claude/events/tool-call.d.ts.map +1 -0
- package/dist/import/claude/events/tool-call.js +119 -0
- package/dist/import/claude/events/tool-call.js.map +1 -0
- package/dist/import/claude/runner.d.ts +31 -0
- package/dist/import/claude/runner.d.ts.map +1 -0
- package/dist/import/claude/runner.js +280 -0
- package/dist/import/claude/runner.js.map +1 -0
- package/dist/import/claude/summary.d.ts +23 -0
- package/dist/import/claude/summary.d.ts.map +1 -0
- package/dist/import/claude/summary.js +186 -0
- package/dist/import/claude/summary.js.map +1 -0
- package/dist/import/claude/transcript-walk.d.ts +52 -0
- package/dist/import/claude/transcript-walk.d.ts.map +1 -0
- package/dist/import/claude/transcript-walk.js +187 -0
- package/dist/import/claude/transcript-walk.js.map +1 -0
- package/dist/import/concurrent-pool.d.ts +45 -0
- package/dist/import/concurrent-pool.d.ts.map +1 -0
- package/dist/import/concurrent-pool.js +95 -0
- package/dist/import/concurrent-pool.js.map +1 -0
- package/dist/import/emitter.d.ts +29 -0
- package/dist/import/emitter.d.ts.map +1 -0
- package/dist/import/emitter.js +66 -0
- package/dist/import/emitter.js.map +1 -0
- package/dist/import/events/activity.d.ts +23 -0
- package/dist/import/events/activity.d.ts.map +1 -0
- package/dist/import/events/activity.js +45 -0
- package/dist/import/events/activity.js.map +1 -0
- package/dist/import/events/session.d.ts +24 -0
- package/dist/import/events/session.d.ts.map +1 -0
- package/dist/import/events/session.js +47 -0
- package/dist/import/events/session.js.map +1 -0
- package/dist/import/filter.d.ts +47 -0
- package/dist/import/filter.d.ts.map +1 -0
- package/dist/import/filter.js +90 -0
- package/dist/import/filter.js.map +1 -0
- package/dist/import/ids.d.ts +56 -0
- package/dist/import/ids.d.ts.map +1 -0
- package/dist/import/ids.js +87 -0
- package/dist/import/ids.js.map +1 -0
- package/dist/import/index.d.ts +29 -0
- package/dist/import/index.d.ts.map +1 -0
- package/dist/import/index.js +52 -0
- package/dist/import/index.js.map +1 -0
- package/dist/import/marker.d.ts +20 -0
- package/dist/import/marker.d.ts.map +1 -0
- package/dist/import/marker.js +71 -0
- package/dist/import/marker.js.map +1 -0
- package/dist/import/pipeline.d.ts +41 -0
- package/dist/import/pipeline.d.ts.map +1 -0
- package/dist/import/pipeline.js +47 -0
- package/dist/import/pipeline.js.map +1 -0
- package/dist/import/progress.d.ts +20 -0
- package/dist/import/progress.d.ts.map +1 -0
- package/dist/import/progress.js +69 -0
- package/dist/import/progress.js.map +1 -0
- package/dist/import/skip.d.ts +13 -0
- package/dist/import/skip.d.ts.map +1 -0
- package/dist/import/skip.js +24 -0
- package/dist/import/skip.js.map +1 -0
- package/dist/import/types.d.ts +125 -0
- package/dist/import/types.d.ts.map +1 -0
- package/dist/import/types.js +28 -0
- package/dist/import/types.js.map +1 -0
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/collector.d.ts +29 -3
- package/dist/lib/collector.d.ts.map +1 -1
- package/dist/lib/collector.js +118 -8
- package/dist/lib/collector.js.map +1 -1
- package/dist/lib/config.d.ts +240 -83
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +482 -89
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/event.d.ts +72 -0
- package/dist/lib/event.d.ts.map +1 -0
- package/dist/lib/event.js +42 -0
- package/dist/lib/event.js.map +1 -0
- package/dist/lib/gitignore.d.ts +21 -0
- package/dist/lib/gitignore.d.ts.map +1 -0
- package/dist/lib/gitignore.js +54 -0
- package/dist/lib/gitignore.js.map +1 -0
- package/dist/lib/runtime-section.d.ts +118 -0
- package/dist/lib/runtime-section.d.ts.map +1 -0
- package/dist/lib/runtime-section.js +256 -0
- package/dist/lib/runtime-section.js.map +1 -0
- package/dist/lib/telemetry.d.ts +1 -1
- package/dist/lib/telemetry.d.ts.map +1 -1
- package/dist/lib/telemetry.js +4 -1
- package/dist/lib/telemetry.js.map +1 -1
- package/dist/queue/dead-letter.d.ts +5 -1
- package/dist/queue/dead-letter.d.ts.map +1 -1
- package/dist/queue/dead-letter.js +5 -1
- package/dist/queue/dead-letter.js.map +1 -1
- package/dist/queue/drain.d.ts +3 -2
- package/dist/queue/drain.d.ts.map +1 -1
- package/dist/queue/drain.js +3 -2
- package/dist/queue/drain.js.map +1 -1
- package/dist/queue/flush.d.ts +28 -12
- package/dist/queue/flush.d.ts.map +1 -1
- package/dist/queue/flush.js +43 -18
- package/dist/queue/flush.js.map +1 -1
- package/dist/queue/handlers/send-event.d.ts.map +1 -1
- package/dist/queue/handlers/send-event.js.map +1 -1
- package/dist/queue/index.d.ts +1 -2
- package/dist/queue/index.d.ts.map +1 -1
- package/dist/queue/index.js +2 -2
- package/dist/queue/index.js.map +1 -1
- package/dist/queue/paths.d.ts +4 -2
- package/dist/queue/paths.d.ts.map +1 -1
- package/dist/queue/paths.js +4 -2
- package/dist/queue/paths.js.map +1 -1
- package/dist/queue/process-file.d.ts +5 -1
- package/dist/queue/process-file.d.ts.map +1 -1
- package/dist/queue/process-file.js +5 -1
- package/dist/queue/process-file.js.map +1 -1
- package/dist/queue/snapshot.d.ts +4 -1
- package/dist/queue/snapshot.d.ts.map +1 -1
- package/dist/queue/snapshot.js +4 -1
- package/dist/queue/snapshot.js.map +1 -1
- package/dist/queue/spawn.d.ts +1 -3
- package/dist/queue/spawn.d.ts.map +1 -1
- package/dist/queue/spawn.js +1 -3
- package/dist/queue/spawn.js.map +1 -1
- package/dist/queue/submit.d.ts +6 -1
- package/dist/queue/submit.d.ts.map +1 -1
- package/dist/queue/submit.js +6 -1
- package/dist/queue/submit.js.map +1 -1
- package/dist/queue/types.d.ts +5 -1
- package/dist/queue/types.d.ts.map +1 -1
- package/dist/queue/types.js +5 -1
- package/dist/queue/types.js.map +1 -1
- package/dist/queue/worker-log.d.ts +3 -1
- package/dist/queue/worker-log.d.ts.map +1 -1
- package/dist/queue/worker-log.js +3 -1
- package/dist/queue/worker-log.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IronBee CLI — Model Pricing
|
|
3
|
+
*
|
|
4
|
+
* Per-model token-cost table (USD per 1M tokens) used at projection time to
|
|
5
|
+
* stamp each delta with `cost_usd` per model + a session total. The CLI
|
|
6
|
+
* estimate is a best-effort — backend may recompute with authoritative
|
|
7
|
+
* pricing or apply a more granular model.
|
|
8
|
+
*
|
|
9
|
+
* Source: Anthropic public pricing for the Claude 4.x family. Values are
|
|
10
|
+
* captured as constants because the projection runs in-hook with no
|
|
11
|
+
* network dependency. Update this table whenever pricing changes.
|
|
12
|
+
*
|
|
13
|
+
* Conventions:
|
|
14
|
+
* - `input` covers fresh (non-cached) input tokens.
|
|
15
|
+
* - `output` covers output tokens.
|
|
16
|
+
* - `cache_read` ≈ 10% of `input` (prompt cache hit).
|
|
17
|
+
* - `cache_creation` ≈ 125% of `input` (5-min cache write — the dominant
|
|
18
|
+
* case in interactive sessions). The 1-hour cache (~200% of input) is
|
|
19
|
+
* not broken out separately by analytics today, so we stay with the 5m
|
|
20
|
+
* baseline. If analytics later splits the two, add a `cache_creation_1h`
|
|
21
|
+
* bucket.
|
|
22
|
+
*
|
|
23
|
+
* Family fallback: when `message.model` doesn't match an exact key, we
|
|
24
|
+
* match by family prefix (`claude-opus-`, `claude-sonnet-`, `claude-haiku-`)
|
|
25
|
+
* to a representative Claude 4.x rate. Anything unrecognized returns
|
|
26
|
+
* `null` and contributes 0 cost — better to undercount than to invent
|
|
27
|
+
* pricing for an unknown family.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Heuristic conversion factor for estimating tokens from byte length when
|
|
31
|
+
* we don't have an authoritative `usage` field to read from. Used by the
|
|
32
|
+
* per-tool input-side attribution: a tool_result.content is part of the
|
|
33
|
+
* NEXT assistant message's `input_tokens`, but we can't easily compute
|
|
34
|
+
* "how many of those input_tokens are this tool's contribution" without
|
|
35
|
+
* tokenizing. Instead we estimate `bytes / BYTES_PER_TOKEN`.
|
|
36
|
+
*
|
|
37
|
+
* Anthropic's BPE tokenizer averages ~3.5–4.5 bytes/token for typical
|
|
38
|
+
* tool_result content (mix of code, JSON, English). 4 is a defensible
|
|
39
|
+
* middle. Tune if production data shows systematic over/under-attribution.
|
|
40
|
+
*/
|
|
41
|
+
export declare const BYTES_PER_TOKEN: number;
|
|
42
|
+
export interface ModelPricing {
|
|
43
|
+
/** USD per 1M fresh input tokens. */
|
|
44
|
+
input: number;
|
|
45
|
+
/** USD per 1M output tokens. */
|
|
46
|
+
output: number;
|
|
47
|
+
/** USD per 1M cache-read tokens (prompt cache hit). */
|
|
48
|
+
cache_read: number;
|
|
49
|
+
/** USD per 1M cache-creation tokens (5-minute ephemeral cache write). */
|
|
50
|
+
cache_creation: number;
|
|
51
|
+
/**
|
|
52
|
+
* USD per 1M cache-creation tokens (1-hour ephemeral cache write tier).
|
|
53
|
+
* Anthropic's prompt caching has two ephemeral tiers — 5 minutes (default)
|
|
54
|
+
* and 1 hour (more expensive). Real sessions often use the 1h tier
|
|
55
|
+
* heavily, especially long agent loops where cache prefix lifetime
|
|
56
|
+
* matters more than per-token rate. Falls back to `cache_creation`
|
|
57
|
+
* (5m rate) if undefined.
|
|
58
|
+
*/
|
|
59
|
+
cache_creation_1h?: number;
|
|
60
|
+
/**
|
|
61
|
+
* USD per server-side web_search request. Anthropic charges $0.01/req
|
|
62
|
+
* for the built-in web_search server tool. Tracked via
|
|
63
|
+
* `usage.server_tool_use.web_search_requests` on the assistant message.
|
|
64
|
+
*/
|
|
65
|
+
web_search?: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Exact-id pricing keys. Family fallback handles unknown model ids.
|
|
69
|
+
*
|
|
70
|
+
* USD per 1M tokens. cache_read = prompt cache hit; cache_creation = 5-minute
|
|
71
|
+
* cache write (the default ephemeral tier on the API). 1-hour cache write is a
|
|
72
|
+
* separate (more expensive) tier — not modelled here since usage._tokens fields
|
|
73
|
+
* don't currently distinguish 5m vs 1h breakpoints in transcript JSONL.
|
|
74
|
+
*
|
|
75
|
+
* Source: https://platform.claude.com/docs/en/about-claude/pricing
|
|
76
|
+
*
|
|
77
|
+
* Opus 4.5+ note: Anthropic dropped Opus list price to ~1/3 of the Opus 4 / 4.1
|
|
78
|
+
* tier starting with 4.5 ($5 input / $25 output vs old $15 / $75). Opus 4 and 4.1
|
|
79
|
+
* retain the legacy higher pricing. Family fallback returns the NEWER (cheaper)
|
|
80
|
+
* pricing for unknown opus-X versions on the assumption that future Opus releases
|
|
81
|
+
* stay on the new tier.
|
|
82
|
+
*/
|
|
83
|
+
export declare const PRICING: Record<string, ModelPricing>;
|
|
84
|
+
/**
|
|
85
|
+
* Opus 4.6 fast-mode pricing tier — 6× the regular Opus 4.5+ rate.
|
|
86
|
+
* Active when `usage.speed === "fast"` on an Opus 4.6 message. Looked up
|
|
87
|
+
* via {@link lookupPricingForUsage} which checks the speed field; the
|
|
88
|
+
* regular {@link PRICING} entry is used otherwise.
|
|
89
|
+
*
|
|
90
|
+
* Source: Claude Code's `getOpus46CostTier` (modelCost.ts), uses a single
|
|
91
|
+
* COST_TIER_30_150 constant — no separate 1h tier in fast mode.
|
|
92
|
+
*/
|
|
93
|
+
export declare const OPUS_4_6_FAST_PRICING: ModelPricing;
|
|
94
|
+
/** Resolve pricing for a model id, with family-prefix fallback. */
|
|
95
|
+
export declare function lookupPricing(model: string): ModelPricing | null;
|
|
96
|
+
/**
|
|
97
|
+
* Resolve pricing for an assistant message, accounting for fast-mode tier
|
|
98
|
+
* upgrades. Currently only Opus 4.6 has a fast-mode tier (6× regular rates);
|
|
99
|
+
* any other model with `speed === "fast"` falls through to its regular tier.
|
|
100
|
+
*
|
|
101
|
+
* Mirrors Claude Code's `getOpus46CostTier`. Returns the regular tier when
|
|
102
|
+
* `speed` is undefined or anything other than "fast".
|
|
103
|
+
*/
|
|
104
|
+
export declare function lookupPricingForUsage(model: string, speed: string | undefined): ModelPricing | null;
|
|
105
|
+
export interface MessageTokenUsage {
|
|
106
|
+
input_tokens: number;
|
|
107
|
+
output_tokens: number;
|
|
108
|
+
/**
|
|
109
|
+
* Total cache-creation tokens across both ephemeral tiers. Use this when
|
|
110
|
+
* the 5m / 1h split is unknown; otherwise prefer
|
|
111
|
+
* {@link cache_creation_5m_tokens} + {@link cache_creation_1h_tokens}
|
|
112
|
+
* which gives accurate per-tier cost.
|
|
113
|
+
*/
|
|
114
|
+
cache_creation_tokens: number;
|
|
115
|
+
cache_read_tokens: number;
|
|
116
|
+
/** Subset of cache_creation_tokens billed at the 5m tier. */
|
|
117
|
+
cache_creation_5m_tokens?: number;
|
|
118
|
+
/** Subset of cache_creation_tokens billed at the 1h tier (more expensive). */
|
|
119
|
+
cache_creation_1h_tokens?: number;
|
|
120
|
+
/** Server-side web_search request count. Each is billed at `pricing.web_search` flat. */
|
|
121
|
+
web_search_requests?: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Compute USD cost of a single assistant-message worth of tokens given
|
|
125
|
+
* a pricing entry. Returns 0 when pricing is null (unknown model).
|
|
126
|
+
*
|
|
127
|
+
* Math: (tokens × $/MTok) / 1_000_000 + (web_search_requests × $/req) → USD.
|
|
128
|
+
*
|
|
129
|
+
* **5m/1h cache_creation tier handling — DISABLED for Claude Code parity.**
|
|
130
|
+
*
|
|
131
|
+
* Anthropic's published pricing distinguishes a 5-minute ephemeral cache
|
|
132
|
+
* write tier (e.g. $6.25/MTok for Opus 4.7) from a 1-hour tier (e.g. $10).
|
|
133
|
+
* Real transcripts often carry 100% 1h cache writes (long agent loops),
|
|
134
|
+
* which means the 5m-only formula UNDERESTIMATES the published-rate cost.
|
|
135
|
+
*
|
|
136
|
+
* However, **Claude Code's own `/cost` command uses a single rate** via
|
|
137
|
+
* `tokensToUSDCost` in modelCost.ts (it reads `usage.cache_creation_input_tokens`
|
|
138
|
+
* as a flat sum and bills at `promptCacheWriteTokens` = 5m rate). To stay
|
|
139
|
+
* sync with `/cost` output that users see in the terminal, we mirror this
|
|
140
|
+
* 5m-only behaviour here.
|
|
141
|
+
*
|
|
142
|
+
* The 5m/1h split infrastructure is intact (`cache_creation_5m_tokens`,
|
|
143
|
+
* `cache_creation_1h_tokens`, `pricing.cache_creation_1h`, the projection
|
|
144
|
+
* walks `usage.cache_creation.ephemeral_*_input_tokens`) — when Claude Code
|
|
145
|
+
* adopts per-tier billing OR we explicitly want to diverge from `/cost`,
|
|
146
|
+
* un-comment the split branch below to enable.
|
|
147
|
+
*/
|
|
148
|
+
export declare function computeMessageCostUsd(usage: MessageTokenUsage, pricing: ModelPricing | null): number;
|
|
149
|
+
//# sourceMappingURL=pricing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/analytics/pricing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,EAAE,MAAU,CAAC;AAEzC,MAAM,WAAW,YAAY;IACzB,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,cAAc,EAAE,MAAM,CAAC;IACvB;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAkBhD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAOnC,CAAC;AAEF,mEAAmE;AACnE,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAehE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,CAKnG;AAED,MAAM,WAAW,iBAAiB;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,8EAA8E;IAC9E,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,yFAAyF;IACzF,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,GAAG,MAAM,CA2BpG"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IronBee CLI — Model Pricing
|
|
4
|
+
*
|
|
5
|
+
* Per-model token-cost table (USD per 1M tokens) used at projection time to
|
|
6
|
+
* stamp each delta with `cost_usd` per model + a session total. The CLI
|
|
7
|
+
* estimate is a best-effort — backend may recompute with authoritative
|
|
8
|
+
* pricing or apply a more granular model.
|
|
9
|
+
*
|
|
10
|
+
* Source: Anthropic public pricing for the Claude 4.x family. Values are
|
|
11
|
+
* captured as constants because the projection runs in-hook with no
|
|
12
|
+
* network dependency. Update this table whenever pricing changes.
|
|
13
|
+
*
|
|
14
|
+
* Conventions:
|
|
15
|
+
* - `input` covers fresh (non-cached) input tokens.
|
|
16
|
+
* - `output` covers output tokens.
|
|
17
|
+
* - `cache_read` ≈ 10% of `input` (prompt cache hit).
|
|
18
|
+
* - `cache_creation` ≈ 125% of `input` (5-min cache write — the dominant
|
|
19
|
+
* case in interactive sessions). The 1-hour cache (~200% of input) is
|
|
20
|
+
* not broken out separately by analytics today, so we stay with the 5m
|
|
21
|
+
* baseline. If analytics later splits the two, add a `cache_creation_1h`
|
|
22
|
+
* bucket.
|
|
23
|
+
*
|
|
24
|
+
* Family fallback: when `message.model` doesn't match an exact key, we
|
|
25
|
+
* match by family prefix (`claude-opus-`, `claude-sonnet-`, `claude-haiku-`)
|
|
26
|
+
* to a representative Claude 4.x rate. Anything unrecognized returns
|
|
27
|
+
* `null` and contributes 0 cost — better to undercount than to invent
|
|
28
|
+
* pricing for an unknown family.
|
|
29
|
+
*/
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.OPUS_4_6_FAST_PRICING = exports.PRICING = exports.BYTES_PER_TOKEN = void 0;
|
|
32
|
+
exports.lookupPricing = lookupPricing;
|
|
33
|
+
exports.lookupPricingForUsage = lookupPricingForUsage;
|
|
34
|
+
exports.computeMessageCostUsd = computeMessageCostUsd;
|
|
35
|
+
/**
|
|
36
|
+
* Heuristic conversion factor for estimating tokens from byte length when
|
|
37
|
+
* we don't have an authoritative `usage` field to read from. Used by the
|
|
38
|
+
* per-tool input-side attribution: a tool_result.content is part of the
|
|
39
|
+
* NEXT assistant message's `input_tokens`, but we can't easily compute
|
|
40
|
+
* "how many of those input_tokens are this tool's contribution" without
|
|
41
|
+
* tokenizing. Instead we estimate `bytes / BYTES_PER_TOKEN`.
|
|
42
|
+
*
|
|
43
|
+
* Anthropic's BPE tokenizer averages ~3.5–4.5 bytes/token for typical
|
|
44
|
+
* tool_result content (mix of code, JSON, English). 4 is a defensible
|
|
45
|
+
* middle. Tune if production data shows systematic over/under-attribution.
|
|
46
|
+
*/
|
|
47
|
+
exports.BYTES_PER_TOKEN = 4;
|
|
48
|
+
/**
|
|
49
|
+
* Exact-id pricing keys. Family fallback handles unknown model ids.
|
|
50
|
+
*
|
|
51
|
+
* USD per 1M tokens. cache_read = prompt cache hit; cache_creation = 5-minute
|
|
52
|
+
* cache write (the default ephemeral tier on the API). 1-hour cache write is a
|
|
53
|
+
* separate (more expensive) tier — not modelled here since usage._tokens fields
|
|
54
|
+
* don't currently distinguish 5m vs 1h breakpoints in transcript JSONL.
|
|
55
|
+
*
|
|
56
|
+
* Source: https://platform.claude.com/docs/en/about-claude/pricing
|
|
57
|
+
*
|
|
58
|
+
* Opus 4.5+ note: Anthropic dropped Opus list price to ~1/3 of the Opus 4 / 4.1
|
|
59
|
+
* tier starting with 4.5 ($5 input / $25 output vs old $15 / $75). Opus 4 and 4.1
|
|
60
|
+
* retain the legacy higher pricing. Family fallback returns the NEWER (cheaper)
|
|
61
|
+
* pricing for unknown opus-X versions on the assumption that future Opus releases
|
|
62
|
+
* stay on the new tier.
|
|
63
|
+
*/
|
|
64
|
+
exports.PRICING = {
|
|
65
|
+
// Claude 4.x — Opus (4.5+ on the new lower price tier)
|
|
66
|
+
// 5m / 1h / cache_read columns from https://platform.claude.com/docs/en/about-claude/pricing
|
|
67
|
+
"claude-opus-4-7": { input: 5, output: 25, cache_read: 0.5, cache_creation: 6.25, cache_creation_1h: 10, web_search: 0.01 },
|
|
68
|
+
"claude-opus-4-6": { input: 5, output: 25, cache_read: 0.5, cache_creation: 6.25, cache_creation_1h: 10, web_search: 0.01 },
|
|
69
|
+
"claude-opus-4-5": { input: 5, output: 25, cache_read: 0.5, cache_creation: 6.25, cache_creation_1h: 10, web_search: 0.01 },
|
|
70
|
+
// Opus 4.1 / 4 retain legacy pricing
|
|
71
|
+
"claude-opus-4-1": { input: 15, output: 75, cache_read: 1.5, cache_creation: 18.75, cache_creation_1h: 30, web_search: 0.01 },
|
|
72
|
+
"claude-opus-4": { input: 15, output: 75, cache_read: 1.5, cache_creation: 18.75, cache_creation_1h: 30, web_search: 0.01 },
|
|
73
|
+
// Claude 4.x — Sonnet
|
|
74
|
+
"claude-sonnet-4-6": { input: 3, output: 15, cache_read: 0.3, cache_creation: 3.75, cache_creation_1h: 6, web_search: 0.01 },
|
|
75
|
+
"claude-sonnet-4-5": { input: 3, output: 15, cache_read: 0.3, cache_creation: 3.75, cache_creation_1h: 6, web_search: 0.01 },
|
|
76
|
+
"claude-sonnet-4": { input: 3, output: 15, cache_read: 0.3, cache_creation: 3.75, cache_creation_1h: 6, web_search: 0.01 },
|
|
77
|
+
// Claude 4.x — Haiku
|
|
78
|
+
"claude-haiku-4-5": { input: 1, output: 5, cache_read: 0.1, cache_creation: 1.25, cache_creation_1h: 2, web_search: 0.01 },
|
|
79
|
+
"claude-haiku-4": { input: 1, output: 5, cache_read: 0.1, cache_creation: 1.25, cache_creation_1h: 2, web_search: 0.01 },
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Opus 4.6 fast-mode pricing tier — 6× the regular Opus 4.5+ rate.
|
|
83
|
+
* Active when `usage.speed === "fast"` on an Opus 4.6 message. Looked up
|
|
84
|
+
* via {@link lookupPricingForUsage} which checks the speed field; the
|
|
85
|
+
* regular {@link PRICING} entry is used otherwise.
|
|
86
|
+
*
|
|
87
|
+
* Source: Claude Code's `getOpus46CostTier` (modelCost.ts), uses a single
|
|
88
|
+
* COST_TIER_30_150 constant — no separate 1h tier in fast mode.
|
|
89
|
+
*/
|
|
90
|
+
exports.OPUS_4_6_FAST_PRICING = {
|
|
91
|
+
input: 30,
|
|
92
|
+
output: 150,
|
|
93
|
+
cache_read: 3,
|
|
94
|
+
cache_creation: 37.5,
|
|
95
|
+
cache_creation_1h: 60, // 6× regular 1h rate; absent from Claude Code which conflates 5m/1h
|
|
96
|
+
web_search: 0.01,
|
|
97
|
+
};
|
|
98
|
+
/** Resolve pricing for a model id, with family-prefix fallback. */
|
|
99
|
+
function lookupPricing(model) {
|
|
100
|
+
const exact = exports.PRICING[model];
|
|
101
|
+
if (exact !== undefined) {
|
|
102
|
+
return exact;
|
|
103
|
+
}
|
|
104
|
+
if (model.startsWith("claude-opus-")) {
|
|
105
|
+
return exports.PRICING["claude-opus-4-7"];
|
|
106
|
+
}
|
|
107
|
+
if (model.startsWith("claude-sonnet-")) {
|
|
108
|
+
return exports.PRICING["claude-sonnet-4-6"];
|
|
109
|
+
}
|
|
110
|
+
if (model.startsWith("claude-haiku-")) {
|
|
111
|
+
return exports.PRICING["claude-haiku-4-5"];
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Resolve pricing for an assistant message, accounting for fast-mode tier
|
|
117
|
+
* upgrades. Currently only Opus 4.6 has a fast-mode tier (6× regular rates);
|
|
118
|
+
* any other model with `speed === "fast"` falls through to its regular tier.
|
|
119
|
+
*
|
|
120
|
+
* Mirrors Claude Code's `getOpus46CostTier`. Returns the regular tier when
|
|
121
|
+
* `speed` is undefined or anything other than "fast".
|
|
122
|
+
*/
|
|
123
|
+
function lookupPricingForUsage(model, speed) {
|
|
124
|
+
if (speed === "fast" && model.includes("opus-4-6")) {
|
|
125
|
+
return exports.OPUS_4_6_FAST_PRICING;
|
|
126
|
+
}
|
|
127
|
+
return lookupPricing(model);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Compute USD cost of a single assistant-message worth of tokens given
|
|
131
|
+
* a pricing entry. Returns 0 when pricing is null (unknown model).
|
|
132
|
+
*
|
|
133
|
+
* Math: (tokens × $/MTok) / 1_000_000 + (web_search_requests × $/req) → USD.
|
|
134
|
+
*
|
|
135
|
+
* **5m/1h cache_creation tier handling — DISABLED for Claude Code parity.**
|
|
136
|
+
*
|
|
137
|
+
* Anthropic's published pricing distinguishes a 5-minute ephemeral cache
|
|
138
|
+
* write tier (e.g. $6.25/MTok for Opus 4.7) from a 1-hour tier (e.g. $10).
|
|
139
|
+
* Real transcripts often carry 100% 1h cache writes (long agent loops),
|
|
140
|
+
* which means the 5m-only formula UNDERESTIMATES the published-rate cost.
|
|
141
|
+
*
|
|
142
|
+
* However, **Claude Code's own `/cost` command uses a single rate** via
|
|
143
|
+
* `tokensToUSDCost` in modelCost.ts (it reads `usage.cache_creation_input_tokens`
|
|
144
|
+
* as a flat sum and bills at `promptCacheWriteTokens` = 5m rate). To stay
|
|
145
|
+
* sync with `/cost` output that users see in the terminal, we mirror this
|
|
146
|
+
* 5m-only behaviour here.
|
|
147
|
+
*
|
|
148
|
+
* The 5m/1h split infrastructure is intact (`cache_creation_5m_tokens`,
|
|
149
|
+
* `cache_creation_1h_tokens`, `pricing.cache_creation_1h`, the projection
|
|
150
|
+
* walks `usage.cache_creation.ephemeral_*_input_tokens`) — when Claude Code
|
|
151
|
+
* adopts per-tier billing OR we explicitly want to diverge from `/cost`,
|
|
152
|
+
* un-comment the split branch below to enable.
|
|
153
|
+
*/
|
|
154
|
+
function computeMessageCostUsd(usage, pricing) {
|
|
155
|
+
if (pricing === null) {
|
|
156
|
+
return 0;
|
|
157
|
+
}
|
|
158
|
+
// ── PER-TIER BILLING (currently DISABLED — Claude Code parity) ──────
|
|
159
|
+
// Re-enable by replacing the single-rate `ccCost` line below with this block:
|
|
160
|
+
//
|
|
161
|
+
// let ccCost: number;
|
|
162
|
+
// if (usage.cache_creation_5m_tokens !== undefined || usage.cache_creation_1h_tokens !== undefined) {
|
|
163
|
+
// const t5m: number = usage.cache_creation_5m_tokens ?? 0;
|
|
164
|
+
// const t1h: number = usage.cache_creation_1h_tokens ?? 0;
|
|
165
|
+
// const rate1h: number = pricing.cache_creation_1h ?? pricing.cache_creation;
|
|
166
|
+
// ccCost = t5m * pricing.cache_creation + t1h * rate1h;
|
|
167
|
+
// } else {
|
|
168
|
+
// ccCost = usage.cache_creation_tokens * pricing.cache_creation;
|
|
169
|
+
// }
|
|
170
|
+
const ccCost = usage.cache_creation_tokens * pricing.cache_creation;
|
|
171
|
+
const wsReqs = usage.web_search_requests ?? 0;
|
|
172
|
+
const wsRate = pricing.web_search ?? 0;
|
|
173
|
+
return (usage.input_tokens * pricing.input
|
|
174
|
+
+ usage.output_tokens * pricing.output
|
|
175
|
+
+ ccCost
|
|
176
|
+
+ usage.cache_read_tokens * pricing.cache_read) / 1000000
|
|
177
|
+
+ wsReqs * wsRate;
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=pricing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../../src/analytics/pricing.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AAiGH,sCAeC;AAUD,sDAKC;AA8CD,sDA2BC;AAtMD;;;;;;;;;;;GAWG;AACU,QAAA,eAAe,GAAW,CAAC,CAAC;AA4BzC;;;;;;;;;;;;;;;GAeG;AACU,QAAA,OAAO,GAAiC;IACjD,uDAAuD;IACvD,6FAA6F;IAC7F,iBAAiB,EAAG,EAAE,KAAK,EAAE,CAAC,EAAG,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,iBAAiB,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;IAC7H,iBAAiB,EAAG,EAAE,KAAK,EAAE,CAAC,EAAG,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,iBAAiB,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;IAC7H,iBAAiB,EAAG,EAAE,KAAK,EAAE,CAAC,EAAG,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,iBAAiB,EAAE,EA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