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.
- checksums.yaml +4 -4
- data/lib/wave_dispatch.rb +25 -8
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a4b8d4f2ac013bb33e11429c60882ffa8d7134ae962c9393dd3860ee2650bfc
|
|
4
|
+
data.tar.gz: fe55e9af52127bfa730cf08f6f5183f2fb1a09357f8fabf259c27b195ecc6f24
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
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.
|
|
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-
|
|
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.
|
|
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: []
|