omnigateway 0.2.0 → 0.2.2

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 (47) hide show
  1. package/README.md +94 -7
  2. package/bin/omni.js +4954 -2939
  3. package/gateway.js +3132 -1164
  4. package/package.json +1 -1
  5. package/public/assets/{Chip-BB_5C1Zp.js → Chip-DJwp7gBu.js} +2 -2
  6. package/public/assets/{Confirm-B6aAiVbT.js → Confirm-CVLz9F7a.js} +1 -1
  7. package/public/assets/CopyValue-CNZbWS59.js +27 -0
  8. package/public/assets/{Field-uHZxl4fI.js → Field-BDtp692L.js} +8 -8
  9. package/public/assets/Lamp-B65uWKbW.js +25 -0
  10. package/public/assets/{Meter-DI_BRUKt.js → Meter-BREBUFGX.js} +2 -2
  11. package/public/assets/{Modal-CI6jk2D4.js → Modal-DbydSAlp.js} +8 -8
  12. package/public/assets/Rack-Bbo4JfEX.js +151 -0
  13. package/public/assets/{Readout-BocZ2HXP.js → Readout-CEAoN5hu.js} +9 -5
  14. package/public/assets/{States-Bbiu5cHE.js → States-BEKLros0.js} +10 -10
  15. package/public/assets/{Table-CdPWxYaz.js → Table-BBypbVWj.js} +1 -1
  16. package/public/assets/{Toggle-CiLC67Dw.js → Toggle-BUr71O4J.js} +2 -2
  17. package/public/assets/{TokenBreakdown-B96iPBm9.js → TokenBreakdown-C1ziK9d1.js} +6 -3
  18. package/public/assets/_app-ByQ1bPbe.js +1 -0
  19. package/public/assets/_app.accounts-BTug_Xfo.js +64 -0
  20. package/public/assets/{_app.console-Daz4aKhf.js → _app.console-DKyGL9xx.js} +10 -10
  21. package/public/assets/_app.index-CSw9gmMf.js +62 -0
  22. package/public/assets/_app.keys-07Kbw4RS.js +39 -0
  23. package/public/assets/_app.logs-C9QiV39p.js +32 -0
  24. package/public/assets/_app.models-CDqVrAeF.js +148 -0
  25. package/public/assets/{_app.settings-a0FKyQAi.js → _app.settings-DmUEeTaP.js} +10 -10
  26. package/public/assets/_app.usage-B1WuMGRr.js +83 -0
  27. package/public/assets/catalog-BBKm8Ih8.js +1 -0
  28. package/public/assets/{dist-C-IbPRiV.js → dist-Bka7ErcH.js} +1 -1
  29. package/public/assets/index-DJfb1i4P.js +186 -0
  30. package/public/assets/{login-CTvH_KAd.js → login-DKZYqRh0.js} +8 -8
  31. package/public/assets/queries-D8LJNQpL.js +144 -0
  32. package/public/assets/shared-CIhZ6FCO.js +84 -0
  33. package/public/assets/{trash-2-BcZb-sCT.js → trash-2-CLYNAAJA.js} +1 -1
  34. package/public/index.html +2 -2
  35. package/public/assets/CopyValue-CRQDLo7k.js +0 -27
  36. package/public/assets/Lamp-B-5SjXbG.js +0 -25
  37. package/public/assets/Rack-D1WJswv3.js +0 -151
  38. package/public/assets/_app-BBOF6A0T.js +0 -1
  39. package/public/assets/_app.accounts-BNkhpvaB.js +0 -54
  40. package/public/assets/_app.index-LO6d38oe.js +0 -62
  41. package/public/assets/_app.keys-kBqLqoFf.js +0 -39
  42. package/public/assets/_app.logs-_wYNS47N.js +0 -32
  43. package/public/assets/_app.models-Cjng8ohC.js +0 -144
  44. package/public/assets/_app.usage-D3KtgLrC.js +0 -166
  45. package/public/assets/catalog-C_OQ0icG.js +0 -1
  46. package/public/assets/index-PW6EvVh5.js +0 -170
  47. package/public/assets/queries-D2o-X8Pj.js +0 -144
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  One endpoint in front of the AI accounts you already pay for.
4
4
 
5
5
  OmniGateway is a self-hosted gateway that speaks the Anthropic and OpenAI APIs
