@hasna/switcher 0.1.2 → 0.1.3
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 +5 -2
- package/dist/cli/index.js +2634 -615
- package/dist/cli.d.ts +2 -0
- package/dist/codex-model-policy.d.ts +65 -0
- package/dist/direct-launch.d.ts +2 -2
- package/dist/domain.d.ts +259 -2
- package/dist/gemini-model-policy.d.ts +56 -0
- package/dist/generated/api.d.ts +192 -0
- package/dist/harness-types.d.ts +9 -0
- package/dist/hermes-model-policy.d.ts +30 -0
- package/dist/index.js +93 -42
- package/dist/inference-gateway.d.ts +24 -0
- package/dist/launcher.d.ts +8 -3
- package/dist/mcp/index.js +107 -55
- package/dist/model-policy-schema.d.ts +137 -0
- package/dist/model-policy.d.ts +31 -0
- package/dist/native-model-policy.d.ts +23 -0
- package/dist/opencode-model-policy.d.ts +33 -0
- package/dist/ori-model-policy.d.ts +8 -0
- package/dist/sdk.d.ts +238 -5
- package/dist/sdk.js +93 -42
- package/dist/serve/index.js +1044 -88
- package/docs/MODEL-POLICY.md +82 -0
- package/openapi.json +836 -1
- package/package.json +3 -2
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: "switcher-model-policy"
|
|
3
|
+
title: "Automatic model guidance and routing policy"
|
|
4
|
+
type: "user-guide"
|
|
5
|
+
owner: "codex-fixer"
|
|
6
|
+
created_at: "2026-09-06T20:15:46.138691+00:00"
|
|
7
|
+
updated_at: "2026-09-06T20:15:46.138691+00:00"
|
|
8
|
+
status: "active"
|
|
9
|
+
source_task: "01a07181-ca8d-70c1-99a2-b276dc5770f3"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Automatic model guidance
|
|
13
|
+
|
|
14
|
+
Starting with 0.1.3, every Switcher launch automatically adds model guidance to managed inference requests. The ordinary command needs no extra setup:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
switcher launch claude --provider deepseek --model deepseek-v4-flash
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The guidance identifies the main session model, the current request model, role assignments, permitted IDs, and the full catalog file. It tells the model to use exact provider IDs instead of remembered harness defaults such as Opus. Switcher appends its own block to native instructions; it preserves user messages, tool turns, media, and existing instruction metadata. It refreshes that block on resumed requests and supported token-count/compaction operations.
|
|
21
|
+
|
|
22
|
+
Prompt following is probabilistic. Switcher also enforces the model policy at a per-launch authenticated loopback gateway. A request for an unapproved model fails before it reaches the provider. The default permitted set contains only the selected main model. Native child/utility model slots are pinned where supported, so ordinary launches do not require manual environment variables.
|
|
23
|
+
|
|
24
|
+
# Assigning roles
|
|
25
|
+
|
|
26
|
+
Use exact IDs returned by `switcher models PROVIDER`. For example, assigning Claude's child-agent role to another model in the same eligible catalog:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
switcher launch claude --provider deepseek --model deepseek-v4-flash \
|
|
30
|
+
--role-model subagent=deepseek-v4-pro
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
For reusable profiles, `profiles add` accepts the same role flag or `--model-policy-file policy.json`. A saved profile can also carry `modelPolicy` through the API/SDK. Saved-profile launches use that saved policy; change the profile to change its routing contract.
|
|
34
|
+
|
|
35
|
+
A policy file has this shape; replace the example IDs with your provider's exact IDs:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"version": 1,
|
|
40
|
+
"roles": {"subagent": "vendor/child"},
|
|
41
|
+
"allowedModels": ["vendor/alternate"],
|
|
42
|
+
"aliases": {"alternate": "vendor/alternate"},
|
|
43
|
+
"fallbacks": {"vendor/main": ["vendor/alternate"]}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Unassigned roles default to the main model. The permitted set combines main, assigned roles, explicit allowed IDs, and fallback targets. All must be present in the eligible catalog. Aliases must point into that permitted set and cannot shadow another real model ID.
|
|
48
|
+
|
|
49
|
+
The complete provider catalog remains visible in each supported native catalog interface. Visibility does not grant permission to use every entry: add intended alternatives to `allowedModels` or launch again with `--model`. This prevents an agent from choosing a familiar but unintended model from a large provider catalog.
|
|
50
|
+
|
|
51
|
+
# Native controls
|
|
52
|
+
|
|
53
|
+
| Harness | Separate native roles wired by Switcher |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| Claude Code ≥2.1.257 | Forced subagent model; fast model through the Haiku default; main/default/Opus/Sonnet/Fable aliases pinned. |
|
|
56
|
+
| Codex ≥0.153 | Default subagent and review models; named role files receive the selected model/provider while preserving their ordinary instructions/settings. Memory extraction/consolidation model defaults are pinned to main. Custom role names must use letters, digits, underscores or hyphens because of native CLI override parsing. |
|
|
57
|
+
| Grok | Session summary model. |
|
|
58
|
+
| OpenCode 2 | General/explore and custom subagents; plan model. Explicit `--agent` launches use the assigned role model. Other primary/custom agents use main. |
|
|
59
|
+
| Legacy OpenCode | General/explore/custom subagents, plan, title/summary, compaction, and the small/fast model. |
|
|
60
|
+
| OMP | Fast (`smol`), planning (`slow` and `plan`). |
|
|
61
|
+
| Hermes | Delegation plus verified auxiliary tasks: compression, title/profile description, review, planning triage, approval, skills, MCP, session search and web extraction. Auxiliary custom-provider settings use the selected protocol and loopback credential. |
|
|
62
|
+
| Gemini CLI 0.58 | Codebase investigator, fast helpers, summarizers, compression, classifier and edit helpers; native default fallback chains terminate at the selected model. Existing generation/tool settings are retained. |
|
|
63
|
+
| Aider | Weak and editor models. |
|
|
64
|
+
| Kilo | Weak/small and subagent models. |
|
|
65
|
+
| Pi, DeepSeek Harness, Cline, Prime Agent | Selected main model and gateway enforcement; no separate role assignments are advertised. |
|
|
66
|
+
| Ori Codex/Grok | The same direct native policy, executed through a per-launch executable shim after Ori's OpenRouter setup. |
|
|
67
|
+
|
|
68
|
+
A role assignment differing from main is rejected when the adapter has no verified native slot for it. Native permissions and managed settings may further restrict a launch. Codex loads trusted project roles only; Switcher does not grant workspace trust. Gemini planning/review and OpenCode 2 utility role overrides are not advertised for the pinned versions.
|
|
69
|
+
|
|
70
|
+
# Fallbacks and evidence
|
|
71
|
+
|
|
72
|
+
Fallbacks are opt-in and ordered. The gateway tries the configured targets only after HTTP 429, HTTP 5xx, or a network failure before a response begins. It does not retry 400/401/403 or retry after a stream starts. Harness-native retries may still repeat the same request. Hermes may try its main-agent model after an auxiliary error; that request remains subject to the same gateway policy.
|
|
73
|
+
|
|
74
|
+
`switcher runs list` and the API/SDK expose `routingEvents` and `routingEventsDropped`. Events record requested and resolved IDs, allow/alias/reject/fallback decisions, safe reason codes, upstream status, and a provider-reported model when observable. Unknown reported IDs are redacted. Each run retains at most 1,000 events and 512 KiB of routing evidence; additional events increase the dropped counter. Events are finalized when a managed request ends, and launch cleanup flushes them before saving final run status.
|
|
75
|
+
|
|
76
|
+
The API requires `modelPolicyVersion: 1` on run creation; the current SDK supplies it. Older launchers receive an upgrade error from an upgraded server. An older local CLI running its own older server cannot enforce the new policy: keep the launcher and server upgraded.
|
|
77
|
+
|
|
78
|
+
# Scope
|
|
79
|
+
|
|
80
|
+
The gateway controls requests sent through Switcher's managed endpoint. It does not sandbox arbitrary shell tools, user extensions, unmanaged network clients, or provider-side routing. Ori still makes its own OpenRouter catalog/auth requests. Provider-reported model IDs are evidence, not an attestation of the provider's internal execution.
|
|
81
|
+
|
|
82
|
+
The native child receives an ephemeral gateway token; the actual provider credential stays in the launcher. Policy files, injected guidance and routing events do not contain provider credential values. Prompt guidance and gateway enforcement are both enabled automatically; there is no prompt-only mode presented as equivalent enforcement.
|