@hasna/switcher 0.1.6 → 0.1.8

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
@@ -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.
@@ -279,16 +291,45 @@ Claude Code with a non-Claude model is experimental and unsupported by Anthropic
279
291
 
280
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.
281
293
 
282
- 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:
294
+ DeepSeek officially released V4.1 Flash on 2026-09-10. Its API model ID is `deepseek-flash`, as documented in the [official release notes](https://api-docs.deepseek.com/updates/) and [API quick start](https://api-docs.deepseek.com/). New DeepSeek presets include that model with text/image input and tool support, and support Chat Completions, Anthropic Messages, and Responses (for Codex). Saved providers and profiles keep their existing model selections. Configure an existing provider explicitly to adopt the new model:
295
+
296
+ ```sh
297
+ switcher models add deepseek-messages deepseek-flash --name "DeepSeek V4.1 Flash"
298
+ switcher launch claude --provider deepseek-messages --model deepseek-flash
299
+ # Or create the documented Responses preset and select the model directly:
300
+ switcher launch codex --provider deepseek --model deepseek-flash
301
+ ```
302
+
303
+ Configure a new model on any saved provider without editing the provider's JSON:
283
304
 
284
305
  ```sh
285
- switcher models add my-provider vendor/preview --name "Preview" --expires-on 2026-09-10
306
+ switcher models add my-provider vendor/new-model --name "New model"
307
+ switcher models add my-provider vendor/detailed-model --file model.json
308
+ switcher models config my-provider
309
+ switcher models list my-provider --refresh
310
+ switcher models update my-provider vendor/new-model --name "Preview" --expires-on 2027-01-01
311
+ switcher models remove my-provider vendor/new-model
286
312
  switcher models my-provider --refresh
287
313
  ```
288
314
 
289
- `--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.
315
+ A model JSON object needs `id` and `name`; it can also carry `contextWindow`, `maxOutputTokens`, `inputModalities`, `outputModalities`, `supportedParameters`, `supportedGenerationMethods`, `available`, `description`, and `expiresOn`. The file ID must match the command. Unknown fields, raw credential fields, invalid dates and blank/control-character model IDs are rejected. `models update` replaces that model's saved metadata: omit an optional field from the replacement to clear it. `models config` reads only saved settings and makes no provider request. SDK clients expose `addModel`, `updateModel`, and `removeModel`; MCP exposes `models_add`, `models_update`, and `models_remove` with the same behavior.
316
+
317
+ For providers using discovery, configured models live in `additionalModels`; discovery still runs and its errors still block launch. Additions merge by ID and override only supplied remote metadata. Removing an addition reveals any upstream entry with the same ID. For manual catalogs, model commands edit `manualModels`. Edits use the provider's current version and fail on concurrent changes rather than overwriting them. Existing profiles are not silently repointed when a model is removed or replaced.
318
+
319
+ `--expires-on` is optional and accepts a real `YYYY-MM-DD` date, inclusive in UTC. Expired models remain visible with `expired: true` and `codingEligible: false`; new launches, policy roles, native picker catalogs and subsequent gateway requests reject them. Existing processes are not stopped. Expiry is operator metadata, not a guarantee of upstream availability.
320
+
321
+ Create an arbitrary provider with a starter model or a JSON array of model objects:
322
+
323
+ ```sh
324
+ switcher providers add deployment --url https://inference.example/v1 --protocol openai-responses \
325
+ --credential-env SWITCHER_PROVIDER_DEPLOYMENT --catalog-format none --model team/deployment
326
+ switcher providers add catalog-provider --url https://inference.example/v1 --protocol openai-chat \
327
+ --credential-env SWITCHER_PROVIDER_CUSTOM --models-file models.json
328
+ ```
329
+
330
+ `--catalog-format none` explicitly selects a manual catalog and avoids model discovery. Without it, starter models supplement discovery. Credential flags store reference names only; use the existing credential binding commands to configure their source.
290
331
 
291
- 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.
332
+ For advanced provider settings, use `providers add ID --file provider.json` with `manualModels` when discovery is unavailable. 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.
292
333
 
293
334
  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.
294
335
 
package/dist/cli/index.js CHANGED
@@ -499,7 +499,7 @@ function canonicalPolicyJSON(value) {
499
499
  }
500
500
 
501
501
  // src/domain.ts
502
- var VERSION = "0.1.6";
502
+ var VERSION = "0.1.8";
503
503
  var harnessSchema = z3.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]);
504
504
  var protocolSchema = z3.enum(["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]);
505
505
  var idSchema = z3.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
@@ -529,7 +529,7 @@ var expiresOnSchema = z3.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) =>
529
529
  return Number.isFinite(day.getTime()) && day.toISOString().slice(0, 10) === value;
530
530
  }, "Use a real calendar date in YYYY-MM-DD format.");
531
531
  var modelSchema = z3.object({
532
- id: z3.string().min(1).max(300),
532
+ id: z3.string().min(1).max(300).refine((value) => value === value.trim() && !/[\x00-\x1f\x7f-\x9f]/.test(value), "Use a nonblank model ID without surrounding whitespace or control characters."),
533
533
  name: label,
534
534
  description: z3.string().max(8000).optional(),
535
535
  available: z3.boolean().optional(),
@@ -1066,8 +1066,9 @@ var preset = (id, name, protocols, sources, alias) => parse2(providerPresetSchem
1066
1066
  var providerPresets = [
1067
1067
  preset("deepseek", "DeepSeek", [
1068
1068
  route("openai-chat", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
1069
+ route("openai-responses", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
1069
1070
  route("anthropic-messages", "https://api.deepseek.com/anthropic/v1", { catalogBaseUrl: "https://api.deepseek.com" })
1070
- ], ["https://api-docs.deepseek.com/guides/anthropic_api", "https://api-docs.deepseek.com/api/list-models"], "DEEPSEEK_API_KEY"),
1071
+ ], ["https://api-docs.deepseek.com/guides/anthropic_api", "https://api-docs.deepseek.com/api/list-models", "https://api-docs.deepseek.com/updates/", "https://api-docs.deepseek.com/guides/responses_api/"], "DEEPSEEK_API_KEY"),
1071
1072
  preset("openrouter", "OpenRouter", ["openai-chat", "openai-responses", "anthropic-messages"].map((protocol) => route(protocol, "https://openrouter.ai/api/v1", { catalogAuthStyle: "none" })), ["https://openrouter.ai/docs/api/api-reference/models/list-all-models-and-their-properties", "https://openrouter.ai/docs/guides/overview"], "OPENROUTER_API_KEY"),
1072
1073
  preset("anthropic", "Anthropic", [route("anthropic-messages", "https://api.anthropic.com/v1", { authStyle: "x-api-key" })], ["https://platform.claude.com/docs/en/api/overview", "https://platform.claude.com/docs/en/api/models/list"], "ANTHROPIC_API_KEY"),
1073
1074
  preset("gemini", "Google Gemini", [route("gemini-generate-content", "https://generativelanguage.googleapis.com/v1beta", {
@@ -1149,7 +1150,7 @@ function providerFromPreset(presetId, options = {}) {
1149
1150
  const suffix = selected.protocol === "anthropic-messages" ? "messages" : selected.protocol === "openai-responses" ? "responses" : "chat";
1150
1151
  if (presetId === "fireworks" && !options.catalogBaseUrl && !options.catalogAccountId)
1151
1152
  throw new Fault(400, "catalog_account_required", "Fireworks model discovery requires --catalog-account-id or an explicit --catalog-url.");
1152
- if (selected.catalogFormat === "none" && options.catalogFormat && !options.catalogBaseUrl)
1153
+ if (selected.catalogFormat === "none" && options.catalogFormat && options.catalogFormat !== "none" && !options.catalogBaseUrl)
1153
1154
  throw new Fault(400, "catalog_url_required", "This preset requires an explicit --catalog-url when enabling a catalog parser.");
1154
1155
  const catalogBaseUrl = options.catalogBaseUrl ?? (presetId === "fireworks" && options.catalogAccountId ? `https://api.fireworks.ai/v1/accounts/${encodeURIComponent(options.catalogAccountId)}` : options.baseUrl ? undefined : selected.catalogBaseUrl);
1155
1156
  return parse2(providerInputSchema, {
@@ -1166,9 +1167,11 @@ function providerFromPreset(presetId, options = {}) {
1166
1167
  catalogAccountId: options.catalogAccountId,
1167
1168
  modelsPath: options.modelsPath ?? selected.modelsPath,
1168
1169
  additionalModels: presetId === "deepseek" && new URL(baseUrl).origin === "https://api.deepseek.com" ? [{
1169
- id: "deepseek-v4.1-flash-expires-on-0910",
1170
- name: "DeepSeek V4.1 Flash preview",
1171
- expiresOn: "2026-09-10"
1170
+ id: "deepseek-flash",
1171
+ name: "DeepSeek V4.1 Flash",
1172
+ inputModalities: ["text", "image"],
1173
+ outputModalities: ["text"],
1174
+ supportedParameters: ["tools"]
1172
1175
  }] : []
1173
1176
  });
1174
1177
  }
@@ -1331,6 +1334,33 @@ class SwitcherClient {
1331
1334
  deleteProvider(id, version, idempotencyKey) {
1332
1335
  return this.request("DELETE", `/v1/providers/${encodeURIComponent(id)}`, undefined, { version, idempotencyKey });
1333
1336
  }
1337
+ async editModel(providerId, operation, value) {
1338
+ const model = typeof value === "string" ? undefined : parse2(modelSchema, value);
1339
+ const id = model?.id ?? parse2(modelSchema.shape.id, value);
1340
+ const provider = await this.getProvider(providerId);
1341
+ const { version, updatedAt, ...input } = provider;
1342
+ const manual = provider.manualModels.some((item) => item.id === id);
1343
+ const additional = (provider.additionalModels ?? []).some((item) => item.id === id);
1344
+ if (operation === "add" && (manual || additional))
1345
+ throw new SwitcherError(409, "model_exists", "This model is already configured. Use models update to replace its metadata.");
1346
+ if (operation !== "add" && !manual && !additional)
1347
+ throw new SwitcherError(404, "model_not_configured", "This model has no saved metadata. Use models add to configure a catalog model; remote catalog entries cannot be deleted locally.");
1348
+ const useManual = manual || !additional && (provider.manualModels.length > 0 || provider.catalogFormat === "none");
1349
+ const manualModels = provider.manualModels.filter((item) => item.id !== id);
1350
+ const additionalModels = (provider.additionalModels ?? []).filter((item) => item.id !== id);
1351
+ if (operation !== "remove")
1352
+ (useManual ? manualModels : additionalModels).push(model);
1353
+ return this.updateProvider({ ...input, manualModels, additionalModels }, version);
1354
+ }
1355
+ addModel(providerId, model) {
1356
+ return this.editModel(providerId, "add", model);
1357
+ }
1358
+ updateModel(providerId, model) {
1359
+ return this.editModel(providerId, "update", model);
1360
+ }
1361
+ removeModel(providerId, modelId) {
1362
+ return this.editModel(providerId, "remove", modelId);
1363
+ }
1334
1364
  refreshModels(id, idempotencyKey) {
1335
1365
  return this.request("POST", `/v1/providers/${encodeURIComponent(id)}/refresh`, {}, { idempotencyKey });
1336
1366
  }
@@ -2178,7 +2208,7 @@ var openapi_default = {
2178
2208
  openapi: "3.0.3",
2179
2209
  info: {
2180
2210
  title: "Switcher API",
2181
- version: "0.1.6",
2211
+ version: "0.1.8",
2182
2212
  description: "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
2183
2213
  },
2184
2214
  security: [
@@ -10571,7 +10601,7 @@ async function ensureLaunchProfile(client, provider, harness, model3, modelPolic
10571
10601
  // src/credentials.ts
10572
10602
  import { z as z6 } from "zod";
10573
10603
  import { constants as constants5 } from "fs";
10574
- import { open as open3, readdir as readdir5, unlink, link, lstat as lstat4, access as access3, stat as stat5, realpath as realpath6, readlink } from "fs/promises";
10604
+ import { open as open3, readdir as readdir5, unlink, link, lstat as lstat4, access as access3, stat as stat5, realpath as realpath6, readlink, rename as rename2 } from "fs/promises";
10575
10605
  import { join as join13, isAbsolute as isAbsolute12, dirname as dirname8, parse as pathParts, resolve as resolvePath, sep as sep2 } from "path";
10576
10606
  import { createHash as createHash10, randomUUID as randomUUID5 } from "crypto";
10577
10607
  import { execFile as execFile3, spawn as spawn2 } from "child_process";
@@ -10723,7 +10753,7 @@ function credentialReference(selector) {
10723
10753
  throw new Fault(400, "credential_reference_required", "Use the explicit SWITCHER_PROVIDER_ reference for this provider.");
10724
10754
  return parse2(reference, name);
10725
10755
  }
10726
- async function validateVaultExecutable(path) {
10756
+ async function inspectVaultExecutable(path, permitWritableFile = false) {
10727
10757
  let info, resolved;
10728
10758
  try {
10729
10759
  resolved = await realpath6(path);
@@ -10734,8 +10764,8 @@ async function validateVaultExecutable(path) {
10734
10764
  } catch {
10735
10765
  throw new Fault(422, "vault_exec_unavailable", "The configured secrets CLI must be an installed executable file. Use --vault-cli with its absolute path.");
10736
10766
  }
10737
- if (process.platform !== "win32" && (info.mode & 18 || info.uid !== 0 && info.uid !== process.getuid?.()))
10738
- throw new Fault(422, "vault_exec_permissions", "The secrets executable must be owned by this user or root and not writable by other users. Remove group/public write permission from its resolved file or choose a trusted installation.");
10767
+ if (process.platform !== "win32" && (!permitWritableFile && info.mode & 18 || info.uid !== 0 && info.uid !== process.getuid?.()))
10768
+ throw new Fault(422, "vault_exec_permissions", "The secrets executable must be owned by this user or root and not writable by other users. Choose a trusted installation, or use credentials repair-executable REFERENCE --sha256 EXPECTED with the executable digest from a verified package artifact. Launch never repairs permissions automatically.");
10739
10769
  if (process.platform !== "win32") {
10740
10770
  const seen = new Set;
10741
10771
  const inspect = async (candidate) => {
@@ -10750,7 +10780,8 @@ async function validateVaultExecutable(path) {
10750
10780
  if (seen.size > 256)
10751
10781
  throw new Fault(422, "vault_exec_permissions", "The secrets executable path has too many symlink components.");
10752
10782
  const entry = await lstat4(prefix);
10753
- if (entry.uid !== 0 && entry.uid !== process.getuid?.() || !entry.isSymbolicLink() && entry.mode & 18)
10783
+ const permittedFile = permitWritableFile && prefix === resolved && entry.isFile();
10784
+ if (entry.uid !== 0 && entry.uid !== process.getuid?.() || !entry.isSymbolicLink() && !permittedFile && entry.mode & 18)
10754
10785
  throw new Fault(422, "vault_exec_permissions", "The secrets executable and its ancestor directories must not be replaceable by other users. Choose an installation owned by this user or root without group/public write permissions.");
10755
10786
  if (entry.isSymbolicLink())
10756
10787
  await inspect(resolvePath(dirname8(prefix), await readlink(prefix)));
@@ -10767,6 +10798,88 @@ async function validateVaultExecutable(path) {
10767
10798
  }
10768
10799
  return resolved;
10769
10800
  }
10801
+ async function validateVaultExecutable(path) {
10802
+ return inspectVaultExecutable(path);
10803
+ }
10804
+ async function repairVaultExecutablePermissions(path, expectedSha256) {
10805
+ if (!/^[a-f0-9]{64}$/.test(expectedSha256))
10806
+ throw new Fault(400, "invalid_request", "--sha256 requires the SHA256 of the executable member from a verified package artifact.");
10807
+ if (!isAbsolute12(path) || path.length > 4096 || /[\x00-\x1f\x7f]/.test(path))
10808
+ throw new Fault(400, "invalid_request", "Secrets executable must be an absolute path without control characters.");
10809
+ if (process.platform === "win32")
10810
+ throw new Fault(422, "vault_exec_repair_unsafe", "Executable permission repair requires POSIX file permissions.");
10811
+ const resolved = await inspectVaultExecutable(path, true);
10812
+ const file = await open3(resolved, constants5.O_RDONLY | constants5.O_NOFOLLOW | constants5.O_NONBLOCK);
10813
+ const unsafe = () => new Fault(422, "vault_exec_repair_unsafe", "Executable ownership, type, links or contents changed; no trusted repair can be confirmed.");
10814
+ let temporary;
10815
+ try {
10816
+ const before = await file.stat();
10817
+ const limit = 256 * 1024 * 1024;
10818
+ if (!before.isFile() || before.uid !== process.getuid?.() || before.size > limit || before.mode & 3584)
10819
+ throw unsafe();
10820
+ const sameFile = (info) => info.dev === before.dev && info.ino === before.ino && info.size === before.size && info.uid === before.uid && info.nlink === before.nlink && info.mode === before.mode && info.mtimeMs === before.mtimeMs && info.ctimeMs === before.ctimeMs;
10821
+ const hash2 = async (target) => {
10822
+ const digest = createHash10("sha256");
10823
+ const buffer = Buffer.alloc(1024 * 1024);
10824
+ let position = 0;
10825
+ while (true) {
10826
+ const { bytesRead } = await file.read(buffer, 0, buffer.length, position);
10827
+ if (!bytesRead)
10828
+ break;
10829
+ position += bytesRead;
10830
+ if (position > limit)
10831
+ throw unsafe();
10832
+ const bytes = buffer.subarray(0, bytesRead);
10833
+ digest.update(bytes);
10834
+ if (target)
10835
+ await target.writeFile(bytes);
10836
+ }
10837
+ if (position !== before.size || !sameFile(await file.stat()))
10838
+ throw unsafe();
10839
+ if (digest.digest("hex") !== expectedSha256)
10840
+ throw new Fault(422, "vault_exec_digest_mismatch", "Installed executable differs from the trusted artifact digest. Reinstall the verified package; no credential was accessed.");
10841
+ };
10842
+ await hash2();
10843
+ const mode = before.mode & 511 & ~18;
10844
+ const changed = mode !== (before.mode & 511);
10845
+ if (await inspectVaultExecutable(path, true) !== resolved || !sameFile(await lstat4(resolved)))
10846
+ throw unsafe();
10847
+ if (!changed) {
10848
+ await validateVaultExecutable(path);
10849
+ return { changed, mode: mode.toString(8).padStart(4, "0"), sha256: expectedSha256 };
10850
+ }
10851
+ temporary = join13(dirname8(resolved), `.switcher-repair-${randomUUID5()}`);
10852
+ const replacement = await open3(temporary, "wx", 384);
10853
+ try {
10854
+ await hash2(replacement);
10855
+ await replacement.chmod(mode);
10856
+ await replacement.sync();
10857
+ const ready = await replacement.stat();
10858
+ if (!ready.isFile() || ready.nlink !== 1 || ready.uid !== before.uid || ready.size !== before.size)
10859
+ throw unsafe();
10860
+ if (await inspectVaultExecutable(path, true) !== resolved || !sameFile(await lstat4(resolved)))
10861
+ throw unsafe();
10862
+ await rename2(temporary, resolved);
10863
+ temporary = undefined;
10864
+ const installed = await lstat4(resolved);
10865
+ if (installed.dev !== ready.dev || installed.ino !== ready.ino || await validateVaultExecutable(path) !== resolved)
10866
+ throw unsafe();
10867
+ const directory = await open3(dirname8(resolved), constants5.O_RDONLY | constants5.O_DIRECTORY | constants5.O_NOFOLLOW);
10868
+ try {
10869
+ await directory.sync();
10870
+ } finally {
10871
+ await directory.close();
10872
+ }
10873
+ } finally {
10874
+ await replacement.close();
10875
+ }
10876
+ return { changed, mode: mode.toString(8).padStart(4, "0"), sha256: expectedSha256 };
10877
+ } finally {
10878
+ await file.close();
10879
+ if (temporary)
10880
+ await unlink(temporary);
10881
+ }
10882
+ }
10770
10883
  function bindingTarget(selector, override, allowedOrigins) {
10771
10884
  if (selector.startsWith("SWITCHER_PROVIDER_")) {
10772
10885
  if (override)
@@ -11015,12 +11128,16 @@ var HELP = `switcher \u2014 launch a coding harness with a provider and its mode
11015
11128
  switcher providers presets [ID]
11016
11129
  switcher providers list [--search TEXT] [--limit N] [--offset N]
11017
11130
  switcher providers add ID --url URL --protocol PROTOCOL [--credential-env NAME]
11131
+ [--model MODEL | --models-file FILE] [--catalog-format none]
11018
11132
  switcher providers add ID --preset PRESET [--protocol PROTOCOL] [--catalog-account-id ID]
11019
11133
  switcher providers get|refresh ID
11020
11134
  switcher providers update ID --file provider.json --version N
11021
11135
  switcher providers delete ID --version N
11022
11136
  switcher models PROVIDER [--refresh] [--search TEXT] [--limit N]
11023
- switcher models add PROVIDER MODEL [--name NAME] [--expires-on YYYY-MM-DD]
11137
+ switcher models list PROVIDER [--refresh] [--search TEXT] [--limit N]
11138
+ switcher models add|update PROVIDER MODEL [--file model.json | --name NAME --expires-on YYYY-MM-DD]
11139
+ switcher models remove PROVIDER MODEL
11140
+ switcher models config PROVIDER
11024
11141
  switcher profiles list|get [ID]
11025
11142
  switcher profiles add ID --provider ID --harness HARNESS --model MODEL [--model-policy-file FILE] [--role-model ROLE=MODEL]
11026
11143
  switcher profiles update ID --file profile.json --version N
@@ -11034,6 +11151,8 @@ var HELP = `switcher \u2014 launch a coding harness with a provider and its mode
11034
11151
  [--vault-cli PATH] [--vault-account ACCOUNT | --vault-operator env]
11035
11152
  switcher credentials bind PRESET --keychain-service SERVICE --keychain-account ACCOUNT
11036
11153
  switcher credentials list|check|remove [PRESET_OR_REFERENCE]
11154
+ switcher credentials repair-executable PRESET_OR_REFERENCE --sha256 EXPECTED
11155
+ switcher credentials repair-executable --vault-cli PATH --sha256 EXPECTED
11037
11156
  switcher doctor
11038
11157
 
11039
11158
  HARNESS: claude, codex, grok, opencode, opencode2, pi, omp, dsh, cline, hermes, prime-agent, gemini, aider, kilo
@@ -11044,11 +11163,17 @@ Remote API URL/key resolve through @hasna/contracts: overrides, Keychain,
11044
11163
  ~/.hasna/switcher/config/credentials, then environment. A key alone uses the gateway.
11045
11164
  A configured remote API never falls back to local data.
11046
11165
  Provider credential references must start SWITCHER_PROVIDER_.
11166
+ --models-file accepts a JSON array of model metadata; --model adds one starter.
11167
+ Use --catalog-format none for a manual catalog; otherwise discovery stays active.
11168
+ models update replaces saved metadata; omit expiry in its JSON to clear it.
11169
+ models remove removes saved metadata, not entries in an upstream catalog.
11047
11170
  Credential bindings contain references only. Custom destinations require --origin URL.
11048
11171
  Vault bindings use the installed secrets CLI and its canonical Contracts URL/key
11049
11172
  by default. --vault-account pins a Keychain account; --vault-operator env requires
11050
11173
  per-process HASNA_SECRETS_API_KEY. Explicit operators also require --vault-url.
11051
11174
  --file accepts a JSON object including id; raw credentials are never accepted.
11175
+ Executable repair requires the digest of its member in a verified package artifact.
11176
+ It replaces writable installed bytes with an identical protected copy; it does not contact the vault.
11052
11177
  Fireworks discovery requires --catalog-account-id (or an explicit --catalog-url).
11053
11178
  --json outputs machine-readable records (also the default for data commands).
11054
11179
  switcher --version | --help
@@ -11093,10 +11218,12 @@ async function main(args = process.argv.slice(2)) {
11093
11218
  version: { type: "string" },
11094
11219
  json: { type: "boolean" },
11095
11220
  url: { type: "string" },
11221
+ sha256: { type: "string" },
11096
11222
  protocol: { type: "string" },
11097
11223
  preset: { type: "string" },
11098
11224
  name: { type: "string" },
11099
11225
  file: { type: "string" },
11226
+ "models-file": { type: "string" },
11100
11227
  "credential-env": { type: "string" },
11101
11228
  "auth-style": { type: "string" },
11102
11229
  "catalog-url": { type: "string" },
@@ -11141,15 +11268,56 @@ async function main(args = process.argv.slice(2)) {
11141
11268
  throw new Error("Unknown command. Run switcher --help.");
11142
11269
  const providerFlags = ["url", "protocol", "preset", "credential-env", "auth-style", "catalog-url", "catalog-format", "catalog-auth-style", "catalog-credential-env", "catalog-account-id", "models-path"];
11143
11270
  const provided = (names) => names.some((name) => values2[name] !== undefined);
11144
- const addingModel = command === "models" && action2 === "add";
11145
- if (values2["expires-on"] !== undefined && !addingModel)
11146
- throw new Fault(400, "conflicting_options", "--expires-on belongs to models add.");
11147
- if (addingModel && (positionals.length !== 4 || nativeArgs.length || Object.keys(values2).some((name) => !["name", "expires-on", "json"].includes(name))))
11148
- throw new Fault(400, "invalid_request", "Use models add PROVIDER MODEL with optional --name and --expires-on.");
11149
- const modelAddition = addingModel ? parse2(modelSchema, { id: positionals[3], name: values2.name ?? positionals[3], expiresOn: values2["expires-on"] }) : undefined;
11271
+ const editingModel = command === "models" && positionals.length > 2 && ["add", "update", "remove"].includes(action2);
11272
+ const configuringModels = command === "models" && positionals.length > 2 && action2 === "config";
11273
+ const listingModels = command === "models" && positionals.length > 2 && action2 === "list";
11274
+ if (listingModels && (positionals.length !== 3 || nativeArgs.length || Object.keys(values2).some((name) => !["refresh", "search", "limit", "offset", "json"].includes(name))))
11275
+ throw new Fault(400, "invalid_request", "Use models list PROVIDER with optional --refresh, --search, --limit and --offset.");
11276
+ if (values2["expires-on"] !== undefined && (!editingModel || action2 === "remove"))
11277
+ throw new Fault(400, "conflicting_options", "--expires-on belongs to models add/update.");
11278
+ if (editingModel && (positionals.length !== 4 || nativeArgs.length || Object.keys(values2).some((name) => !(action2 === "remove" ? ["json"] : ["name", "expires-on", "file", "json"]).includes(name))))
11279
+ throw new Fault(400, "invalid_request", "Use models add/update PROVIDER MODEL with --file or --name/--expires-on; models remove accepts only PROVIDER MODEL.");
11280
+ if (configuringModels && (positionals.length !== 3 || nativeArgs.length || Object.keys(values2).some((name) => name !== "json")))
11281
+ throw new Fault(400, "invalid_request", "Use models config PROVIDER without other settings.");
11282
+ if (editingModel && values2.file !== undefined && (values2.name !== undefined || values2["expires-on"] !== undefined))
11283
+ throw new Fault(400, "conflicting_options", "Use --file by itself for model metadata.");
11284
+ const modelInput = editingModel && action2 !== "remove" ? parse2(modelSchema, values2.file !== undefined ? await readInput(values2.file) : { id: positionals[3], name: values2.name ?? positionals[3], expiresOn: values2["expires-on"] }) : undefined;
11285
+ if (modelInput && modelInput.id !== positionals[3])
11286
+ throw new Fault(400, "id_mismatch", "Model file id must match the command model ID.");
11287
+ if (editingModel && action2 === "remove")
11288
+ parse2(modelSchema.shape.id, positionals[3]);
11289
+ const seedingProvider = command === "providers" && action2 === "add";
11290
+ if (values2["models-file"] !== undefined && !seedingProvider)
11291
+ throw new Fault(400, "conflicting_options", "--models-file belongs to providers add.");
11292
+ if (command === "providers" && values2.model !== undefined && !seedingProvider)
11293
+ throw new Fault(400, "conflicting_options", "Provider --model belongs to providers add. Use models add/update/remove for saved providers.");
11294
+ if (seedingProvider && values2["models-file"] !== undefined && values2.model !== undefined)
11295
+ throw new Fault(400, "conflicting_options", "Use --model or --models-file, not both.");
11296
+ let starterModels;
11297
+ if (seedingProvider && (values2.model !== undefined || values2["models-file"] !== undefined)) {
11298
+ starterModels = parse2(modelSchema.array().min(1).max(1e4), values2["models-file"] !== undefined ? await readInput(values2["models-file"]) : [{ id: values2.model, name: values2.model }]);
11299
+ if (new Set(starterModels.map((model3) => model3.id)).size !== starterModels.length)
11300
+ throw new Fault(400, "duplicate_model", "Model IDs must be unique.");
11301
+ }
11150
11302
  const credentialFlags = ["vault-key", "vault-url", "vault-cli", "vault-account", "vault-operator", "keychain-service", "keychain-account", "origin"];
11151
11303
  const credentials = new CredentialResolver;
11304
+ if (values2.sha256 !== undefined && !(command === "credentials" && action2 === "repair-executable"))
11305
+ throw new Fault(400, "conflicting_options", "--sha256 belongs to credentials repair-executable.");
11152
11306
  if (command === "credentials") {
11307
+ if (action2 === "repair-executable") {
11308
+ const explicitPath = values2["vault-cli"];
11309
+ if (Boolean(id2) === (explicitPath !== undefined) || positionals.length !== (id2 ? 3 : 2) || nativeArgs.length || Object.keys(values2).some((name) => !["sha256", "json", "vault-cli"].includes(name)) || !/^[a-f0-9]{64}$/.test(values2.sha256 ?? ""))
11310
+ throw new Fault(400, "invalid_request", "Use credentials repair-executable PRESET_OR_REFERENCE (or --vault-cli PATH) --sha256 EXPECTED, with the executable digest from a verified package artifact.");
11311
+ let executable = explicitPath;
11312
+ if (id2) {
11313
+ const binding = await credentials.bindings.get(credentialReference(id2));
11314
+ if (!binding || binding.source.kind !== "vault")
11315
+ throw new Fault(422, "vault_binding_required", "Choose an existing vault credential binding to repair its configured executable.");
11316
+ executable = binding.source.executable;
11317
+ }
11318
+ output(await repairVaultExecutablePermissions(executable, values2.sha256));
11319
+ return;
11320
+ }
11153
11321
  const bindingFlags = [...credentialFlags, "credential-env"];
11154
11322
  if (nativeArgs.length || positionals.length > 3 || Object.keys(values2).some((name) => name !== "json" && !bindingFlags.includes(name)))
11155
11323
  throw new Fault(400, "conflicting_options", "Credentials accepts only binding options; no API, profile or harness settings.");
@@ -11199,7 +11367,7 @@ async function main(args = process.argv.slice(2)) {
11199
11367
  if (command === "launch" && backend === "direct" && values2["ori-executable"] !== undefined)
11200
11368
  throw new Fault(400, "conflicting_options", "--ori-executable requires --backend ori.");
11201
11369
  const mutation = (command === "providers" || command === "profiles") && ["add", "update"].includes(action2);
11202
- if (values2.file && (!mutation || provided([...providerFlags, "name", "provider", "harness", "model", "model-policy-file", "role-model"])))
11370
+ if (values2.file && !editingModel && (!mutation || provided([...providerFlags, "name", "provider", "harness", "model", "models-file", "model-policy-file", "role-model"])))
11203
11371
  throw new Fault(400, "conflicting_options", "Use --file by itself for provider/profile settings; inline settings cannot override an input file.");
11204
11372
  if (command === "launch" && !values2.provider && provided([...providerFlags, "name", "harness", "model", "search", "model-policy-file", "role-model"]))
11205
11373
  throw new Fault(400, "conflicting_options", "Use --provider PROVIDER for direct launch settings, or update the saved profile explicitly.");
@@ -11295,17 +11463,18 @@ async function main(args = process.argv.slice(2)) {
11295
11463
  process.exitCode = await launch(client, profileId, { backend, oriExecutable: values2["ori-executable"], cwd: values2.cwd, executable: values2.executable, stateDir: values2["state-dir"], args: nativeArgs, timeoutMs, refresh: false, resolveCredential: (provider) => credentials.resolve(provider) });
11296
11464
  return;
11297
11465
  }
11298
- if (modelAddition) {
11466
+ if (editingModel) {
11467
+ const saved = action2 === "add" ? await client.addModel(id2, modelInput) : action2 === "update" ? await client.updateModel(id2, modelInput) : await client.removeModel(id2, positionals[3]);
11468
+ output({ providerId: saved.id, version: saved.version, ...modelInput ? { model: modelInput, expired: modelExpired(modelInput) } : { removed: positionals[3] } });
11469
+ return;
11470
+ }
11471
+ if (configuringModels) {
11299
11472
  const provider = await client.getProvider(id2);
11300
- const { version, updatedAt, ...input } = provider;
11301
- if ((provider.additionalModels ?? []).some((model3) => model3.id === modelAddition.id))
11302
- throw new Fault(409, "model_exists", "This additional model already exists. Use providers update --file to edit its metadata.");
11303
- await client.updateProvider({ ...input, additionalModels: [...provider.additionalModels ?? [], modelAddition] }, version);
11304
- output({ providerId: provider.id, model: modelAddition, expired: modelExpired(modelAddition) });
11473
+ output({ providerId: provider.id, version: provider.version, manualModels: provider.manualModels, additionalModels: provider.additionalModels ?? [] });
11305
11474
  return;
11306
11475
  }
11307
11476
  if (command === "models" && action2) {
11308
- const provider = await resolveLaunchProvider(client, action2, presetOptions());
11477
+ const provider = await resolveLaunchProvider(client, listingModels ? id2 : action2, presetOptions());
11309
11478
  if (values2.refresh)
11310
11479
  await client.refreshModels(provider.id);
11311
11480
  try {
@@ -11346,7 +11515,7 @@ async function main(args = process.argv.slice(2)) {
11346
11515
  return;
11347
11516
  }
11348
11517
  if (["add", "update"].includes(action2) && id2) {
11349
- const input = parse2(providerInputSchema, values2.file ? await readInput(values2.file) : values2.preset ? { ...providerFromPreset(values2.preset, { ...presetOptions(), id: id2 }), ...values2.name ? { name: values2.name } : {} } : {
11518
+ let input = parse2(providerInputSchema, values2.file ? await readInput(values2.file) : values2.preset ? { ...providerFromPreset(values2.preset, { ...presetOptions(), id: id2 }), ...values2.name ? { name: values2.name } : {} } : {
11350
11519
  id: id2,
11351
11520
  name: values2.name ?? id2,
11352
11521
  baseUrl: values2.url,
@@ -11360,6 +11529,13 @@ async function main(args = process.argv.slice(2)) {
11360
11529
  catalogAccountId: values2["catalog-account-id"],
11361
11530
  modelsPath: values2["models-path"]
11362
11531
  });
11532
+ if (starterModels) {
11533
+ const field = input.catalogFormat === "none" ? "manualModels" : "additionalModels";
11534
+ const models = new Map((input[field] ?? []).map((model3) => [model3.id, model3]));
11535
+ for (const model3 of starterModels)
11536
+ models.set(model3.id, model3);
11537
+ input = parse2(providerInputSchema, { ...input, [field]: [...models.values()] });
11538
+ }
11363
11539
  if (input.id !== id2)
11364
11540
  throw new Error("File id must match the command id.");
11365
11541
  output(action2 === "add" ? await client.createProvider(input) : await client.updateProvider(input, currentVersion()));
@@ -211,6 +211,18 @@ export declare class CredentialBindings {
211
211
  }
212
212
  export declare function credentialReference(selector: string): string;
213
213
  export declare function validateVaultExecutable(path: string): Promise<string>;
214
+ /** Explicit install finalization. The caller supplies a digest from a verified
215
+ * artifact, never a digest computed from the currently installed executable.
216
+ * No credential is resolved and the executable is never started. */
217
+ export declare function repairVaultExecutablePermissions(path: string, expectedSha256: string): Promise<{
218
+ changed: false;
219
+ mode: string;
220
+ sha256: string;
221
+ } | {
222
+ changed: true;
223
+ mode: string;
224
+ sha256: string;
225
+ }>;
214
226
  export declare function bindingTarget(selector: string, override?: string, allowedOrigins?: string[]): {
215
227
  credentialEnv: string;
216
228
  origins: string[];
package/dist/domain.d.ts CHANGED
@@ -3,14 +3,14 @@ import { type RoutingEvent } from "./model-policy-schema";
3
3
  export { modelPolicySchema, routingEventSchema, routingEventsSchema } from "./model-policy-schema";
4
4
  export type { ModelPolicy, RoutingEvent } from "./model-policy-schema";
5
5
  export type { AuthStyle } from "./auth";
6
- export declare const VERSION = "0.1.6";
6
+ export declare const VERSION = "0.1.8";
7
7
  export declare const harnessSchema: z.ZodEnum<["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]>;
8
8
  export declare const protocolSchema: z.ZodEnum<["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]>;
9
9
  export declare const idSchema: z.ZodString;
10
10
  export declare function endpoint(value: string): string;
11
11
  export declare const expiresOnSchema: z.ZodEffects<z.ZodString, string, string>;
12
12
  export declare const modelSchema: z.ZodObject<{
13
- id: z.ZodString;
13
+ id: z.ZodEffects<z.ZodString, string, string>;
14
14
  name: z.ZodString;
15
15
  description: z.ZodOptional<z.ZodString>;
16
16
  available: z.ZodOptional<z.ZodBoolean>;
@@ -60,7 +60,7 @@ export declare const providerInputSchema: z.ZodEffects<z.ZodObject<{
60
60
  catalogAccountId: z.ZodOptional<z.ZodString>;
61
61
  modelsPath: z.ZodDefault<z.ZodString>;
62
62
  manualModels: z.ZodDefault<z.ZodArray<z.ZodObject<{
63
- id: z.ZodString;
63
+ id: z.ZodEffects<z.ZodString, string, string>;
64
64
  name: z.ZodString;
65
65
  description: z.ZodOptional<z.ZodString>;
66
66
  available: z.ZodOptional<z.ZodBoolean>;
@@ -97,7 +97,7 @@ export declare const providerInputSchema: z.ZodEffects<z.ZodObject<{
97
97
  supportedGenerationMethods?: string[] | undefined;
98
98
  }>, "many">>;
99
99
  additionalModels: z.ZodOptional<z.ZodArray<z.ZodObject<{
100
- id: z.ZodString;
100
+ id: z.ZodEffects<z.ZodString, string, string>;
101
101
  name: z.ZodString;
102
102
  description: z.ZodOptional<z.ZodString>;
103
103
  available: z.ZodOptional<z.ZodBoolean>;
package/dist/index.js CHANGED
@@ -75,7 +75,7 @@ var expiresOnSchema = z2.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) =>
75
75
  return Number.isFinite(day.getTime()) && day.toISOString().slice(0, 10) === value;
76
76
  }, "Use a real calendar date in YYYY-MM-DD format.");
77
77
  var modelSchema = z2.object({
78
- id: z2.string().min(1).max(300),
78
+ id: z2.string().min(1).max(300).refine((value) => value === value.trim() && !/[\x00-\x1f\x7f-\x9f]/.test(value), "Use a nonblank model ID without surrounding whitespace or control characters."),
79
79
  name: label,
80
80
  description: z2.string().max(8000).optional(),
81
81
  available: z2.boolean().optional(),
@@ -230,8 +230,9 @@ var preset = (id, name, protocols, sources, alias) => parse(providerPresetSchema
230
230
  var providerPresets = [
231
231
  preset("deepseek", "DeepSeek", [
232
232
  route("openai-chat", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
233
+ route("openai-responses", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
233
234
  route("anthropic-messages", "https://api.deepseek.com/anthropic/v1", { catalogBaseUrl: "https://api.deepseek.com" })
234
- ], ["https://api-docs.deepseek.com/guides/anthropic_api", "https://api-docs.deepseek.com/api/list-models"], "DEEPSEEK_API_KEY"),
235
+ ], ["https://api-docs.deepseek.com/guides/anthropic_api", "https://api-docs.deepseek.com/api/list-models", "https://api-docs.deepseek.com/updates/", "https://api-docs.deepseek.com/guides/responses_api/"], "DEEPSEEK_API_KEY"),
235
236
  preset("openrouter", "OpenRouter", ["openai-chat", "openai-responses", "anthropic-messages"].map((protocol) => route(protocol, "https://openrouter.ai/api/v1", { catalogAuthStyle: "none" })), ["https://openrouter.ai/docs/api/api-reference/models/list-all-models-and-their-properties", "https://openrouter.ai/docs/guides/overview"], "OPENROUTER_API_KEY"),
236
237
  preset("anthropic", "Anthropic", [route("anthropic-messages", "https://api.anthropic.com/v1", { authStyle: "x-api-key" })], ["https://platform.claude.com/docs/en/api/overview", "https://platform.claude.com/docs/en/api/models/list"], "ANTHROPIC_API_KEY"),
237
238
  preset("gemini", "Google Gemini", [route("gemini-generate-content", "https://generativelanguage.googleapis.com/v1beta", {
@@ -313,7 +314,7 @@ function providerFromPreset(presetId, options = {}) {
313
314
  const suffix = selected.protocol === "anthropic-messages" ? "messages" : selected.protocol === "openai-responses" ? "responses" : "chat";
314
315
  if (presetId === "fireworks" && !options.catalogBaseUrl && !options.catalogAccountId)
315
316
  throw new Fault(400, "catalog_account_required", "Fireworks model discovery requires --catalog-account-id or an explicit --catalog-url.");
316
- if (selected.catalogFormat === "none" && options.catalogFormat && !options.catalogBaseUrl)
317
+ if (selected.catalogFormat === "none" && options.catalogFormat && options.catalogFormat !== "none" && !options.catalogBaseUrl)
317
318
  throw new Fault(400, "catalog_url_required", "This preset requires an explicit --catalog-url when enabling a catalog parser.");
318
319
  const catalogBaseUrl = options.catalogBaseUrl ?? (presetId === "fireworks" && options.catalogAccountId ? `https://api.fireworks.ai/v1/accounts/${encodeURIComponent(options.catalogAccountId)}` : options.baseUrl ? undefined : selected.catalogBaseUrl);
319
320
  return parse(providerInputSchema, {
@@ -330,9 +331,11 @@ function providerFromPreset(presetId, options = {}) {
330
331
  catalogAccountId: options.catalogAccountId,
331
332
  modelsPath: options.modelsPath ?? selected.modelsPath,
332
333
  additionalModels: presetId === "deepseek" && new URL(baseUrl).origin === "https://api.deepseek.com" ? [{
333
- id: "deepseek-v4.1-flash-expires-on-0910",
334
- name: "DeepSeek V4.1 Flash preview",
335
- expiresOn: "2026-09-10"
334
+ id: "deepseek-flash",
335
+ name: "DeepSeek V4.1 Flash",
336
+ inputModalities: ["text", "image"],
337
+ outputModalities: ["text"],
338
+ supportedParameters: ["tools"]
336
339
  }] : []
337
340
  });
338
341
  }
@@ -483,6 +486,33 @@ class SwitcherClient {
483
486
  deleteProvider(id, version, idempotencyKey) {
484
487
  return this.request("DELETE", `/v1/providers/${encodeURIComponent(id)}`, undefined, { version, idempotencyKey });
485
488
  }
489
+ async editModel(providerId, operation, value) {
490
+ const model = typeof value === "string" ? undefined : parse(modelSchema, value);
491
+ const id = model?.id ?? parse(modelSchema.shape.id, value);
492
+ const provider = await this.getProvider(providerId);
493
+ const { version, updatedAt, ...input } = provider;
494
+ const manual = provider.manualModels.some((item) => item.id === id);
495
+ const additional = (provider.additionalModels ?? []).some((item) => item.id === id);
496
+ if (operation === "add" && (manual || additional))
497
+ throw new SwitcherError(409, "model_exists", "This model is already configured. Use models update to replace its metadata.");
498
+ if (operation !== "add" && !manual && !additional)
499
+ throw new SwitcherError(404, "model_not_configured", "This model has no saved metadata. Use models add to configure a catalog model; remote catalog entries cannot be deleted locally.");
500
+ const useManual = manual || !additional && (provider.manualModels.length > 0 || provider.catalogFormat === "none");
501
+ const manualModels = provider.manualModels.filter((item) => item.id !== id);
502
+ const additionalModels = (provider.additionalModels ?? []).filter((item) => item.id !== id);
503
+ if (operation !== "remove")
504
+ (useManual ? manualModels : additionalModels).push(model);
505
+ return this.updateProvider({ ...input, manualModels, additionalModels }, version);
506
+ }
507
+ addModel(providerId, model) {
508
+ return this.editModel(providerId, "add", model);
509
+ }
510
+ updateModel(providerId, model) {
511
+ return this.editModel(providerId, "update", model);
512
+ }
513
+ removeModel(providerId, modelId) {
514
+ return this.editModel(providerId, "remove", modelId);
515
+ }
486
516
  refreshModels(id, idempotencyKey) {
487
517
  return this.request("POST", `/v1/providers/${encodeURIComponent(id)}/refresh`, {}, { idempotencyKey });
488
518
  }
package/dist/mcp/index.js CHANGED
@@ -55,7 +55,7 @@ var routingEventSchema = z.object({
55
55
  var routingEventsSchema = z.array(routingEventSchema).max(1000);
56
56
 
57
57
  // src/domain.ts
58
- var VERSION = "0.1.6";
58
+ var VERSION = "0.1.8";
59
59
  var harnessSchema = z2.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]);
60
60
  var protocolSchema = z2.enum(["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]);
61
61
  var idSchema = z2.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
@@ -85,7 +85,7 @@ var expiresOnSchema = z2.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) =>
85
85
  return Number.isFinite(day.getTime()) && day.toISOString().slice(0, 10) === value;
86
86
  }, "Use a real calendar date in YYYY-MM-DD format.");
87
87
  var modelSchema = z2.object({
88
- id: z2.string().min(1).max(300),
88
+ id: z2.string().min(1).max(300).refine((value) => value === value.trim() && !/[\x00-\x1f\x7f-\x9f]/.test(value), "Use a nonblank model ID without surrounding whitespace or control characters."),
89
89
  name: label,
90
90
  description: z2.string().max(8000).optional(),
91
91
  available: z2.boolean().optional(),
@@ -229,8 +229,9 @@ var preset = (id, name, protocols, sources, alias) => parse(providerPresetSchema
229
229
  var providerPresets = [
230
230
  preset("deepseek", "DeepSeek", [
231
231
  route("openai-chat", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
232
+ route("openai-responses", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
232
233
  route("anthropic-messages", "https://api.deepseek.com/anthropic/v1", { catalogBaseUrl: "https://api.deepseek.com" })
233
- ], ["https://api-docs.deepseek.com/guides/anthropic_api", "https://api-docs.deepseek.com/api/list-models"], "DEEPSEEK_API_KEY"),
234
+ ], ["https://api-docs.deepseek.com/guides/anthropic_api", "https://api-docs.deepseek.com/api/list-models", "https://api-docs.deepseek.com/updates/", "https://api-docs.deepseek.com/guides/responses_api/"], "DEEPSEEK_API_KEY"),
234
235
  preset("openrouter", "OpenRouter", ["openai-chat", "openai-responses", "anthropic-messages"].map((protocol) => route(protocol, "https://openrouter.ai/api/v1", { catalogAuthStyle: "none" })), ["https://openrouter.ai/docs/api/api-reference/models/list-all-models-and-their-properties", "https://openrouter.ai/docs/guides/overview"], "OPENROUTER_API_KEY"),
235
236
  preset("anthropic", "Anthropic", [route("anthropic-messages", "https://api.anthropic.com/v1", { authStyle: "x-api-key" })], ["https://platform.claude.com/docs/en/api/overview", "https://platform.claude.com/docs/en/api/models/list"], "ANTHROPIC_API_KEY"),
236
237
  preset("gemini", "Google Gemini", [route("gemini-generate-content", "https://generativelanguage.googleapis.com/v1beta", {
@@ -438,6 +439,33 @@ class SwitcherClient {
438
439
  deleteProvider(id, version, idempotencyKey) {
439
440
  return this.request("DELETE", `/v1/providers/${encodeURIComponent(id)}`, undefined, { version, idempotencyKey });
440
441
  }
442
+ async editModel(providerId, operation, value) {
443
+ const model = typeof value === "string" ? undefined : parse(modelSchema, value);
444
+ const id = model?.id ?? parse(modelSchema.shape.id, value);
445
+ const provider = await this.getProvider(providerId);
446
+ const { version, updatedAt, ...input } = provider;
447
+ const manual = provider.manualModels.some((item) => item.id === id);
448
+ const additional = (provider.additionalModels ?? []).some((item) => item.id === id);
449
+ if (operation === "add" && (manual || additional))
450
+ throw new SwitcherError(409, "model_exists", "This model is already configured. Use models update to replace its metadata.");
451
+ if (operation !== "add" && !manual && !additional)
452
+ throw new SwitcherError(404, "model_not_configured", "This model has no saved metadata. Use models add to configure a catalog model; remote catalog entries cannot be deleted locally.");
453
+ const useManual = manual || !additional && (provider.manualModels.length > 0 || provider.catalogFormat === "none");
454
+ const manualModels = provider.manualModels.filter((item) => item.id !== id);
455
+ const additionalModels = (provider.additionalModels ?? []).filter((item) => item.id !== id);
456
+ if (operation !== "remove")
457
+ (useManual ? manualModels : additionalModels).push(model);
458
+ return this.updateProvider({ ...input, manualModels, additionalModels }, version);
459
+ }
460
+ addModel(providerId, model) {
461
+ return this.editModel(providerId, "add", model);
462
+ }
463
+ updateModel(providerId, model) {
464
+ return this.editModel(providerId, "update", model);
465
+ }
466
+ removeModel(providerId, modelId) {
467
+ return this.editModel(providerId, "remove", modelId);
468
+ }
441
469
  refreshModels(id, idempotencyKey) {
442
470
  return this.request("POST", `/v1/providers/${encodeURIComponent(id)}/refresh`, {}, { idempotencyKey });
443
471
  }
@@ -500,6 +528,9 @@ tool("models_list", "List catalog with capability information.", { id: z3.string
500
528
  const { id, ...rest } = p;
501
529
  return clientFromEnv().listModels(id, rest);
502
530
  });
531
+ tool("models_add", "Add saved model metadata; discovery stays active unless the provider uses a manual catalog.", { providerId: z3.string(), model: modelSchema }, (p) => clientFromEnv().addModel(p.providerId, p.model));
532
+ tool("models_update", "Replace all saved metadata for a configured model.", { providerId: z3.string(), model: modelSchema }, (p) => clientFromEnv().updateModel(p.providerId, p.model));
533
+ tool("models_remove", "Remove saved model metadata; upstream catalog entries remain.", { providerId: z3.string(), modelId: modelSchema.shape.id }, (p) => clientFromEnv().removeModel(p.providerId, p.modelId));
503
534
  tool("models_refresh", "Discover provider models.", { id: z3.string() }, (p) => clientFromEnv().refreshModels(p.id));
504
535
  tool("profiles_list", "List harness launch profiles.", page, (p) => clientFromEnv().listProfiles(p));
505
536
  tool("profiles_get", "Get a harness profile.", { id: z3.string() }, (p) => clientFromEnv().getProfile(p.id));
package/dist/sdk.d.ts CHANGED
@@ -251,6 +251,137 @@ export declare class SwitcherClient {
251
251
  deleteProvider(id: string, version: number, idempotencyKey?: string): Promise<{
252
252
  deleted: string;
253
253
  }>;
254
+ /** Configure model metadata through the existing versioned provider API.
255
+ * Discovery stays active unless the provider explicitly uses a manual catalog.
256
+ * A concurrent edit returns 409; it is never silently overwritten or retried. */
257
+ private editModel;
258
+ addModel(providerId: string, model: Model): Promise<{
259
+ id: string;
260
+ name: string;
261
+ baseUrl: string;
262
+ protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
263
+ credentialEnv?: string;
264
+ authStyle: "bearer" | "x-api-key" | "api-key";
265
+ catalogBaseUrl?: string;
266
+ catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
267
+ catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none";
268
+ catalogCredentialEnv?: string;
269
+ catalogAccountId?: string;
270
+ modelsPath: string;
271
+ manualModels: {
272
+ id: string;
273
+ name: string;
274
+ description?: string;
275
+ available?: boolean;
276
+ expiresOn?: string;
277
+ contextWindow?: number;
278
+ maxOutputTokens?: number;
279
+ inputModalities?: string[];
280
+ outputModalities?: string[];
281
+ supportedParameters?: string[];
282
+ supportedGenerationMethods?: string[];
283
+ }[];
284
+ additionalModels?: {
285
+ id: string;
286
+ name: string;
287
+ description?: string;
288
+ available?: boolean;
289
+ expiresOn?: string;
290
+ contextWindow?: number;
291
+ maxOutputTokens?: number;
292
+ inputModalities?: string[];
293
+ outputModalities?: string[];
294
+ supportedParameters?: string[];
295
+ supportedGenerationMethods?: string[];
296
+ }[];
297
+ version: number;
298
+ updatedAt: string;
299
+ }>;
300
+ /** Replace all saved metadata for one model, including clearing omitted fields. */
301
+ updateModel(providerId: string, model: Model): Promise<{
302
+ id: string;
303
+ name: string;
304
+ baseUrl: string;
305
+ protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
306
+ credentialEnv?: string;
307
+ authStyle: "bearer" | "x-api-key" | "api-key";
308
+ catalogBaseUrl?: string;
309
+ catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
310
+ catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none";
311
+ catalogCredentialEnv?: string;
312
+ catalogAccountId?: string;
313
+ modelsPath: string;
314
+ manualModels: {
315
+ id: string;
316
+ name: string;
317
+ description?: string;
318
+ available?: boolean;
319
+ expiresOn?: string;
320
+ contextWindow?: number;
321
+ maxOutputTokens?: number;
322
+ inputModalities?: string[];
323
+ outputModalities?: string[];
324
+ supportedParameters?: string[];
325
+ supportedGenerationMethods?: string[];
326
+ }[];
327
+ additionalModels?: {
328
+ id: string;
329
+ name: string;
330
+ description?: string;
331
+ available?: boolean;
332
+ expiresOn?: string;
333
+ contextWindow?: number;
334
+ maxOutputTokens?: number;
335
+ inputModalities?: string[];
336
+ outputModalities?: string[];
337
+ supportedParameters?: string[];
338
+ supportedGenerationMethods?: string[];
339
+ }[];
340
+ version: number;
341
+ updatedAt: string;
342
+ }>;
343
+ removeModel(providerId: string, modelId: string): Promise<{
344
+ id: string;
345
+ name: string;
346
+ baseUrl: string;
347
+ protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
348
+ credentialEnv?: string;
349
+ authStyle: "bearer" | "x-api-key" | "api-key";
350
+ catalogBaseUrl?: string;
351
+ catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
352
+ catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none";
353
+ catalogCredentialEnv?: string;
354
+ catalogAccountId?: string;
355
+ modelsPath: string;
356
+ manualModels: {
357
+ id: string;
358
+ name: string;
359
+ description?: string;
360
+ available?: boolean;
361
+ expiresOn?: string;
362
+ contextWindow?: number;
363
+ maxOutputTokens?: number;
364
+ inputModalities?: string[];
365
+ outputModalities?: string[];
366
+ supportedParameters?: string[];
367
+ supportedGenerationMethods?: string[];
368
+ }[];
369
+ additionalModels?: {
370
+ id: string;
371
+ name: string;
372
+ description?: string;
373
+ available?: boolean;
374
+ expiresOn?: string;
375
+ contextWindow?: number;
376
+ maxOutputTokens?: number;
377
+ inputModalities?: string[];
378
+ outputModalities?: string[];
379
+ supportedParameters?: string[];
380
+ supportedGenerationMethods?: string[];
381
+ }[];
382
+ version: number;
383
+ updatedAt: string;
384
+ }>;
254
385
  refreshModels(id: string, idempotencyKey?: string): Promise<{
255
386
  models: {
256
387
  id: string;
package/dist/sdk.js CHANGED
@@ -75,7 +75,7 @@ var expiresOnSchema = z2.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) =>
75
75
  return Number.isFinite(day.getTime()) && day.toISOString().slice(0, 10) === value;
76
76
  }, "Use a real calendar date in YYYY-MM-DD format.");
77
77
  var modelSchema = z2.object({
78
- id: z2.string().min(1).max(300),
78
+ id: z2.string().min(1).max(300).refine((value) => value === value.trim() && !/[\x00-\x1f\x7f-\x9f]/.test(value), "Use a nonblank model ID without surrounding whitespace or control characters."),
79
79
  name: label,
80
80
  description: z2.string().max(8000).optional(),
81
81
  available: z2.boolean().optional(),
@@ -230,8 +230,9 @@ var preset = (id, name, protocols, sources, alias) => parse(providerPresetSchema
230
230
  var providerPresets = [
231
231
  preset("deepseek", "DeepSeek", [
232
232
  route("openai-chat", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
233
+ route("openai-responses", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
233
234
  route("anthropic-messages", "https://api.deepseek.com/anthropic/v1", { catalogBaseUrl: "https://api.deepseek.com" })
234
- ], ["https://api-docs.deepseek.com/guides/anthropic_api", "https://api-docs.deepseek.com/api/list-models"], "DEEPSEEK_API_KEY"),
235
+ ], ["https://api-docs.deepseek.com/guides/anthropic_api", "https://api-docs.deepseek.com/api/list-models", "https://api-docs.deepseek.com/updates/", "https://api-docs.deepseek.com/guides/responses_api/"], "DEEPSEEK_API_KEY"),
235
236
  preset("openrouter", "OpenRouter", ["openai-chat", "openai-responses", "anthropic-messages"].map((protocol) => route(protocol, "https://openrouter.ai/api/v1", { catalogAuthStyle: "none" })), ["https://openrouter.ai/docs/api/api-reference/models/list-all-models-and-their-properties", "https://openrouter.ai/docs/guides/overview"], "OPENROUTER_API_KEY"),
236
237
  preset("anthropic", "Anthropic", [route("anthropic-messages", "https://api.anthropic.com/v1", { authStyle: "x-api-key" })], ["https://platform.claude.com/docs/en/api/overview", "https://platform.claude.com/docs/en/api/models/list"], "ANTHROPIC_API_KEY"),
237
238
  preset("gemini", "Google Gemini", [route("gemini-generate-content", "https://generativelanguage.googleapis.com/v1beta", {
@@ -313,7 +314,7 @@ function providerFromPreset(presetId, options = {}) {
313
314
  const suffix = selected.protocol === "anthropic-messages" ? "messages" : selected.protocol === "openai-responses" ? "responses" : "chat";
314
315
  if (presetId === "fireworks" && !options.catalogBaseUrl && !options.catalogAccountId)
315
316
  throw new Fault(400, "catalog_account_required", "Fireworks model discovery requires --catalog-account-id or an explicit --catalog-url.");
316
- if (selected.catalogFormat === "none" && options.catalogFormat && !options.catalogBaseUrl)
317
+ if (selected.catalogFormat === "none" && options.catalogFormat && options.catalogFormat !== "none" && !options.catalogBaseUrl)
317
318
  throw new Fault(400, "catalog_url_required", "This preset requires an explicit --catalog-url when enabling a catalog parser.");
318
319
  const catalogBaseUrl = options.catalogBaseUrl ?? (presetId === "fireworks" && options.catalogAccountId ? `https://api.fireworks.ai/v1/accounts/${encodeURIComponent(options.catalogAccountId)}` : options.baseUrl ? undefined : selected.catalogBaseUrl);
319
320
  return parse(providerInputSchema, {
@@ -330,9 +331,11 @@ function providerFromPreset(presetId, options = {}) {
330
331
  catalogAccountId: options.catalogAccountId,
331
332
  modelsPath: options.modelsPath ?? selected.modelsPath,
332
333
  additionalModels: presetId === "deepseek" && new URL(baseUrl).origin === "https://api.deepseek.com" ? [{
333
- id: "deepseek-v4.1-flash-expires-on-0910",
334
- name: "DeepSeek V4.1 Flash preview",
335
- expiresOn: "2026-09-10"
334
+ id: "deepseek-flash",
335
+ name: "DeepSeek V4.1 Flash",
336
+ inputModalities: ["text", "image"],
337
+ outputModalities: ["text"],
338
+ supportedParameters: ["tools"]
336
339
  }] : []
337
340
  });
338
341
  }
@@ -483,6 +486,33 @@ class SwitcherClient {
483
486
  deleteProvider(id, version, idempotencyKey) {
484
487
  return this.request("DELETE", `/v1/providers/${encodeURIComponent(id)}`, undefined, { version, idempotencyKey });
485
488
  }
489
+ async editModel(providerId, operation, value) {
490
+ const model = typeof value === "string" ? undefined : parse(modelSchema, value);
491
+ const id = model?.id ?? parse(modelSchema.shape.id, value);
492
+ const provider = await this.getProvider(providerId);
493
+ const { version, updatedAt, ...input } = provider;
494
+ const manual = provider.manualModels.some((item) => item.id === id);
495
+ const additional = (provider.additionalModels ?? []).some((item) => item.id === id);
496
+ if (operation === "add" && (manual || additional))
497
+ throw new SwitcherError(409, "model_exists", "This model is already configured. Use models update to replace its metadata.");
498
+ if (operation !== "add" && !manual && !additional)
499
+ throw new SwitcherError(404, "model_not_configured", "This model has no saved metadata. Use models add to configure a catalog model; remote catalog entries cannot be deleted locally.");
500
+ const useManual = manual || !additional && (provider.manualModels.length > 0 || provider.catalogFormat === "none");
501
+ const manualModels = provider.manualModels.filter((item) => item.id !== id);
502
+ const additionalModels = (provider.additionalModels ?? []).filter((item) => item.id !== id);
503
+ if (operation !== "remove")
504
+ (useManual ? manualModels : additionalModels).push(model);
505
+ return this.updateProvider({ ...input, manualModels, additionalModels }, version);
506
+ }
507
+ addModel(providerId, model) {
508
+ return this.editModel(providerId, "add", model);
509
+ }
510
+ updateModel(providerId, model) {
511
+ return this.editModel(providerId, "update", model);
512
+ }
513
+ removeModel(providerId, modelId) {
514
+ return this.editModel(providerId, "remove", modelId);
515
+ }
486
516
  refreshModels(id, idempotencyKey) {
487
517
  return this.request("POST", `/v1/providers/${encodeURIComponent(id)}/refresh`, {}, { idempotencyKey });
488
518
  }
@@ -62,7 +62,7 @@ function canonicalPolicyJSON(value) {
62
62
  }
63
63
 
64
64
  // src/domain.ts
65
- var VERSION = "0.1.6";
65
+ var VERSION = "0.1.8";
66
66
  var harnessSchema = z2.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]);
67
67
  var protocolSchema = z2.enum(["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]);
68
68
  var idSchema = z2.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
@@ -92,7 +92,7 @@ var expiresOnSchema = z2.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) =>
92
92
  return Number.isFinite(day.getTime()) && day.toISOString().slice(0, 10) === value;
93
93
  }, "Use a real calendar date in YYYY-MM-DD format.");
94
94
  var modelSchema = z2.object({
95
- id: z2.string().min(1).max(300),
95
+ id: z2.string().min(1).max(300).refine((value) => value === value.trim() && !/[\x00-\x1f\x7f-\x9f]/.test(value), "Use a nonblank model ID without surrounding whitespace or control characters."),
96
96
  name: label,
97
97
  description: z2.string().max(8000).optional(),
98
98
  available: z2.boolean().optional(),
@@ -757,8 +757,9 @@ var preset = (id2, name, protocols, sources, alias) => parse(providerPresetSchem
757
757
  var providerPresets = [
758
758
  preset("deepseek", "DeepSeek", [
759
759
  route("openai-chat", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
760
+ route("openai-responses", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
760
761
  route("anthropic-messages", "https://api.deepseek.com/anthropic/v1", { catalogBaseUrl: "https://api.deepseek.com" })
761
- ], ["https://api-docs.deepseek.com/guides/anthropic_api", "https://api-docs.deepseek.com/api/list-models"], "DEEPSEEK_API_KEY"),
762
+ ], ["https://api-docs.deepseek.com/guides/anthropic_api", "https://api-docs.deepseek.com/api/list-models", "https://api-docs.deepseek.com/updates/", "https://api-docs.deepseek.com/guides/responses_api/"], "DEEPSEEK_API_KEY"),
762
763
  preset("openrouter", "OpenRouter", ["openai-chat", "openai-responses", "anthropic-messages"].map((protocol) => route(protocol, "https://openrouter.ai/api/v1", { catalogAuthStyle: "none" })), ["https://openrouter.ai/docs/api/api-reference/models/list-all-models-and-their-properties", "https://openrouter.ai/docs/guides/overview"], "OPENROUTER_API_KEY"),
763
764
  preset("anthropic", "Anthropic", [route("anthropic-messages", "https://api.anthropic.com/v1", { authStyle: "x-api-key" })], ["https://platform.claude.com/docs/en/api/overview", "https://platform.claude.com/docs/en/api/models/list"], "ANTHROPIC_API_KEY"),
764
765
  preset("gemini", "Google Gemini", [route("gemini-generate-content", "https://generativelanguage.googleapis.com/v1beta", {
@@ -830,7 +831,7 @@ var openapi_default = {
830
831
  openapi: "3.0.3",
831
832
  info: {
832
833
  title: "Switcher API",
833
- version: "0.1.6",
834
+ version: "0.1.8",
834
835
  description: "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
835
836
  },
836
837
  security: [
package/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.0.3",
3
3
  "info": {
4
4
  "title": "Switcher API",
5
- "version": "0.1.6",
5
+ "version": "0.1.8",
6
6
  "description": "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
7
7
  },
8
8
  "security": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/switcher",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "description": "Universal provider and model switcher for coding harnesses with an API, SDK and self-hosted storage",
6
6
  "license": "Apache-2.0",