wave-dispatch 0.1.0 → 0.2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/wave_dispatch.rb +25 -8
  3. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4c775b53e4a96fcf951036dd860ad9d7caf2e2cdd86c0812921ff2e6f5b2fbb
4
- data.tar.gz: f6cc786bd777807eeccda5f3a79a92dbfa63074ea2f209f5417dd201b4b2c29b
3
+ metadata.gz: 1a4b8d4f2ac013bb33e11429c60882ffa8d7134ae962c9393dd3860ee2650bfc
4
+ data.tar.gz: fe55e9af52127bfa730cf08f6f5183f2fb1a09357f8fabf259c27b195ecc6f24
5
5
  SHA512:
6
- metadata.gz: 3199c890be6fe2d2026e76932a8cfe9f4c137c4fcea1caf2e686fcbcf1604f4b7a36a9174a8c20c61e1d68f4f563c64d12b7e0ba5ef15c1433b19a30aa20bc84
7
- data.tar.gz: f5403ff2b3c04d5e45e091d7e3285e5ea0f54224cfa97dd379f0e1a1b356714d71d8a960c5c9cb98ef6d82c3159e551bc1c49854eb2dd6d02cdce1c69bd461e5
6
+ metadata.gz: 918f879fde61a2fab5d496236bddd6d636fd9d9f77215d3dd572dfef2099335fcf891cd0fc258abc97481297a059af747750f4c6c4241355f3fbbb994e9950b6
7
+ data.tar.gz: 935a6c061460565005a19471a6ae260ec50051d95e5754a2fa963d8abcd31d9007b3a6ae40594bbc12ad52b594935cbbbf37b6547e8a8ba926fece64078e6a31
data/lib/wave_dispatch.rb CHANGED
@@ -5,29 +5,46 @@ require "json"
5
5
  require "uri"
6
6
 
7
7
  module WaveDispatch
8
- VERSION = "0.1.0"
8
+ VERSION = "0.2.0"
9
9
 
10
10
  class Client
11
- def initialize(license = ENV["WAVE_LICENSE"], endpoint: "https://dispatch.wave.online")
11
+ def initialize(license = ENV["WAVE_LICENSE"], endpoint: "https://dispatch.wave.online",
12
+ agents_endpoint: ENV["WAVE_AGENTS_ENDPOINT"] || "https://dispatch-agents.wave.online")
12
13
  @license = license
13
14
  @endpoint = endpoint
15
+ @agents = agents_endpoint
14
16
  end
15
17
 
16
18
  # Classify a prompt (no execution) -> {"route", "probability", "margin", "forward"}
17
- def route(prompt) = post({ prompt: prompt })
19
+ def route(prompt) = send_req(:post, @endpoint + "/", { prompt: prompt })
18
20
 
19
21
  # Classify and run on the edge if your plan allows it.
20
- def execute(prompt) = post({ prompt: prompt, execute: true })
22
+ def execute(prompt) = send_req(:post, @endpoint + "/", { prompt: prompt, execute: true })
23
+
24
+ # This license's savings ledger (decisions, saved_usd, saved_pct, ...). Requires a license.
25
+ def savings = send_req(:get, "#{@agents}/ledger/summary?license=#{lic}")
26
+
27
+ # This license's agent-subscription status.
28
+ def subscription = send_req(:get, "#{@agents}/subscription/status?license=#{lic}")
29
+
30
+ # Start/replace a programmatic subscription (plan: agent_starter | agent_pro | agent_scale).
31
+ def subscribe(plan) = send_req(:post, "#{@agents}/subscription/create", { license: @license, plan: plan })
21
32
 
22
33
  private
23
34
 
24
- def post(body)
25
- uri = URI(@endpoint + "/")
26
- req = Net::HTTP::Post.new(uri, "content-type" => "application/json")
35
+ def lic
36
+ raise "dispatch: a license is required for savings/subscription" unless @license
37
+ URI.encode_www_form_component(@license)
38
+ end
39
+
40
+ def send_req(method, url, body = nil)
41
+ uri = URI(url)
42
+ req = (method == :post ? Net::HTTP::Post : Net::HTTP::Get).new(uri, "content-type" => "application/json")
27
43
  req["authorization"] = "Bearer #{@license}" if @license
28
- req.body = body.to_json
44
+ req.body = body.to_json if body
29
45
  res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |h| h.request(req) }
30
46
  raise "dispatch: 402 payment required (x402)" if res.code == "402"
47
+ raise "dispatch: 401 unauthorized — set a valid license" if res.code == "401"
31
48
  JSON.parse(res.body)
32
49
  end
33
50
  end
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wave-dispatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - WAVE Online, LLC
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-26 00:00:00.000000000 Z
11
+ date: 2026-05-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Route each request to the cheapest capable model (local-first; escalate
14
14
  to your frontier only when needed). BYO keys + infra.
15
- email:
15
+ email:
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
@@ -23,7 +23,7 @@ licenses:
23
23
  - MIT
24
24
  metadata:
25
25
  source_code_uri: https://github.com/wave-av/dispatch-edge
26
- post_install_message:
26
+ post_install_message:
27
27
  rdoc_options: []
28
28
  require_paths:
29
29
  - lib
@@ -38,8 +38,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  requirements: []
41
- rubygems_version: 3.0.3.1
42
- signing_key:
41
+ rubygems_version: 3.4.19
42
+ signing_key:
43
43
  specification_version: 4
44
44
  summary: wave Dispatch — local-first AI router client
45
45
  test_files: []