auto-model-router 0.1.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.
- package/.env.example +24 -0
- package/.github/workflows/publish.yml +40 -0
- package/.omp-plugin/marketplace.json +30 -0
- package/LICENSE +21 -0
- package/README.md +639 -0
- package/bun.lock +32 -0
- package/docs/claude-anthropic-wire.md +116 -0
- package/omp-extension/configure-logic.ts +128 -0
- package/omp-extension/embed-logic.ts +141 -0
- package/omp-extension/router-configure.ts +111 -0
- package/omp-extension/router-embed.ts +118 -0
- package/omp-extension/router-toast.ts +130 -0
- package/omp-extension/toast-logic.ts +136 -0
- package/package.json +56 -0
- package/src/catalog/openrouter-catalog.ts +428 -0
- package/src/catalog/types.ts +104 -0
- package/src/cli/args.ts +105 -0
- package/src/cli/config-cmd.ts +362 -0
- package/src/cli/config-wizard.ts +636 -0
- package/src/cli/explain.ts +167 -0
- package/src/cli/models.ts +240 -0
- package/src/cli/stats.ts +69 -0
- package/src/config/defaults.ts +136 -0
- package/src/config/load.ts +143 -0
- package/src/config/omp-credentials.ts +124 -0
- package/src/config/schema.ts +161 -0
- package/src/config/types.ts +244 -0
- package/src/cost/blended.ts +80 -0
- package/src/cost/forecast.ts +129 -0
- package/src/cost/ledger.ts +291 -0
- package/src/cost/types.ts +148 -0
- package/src/index.ts +93 -0
- package/src/router/cache-control.ts +66 -0
- package/src/router/candidates.ts +246 -0
- package/src/router/classify.ts +329 -0
- package/src/router/escalate.ts +264 -0
- package/src/router/features.ts +225 -0
- package/src/router/index.ts +99 -0
- package/src/router/select.ts +365 -0
- package/src/router/state.ts +118 -0
- package/src/router/tier-plan.ts +151 -0
- package/src/router/types.ts +222 -0
- package/src/server/http.ts +343 -0
- package/src/server/turn.ts +393 -0
- package/src/tokens/estimate.ts +74 -0
- package/src/upstream/openrouter.ts +221 -0
- package/src/upstream/sse-parse.ts +208 -0
- package/src/upstream/types.ts +75 -0
- package/src/util/hash.ts +0 -0
- package/src/util/log.ts +53 -0
- package/src/util/sqlite.ts +140 -0
- package/src/util/sse.ts +23 -0
- package/src/wire/openai/errors.ts +48 -0
- package/src/wire/openai/models.ts +37 -0
- package/src/wire/openai/request.ts +279 -0
- package/src/wire/openai/sink.ts +213 -0
- package/src/wire/types.ts +156 -0
- package/test/catalog.test.ts +319 -0
- package/test/classify.test.ts +269 -0
- package/test/config-wizard.test.ts +482 -0
- package/test/config.test.ts +121 -0
- package/test/configure-logic.test.ts +151 -0
- package/test/cost.test.ts +137 -0
- package/test/embed-logic.test.ts +107 -0
- package/test/escalate.test.ts +223 -0
- package/test/failover.test.ts +494 -0
- package/test/features.test.ts +228 -0
- package/test/fixtures/openrouter-models.json +15340 -0
- package/test/models-yml.test.ts +186 -0
- package/test/omp-credentials.test.ts +185 -0
- package/test/select.test.ts +538 -0
- package/test/sse-parse.test.ts +142 -0
- package/test/tier-plan.test.ts +302 -0
- package/test/toast-logic.test.ts +160 -0
- package/test/tokens.test.ts +160 -0
- package/test/trust-attribution.test.ts +175 -0
- package/test/turn.test.ts +498 -0
- package/test/wire-request.test.ts +297 -0
- package/test/wire-sink.test.ts +179 -0
- package/tools/install.ts +140 -0
- package/tools/mock-openrouter.ts +269 -0
- package/tools/smoke.ts +326 -0
- package/tsconfig.json +23 -0
package/.env.example
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# OpenRouter credential.
|
|
2
|
+
#
|
|
3
|
+
# Optional: if omp already has an OpenRouter login (`/login openrouter`),
|
|
4
|
+
# auto-model-router reads it straight from omp's auth store at
|
|
5
|
+
# ~/.omp/agent/agent.db and needs nothing here. Set this only to override
|
|
6
|
+
# that, or to point at a different account.
|
|
7
|
+
#
|
|
8
|
+
# The model catalog is readable unauthenticated either way, so
|
|
9
|
+
# `auto-model-router models` and `auto-model-router config --print` work with no key at all.
|
|
10
|
+
OPENROUTER_API_KEY=
|
|
11
|
+
|
|
12
|
+
# The router runs embedded in omp (router-embed.ts) and binds a free OS-assigned
|
|
13
|
+
# port so multiple omp sessions never collide. Set AUTO_MODEL_ROUTER_PORT only to pin a
|
|
14
|
+
# specific port instead (rarely needed).
|
|
15
|
+
# AUTO_MODEL_ROUTER_PORT=
|
|
16
|
+
|
|
17
|
+
# Config and database directory. Default: ~/.auto-model-router
|
|
18
|
+
# AUTO_MODEL_ROUTER_HOME=
|
|
19
|
+
|
|
20
|
+
# Log level: silent | error | warn | info | debug. Default: info
|
|
21
|
+
# AUTO_MODEL_ROUTER_LOG=info
|
|
22
|
+
|
|
23
|
+
# SQLite ledger path. Default: $AUTO_MODEL_ROUTER_HOME/router.db
|
|
24
|
+
# AUTO_MODEL_ROUTER_DB=
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
# Publish to npm when a change lands on main AND the package version actually
|
|
4
|
+
# changed. Doc-only commits (no version bump) are skipped, so npm stays in
|
|
5
|
+
# sync with real releases without publishing noise on every push.
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [main]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version: 20
|
|
19
|
+
registry-url: https://registry.npmjs.org
|
|
20
|
+
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: npm install
|
|
23
|
+
|
|
24
|
+
- name: Check if version changed
|
|
25
|
+
id: version
|
|
26
|
+
run: |
|
|
27
|
+
LOCAL=$(node -p "require('./package.json').version")
|
|
28
|
+
PUBLISHED=$(npm view auto-model-router version 2>/dev/null || echo "0.0.0")
|
|
29
|
+
echo "local=$LOCAL published=$PUBLISHED"
|
|
30
|
+
if [ "$LOCAL" != "$PUBLISHED" ]; then
|
|
31
|
+
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
32
|
+
else
|
|
33
|
+
echo "changed=false" >> "$GITHUB_OUTPUT"
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
- name: Publish to npm
|
|
37
|
+
if: steps.version.outputs.changed == 'true'
|
|
38
|
+
run: npm publish
|
|
39
|
+
env:
|
|
40
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
|
|
3
|
+
"name": "auto-model-router",
|
|
4
|
+
"owner": {
|
|
5
|
+
"name": "drewappling",
|
|
6
|
+
"email": "drewappling@gmail.com"
|
|
7
|
+
},
|
|
8
|
+
"metadata": {
|
|
9
|
+
"description": "auto-model-router: a local cost/complexity-aware model router for Oh My Pi, backed by OpenRouter",
|
|
10
|
+
"version": "0.1.0",
|
|
11
|
+
"pluginRoot": "."
|
|
12
|
+
},
|
|
13
|
+
"plugins": [
|
|
14
|
+
{
|
|
15
|
+
"name": "auto-model-router",
|
|
16
|
+
"description": "Local cost/complexity-aware model router for Oh My Pi, backed by OpenRouter. Runs in-process, routes per turn by price and task complexity, with budget caps, mid-stream escalation, and cache-aware hysteresis.",
|
|
17
|
+
"version": "0.1.0",
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "drewappling",
|
|
20
|
+
"email": "drewappling@gmail.com"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/drewappling/auto-model-router",
|
|
23
|
+
"repository": "https://github.com/drewappling/auto-model-router.git",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"keywords": ["router", "openrouter", "cost", "model", "omp", "oh-my-pi"],
|
|
26
|
+
"category": "development",
|
|
27
|
+
"source": "./"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 drewappling
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|