mozart-router 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -1,250 +1,253 @@
1
- # Mozart
2
-
3
- [![CI](https://github.com/ucav/mozart-router/actions/workflows/ci.yml/badge.svg)](https://github.com/ucav/mozart-router/actions)
4
- [![Tests](https://img.shields.io/badge/tests-118%20passed-brightgreen)](https://github.com/ucav/mozart-router)
5
- [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
6
- [![Version](https://img.shields.io/badge/version-0.1.0-blue)](https://github.com/ucav/mozart-router)
7
-
8
- **Mozart is the local conductor for AI agents** — a gateway-aware routing and orchestration layer that integrates as a skill, tool, adapter or middleware into your existing AI stack.
9
-
10
- Mozart detects your available gateways, providers and models, then routes each task to the best option based on cost, context, latency, privacy, quotas and reliability.
11
-
12
- ```
13
- Gateways execute. Mozart decides.
14
-
15
- Do not rebuild what the gateway already does.
16
- Detect it, understand it, orchestrate it.
17
- ```
18
-
19
- ## Why Mozart?
20
-
21
- - **Stop choosing models manually.** Mozart classifies your task and picks the best model.
22
- - **Stop wasting tokens.** Context optimization reduces token usage.
23
- - **Stop leaking sensitive context.** Privacy Guard prevents secrets from being sent to cloud models.
24
- - **Stop breaking agent workflows when providers fail.** Automatic fallback chains keep your agents running.
25
- - **Understand every decision.** Every route comes with a full explanation why this model, why not the others.
26
-
27
- ## What Mozart is
28
-
29
- - A **skill** callable by OpenClaw, OpenCode, Hermes or custom agents
30
- - A **tool** that agents can invoke for routing decisions
31
- - An **adapter** that reads existing gateway configs without duplicating them
32
- - A **middleware** you can insert between your agent and its gateway
33
- - A **local SDK** you import into your own TypeScript/Node.js projects
34
- - A **CLI** for diagnostics, simulation, and reporting
35
-
36
- ## What Mozart is NOT
37
-
38
- - Not a desktop application or separate dashboard
39
- - Not a replacement for LiteLLM, OpenRouter, or your existing gateways
40
- - Not a tool that asks you to re-enter all your API keys
41
- - Not a system that stores or manages keys that gateways already handle
42
-
43
- ## Quick start
44
-
45
- ```bash
46
- git clone https://github.com/ucav/mozart-router.git
47
- cd mozart-router
48
- npm install
49
- npm run build
50
-
51
- # Integration-first — detect your existing stack
52
- npx mozart-router init --gateway opencode
53
- npx mozart-router init --gateway openclaw
54
- npx mozart-router init --gateway hermes
55
-
56
- # Discover what's already available
57
- npx mozart-router doctor
58
-
59
- # See your full inventory
60
- npx mozart-router inventory
61
-
62
- # Simulate routing before executing
63
- npx mozart-router simulate "debug my Next.js build error"
64
-
65
- # Route a task (recommend-only by default)
66
- npx mozart-router route "write Playwright tests"
67
-
68
- # Understand the decision
69
- npx mozart-router why
70
-
71
- # Session report
72
- npx mozart-router report
73
-
74
- # List available Mozart skills for your agents
75
- npx mozart-router skills
76
- ```
77
-
78
- > Note: until published to npm, use `npm run mozart -- <command>` for local development. The `npx mozart-router` commands will work after `npm publish`.
79
-
80
- ## Integration modes
81
-
82
- ### 1. Skill mode — for OpenClaw, OpenCode, Hermes
83
-
84
- Copy the skill manifest from `examples/` into your agent:
85
-
86
- ```bash
87
- npx mozart-router init --gateway opencode # → examples/opencode/mozart-skill.json
88
- npx mozart-router init --gateway openclaw # → examples/openclaw/mozart-skill.yaml
89
- npx mozart-router init --gateway hermes # → examples/hermes/mozart-tool.json
90
- ```
91
-
92
- ### 2. SDK mode — import into your agent code
93
-
94
- ```typescript
95
- import { Mozart, OllamaAdapter, OpenRouterAdapter, OpenClawAdapter } from 'mozart-router';
96
-
97
- const mozart = new Mozart();
98
-
99
- // Register adapters — Mozart auto-detects each gateway
100
- mozart.registry.registerAdapter(new OllamaAdapter());
101
- mozart.registry.registerAdapter(new OpenRouterAdapter());
102
- mozart.registry.registerAdapter(new OpenClawAdapter());
103
-
104
- // Discover all gateways
105
- await mozart.detectAll();
106
-
107
- // Route a task
108
- const route = await mozart.recommend('write a function to sort an array');
109
- console.log(route.selectedModel); // e.g. "qwen3:8b"
110
-
111
- // Full processing with privacy, cost, explanation
112
- const response = await mozart.process({
113
- input: 'refactor the auth module',
114
- budgetMode: 'balanced',
115
- privacyMode: 'balanced',
116
- executionMode: 'recommend',
117
- });
118
- ```
119
-
120
- ### 3. Adapter mode — introspect any gateway
121
-
122
- ```typescript
123
- import { OllamaAdapter } from 'mozart-router';
124
-
125
- const ollama = new OllamaAdapter();
126
- const detection = await ollama.detect();
127
- const models = await ollama.listModels();
128
- // Build inventory without touching API keys
129
- ```
130
-
131
- ### 4. Middleware mode — OpenAI-compatible proxy
132
-
133
- ```bash
134
- npm run mozart -- proxy --port=4445
135
- # Point your agent to http://127.0.0.1:4445/v1
136
- # Mozart routes every chat completion to the best model
137
- ```
138
-
139
- ### 5. Recommend-only mode — advisory without execution
140
-
141
- ```typescript
142
- const recommendation = await mozart.recommend('security audit payment module');
143
- // Returns: selected model, confidence, cost estimate, explanation
144
- // No execution your existing gateway handles the actual call
145
- ```
146
-
147
- ## Architecture
148
-
149
- ```
150
- User / Agent / IDE
151
- |
152
- Mozart Interface (CLI · SDK · Skills · API · Middleware)
153
- |
154
- Gateway Introspection Layer → detects existing configs non-destructively
155
- |
156
- Provider & Model Inventory → built from detected gateways
157
- |
158
- Task Classifier → heuristic, local, no LLM needed
159
- |
160
- Policy Engine → privacy, budget, routing rules
161
- |
162
- Privacy Guard → scans for secrets, blocks cloud leaks
163
- |
164
- Context Optimizer → reduces token waste
165
- |
166
- Routing Engine → 7-dimension scoring per model
167
- |
168
- Explainability → every decision explained
169
- |
170
- Execution Delegation → delegates to existing gateway
171
- |
172
- Existing Gateway → LiteLLM · OpenRouter · Ollama · ...
173
- ```
174
-
175
- ## Feature matrix
176
-
177
- See [docs/FEATURE_MATRIX.md](docs/FEATURE_MATRIX.md) for the complete status of every module.
178
-
179
- ## Core commands
180
-
181
- | Command | Description |
182
- |---------|-------------|
183
- | `mozart doctor` | Detect gateways, providers and models |
184
- | `mozart inventory` | Show full inventory as JSON |
185
- | `mozart simulate <task>` | Simulate routing for a task |
186
- | `mozart route <task>` | Route a task (recommend-only) |
187
- | `mozart why` | Explain the last routing decision |
188
- | `mozart report` | Show session report |
189
- | `mozart skills` | List available Mozart skills |
190
- | `mozart profiles` | List built-in policy profiles |
191
- | `mozart policy list` | List available policy profiles |
192
- | `mozart start [--port=4444]` | Start local HTTP API + dashboard |
193
- | `mozart stream [--port=4445]` | Start streaming middleware (SSE) |
194
- | `mozart proxy [--port=4445]` | Start OpenAI-compatible middleware |
195
- | `mozart mcp` | Start MCP server (stdlib) |
196
- | `mozart config init` | Interactive config generator |
197
- | `mozart plugins` | List registered plugins |
198
- | `mozart metrics` | Export metrics (JSON + Prometheus) |
199
- | `mozart health` | Health check all adapters |
200
- | `mozart scan-local` | Scan local hardware capabilities |
201
- | `mozart sync dealsforge` | Load DealsForge provider intelligence |
202
- | `mozart init --gateway <name>` | Generate integration files |
203
- | `mozart reset` | Clear all local data |
204
-
205
- ## Skills
206
-
207
- Mozart exposes these skills for agents:
208
-
209
- | Skill | Description |
210
- |-------|-------------|
211
- | `mozart.route_model` | Choose best model/provider for a task |
212
- | `mozart.explain_route` | Explain why a model was chosen |
213
- | `mozart.estimate_cost` | Estimate cost before execution |
214
- | `mozart.compress_context` | Optimize context for token savings |
215
- | `mozart.privacy_check` | Scan content for secrets |
216
- | `mozart.fallback_plan` | Generate fallback execution plan |
217
- | `mozart.inventory` | Return current inventory |
218
-
219
- ## Documentation
220
-
221
- | Document | Content |
222
- |----------|---------|
223
- | [ARCHITECTURE](docs/ARCHITECTURE.md) | System design and module dependencies |
224
- | [GATEWAY_FIRST_PRINCIPLES](docs/GATEWAY_FIRST_PRINCIPLES.md) | Why Mozart doesn't replace gateways |
225
- | [FEATURE_MATRIX](docs/FEATURE_MATRIX.md) | Complete feature status |
226
- | [INTEGRATIONS](docs/INTEGRATIONS.md) | Supported gateways and agents |
227
- | [ADAPTERS](docs/ADAPTERS.md) | Adapter reference and how to create new ones |
228
- | [SKILLS_AND_TOOLS](docs/SKILLS_AND_TOOLS.md) | Skill/tool manifest reference |
229
- | [RECOMMEND_ONLY_MODE](docs/RECOMMEND_ONLY_MODE.md) | How Mozart works without execution |
230
- | [SECURITY](docs/SECURITY.md) | Security design and privacy guard |
231
- | [LIMITATIONS](docs/LIMITATIONS.md) | Honest limits and constraints |
232
- | [ROADMAP](docs/ROADMAP.md) | Development plans |
233
-
234
- ## Security
235
-
236
- - All secrets are redacted in logs (see [SECURITY](docs/SECURITY.md))
237
- - No API keys are stored or logged
238
- - Privacy Guard scans content before routing
239
- - Local-only mode prevents cloud routing
240
- - No mandatory telemetry
241
- - All processing is local by default
242
- - See [reports/SECURITY_AUDIT.md](reports/SECURITY_AUDIT.md) for full audit
243
-
244
- ## Contributing
245
-
246
- See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.
247
-
248
- ## License
249
-
250
- MIT — see [LICENSE](LICENSE)
1
+ # Mozart
2
+
3
+ [![CI](https://github.com/ucav/mozart-router/actions/workflows/ci.yml/badge.svg)](https://github.com/ucav/mozart-router/actions)
4
+ [![npm version](https://img.shields.io/npm/v/mozart-router.svg)](https://www.npmjs.com/package/mozart-router)
5
+ [![npm downloads](https://img.shields.io/npm/dm/mozart-router.svg)](https://www.npmjs.com/package/mozart-router)
6
+ [![Tests](https://img.shields.io/badge/tests-118%20passed-brightgreen)](https://github.com/ucav/mozart-router)
7
+ [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
8
+
9
+ **Mozart is the local conductor for AI agents** — a gateway-aware routing and orchestration layer that integrates as a skill, tool, adapter or middleware into your existing AI stack.
10
+
11
+ Mozart detects your available gateways, providers and models, then routes each task to the best option based on cost, context, latency, privacy, quotas and reliability.
12
+
13
+ ```
14
+ Gateways execute. Mozart decides.
15
+
16
+ Do not rebuild what the gateway already does.
17
+ Detect it, understand it, orchestrate it.
18
+ ```
19
+
20
+ ## Why Mozart?
21
+
22
+ - **Stop choosing models manually.** Mozart classifies your task and picks the best model.
23
+ - **Stop wasting tokens.** Context optimization reduces token usage.
24
+ - **Stop leaking sensitive context.** Privacy Guard prevents secrets from being sent to cloud models.
25
+ - **Stop breaking agent workflows when providers fail.** Automatic fallback chains keep your agents running.
26
+ - **Understand every decision.** Every route comes with a full explanation — why this model, why not the others.
27
+
28
+ ## What Mozart is
29
+
30
+ - A **skill** callable by OpenClaw, OpenCode, Hermes or custom agents
31
+ - A **tool** that agents can invoke for routing decisions
32
+ - An **adapter** that reads existing gateway configs without duplicating them
33
+ - A **middleware** you can insert between your agent and its gateway
34
+ - A **local SDK** you import into your own TypeScript/Node.js projects
35
+ - A **CLI** for diagnostics, simulation, and reporting
36
+
37
+ ## What Mozart is NOT
38
+
39
+ - Not a desktop application or separate dashboard
40
+ - Not a replacement for LiteLLM, OpenRouter, or your existing gateways
41
+ - Not a tool that asks you to re-enter all your API keys
42
+ - Not a system that stores or manages keys that gateways already handle
43
+
44
+ ## Quick start
45
+
46
+ ```bash
47
+ npm install -g mozart-router
48
+
49
+ # Or use directly with npx
50
+ npx mozart-router doctor
51
+ ```
52
+
53
+ ```bash
54
+ # Integration-first detect your existing stack
55
+ npx mozart-router init --gateway opencode
56
+ npx mozart-router init --gateway openclaw
57
+ npx mozart-router init --gateway hermes
58
+
59
+ # Discover what's already available
60
+ npx mozart-router doctor
61
+
62
+ # See your full inventory
63
+ npx mozart-router inventory
64
+
65
+ # Simulate routing before executing
66
+ npx mozart-router simulate "debug my Next.js build error"
67
+
68
+ # Route a task (recommend-only by default)
69
+ npx mozart-router route "write Playwright tests"
70
+
71
+ # Understand the decision
72
+ npx mozart-router why
73
+
74
+ # Session report
75
+ npx mozart-router report
76
+
77
+ # List available Mozart skills for your agents
78
+ npx mozart-router skills
79
+ ```
80
+
81
+ ## Integration modes
82
+
83
+ ### 1. Skill mode — for OpenClaw, OpenCode, Hermes
84
+
85
+ Copy the skill manifest from `examples/` into your agent:
86
+
87
+ ```bash
88
+ npx mozart-router init --gateway opencode # → examples/opencode/mozart-skill.json
89
+ npx mozart-router init --gateway openclaw # → examples/openclaw/mozart-skill.yaml
90
+ npx mozart-router init --gateway hermes # → examples/hermes/mozart-tool.json
91
+ ```
92
+
93
+ ### 2. SDK mode — import into your agent code
94
+
95
+ ```typescript
96
+ import { Mozart, OllamaAdapter, OpenRouterAdapter, OpenClawAdapter } from 'mozart-router';
97
+
98
+ const mozart = new Mozart();
99
+
100
+ // Register adapters — Mozart auto-detects each gateway
101
+ mozart.registry.registerAdapter(new OllamaAdapter());
102
+ mozart.registry.registerAdapter(new OpenRouterAdapter());
103
+ mozart.registry.registerAdapter(new OpenClawAdapter());
104
+
105
+ // Discover all gateways
106
+ await mozart.detectAll();
107
+
108
+ // Route a task
109
+ const route = await mozart.recommend('write a function to sort an array');
110
+ console.log(route.selectedModel); // e.g. "qwen3:8b"
111
+
112
+ // Full processing with privacy, cost, explanation
113
+ const response = await mozart.process({
114
+ input: 'refactor the auth module',
115
+ budgetMode: 'balanced',
116
+ privacyMode: 'balanced',
117
+ executionMode: 'recommend',
118
+ });
119
+ ```
120
+
121
+ ### 3. Adapter mode — introspect any gateway
122
+
123
+ ```typescript
124
+ import { OllamaAdapter } from 'mozart-router';
125
+
126
+ const ollama = new OllamaAdapter();
127
+ const detection = await ollama.detect();
128
+ const models = await ollama.listModels();
129
+ // Build inventory without touching API keys
130
+ ```
131
+
132
+ ### 4. Middleware mode — OpenAI-compatible proxy
133
+
134
+ ```bash
135
+ npx mozart-router proxy --port=4445
136
+ # Point your agent to http://127.0.0.1:4445/v1
137
+ # Mozart routes every chat completion to the best model
138
+ ```
139
+
140
+ ### 5. Recommend-only mode — advisory without execution
141
+
142
+ ```typescript
143
+ const recommendation = await mozart.recommend('security audit payment module');
144
+ // Returns: selected model, confidence, cost estimate, explanation
145
+ // No execution — your existing gateway handles the actual call
146
+ ```
147
+
148
+ ## Architecture
149
+
150
+ ```
151
+ User / Agent / IDE
152
+ |
153
+ Mozart Interface (CLI · SDK · Skills · API · Middleware)
154
+ |
155
+ Gateway Introspection Layer → detects existing configs non-destructively
156
+ |
157
+ Provider & Model Inventory → built from detected gateways
158
+ |
159
+ Task Classifier → heuristic, local, no LLM needed
160
+ |
161
+ Policy Engine → privacy, budget, routing rules
162
+ |
163
+ Privacy Guard → scans for secrets, blocks cloud leaks
164
+ |
165
+ Context Optimizer → reduces token waste
166
+ |
167
+ Routing Engine → 7-dimension scoring per model
168
+ |
169
+ Explainability → every decision explained
170
+ |
171
+ Execution Delegation → delegates to existing gateway
172
+ |
173
+ Existing Gateway → LiteLLM · OpenRouter · Ollama · ...
174
+ ```
175
+
176
+ ## Feature matrix
177
+
178
+ See [docs/FEATURE_MATRIX.md](docs/FEATURE_MATRIX.md) for the complete status of every module.
179
+
180
+ ## Core commands
181
+
182
+ | Command | Description |
183
+ |---------|-------------|
184
+ | `mozart doctor` | Detect gateways, providers and models |
185
+ | `mozart inventory` | Show full inventory as JSON |
186
+ | `mozart simulate <task>` | Simulate routing for a task |
187
+ | `mozart route <task>` | Route a task (recommend-only) |
188
+ | `mozart why` | Explain the last routing decision |
189
+ | `mozart report` | Show session report |
190
+ | `mozart skills` | List available Mozart skills |
191
+ | `mozart profiles` | List built-in policy profiles |
192
+ | `mozart policy list` | List available policy profiles |
193
+ | `mozart start [--port=4444]` | Start local HTTP API + dashboard |
194
+ | `mozart stream [--port=4445]` | Start streaming middleware (SSE) |
195
+ | `mozart proxy [--port=4445]` | Start OpenAI-compatible middleware |
196
+ | `mozart mcp` | Start MCP server (stdlib) |
197
+ | `mozart config init` | Interactive config generator |
198
+ | `mozart plugins` | List registered plugins |
199
+ | `mozart metrics` | Export metrics (JSON + Prometheus) |
200
+ | `mozart health` | Health check all adapters |
201
+ | `mozart scan-local` | Scan local hardware capabilities |
202
+ | `mozart sync dealsforge` | Load DealsForge provider intelligence |
203
+ | `mozart init --gateway <name>` | Generate integration files |
204
+ | `mozart reset` | Clear all local data |
205
+
206
+ ## Skills
207
+
208
+ Mozart exposes these skills for agents:
209
+
210
+ | Skill | Description |
211
+ |-------|-------------|
212
+ | `mozart.route_model` | Choose best model/provider for a task |
213
+ | `mozart.explain_route` | Explain why a model was chosen |
214
+ | `mozart.estimate_cost` | Estimate cost before execution |
215
+ | `mozart.compress_context` | Optimize context for token savings |
216
+ | `mozart.privacy_check` | Scan content for secrets |
217
+ | `mozart.fallback_plan` | Generate fallback execution plan |
218
+ | `mozart.inventory` | Return current inventory |
219
+
220
+ ## Documentation
221
+
222
+ | Document | Content |
223
+ |----------|---------|
224
+ | [ARCHITECTURE](docs/ARCHITECTURE.md) | System design and module dependencies |
225
+ | [GATEWAY_FIRST_PRINCIPLES](docs/GATEWAY_FIRST_PRINCIPLES.md) | Why Mozart doesn't replace gateways |
226
+ | [FEATURE_MATRIX](docs/FEATURE_MATRIX.md) | Complete feature status |
227
+ | [INTEGRATIONS](docs/INTEGRATIONS.md) | Supported gateways and agents |
228
+ | [ADAPTERS](docs/ADAPTERS.md) | Adapter reference and how to create new ones |
229
+ | [SKILLS_AND_TOOLS](docs/SKILLS_AND_TOOLS.md) | Skill/tool manifest reference |
230
+ | [RECOMMEND_ONLY_MODE](docs/RECOMMEND_ONLY_MODE.md) | How Mozart works without execution |
231
+ | [SECURITY](docs/SECURITY.md) | Security design and privacy guard |
232
+ | [LIMITATIONS](docs/LIMITATIONS.md) | Honest limits and constraints |
233
+ | [ROADMAP](docs/ROADMAP.md) | Development plans |
234
+
235
+ ## Security
236
+
237
+ - All secrets are redacted in logs (see [SECURITY](docs/SECURITY.md))
238
+ - No API keys are stored or logged
239
+ - Privacy Guard scans content before routing
240
+ - Local-only mode prevents cloud routing
241
+ - No mandatory telemetry
242
+ - All processing is local by default
243
+ - See [reports/SECURITY_AUDIT.md](reports/SECURITY_AUDIT.md) for full audit
244
+
245
+ ## Contributing
246
+
247
+ Contributions are welcome! Check the [good first issues](https://github.com/ucav/mozart-router/labels/good%20first%20issue) for beginner-friendly tasks.
248
+
249
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for full contribution guidelines.
250
+
251
+ ## License
252
+
253
+ MIT — see [LICENSE](LICENSE)
@@ -1 +1 @@
1
- {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/adapters/cursor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,KAAK,EACN,MAAM,UAAU,CAAC;AAElB,qBAAa,aAAc,YAAW,cAAc;IAClD,EAAE,SAAY;IACd,IAAI,SAAY;IAEV,MAAM,IAAI,OAAO,CAAC,eAAe,CAAC;IAgBlC,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAU3C,aAAa,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIpC,UAAU,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;CAGrC"}
1
+ {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/adapters/cursor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,KAAK,EACN,MAAM,UAAU,CAAC;AAuHlB,qBAAa,aAAc,YAAW,cAAc;IAClD,EAAE,SAAY;IACd,IAAI,SAAY;IAEV,MAAM,IAAI,OAAO,CAAC,eAAe,CAAC;IAmClC,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAU3C,aAAa,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAqBpC,UAAU,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;CAKrC"}