@hasna/switcher 0.1.1 → 0.1.3

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.
Files changed (43) hide show
  1. package/README.md +146 -7
  2. package/dist/aider-args.d.ts +7 -0
  3. package/dist/aider-config.d.ts +6 -0
  4. package/dist/auth.d.ts +3 -0
  5. package/dist/cli/index.js +7548 -2558
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cline-backend.d.ts +7 -0
  8. package/dist/codex-model-policy.d.ts +65 -0
  9. package/dist/credentials.d.ts +5 -5
  10. package/dist/direct-launch.d.ts +3 -3
  11. package/dist/domain.d.ts +320 -50
  12. package/dist/dsh-args.d.ts +5 -0
  13. package/dist/gemini-bridge.d.ts +6 -0
  14. package/dist/gemini-config.d.ts +12 -0
  15. package/dist/gemini-model-policy.d.ts +56 -0
  16. package/dist/generated/api.d.ts +220 -21
  17. package/dist/harness-arguments.d.ts +1 -0
  18. package/dist/harness-installation.d.ts +19 -0
  19. package/dist/harness-types.d.ts +10 -0
  20. package/dist/harnesses.d.ts +5 -2
  21. package/dist/hermes-backend.d.ts +19 -0
  22. package/dist/hermes-model-policy.d.ts +30 -0
  23. package/dist/index.js +136 -43
  24. package/dist/inference-gateway.d.ts +24 -0
  25. package/dist/kilo-config.d.ts +13 -0
  26. package/dist/kilo.d.ts +5 -0
  27. package/dist/launcher.d.ts +12 -6
  28. package/dist/mcp/index.js +139 -55
  29. package/dist/model-policy-schema.d.ts +137 -0
  30. package/dist/model-policy.d.ts +31 -0
  31. package/dist/native-model-policy.d.ts +23 -0
  32. package/dist/omp-backend.d.ts +7 -0
  33. package/dist/opencode-model-policy.d.ts +33 -0
  34. package/dist/opencode2-config.d.ts +3 -3
  35. package/dist/ori-backend.d.ts +2 -2
  36. package/dist/ori-model-policy.d.ts +8 -0
  37. package/dist/presets.d.ts +11 -10
  38. package/dist/sdk.d.ts +279 -38
  39. package/dist/sdk.js +136 -43
  40. package/dist/serve/index.js +1306 -125
  41. package/docs/MODEL-POLICY.md +82 -0
  42. package/openapi.json +973 -14
  43. package/package.json +14 -3
package/dist/cli.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  #!/usr/bin/env bun
2
+ import { type ModelPolicy } from "./domain";
3
+ export declare function readModelPolicy(file: string | undefined, roleValues: string[] | undefined): Promise<ModelPolicy | undefined>;
2
4
  export declare function main(args?: string[]): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import type { HarnessLaunchInput, PreparedLaunch } from "./harness-types";
2
+ /**
3
+ * Prepare Cline's native provider and model registries in an isolated data
4
+ * directory. Cline resolves OPENAI_API_KEY/ANTHROPIC_API_KEY from the child
5
+ * environment; no apiKey or auth token is written to either registry.
6
+ */
7
+ export declare function prepareClineLaunch(input: HarnessLaunchInput): Promise<PreparedLaunch>;
@@ -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 {};
@@ -52,8 +52,8 @@ export declare const credentialBindingSchema: z.ZodObject<{
52
52
  }>]>;
53
53
  }, "strict", z.ZodTypeAny, {
54
54
  url: string;
55
- executable: string;
56
55
  key: string;
56
+ executable: string;
57
57
  kind: "vault";
58
58
  operator: {
59
59
  kind: "env";
@@ -63,8 +63,8 @@ export declare const credentialBindingSchema: z.ZodObject<{
63
63
  };
64
64
  }, {
65
65
  url: string;
66
- executable: string;
67
66
  key: string;
67
+ executable: string;
68
68
  kind: "vault";
69
69
  operator: {
70
70
  kind: "env";
@@ -81,8 +81,8 @@ export declare const credentialBindingSchema: z.ZodObject<{
81
81
  account: string;
82
82
  } | {
83
83
  url: string;
84
- executable: string;
85
84
  key: string;
85
+ executable: string;
86
86
  kind: "vault";
87
87
  operator: {
88
88
  kind: "env";
@@ -101,8 +101,8 @@ export declare const credentialBindingSchema: z.ZodObject<{
101
101
  account: string;
102
102
  } | {
103
103
  url: string;
104
- executable: string;
105
104
  key: string;
105
+ executable: string;
106
106
  kind: "vault";
107
107
  operator: {
108
108
  kind: "env";
@@ -131,8 +131,8 @@ export declare class CredentialBindings {
131
131
  account: string;
132
132
  } | {
133
133
  url: string;
134
- executable: string;
135
134
  key: string;
135
+ executable: string;
136
136
  kind: "vault";
137
137
  operator: {
138
138
  kind: "env";
@@ -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
- export declare function selectModel(models: Model[], query?: string): Promise<string>;
6
- export declare function ensureLaunchProfile(client: SwitcherClient, provider: Provider, harness: Profile["harness"], model: string): Promise<Profile>;
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, modelPolicy?: ModelPolicy): Promise<Profile>;