@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/dist/mcp/index.js CHANGED
@@ -69,7 +69,7 @@ function canonicalPolicyJSON(value) {
69
69
  }
70
70
 
71
71
  // src/domain.ts
72
- var VERSION = "0.2.1";
72
+ var VERSION = "0.2.2";
73
73
  var harnessSchema = z3.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]);
74
74
  var protocolSchema = z3.enum(["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]);
75
75
  var idSchema = z3.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
@@ -94,6 +94,8 @@ var urlSchema = z3.string().max(2000).superRefine((v, ctx) => {
94
94
  ctx.addIssue({ code: "custom", message: "Invalid endpoint URL" });
95
95
  }
96
96
  }).transform(endpoint);
97
+ var credentialCheckPath = z3.string().min(1).max(200).regex(/^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$/).refine((value) => !value.startsWith("/") && !value.split("/").some((part) => part === "." || part === ".."), "credentialCheck.path must be relative without dot segments");
98
+ var credentialCheckSchema = z3.object({ method: z3.enum(["GET", "HEAD"]).default("GET"), path: credentialCheckPath }).strict();
97
99
  var expiresOnSchema = z3.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) => {
98
100
  const day = new Date(`${value}T00:00:00.000Z`);
99
101
  return Number.isFinite(day.getTime()) && day.toISOString().slice(0, 10) === value;
@@ -119,6 +121,7 @@ var providerInputSchema = z3.object({
119
121
  protocol: protocolSchema,
120
122
  credentialEnv: envRef.optional(),
121
123
  authStyle: z3.enum(["bearer", "x-api-key", "api-key"]).default("bearer"),
124
+ credentialCheck: credentialCheckSchema.optional(),
122
125
  catalogBaseUrl: urlSchema.optional(),
123
126
  catalogFormat: z3.enum(["openai", "ollama", "mistral", "together", "fireworks", "dashscope", "gemini", "none"]).optional(),
124
127
  catalogAuthStyle: z3.enum(["bearer", "x-api-key", "api-key", "none"]).optional(),
@@ -137,6 +140,7 @@ var providerPresetSchema = z3.object({
137
140
  protocol: protocolSchema,
138
141
  baseUrl: urlSchema.optional(),
139
142
  authStyle: z3.enum(["bearer", "x-api-key", "api-key"]),
143
+ credentialCheck: credentialCheckSchema.optional(),
140
144
  catalogBaseUrl: urlSchema.optional(),
141
145
  catalogFormat: z3.enum(["openai", "ollama", "mistral", "together", "fireworks", "dashscope", "gemini", "none"]),
142
146
  catalogAuthStyle: z3.enum(["bearer", "x-api-key", "api-key", "none"]).optional(),
@@ -278,7 +282,7 @@ var providerPresets = [
278
282
  route("openai-responses", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
279
283
  route("anthropic-messages", "https://api.deepseek.com/anthropic/v1", { catalogBaseUrl: "https://api.deepseek.com" })
280
284
  ], ["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"),
281
- 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"),
285
+ preset("openrouter", "OpenRouter", ["openai-chat", "openai-responses", "anthropic-messages"].map((protocol) => route(protocol, "https://openrouter.ai/api/v1", { catalogAuthStyle: "none", credentialCheck: { method: "GET", path: "key" } })), ["https://openrouter.ai/docs/api/api-reference/models/list-all-models-and-their-properties", "https://openrouter.ai/docs/guides/overview"], "OPENROUTER_API_KEY"),
282
286
  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"),
283
287
  preset("gemini", "Google Gemini", [route("gemini-generate-content", "https://generativelanguage.googleapis.com/v1beta", {
284
288
  authStyle: "x-api-key",
@@ -1095,7 +1099,7 @@ var openapi_default = {
1095
1099
  openapi: "3.0.3",
1096
1100
  info: {
1097
1101
  title: "Switcher API",
1098
- version: "0.2.1",
1102
+ version: "0.2.2",
1099
1103
  description: "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
1100
1104
  },
1101
1105
  security: [
@@ -2325,6 +2329,29 @@ var openapi_default = {
2325
2329
  "api-key"
2326
2330
  ]
2327
2331
  },
2332
+ credentialCheck: {
2333
+ type: "object",
2334
+ properties: {
2335
+ method: {
2336
+ type: "string",
2337
+ enum: [
2338
+ "GET",
2339
+ "HEAD"
2340
+ ],
2341
+ default: "GET"
2342
+ },
2343
+ path: {
2344
+ type: "string",
2345
+ minLength: 1,
2346
+ maxLength: 200,
2347
+ pattern: "^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$"
2348
+ }
2349
+ },
2350
+ required: [
2351
+ "path"
2352
+ ],
2353
+ additionalProperties: false
2354
+ },
2328
2355
  catalogBaseUrl: {
2329
2356
  type: "string",
2330
2357
  maxLength: 2000
@@ -2434,6 +2461,29 @@ var openapi_default = {
2434
2461
  ],
2435
2462
  default: "bearer"
2436
2463
  },
2464
+ credentialCheck: {
2465
+ type: "object",
2466
+ properties: {
2467
+ method: {
2468
+ type: "string",
2469
+ enum: [
2470
+ "GET",
2471
+ "HEAD"
2472
+ ],
2473
+ default: "GET"
2474
+ },
2475
+ path: {
2476
+ type: "string",
2477
+ minLength: 1,
2478
+ maxLength: 200,
2479
+ pattern: "^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$"
2480
+ }
2481
+ },
2482
+ required: [
2483
+ "path"
2484
+ ],
2485
+ additionalProperties: false
2486
+ },
2437
2487
  catalogBaseUrl: {
2438
2488
  type: "string",
2439
2489
  maxLength: 2000
@@ -2712,6 +2762,29 @@ var openapi_default = {
2712
2762
  ],
2713
2763
  default: "bearer"
2714
2764
  },
2765
+ credentialCheck: {
2766
+ type: "object",
2767
+ properties: {
2768
+ method: {
2769
+ type: "string",
2770
+ enum: [
2771
+ "GET",
2772
+ "HEAD"
2773
+ ],
2774
+ default: "GET"
2775
+ },
2776
+ path: {
2777
+ type: "string",
2778
+ minLength: 1,
2779
+ maxLength: 200,
2780
+ pattern: "^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$"
2781
+ }
2782
+ },
2783
+ required: [
2784
+ "path"
2785
+ ],
2786
+ additionalProperties: false
2787
+ },
2715
2788
  catalogBaseUrl: {
2716
2789
  type: "string",
2717
2790
  maxLength: 2000
@@ -3834,6 +3907,29 @@ var openapi_default = {
3834
3907
  ],
3835
3908
  default: "bearer"
3836
3909
  },
3910
+ credentialCheck: {
3911
+ type: "object",
3912
+ properties: {
3913
+ method: {
3914
+ type: "string",
3915
+ enum: [
3916
+ "GET",
3917
+ "HEAD"
3918
+ ],
3919
+ default: "GET"
3920
+ },
3921
+ path: {
3922
+ type: "string",
3923
+ minLength: 1,
3924
+ maxLength: 200,
3925
+ pattern: "^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$"
3926
+ }
3927
+ },
3928
+ required: [
3929
+ "path"
3930
+ ],
3931
+ additionalProperties: false
3932
+ },
3837
3933
  catalogBaseUrl: {
3838
3934
  type: "string",
3839
3935
  maxLength: 2000
package/dist/presets.d.ts CHANGED
@@ -12,6 +12,10 @@ export declare function getProviderPreset(id: string): {
12
12
  modelsPath: string;
13
13
  notes: string[];
14
14
  baseUrl?: string | undefined;
15
+ credentialCheck?: {
16
+ path: string;
17
+ method: "GET" | "HEAD";
18
+ } | undefined;
15
19
  catalogBaseUrl?: string | undefined;
16
20
  catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none" | undefined;
17
21
  }[];
@@ -55,6 +59,10 @@ export declare function providerFromPreset(presetId: string, options?: PresetOpt
55
59
  supportedGenerationMethods?: string[] | undefined;
56
60
  }[];
57
61
  credentialEnv?: string | undefined;
62
+ credentialCheck?: {
63
+ path: string;
64
+ method: "GET" | "HEAD";
65
+ } | undefined;
58
66
  catalogBaseUrl?: string | undefined;
59
67
  catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none" | undefined;
60
68
  catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none" | undefined;
package/dist/sdk.d.ts CHANGED
@@ -73,6 +73,10 @@ export declare class SwitcherClient {
73
73
  protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
74
74
  baseUrl?: string;
75
75
  authStyle: "bearer" | "x-api-key" | "api-key";
76
+ credentialCheck?: {
77
+ method: "GET" | "HEAD";
78
+ path: string;
79
+ };
76
80
  catalogBaseUrl?: string;
77
81
  catalogFormat: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
78
82
  catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none";
@@ -89,6 +93,10 @@ export declare class SwitcherClient {
89
93
  protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
90
94
  credentialEnv?: string;
91
95
  authStyle: "bearer" | "x-api-key" | "api-key";
96
+ credentialCheck?: {
97
+ method: "GET" | "HEAD";
98
+ path: string;
99
+ };
92
100
  catalogBaseUrl?: string;
93
101
  catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
94
102
  catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none";
@@ -133,6 +141,10 @@ export declare class SwitcherClient {
133
141
  protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
134
142
  credentialEnv?: string;
135
143
  authStyle: "bearer" | "x-api-key" | "api-key";
144
+ credentialCheck?: {
145
+ method: "GET" | "HEAD";
146
+ path: string;
147
+ };
136
148
  catalogBaseUrl?: string;
137
149
  catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
138
150
  catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none";
@@ -177,6 +189,10 @@ export declare class SwitcherClient {
177
189
  protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
178
190
  credentialEnv?: string;
179
191
  authStyle: "bearer" | "x-api-key" | "api-key";
192
+ credentialCheck?: {
193
+ method: "GET" | "HEAD";
194
+ path: string;
195
+ };
180
196
  catalogBaseUrl?: string;
181
197
  catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
182
198
  catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none";
@@ -221,6 +237,10 @@ export declare class SwitcherClient {
221
237
  protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
222
238
  credentialEnv?: string;
223
239
  authStyle: "bearer" | "x-api-key" | "api-key";
240
+ credentialCheck?: {
241
+ method: "GET" | "HEAD";
242
+ path: string;
243
+ };
224
244
  catalogBaseUrl?: string;
225
245
  catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
226
246
  catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none";
@@ -272,6 +292,10 @@ export declare class SwitcherClient {
272
292
  protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
273
293
  credentialEnv?: string;
274
294
  authStyle: "bearer" | "x-api-key" | "api-key";
295
+ credentialCheck?: {
296
+ method: "GET" | "HEAD";
297
+ path: string;
298
+ };
275
299
  catalogBaseUrl?: string;
276
300
  catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
277
301
  catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none";
@@ -317,6 +341,10 @@ export declare class SwitcherClient {
317
341
  protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
318
342
  credentialEnv?: string;
319
343
  authStyle: "bearer" | "x-api-key" | "api-key";
344
+ credentialCheck?: {
345
+ method: "GET" | "HEAD";
346
+ path: string;
347
+ };
320
348
  catalogBaseUrl?: string;
321
349
  catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
322
350
  catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none";
@@ -361,6 +389,10 @@ export declare class SwitcherClient {
361
389
  protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
362
390
  credentialEnv?: string;
363
391
  authStyle: "bearer" | "x-api-key" | "api-key";
392
+ credentialCheck?: {
393
+ method: "GET" | "HEAD";
394
+ path: string;
395
+ };
364
396
  catalogBaseUrl?: string;
365
397
  catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
366
398
  catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none";
@@ -566,6 +598,10 @@ export declare class SwitcherClient {
566
598
  protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
567
599
  credentialEnv?: string;
568
600
  authStyle: "bearer" | "x-api-key" | "api-key";
601
+ credentialCheck?: {
602
+ method: "GET" | "HEAD";
603
+ path: string;
604
+ };
569
605
  catalogBaseUrl?: string;
570
606
  catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
571
607
  catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none";
package/dist/sdk.js CHANGED
@@ -75,6 +75,8 @@ var urlSchema = z3.string().max(2000).superRefine((v, ctx) => {
75
75
  ctx.addIssue({ code: "custom", message: "Invalid endpoint URL" });
76
76
  }
77
77
  }).transform(endpoint);
78
+ var credentialCheckPath = z3.string().min(1).max(200).regex(/^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$/).refine((value) => !value.startsWith("/") && !value.split("/").some((part) => part === "." || part === ".."), "credentialCheck.path must be relative without dot segments");
79
+ var credentialCheckSchema = z3.object({ method: z3.enum(["GET", "HEAD"]).default("GET"), path: credentialCheckPath }).strict();
78
80
  var expiresOnSchema = z3.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) => {
79
81
  const day = new Date(`${value}T00:00:00.000Z`);
80
82
  return Number.isFinite(day.getTime()) && day.toISOString().slice(0, 10) === value;
@@ -100,6 +102,7 @@ var providerInputSchema = z3.object({
100
102
  protocol: protocolSchema,
101
103
  credentialEnv: envRef.optional(),
102
104
  authStyle: z3.enum(["bearer", "x-api-key", "api-key"]).default("bearer"),
105
+ credentialCheck: credentialCheckSchema.optional(),
103
106
  catalogBaseUrl: urlSchema.optional(),
104
107
  catalogFormat: z3.enum(["openai", "ollama", "mistral", "together", "fireworks", "dashscope", "gemini", "none"]).optional(),
105
108
  catalogAuthStyle: z3.enum(["bearer", "x-api-key", "api-key", "none"]).optional(),
@@ -118,6 +121,7 @@ var providerPresetSchema = z3.object({
118
121
  protocol: protocolSchema,
119
122
  baseUrl: urlSchema.optional(),
120
123
  authStyle: z3.enum(["bearer", "x-api-key", "api-key"]),
124
+ credentialCheck: credentialCheckSchema.optional(),
121
125
  catalogBaseUrl: urlSchema.optional(),
122
126
  catalogFormat: z3.enum(["openai", "ollama", "mistral", "together", "fireworks", "dashscope", "gemini", "none"]),
123
127
  catalogAuthStyle: z3.enum(["bearer", "x-api-key", "api-key", "none"]).optional(),
@@ -244,7 +248,7 @@ var providerPresets = [
244
248
  route("openai-responses", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
245
249
  route("anthropic-messages", "https://api.deepseek.com/anthropic/v1", { catalogBaseUrl: "https://api.deepseek.com" })
246
250
  ], ["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"),
247
- 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"),
251
+ preset("openrouter", "OpenRouter", ["openai-chat", "openai-responses", "anthropic-messages"].map((protocol) => route(protocol, "https://openrouter.ai/api/v1", { catalogAuthStyle: "none", credentialCheck: { method: "GET", path: "key" } })), ["https://openrouter.ai/docs/api/api-reference/models/list-all-models-and-their-properties", "https://openrouter.ai/docs/guides/overview"], "OPENROUTER_API_KEY"),
248
252
  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"),
249
253
  preset("gemini", "Google Gemini", [route("gemini-generate-content", "https://generativelanguage.googleapis.com/v1beta", {
250
254
  authStyle: "x-api-key",
@@ -335,6 +339,7 @@ function providerFromPreset(presetId, options = {}) {
335
339
  protocol: selected.protocol,
336
340
  credentialEnv: options.credentialEnv ?? preset2.credentialEnv,
337
341
  authStyle: options.authStyle ?? selected.authStyle,
342
+ credentialCheck: selected.credentialCheck,
338
343
  catalogBaseUrl,
339
344
  catalogCredentialEnv: options.catalogCredentialEnv,
340
345
  catalogAuthStyle: options.catalogAuthStyle ?? selected.catalogAuthStyle,
@@ -67,7 +67,7 @@ function canonicalPolicyJSON(value) {
67
67
  }
68
68
 
69
69
  // src/domain.ts
70
- var VERSION = "0.2.1";
70
+ var VERSION = "0.2.2";
71
71
  var harnessSchema = z3.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]);
72
72
  var protocolSchema = z3.enum(["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]);
73
73
  var idSchema = z3.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
@@ -92,6 +92,8 @@ var urlSchema = z3.string().max(2000).superRefine((v, ctx) => {
92
92
  ctx.addIssue({ code: "custom", message: "Invalid endpoint URL" });
93
93
  }
94
94
  }).transform(endpoint);
95
+ var credentialCheckPath = z3.string().min(1).max(200).regex(/^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$/).refine((value) => !value.startsWith("/") && !value.split("/").some((part) => part === "." || part === ".."), "credentialCheck.path must be relative without dot segments");
96
+ var credentialCheckSchema = z3.object({ method: z3.enum(["GET", "HEAD"]).default("GET"), path: credentialCheckPath }).strict();
95
97
  var expiresOnSchema = z3.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) => {
96
98
  const day = new Date(`${value}T00:00:00.000Z`);
97
99
  return Number.isFinite(day.getTime()) && day.toISOString().slice(0, 10) === value;
@@ -117,6 +119,7 @@ var providerInputSchema = z3.object({
117
119
  protocol: protocolSchema,
118
120
  credentialEnv: envRef.optional(),
119
121
  authStyle: z3.enum(["bearer", "x-api-key", "api-key"]).default("bearer"),
122
+ credentialCheck: credentialCheckSchema.optional(),
120
123
  catalogBaseUrl: urlSchema.optional(),
121
124
  catalogFormat: z3.enum(["openai", "ollama", "mistral", "together", "fireworks", "dashscope", "gemini", "none"]).optional(),
122
125
  catalogAuthStyle: z3.enum(["bearer", "x-api-key", "api-key", "none"]).optional(),
@@ -135,6 +138,7 @@ var providerPresetSchema = z3.object({
135
138
  protocol: protocolSchema,
136
139
  baseUrl: urlSchema.optional(),
137
140
  authStyle: z3.enum(["bearer", "x-api-key", "api-key"]),
141
+ credentialCheck: credentialCheckSchema.optional(),
138
142
  catalogBaseUrl: urlSchema.optional(),
139
143
  catalogFormat: z3.enum(["openai", "ollama", "mistral", "together", "fireworks", "dashscope", "gemini", "none"]),
140
144
  catalogAuthStyle: z3.enum(["bearer", "x-api-key", "api-key", "none"]).optional(),
@@ -772,7 +776,7 @@ var providerPresets = [
772
776
  route("openai-responses", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
773
777
  route("anthropic-messages", "https://api.deepseek.com/anthropic/v1", { catalogBaseUrl: "https://api.deepseek.com" })
774
778
  ], ["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"),
775
- 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"),
779
+ preset("openrouter", "OpenRouter", ["openai-chat", "openai-responses", "anthropic-messages"].map((protocol) => route(protocol, "https://openrouter.ai/api/v1", { catalogAuthStyle: "none", credentialCheck: { method: "GET", path: "key" } })), ["https://openrouter.ai/docs/api/api-reference/models/list-all-models-and-their-properties", "https://openrouter.ai/docs/guides/overview"], "OPENROUTER_API_KEY"),
776
780
  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"),
777
781
  preset("gemini", "Google Gemini", [route("gemini-generate-content", "https://generativelanguage.googleapis.com/v1beta", {
778
782
  authStyle: "x-api-key",
@@ -843,7 +847,7 @@ var openapi_default = {
843
847
  openapi: "3.0.3",
844
848
  info: {
845
849
  title: "Switcher API",
846
- version: "0.2.1",
850
+ version: "0.2.2",
847
851
  description: "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
848
852
  },
849
853
  security: [
@@ -2073,6 +2077,29 @@ var openapi_default = {
2073
2077
  "api-key"
2074
2078
  ]
2075
2079
  },
2080
+ credentialCheck: {
2081
+ type: "object",
2082
+ properties: {
2083
+ method: {
2084
+ type: "string",
2085
+ enum: [
2086
+ "GET",
2087
+ "HEAD"
2088
+ ],
2089
+ default: "GET"
2090
+ },
2091
+ path: {
2092
+ type: "string",
2093
+ minLength: 1,
2094
+ maxLength: 200,
2095
+ pattern: "^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$"
2096
+ }
2097
+ },
2098
+ required: [
2099
+ "path"
2100
+ ],
2101
+ additionalProperties: false
2102
+ },
2076
2103
  catalogBaseUrl: {
2077
2104
  type: "string",
2078
2105
  maxLength: 2000
@@ -2182,6 +2209,29 @@ var openapi_default = {
2182
2209
  ],
2183
2210
  default: "bearer"
2184
2211
  },
2212
+ credentialCheck: {
2213
+ type: "object",
2214
+ properties: {
2215
+ method: {
2216
+ type: "string",
2217
+ enum: [
2218
+ "GET",
2219
+ "HEAD"
2220
+ ],
2221
+ default: "GET"
2222
+ },
2223
+ path: {
2224
+ type: "string",
2225
+ minLength: 1,
2226
+ maxLength: 200,
2227
+ pattern: "^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$"
2228
+ }
2229
+ },
2230
+ required: [
2231
+ "path"
2232
+ ],
2233
+ additionalProperties: false
2234
+ },
2185
2235
  catalogBaseUrl: {
2186
2236
  type: "string",
2187
2237
  maxLength: 2000
@@ -2460,6 +2510,29 @@ var openapi_default = {
2460
2510
  ],
2461
2511
  default: "bearer"
2462
2512
  },
2513
+ credentialCheck: {
2514
+ type: "object",
2515
+ properties: {
2516
+ method: {
2517
+ type: "string",
2518
+ enum: [
2519
+ "GET",
2520
+ "HEAD"
2521
+ ],
2522
+ default: "GET"
2523
+ },
2524
+ path: {
2525
+ type: "string",
2526
+ minLength: 1,
2527
+ maxLength: 200,
2528
+ pattern: "^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$"
2529
+ }
2530
+ },
2531
+ required: [
2532
+ "path"
2533
+ ],
2534
+ additionalProperties: false
2535
+ },
2463
2536
  catalogBaseUrl: {
2464
2537
  type: "string",
2465
2538
  maxLength: 2000
@@ -3582,6 +3655,29 @@ var openapi_default = {
3582
3655
  ],
3583
3656
  default: "bearer"
3584
3657
  },
3658
+ credentialCheck: {
3659
+ type: "object",
3660
+ properties: {
3661
+ method: {
3662
+ type: "string",
3663
+ enum: [
3664
+ "GET",
3665
+ "HEAD"
3666
+ ],
3667
+ default: "GET"
3668
+ },
3669
+ path: {
3670
+ type: "string",
3671
+ minLength: 1,
3672
+ maxLength: 200,
3673
+ pattern: "^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$"
3674
+ }
3675
+ },
3676
+ required: [
3677
+ "path"
3678
+ ],
3679
+ additionalProperties: false
3680
+ },
3585
3681
  catalogBaseUrl: {
3586
3682
  type: "string",
3587
3683
  maxLength: 2000
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.2.1",
5
+ "version": "0.2.2",
6
6
  "description": "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
7
7
  },
8
8
  "security": [
@@ -1232,6 +1232,29 @@
1232
1232
  "api-key"
1233
1233
  ]
1234
1234
  },
1235
+ "credentialCheck": {
1236
+ "type": "object",
1237
+ "properties": {
1238
+ "method": {
1239
+ "type": "string",
1240
+ "enum": [
1241
+ "GET",
1242
+ "HEAD"
1243
+ ],
1244
+ "default": "GET"
1245
+ },
1246
+ "path": {
1247
+ "type": "string",
1248
+ "minLength": 1,
1249
+ "maxLength": 200,
1250
+ "pattern": "^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$"
1251
+ }
1252
+ },
1253
+ "required": [
1254
+ "path"
1255
+ ],
1256
+ "additionalProperties": false
1257
+ },
1235
1258
  "catalogBaseUrl": {
1236
1259
  "type": "string",
1237
1260
  "maxLength": 2000
@@ -1341,6 +1364,29 @@
1341
1364
  ],
1342
1365
  "default": "bearer"
1343
1366
  },
1367
+ "credentialCheck": {
1368
+ "type": "object",
1369
+ "properties": {
1370
+ "method": {
1371
+ "type": "string",
1372
+ "enum": [
1373
+ "GET",
1374
+ "HEAD"
1375
+ ],
1376
+ "default": "GET"
1377
+ },
1378
+ "path": {
1379
+ "type": "string",
1380
+ "minLength": 1,
1381
+ "maxLength": 200,
1382
+ "pattern": "^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$"
1383
+ }
1384
+ },
1385
+ "required": [
1386
+ "path"
1387
+ ],
1388
+ "additionalProperties": false
1389
+ },
1344
1390
  "catalogBaseUrl": {
1345
1391
  "type": "string",
1346
1392
  "maxLength": 2000
@@ -1619,6 +1665,29 @@
1619
1665
  ],
1620
1666
  "default": "bearer"
1621
1667
  },
1668
+ "credentialCheck": {
1669
+ "type": "object",
1670
+ "properties": {
1671
+ "method": {
1672
+ "type": "string",
1673
+ "enum": [
1674
+ "GET",
1675
+ "HEAD"
1676
+ ],
1677
+ "default": "GET"
1678
+ },
1679
+ "path": {
1680
+ "type": "string",
1681
+ "minLength": 1,
1682
+ "maxLength": 200,
1683
+ "pattern": "^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$"
1684
+ }
1685
+ },
1686
+ "required": [
1687
+ "path"
1688
+ ],
1689
+ "additionalProperties": false
1690
+ },
1622
1691
  "catalogBaseUrl": {
1623
1692
  "type": "string",
1624
1693
  "maxLength": 2000
@@ -2741,6 +2810,29 @@
2741
2810
  ],
2742
2811
  "default": "bearer"
2743
2812
  },
2813
+ "credentialCheck": {
2814
+ "type": "object",
2815
+ "properties": {
2816
+ "method": {
2817
+ "type": "string",
2818
+ "enum": [
2819
+ "GET",
2820
+ "HEAD"
2821
+ ],
2822
+ "default": "GET"
2823
+ },
2824
+ "path": {
2825
+ "type": "string",
2826
+ "minLength": 1,
2827
+ "maxLength": 200,
2828
+ "pattern": "^[a-zA-Z0-9_~!$&'()*+,;=:@%./-]+$"
2829
+ }
2830
+ },
2831
+ "required": [
2832
+ "path"
2833
+ ],
2834
+ "additionalProperties": false
2835
+ },
2744
2836
  "catalogBaseUrl": {
2745
2837
  "type": "string",
2746
2838
  "maxLength": 2000
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/switcher",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
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",