6
- and answers them using your own Anthropic, OpenAI, and Kimi Coding
6
+ and answers them using your own Anthropic, OpenAI, Kimi Coding, Kilo, and xAI
7
7
  subscriptions. Point any compatible client at it, ask for a model you defined,
8
8
  and the gateway picks an account that can serve it — falling back to another
9
9
  when one is rate-limited, expired, or out of quota.
@@ -29,7 +29,7 @@ omni start
29
29
  provider dispatch, preserve errors and non-tool-result content, and default off.
30
30
  - **Routes across your accounts.** Define a virtual model like `fast` or
31
31
  `smart` with several targets; the gateway ranks them by tier, health,
32
- remaining quota, cost, and latency.
32
+ remaining quota, cost, latency, and current load.
33
33
  - **Fails over.** A rate-limited or broken account is skipped, its circuit
34
34
  breaker opens, and the next candidate is tried — before the response starts
35
35
  streaming.
@@ -45,12 +45,66 @@ omni start
45
45
  - **Ships an admin console and a CLI.** Both cover the same ground; use
46
46
  whichever suits the machine you are on.
47
47
 
48
+ ## How it is built
49
+
50
+ A Bun workspace monorepo. The layering is deliberate and enforced by what each
51
+ package is allowed to import: a provider-neutral core at the bottom, provider
52
+ knowledge in one place, pure routing above that, and every side effect pushed up
53
+ into the gateway process.
54
+
55
+ ```mermaid
56
+ graph TD
57
+ subgraph frontends[Front ends]
58
+ gateway["apps/gateway<br/><i>Elysia server, dispatch, loops</i>"]
59
+ cli["apps/cli<br/><i>the omni binary</i>"]
60
+ dashboard["apps/dashboard<br/><i>React console</i>"]
61
+ end
62
+
63
+ control["@omni/control<br/><i>every operator action;<br/>no HTTP, argv or terminal</i>"]
64
+ router["@omni/router<br/><i>pure ranking;<br/>no I/O, no timers</i>"]
65
+ store["@omni/store<br/><i>SQLite + field encryption</i>"]
66
+ providers["@omni/providers<br/><i>adapters, wire codecs,<br/>catalog, HTTP client</i>"]
67
+ rtk["@omni/rtk<br/><i>tool-result filters</i>"]
68
+ ir["@omni/ir<br/><i>domain model — depends on nothing</i>"]
69
+
70
+ gateway --> control
71
+ gateway --> rtk
72
+ cli --> control
73
+ dashboard -. "types + catalog only" .-> providers
74
+ dashboard -. "types only" .-> store
75
+ control --> router
76
+ router --> store
77
+ router --> providers
78
+ store --> rtk
79
+ providers --> ir
80
+ rtk --> ir
81
+ store --> ir
82
+ ```
83
+
84
+ Arrows read *depends on*, and the direction never reverses. Two rules do most of
85
+ the work: `@omni/ir` is side-effect free and imports nothing, and `@omni/router`
86
+ is a pure function — no network, no database, no timers. Everything that has to
87
+ touch the world is pushed up into the gateway process.
88
+
89
+ The dashboard's edges are dotted because they are type-level only.
90
+ `@omni/providers/catalog` is deliberately kept import-free so model lists can be
91
+ bundled into the browser without dragging in the HTTP client.
92
+
93
+ The gateway and the CLI are two front ends over the same `@omni/control`
94
+ functions. The CLI does not call the running server's API — it opens the same
95
+ SQLite file directly, which is why it still works when the gateway is down.
96
+
97
+ **[ARCHITECTURE.md](ARCHITECTURE.md)** goes a level deeper: a request traced end
98
+ to end, how routing ranks and excludes accounts, the commit point that decides
99
+ whether failover is still possible, the provider adapter shape, the database
100
+ schema and its encryption boundary, and the background loops.
101
+
48
102
  ## Requirements
49
103
 
