@hasna/switcher 0.1.2 → 0.1.4
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 +20 -8
- package/dist/cli/index.js +2725 -621
- package/dist/cli.d.ts +2 -0
- package/dist/codex-model-policy.d.ts +65 -0
- package/dist/credentials.d.ts +71 -8
- package/dist/direct-launch.d.ts +2 -2
- package/dist/domain.d.ts +259 -2
- package/dist/gemini-model-policy.d.ts +56 -0
- package/dist/generated/api.d.ts +192 -0
- package/dist/harness-types.d.ts +9 -0
- package/dist/hermes-model-policy.d.ts +30 -0
- package/dist/index.js +138 -48
- package/dist/inference-gateway.d.ts +24 -0
- package/dist/launcher.d.ts +8 -3
- package/dist/mcp/index.js +153 -62
- package/dist/model-policy-schema.d.ts +137 -0
- package/dist/model-policy.d.ts +31 -0
- package/dist/native-model-policy.d.ts +23 -0
- package/dist/opencode-model-policy.d.ts +33 -0
- package/dist/ori-model-policy.d.ts +8 -0
- package/dist/sdk.d.ts +248 -6
- package/dist/sdk.js +138 -48
- package/dist/serve/index.js +1044 -88
- package/docs/MODEL-POLICY.md +82 -0
- package/openapi.json +836 -1
- package/package.json +3 -2
package/dist/cli.d.ts
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type ModelPolicy } from "./model-policy-schema";
|
|
2
|
+
type Dict = Record<string, unknown>;
|
|
3
|
+
/** Keys which can redirect a Codex request outside Switcher's launch provider. */
|
|
4
|
+
export declare const codexRoutingKeys: Set<string>;
|
|
5
|
+
export declare const codexTransportKeys: Set<string>;
|
|
6
|
+
export type CodexAgentInput = {
|
|
7
|
+
description?: string;
|
|
8
|
+
config_file?: string;
|
|
9
|
+
nickname_candidates?: string[];
|
|
10
|
+
/** Parsed contents of config_file. The caller reads native config layers. */
|
|
11
|
+
config?: Dict;
|
|
12
|
+
trusted?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type CodexModelPolicyInput = {
|
|
15
|
+
model: string;
|
|
16
|
+
policy?: ModelPolicy;
|
|
17
|
+
/** Effective native global/project config, after Codex precedence is applied. */
|
|
18
|
+
effectiveConfig?: Dict;
|
|
19
|
+
agents?: Record<string, CodexAgentInput>;
|
|
20
|
+
switcherProvider: string;
|
|
21
|
+
switcherBaseUrl: string;
|
|
22
|
+
/** Project config is never activated unless the caller has established trust. */
|
|
23
|
+
trustedProject?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type CodexAgentOverride = {
|
|
26
|
+
name: string;
|
|
27
|
+
model: string;
|
|
28
|
+
config: Dict;
|
|
29
|
+
sourceConfigFile?: string;
|
|
30
|
+
trusted: boolean;
|
|
31
|
+
};
|
|
32
|
+
export type CodexModelPolicyResult = {
|
|
33
|
+
model: string;
|
|
34
|
+
subagentModel: string;
|
|
35
|
+
reviewModel: string;
|
|
36
|
+
provider: {
|
|
37
|
+
name: string;
|
|
38
|
+
base_url: string;
|
|
39
|
+
};
|
|
40
|
+
/** Structured -c values; the launcher serializes these as TOML. */
|
|
41
|
+
overrides: Record<string, unknown>;
|
|
42
|
+
agents: CodexAgentOverride[];
|
|
43
|
+
ignoredUntrustedAgents: string[];
|
|
44
|
+
};
|
|
45
|
+
/** Extract named role declarations from an already merged native config layer. */
|
|
46
|
+
export declare function codexAgentsFromEffectiveConfig(config: Dict, trustedProject?: boolean, baseDir?: string): Record<string, CodexAgentInput>;
|
|
47
|
+
/** Compile only routing controls; native instructions, permissions and descriptions remain intact. */
|
|
48
|
+
export declare function compileCodexModelPolicy(input: CodexModelPolicyInput): CodexModelPolicyResult;
|
|
49
|
+
/** Small deterministic TOML writer for the copied, sanitized agent config layer. */
|
|
50
|
+
export declare function renderCodexAgentToml(config: Dict): string;
|
|
51
|
+
/** Copy sanitized role layers into the per-launch state directory. */
|
|
52
|
+
export declare function writeCodexAgentOverrides(result: CodexModelPolicyResult, stateDir: string): Promise<Record<string, string>>;
|
|
53
|
+
export type PrepareCodexModelPolicyInput = Omit<CodexModelPolicyInput, "effectiveConfig" | "agents"> & {
|
|
54
|
+
cwd: string;
|
|
55
|
+
stateDir: string;
|
|
56
|
+
home?: string;
|
|
57
|
+
};
|
|
58
|
+
/** Load global Codex config plus trusted .codex/config.toml ancestors, then prepare role layers. */
|
|
59
|
+
export declare function prepareCodexModelPolicy(input: PrepareCodexModelPolicyInput): Promise<CodexModelPolicyResult & {
|
|
60
|
+
agentConfigPaths: Record<string, string>;
|
|
61
|
+
configPaths: string[];
|
|
62
|
+
}>;
|
|
63
|
+
/** Read a referenced role layer without activating it; callers must establish project trust. */
|
|
64
|
+
export declare function readCodexAgentConfig(path: string): Promise<Dict>;
|
|
65
|
+
export {};
|
package/dist/credentials.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type CredentialChainOptions } from "@hasna/contracts/client";
|
|
2
3
|
import { CommandInterrupted, type ProviderInput } from "./domain";
|
|
3
4
|
declare const keychain: z.ZodObject<{
|
|
4
5
|
kind: z.ZodLiteral<"keychain">;
|
|
@@ -13,7 +14,7 @@ declare const keychain: z.ZodObject<{
|
|
|
13
14
|
service: string;
|
|
14
15
|
account: string;
|
|
15
16
|
}>;
|
|
16
|
-
export declare const credentialBindingSchema: z.ZodObject<{
|
|
17
|
+
export declare const credentialBindingSchema: z.ZodEffects<z.ZodObject<{
|
|
17
18
|
schema: z.ZodLiteral<1>;
|
|
18
19
|
credentialEnv: z.ZodString;
|
|
19
20
|
origins: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
@@ -32,9 +33,15 @@ export declare const credentialBindingSchema: z.ZodObject<{
|
|
|
32
33
|
}>, z.ZodObject<{
|
|
33
34
|
kind: z.ZodLiteral<"vault">;
|
|
34
35
|
key: z.ZodString;
|
|
35
|
-
url: z.ZodEffects<z.ZodString, string, string
|
|
36
|
+
url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
36
37
|
executable: z.ZodEffects<z.ZodString, string, string>;
|
|
37
38
|
operator: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
39
|
+
kind: z.ZodLiteral<"contracts">;
|
|
40
|
+
}, "strict", z.ZodTypeAny, {
|
|
41
|
+
kind: "contracts";
|
|
42
|
+
}, {
|
|
43
|
+
kind: "contracts";
|
|
44
|
+
}>, z.ZodObject<{
|
|
38
45
|
kind: z.ZodLiteral<"env">;
|
|
39
46
|
}, "strict", z.ZodTypeAny, {
|
|
40
47
|
kind: "env";
|
|
@@ -42,7 +49,7 @@ export declare const credentialBindingSchema: z.ZodObject<{
|
|
|
42
49
|
kind: "env";
|
|
43
50
|
}>, z.ZodObject<{
|
|
44
51
|
kind: z.ZodLiteral<"keychain">;
|
|
45
|
-
account: z.ZodString
|
|
52
|
+
account: z.ZodEffects<z.ZodString, string, string>;
|
|
46
53
|
}, "strict", z.ZodTypeAny, {
|
|
47
54
|
kind: "keychain";
|
|
48
55
|
account: string;
|
|
@@ -51,27 +58,31 @@ export declare const credentialBindingSchema: z.ZodObject<{
|
|
|
51
58
|
account: string;
|
|
52
59
|
}>]>;
|
|
53
60
|
}, "strict", z.ZodTypeAny, {
|
|
54
|
-
url: string;
|
|
55
61
|
key: string;
|
|
56
62
|
executable: string;
|
|
57
63
|
kind: "vault";
|
|
58
64
|
operator: {
|
|
65
|
+
kind: "contracts";
|
|
66
|
+
} | {
|
|
59
67
|
kind: "env";
|
|
60
68
|
} | {
|
|
61
69
|
kind: "keychain";
|
|
62
70
|
account: string;
|
|
63
71
|
};
|
|
72
|
+
url?: string | undefined;
|
|
64
73
|
}, {
|
|
65
|
-
url: string;
|
|
66
74
|
key: string;
|
|
67
75
|
executable: string;
|
|
68
76
|
kind: "vault";
|
|
69
77
|
operator: {
|
|
78
|
+
kind: "contracts";
|
|
79
|
+
} | {
|
|
70
80
|
kind: "env";
|
|
71
81
|
} | {
|
|
72
82
|
kind: "keychain";
|
|
73
83
|
account: string;
|
|
74
84
|
};
|
|
85
|
+
url?: string | undefined;
|
|
75
86
|
}>]>;
|
|
76
87
|
}, "strict", z.ZodTypeAny, {
|
|
77
88
|
credentialEnv: string;
|
|
@@ -80,16 +91,18 @@ export declare const credentialBindingSchema: z.ZodObject<{
|
|
|
80
91
|
service: string;
|
|
81
92
|
account: string;
|
|
82
93
|
} | {
|
|
83
|
-
url: string;
|
|
84
94
|
key: string;
|
|
85
95
|
executable: string;
|
|
86
96
|
kind: "vault";
|
|
87
97
|
operator: {
|
|
98
|
+
kind: "contracts";
|
|
99
|
+
} | {
|
|
88
100
|
kind: "env";
|
|
89
101
|
} | {
|
|
90
102
|
kind: "keychain";
|
|
91
103
|
account: string;
|
|
92
104
|
};
|
|
105
|
+
url?: string | undefined;
|
|
93
106
|
};
|
|
94
107
|
schema: 1;
|
|
95
108
|
origins: string[];
|
|
@@ -100,16 +113,62 @@ export declare const credentialBindingSchema: z.ZodObject<{
|
|
|
100
113
|
service: string;
|
|
101
114
|
account: string;
|
|
102
115
|
} | {
|
|
103
|
-
url: string;
|
|
104
116
|
key: string;
|
|
105
117
|
executable: string;
|
|
106
118
|
kind: "vault";
|
|
107
119
|
operator: {
|
|
120
|
+
kind: "contracts";
|
|
121
|
+
} | {
|
|
108
122
|
kind: "env";
|
|
109
123
|
} | {
|
|
110
124
|
kind: "keychain";
|
|
111
125
|
account: string;
|
|
112
126
|
};
|
|
127
|
+
url?: string | undefined;
|
|
128
|
+
};
|
|
129
|
+
schema: 1;
|
|
130
|
+
origins: string[];
|
|
131
|
+
}>, {
|
|
132
|
+
credentialEnv: string;
|
|
133
|
+
source: {
|
|
134
|
+
kind: "keychain";
|
|
135
|
+
service: string;
|
|
136
|
+
account: string;
|
|
137
|
+
} | {
|
|
138
|
+
key: string;
|
|
139
|
+
executable: string;
|
|
140
|
+
kind: "vault";
|
|
141
|
+
operator: {
|
|
142
|
+
kind: "contracts";
|
|
143
|
+
} | {
|
|
144
|
+
kind: "env";
|
|
145
|
+
} | {
|
|
146
|
+
kind: "keychain";
|
|
147
|
+
account: string;
|
|
148
|
+
};
|
|
149
|
+
url?: string | undefined;
|
|
150
|
+
};
|
|
151
|
+
schema: 1;
|
|
152
|
+
origins: string[];
|
|
153
|
+
}, {
|
|
154
|
+
credentialEnv: string;
|
|
155
|
+
source: {
|
|
156
|
+
kind: "keychain";
|
|
157
|
+
service: string;
|
|
158
|
+
account: string;
|
|
159
|
+
} | {
|
|
160
|
+
key: string;
|
|
161
|
+
executable: string;
|
|
162
|
+
kind: "vault";
|
|
163
|
+
operator: {
|
|
164
|
+
kind: "contracts";
|
|
165
|
+
} | {
|
|
166
|
+
kind: "env";
|
|
167
|
+
} | {
|
|
168
|
+
kind: "keychain";
|
|
169
|
+
account: string;
|
|
170
|
+
};
|
|
171
|
+
url?: string | undefined;
|
|
113
172
|
};
|
|
114
173
|
schema: 1;
|
|
115
174
|
origins: string[];
|
|
@@ -130,16 +189,18 @@ export declare class CredentialBindings {
|
|
|
130
189
|
service: string;
|
|
131
190
|
account: string;
|
|
132
191
|
} | {
|
|
133
|
-
url: string;
|
|
134
192
|
key: string;
|
|
135
193
|
executable: string;
|
|
136
194
|
kind: "vault";
|
|
137
195
|
operator: {
|
|
196
|
+
kind: "contracts";
|
|
197
|
+
} | {
|
|
138
198
|
kind: "env";
|
|
139
199
|
} | {
|
|
140
200
|
kind: "keychain";
|
|
141
201
|
account: string;
|
|
142
202
|
};
|
|
203
|
+
url?: string | undefined;
|
|
143
204
|
};
|
|
144
205
|
schema: 1;
|
|
145
206
|
origins: string[];
|
|
@@ -173,6 +234,8 @@ export declare class CredentialResolver {
|
|
|
173
234
|
export declare class CredentialInterrupted extends CommandInterrupted {
|
|
174
235
|
constructor(exitCode: number);
|
|
175
236
|
}
|
|
237
|
+
/** Select an operator through the shared credential seam, then pin that choice. */
|
|
238
|
+
export declare function vaultEnvironment(binding: CredentialBinding, env: NodeJS.ProcessEnv, options?: Pick<CredentialChainOptions, "keychain">): Promise<NodeJS.ProcessEnv>;
|
|
176
239
|
/** Internal child mode: the key travels only through an authenticated loopback request. */
|
|
177
240
|
export declare function deliverVaultCredential(): Promise<void>;
|
|
178
241
|
export {};
|
package/dist/direct-launch.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SwitcherClient, type Provider, type Profile } from "./sdk";
|
|
2
|
-
import { type Model } from "./domain";
|
|
2
|
+
import { 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
5
|
export declare function selectModel(models: Model[], query?: string, harness?: Profile["harness"]): Promise<string>;
|
|
6
|
-
export declare function ensureLaunchProfile(client: SwitcherClient, provider: Provider, harness: Profile["harness"], model: string): Promise<Profile>;
|
|
6
|
+
export declare function ensureLaunchProfile(client: SwitcherClient, provider: Provider, harness: Profile["harness"], model: string, modelPolicy?: ModelPolicy): Promise<Profile>;
|
package/dist/domain.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type RoutingEvent } from "./model-policy-schema";
|
|
3
|
+
export { modelPolicySchema, routingEventSchema, routingEventsSchema } from "./model-policy-schema";
|
|
4
|
+
export type { ModelPolicy, RoutingEvent } from "./model-policy-schema";
|
|
2
5
|
export type { AuthStyle } from "./auth";
|
|
3
|
-
export declare const VERSION = "0.1.
|
|
6
|
+
export declare const VERSION = "0.1.4";
|
|
4
7
|
export declare const harnessSchema: z.ZodEnum<["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]>;
|
|
5
8
|
export declare const protocolSchema: z.ZodEnum<["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]>;
|
|
6
9
|
export declare const idSchema: z.ZodString;
|
|
@@ -264,44 +267,295 @@ export declare const profileInputSchema: z.ZodObject<{
|
|
|
264
267
|
providerId: z.ZodString;
|
|
265
268
|
harness: z.ZodEnum<["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]>;
|
|
266
269
|
model: z.ZodString;
|
|
270
|
+
modelPolicy: z.ZodOptional<z.ZodObject<{
|
|
271
|
+
version: z.ZodDefault<z.ZodLiteral<1>>;
|
|
272
|
+
roles: z.ZodOptional<z.ZodObject<{
|
|
273
|
+
subagent: z.ZodOptional<z.ZodString>;
|
|
274
|
+
fast: z.ZodOptional<z.ZodString>;
|
|
275
|
+
planning: z.ZodOptional<z.ZodString>;
|
|
276
|
+
review: z.ZodOptional<z.ZodString>;
|
|
277
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
278
|
+
compaction: z.ZodOptional<z.ZodString>;
|
|
279
|
+
weak: z.ZodOptional<z.ZodString>;
|
|
280
|
+
editor: z.ZodOptional<z.ZodString>;
|
|
281
|
+
}, "strict", z.ZodTypeAny, {
|
|
282
|
+
subagent?: string | undefined;
|
|
283
|
+
fast?: string | undefined;
|
|
284
|
+
planning?: string | undefined;
|
|
285
|
+
review?: string | undefined;
|
|
286
|
+
summary?: string | undefined;
|
|
287
|
+
compaction?: string | undefined;
|
|
288
|
+
weak?: string | undefined;
|
|
289
|
+
editor?: string | undefined;
|
|
290
|
+
}, {
|
|
291
|
+
subagent?: string | undefined;
|
|
292
|
+
fast?: string | undefined;
|
|
293
|
+
planning?: string | undefined;
|
|
294
|
+
review?: string | undefined;
|
|
295
|
+
summary?: string | undefined;
|
|
296
|
+
compaction?: string | undefined;
|
|
297
|
+
weak?: string | undefined;
|
|
298
|
+
editor?: string | undefined;
|
|
299
|
+
}>>;
|
|
300
|
+
allowedModels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
301
|
+
aliases: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodString>, Record<string, string>, Record<string, string>>>;
|
|
302
|
+
fallbacks: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>, Record<string, string[]>, Record<string, string[]>>>;
|
|
303
|
+
}, "strict", z.ZodTypeAny, {
|
|
304
|
+
version: 1;
|
|
305
|
+
roles?: {
|
|
306
|
+
subagent?: string | undefined;
|
|
307
|
+
fast?: string | undefined;
|
|
308
|
+
planning?: string | undefined;
|
|
309
|
+
review?: string | undefined;
|
|
310
|
+
summary?: string | undefined;
|
|
311
|
+
compaction?: string | undefined;
|
|
312
|
+
weak?: string | undefined;
|
|
313
|
+
editor?: string | undefined;
|
|
314
|
+
} | undefined;
|
|
315
|
+
allowedModels?: string[] | undefined;
|
|
316
|
+
aliases?: Record<string, string> | undefined;
|
|
317
|
+
fallbacks?: Record<string, string[]> | undefined;
|
|
318
|
+
}, {
|
|
319
|
+
version?: 1 | undefined;
|
|
320
|
+
roles?: {
|
|
321
|
+
subagent?: string | undefined;
|
|
322
|
+
fast?: string | undefined;
|
|
323
|
+
planning?: string | undefined;
|
|
324
|
+
review?: string | undefined;
|
|
325
|
+
summary?: string | undefined;
|
|
326
|
+
compaction?: string | undefined;
|
|
327
|
+
weak?: string | undefined;
|
|
328
|
+
editor?: string | undefined;
|
|
329
|
+
} | undefined;
|
|
330
|
+
allowedModels?: string[] | undefined;
|
|
331
|
+
aliases?: Record<string, string> | undefined;
|
|
332
|
+
fallbacks?: Record<string, string[]> | undefined;
|
|
333
|
+
}>>;
|
|
267
334
|
}, "strict", z.ZodTypeAny, {
|
|
268
335
|
id: string;
|
|
269
336
|
name: string;
|
|
270
337
|
providerId: string;
|
|
271
338
|
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "aider" | "kilo";
|
|
272
339
|
model: string;
|
|
340
|
+
modelPolicy?: {
|
|
341
|
+
version: 1;
|
|
342
|
+
roles?: {
|
|
343
|
+
subagent?: string | undefined;
|
|
344
|
+
fast?: string | undefined;
|
|
345
|
+
planning?: string | undefined;
|
|
346
|
+
review?: string | undefined;
|
|
347
|
+
summary?: string | undefined;
|
|
348
|
+
compaction?: string | undefined;
|
|
349
|
+
weak?: string | undefined;
|
|
350
|
+
editor?: string | undefined;
|
|
351
|
+
} | undefined;
|
|
352
|
+
allowedModels?: string[] | undefined;
|
|
353
|
+
aliases?: Record<string, string> | undefined;
|
|
354
|
+
fallbacks?: Record<string, string[]> | undefined;
|
|
355
|
+
} | undefined;
|
|
273
356
|
}, {
|
|
274
357
|
id: string;
|
|
275
358
|
name: string;
|
|
276
359
|
providerId: string;
|
|
277
360
|
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "aider" | "kilo";
|
|
278
361
|
model: string;
|
|
362
|
+
modelPolicy?: {
|
|
363
|
+
version?: 1 | undefined;
|
|
364
|
+
roles?: {
|
|
365
|
+
subagent?: string | undefined;
|
|
366
|
+
fast?: string | undefined;
|
|
367
|
+
planning?: string | undefined;
|
|
368
|
+
review?: string | undefined;
|
|
369
|
+
summary?: string | undefined;
|
|
370
|
+
compaction?: string | undefined;
|
|
371
|
+
weak?: string | undefined;
|
|
372
|
+
editor?: string | undefined;
|
|
373
|
+
} | undefined;
|
|
374
|
+
allowedModels?: string[] | undefined;
|
|
375
|
+
aliases?: Record<string, string> | undefined;
|
|
376
|
+
fallbacks?: Record<string, string[]> | undefined;
|
|
377
|
+
} | undefined;
|
|
279
378
|
}>;
|
|
280
379
|
export declare const runInputSchema: z.ZodObject<{
|
|
380
|
+
modelPolicyVersion: z.ZodLiteral<1>;
|
|
281
381
|
profileId: z.ZodString;
|
|
282
382
|
harness: z.ZodEnum<["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]>;
|
|
283
383
|
model: z.ZodString;
|
|
384
|
+
modelPolicy: z.ZodOptional<z.ZodObject<{
|
|
385
|
+
version: z.ZodDefault<z.ZodLiteral<1>>;
|
|
386
|
+
roles: z.ZodOptional<z.ZodObject<{
|
|
387
|
+
subagent: z.ZodOptional<z.ZodString>;
|
|
388
|
+
fast: z.ZodOptional<z.ZodString>;
|
|
389
|
+
planning: z.ZodOptional<z.ZodString>;
|
|
390
|
+
review: z.ZodOptional<z.ZodString>;
|
|
391
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
392
|
+
compaction: z.ZodOptional<z.ZodString>;
|
|
393
|
+
weak: z.ZodOptional<z.ZodString>;
|
|
394
|
+
editor: z.ZodOptional<z.ZodString>;
|
|
395
|
+
}, "strict", z.ZodTypeAny, {
|
|
396
|
+
subagent?: string | undefined;
|
|
397
|
+
fast?: string | undefined;
|
|
398
|
+
planning?: string | undefined;
|
|
399
|
+
review?: string | undefined;
|
|
400
|
+
summary?: string | undefined;
|
|
401
|
+
compaction?: string | undefined;
|
|
402
|
+
weak?: string | undefined;
|
|
403
|
+
editor?: string | undefined;
|
|
404
|
+
}, {
|
|
405
|
+
subagent?: string | undefined;
|
|
406
|
+
fast?: string | undefined;
|
|
407
|
+
planning?: string | undefined;
|
|
408
|
+
review?: string | undefined;
|
|
409
|
+
summary?: string | undefined;
|
|
410
|
+
compaction?: string | undefined;
|
|
411
|
+
weak?: string | undefined;
|
|
412
|
+
editor?: string | undefined;
|
|
413
|
+
}>>;
|
|
414
|
+
allowedModels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
415
|
+
aliases: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodString>, Record<string, string>, Record<string, string>>>;
|
|
416
|
+
fallbacks: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>, Record<string, string[]>, Record<string, string[]>>>;
|
|
417
|
+
}, "strict", z.ZodTypeAny, {
|
|
418
|
+
version: 1;
|
|
419
|
+
roles?: {
|
|
420
|
+
subagent?: string | undefined;
|
|
421
|
+
fast?: string | undefined;
|
|
422
|
+
planning?: string | undefined;
|
|
423
|
+
review?: string | undefined;
|
|
424
|
+
summary?: string | undefined;
|
|
425
|
+
compaction?: string | undefined;
|
|
426
|
+
weak?: string | undefined;
|
|
427
|
+
editor?: string | undefined;
|
|
428
|
+
} | undefined;
|
|
429
|
+
allowedModels?: string[] | undefined;
|
|
430
|
+
aliases?: Record<string, string> | undefined;
|
|
431
|
+
fallbacks?: Record<string, string[]> | undefined;
|
|
432
|
+
}, {
|
|
433
|
+
version?: 1 | undefined;
|
|
434
|
+
roles?: {
|
|
435
|
+
subagent?: string | undefined;
|
|
436
|
+
fast?: string | undefined;
|
|
437
|
+
planning?: string | undefined;
|
|
438
|
+
review?: string | undefined;
|
|
439
|
+
summary?: string | undefined;
|
|
440
|
+
compaction?: string | undefined;
|
|
441
|
+
weak?: string | undefined;
|
|
442
|
+
editor?: string | undefined;
|
|
443
|
+
} | undefined;
|
|
444
|
+
allowedModels?: string[] | undefined;
|
|
445
|
+
aliases?: Record<string, string> | undefined;
|
|
446
|
+
fallbacks?: Record<string, string[]> | undefined;
|
|
447
|
+
}>>;
|
|
284
448
|
planToken: z.ZodString;
|
|
285
449
|
}, "strict", z.ZodTypeAny, {
|
|
286
450
|
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "aider" | "kilo";
|
|
287
451
|
model: string;
|
|
452
|
+
modelPolicyVersion: 1;
|
|
288
453
|
profileId: string;
|
|
289
454
|
planToken: string;
|
|
455
|
+
modelPolicy?: {
|
|
456
|
+
version: 1;
|
|
457
|
+
roles?: {
|
|
458
|
+
subagent?: string | undefined;
|
|
459
|
+
fast?: string | undefined;
|
|
460
|
+
planning?: string | undefined;
|
|
461
|
+
review?: string | undefined;
|
|
462
|
+
summary?: string | undefined;
|
|
463
|
+
compaction?: string | undefined;
|
|
464
|
+
weak?: string | undefined;
|
|
465
|
+
editor?: string | undefined;
|
|
466
|
+
} | undefined;
|
|
467
|
+
allowedModels?: string[] | undefined;
|
|
468
|
+
aliases?: Record<string, string> | undefined;
|
|
469
|
+
fallbacks?: Record<string, string[]> | undefined;
|
|
470
|
+
} | undefined;
|
|
290
471
|
}, {
|
|
291
472
|
harness: "gemini" | "claude" | "codex" | "grok" | "opencode" | "opencode2" | "pi" | "omp" | "dsh" | "cline" | "hermes" | "prime-agent" | "aider" | "kilo";
|
|
292
473
|
model: string;
|
|
474
|
+
modelPolicyVersion: 1;
|
|
293
475
|
profileId: string;
|
|
294
476
|
planToken: string;
|
|
477
|
+
modelPolicy?: {
|
|
478
|
+
version?: 1 | undefined;
|
|
479
|
+
roles?: {
|
|
480
|
+
subagent?: string | undefined;
|
|
481
|
+
fast?: string | undefined;
|
|
482
|
+
planning?: string | undefined;
|
|
483
|
+
review?: string | undefined;
|
|
484
|
+
summary?: string | undefined;
|
|
485
|
+
compaction?: string | undefined;
|
|
486
|
+
weak?: string | undefined;
|
|
487
|
+
editor?: string | undefined;
|
|
488
|
+
} | undefined;
|
|
489
|
+
allowedModels?: string[] | undefined;
|
|
490
|
+
aliases?: Record<string, string> | undefined;
|
|
491
|
+
fallbacks?: Record<string, string[]> | undefined;
|
|
492
|
+
} | undefined;
|
|
295
493
|
}>;
|
|
296
494
|
export declare const runUpdateSchema: z.ZodObject<{
|
|
297
495
|
status: z.ZodEnum<["exited", "failed", "interrupted"]>;
|
|
298
496
|
exitCode: z.ZodNumber;
|
|
497
|
+
routingEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
498
|
+
at: z.ZodString;
|
|
499
|
+
requestId: z.ZodString;
|
|
500
|
+
requestedModel: z.ZodString;
|
|
501
|
+
resolvedModel: z.ZodOptional<z.ZodString>;
|
|
502
|
+
reportedModel: z.ZodOptional<z.ZodString>;
|
|
503
|
+
decision: z.ZodEnum<["allow", "alias", "reject", "fallback"]>;
|
|
504
|
+
role: z.ZodOptional<z.ZodEnum<["main", "subagent", "fast", "planning", "review", "summary", "compaction", "weak", "editor"]>>;
|
|
505
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
506
|
+
upstreamStatus: z.ZodOptional<z.ZodNumber>;
|
|
507
|
+
}, "strict", z.ZodTypeAny, {
|
|
508
|
+
at: string;
|
|
509
|
+
requestId: string;
|
|
510
|
+
requestedModel: string;
|
|
511
|
+
decision: "allow" | "alias" | "reject" | "fallback";
|
|
512
|
+
resolvedModel?: string | undefined;
|
|
513
|
+
reportedModel?: string | undefined;
|
|
514
|
+
role?: "main" | "subagent" | "fast" | "planning" | "review" | "summary" | "compaction" | "weak" | "editor" | undefined;
|
|
515
|
+
reason?: string | undefined;
|
|
516
|
+
upstreamStatus?: number | undefined;
|
|
517
|
+
}, {
|
|
518
|
+
at: string;
|
|
519
|
+
requestId: string;
|
|
520
|
+
requestedModel: string;
|
|
521
|
+
decision: "allow" | "alias" | "reject" | "fallback";
|
|
522
|
+
resolvedModel?: string | undefined;
|
|
523
|
+
reportedModel?: string | undefined;
|
|
524
|
+
role?: "main" | "subagent" | "fast" | "planning" | "review" | "summary" | "compaction" | "weak" | "editor" | undefined;
|
|
525
|
+
reason?: string | undefined;
|
|
526
|
+
upstreamStatus?: number | undefined;
|
|
527
|
+
}>, "many">>;
|
|
528
|
+
routingEventsDropped: z.ZodOptional<z.ZodNumber>;
|
|
299
529
|
}, "strict", z.ZodTypeAny, {
|
|
300
530
|
status: "exited" | "failed" | "interrupted";
|
|
301
531
|
exitCode: number;
|
|
532
|
+
routingEvents?: {
|
|
533
|
+
at: string;
|
|
534
|
+
requestId: string;
|
|
535
|
+
requestedModel: string;
|
|
536
|
+
decision: "allow" | "alias" | "reject" | "fallback";
|
|
537
|
+
resolvedModel?: string | undefined;
|
|
538
|
+
reportedModel?: string | undefined;
|
|
539
|
+
role?: "main" | "subagent" | "fast" | "planning" | "review" | "summary" | "compaction" | "weak" | "editor" | undefined;
|
|
540
|
+
reason?: string | undefined;
|
|
541
|
+
upstreamStatus?: number | undefined;
|
|
542
|
+
}[] | undefined;
|
|
543
|
+
routingEventsDropped?: number | undefined;
|
|
302
544
|
}, {
|
|
303
545
|
status: "exited" | "failed" | "interrupted";
|
|
304
546
|
exitCode: number;
|
|
547
|
+
routingEvents?: {
|
|
548
|
+
at: string;
|
|
549
|
+
requestId: string;
|
|
550
|
+
requestedModel: string;
|
|
551
|
+
decision: "allow" | "alias" | "reject" | "fallback";
|
|
552
|
+
resolvedModel?: string | undefined;
|
|
553
|
+
reportedModel?: string | undefined;
|
|
554
|
+
role?: "main" | "subagent" | "fast" | "planning" | "review" | "summary" | "compaction" | "weak" | "editor" | undefined;
|
|
555
|
+
reason?: string | undefined;
|
|
556
|
+
upstreamStatus?: number | undefined;
|
|
557
|
+
}[] | undefined;
|
|
558
|
+
routingEventsDropped?: number | undefined;
|
|
305
559
|
}>;
|
|
306
560
|
export type ProviderInput = z.input<typeof providerInputSchema>;
|
|
307
561
|
export type Provider = z.output<typeof providerInputSchema> & {
|
|
@@ -314,7 +568,8 @@ export type Profile = ProfileInput & {
|
|
|
314
568
|
updatedAt: string;
|
|
315
569
|
};
|
|
316
570
|
export type Model = z.infer<typeof modelSchema>;
|
|
317
|
-
export type Run = z.infer<typeof runInputSchema> & {
|
|
571
|
+
export type Run = Omit<z.infer<typeof runInputSchema>, "modelPolicyVersion"> & {
|
|
572
|
+
modelPolicyVersion?: 1;
|
|
318
573
|
providerId: string;
|
|
319
574
|
providerVersion: number;
|
|
320
575
|
profileVersion: number;
|
|
@@ -323,6 +578,8 @@ export type Run = z.infer<typeof runInputSchema> & {
|
|
|
323
578
|
startedAt: string;
|
|
324
579
|
endedAt?: string;
|
|
325
580
|
exitCode?: number;
|
|
581
|
+
routingEvents?: RoutingEvent[];
|
|
582
|
+
routingEventsDropped?: number;
|
|
326
583
|
version: number;
|
|
327
584
|
updatedAt: string;
|
|
328
585
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type Model } from "./domain";
|
|
2
|
+
import type { CompiledModelPolicy } from "./model-policy";
|
|
3
|
+
/** The settings fragment understood by Gemini CLI 0.58.0. */
|
|
4
|
+
export type GeminiModelPolicyFragment = {
|
|
5
|
+
modelConfigs: {
|
|
6
|
+
customOverrides: Array<{
|
|
7
|
+
match: {
|
|
8
|
+
model: string;
|
|
9
|
+
};
|
|
10
|
+
modelConfig: {
|
|
11
|
+
model: string;
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
14
|
+
modelChains: Record<string, Array<{
|
|
15
|
+
model: string;
|
|
16
|
+
isLastResort: true;
|
|
17
|
+
}>>;
|
|
18
|
+
modelDefinitions: Record<string, {
|
|
19
|
+
displayName: string;
|
|
20
|
+
tier: "custom";
|
|
21
|
+
family: "switcher";
|
|
22
|
+
isPreview: false;
|
|
23
|
+
isVisible: true;
|
|
24
|
+
features: {
|
|
25
|
+
thinking: false;
|
|
26
|
+
multimodalToolUse: boolean;
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
29
|
+
modelIdResolutions: Record<string, {
|
|
30
|
+
default: string;
|
|
31
|
+
contexts: [];
|
|
32
|
+
}>;
|
|
33
|
+
classifierIdResolutions: Record<string, {
|
|
34
|
+
default: string;
|
|
35
|
+
contexts: [];
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
agents?: {
|
|
39
|
+
overrides: {
|
|
40
|
+
codebase_investigator: {
|
|
41
|
+
modelConfig: {
|
|
42
|
+
model: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Compile the portable Switcher policy into native Gemini 0.58.0 settings.
|
|
50
|
+
*
|
|
51
|
+
* Gemini's stable native route controls are modelConfigs.modelIdResolutions
|
|
52
|
+
* and agents.overrides.<agent>.modelConfig.model. Its modelConfigs.modelChains
|
|
53
|
+
* field receives terminal selected-model chains; the gateway owns explicit
|
|
54
|
+
* ordered fallback and retry semantics.
|
|
55
|
+
*/
|
|
56
|
+
export declare function compileGeminiModelPolicy(selectedModel: string, models: readonly Model[], compiled: CompiledModelPolicy): GeminiModelPolicyFragment;
|