@hasna/switcher 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 +20 -8
- package/dist/cli/index.js +2725 -621
- package/dist/cli.d.ts +2 -0
- package/dist/codex-model-policy.d.ts +65 -0
- package/dist/credentials.d.ts +71 -8
- 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 +138 -48
- package/dist/inference-gateway.d.ts +24 -0
- package/dist/launcher.d.ts +8 -3
- package/dist/mcp/index.js +153 -62
- 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 +248 -6
- package/dist/sdk.js +138 -48
- package/dist/serve/index.js +1044 -88
- package/docs/MODEL-POLICY.md +82 -0
- package/openapi.json +836 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ title: "Switcher"
|
|
|
4
4
|
type: "package-documentation"
|
|
5
5
|
owner: "codex-fixer"
|
|
6
6
|
created_at: "2026-09-05T12:50:21.698672Z"
|
|
7
|
-
updated_at: "2026-09-
|
|
7
|
+
updated_at: "2026-09-07T06:18:32.384233+00:00"
|
|
8
8
|
status: "active"
|
|
9
9
|
source_task: "01a07181-ca8d-70c1-99a2-b276dc5770f3"
|
|
10
10
|
---
|
|
@@ -22,7 +22,7 @@ installation guidance for every adapter. If a harness is installed outside
|
|
|
22
22
|
|
|
23
23
|
| Harness | Executable and verified version | Install target | Official instructions |
|
|
24
24
|
| --- | --- | --- | --- |
|
|
25
|
-
| Claude Code | `claude`, >=2.1.
|
|
25
|
+
| Claude Code | `claude`, >=2.1.257 | Claude Code official distribution | [Quickstart](https://code.claude.com/docs/en/quickstart) |
|
|
26
26
|
| Codex CLI | `codex`, >=0.153.0 | OpenAI Codex official distribution | [Project](https://github.com/openai/codex) |
|
|
27
27
|
| Grok Build | `grok`, >=1.0.13 | xAI Grok Build official project | [Project](https://github.com/xai-org/grok-build) |
|
|
28
28
|
| OpenCode (legacy) | `opencode`, >=1.18.0 | `opencode-ai` | [CLI guide](https://github.com/anomalyco/opencode/blob/dev/packages/web/src/content/docs/cli.mdx) |
|
|
@@ -51,6 +51,9 @@ switcher doctor
|
|
|
51
51
|
|
|
52
52
|
The direct launch flow is available from 0.1.1. The additional OMP, DeepSeek Harness, Cline, Hermes, Prime Agent, legacy OpenCode, Kilo, Gemini CLI and Aider adapters are introduced in 0.1.2. Version 0.1.0 requires explicit API/provider/profile setup.
|
|
53
53
|
|
|
54
|
+
Version 0.1.3 automatically injects model guidance and enforces allowed model IDs through a per-launch gateway. Native child and utility models default to your selected provider model. Use `--role-model ROLE=ID` or `--model-policy-file FILE` for explicit assignments, aliases and fallbacks. The full catalog stays visible; using another catalog entry requires an allowed assignment or a new launch. See [model policy](docs/MODEL-POLICY.md) for native role support, routing traces and enforcement scope.
|
|
55
|
+
|
|
56
|
+
|
|
54
57
|
Supply the provider key through environment injection (`DEEPSEEK_API_KEY`, `OPENROUTER_API_KEY`, or an explicit `SWITCHER_PROVIDER_*` reference), or configure a local credential binding below. Switcher never saves the value.
|
|
55
58
|
|
|
56
59
|
```sh
|
|
@@ -66,18 +69,27 @@ An interactive terminal can choose or search the catalog when `--model` is omitt
|
|
|
66
69
|
|
|
67
70
|
When no remote API configuration is present, each CLI invocation starts an authenticated loopback API on an allocated port, stores SQLite data in `~/.hasna/switcher`, and closes its own listener on completion. Its random operator key remains in memory. Use `HASNA_SWITCHER_HOME` to choose another owner-only home, `HASNA_SWITCHER_SQLITE_PATH` for an explicit database, or `HASNA_SWITCHER_DATABASE_URL` for PostgreSQL. API and SDK data access remains HTTP.
|
|
68
71
|
|
|
69
|
-
|
|
72
|
+
Remote API configuration is resolved through Contracts, including canonical credential stores and the default gateway URL. Invalid, unavailable or unauthorized remote services fail without opening local SQLite.
|
|
70
73
|
|
|
71
74
|
The registry contains DeepSeek, OpenRouter, Anthropic, OpenAI, xAI, Ollama, LM Studio, Groq, Cerebras, Mistral, Together AI, Fireworks, Moonshot/Kimi, DashScope, Z.AI, MiniMax, SiliconFlow, and generic protocol entries. `switcher providers presets ID` exposes documented routes, aliases and limitations; this is not a claim that every combination has passed live tests. Remaining adapters and acceptance gates are tracked in [TODOS.md](TODOS.md).
|
|
72
75
|
|
|
76
|
+
## Canonical API configuration
|
|
77
|
+
|
|
78
|
+
The CLI, `clientFromEnv()` SDK helper and standalone MCP client resolve Switcher API URL/key through `@hasna/contracts/client`, following the same shared convention as Conversations. A key alone selects `https://api.hasna.com/switcher`; `HASNA_SWITCHER_API_URL` selects a self-hosted endpoint. The `SWITCHER_API_URL` and `SWITCHER_API_KEY` aliases are supported. Deliberate overrides/profile selections take precedence; otherwise the resolver reads macOS Keychain, canonical disk configuration and then environment. A live client rereads credentials before each request and refuses an authority change until rebuilt.
|
|
79
|
+
|
|
80
|
+
The canonical file is `~/.hasna/switcher/config/credentials` (owner-only mode 0600), using assignments named `HASNA_SWITCHER_API_URL` and `HASNA_SWITCHER_API_KEY`. Provision actual values through your approved secret manager. macOS Keychain uses service `hasna.credentials.switcher.api-key` and optional `api-url`, with account `HASNA_STATION` or the short hostname. Provider keys remain in the provider's vault or secure store; this file authenticates the Switcher API only.
|
|
81
|
+
|
|
82
|
+
`HASNA_HOME` replaces `~/.hasna`; `HASNA_CONFIG_HOME` places credentials at `<root>/switcher/credentials` and `<root>/secrets/credentials`. These shared overrides must be absolute and nonblank. `HASNA_PROFILE` selects `credentials-<profile>`; API authority stays in the common credentials file. `HASNA_SWITCHER_HOME` changes Switcher's local database, bindings and launch state only, and does not relocate shared credentials. `HOME` is respected by both paths.
|
|
83
|
+
|
|
84
|
+
Configured but missing, unsafe, conflicting or inaccessible remote credentials fail before local data is opened. Only complete absence of Switcher remote configuration retains the user-authorized automatic local API. The owned local API uses a random in-memory key. Server-side authentication remains configured separately through `HASNA_SWITCHER_API_KEY` on `switcher-serve`.
|
|
85
|
+
|
|
73
86
|
## Credential bindings
|
|
74
87
|
|
|
75
|
-
Bind an existing vault key once, then launch without an external wrapper.
|
|
88
|
+
Bind an existing vault key once, then launch without an external wrapper. New bindings use the installed `secrets` CLI and resolve its operator key and API URL through `@hasna/contracts/client`. A configured Keychain item or canonical `~/.hasna/secrets/config/credentials` supplies the operator without shell exports. The default Secrets API URL is `https://api.hasna.com/secrets`; `--vault-url` can select a custom vault but must agree with any configured Secrets authority.
|
|
76
89
|
|
|
77
90
|
```sh
|
|
78
91
|
switcher credentials bind deepseek \
|
|
79
|
-
--vault-key providers/deepseek/live/api_key
|
|
80
|
-
--vault-account my-station
|
|
92
|
+
--vault-key providers/deepseek/live/api_key
|
|
81
93
|
switcher credentials check deepseek
|
|
82
94
|
switcher launch claude --provider deepseek --model deepseek-v4-pro
|
|
83
95
|
```
|
|
@@ -88,7 +100,7 @@ For provider keys already stored in macOS Keychain, use `--keychain-service SERV
|
|
|
88
100
|
|
|
89
101
|
`credentials list` displays bindings; `credentials remove PRESET_OR_REFERENCE` removes only the locator. Replacement requires explicit removal. Custom credential references require `--origin URL` (repeatable); preset bindings authorize their documented origins by default. `credentials check` reports availability, length and hash, not successful provider authentication. Provider credentials needed by a remote API's catalog discovery must still be configured on that server independently.
|
|
90
102
|
|
|
91
|
-
|
|
103
|
+
Explicit `--vault-account ACCOUNT` pins one macOS Keychain account and requires `--vault-url`; it never falls back when that account is missing or locked. `--vault-operator env` preserves the per-process `HASNA_SECRETS_API_KEY` mode and also requires `--vault-url`. Existing bindings keep their original operator mode. To adopt canonical resolution for an old binding, explicitly remove and rebind its same provider key reference. A Secrets operator cannot bootstrap itself through `HASNA_SECRETS_API_KEY_REF`; use a literal operator from its canonical store or explicit override. On Linux the shared resolver reads the owner-only canonical credentials file or process environment. The binding stores only the locator and optional vault authority. Alternatively, let the authenticated `secrets` CLI inject a provider credential for one command:
|
|
92
104
|
|
|
93
105
|
```sh
|
|
94
106
|
secrets exec providers/deepseek/live/api_key --as DEEPSEEK_API_KEY -- \
|
|
@@ -244,7 +256,7 @@ Discovery allows at most two retries per page for network failures and HTTP 408,
|
|
|
244
256
|
|
|
245
257
|
| Harness | Required wire protocol | Native catalog |
|
|
246
258
|
| --- | --- | --- |
|
|
247
|
-
| Claude Code ≥2.1.
|
|
259
|
+
| Claude Code ≥2.1.257 | Anthropic Messages | Per-launch `modelPicker` on compatible Claude versions |
|
|
248
260
|
| Codex ≥0.153.0 | OpenAI Responses | Startup `model_catalog_json` |
|
|
249
261
|
| Grok Build ≥1.0.13 | Chat Completions, Responses or Messages | Authenticated loopback remote catalog with upstream model IDs |
|
|
250
262
|
| OpenCode 2 (tested beta-19157) | Chat Completions, Responses or Messages | Version 2 provider/model configuration and standalone server |
|