50
104
  - [Bun](https://bun.sh/) 1.4 or later. Bun is the runtime, not just the
51
105
  installer, so a Node-only machine cannot run OmniGateway.
52
106
  - A directory that persists, for the SQLite database.
53
- - At least one Anthropic, OpenAI, or Kimi Coding account to connect.
107
+ - At least one Anthropic, OpenAI, Kimi Coding, Kilo, or xAI account to connect.
54
108
 
55
109
  ## Install
56
110
 
@@ -86,9 +140,18 @@ omni start # serves the API and the console on 127.0.0.1:9000
86
140
  Connect an account. The CLI prints a URL to open, and waits:
87
141
 
88
142
  ```bash
89
- omni connect anthropic # or: openai, kimi
143
+ omni connect anthropic # or: openai, kimi, kilo, grok
90
144
  ```
91
145
 
146
+ Every provider also takes a plain API key, if that is what you hold rather than
147
+ a subscription. `custom` takes nothing else:
148
+
149
+ ```bash
150
+ omni credentials add-key anthropic # prompts for the key, or reads stdin
151
+ ```
152
+
153
+ The console offers the same choice per provider on the Connect dialog.
154
+
92
155
  Define a virtual model your clients will ask for, seeding its pricing and
93
156
  capabilities from the built-in catalog:
94
157
 
@@ -97,6 +160,23 @@ omni models catalog # what is available
97
160
  omni models put fast --from-catalog anthropic:claude-sonnet-5
98
161
  ```
99
162
 
163
+ **A note on grok pricing.** xAI charges by request size: at or above 200K
164
+ context the rate roughly doubles, and the higher rate applies to *every token
165
+ in the request*, not just the tokens past the mark. A target holds one flat
166
+ price, so the catalog carries xAI's sub-200K figures and long-context traffic
167
+ is reported cheaper than it was billed. Catalog pricing is only the default a
168
+ new target starts from — if you run grok at long context, edit the saved
169
+ target's price to match the tier you are actually paying.
170
+
171
+ **A note on `kilo-auto/*` pricing.** Kilo's `frontier`, `balanced`, and
172
+ `efficient` routers choose an upstream model per request, and Kilo states no
173
+ rate for them. The catalog records zero, which the router reads as *unpriced*
174
+ and leaves out of its cost ranking — the same stored figure `kilo-auto/free`
175
+ carries because it genuinely is free. So a `kilo-auto` target seeded from the
176
+ catalog is not free, it is unranked: cost never counts for or against it. If you
177
+ want one ranked against your other accounts, set a real `costPerMTok` on the
178
+ saved target for the tier you expect it to land in.
179
+
100
180
  Mint a key for your client. **It is printed once and stored only as a hash:**
101
181
 
102
182
  ```bash
@@ -170,6 +250,10 @@ carries the header through but does not add one on your behalf.
170
250
  command takes `--json` for scripting, and `--root <path>` to manage an
171
251
  installation other than the default.
172
252
 
253
+ `--root` names the installation, so an `OMNI_DB_PATH` exported in your shell is
254
+ ignored alongside it and said so on stderr; that root's own `.env` still decides.
255
+ Use `--db <path>` to point one command somewhere else.
256
+
173
257
  | | |
174
258
  | --- | --- |
175
259
  | `omni status` | the gateway, its accounts, and their quota, on one screen |
@@ -178,6 +262,7 @@ installation other than the default.
178
262
  | `omni logs` | recent requests as the gateway recorded them |
179
263
  | `omni console` | the gateway process's own output: boot, refreshes, quota, errors |
180
264
  | `omni usage` | spend and tokens, by provider, model, key, or day |
265
+ | `omni quota` | provider quota per window: use, burn rate, and when it runs out |
181
266
  | `omni connect <provider>` | authorize an account from the terminal |
182
267
  | `omni credentials …` | list, show, enable, disable, retier, refresh, remove |
183
268
  | `omni models …` | list, show, put, remove, `dry-run`, `catalog` |
@@ -295,9 +380,11 @@ Worth knowing before you deploy it:
295
380
 
296
381
  ## Development
297
382
 
298
- Contributing, or running from a checkout? See [CLAUDE.md](CLAUDE.md) for the
299
- repository map, architectural boundaries, and conventions, and
300
- `docs/superpowers/specs/` for the design documents behind each feature.
383
+ Contributing, or running from a checkout? See
384
+ [ARCHITECTURE.md](ARCHITECTURE.md) for how the system fits together,
385
+ [CLAUDE.md](CLAUDE.md) for the repository map, architectural boundaries, and
386
+ conventions, and `docs/superpowers/specs/` for the design documents behind each
387
+ feature.
301
388
 
302
389
  ```bash
303
390
  git clone https://github.com/harismawan/omnigateway.git