@hasna/switcher 0.1.5 → 0.1.7
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 +23 -0
- package/dist/catalog.d.ts +1 -0
- package/dist/claude-context.d.ts +5 -0
- package/dist/cli/index.js +519 -32
- package/dist/credentials.d.ts +12 -0
- package/dist/domain.d.ts +103 -1
- package/dist/generated/api.d.ts +47 -0
- package/dist/index.js +13 -2
- package/dist/mcp/index.js +8 -2
- package/dist/presets.d.ts +14 -0
- package/dist/provider-error.d.ts +2 -0
- package/dist/sdk.d.ts +74 -0
- package/dist/sdk.js +13 -2
- package/dist/serve/index.js +311 -20
- package/openapi.json +268 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,6 +96,18 @@ switcher launch claude --provider deepseek --model deepseek-v4-pro
|
|
|
96
96
|
|
|
97
97
|
`--vault-cli /absolute/path/to/secrets` selects a particular installation. Vault lookup uses `secrets exec` to inject the value into a short-lived receiver, which delivers it over an authenticated loopback connection. Values stay in process memory. The lookup has a 20-second deadline and owns a separate process group; it finishes before the native harness starts. Each lookup reads the vault again. Conflicting Secrets service URL configuration fails explicitly. Vault CLI bindings currently require POSIX; Windows callers can inject provider environment variables.
|
|
98
98
|
|
|
99
|
+
If launch reports `vault_exec_permissions`, verify the installed Secrets package against its trusted release artifact before repairing it. Bun 1.3.14's [bin-link installer](https://github.com/oven-sh/bun/blob/bun-v1.3.14/src/install/bin.zig#L731-L735) can change an executable member from mode `0755` to `0777`, including with `--ignore-scripts`. Changing the shell umask does not correct that installer behavior.
|
|
100
|
+
|
|
101
|
+
After validating the package archive against its registry integrity, compute the SHA256 of the executable member **inside that verified archive**. Use that expected digest to finalize the existing binding's installed executable:
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
switcher credentials repair-executable deepseek --sha256 EXPECTED_EXECUTABLE_SHA256
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
For a fresh installation whose unsafe executable prevents creating a binding, use `switcher credentials repair-executable --vault-cli /absolute/path/to/secrets --sha256 EXPECTED_EXECUTABLE_SHA256` first, then bind normally. Select either a binding reference or an explicit path.
|
|
108
|
+
|
|
109
|
+
The digest is a release-artifact checksum, not a credential. Do not substitute the installed file's own hash: that would trust any altered bytes. Repair checks the exact bytes, file owner/type and every path ancestor, then creates an identical private copy and atomically replaces the writable executable with group/public write permission removed. Cache hardlinks and already-open writers retain the old inode and cannot change the repaired executable. It then runs the ordinary launch checks again. Safe files are unchanged; digest mismatches, unsafe ancestors and unowned files are refused. The command never starts Secrets, contacts the vault, changes bindings, or repairs permissions automatically during launch. Run this explicit step after each affected installation; a later Bun install can reset bin modes again. Reinstall a verified package if its bytes differ.
|
|
110
|
+
|
|
99
111
|
For provider keys already stored in macOS Keychain, use `--keychain-service SERVICE --keychain-account ACCOUNT` instead of vault options. Bindings contain only references and authorized origins under `~/.hasna/switcher/config/credential-bindings`, in owner-only files. They remain local even when Switcher uses a remote API. A configured binding takes precedence over environment aliases; an unavailable binding never falls back to another account.
|
|
100
112
|
|
|
101
113
|
`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.
|
|
@@ -277,6 +289,17 @@ The Claude adapter sets `ANTHROPIC_DEFAULT_MODEL` and the default subagent model
|
|
|
277
289
|
|
|
278
290
|
Claude Code with a non-Claude model is experimental and unsupported by Anthropic. Codex requires Responses, not Chat Completions. Upstream reasoning, tool schemas, context limits and stateless Responses behavior still need provider-specific validation. Switcher never silently falls back to a different provider.
|
|
279
291
|
|
|
292
|
+
For Claude Code using the official DeepSeek Messages endpoint, Switcher defaults `CLAUDE_CODE_AUTO_COMPACT_WINDOW` to `786432`, following [DeepSeek's integration guidance](https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code/). An explicitly set environment value takes precedence. Recognized provider context-overflow errors become a sanitized `prompt is too long` error so the native client can compact or guide recovery; unrelated errors retain the sanitized upstream status. Existing launches must pick up the compaction setting or start a new launch to use this default.
|
|
293
|
+
|
|
294
|
+
New DeepSeek presets include `deepseek-v4.1-flash-expires-on-0910` as an additional preview model with `expiresOn: "2026-09-10"`. The provider's normal model discovery stays active. To register an unlisted model on an existing provider:
|
|
295
|
+
|
|
296
|
+
```sh
|
|
297
|
+
switcher models add my-provider vendor/preview --name "Preview" --expires-on 2026-09-10
|
|
298
|
+
switcher models my-provider --refresh
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
`--expires-on` is optional and accepts a real `YYYY-MM-DD` date. Dates are inclusive in UTC: `2026-09-10` becomes expired at `2026-09-11T00:00:00Z`. This is operator metadata, not a guarantee of provider uptime. Expired models remain visible in `switcher models` with `expired: true` and `codingEligible: false`; new launches, policy roles, native picker catalogs and subsequent gateway requests reject them. Existing processes are not stopped. `models add` appends to the provider's optional `additionalModels` array; entries merge by model ID with discovered or manual models and override only supplied metadata. A duplicate additional entry is rejected; use a versioned `providers update --file` to edit it. Remote catalogs can also supply `expiresOn` or `expires_on`. `manualModels` continues to replace discovery when explicitly configured.
|
|
302
|
+
|
|
280
303
|
For a provider without discovery, use `providers add ID --file provider.json` with `manualModels`. Each model needs `id` and `name`; optional fields are `contextWindow`, `maxOutputTokens`, `inputModalities`, `outputModalities`, `supportedParameters`, and `available`. Use `catalogBaseUrl` and `modelsPath` for a separate discovery root/path; CLI equivalents are `--catalog-url` and `--models-path`. Use `catalogFormat: "ollama"` for `/api/tags`. Mistral presets select a capability-aware parser, including archived status. Together presets select its native bare-array parser. Fireworks requires `--catalog-account-id ID` or an explicit catalog URL and retains count evidence across its paginated account catalog. DashScope requires an explicit region/workspace `--catalog-url` with `--catalog-format dashscope`. Z.AI currently requires an explicit catalog or manual models because its documented API has no model-list contract. MiniMax defaults to its `.cn` Open Platform endpoints; use an explicit authority and credential reference for another product or region. A different authenticated catalog origin requires an explicit `catalogCredentialEnv`; a public catalog can declare `catalogAuthStyle: "none"`. Standard credential aliases are resolved only for the matching built-in provider origin. The default parser follows Anthropic-style `has_more/last_id` pagination and otherwise expects an OpenAI-style `data` array. HTTP redirects are rejected.
|
|
281
304
|
|
|
282
305
|
Grok uses a per-launch authenticated loopback bridge because its environment overlay cannot define providers. The bridge serves model metadata and forwards the selected protocol unchanged. It holds upstream credentials only in memory; Grok receives an ephemeral local token. The same bridge handles credentialless endpoints and OpenCode auth-header mismatches. Bridged requests are limited to 4 MiB and four minutes. Grok resumes retain the selected profile model. Use `-- --resume SESSION_ID -p PROMPT` for headless continuation, or omit the prompt and type after the interactive session loads. Interactive resume with an inline positional prompt is rejected because the native client can send it before applying the selected model. Grok 1.0.13 passed source and installed development CLI resume checks against a controlled Messages fixture and live DeepSeek Flash. OpenCode's provider identity stays stable across temporary bridge ports; `-- run --session SESSION_ID PROMPT` resumes with fresh launch settings. The installed beta-19157 passed two-process Messages resume checks against a controlled local upstream and live DeepSeek Flash, including a proof-file read and preserved history. Other provider/protocol and registry-release cells remain tracked separately in COMPATIBILITY.md.
|
package/dist/catalog.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type Catalog, type Provider, type ProviderInput } from "./domain";
|
|
2
2
|
export type CatalogCredentialResolver = (provider: ProviderInput) => Promise<string | undefined>;
|
|
3
|
+
/** Add operator metadata only after remote pagination counts have been reconciled. */
|
|
3
4
|
export declare function discover(provider: Provider, env?: Record<string, string | undefined>, resolveCredential?: CatalogCredentialResolver): Promise<Catalog>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Keep enough room for Claude's next turn and compaction request on DeepSeek.
|
|
2
|
+
* https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code/
|
|
3
|
+
* Inspect the original provider URL: the native URL is a loopback gateway.
|
|
4
|
+
*/
|
|
5
|
+
export declare function claudeContextEnvironment(providerBaseUrl: string, environment?: NodeJS.ProcessEnv): Record<string, string>;
|