mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-19 04:41:03 +00:00
Compare commits
4 Commits
fix/plugin
...
fix/usage-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea6a7edb9e | ||
|
|
c91099adfc | ||
|
|
0cddfb918b | ||
|
|
90481eb9b3 |
22
.github/workflows/npm-publish.yml
vendored
22
.github/workflows/npm-publish.yml
vendored
@@ -450,13 +450,12 @@ jobs:
|
||||
echo "✅ Published omniroute@$VERSION (dist-tag=$TAG) via Trusted Publishing"
|
||||
|
||||
- name: Publish to npm (staged — owner approves with 2FA)
|
||||
# Only on an explicit request now: Trusted Publishing above is the default. Staging
|
||||
# also goes through OIDC (Trusted Publishers allow `npm stage publish`); the approve
|
||||
# step still needs the owner's 2FA.
|
||||
# Only on an explicit request now: Trusted Publishing below is the default.
|
||||
if: github.event_name == 'workflow_dispatch' && inputs.publish_mode == 'staged'
|
||||
env:
|
||||
VERSION: ${{ needs.publish.outputs.version }}
|
||||
TAG: ${{ needs.publish.outputs.tag }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TARBALL="omniroute-${VERSION}.tgz"
|
||||
@@ -480,9 +479,6 @@ jobs:
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "✅ Staged omniroute@$VERSION (dist-tag=$TAG) — awaiting owner 'npm stage approve'"
|
||||
|
||||
# The one step still on a token: for when Trusted Publishing itself is broken. npm caps
|
||||
# write tokens at 90 days, so mint a fresh granular token (publish on omniroute, 2FA
|
||||
# bypass) and set NPM_TOKEN right before dispatching publish_mode=direct.
|
||||
- name: Publish to npm (DIRECT — emergency fallback)
|
||||
if: github.event_name == 'workflow_dispatch' && inputs.publish_mode == 'direct'
|
||||
env:
|
||||
@@ -602,13 +598,10 @@ jobs:
|
||||
working-directory: "@omniroute/opencode-plugin"
|
||||
run: npm test
|
||||
|
||||
# Trusted Publishing (OIDC), like the main package: no NODE_AUTH_TOKEN. npm >= 11.5
|
||||
# detects the job's id-token itself. The Trusted Publisher of this package
|
||||
# (cheaper-inference/OmniRoute, npm-publish.yml, no environment, "npm publish" allowed)
|
||||
# was set up on 2026-11-18, after the long-lived NPM_TOKEN expired and v3.8.54's
|
||||
# plugin publishes answered E404.
|
||||
- name: Publish @omniroute/opencode-plugin to npm
|
||||
working-directory: "@omniroute/opencode-plugin"
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
PKG_VERSION=$(node -p "require('./package.json').version")
|
||||
@@ -728,13 +721,10 @@ jobs:
|
||||
working-directory: "@omniroute/opencode-plugin-v2"
|
||||
run: npm test
|
||||
|
||||
# Trusted Publishing (OIDC), like the main package: no NODE_AUTH_TOKEN. npm >= 11.5
|
||||
# detects the job's id-token itself. The Trusted Publisher of this package
|
||||
# (cheaper-inference/OmniRoute, npm-publish.yml, no environment, "npm publish" allowed)
|
||||
# was set up on 2026-11-18, after the long-lived NPM_TOKEN expired and v3.8.54's
|
||||
# plugin publishes answered E404.
|
||||
- name: Publish @omniroute/opencode-plugin-v2 to npm
|
||||
working-directory: "@omniroute/opencode-plugin-v2"
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
PKG_VERSION=$(node -p "require('./package.json').version")
|
||||
|
||||
@@ -275,7 +275,7 @@ ENV DATA_DIR=/app/data
|
||||
RUN mkdir -p /app/data && chown node:node /app /app/data
|
||||
|
||||
# #13679: default the PUBLISHED image to requiring an API key. A bare
|
||||
# `docker run -p 20128:20128 … cheaperinference/omniroute` (README/QUICK-START
|
||||
# `docker run -p 20128:20128 … diegosouzapw/omniroute` (README/QUICK-START
|
||||
# one-liners) does not pass `--env-file .env`, so without this default the
|
||||
# anonymous /v1 LLM proxy would be both keyless AND world-reachable on the
|
||||
# published container. This does NOT change the npm/CLI local-dev default
|
||||
|
||||
10
README.md
10
README.md
@@ -87,7 +87,7 @@
|
||||
|
||||
[](https://www.npmjs.com/package/omniroute)
|
||||

|
||||
[](https://hub.docker.com/r/cheaperinference/omniroute)
|
||||
[](https://hub.docker.com/r/diegosouzapw/omniroute)
|
||||
[](LICENSE)
|
||||

|
||||

|
||||
@@ -781,7 +781,7 @@ of your shell history. → [CLI Integrations](docs/guides/CLI-INTEGRATIONS.md)
|
||||
<tr><th align="left">Platform</th><th align="left">Install</th><th align="left">Highlights</th></tr>
|
||||
<tr><td align="left" nowrap>📦 <b>npm (global)</b></td><td align="left" nowrap><code>npm install -g omniroute</code></td><td align="left">One command, any OS</td></tr>
|
||||
<tr><td align="left" nowrap>⚡ <b>Bun (global)</b></td><td align="left" nowrap><code>bun add -g omniroute</code></td><td align="left">Same registry tarball, faster installs</td></tr>
|
||||
<tr><td align="left" nowrap>🐳 <b>Docker</b></td><td align="left" nowrap><code>docker run … cheaperinference/omniroute</code></td><td align="left">Multi-arch <b>AMD64 + ARM64</b></td></tr>
|
||||
<tr><td align="left" nowrap>🐳 <b>Docker</b></td><td align="left" nowrap><code>docker run … diegosouzapw/omniroute</code></td><td align="left">Multi-arch <b>AMD64 + ARM64</b></td></tr>
|
||||
<tr><td align="left" nowrap>🖥️ <b>Desktop (Electron)</b></td><td align="left" nowrap><code>npm run electron:build</code></td><td align="left">Native window + system tray — <b>Windows / macOS / Linux</b></td></tr>
|
||||
<tr><td align="left" nowrap>🎩 <b>Menu-bar (OmniRouteTray)</b></td><td align="left" nowrap><code>brew install --cask zoispag/tap/omniroute-tray</code></td><td align="left">Supervises & auto-updates the server — <b>macOS</b></td></tr>
|
||||
<tr><td align="left" nowrap>💪 <b>ARM</b></td><td align="left" nowrap>native <code>arm64</code></td><td align="left">Raspberry Pi, ARM servers, Apple Silicon</td></tr>
|
||||
@@ -1105,7 +1105,7 @@ Use these only for clients that cannot attach `Authorization: Bearer ...`. Heade
|
||||
|
||||
```bash
|
||||
docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
|
||||
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data cheaperinference/omniroute:latest
|
||||
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data diegosouzapw/omniroute:latest
|
||||
```
|
||||
|
||||
`:latest` follows the highest **published** stable SemVer. It does not track git `main`. Pin `:X.Y.Z` for GitOps. See [Docker Release Channels](docs/guides/DOCKER_GUIDE.md#release-channels).The image pins **`OMNIROUTE_MEMORY_MB=1024`**. That is enough for the dashboard and a light chat. **Coding agents** (`POST /v1/responses` from Claude Code, Codex, Grok, …) need a much larger V8 heap or the process `FATAL ERROR`s at ~12 GiB under two overlapping long contexts. Size the container above the heap (native buffers sit outside V8):
|
||||
@@ -1119,7 +1119,7 @@ docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
|
||||
```bash
|
||||
docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
|
||||
-e OMNIROUTE_MEMORY_MB=8192 --memory=10g \
|
||||
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data cheaperinference/omniroute:latest
|
||||
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data diegosouzapw/omniroute:latest
|
||||
```
|
||||
|
||||
Full table: [Docker Guide — runtime RAM](docs/guides/DOCKER_GUIDE.md#runtime-ram-for-coding-agents).
|
||||
@@ -1338,7 +1338,7 @@ Métricas canônicas em 2026-10-18: **1.976 vídeos únicos** · **20.220.289 vi
|
||||
<tr><td nowrap><b>Testing</b></td><td>Node.js test runner + Vitest — <b>60,000+ static test declarations</b> across 8,400+ tracked test files (unit, integration, E2E, security, ecosystem)</td></tr>
|
||||
<tr><td nowrap><b>Platforms</b></td><td>Desktop (Electron) · Android (Termux) · PWA (any browser)</td></tr>
|
||||
<tr><td nowrap><b>CI/CD</b></td><td>GitHub Actions — auto npm publish + Docker Hub on release</td></tr>
|
||||
<tr><td nowrap><b>Links</b></td><td><a href="https://omniroute.online">Website</a> · <a href="https://www.npmjs.com/package/omniroute">npm</a> · <a href="https://hub.docker.com/r/cheaperinference/omniroute">Docker Hub</a></td></tr>
|
||||
<tr><td nowrap><b>Links</b></td><td><a href="https://omniroute.online">Website</a> · <a href="https://www.npmjs.com/package/omniroute">npm</a> · <a href="https://hub.docker.com/r/diegosouzapw/omniroute">Docker Hub</a></td></tr>
|
||||
</table>
|
||||
|
||||
<div align="center">
|
||||
|
||||
@@ -207,7 +207,7 @@ docker run -d \
|
||||
-e JWT_SECRET="$(openssl rand -base64 48)" \
|
||||
-e API_KEY_SECRET="$(openssl rand -hex 32)" \
|
||||
-e STORAGE_ENCRYPTION_KEY="$(openssl rand -hex 32)" \
|
||||
cheaperinference/omniroute:latest
|
||||
diegosouzapw/omniroute:latest
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
- **fix(ci):** the OpenCode plugins and the staged release mode publish to npm through Trusted Publishing (OIDC) only; the expired long-lived `NPM_TOKEN` is left solely on the DIRECT emergency fallback ([#20489](https://github.com/cheaper-inference/OmniRoute/pull/20489))
|
||||
@@ -1 +0,0 @@
|
||||
- **fix(security):** plugin hooks (`onRequest`/`onResponse`/`onError`) no longer receive the client's `authorization`, `x-api-key` or `proxy-authorization` headers or the API key value; the Plugin SDK and marketplace docs now state that plugins run as ordinary Node.js processes with the OmniRoute user's privileges (`requires.permissions` only selects environment variables), and the plugins page shows a warning to that effect ([#20566](https://github.com/cheaper-inference/OmniRoute/pull/20566))
|
||||
1
changelog.d/fixes/usage-command-json-account-scope.md
Normal file
1
changelog.d/fixes/usage-command-json-account-scope.md
Normal file
@@ -0,0 +1 @@
|
||||
- Return the shared provider accounts in the usage command JSON (`?format=json`) only to keys with `self:account-quota` or a management scope, the same rule `/v1/me/status` uses; other keys get their personal quota only (thanks @Witroch4).
|
||||
@@ -1 +0,0 @@
|
||||
- **chore(docker):** new installs use the Cheaper Inference Docker Hub repository `cheaperinference/omniroute` (Helm chart 0.1.2, the base Kubernetes manifest, the manifest generator, compose, Podman and the docs); `diegosouzapw/omniroute` keeps every release and its pull history, and stays the home of the `:next` channel ([#20490](https://github.com/cheaper-inference/OmniRoute/pull/20490))
|
||||
@@ -191,7 +191,7 @@ podman run -d --name omniroute \
|
||||
-e DATA_DIR=/app/data \
|
||||
-p 20128:20128 \
|
||||
-v omniroute-data:/app/data \
|
||||
docker.io/cheaperinference/omniroute:latest
|
||||
docker.io/diegosouzapw/omniroute:latest
|
||||
```
|
||||
|
||||
For a bind mount that still fails, inspect or repair the shared path from the
|
||||
|
||||
@@ -9,7 +9,7 @@ After=omniroute-redis.service
|
||||
# Use this image after building locally
|
||||
Image=localhost/omniroute:base
|
||||
# Or use the fully qualified published image (there is no published :base tag)
|
||||
# Image=docker.io/cheaperinference/omniroute:latest
|
||||
# Image=docker.io/diegosouzapw/omniroute:latest
|
||||
|
||||
ContainerName=omniroute
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ name: omniroute
|
||||
description: OmniRoute — unified AI proxy/router. One endpoint, many LLM providers, auto-fallback.
|
||||
type: application
|
||||
# Chart version — bump on every chart change.
|
||||
version: 0.1.2
|
||||
version: 0.1.1
|
||||
# Default image tag. Overridable with image.tag.
|
||||
appVersion: "latest"
|
||||
home: https://github.com/cheaper-inference/OmniRoute
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: cheaperinference/omniroute
|
||||
repository: diegosouzapw/omniroute
|
||||
# Pin a real SemVer (or a digest) for anything you care about. `latest` only
|
||||
# moves when a stable release promotes it, so it silently lags merged fixes.
|
||||
tag: "latest"
|
||||
|
||||
@@ -43,7 +43,7 @@ spec:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: omniroute
|
||||
image: cheaperinference/omniroute:latest
|
||||
image: diegosouzapw/omniroute:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
services:
|
||||
omniroute:
|
||||
image: cheaperinference/omniroute:latest
|
||||
image: diegosouzapw/omniroute:latest
|
||||
container_name: omniroute
|
||||
environment:
|
||||
- OMNIROUTE_DIRECT_HEADERS_TIMEOUT_MS=${OMNIROUTE_DIRECT_HEADERS_TIMEOUT_MS:-300000}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# open http://127.0.0.1:20128
|
||||
#
|
||||
# No profiles, no build step, no multi-tenant anything.
|
||||
# Pulls the published image `cheaperinference/omniroute:latest`.
|
||||
# Pulls the published image `diegosouzapw/omniroute:latest`.
|
||||
#
|
||||
# All app ports bind to 127.0.0.1 ONLY by default (REQUIRE_API_KEY ships
|
||||
# as false). Set APP_BIND_HOST=0.0.0.0 in .env ONLY after you have set
|
||||
@@ -35,7 +35,7 @@ services:
|
||||
retries: 3
|
||||
|
||||
omniroute:
|
||||
image: cheaperinference/omniroute:latest
|
||||
image: diegosouzapw/omniroute:latest
|
||||
container_name: omniroute
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 40s
|
||||
|
||||
@@ -50,9 +50,8 @@ Dashboard (/dashboard/plugins)
|
||||
`plugin.json`.
|
||||
- **Scanner** — `src/lib/plugins/scanner.ts`: discovers plugins on disk under
|
||||
the plugin directory.
|
||||
- **Loader** — `src/lib/plugins/loader.ts`: spawns each plugin in a separate
|
||||
Node.js child process and brokers hook calls over IPC. The child is not a
|
||||
sandbox (see "Plugin execution isolation" below).
|
||||
- **Loader** — `src/lib/plugins/loader.ts`: spawns each plugin in an isolated
|
||||
child process and brokers hook calls over IPC.
|
||||
|
||||
## Marketplace Catalog
|
||||
|
||||
@@ -243,14 +242,6 @@ silently falls back to the built-in seed registry and logs a warning.
|
||||
|
||||
### Plugin execution isolation
|
||||
|
||||
> **Plugins are not sandboxed.** The child is an ordinary Node.js process running
|
||||
> as the OmniRoute user, with no VM context and no Node.js permission flags, so
|
||||
> plugin code can read and write any file that user can, run programs and reach
|
||||
> the network. `requires.permissions` only decides which environment variables
|
||||
> the child receives; the other permissions are not enforced. Install only
|
||||
> plugins you trust. The process boundary below contains crashes and hangs; it
|
||||
> is not a security boundary.
|
||||
|
||||
- **Process isolation** — `loadPlugin()` (`src/lib/plugins/loader.ts`) spawns
|
||||
each plugin in a separate Node.js child process and communicates over IPC.
|
||||
Hook calls have a timeout with `SIGTERM` → `SIGKILL` escalation.
|
||||
@@ -266,12 +257,8 @@ silently falls back to the built-in seed registry and logs a warning.
|
||||
- **Optional integrity pin** — a manifest may declare an `integrity`
|
||||
(`sha256-<base64>`, SRI format) field. When present, the loader verifies the
|
||||
entry file hash at load time and refuses to activate on mismatch. It is
|
||||
opt-in tamper-detection, **not** a security boundary: it does not limit what
|
||||
a loaded plugin can do.
|
||||
- **No client credentials in hooks** — the context passed to `onRequest`,
|
||||
`onResponse` and `onError` has the `authorization`, `x-api-key`,
|
||||
`proxy-authorization` and `cookie` headers removed, and the API key record carries no key
|
||||
value (`redactPluginContext()` in `src/lib/plugins/hooks.ts`).
|
||||
opt-in tamper-detection, **not** a security boundary — loopback-only routing
|
||||
and the permission model are the real boundaries.
|
||||
|
||||
## Manifest (`plugin.json`)
|
||||
|
||||
@@ -295,9 +282,7 @@ Validated by `PluginManifestSchema` (`src/lib/plugins/manifest.ts`):
|
||||
| `integrity` | string? | Optional `sha256-<base64>` entry-file pin |
|
||||
|
||||
Permissions are drawn from the enum
|
||||
`network` / `file-read` / `file-write` / `env` / `exec`. Only `env` has a
|
||||
runtime effect (a slightly larger environment-variable allowlist for the
|
||||
child); the others are declarations and are not enforced.
|
||||
`network` / `file-read` / `file-write` / `env` / `exec`.
|
||||
|
||||
## Lifecycle Flow
|
||||
|
||||
@@ -366,9 +351,6 @@ The dashboard page at `/dashboard/plugins`
|
||||
- **Marketplace** — shows the catalog from `GET /api/plugins/marketplace` with a
|
||||
field to set the custom registry URL.
|
||||
|
||||
The page always shows a warning that plugins run with the full privileges of
|
||||
the OmniRoute process.
|
||||
|
||||
A per-plugin config page lives at `/dashboard/plugins/[name]/config`
|
||||
(`src/app/(dashboard)/dashboard/plugins/[name]/config/page.tsx`).
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ Block the request and optionally return a custom response.
|
||||
|
||||
```ts
|
||||
onRequest: (ctx) => {
|
||||
if (!ctx.headers?.["x-client-team"]) {
|
||||
return blockRequest({ error: "Missing x-client-team header", status: 400 });
|
||||
if (!ctx.headers["authorization"]) {
|
||||
return blockRequest({ error: "Unauthorized", status: 401 });
|
||||
}
|
||||
};
|
||||
```
|
||||
@@ -76,22 +76,15 @@ onRequest: (ctx) => {
|
||||
|
||||
## Plugin Context (`PluginContext`)
|
||||
|
||||
| Field | Type | Description |
|
||||
| ------------ | ------------------------- | --------------------------- |
|
||||
| `requestId` | `string` | Unique request identifier |
|
||||
| `model` | `string` | Requested model name |
|
||||
| `provider` | `string` | Target provider ID |
|
||||
| `body` | `Record<string, unknown>` | Request body |
|
||||
| `headers` | `Record<string, string>` | Request headers (see note) |
|
||||
| `metadata` | `Record<string, unknown>` | Mutable metadata |
|
||||
| `timestamp` | `number` | Request timestamp |
|
||||
| `apiKeyInfo` | `object` (optional) | API key metadata (see note) |
|
||||
|
||||
The context never carries the client's credentials: the `authorization`, `x-api-key`,
|
||||
`proxy-authorization` and `cookie` headers are removed (any casing), and `apiKeyInfo` keeps the key's
|
||||
metadata (such as `id`, `name` and `scopes`) but not the key value or its fingerprint
|
||||
(`redactPluginContext()` in `src/lib/plugins/hooks.ts`). This applies to `onRequest`,
|
||||
`onResponse` and `onError`.
|
||||
| Field | Type | Description |
|
||||
| ----------- | ------------------------- | ------------------------- |
|
||||
| `requestId` | `string` | Unique request identifier |
|
||||
| `model` | `string` | Requested model name |
|
||||
| `provider` | `string` | Target provider ID |
|
||||
| `body` | `Record<string, unknown>` | Request body |
|
||||
| `headers` | `Record<string, string>` | Request headers |
|
||||
| `metadata` | `Record<string, unknown>` | Mutable metadata |
|
||||
| `timestamp` | `number` | Request timestamp |
|
||||
|
||||
## Manifest (`plugin.json`)
|
||||
|
||||
@@ -146,22 +139,17 @@ Or as simple booleans (default priority 100):
|
||||
|
||||
## Permission System
|
||||
|
||||
Plugins are **not sandboxed**. Each active plugin runs as a separate, ordinary Node.js child
|
||||
process (`loadPlugin()` in `src/lib/plugins/loader.ts`) under the same operating-system user as
|
||||
OmniRoute, with no VM context and no Node.js permission flags. Plugin code can use `node:fs`,
|
||||
`node:child_process`, `fetch` and every other Node.js API: it can read and write any file the
|
||||
OmniRoute user can (including the data directory), run programs and reach the network.
|
||||
Plugins run in a sandboxed VM context. Access to external resources requires explicit permissions:
|
||||
|
||||
The manifest's `requires.permissions` accepts `network`, `file-read`, `file-write`, `env` and
|
||||
`exec`, but today only `env` has an effect at runtime:
|
||||
| Permission | Grants |
|
||||
| ------------ | ------------------------------------------------------------ |
|
||||
| `network` | `fetch`, `AbortController`, `Headers`, `Request`, `Response` |
|
||||
| `file-read` | `fs.readFile`, `fs.readdir`, `fs.stat` |
|
||||
| `file-write` | `fs.writeFile`, `fs.mkdir`, `fs.rm` |
|
||||
| `env` | Read-only `process.env` proxy |
|
||||
| `exec` | `child_process.exec`, `child_process.execSync` |
|
||||
|
||||
| Permission | Effect today |
|
||||
| -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `env` | The plugin process also receives `PORT`, `HOSTNAME`, `TZ` and `TMPDIR`. Without it, it receives only `PATH`, `HOME`, `USER`, `LANG`, `LC_ALL`, `NODE_ENV`, `PLUGIN_ENTRY` and `PLUGIN_NAME` (plus `SystemRoot` and `windir` on Windows). |
|
||||
| `network`, `file-read`, `file-write`, `exec` | None. They are declarations only: nothing is blocked when they are missing. |
|
||||
|
||||
Installing a plugin is like installing any other program on the host. Install only plugins whose
|
||||
source you trust.
|
||||
Without a permission, the corresponding globals are simply not available in the sandbox.
|
||||
|
||||
## Config Schema
|
||||
|
||||
@@ -229,7 +217,7 @@ export default definePlugin({
|
||||
name: "rate-limiter",
|
||||
priority: 10,
|
||||
onRequest: async (ctx) => {
|
||||
const key = ctx.apiKeyInfo?.id || "anonymous";
|
||||
const key = ctx.headers["x-api-key"] || "anonymous";
|
||||
const now = Date.now();
|
||||
const window = 60000; // 1 minute
|
||||
const maxRequests = 100;
|
||||
|
||||
@@ -23,10 +23,10 @@ npm install -g omniroute
|
||||
### Option B: Docker
|
||||
|
||||
```bash
|
||||
docker run -d --name omniroute -p 20128:20128 cheaperinference/omniroute:latest
|
||||
docker run -d --name omniroute -p 20128:20128 diegosouzapw/omniroute:latest
|
||||
```
|
||||
|
||||
`:latest` is the highest **published** stable SemVer. It does **not** track git `main`. Pin `cheaperinference/omniroute:X.Y.Z` for GitOps. See [Image Tags / Release Channels](../guides/DOCKER_GUIDE.md#release-channels).
|
||||
`:latest` is the highest **published** stable SemVer. It does **not** track git `main`. Pin `diegosouzapw/omniroute:X.Y.Z` for GitOps. See [Image Tags / Release Channels](../guides/DOCKER_GUIDE.md#release-channels).
|
||||
|
||||
### Option C: From Source
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ you need to change them.
|
||||
docker compose -f docker-compose.selfhost.yml up -d
|
||||
```
|
||||
|
||||
Pulls `cheaperinference/omniroute:latest` (multi-arch AMD64 + ARM64, ~250 MB) and
|
||||
Pulls `diegosouzapw/omniroute:latest` (multi-arch AMD64 + ARM64, ~250 MB) and
|
||||
`redis:8.6.5-alpine`, starts both, and waits for Redis to be healthy before
|
||||
the app boots.
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ docker run -d \
|
||||
--stop-timeout 40 \
|
||||
-p 20128:20128 \
|
||||
-v omniroute-data:/app/data \
|
||||
cheaperinference/omniroute:latest
|
||||
diegosouzapw/omniroute:latest
|
||||
```
|
||||
|
||||
## With Environment File
|
||||
@@ -60,7 +60,7 @@ docker run -d \
|
||||
--env-file .env \
|
||||
-p 20128:20128 \
|
||||
-v omniroute-data:/app/data \
|
||||
cheaperinference/omniroute:latest
|
||||
diegosouzapw/omniroute:latest
|
||||
```
|
||||
|
||||
## Docker Compose
|
||||
@@ -342,7 +342,7 @@ Size **cgroup `--memory` above the heap** — native buffers, SQLite, and compre
|
||||
```bash
|
||||
docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
|
||||
-e OMNIROUTE_MEMORY_MB=8192 --memory=10g \
|
||||
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data cheaperinference/omniroute:latest
|
||||
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data diegosouzapw/omniroute:latest
|
||||
```
|
||||
|
||||
## Critical Environment Variables
|
||||
@@ -398,14 +398,14 @@ runtime environment variable.
|
||||
|
||||
### Pre-built root image + runtime subpath
|
||||
|
||||
Published `cheaperinference/omniroute:*` images are built for the domain root. You can still
|
||||
Published `diegosouzapw/omniroute:*` images are built for the domain root. You can still
|
||||
set `OMNIROUTE_BASE_PATH` at runtime; the container patches the bundle once on startup.
|
||||
Pair it with the matching public origin:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
omniroute:
|
||||
image: cheaperinference/omniroute:latest
|
||||
image: diegosouzapw/omniroute:latest
|
||||
environment:
|
||||
OMNIROUTE_BASE_PATH: /omniroute
|
||||
NEXT_PUBLIC_BASE_URL: https://myhostname.example.com/omniroute
|
||||
@@ -446,7 +446,7 @@ OmniRoute can be securely exposed using Caddy's automatic SSL provisioning. Ensu
|
||||
```yaml
|
||||
services:
|
||||
omniroute:
|
||||
image: cheaperinference/omniroute:latest
|
||||
image: diegosouzapw/omniroute:latest
|
||||
container_name: omniroute
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
@@ -496,17 +496,10 @@ Endpoint tunnel panels (Cloudflare, Tailscale, ngrok) can be shown or hidden fro
|
||||
|
||||
## Image Tags
|
||||
|
||||
| Image | Tag | Size | Description |
|
||||
| ---------------------------- | -------- | ------ | ---------------------------------------------------- |
|
||||
| `cheaperinference/omniroute` | `latest` | ~250MB | Highest **published** stable SemVer (not git `main`) |
|
||||
| `cheaperinference/omniroute` | `3.8.54` | ~250MB | Pin this class of tag for GitOps |
|
||||
|
||||
The same images are published to three repositories, with the same per-architecture digests:
|
||||
`cheaperinference/omniroute` (Docker Hub, the Cheaper Inference organization, from 3.8.53 on),
|
||||
`ghcr.io/cheaper-inference/omniroute` and the legacy `diegosouzapw/omniroute`, which keeps its
|
||||
pull history and still receives every release. Existing `diegosouzapw/omniroute` deployments
|
||||
keep updating; switching the image name is optional. The `:next` / `:next-web` pre-release
|
||||
channel below is published to `diegosouzapw/omniroute` and GHCR only.
|
||||
| Image | Tag | Size | Description |
|
||||
| ------------------------ | -------- | ------ | ---------------------------------------------------- |
|
||||
| `diegosouzapw/omniroute` | `latest` | ~250MB | Highest **published** stable SemVer (not git `main`) |
|
||||
| `diegosouzapw/omniroute` | `3.8.0` | ~250MB | Pin this class of tag for GitOps |
|
||||
|
||||
Multi-platform manifest: `linux/amd64` + `linux/arm64` native (Apple Silicon, AWS Graviton, Raspberry Pi). Docker selects the matching architecture automatically; pass `--platform linux/amd64` if you need to force AMD64 emulation on ARM hosts.
|
||||
|
||||
@@ -568,7 +561,7 @@ docker image inspect diegosouzapw/omniroute:next --format '{{index .RepoDigests
|
||||
Before testing, back up the OmniRoute data volume or bind-mounted data directory. To roll back, restore the previously used stable version or digest and recreate the container:
|
||||
|
||||
```bash
|
||||
docker pull cheaperinference/omniroute:<stable-version>
|
||||
docker pull diegosouzapw/omniroute:<stable-version>
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
|
||||
@@ -472,7 +472,7 @@ see [`docs/guides/KIRO_SETUP.md`](./KIRO_SETUP.md).
|
||||
2. **Permanent fix:** Bind to IPv4 explicitly by using `-p 127.0.0.1:20128:20128` in your `docker run` command:
|
||||
```bash
|
||||
docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
|
||||
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data cheaperinference/omniroute:latest
|
||||
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data diegosouzapw/omniroute:latest
|
||||
```
|
||||
This forces the IPv4 bind and also avoids exposing the proxy on all host interfaces.
|
||||
|
||||
|
||||
@@ -72,8 +72,6 @@ docker rm omniroute
|
||||
docker volume rm omniroute-data
|
||||
|
||||
# (Optional) Remove the image
|
||||
docker rmi cheaperinference/omniroute:latest
|
||||
# Older installs pulled the legacy name:
|
||||
docker rmi diegosouzapw/omniroute:latest
|
||||
```
|
||||
|
||||
|
||||
@@ -354,7 +354,7 @@ Helm:
|
||||
|
||||
```bash
|
||||
# Kustomize: pin a real tag rather than relying on :latest
|
||||
kubectl -n omniroute set image deploy/omniroute omniroute=cheaperinference/omniroute:3.8.54
|
||||
kubectl -n omniroute set image deploy/omniroute omniroute=diegosouzapw/omniroute:3.8.51
|
||||
|
||||
# Helm
|
||||
helm upgrade omniroute deploy/helm/omniroute -n omniroute --reuse-values \
|
||||
|
||||
@@ -135,7 +135,7 @@ EOF
|
||||
### 2.3 Start the container
|
||||
|
||||
```bash
|
||||
docker pull cheaperinference/omniroute:latest
|
||||
docker pull diegosouzapw/omniroute:latest
|
||||
|
||||
docker run -d \
|
||||
--name omniroute \
|
||||
@@ -143,7 +143,7 @@ docker run -d \
|
||||
--env-file /opt/omniroute/.env \
|
||||
-p 20128:20128 \
|
||||
-v omniroute-data:/app/data \
|
||||
cheaperinference/omniroute:latest
|
||||
diegosouzapw/omniroute:latest
|
||||
```
|
||||
|
||||
### 2.4 Verify that it is running
|
||||
@@ -302,13 +302,13 @@ curl -sI https://llms.seudominio.com/health
|
||||
### Upgrade to a new version
|
||||
|
||||
```bash
|
||||
docker pull cheaperinference/omniroute:latest
|
||||
docker pull diegosouzapw/omniroute:latest
|
||||
docker stop omniroute && docker rm omniroute
|
||||
docker run -d --name omniroute --restart unless-stopped \
|
||||
--env-file /opt/omniroute/.env \
|
||||
-p 20128:20128 \
|
||||
-v omniroute-data:/app/data \
|
||||
cheaperinference/omniroute:latest
|
||||
diegosouzapw/omniroute:latest
|
||||
```
|
||||
|
||||
### View logs
|
||||
|
||||
@@ -70,7 +70,7 @@ docker run -d --name omniroute \
|
||||
-p 20128:20128 \
|
||||
-v omniroute-data:/app/data \
|
||||
-e ENABLE_CC_COMPATIBLE_PROVIDER=true \
|
||||
cheaperinference/omniroute:latest
|
||||
diegosouzapw/omniroute:latest
|
||||
```
|
||||
|
||||
After restarting, the dashboard exposes an **Add Claude Code Compatible** option in
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { PageHeader } from "@omniroute/ui-kit/page-header";
|
||||
import { Alert } from "@omniroute/ui-kit/alert";
|
||||
import { Card, Button, EmptyState } from "@/shared/components";
|
||||
import Badge from "@/shared/components/Badge";
|
||||
import Icon from "@/shared/components/Icon";
|
||||
import { useNotificationStore } from "@/store/notificationStore";
|
||||
import { useConfirmDialog } from "@/shared/hooks/useConfirmDialog";
|
||||
import { useTranslations } from "next-intl";
|
||||
@@ -114,13 +112,6 @@ export default function PluginsPage() {
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<Alert
|
||||
variant="warning"
|
||||
dismissible={false}
|
||||
icon={<Icon name="warning" size={18} />}
|
||||
title={t("privilegesWarningTitle")}
|
||||
description={t("privilegesWarningBody")}
|
||||
/>
|
||||
{plugins.length === 0 ? (
|
||||
<EmptyState title={t("noPlugins")} description={t("noPluginsDescription")} />
|
||||
) : (
|
||||
|
||||
@@ -13434,8 +13434,6 @@
|
||||
"scanForPlugins": "Scan for Plugins",
|
||||
"noPlugins": "No plugins installed",
|
||||
"noPluginsDescription": "Place plugin directories in ~/.omniroute/plugins/ and click Scan.",
|
||||
"privilegesWarningTitle": "Plugins run with full privileges",
|
||||
"privilegesWarningBody": "A plugin runs as a regular Node.js process with the same access as OmniRoute: it can read files, run programs and use the network, whatever permissions its manifest declares. Install only plugins you trust.",
|
||||
"activate": "Activate",
|
||||
"deactivate": "Deactivate",
|
||||
"uninstall": "Uninstall",
|
||||
|
||||
@@ -344,7 +344,7 @@ export function defaultSpec(target: DeployTargetKind): DeploySpec {
|
||||
namespace: "omniroute",
|
||||
releaseName: "omniroute",
|
||||
image: {
|
||||
repository: "cheaperinference/omniroute",
|
||||
repository: "diegosouzapw/omniroute",
|
||||
tag: "latest",
|
||||
pullPolicy: "IfNotPresent" as const,
|
||||
},
|
||||
|
||||
@@ -231,55 +231,11 @@ export interface PluginContext {
|
||||
/** Client request headers available at the call site. Optional — not all callers
|
||||
* have access to headers (e.g. internal triggers, retries). Exposed so
|
||||
* observability/trace-export plugins can read request-scoped context sent by the
|
||||
* client (trace ids, correlation ids, session markers). Credential headers are removed
|
||||
* before a hook sees the context (see redactPluginContext). */
|
||||
* client (trace ids, correlation ids, session markers). */
|
||||
headers?: Record<string, string | string[] | undefined>;
|
||||
metadata: Record<string, unknown>;
|
||||
}
|
||||
|
||||
// ── Credential redaction ──
|
||||
// Plugins are third-party code running as an ordinary Node process with the OmniRoute
|
||||
// user's privileges, so anything in the hook context is readable by them. The client's
|
||||
// credentials never go there: the request pipeline keeps its own (unmodified) copy.
|
||||
|
||||
const CREDENTIAL_HEADER_NAMES: ReadonlySet<string> = new Set([
|
||||
"authorization",
|
||||
"x-api-key",
|
||||
"proxy-authorization",
|
||||
// The dashboard session token travels in a cookie.
|
||||
"cookie",
|
||||
]);
|
||||
|
||||
/** API key record fields that carry the key itself or a fingerprint of it. */
|
||||
const API_KEY_SECRET_FIELDS: ReadonlySet<string> = new Set(["key", "apiKey", "rawKey", "keyHash"]);
|
||||
|
||||
function omitFields(
|
||||
record: Record<string, unknown>,
|
||||
shouldOmit: (field: string) => boolean
|
||||
): Record<string, unknown> {
|
||||
return Object.fromEntries(Object.entries(record).filter(([field]) => !shouldOmit(field)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy of a hook context without the client's credentials: drops the `authorization`,
|
||||
* `x-api-key`, `proxy-authorization` and `cookie` headers (any casing) and the key value/fingerprint
|
||||
* from the API key record. The input is never mutated.
|
||||
*/
|
||||
function redactPluginContext<T extends PluginContext>(ctx: T): T {
|
||||
const redacted: T = { ...ctx };
|
||||
if (ctx.headers && typeof ctx.headers === "object") {
|
||||
redacted.headers = omitFields(ctx.headers, (name) =>
|
||||
CREDENTIAL_HEADER_NAMES.has(name.toLowerCase())
|
||||
) as PluginContext["headers"];
|
||||
}
|
||||
if (ctx.apiKeyInfo && typeof ctx.apiKeyInfo === "object") {
|
||||
redacted.apiKeyInfo = omitFields(ctx.apiKeyInfo as Record<string, unknown>, (field) =>
|
||||
API_KEY_SECRET_FIELDS.has(field)
|
||||
);
|
||||
}
|
||||
return redacted;
|
||||
}
|
||||
|
||||
export interface PluginResult {
|
||||
blocked?: boolean;
|
||||
response?: unknown;
|
||||
@@ -374,7 +330,7 @@ export async function runOnRequest(ctx: PluginContext): Promise<PluginResult> {
|
||||
// When no plugins exist, avoid lazy loading arbitrary plugin code in this request.
|
||||
if (!canInitializeRequestPlugins()) return {};
|
||||
await ensurePluginsLoaded();
|
||||
return emitHookBlocking("onRequest", redactPluginContext(ctx));
|
||||
return emitHookBlocking("onRequest", ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -383,11 +339,10 @@ export async function runOnRequest(ctx: PluginContext): Promise<PluginResult> {
|
||||
export async function runOnResponse(ctx: PluginContext, response: unknown): Promise<unknown> {
|
||||
let currentResponse = response;
|
||||
const list = hooks.get("onResponse") || [];
|
||||
const hookCtx = redactPluginContext(ctx);
|
||||
for (const reg of list) {
|
||||
assertPluginHandlerAllowed();
|
||||
try {
|
||||
const result = await reg.handler({ ...hookCtx, response: currentResponse });
|
||||
const result = await reg.handler({ ...ctx, response: currentResponse });
|
||||
if (
|
||||
result !== undefined &&
|
||||
result !== null &&
|
||||
@@ -408,7 +363,7 @@ export async function runOnResponse(ctx: PluginContext, response: unknown): Prom
|
||||
* Run onError hooks — fire-and-forget notification.
|
||||
*/
|
||||
export async function runOnError(ctx: PluginContext, error: Error): Promise<void> {
|
||||
await emitHook("onError", { ...redactPluginContext(ctx), error });
|
||||
await emitHook("onError", { ...ctx, error });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,8 @@ import {
|
||||
type ApiKeyUsageLimitStatus,
|
||||
} from "@/lib/usage/apiKeyUsageLimits";
|
||||
import { buildErrorBody } from "@omniroute/open-sse/utils/error";
|
||||
import { hasManageScope } from "@/shared/constants/managementScopes";
|
||||
import { hasSelfAccountQuotaScope } from "@/shared/constants/selfServiceScopes";
|
||||
|
||||
export const INTERNAL_USAGE_COMMAND = "@@om-usage";
|
||||
export const USAGE_COMMAND_DISABLED_MESSAGE = "Usage command is disabled for this API key.";
|
||||
@@ -23,6 +25,21 @@ export interface UsageCommandApiKeyMetadata {
|
||||
dailyUsageLimitUsd?: number | null;
|
||||
weeklyUsageLimitUsd?: number | null;
|
||||
fiveHourUsageLimitUsd?: number | null;
|
||||
scopes?: string[] | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The shared provider accounts behind a key (plan, raw quota windows, reset
|
||||
* times, connection ids) are operator data, not the key holder's. Only a key
|
||||
* explicitly granted `self:account-quota` (the same scope that gates
|
||||
* `accountQuotas` on /v1/me/status) or a management key may read them; any other
|
||||
* key gets its own personal quota and nothing else. Missing scopes fail closed.
|
||||
*/
|
||||
export function canReadSharedAccountQuota(scopes: readonly string[] | null | undefined): boolean {
|
||||
const list = Array.isArray(scopes)
|
||||
? scopes.filter((s): s is string => typeof s === "string")
|
||||
: [];
|
||||
return hasSelfAccountQuotaScope(list) || hasManageScope(list);
|
||||
}
|
||||
|
||||
interface ProviderConnectionLike {
|
||||
@@ -547,7 +564,9 @@ function appendQuotaBlock(
|
||||
* NOTE on percentage semantics (#15530):
|
||||
* - JSON `provider.quotas` and `providers[].quotas` expose raw upstream
|
||||
* snapshots (unadjusted usage and remaining numbers/percentages), alongside
|
||||
* connection-level `quotaWindowThresholds`.
|
||||
* connection-level `quotaWindowThresholds` — ONLY to keys allowed to read the
|
||||
* shared accounts ({@link canReadSharedAccountQuota}). Every other key gets
|
||||
* `provider: null` and `providers: []`.
|
||||
* - In contrast, text output (`buildUsageCommandText` / terminal `@@om-usage`)
|
||||
* renders cutoff-adjusted remaining percentages (`NN% left`) via
|
||||
* {@link effectiveRemainingPercent}, where the configured cutoff reserve
|
||||
@@ -591,6 +610,9 @@ export async function buildUsageCommandJson(
|
||||
{ now: resolvedDeps.now }
|
||||
)
|
||||
: null;
|
||||
if (!canReadSharedAccountQuota(metadata.scopes)) {
|
||||
return { allowed: true, personal, provider: null, providers: [] };
|
||||
}
|
||||
const snapshots = await collectUsageSnapshots(metadata, resolvedDeps);
|
||||
const provider = selectUsageSnapshot(snapshots, selection);
|
||||
return { allowed: true, personal, provider, providers: snapshots };
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
// npm publishing goes through Trusted Publishing (OIDC) only. The long-lived NPM_TOKEN expired
|
||||
// in silence (npm caps write tokens at 90 days) and the v3.8.54 plugin publishes failed with
|
||||
// E404 because the plugin jobs still sent it; the Trusted Publisher for both plugins was set up
|
||||
// on 2026-11-18 and @omniroute/opencode-plugin@0.2.2 / -v2@0.1.1 shipped through OIDC. The
|
||||
// only step left on a token is the DIRECT emergency fallback of `stage-npm`, which exists for
|
||||
// the case where Trusted Publishing itself is broken and needs a freshly minted token.
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import test from "node:test";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import YAML from "yaml";
|
||||
|
||||
const root = fileURLToPath(new URL("../../../", import.meta.url));
|
||||
const workflow = YAML.parse(readFileSync(join(root, ".github/workflows/npm-publish.yml"), "utf8"));
|
||||
|
||||
const DIRECT_FALLBACK = "Publish to npm (DIRECT — emergency fallback)";
|
||||
|
||||
function stepsUsingNpmToken() {
|
||||
const found = [];
|
||||
for (const [jobName, job] of Object.entries(workflow.jobs)) {
|
||||
for (const step of job.steps || []) {
|
||||
if (JSON.stringify(step).includes("secrets.NPM_TOKEN"))
|
||||
found.push(`${jobName} → ${step.name}`);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
test("only the DIRECT emergency fallback still reads the NPM_TOKEN secret", () => {
|
||||
assert.deepEqual(stepsUsingNpmToken(), [`stage-npm → ${DIRECT_FALLBACK}`]);
|
||||
});
|
||||
|
||||
for (const jobName of ["publish-opencode-plugin", "publish-opencode-plugin-v2"]) {
|
||||
test(`${jobName} publishes through OIDC: id-token write, no auth token on the publish step`, () => {
|
||||
const job = workflow.jobs[jobName];
|
||||
assert.equal(job.permissions["id-token"], "write");
|
||||
const publish = job.steps.find((s) => /^Publish @omniroute\//.test(s.name || ""));
|
||||
assert.ok(publish, `${jobName} has a publish step`);
|
||||
assert.equal(publish.env?.NODE_AUTH_TOKEN, undefined);
|
||||
assert.match(publish.run, /npm publish --provenance --access public/);
|
||||
});
|
||||
}
|
||||
|
||||
test("stage-npm staged mode publishes through OIDC as well", () => {
|
||||
const job = workflow.jobs["stage-npm"];
|
||||
assert.equal(job.permissions["id-token"], "write");
|
||||
const staged = job.steps.find((s) => (s.name || "").startsWith("Publish to npm (staged"));
|
||||
assert.ok(staged, "stage-npm has the staged step");
|
||||
assert.equal(staged.env?.NODE_AUTH_TOKEN, undefined);
|
||||
assert.match(staged.run, /npm stage publish/);
|
||||
});
|
||||
@@ -216,29 +216,3 @@ test("generated ConfigMap keys match the committed ConfigMap", () => {
|
||||
"the dashboard would ship a different env surface than the committed manifests"
|
||||
);
|
||||
});
|
||||
|
||||
// The default image is the Cheaper Inference Docker Hub repository; the Helm chart and the
|
||||
// static base manifest point at the same name, so the three ways to deploy agree.
|
||||
// diegosouzapw/omniroute still receives every release (legacy name, same digests).
|
||||
test("default image is cheaperinference/omniroute in the generator, the Helm chart and the base manifest", () => {
|
||||
for (const target of ["local", "vps"] as const) {
|
||||
const spec = defaultSpec(target);
|
||||
assert.equal(spec.image.repository, "cheaperinference/omniroute");
|
||||
const deployment = ofKind(docsFor(spec), "Deployment") as {
|
||||
spec?: { template?: { spec?: { containers?: { image?: string }[] } } };
|
||||
};
|
||||
assert.equal(
|
||||
deployment.spec?.template?.spec?.containers?.[0]?.image,
|
||||
`cheaperinference/omniroute:${spec.image.tag}`
|
||||
);
|
||||
}
|
||||
const values = yamlLoad(
|
||||
fs.readFileSync(path.join(REPO_ROOT, "deploy/helm/omniroute/values.yaml"), "utf8")
|
||||
) as { image?: { repository?: string } };
|
||||
assert.equal(values.image?.repository, "cheaperinference/omniroute");
|
||||
const base = fs.readFileSync(
|
||||
path.join(REPO_ROOT, "deploy/kubernetes/base/deployment.yaml"),
|
||||
"utf8"
|
||||
);
|
||||
assert.match(base, /image: cheaperinference\/omniroute:latest/);
|
||||
});
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
// Plugin hooks must not receive the client's credentials. A plugin is third-party code
|
||||
// running as a plain Node child process, so whatever the hook context carries is fully
|
||||
// readable by it. The request headers handed to onRequest/onResponse/onError must not
|
||||
// include `authorization`, `x-api-key`, `proxy-authorization` or `cookie` (any casing), and the
|
||||
// API key record must not carry the key itself — only its id/name/scopes-style metadata.
|
||||
import { test, afterEach } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
|
||||
const { registerHook, unregisterHooks, runOnResponse, runOnError } =
|
||||
await import("../../src/lib/plugins/hooks.ts");
|
||||
const { runPluginOnRequestHook } =
|
||||
await import("../../open-sse/handlers/chatCore/pluginOnRequest.ts");
|
||||
const { loadPlugin } = await import("../../src/lib/plugins/loader.ts");
|
||||
|
||||
const SECRET = "sk-client-secret-value-0001";
|
||||
const CREDENTIAL_HEADERS = ["authorization", "x-api-key", "proxy-authorization", "cookie"];
|
||||
|
||||
function clientHeaders(): Record<string, string> {
|
||||
return {
|
||||
Authorization: `Bearer ${SECRET}`,
|
||||
"X-Api-Key": SECRET,
|
||||
"proxy-authorization": `Basic ${SECRET}`,
|
||||
Cookie: `auth_token=${SECRET}; theme=dark`,
|
||||
"x-trace-id": "trace-123",
|
||||
"content-type": "application/json",
|
||||
};
|
||||
}
|
||||
|
||||
function apiKeyRecord() {
|
||||
return {
|
||||
id: "key-id-1",
|
||||
name: "ci key",
|
||||
scopes: ["chat"],
|
||||
noLog: false,
|
||||
key: SECRET,
|
||||
keyHash: "fingerprint-of-the-key",
|
||||
};
|
||||
}
|
||||
|
||||
function assertNoCredentials(seen: unknown) {
|
||||
const ctx = seen as { headers?: Record<string, unknown>; apiKeyInfo?: Record<string, unknown> };
|
||||
assert.ok(ctx, "expected the hook to run");
|
||||
const headerNames = Object.keys(ctx.headers ?? {}).map((h) => h.toLowerCase());
|
||||
for (const name of CREDENTIAL_HEADERS) {
|
||||
assert.equal(headerNames.includes(name), false, `hook received the ${name} header`);
|
||||
}
|
||||
assert.equal(ctx.headers?.["x-trace-id"], "trace-123", "non-credential headers stay visible");
|
||||
assert.equal(ctx.apiKeyInfo?.id, "key-id-1");
|
||||
assert.equal(ctx.apiKeyInfo?.name, "ci key");
|
||||
assert.deepEqual(ctx.apiKeyInfo?.scopes, ["chat"]);
|
||||
assert.equal("key" in (ctx.apiKeyInfo ?? {}), false, "hook received the API key value");
|
||||
assert.equal("keyHash" in (ctx.apiKeyInfo ?? {}), false, "hook received the key fingerprint");
|
||||
assert.equal(JSON.stringify(seen).includes(SECRET), false, "the client secret reached the hook");
|
||||
}
|
||||
|
||||
const registered: string[] = [];
|
||||
afterEach(() => {
|
||||
for (const name of registered.splice(0)) unregisterHooks(name);
|
||||
});
|
||||
|
||||
test("a real plugin process's onRequest hook never sees the client's credentials", async (t) => {
|
||||
const pluginDir = await mkdtemp(join(tmpdir(), "omniroute-plugin-cred-"));
|
||||
const entryPoint = join(pluginDir, "index.mjs");
|
||||
await writeFile(
|
||||
entryPoint,
|
||||
`export async function onRequest(ctx) {
|
||||
return { body: { seen: { headers: ctx.headers ?? null, apiKeyInfo: ctx.apiKeyInfo ?? null } } };
|
||||
}
|
||||
`,
|
||||
"utf-8"
|
||||
);
|
||||
const loaded = await loadPlugin(entryPoint, {
|
||||
name: "credential-probe",
|
||||
version: "1.0.0",
|
||||
license: "MIT",
|
||||
main: "index.mjs",
|
||||
source: "local",
|
||||
tags: [],
|
||||
requires: { permissions: [] },
|
||||
hooks: { onRequest: true, onResponse: false, onError: false },
|
||||
skills: [],
|
||||
enabledByDefault: false,
|
||||
configSchema: {},
|
||||
} as unknown as Parameters<typeof loadPlugin>[1]);
|
||||
t.after(async () => {
|
||||
loaded.cleanup();
|
||||
await rm(pluginDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
||||
});
|
||||
registerHook("onRequest", "credential-probe", loaded.plugin.onRequest as never);
|
||||
registered.push("credential-probe");
|
||||
|
||||
const headers = clientHeaders();
|
||||
const gate = await runPluginOnRequestHook({
|
||||
requestId: "req-cred-1",
|
||||
body: { messages: [{ role: "user", content: "hi" }] },
|
||||
model: "gpt-x",
|
||||
provider: "openai",
|
||||
apiKeyInfo: apiKeyRecord(),
|
||||
headers,
|
||||
});
|
||||
|
||||
assert.equal(gate.blocked, false);
|
||||
if (gate.blocked) return;
|
||||
const body = gate.body as { seen?: unknown } | undefined;
|
||||
assertNoCredentials(body?.seen);
|
||||
// The caller's own header record is not mutated: the request pipeline still needs it.
|
||||
assert.equal(headers.Authorization, `Bearer ${SECRET}`);
|
||||
assert.equal(headers["X-Api-Key"], SECRET);
|
||||
});
|
||||
|
||||
test("onResponse hooks never see the client's credentials", async () => {
|
||||
let seen: unknown;
|
||||
registerHook("onResponse", "credential-probe-response", async (ctx: unknown) => {
|
||||
seen = ctx;
|
||||
});
|
||||
registered.push("credential-probe-response");
|
||||
|
||||
await runOnResponse(
|
||||
{
|
||||
requestId: "req-cred-2",
|
||||
body: {},
|
||||
model: "gpt-x",
|
||||
provider: "openai",
|
||||
apiKeyInfo: apiKeyRecord(),
|
||||
headers: clientHeaders(),
|
||||
metadata: {},
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
|
||||
assertNoCredentials(seen);
|
||||
});
|
||||
|
||||
test("onError hooks never see the client's credentials", async () => {
|
||||
let seen: unknown;
|
||||
registerHook("onError", "credential-probe-error", async (ctx: unknown) => {
|
||||
seen = ctx;
|
||||
});
|
||||
registered.push("credential-probe-error");
|
||||
|
||||
await runOnError(
|
||||
{
|
||||
requestId: "req-cred-3",
|
||||
body: {},
|
||||
model: "gpt-x",
|
||||
provider: "openai",
|
||||
apiKeyInfo: apiKeyRecord(),
|
||||
headers: clientHeaders(),
|
||||
metadata: {},
|
||||
},
|
||||
new Error("upstream failed")
|
||||
);
|
||||
|
||||
assertNoCredentials(seen);
|
||||
});
|
||||
|
||||
test("a context without headers or API key record still reaches the hook unchanged", async () => {
|
||||
let seen: Record<string, unknown> | undefined;
|
||||
registerHook("onError", "credential-probe-empty", async (ctx: unknown) => {
|
||||
seen = ctx as Record<string, unknown>;
|
||||
});
|
||||
registered.push("credential-probe-empty");
|
||||
|
||||
await runOnError(
|
||||
{ requestId: "req-cred-4", body: {}, model: "m", provider: "p", metadata: {} },
|
||||
new Error("x")
|
||||
);
|
||||
|
||||
assert.ok(seen);
|
||||
assert.equal(seen!.headers, undefined);
|
||||
assert.equal(seen!.apiKeyInfo, undefined);
|
||||
assert.equal(seen!.requestId, "req-cred-4");
|
||||
});
|
||||
@@ -38,7 +38,7 @@ test("#8497 Podman guide separates local engines from Podman Machine", () => {
|
||||
assert.match(localGuidance, /podman unshare chown 1000:1000 \.\/data/);
|
||||
assert.doesNotMatch(machineGuidance, /podman unshare chown/);
|
||||
assert.match(machineGuidance, /remote client/);
|
||||
assert.match(machineGuidance, /docker\.io\/cheaperinference\/omniroute:latest/);
|
||||
assert.match(machineGuidance, /docker\.io\/diegosouzapw\/omniroute:latest/);
|
||||
});
|
||||
|
||||
test("#8497 Quadlet is Linux/systemd-only and generated units are not enabled", () => {
|
||||
@@ -94,8 +94,8 @@ test("#8497 pull example and environment hints stay topology-safe", () => {
|
||||
const envExample = read(".env.example");
|
||||
const envReference = read("docs/reference/ENVIRONMENT.md");
|
||||
|
||||
assert.match(quadlet, /Image=docker\.io\/cheaperinference\/omniroute:latest/);
|
||||
assert.doesNotMatch(quadlet, /(?:diegosouzapw|cheaperinference)\/omniroute:base/);
|
||||
assert.match(quadlet, /Image=docker\.io\/diegosouzapw\/omniroute:latest/);
|
||||
assert.doesNotMatch(quadlet, /diegosouzapw\/omniroute:base/);
|
||||
|
||||
for (const source of [envExample, envReference]) {
|
||||
assert.match(source, /any Podman topology/);
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
// @vitest-environment jsdom
|
||||
/**
|
||||
* The plugins page must tell the operator that plugins run with the full privileges of the
|
||||
* OmniRoute process. The manifest's `requires.permissions` is not a sandbox (it only selects
|
||||
* which environment variables the plugin process receives), so the notice is shown whether
|
||||
* or not any plugin is installed and cannot be dismissed.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { act } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { NextIntlClientProvider } from "next-intl";
|
||||
import messages from "../../../src/i18n/messages/en.json";
|
||||
|
||||
vi.mock("next/navigation", () => ({
|
||||
useRouter: () => ({ push: vi.fn() }),
|
||||
usePathname: () => "/dashboard/plugins",
|
||||
}));
|
||||
|
||||
vi.mock("@/store/notificationStore", () => ({
|
||||
useNotificationStore: () => ({ addNotification: vi.fn() }),
|
||||
}));
|
||||
|
||||
let pluginList: unknown[] = [];
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi
|
||||
.fn()
|
||||
.mockImplementation(() =>
|
||||
Promise.resolve({ ok: true, json: async () => ({ plugins: pluginList }) })
|
||||
)
|
||||
);
|
||||
|
||||
import PluginsPage from "../../../src/app/(dashboard)/dashboard/plugins/page";
|
||||
|
||||
describe("plugins page — full-privileges notice", () => {
|
||||
let container: HTMLDivElement;
|
||||
let root: ReturnType<typeof createRoot>;
|
||||
|
||||
beforeEach(() => {
|
||||
container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
root = createRoot(container);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
act(() => {
|
||||
root.unmount();
|
||||
});
|
||||
document.body.removeChild(container);
|
||||
pluginList = [];
|
||||
});
|
||||
|
||||
async function renderPage() {
|
||||
await act(async () => {
|
||||
root.render(
|
||||
<NextIntlClientProvider locale="en" messages={{ plugins: messages.plugins }}>
|
||||
<PluginsPage />
|
||||
</NextIntlClientProvider>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function notice(): HTMLElement | null {
|
||||
return container.querySelector('[data-slot="alert"][data-variant="warning"]');
|
||||
}
|
||||
|
||||
it("shows the notice when no plugin is installed", async () => {
|
||||
await renderPage();
|
||||
const alert = notice();
|
||||
expect(alert).not.toBeNull();
|
||||
expect(alert!.textContent).toContain(messages.plugins.privilegesWarningTitle);
|
||||
expect(alert!.textContent).toContain(messages.plugins.privilegesWarningBody);
|
||||
expect(alert!.querySelector("button.ci-alert__dismiss")).toBeNull();
|
||||
});
|
||||
|
||||
it("shows the notice alongside installed plugins", async () => {
|
||||
pluginList = [
|
||||
{ name: "demo", version: "1.0.0", status: "active", enabled: true, hooks: ["onRequest"] },
|
||||
];
|
||||
await renderPage();
|
||||
expect(container.textContent).toContain("demo");
|
||||
expect(notice()?.textContent).toContain(messages.plugins.privilegesWarningTitle);
|
||||
});
|
||||
|
||||
it("the notice says permissions are not a sandbox and to trust the plugin", () => {
|
||||
const body = messages.plugins.privilegesWarningBody;
|
||||
expect(body).toMatch(/whatever permissions its manifest declares/);
|
||||
expect(body).toMatch(/only plugins you trust/);
|
||||
});
|
||||
});
|
||||
@@ -32,11 +32,14 @@ function allowedDeps(overrides: Record<string, unknown> = {}) {
|
||||
return {
|
||||
now: () => NOW,
|
||||
isValidApiKey: async (apiKey: string) => apiKey === "sk-allowed",
|
||||
// The panel key is explicitly granted the shared-account view; a plain
|
||||
// client key (self:usage only) is covered by the tests at the bottom.
|
||||
getApiKeyMetadata: async () => ({
|
||||
id: "key-allowed",
|
||||
name: "panel key",
|
||||
allowUsageCommand: true,
|
||||
usageLimitEnabled: true,
|
||||
scopes: ["self:usage", "self:account-quota"],
|
||||
}),
|
||||
getProviderConnections: async () => [
|
||||
{ id: "conn-claude", provider: "claude", isActive: true },
|
||||
@@ -223,3 +226,75 @@ test("om-usage preserves raw quota in json while text scales remaining quota by
|
||||
assert.match(text, /Weekly/);
|
||||
assert.match(text, /20% left/);
|
||||
});
|
||||
|
||||
// A client key with the usage command could read, through ?format=json, every
|
||||
// shared provider account: connection ids, plan, raw quota and resets. Those
|
||||
// belong to the operator, not to the key holder.
|
||||
function failingProviderCollectors() {
|
||||
const fail = () => {
|
||||
throw new Error("provider accounts must not be read for this key");
|
||||
};
|
||||
return {
|
||||
getProviderConnections: async () => fail(),
|
||||
getAllProviderLimitsCache: () => fail(),
|
||||
getProviderConnectionById: async () => fail(),
|
||||
getProviderLimitsCache: () => fail(),
|
||||
};
|
||||
}
|
||||
|
||||
for (const [label, scopes] of [
|
||||
["a plain client key (self:usage only)", ["self:usage"]],
|
||||
["a key whose metadata carries no scopes", undefined],
|
||||
] as const) {
|
||||
test(`om-usage ?format=json hides the shared provider accounts from ${label}`, async () => {
|
||||
const response = await handleInternalUsageCommandHttpRequest(
|
||||
new Request("http://localhost/api/usage/om-usage?format=json", {
|
||||
headers: { Authorization: "Bearer sk-allowed" },
|
||||
}),
|
||||
allowedDeps({
|
||||
getApiKeyMetadata: async () => ({
|
||||
id: "key-client",
|
||||
name: "client key",
|
||||
allowUsageCommand: true,
|
||||
usageLimitEnabled: true,
|
||||
...(scopes ? { scopes: [...scopes] } : {}),
|
||||
}),
|
||||
...failingProviderCollectors(),
|
||||
})
|
||||
);
|
||||
|
||||
assert.equal(response.status, 200);
|
||||
const body = (await response.json()) as {
|
||||
allowed: boolean;
|
||||
personal: { weeklySpentUsd: number } | null;
|
||||
provider: unknown;
|
||||
providers: unknown[];
|
||||
};
|
||||
assert.equal(body.allowed, true);
|
||||
assert.equal(body.personal?.weeklySpentUsd, 8);
|
||||
assert.equal(body.provider, null);
|
||||
assert.deepEqual(body.providers, []);
|
||||
assert.doesNotMatch(JSON.stringify(body), /conn-claude|conn-codex|Claude Max|Codex Pro/);
|
||||
});
|
||||
}
|
||||
|
||||
test("om-usage ?format=json still shows the shared accounts to a management key", async () => {
|
||||
const response = await handleInternalUsageCommandHttpRequest(
|
||||
new Request("http://localhost/api/usage/om-usage?format=json", {
|
||||
headers: { Authorization: "Bearer sk-allowed" },
|
||||
}),
|
||||
allowedDeps({
|
||||
getApiKeyMetadata: async () => ({
|
||||
id: "key-admin",
|
||||
name: "operator key",
|
||||
allowUsageCommand: true,
|
||||
usageLimitEnabled: false,
|
||||
scopes: ["manage", "self:usage"],
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
assert.equal(response.status, 200);
|
||||
const body = (await response.json()) as { providers: Array<{ provider: string }> };
|
||||
assert.deepEqual(body.providers.map((s) => s.provider).sort(), ["claude", "codex"]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user