@hasna/switcher 0.2.1 → 0.2.2
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 +29 -4
- package/dist/cli/index.js +2044 -1664
- package/dist/credentials.d.ts +96 -7
- package/dist/direct-launch.d.ts +2 -1
- package/dist/domain.d.ts +63 -1
- package/dist/generated/api.d.ts +32 -0
- package/dist/index.js +6 -1
- package/dist/launcher.d.ts +1 -0
- package/dist/mcp/index.js +99 -3
- package/dist/presets.d.ts +8 -0
- package/dist/sdk.d.ts +36 -0
- package/dist/sdk.js +6 -1
- package/dist/serve/index.js +99 -3
- package/openapi.json +93 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -297,16 +297,41 @@ Configured but missing, unsafe, conflicting or inaccessible remote credentials f
|
|
|
297
297
|
|
|
298
298
|
## Credential bindings
|
|
299
299
|
|
|
300
|
-
Bind an existing vault key once, then launch without an external wrapper. New bindings
|
|
300
|
+
Bind an existing vault key once, then launch without an external wrapper. New bindings resolve the Secrets 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.
|
|
301
|
+
|
|
302
|
+
Real launches now preflight the local inference credential before catalog refresh and before an interactive model picker. An existing environment credential is preserved without creating a binding. An existing binding remains authoritative, including its exact Secrets operator account and allowed provider origins; a locked source, an unauthorized destination, or rejected provider credential is terminal and never falls through to another account.
|
|
303
|
+
|
|
304
|
+
When a provider credential is missing in an interactive terminal, Switcher uses the trusted `secrets` executable on `PATH` to search metadata only. It displays the selected Secrets account/source and matching vault key references, asks which reference to bind, saves that reference through the existing immutable binding store, resolves the value through the authenticated loopback delivery path, and performs a bounded, non-inference provider authentication check before continuing the original launch. OpenRouter uses its authenticated `GET /api/v1/key` metadata endpoint; its public model catalog is never treated as proof that a key works. Custom providers may declare a relative `credentialCheck` (`GET` or `HEAD`) in provider JSON. Catalog configuration alone is never inferred to validate a credential because a catalog may be public or ignore invalid authorization.
|
|
305
|
+
|
|
306
|
+
If no matching key exists, Secrets is unavailable, the selected Keychain/vault cannot be read, or the provider rejects the credential, the structured error names the exact recovery without changing accounts. The first-run binding pins the exact Contracts source and vault authority that were displayed; if that Keychain account, environment tier, profile, or canonical file changes, later launches stop rather than selecting another account. First-run bindings also retain a requirement for a supported provider authentication check, so an unsupported check cannot be bypassed by retrying. Older explicit bindings remain compatible when no safe check is declared; adding `credentialCheck` upgrades them to authenticated preflight without changing their account or origins. Noninteractive launches never prompt and return `credential_setup_required` with explicit binding syntax or the provider environment reference. `--dry-run` preserves its planning contract: it does not search Secrets, create a binding, retrieve a provider credential, or perform provider authentication merely to describe a launch plan. Public and credentialless catalogs may refresh. Authenticated catalogs are read from the saved Switcher snapshot; if none exists, the error names the explicit `switcher models PROVIDER --refresh` command that performs the credential-consuming refresh.
|
|
307
|
+
|
|
308
|
+
For stations that update global tools with Bun, give the vault binding a private, version-pinned npm installation. A later global Bun installation can reset the permissions of its `secrets` executable, including one already repaired, and break every provider using it. The private installation keeps that update path separate. This example uses Secrets `0.4.2`; choose an exact verified release and a **new, unused prefix** for each upgrade:
|
|
309
|
+
|
|
310
|
+
```sh
|
|
311
|
+
SWITCHER_VAULT_PREFIX="$HOME/.hasna/switcher/vault-runtimes/secrets-0.4.2-private"
|
|
312
|
+
(
|
|
313
|
+
set -e
|
|
314
|
+
umask 077
|
|
315
|
+
test ! -e "$SWITCHER_VAULT_PREFIX"
|
|
316
|
+
mkdir -p "$SWITCHER_VAULT_PREFIX"
|
|
317
|
+
npm install --prefix "$SWITCHER_VAULT_PREFIX" --save-exact \
|
|
318
|
+
--ignore-scripts --no-audit --no-fund --umask=077 @hasna/secrets@0.4.2
|
|
319
|
+
)
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Both the shell and npm umasks matter: a shell umask of `0002` can leave npm package directories group-writable, which the vault guard also rejects. `--ignore-scripts` prevents lifecycle scripts from running during this installation. Verify the installed package against its integrity-checked release archive before binding it, as described below. Do not run Bun installs inside this prefix. Preserve the previous runtime until the new binding passes a real provider launch.
|
|
323
|
+
|
|
324
|
+
To migrate an existing binding, record its locator with `credentials list`, then explicitly remove and recreate that same reference with the new `--vault-cli`. Preserve its vault key, URL, operator/account and authorized origins; only the executable path should change. Keep the original locator available to restore if verification fails.
|
|
301
325
|
|
|
302
326
|
```sh
|
|
303
327
|
switcher credentials bind deepseek \
|
|
304
|
-
--vault-key providers/deepseek/live/api_key
|
|
328
|
+
--vault-key providers/deepseek/live/api_key \
|
|
329
|
+
--vault-cli "$SWITCHER_VAULT_PREFIX/node_modules/@hasna/secrets/dist/index.js"
|
|
305
330
|
switcher credentials check deepseek
|
|
306
331
|
switcher launch claude --provider deepseek --model deepseek-v4-pro
|
|
307
332
|
```
|
|
308
333
|
|
|
309
|
-
`--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.
|
|
334
|
+
`--vault-cli /absolute/path/to/secrets` selects a particular installation; omitting it binds the current `secrets` on `PATH`, which may be replaced by a global tool update. 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.
|
|
310
335
|
|
|
311
336
|
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.
|
|
312
337
|
|
|
@@ -331,7 +356,7 @@ secrets exec providers/deepseek/live/api_key --as DEEPSEEK_API_KEY -- \
|
|
|
331
356
|
switcher launch claude --provider deepseek --model deepseek-v4-flash --dry-run
|
|
332
357
|
```
|
|
333
358
|
|
|
334
|
-
Authenticate that Secrets process through your existing secret manager or service environment. `--dry-run`
|
|
359
|
+
Authenticate that Secrets process through your existing secret manager or service environment. `--dry-run` refreshes public/credentialless catalogs, reuses saved authenticated catalog snapshots, creates provider/profile records as needed and returns a launch plan without starting the native harness or inference. It never retrieves a provider credential solely for planning. Every new process needs its own runtime injection. `credentials check` inspects configured bindings, not environment aliases. Keychain bindings are macOS-only; on Linux they fail with `keychain_unavailable` and recommend a vault binding or runtime environment. Native subscription/OAuth login is separate from Switcher's provider-key mode; Switcher does not import or reuse it.
|
|
335
360
|
|
|
336
361
|
## OpenCode 2 configuration
|
|
337
362
|
|