diff options
| author | Adam Malczewski <[email protected]> | 2026-04-29 21:40:58 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-04-29 21:40:58 +0900 |
| commit | 27af03cb3540539f065334c199fdb42c48776fc5 (patch) | |
| tree | 9dcaecc59f4383d88933519b5b049793e772427b /lib/dispatch/adapter/interface/usage_report.rb | |
| parent | 07277435c0688ad9f5fa682633b86b99ef5bb854 (diff) | |
| download | dispatch-adapter-interface-27af03cb3540539f065334c199fdb42c48776fc5.tar.gz dispatch-adapter-interface-27af03cb3540539f065334c199fdb42c48776fc5.zip | |
update to support claude
Diffstat (limited to 'lib/dispatch/adapter/interface/usage_report.rb')
| -rw-r--r-- | lib/dispatch/adapter/interface/usage_report.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/dispatch/adapter/interface/usage_report.rb b/lib/dispatch/adapter/interface/usage_report.rb new file mode 100644 index 0000000..132c484 --- /dev/null +++ b/lib/dispatch/adapter/interface/usage_report.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Dispatch + module Adapter + UsageWindow = Struct.new(:id, :label, :duration_ms, :resets_at, keyword_init: true) do + def initialize(id:, label:, duration_ms: nil, resets_at: nil) + super + end + end + + UsageAmount = Struct.new( + :used, :limit, :remaining, + :used_fraction, :remaining_fraction, + :unit, keyword_init: true + ) do + # unit ∈ :percent | :tokens | :requests | :usd | :minutes | :bytes | :unknown + def initialize(unit:, used: nil, limit: nil, remaining: nil, + used_fraction: nil, remaining_fraction: nil) + super + end + end + + UsageLimitEntry = Struct.new( + :id, :label, :scope, :window, :amount, :status, :notes, + keyword_init: true + ) do + # status ∈ :ok | :warning | :exhausted | :unknown + def initialize(id:, label:, scope:, amount:, window: nil, + status: :unknown, notes: []) + super + end + end + + UsageReport = Struct.new( + :provider, :fetched_at, :limits, :metadata, :raw, + keyword_init: true + ) do + def initialize(provider:, limits:, fetched_at: Time.now, metadata: {}, raw: nil) + super + end + end + end +end |
