@hasna/switcher 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -4
- package/dist/cli/index.js +2044 -1664
- package/dist/credentials.d.ts +96 -7
- package/dist/direct-launch.d.ts +2 -1
- package/dist/domain.d.ts +63 -1
- package/dist/generated/api.d.ts +32 -0
- package/dist/index.js +6 -1
- package/dist/launcher.d.ts +1 -0
- package/dist/mcp/index.js +99 -3
- package/dist/presets.d.ts +8 -0
- package/dist/sdk.d.ts +36 -0
- package/dist/sdk.js +6 -1
- package/dist/serve/index.js +99 -3
- package/openapi.json +93 -1
- package/package.json +1 -1
package/dist/credentials.d.ts
CHANGED
|
@@ -14,10 +14,12 @@ declare const keychain: z.ZodObject<{
|
|
|
14
14
|
service: string;
|
|
15
15
|
account: string;
|
|
16
16
|
}>;
|
|
17
|
+
declare const credentialTier: z.ZodEnum<["argument", "override", "pointer", "profile", "keychain", "disk", "env"]>;
|
|
17
18
|
export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
18
19
|
schema: z.ZodLiteral<1>;
|
|
19
20
|
credentialEnv: z.ZodString;
|
|
20
21
|
origins: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
22
|
+
requireProviderAuthentication: z.ZodOptional<z.ZodLiteral<true>>;
|
|
21
23
|
source: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
22
24
|
kind: z.ZodLiteral<"keychain">;
|
|
23
25
|
service: z.ZodString;
|
|
@@ -37,10 +39,16 @@ export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
|
37
39
|
executable: z.ZodEffects<z.ZodString, string, string>;
|
|
38
40
|
operator: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
39
41
|
kind: z.ZodLiteral<"contracts">;
|
|
42
|
+
expectedSource: z.ZodOptional<z.ZodString>;
|
|
43
|
+
expectedTier: z.ZodOptional<z.ZodEnum<["argument", "override", "pointer", "profile", "keychain", "disk", "env"]>>;
|
|
40
44
|
}, "strict", z.ZodTypeAny, {
|
|
41
45
|
kind: "contracts";
|
|
46
|
+
expectedSource?: string | undefined;
|
|
47
|
+
expectedTier?: "profile" | "argument" | "override" | "pointer" | "keychain" | "disk" | "env" | undefined;
|
|
42
48
|
}, {
|
|
43
49
|
kind: "contracts";
|
|
50
|
+
expectedSource?: string | undefined;
|
|
51
|
+
expectedTier?: "profile" | "argument" | "override" | "pointer" | "keychain" | "disk" | "env" | undefined;
|
|
44
52
|
}>, z.ZodObject<{
|
|
45
53
|
kind: z.ZodLiteral<"env">;
|
|
46
54
|
}, "strict", z.ZodTypeAny, {
|
|
@@ -58,11 +66,13 @@ export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
|
58
66
|
account: string;
|
|
59
67
|
}>]>;
|
|
60
68
|
}, "strict", z.ZodTypeAny, {
|
|
61
|
-
executable: string;
|
|
62
69
|
key: string;
|
|
70
|
+
executable: string;
|
|
63
71
|
kind: "vault";
|
|
64
72
|
operator: {
|
|
65
73
|
kind: "contracts";
|
|
74
|
+
expectedSource?: string | undefined;
|
|
75
|
+
expectedTier?: "profile" | "argument" | "override" | "pointer" | "keychain" | "disk" | "env" | undefined;
|
|
66
76
|
} | {
|
|
67
77
|
kind: "env";
|
|
68
78
|
} | {
|
|
@@ -71,11 +81,13 @@ export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
|
71
81
|
};
|
|
72
82
|
url?: string | undefined;
|
|
73
83
|
}, {
|
|
74
|
-
executable: string;
|
|
75
84
|
key: string;
|
|
85
|
+
executable: string;
|
|
76
86
|
kind: "vault";
|
|
77
87
|
operator: {
|
|
78
88
|
kind: "contracts";
|
|
89
|
+
expectedSource?: string | undefined;
|
|
90
|
+
expectedTier?: "profile" | "argument" | "override" | "pointer" | "keychain" | "disk" | "env" | undefined;
|
|
79
91
|
} | {
|
|
80
92
|
kind: "env";
|
|
81
93
|
} | {
|
|
@@ -91,11 +103,13 @@ export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
|
91
103
|
service: string;
|
|
92
104
|
account: string;
|
|
93
105
|
} | {
|
|
94
|
-
executable: string;
|
|
95
106
|
key: string;
|
|
107
|
+
executable: string;
|
|
96
108
|
kind: "vault";
|
|
97
109
|
operator: {
|
|
98
110
|
kind: "contracts";
|
|
111
|
+
expectedSource?: string | undefined;
|
|
112
|
+
expectedTier?: "profile" | "argument" | "override" | "pointer" | "keychain" | "disk" | "env" | undefined;
|
|
99
113
|
} | {
|
|
100
114
|
kind: "env";
|
|
101
115
|
} | {
|
|
@@ -106,6 +120,7 @@ export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
|
106
120
|
};
|
|
107
121
|
schema: 1;
|
|
108
122
|
origins: string[];
|
|
123
|
+
requireProviderAuthentication?: true | undefined;
|
|
109
124
|
}, {
|
|
110
125
|
credentialEnv: string;
|
|
111
126
|
source: {
|
|
@@ -113,11 +128,13 @@ export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
|
113
128
|
service: string;
|
|
114
129
|
account: string;
|
|
115
130
|
} | {
|
|
116
|
-
executable: string;
|
|
117
131
|
key: string;
|
|
132
|
+
executable: string;
|
|
118
133
|
kind: "vault";
|
|
119
134
|
operator: {
|
|
120
135
|
kind: "contracts";
|
|
136
|
+
expectedSource?: string | undefined;
|
|
137
|
+
expectedTier?: "profile" | "argument" | "override" | "pointer" | "keychain" | "disk" | "env" | undefined;
|
|
121
138
|
} | {
|
|
122
139
|
kind: "env";
|
|
123
140
|
} | {
|
|
@@ -128,6 +145,7 @@ export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
|
128
145
|
};
|
|
129
146
|
schema: 1;
|
|
130
147
|
origins: string[];
|
|
148
|
+
requireProviderAuthentication?: true | undefined;
|
|
131
149
|
}>, {
|
|
132
150
|
credentialEnv: string;
|
|
133
151
|
source: {
|
|
@@ -135,11 +153,13 @@ export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
|
135
153
|
service: string;
|
|
136
154
|
account: string;
|
|
137
155
|
} | {
|
|
138
|
-
executable: string;
|
|
139
156
|
key: string;
|
|
157
|
+
executable: string;
|
|
140
158
|
kind: "vault";
|
|
141
159
|
operator: {
|
|
142
160
|
kind: "contracts";
|
|
161
|
+
expectedSource?: string | undefined;
|
|
162
|
+
expectedTier?: "profile" | "argument" | "override" | "pointer" | "keychain" | "disk" | "env" | undefined;
|
|
143
163
|
} | {
|
|
144
164
|
kind: "env";
|
|
145
165
|
} | {
|
|
@@ -150,6 +170,7 @@ export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
|
150
170
|
};
|
|
151
171
|
schema: 1;
|
|
152
172
|
origins: string[];
|
|
173
|
+
requireProviderAuthentication?: true | undefined;
|
|
153
174
|
}, {
|
|
154
175
|
credentialEnv: string;
|
|
155
176
|
source: {
|
|
@@ -157,11 +178,13 @@ export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
|
157
178
|
service: string;
|
|
158
179
|
account: string;
|
|
159
180
|
} | {
|
|
160
|
-
executable: string;
|
|
161
181
|
key: string;
|
|
182
|
+
executable: string;
|
|
162
183
|
kind: "vault";
|
|
163
184
|
operator: {
|
|
164
185
|
kind: "contracts";
|
|
186
|
+
expectedSource?: string | undefined;
|
|
187
|
+
expectedTier?: "profile" | "argument" | "override" | "pointer" | "keychain" | "disk" | "env" | undefined;
|
|
165
188
|
} | {
|
|
166
189
|
kind: "env";
|
|
167
190
|
} | {
|
|
@@ -172,6 +195,7 @@ export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
|
172
195
|
};
|
|
173
196
|
schema: 1;
|
|
174
197
|
origins: string[];
|
|
198
|
+
requireProviderAuthentication?: true | undefined;
|
|
175
199
|
}>;
|
|
176
200
|
export type CredentialBinding = z.infer<typeof credentialBindingSchema>;
|
|
177
201
|
export declare class CredentialBindings {
|
|
@@ -189,11 +213,13 @@ export declare class CredentialBindings {
|
|
|
189
213
|
service: string;
|
|
190
214
|
account: string;
|
|
191
215
|
} | {
|
|
192
|
-
executable: string;
|
|
193
216
|
key: string;
|
|
217
|
+
executable: string;
|
|
194
218
|
kind: "vault";
|
|
195
219
|
operator: {
|
|
196
220
|
kind: "contracts";
|
|
221
|
+
expectedSource?: string | undefined;
|
|
222
|
+
expectedTier?: "profile" | "argument" | "override" | "pointer" | "keychain" | "disk" | "env" | undefined;
|
|
197
223
|
} | {
|
|
198
224
|
kind: "env";
|
|
199
225
|
} | {
|
|
@@ -204,6 +230,7 @@ export declare class CredentialBindings {
|
|
|
204
230
|
};
|
|
205
231
|
schema: 1;
|
|
206
232
|
origins: string[];
|
|
233
|
+
requireProviderAuthentication?: true | undefined;
|
|
207
234
|
}>;
|
|
208
235
|
remove(name: string): Promise<{
|
|
209
236
|
removed: string;
|
|
@@ -248,6 +275,68 @@ export declare class CredentialInterrupted extends CommandInterrupted {
|
|
|
248
275
|
}
|
|
249
276
|
/** Select an operator through the shared credential seam, then pin that choice. */
|
|
250
277
|
export declare function vaultEnvironment(binding: CredentialBinding, env: NodeJS.ProcessEnv, options?: Pick<CredentialChainOptions, "keychain">): Promise<NodeJS.ProcessEnv>;
|
|
278
|
+
export type VaultCredentialReference = {
|
|
279
|
+
account: string;
|
|
280
|
+
key: string;
|
|
281
|
+
url?: string;
|
|
282
|
+
executable: string;
|
|
283
|
+
operator: {
|
|
284
|
+
kind: "contracts";
|
|
285
|
+
expectedSource?: string;
|
|
286
|
+
expectedTier?: z.infer<typeof credentialTier>;
|
|
287
|
+
} | {
|
|
288
|
+
kind: "env";
|
|
289
|
+
} | {
|
|
290
|
+
kind: "keychain";
|
|
291
|
+
account: string;
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
type CredentialResolverLike = Pick<CredentialResolver, "resolve"> & {
|
|
295
|
+
bindings: Pick<CredentialBindings, "get" | "bind">;
|
|
296
|
+
};
|
|
297
|
+
export type ProviderAuthenticationResult = {
|
|
298
|
+
authenticated: boolean;
|
|
299
|
+
status?: number;
|
|
300
|
+
unsupported?: boolean;
|
|
301
|
+
};
|
|
302
|
+
export type EnsureProviderCredentialOptions = {
|
|
303
|
+
interactive?: boolean;
|
|
304
|
+
resolver?: CredentialResolverLike;
|
|
305
|
+
env?: NodeJS.ProcessEnv;
|
|
306
|
+
vaultExecutable?: string;
|
|
307
|
+
discoverVaultReferences?: (request: {
|
|
308
|
+
provider: ProviderInput;
|
|
309
|
+
credentialEnv: string;
|
|
310
|
+
}) => Promise<VaultCredentialReference[]>;
|
|
311
|
+
selectVaultReference?: (request: {
|
|
312
|
+
provider: ProviderInput;
|
|
313
|
+
matches: VaultCredentialReference[];
|
|
314
|
+
}) => Promise<VaultCredentialReference | undefined>;
|
|
315
|
+
verifyProviderAuthentication?: (request: {
|
|
316
|
+
provider: ProviderInput;
|
|
317
|
+
credential: string;
|
|
318
|
+
}) => Promise<ProviderAuthenticationResult>;
|
|
319
|
+
};
|
|
320
|
+
export type PreparedProviderCredential = {
|
|
321
|
+
source: "not-required" | "environment" | "binding";
|
|
322
|
+
configured: boolean;
|
|
323
|
+
verified: boolean;
|
|
324
|
+
providerFingerprint: string;
|
|
325
|
+
readonly resolveCredential: (provider: ProviderInput) => Promise<string | undefined>;
|
|
326
|
+
};
|
|
327
|
+
export declare const providerCredentialSetupCommand: (provider: ProviderInput) => string;
|
|
328
|
+
export declare function discoverVaultReferences(provider: ProviderInput, env?: NodeJS.ProcessEnv, vaultExecutable?: string): Promise<VaultCredentialReference[]>;
|
|
329
|
+
export declare function selectVaultReference({ provider, matches }: {
|
|
330
|
+
provider: ProviderInput;
|
|
331
|
+
matches: VaultCredentialReference[];
|
|
332
|
+
}): Promise<VaultCredentialReference | undefined>;
|
|
333
|
+
export declare function verifyProviderAuthentication({ provider, credential, fetch: fetchImpl }: {
|
|
334
|
+
provider: ProviderInput;
|
|
335
|
+
credential: string;
|
|
336
|
+
fetch?: typeof fetch;
|
|
337
|
+
}): Promise<ProviderAuthenticationResult>;
|
|
338
|
+
export declare function providerCredentialFingerprint(provider: ProviderInput): string;
|
|
339
|
+
export declare function ensureProviderCredential(provider: ProviderInput, options?: EnsureProviderCredentialOptions): Promise<PreparedProviderCredential>;
|
|
251
340
|
/** Internal child mode: the key travels only through an authenticated loopback request. */
|
|
252
341
|
export declare function deliverVaultCredential(): Promise<void>;
|
|
253
342
|
export {};
|
package/dist/direct-launch.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SwitcherClient, type Provider, type Profile } from "./sdk";
|
|
2
|
-
import { type Model, type ModelPolicy } from "./domain";
|
|
2
|
+
import { type Catalog, type Model, type ModelPolicy } from "./domain";
|
|
3
3
|
import { type PresetOptions } from "./presets";
|
|
4
4
|
export declare function resolveLaunchProvider(client: SwitcherClient, selector: string, options?: PresetOptions): Promise<Provider>;
|
|
5
|
+
export declare function launchCatalog(client: SwitcherClient, provider: Provider, dryRun?: boolean): Promise<Catalog>;
|
|
5
6
|
export declare function selectModel(models: Model[], query?: string, harness?: Profile["harness"]): Promise<string>;
|
|
6
7
|
export declare function ensureLaunchProfile(client: SwitcherClient, provider: Provider, harness: Profile["harness"], model: string, modelPolicy?: ModelPolicy): Promise<Profile>;
|
package/dist/domain.d.ts
CHANGED
|
@@ -3,11 +3,21 @@ 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.2.
|
|
6
|
+
export declare const VERSION = "0.2.2";
|
|
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
|
+
export declare const credentialCheckSchema: z.ZodObject<{
|
|
12
|
+
method: z.ZodDefault<z.ZodEnum<["GET", "HEAD"]>>;
|
|
13
|
+
path: z.ZodEffects<z.ZodString, string, string>;
|
|
14
|
+
}, "strict", z.ZodTypeAny, {
|
|
15
|
+
path: string;
|
|
16
|
+
method: "GET" | "HEAD";
|
|
17
|
+
}, {
|
|
18
|
+
path: string;
|
|
19
|
+
method?: "GET" | "HEAD" | undefined;
|
|
20
|
+
}>;
|
|
11
21
|
export declare const expiresOnSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
12
22
|
export declare const modelSchema: z.ZodObject<{
|
|
13
23
|
id: z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -56,6 +66,16 @@ export declare const providerInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
56
66
|
protocol: z.ZodEnum<["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]>;
|
|
57
67
|
credentialEnv: z.ZodOptional<z.ZodString>;
|
|
58
68
|
authStyle: z.ZodDefault<z.ZodEnum<["bearer", "x-api-key", "api-key"]>>;
|
|
69
|
+
credentialCheck: z.ZodOptional<z.ZodObject<{
|
|
70
|
+
method: z.ZodDefault<z.ZodEnum<["GET", "HEAD"]>>;
|
|
71
|
+
path: z.ZodEffects<z.ZodString, string, string>;
|
|
72
|
+
}, "strict", z.ZodTypeAny, {
|
|
73
|
+
path: string;
|
|
74
|
+
method: "GET" | "HEAD";
|
|
75
|
+
}, {
|
|
76
|
+
path: string;
|
|
77
|
+
method?: "GET" | "HEAD" | undefined;
|
|
78
|
+
}>>;
|
|
59
79
|
catalogBaseUrl: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
60
80
|
catalogFormat: z.ZodOptional<z.ZodEnum<["openai", "ollama", "mistral", "together", "fireworks", "dashscope", "gemini", "none"]>>;
|
|
61
81
|
catalogAuthStyle: z.ZodOptional<z.ZodEnum<["bearer", "x-api-key", "api-key", "none"]>>;
|
|
@@ -164,6 +184,10 @@ export declare const providerInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
164
184
|
supportedGenerationMethods?: string[] | undefined;
|
|
165
185
|
}[];
|
|
166
186
|
credentialEnv?: string | undefined;
|
|
187
|
+
credentialCheck?: {
|
|
188
|
+
path: string;
|
|
189
|
+
method: "GET" | "HEAD";
|
|
190
|
+
} | undefined;
|
|
167
191
|
catalogBaseUrl?: string | undefined;
|
|
168
192
|
catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none" | undefined;
|
|
169
193
|
catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none" | undefined;
|
|
@@ -190,6 +214,10 @@ export declare const providerInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
190
214
|
protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
|
|
191
215
|
credentialEnv?: string | undefined;
|
|
192
216
|
authStyle?: "bearer" | "x-api-key" | "api-key" | undefined;
|
|
217
|
+
credentialCheck?: {
|
|
218
|
+
path: string;
|
|
219
|
+
method?: "GET" | "HEAD" | undefined;
|
|
220
|
+
} | undefined;
|
|
193
221
|
catalogBaseUrl?: string | undefined;
|
|
194
222
|
catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none" | undefined;
|
|
195
223
|
catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none" | undefined;
|
|
@@ -246,6 +274,10 @@ export declare const providerInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
246
274
|
supportedGenerationMethods?: string[] | undefined;
|
|
247
275
|
}[];
|
|
248
276
|
credentialEnv?: string | undefined;
|
|
277
|
+
credentialCheck?: {
|
|
278
|
+
path: string;
|
|
279
|
+
method: "GET" | "HEAD";
|
|
280
|
+
} | undefined;
|
|
249
281
|
catalogBaseUrl?: string | undefined;
|
|
250
282
|
catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none" | undefined;
|
|
251
283
|
catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none" | undefined;
|
|
@@ -272,6 +304,10 @@ export declare const providerInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
272
304
|
protocol: "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
|
|
273
305
|
credentialEnv?: string | undefined;
|
|
274
306
|
authStyle?: "bearer" | "x-api-key" | "api-key" | undefined;
|
|
307
|
+
credentialCheck?: {
|
|
308
|
+
path: string;
|
|
309
|
+
method?: "GET" | "HEAD" | undefined;
|
|
310
|
+
} | undefined;
|
|
275
311
|
catalogBaseUrl?: string | undefined;
|
|
276
312
|
catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none" | undefined;
|
|
277
313
|
catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none" | undefined;
|
|
@@ -316,6 +352,16 @@ export declare const providerPresetSchema: z.ZodObject<{
|
|
|
316
352
|
protocol: z.ZodEnum<["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]>;
|
|
317
353
|
baseUrl: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
318
354
|
authStyle: z.ZodEnum<["bearer", "x-api-key", "api-key"]>;
|
|
355
|
+
credentialCheck: z.ZodOptional<z.ZodObject<{
|
|
356
|
+
method: z.ZodDefault<z.ZodEnum<["GET", "HEAD"]>>;
|
|
357
|
+
path: z.ZodEffects<z.ZodString, string, string>;
|
|
358
|
+
}, "strict", z.ZodTypeAny, {
|
|
359
|
+
path: string;
|
|
360
|
+
method: "GET" | "HEAD";
|
|
361
|
+
}, {
|
|
362
|
+
path: string;
|
|
363
|
+
method?: "GET" | "HEAD" | undefined;
|
|
364
|
+
}>>;
|
|
319
365
|
catalogBaseUrl: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
320
366
|
catalogFormat: z.ZodEnum<["openai", "ollama", "mistral", "together", "fireworks", "dashscope", "gemini", "none"]>;
|
|
321
367
|
catalogAuthStyle: z.ZodOptional<z.ZodEnum<["bearer", "x-api-key", "api-key", "none"]>>;
|
|
@@ -328,6 +374,10 @@ export declare const providerPresetSchema: z.ZodObject<{
|
|
|
328
374
|
modelsPath: string;
|
|
329
375
|
notes: string[];
|
|
330
376
|
baseUrl?: string | undefined;
|
|
377
|
+
credentialCheck?: {
|
|
378
|
+
path: string;
|
|
379
|
+
method: "GET" | "HEAD";
|
|
380
|
+
} | undefined;
|
|
331
381
|
catalogBaseUrl?: string | undefined;
|
|
332
382
|
catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none" | undefined;
|
|
333
383
|
}, {
|
|
@@ -337,6 +387,10 @@ export declare const providerPresetSchema: z.ZodObject<{
|
|
|
337
387
|
modelsPath: string;
|
|
338
388
|
notes: string[];
|
|
339
389
|
baseUrl?: string | undefined;
|
|
390
|
+
credentialCheck?: {
|
|
391
|
+
path: string;
|
|
392
|
+
method?: "GET" | "HEAD" | undefined;
|
|
393
|
+
} | undefined;
|
|
340
394
|
catalogBaseUrl?: string | undefined;
|
|
341
395
|
catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none" | undefined;
|
|
342
396
|
}>, "many">;
|
|
@@ -353,6 +407,10 @@ export declare const providerPresetSchema: z.ZodObject<{
|
|
|
353
407
|
modelsPath: string;
|
|
354
408
|
notes: string[];
|
|
355
409
|
baseUrl?: string | undefined;
|
|
410
|
+
credentialCheck?: {
|
|
411
|
+
path: string;
|
|
412
|
+
method: "GET" | "HEAD";
|
|
413
|
+
} | undefined;
|
|
356
414
|
catalogBaseUrl?: string | undefined;
|
|
357
415
|
catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none" | undefined;
|
|
358
416
|
}[];
|
|
@@ -370,6 +428,10 @@ export declare const providerPresetSchema: z.ZodObject<{
|
|
|
370
428
|
modelsPath: string;
|
|
371
429
|
notes: string[];
|
|
372
430
|
baseUrl?: string | undefined;
|
|
431
|
+
credentialCheck?: {
|
|
432
|
+
path: string;
|
|
433
|
+
method?: "GET" | "HEAD" | undefined;
|
|
434
|
+
} | undefined;
|
|
373
435
|
catalogBaseUrl?: string | undefined;
|
|
374
436
|
catalogAuthStyle?: "bearer" | "x-api-key" | "api-key" | "none" | undefined;
|
|
375
437
|
}[];
|
package/dist/generated/api.d.ts
CHANGED
|
@@ -254,6 +254,14 @@ export interface components {
|
|
|
254
254
|
baseUrl?: string;
|
|
255
255
|
/** @enum {string} */
|
|
256
256
|
authStyle: "bearer" | "x-api-key" | "api-key";
|
|
257
|
+
credentialCheck?: {
|
|
258
|
+
/**
|
|
259
|
+
* @default GET
|
|
260
|
+
* @enum {string}
|
|
261
|
+
*/
|
|
262
|
+
method: "GET" | "HEAD";
|
|
263
|
+
path: string;
|
|
264
|
+
};
|
|
257
265
|
catalogBaseUrl?: string;
|
|
258
266
|
/** @enum {string} */
|
|
259
267
|
catalogFormat: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
|
|
@@ -278,6 +286,14 @@ export interface components {
|
|
|
278
286
|
* @enum {string}
|
|
279
287
|
*/
|
|
280
288
|
authStyle: "bearer" | "x-api-key" | "api-key";
|
|
289
|
+
credentialCheck?: {
|
|
290
|
+
/**
|
|
291
|
+
* @default GET
|
|
292
|
+
* @enum {string}
|
|
293
|
+
*/
|
|
294
|
+
method: "GET" | "HEAD";
|
|
295
|
+
path: string;
|
|
296
|
+
};
|
|
281
297
|
catalogBaseUrl?: string;
|
|
282
298
|
/** @enum {string} */
|
|
283
299
|
catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
|
|
@@ -329,6 +345,14 @@ export interface components {
|
|
|
329
345
|
* @enum {string}
|
|
330
346
|
*/
|
|
331
347
|
authStyle: "bearer" | "x-api-key" | "api-key";
|
|
348
|
+
credentialCheck?: {
|
|
349
|
+
/**
|
|
350
|
+
* @default GET
|
|
351
|
+
* @enum {string}
|
|
352
|
+
*/
|
|
353
|
+
method: "GET" | "HEAD";
|
|
354
|
+
path: string;
|
|
355
|
+
};
|
|
332
356
|
catalogBaseUrl?: string;
|
|
333
357
|
/** @enum {string} */
|
|
334
358
|
catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
|
|
@@ -546,6 +570,14 @@ export interface components {
|
|
|
546
570
|
* @enum {string}
|
|
547
571
|
*/
|
|
548
572
|
authStyle: "bearer" | "x-api-key" | "api-key";
|
|
573
|
+
credentialCheck?: {
|
|
574
|
+
/**
|
|
575
|
+
* @default GET
|
|
576
|
+
* @enum {string}
|
|
577
|
+
*/
|
|
578
|
+
method: "GET" | "HEAD";
|
|
579
|
+
path: string;
|
|
580
|
+
};
|
|
549
581
|
catalogBaseUrl?: string;
|
|
550
582
|
/** @enum {string} */
|
|
551
583
|
catalogFormat?: "openai" | "ollama" | "mistral" | "together" | "fireworks" | "dashscope" | "gemini" | "none";
|
package/dist/index.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,
|
package/dist/launcher.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export type LaunchOptions = {
|
|
|
21
21
|
timeoutMs?: number;
|
|
22
22
|
refresh?: boolean;
|
|
23
23
|
credentialEnv?: NodeJS.ProcessEnv;
|
|
24
|
+
credentialPreflight?: string;
|
|
24
25
|
resolveCredential?: (provider: ProviderInput) => Promise<string | undefined>;
|
|
25
26
|
};
|
|
26
27
|
type OriPreparationOptions = Pick<LaunchOptions, "oriExecutable" | "args" | "resolveCredential" | "credentialEnv"> & {
|