@hasna/switcher 0.1.8 → 0.1.9
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 +133 -0
- package/dist/chatgpt-launch.d.ts +5 -0
- package/dist/claude-desktop-launch.d.ts +11 -0
- package/dist/cli/index.js +1029 -347
- package/dist/codex-delegation.d.ts +7 -0
- package/dist/credentials.d.ts +7 -7
- package/dist/desktop-apps.d.ts +25 -0
- package/dist/desktop-state.d.ts +3 -0
- package/dist/domain.d.ts +23 -1
- package/dist/generated/api.d.ts +16 -0
- package/dist/harness-process.d.ts +1 -0
- package/dist/harness-types.d.ts +3 -0
- package/dist/harnesses.d.ts +7 -3
- package/dist/index.js +164 -64
- package/dist/inference-gateway.d.ts +2 -0
- package/dist/launcher.d.ts +6 -0
- package/dist/mcp/index.js +116 -80
- package/dist/model-policy-schema.d.ts +6 -0
- package/dist/presets.d.ts +2 -0
- package/dist/reasoning.d.ts +10 -0
- package/dist/sdk.d.ts +25 -0
- package/dist/sdk.js +164 -64
- package/dist/serve/index.js +288 -73
- package/openapi.json +210 -1
- package/package.json +3 -2
package/dist/mcp/index.js
CHANGED
|
@@ -4,28 +4,32 @@
|
|
|
4
4
|
// src/mcp.ts
|
|
5
5
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
6
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
|
-
import { z as
|
|
7
|
+
import { z as z4 } from "zod";
|
|
8
8
|
|
|
9
9
|
// src/domain.ts
|
|
10
|
-
import { z as
|
|
10
|
+
import { z as z3 } from "zod";
|
|
11
11
|
|
|
12
|
-
// src/
|
|
12
|
+
// src/reasoning.ts
|
|
13
13
|
import { z } from "zod";
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
14
|
+
var reasoningEffortSchema = z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]);
|
|
15
|
+
|
|
16
|
+
// src/model-policy-schema.ts
|
|
17
|
+
import { z as z2 } from "zod";
|
|
18
|
+
var policyModelIdSchema = z2.string().min(1).max(300).regex(/^[^\u0000-\u001f\u007f]+$/);
|
|
19
|
+
var modelPolicyRoleSchema = z2.enum(["subagent", "fast", "planning", "review", "summary", "compaction", "weak", "editor"]);
|
|
20
|
+
var boundedModelList = z2.array(policyModelIdSchema).max(500);
|
|
21
|
+
var aliasSchema = z2.string().regex(/^[A-Za-z0-9._/-]{1,120}$/).refine((v) => !["__proto__", "prototype", "constructor"].includes(v));
|
|
22
|
+
var boundedModelMap = z2.record(aliasSchema, policyModelIdSchema).superRefine((value, ctx) => {
|
|
19
23
|
if (Object.keys(value).length > 200)
|
|
20
24
|
ctx.addIssue({ code: "custom", message: "Model policy maps may contain at most 200 entries." });
|
|
21
25
|
});
|
|
22
|
-
var fallbacksSchema =
|
|
26
|
+
var fallbacksSchema = z2.record(policyModelIdSchema, z2.array(policyModelIdSchema).max(20)).superRefine((value, ctx) => {
|
|
23
27
|
if (Object.keys(value).length > 200)
|
|
24
28
|
ctx.addIssue({ code: "custom", message: "Model policy fallback maps may contain at most 200 entries." });
|
|
25
29
|
});
|
|
26
|
-
var modelPolicySchema =
|
|
27
|
-
version:
|
|
28
|
-
roles:
|
|
30
|
+
var modelPolicySchema = z2.object({
|
|
31
|
+
version: z2.literal(1).default(1),
|
|
32
|
+
roles: z2.object({
|
|
29
33
|
subagent: policyModelIdSchema.optional(),
|
|
30
34
|
fast: policyModelIdSchema.optional(),
|
|
31
35
|
planning: policyModelIdSchema.optional(),
|
|
@@ -39,28 +43,29 @@ var modelPolicySchema = z.object({
|
|
|
39
43
|
aliases: boundedModelMap.optional(),
|
|
40
44
|
fallbacks: fallbacksSchema.optional()
|
|
41
45
|
}).strict();
|
|
42
|
-
var routingDecisionSchema =
|
|
43
|
-
var routingEventRoleSchema =
|
|
44
|
-
var routingEventSchema =
|
|
45
|
-
at:
|
|
46
|
-
requestId:
|
|
46
|
+
var routingDecisionSchema = z2.enum(["allow", "alias", "reject", "fallback"]);
|
|
47
|
+
var routingEventRoleSchema = z2.enum(["main", ...modelPolicyRoleSchema.options]);
|
|
48
|
+
var routingEventSchema = z2.object({
|
|
49
|
+
at: z2.string().datetime({ offset: true }),
|
|
50
|
+
requestId: z2.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/),
|
|
47
51
|
requestedModel: policyModelIdSchema,
|
|
48
52
|
resolvedModel: policyModelIdSchema.optional(),
|
|
49
53
|
reportedModel: policyModelIdSchema.optional(),
|
|
54
|
+
reasoningEffort: reasoningEffortSchema.optional(),
|
|
50
55
|
decision: routingDecisionSchema,
|
|
51
56
|
role: routingEventRoleSchema.optional(),
|
|
52
|
-
reason:
|
|
53
|
-
upstreamStatus:
|
|
57
|
+
reason: z2.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),
|
|
58
|
+
upstreamStatus: z2.number().int().min(100).max(599).optional()
|
|
54
59
|
}).strict();
|
|
55
|
-
var routingEventsSchema =
|
|
60
|
+
var routingEventsSchema = z2.array(routingEventSchema).max(1000);
|
|
56
61
|
|
|
57
62
|
// src/domain.ts
|
|
58
|
-
var VERSION = "0.1.
|
|
59
|
-
var harnessSchema =
|
|
60
|
-
var protocolSchema =
|
|
61
|
-
var idSchema =
|
|
62
|
-
var label =
|
|
63
|
-
var envRef =
|
|
63
|
+
var VERSION = "0.1.9";
|
|
64
|
+
var harnessSchema = z3.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]);
|
|
65
|
+
var protocolSchema = z3.enum(["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]);
|
|
66
|
+
var idSchema = z3.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
|
|
67
|
+
var label = z3.string().min(1).max(200);
|
|
68
|
+
var envRef = z3.string().regex(/^SWITCHER_PROVIDER_[A-Z0-9_]+$/);
|
|
64
69
|
function endpoint(value) {
|
|
65
70
|
let url;
|
|
66
71
|
try {
|
|
@@ -73,85 +78,86 @@ function endpoint(value) {
|
|
|
73
78
|
throw new Fault(400, "invalid_url", "URL must use HTTPS, contain no credentials/query/fragment, or use HTTP on loopback.");
|
|
74
79
|
return url.href.replace(/\/+$/, "");
|
|
75
80
|
}
|
|
76
|
-
var urlSchema =
|
|
81
|
+
var urlSchema = z3.string().max(2000).superRefine((v, ctx) => {
|
|
77
82
|
try {
|
|
78
83
|
endpoint(v);
|
|
79
84
|
} catch {
|
|
80
85
|
ctx.addIssue({ code: "custom", message: "Invalid endpoint URL" });
|
|
81
86
|
}
|
|
82
87
|
}).transform(endpoint);
|
|
83
|
-
var expiresOnSchema =
|
|
88
|
+
var expiresOnSchema = z3.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) => {
|
|
84
89
|
const day = new Date(`${value}T00:00:00.000Z`);
|
|
85
90
|
return Number.isFinite(day.getTime()) && day.toISOString().slice(0, 10) === value;
|
|
86
91
|
}, "Use a real calendar date in YYYY-MM-DD format.");
|
|
87
|
-
var modelSchema =
|
|
88
|
-
id:
|
|
92
|
+
var modelSchema = z3.object({
|
|
93
|
+
id: z3.string().min(1).max(300).refine((value) => value === value.trim() && !/[\x00-\x1f\x7f-\x9f]/.test(value), "Use a nonblank model ID without surrounding whitespace or control characters."),
|
|
89
94
|
name: label,
|
|
90
|
-
description:
|
|
91
|
-
available:
|
|
95
|
+
description: z3.string().max(8000).optional(),
|
|
96
|
+
available: z3.boolean().optional(),
|
|
92
97
|
expiresOn: expiresOnSchema.optional(),
|
|
93
|
-
contextWindow:
|
|
94
|
-
maxOutputTokens:
|
|
95
|
-
inputModalities:
|
|
96
|
-
outputModalities:
|
|
97
|
-
supportedParameters:
|
|
98
|
-
|
|
98
|
+
contextWindow: z3.number().int().positive().optional(),
|
|
99
|
+
maxOutputTokens: z3.number().int().positive().optional(),
|
|
100
|
+
inputModalities: z3.array(z3.string().max(50)).max(20).optional(),
|
|
101
|
+
outputModalities: z3.array(z3.string().max(50)).max(20).optional(),
|
|
102
|
+
supportedParameters: z3.array(z3.string().max(100)).max(100).optional(),
|
|
103
|
+
reasoningEfforts: z3.array(reasoningEffortSchema).max(8).optional(),
|
|
104
|
+
supportedGenerationMethods: z3.array(z3.string().min(1).max(100)).max(100).optional()
|
|
99
105
|
}).strict();
|
|
100
|
-
var providerInputSchema =
|
|
106
|
+
var providerInputSchema = z3.object({
|
|
101
107
|
id: idSchema,
|
|
102
108
|
name: label,
|
|
103
109
|
baseUrl: urlSchema,
|
|
104
110
|
protocol: protocolSchema,
|
|
105
111
|
credentialEnv: envRef.optional(),
|
|
106
|
-
authStyle:
|
|
112
|
+
authStyle: z3.enum(["bearer", "x-api-key", "api-key"]).default("bearer"),
|
|
107
113
|
catalogBaseUrl: urlSchema.optional(),
|
|
108
|
-
catalogFormat:
|
|
109
|
-
catalogAuthStyle:
|
|
114
|
+
catalogFormat: z3.enum(["openai", "ollama", "mistral", "together", "fireworks", "dashscope", "gemini", "none"]).optional(),
|
|
115
|
+
catalogAuthStyle: z3.enum(["bearer", "x-api-key", "api-key", "none"]).optional(),
|
|
110
116
|
catalogCredentialEnv: envRef.optional(),
|
|
111
|
-
catalogAccountId:
|
|
112
|
-
modelsPath:
|
|
113
|
-
manualModels:
|
|
114
|
-
additionalModels:
|
|
117
|
+
catalogAccountId: z3.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/).optional(),
|
|
118
|
+
modelsPath: z3.string().regex(/^[a-zA-Z0-9_/-]+$/).max(200).default("models"),
|
|
119
|
+
manualModels: z3.array(modelSchema).max(1e4).default([]),
|
|
120
|
+
additionalModels: z3.array(modelSchema).max(1e4).optional()
|
|
115
121
|
}).strict().refine((p) => !p.modelsPath.split("/").includes("..") && !p.modelsPath.startsWith("/"), "modelsPath must be relative");
|
|
116
|
-
var providerPresetSchema =
|
|
122
|
+
var providerPresetSchema = z3.object({
|
|
117
123
|
id: idSchema,
|
|
118
124
|
name: label,
|
|
119
125
|
credentialEnv: envRef.optional(),
|
|
120
|
-
credentialAliases:
|
|
121
|
-
protocols:
|
|
126
|
+
credentialAliases: z3.array(z3.string().regex(/^[A-Z][A-Z0-9_]+$/)),
|
|
127
|
+
protocols: z3.array(z3.object({
|
|
122
128
|
protocol: protocolSchema,
|
|
123
129
|
baseUrl: urlSchema.optional(),
|
|
124
|
-
authStyle:
|
|
130
|
+
authStyle: z3.enum(["bearer", "x-api-key", "api-key"]),
|
|
125
131
|
catalogBaseUrl: urlSchema.optional(),
|
|
126
|
-
catalogFormat:
|
|
127
|
-
catalogAuthStyle:
|
|
128
|
-
modelsPath:
|
|
129
|
-
notes:
|
|
132
|
+
catalogFormat: z3.enum(["openai", "ollama", "mistral", "together", "fireworks", "dashscope", "gemini", "none"]),
|
|
133
|
+
catalogAuthStyle: z3.enum(["bearer", "x-api-key", "api-key", "none"]).optional(),
|
|
134
|
+
modelsPath: z3.string(),
|
|
135
|
+
notes: z3.array(z3.string())
|
|
130
136
|
}).strict()).min(1),
|
|
131
|
-
sources:
|
|
132
|
-
verification:
|
|
137
|
+
sources: z3.array(z3.string().url()),
|
|
138
|
+
verification: z3.literal("documented")
|
|
133
139
|
}).strict();
|
|
134
|
-
var profileInputSchema =
|
|
140
|
+
var profileInputSchema = z3.object({
|
|
135
141
|
id: idSchema,
|
|
136
142
|
name: label,
|
|
137
143
|
providerId: idSchema,
|
|
138
144
|
harness: harnessSchema,
|
|
139
|
-
model:
|
|
145
|
+
model: z3.string().min(1).max(300),
|
|
140
146
|
modelPolicy: modelPolicySchema.optional()
|
|
141
147
|
}).strict();
|
|
142
|
-
var runInputSchema =
|
|
143
|
-
modelPolicyVersion:
|
|
148
|
+
var runInputSchema = z3.object({
|
|
149
|
+
modelPolicyVersion: z3.literal(1),
|
|
144
150
|
profileId: idSchema,
|
|
145
151
|
harness: harnessSchema,
|
|
146
|
-
model:
|
|
152
|
+
model: z3.string().min(1).max(300),
|
|
147
153
|
modelPolicy: modelPolicySchema.optional(),
|
|
148
|
-
planToken:
|
|
154
|
+
planToken: z3.string().regex(/^[a-f0-9]{64}$/)
|
|
149
155
|
}).strict();
|
|
150
|
-
var runUpdateSchema =
|
|
151
|
-
status:
|
|
152
|
-
exitCode:
|
|
156
|
+
var runUpdateSchema = z3.object({
|
|
157
|
+
status: z3.enum(["exited", "failed", "interrupted"]),
|
|
158
|
+
exitCode: z3.number().int().min(0).max(255),
|
|
153
159
|
routingEvents: routingEventsSchema.optional(),
|
|
154
|
-
routingEventsDropped:
|
|
160
|
+
routingEventsDropped: z3.number().int().min(0).max(1e6).optional()
|
|
155
161
|
}).strict();
|
|
156
162
|
|
|
157
163
|
class Fault extends Error {
|
|
@@ -292,6 +298,36 @@ var providerPresets = [
|
|
|
292
298
|
preset("siliconflow", "SiliconFlow", [route("openai-chat", "https://api.siliconflow.cn/v1", { catalogBaseUrl: "https://api.siliconflow.cn/v1", catalogFormat: "openai", notes: ["The official SiliconCloud OpenAPI contract defines GET /models with Bearer auth and data[] model rows; optional type and sub_type filters are available at the upstream endpoint."] })], ["https://github.com/siliconflow/siliconcloud/blob/main/openapi.yaml", "https://docs.siliconflow.cn/docs/userguide/quickstart", "https://docs.siliconflow.cn/docs/api/chat-completions-post"], "SILICONFLOW_API_KEY"),
|
|
293
299
|
...["anthropic-messages", "openai-responses", "openai-chat"].map((protocol) => preset(`generic-${protocol}`, `Custom ${protocol}`, [route(protocol)], []))
|
|
294
300
|
];
|
|
301
|
+
// src/desktop-apps.ts
|
|
302
|
+
import { execFile } from "child_process";
|
|
303
|
+
import { access, stat } from "fs/promises";
|
|
304
|
+
import { constants } from "fs";
|
|
305
|
+
import { homedir } from "os";
|
|
306
|
+
import { promisify } from "util";
|
|
307
|
+
var execute = promisify(execFile);
|
|
308
|
+
var host = {
|
|
309
|
+
platform: process.platform,
|
|
310
|
+
home: homedir(),
|
|
311
|
+
async run(command, args) {
|
|
312
|
+
const { stdout } = await execute(command, args, { encoding: "utf8", timeout: 8000, maxBuffer: 64 * 1024, env: { PATH: "/usr/bin:/bin", HOME: homedir() } });
|
|
313
|
+
return stdout.trim();
|
|
314
|
+
},
|
|
315
|
+
async executable(path) {
|
|
316
|
+
try {
|
|
317
|
+
await access(path, constants.X_OK);
|
|
318
|
+
return (await stat(path)).isFile();
|
|
319
|
+
} catch {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
async isDirectory(path) {
|
|
324
|
+
try {
|
|
325
|
+
return (await stat(path)).isDirectory();
|
|
326
|
+
} catch {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
};
|
|
295
331
|
|
|
296
332
|
// src/sdk.ts
|
|
297
333
|
class SwitcherError extends Error {
|
|
@@ -509,7 +545,7 @@ function clientFromEnv(env = process.env, options = {}) {
|
|
|
509
545
|
|
|
510
546
|
// src/mcp.ts
|
|
511
547
|
var server = new McpServer({ name: "switcher", version: VERSION });
|
|
512
|
-
var page = { limit:
|
|
548
|
+
var page = { limit: z4.number().int().min(1).max(1000).optional(), offset: z4.number().int().nonnegative().optional(), search: z4.string().optional() };
|
|
513
549
|
function tool(name, description, schema, run) {
|
|
514
550
|
server.tool(name, description, schema, async (input) => {
|
|
515
551
|
try {
|
|
@@ -520,26 +556,26 @@ function tool(name, description, schema, run) {
|
|
|
520
556
|
});
|
|
521
557
|
}
|
|
522
558
|
tool("providers_list", "List provider profiles.", page, (p) => clientFromEnv().listProviders(p));
|
|
523
|
-
tool("providers_get", "Get a provider.", { id:
|
|
559
|
+
tool("providers_get", "Get a provider.", { id: z4.string() }, (p) => clientFromEnv().getProvider(p.id));
|
|
524
560
|
tool("providers_create", "Create a provider using credential environment references only.", providerInputSchema.innerType().shape, (p) => clientFromEnv().createProvider(p));
|
|
525
|
-
tool("providers_update", "Replace a provider at its current version.", { provider: providerInputSchema, version:
|
|
526
|
-
tool("providers_delete", "Delete an unreferenced provider.", { id:
|
|
527
|
-
tool("models_list", "List catalog with capability information.", { id:
|
|
561
|
+
tool("providers_update", "Replace a provider at its current version.", { provider: providerInputSchema, version: z4.number().int() }, (p) => clientFromEnv().updateProvider(p.provider, p.version));
|
|
562
|
+
tool("providers_delete", "Delete an unreferenced provider.", { id: z4.string(), version: z4.number().int() }, (p) => clientFromEnv().deleteProvider(p.id, p.version));
|
|
563
|
+
tool("models_list", "List catalog with capability information.", { id: z4.string(), ...page }, (p) => {
|
|
528
564
|
const { id, ...rest } = p;
|
|
529
565
|
return clientFromEnv().listModels(id, rest);
|
|
530
566
|
});
|
|
531
|
-
tool("models_add", "Add saved model metadata; discovery stays active unless the provider uses a manual catalog.", { providerId:
|
|
532
|
-
tool("models_update", "Replace all saved metadata for a configured model.", { providerId:
|
|
533
|
-
tool("models_remove", "Remove saved model metadata; upstream catalog entries remain.", { providerId:
|
|
534
|
-
tool("models_refresh", "Discover provider models.", { id:
|
|
567
|
+
tool("models_add", "Add saved model metadata; discovery stays active unless the provider uses a manual catalog.", { providerId: z4.string(), model: modelSchema }, (p) => clientFromEnv().addModel(p.providerId, p.model));
|
|
568
|
+
tool("models_update", "Replace all saved metadata for a configured model.", { providerId: z4.string(), model: modelSchema }, (p) => clientFromEnv().updateModel(p.providerId, p.model));
|
|
569
|
+
tool("models_remove", "Remove saved model metadata; upstream catalog entries remain.", { providerId: z4.string(), modelId: modelSchema.shape.id }, (p) => clientFromEnv().removeModel(p.providerId, p.modelId));
|
|
570
|
+
tool("models_refresh", "Discover provider models.", { id: z4.string() }, (p) => clientFromEnv().refreshModels(p.id));
|
|
535
571
|
tool("profiles_list", "List harness launch profiles.", page, (p) => clientFromEnv().listProfiles(p));
|
|
536
|
-
tool("profiles_get", "Get a harness profile.", { id:
|
|
572
|
+
tool("profiles_get", "Get a harness profile.", { id: z4.string() }, (p) => clientFromEnv().getProfile(p.id));
|
|
537
573
|
tool("profiles_create", "Create a harness launch profile.", profileInputSchema.shape, (p) => clientFromEnv().createProfile(p));
|
|
538
|
-
tool("profiles_update", "Replace a harness profile at its version.", { profile: profileInputSchema, version:
|
|
539
|
-
tool("profiles_delete", "Delete a profile without run history.", { id:
|
|
540
|
-
tool("launch_plan", "Validate a local launch plan; does not execute a remote process.", { profileId:
|
|
574
|
+
tool("profiles_update", "Replace a harness profile at its version.", { profile: profileInputSchema, version: z4.number().int() }, (p) => clientFromEnv().updateProfile(p.profile, p.version));
|
|
575
|
+
tool("profiles_delete", "Delete a profile without run history.", { id: z4.string(), version: z4.number().int() }, (p) => clientFromEnv().deleteProfile(p.id, p.version));
|
|
576
|
+
tool("launch_plan", "Validate a local launch plan; does not execute a remote process.", { profileId: z4.string() }, (p) => clientFromEnv().launchPlan(p.profileId));
|
|
541
577
|
tool("runs_list", "List launch metadata.", page, (p) => clientFromEnv().listRuns(p));
|
|
542
|
-
tool("runs_get", "Get launch metadata.", { id:
|
|
578
|
+
tool("runs_get", "Get launch metadata.", { id: z4.string() }, (p) => clientFromEnv().getRun(p.id));
|
|
543
579
|
if (process.argv.includes("--version"))
|
|
544
580
|
console.log(VERSION);
|
|
545
581
|
else if (process.argv.includes("--help"))
|
|
@@ -76,6 +76,7 @@ export declare const routingEventSchema: z.ZodObject<{
|
|
|
76
76
|
requestedModel: z.ZodString;
|
|
77
77
|
resolvedModel: z.ZodOptional<z.ZodString>;
|
|
78
78
|
reportedModel: z.ZodOptional<z.ZodString>;
|
|
79
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]>>;
|
|
79
80
|
decision: z.ZodEnum<["allow", "alias", "reject", "fallback"]>;
|
|
80
81
|
role: z.ZodOptional<z.ZodEnum<["main", "subagent", "fast", "planning", "review", "summary", "compaction", "weak", "editor"]>>;
|
|
81
82
|
reason: z.ZodOptional<z.ZodString>;
|
|
@@ -87,6 +88,7 @@ export declare const routingEventSchema: z.ZodObject<{
|
|
|
87
88
|
decision: "allow" | "alias" | "reject" | "fallback";
|
|
88
89
|
resolvedModel?: string | undefined;
|
|
89
90
|
reportedModel?: string | undefined;
|
|
91
|
+
reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra" | undefined;
|
|
90
92
|
role?: "main" | "subagent" | "fast" | "planning" | "review" | "summary" | "compaction" | "weak" | "editor" | undefined;
|
|
91
93
|
reason?: string | undefined;
|
|
92
94
|
upstreamStatus?: number | undefined;
|
|
@@ -97,6 +99,7 @@ export declare const routingEventSchema: z.ZodObject<{
|
|
|
97
99
|
decision: "allow" | "alias" | "reject" | "fallback";
|
|
98
100
|
resolvedModel?: string | undefined;
|
|
99
101
|
reportedModel?: string | undefined;
|
|
102
|
+
reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra" | undefined;
|
|
100
103
|
role?: "main" | "subagent" | "fast" | "planning" | "review" | "summary" | "compaction" | "weak" | "editor" | undefined;
|
|
101
104
|
reason?: string | undefined;
|
|
102
105
|
upstreamStatus?: number | undefined;
|
|
@@ -108,6 +111,7 @@ export declare const routingEventsSchema: z.ZodArray<z.ZodObject<{
|
|
|
108
111
|
requestedModel: z.ZodString;
|
|
109
112
|
resolvedModel: z.ZodOptional<z.ZodString>;
|
|
110
113
|
reportedModel: z.ZodOptional<z.ZodString>;
|
|
114
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]>>;
|
|
111
115
|
decision: z.ZodEnum<["allow", "alias", "reject", "fallback"]>;
|
|
112
116
|
role: z.ZodOptional<z.ZodEnum<["main", "subagent", "fast", "planning", "review", "summary", "compaction", "weak", "editor"]>>;
|
|
113
117
|
reason: z.ZodOptional<z.ZodString>;
|
|
@@ -119,6 +123,7 @@ export declare const routingEventsSchema: z.ZodArray<z.ZodObject<{
|
|
|
119
123
|
decision: "allow" | "alias" | "reject" | "fallback";
|
|
120
124
|
resolvedModel?: string | undefined;
|
|
121
125
|
reportedModel?: string | undefined;
|
|
126
|
+
reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra" | undefined;
|
|
122
127
|
role?: "main" | "subagent" | "fast" | "planning" | "review" | "summary" | "compaction" | "weak" | "editor" | undefined;
|
|
123
128
|
reason?: string | undefined;
|
|
124
129
|
upstreamStatus?: number | undefined;
|
|
@@ -129,6 +134,7 @@ export declare const routingEventsSchema: z.ZodArray<z.ZodObject<{
|
|
|
129
134
|
decision: "allow" | "alias" | "reject" | "fallback";
|
|
130
135
|
resolvedModel?: string | undefined;
|
|
131
136
|
reportedModel?: string | undefined;
|
|
137
|
+
reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra" | undefined;
|
|
132
138
|
role?: "main" | "subagent" | "fast" | "planning" | "review" | "summary" | "compaction" | "weak" | "editor" | undefined;
|
|
133
139
|
reason?: string | undefined;
|
|
134
140
|
upstreamStatus?: number | undefined;
|
package/dist/presets.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare function providerFromPreset(presetId: string, options?: PresetOpt
|
|
|
51
51
|
inputModalities?: string[] | undefined;
|
|
52
52
|
outputModalities?: string[] | undefined;
|
|
53
53
|
supportedParameters?: string[] | undefined;
|
|
54
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[] | undefined;
|
|
54
55
|
supportedGenerationMethods?: string[] | undefined;
|
|
55
56
|
}[];
|
|
56
57
|
credentialEnv?: string | undefined;
|
|
@@ -70,6 +71,7 @@ export declare function providerFromPreset(presetId: string, options?: PresetOpt
|
|
|
70
71
|
inputModalities?: string[] | undefined;
|
|
71
72
|
outputModalities?: string[] | undefined;
|
|
72
73
|
supportedParameters?: string[] | undefined;
|
|
74
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[] | undefined;
|
|
73
75
|
supportedGenerationMethods?: string[] | undefined;
|
|
74
76
|
}[] | undefined;
|
|
75
77
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Model } from "./domain";
|
|
3
|
+
export declare const reasoningEffortSchema: z.ZodEnum<["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]>;
|
|
4
|
+
export type ReasoningEffort = z.infer<typeof reasoningEffortSchema>;
|
|
5
|
+
/** Advertise declared capabilities, documented DeepSeek levels, or an explicit
|
|
6
|
+
* operator selection. Do not invent a complete effort menu for arbitrary models. */
|
|
7
|
+
export declare function codexReasoning(model: Model, baseUrl: string, selected?: ReasoningEffort): {
|
|
8
|
+
levels: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
9
|
+
defaultEffort: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra";
|
|
10
|
+
};
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { components } from "./generated/api";
|
|
2
2
|
import { type CredentialChainOptions } from "@hasna/contracts/client";
|
|
3
3
|
export { providerFromPreset } from "./presets";
|
|
4
|
+
export { detectChatGPTApp, detectClaudeDesktopApp } from "./desktop-apps";
|
|
5
|
+
export type { ChatGPTInstallation, ClaudeDesktopInstallation } from "./desktop-apps";
|
|
4
6
|
export type ProviderPreset = components["schemas"]["ProviderPreset"];
|
|
5
7
|
export type ProviderInput = components["schemas"]["ProviderInput"];
|
|
6
8
|
export type Provider = components["schemas"]["Provider"];
|
|
@@ -104,6 +106,7 @@ export declare class SwitcherClient {
|
|
|
104
106
|
inputModalities?: string[];
|
|
105
107
|
outputModalities?: string[];
|
|
106
108
|
supportedParameters?: string[];
|
|
109
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
107
110
|
supportedGenerationMethods?: string[];
|
|
108
111
|
}[];
|
|
109
112
|
additionalModels?: {
|
|
@@ -117,6 +120,7 @@ export declare class SwitcherClient {
|
|
|
117
120
|
inputModalities?: string[];
|
|
118
121
|
outputModalities?: string[];
|
|
119
122
|
supportedParameters?: string[];
|
|
123
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
120
124
|
supportedGenerationMethods?: string[];
|
|
121
125
|
}[];
|
|
122
126
|
version: number;
|
|
@@ -146,6 +150,7 @@ export declare class SwitcherClient {
|
|
|
146
150
|
inputModalities?: string[];
|
|
147
151
|
outputModalities?: string[];
|
|
148
152
|
supportedParameters?: string[];
|
|
153
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
149
154
|
supportedGenerationMethods?: string[];
|
|
150
155
|
}[];
|
|
151
156
|
additionalModels?: {
|
|
@@ -159,6 +164,7 @@ export declare class SwitcherClient {
|
|
|
159
164
|
inputModalities?: string[];
|
|
160
165
|
outputModalities?: string[];
|
|
161
166
|
supportedParameters?: string[];
|
|
167
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
162
168
|
supportedGenerationMethods?: string[];
|
|
163
169
|
}[];
|
|
164
170
|
version: number;
|
|
@@ -188,6 +194,7 @@ export declare class SwitcherClient {
|
|
|
188
194
|
inputModalities?: string[];
|
|
189
195
|
outputModalities?: string[];
|
|
190
196
|
supportedParameters?: string[];
|
|
197
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
191
198
|
supportedGenerationMethods?: string[];
|
|
192
199
|
}[];
|
|
193
200
|
additionalModels?: {
|
|
@@ -201,6 +208,7 @@ export declare class SwitcherClient {
|
|
|
201
208
|
inputModalities?: string[];
|
|
202
209
|
outputModalities?: string[];
|
|
203
210
|
supportedParameters?: string[];
|
|
211
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
204
212
|
supportedGenerationMethods?: string[];
|
|
205
213
|
}[];
|
|
206
214
|
version: number;
|
|
@@ -230,6 +238,7 @@ export declare class SwitcherClient {
|
|
|
230
238
|
inputModalities?: string[];
|
|
231
239
|
outputModalities?: string[];
|
|
232
240
|
supportedParameters?: string[];
|
|
241
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
233
242
|
supportedGenerationMethods?: string[];
|
|
234
243
|
}[];
|
|
235
244
|
additionalModels?: {
|
|
@@ -243,6 +252,7 @@ export declare class SwitcherClient {
|
|
|
243
252
|
inputModalities?: string[];
|
|
244
253
|
outputModalities?: string[];
|
|
245
254
|
supportedParameters?: string[];
|
|
255
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
246
256
|
supportedGenerationMethods?: string[];
|
|
247
257
|
}[];
|
|
248
258
|
version: number;
|
|
@@ -279,6 +289,7 @@ export declare class SwitcherClient {
|
|
|
279
289
|
inputModalities?: string[];
|
|
280
290
|
outputModalities?: string[];
|
|
281
291
|
supportedParameters?: string[];
|
|
292
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
282
293
|
supportedGenerationMethods?: string[];
|
|
283
294
|
}[];
|
|
284
295
|
additionalModels?: {
|
|
@@ -292,6 +303,7 @@ export declare class SwitcherClient {
|
|
|
292
303
|
inputModalities?: string[];
|
|
293
304
|
outputModalities?: string[];
|
|
294
305
|
supportedParameters?: string[];
|
|
306
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
295
307
|
supportedGenerationMethods?: string[];
|
|
296
308
|
}[];
|
|
297
309
|
version: number;
|
|
@@ -322,6 +334,7 @@ export declare class SwitcherClient {
|
|
|
322
334
|
inputModalities?: string[];
|
|
323
335
|
outputModalities?: string[];
|
|
324
336
|
supportedParameters?: string[];
|
|
337
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
325
338
|
supportedGenerationMethods?: string[];
|
|
326
339
|
}[];
|
|
327
340
|
additionalModels?: {
|
|
@@ -335,6 +348,7 @@ export declare class SwitcherClient {
|
|
|
335
348
|
inputModalities?: string[];
|
|
336
349
|
outputModalities?: string[];
|
|
337
350
|
supportedParameters?: string[];
|
|
351
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
338
352
|
supportedGenerationMethods?: string[];
|
|
339
353
|
}[];
|
|
340
354
|
version: number;
|
|
@@ -364,6 +378,7 @@ export declare class SwitcherClient {
|
|
|
364
378
|
inputModalities?: string[];
|
|
365
379
|
outputModalities?: string[];
|
|
366
380
|
supportedParameters?: string[];
|
|
381
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
367
382
|
supportedGenerationMethods?: string[];
|
|
368
383
|
}[];
|
|
369
384
|
additionalModels?: {
|
|
@@ -377,6 +392,7 @@ export declare class SwitcherClient {
|
|
|
377
392
|
inputModalities?: string[];
|
|
378
393
|
outputModalities?: string[];
|
|
379
394
|
supportedParameters?: string[];
|
|
395
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
380
396
|
supportedGenerationMethods?: string[];
|
|
381
397
|
}[];
|
|
382
398
|
version: number;
|
|
@@ -394,6 +410,7 @@ export declare class SwitcherClient {
|
|
|
394
410
|
inputModalities?: string[];
|
|
395
411
|
outputModalities?: string[];
|
|
396
412
|
supportedParameters?: string[];
|
|
413
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
397
414
|
supportedGenerationMethods?: string[];
|
|
398
415
|
}[];
|
|
399
416
|
refreshedAt: string;
|
|
@@ -411,6 +428,7 @@ export declare class SwitcherClient {
|
|
|
411
428
|
inputModalities?: string[];
|
|
412
429
|
outputModalities?: string[];
|
|
413
430
|
supportedParameters?: string[];
|
|
431
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
414
432
|
supportedGenerationMethods?: string[];
|
|
415
433
|
codingEligible: boolean;
|
|
416
434
|
expired: boolean;
|
|
@@ -565,6 +583,7 @@ export declare class SwitcherClient {
|
|
|
565
583
|
inputModalities?: string[];
|
|
566
584
|
outputModalities?: string[];
|
|
567
585
|
supportedParameters?: string[];
|
|
586
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
568
587
|
supportedGenerationMethods?: string[];
|
|
569
588
|
}[];
|
|
570
589
|
additionalModels?: {
|
|
@@ -578,6 +597,7 @@ export declare class SwitcherClient {
|
|
|
578
597
|
inputModalities?: string[];
|
|
579
598
|
outputModalities?: string[];
|
|
580
599
|
supportedParameters?: string[];
|
|
600
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
581
601
|
supportedGenerationMethods?: string[];
|
|
582
602
|
}[];
|
|
583
603
|
version: number;
|
|
@@ -624,6 +644,7 @@ export declare class SwitcherClient {
|
|
|
624
644
|
inputModalities?: string[];
|
|
625
645
|
outputModalities?: string[];
|
|
626
646
|
supportedParameters?: string[];
|
|
647
|
+
reasoningEfforts?: ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra")[];
|
|
627
648
|
supportedGenerationMethods?: string[];
|
|
628
649
|
}[];
|
|
629
650
|
refreshedAt: string;
|
|
@@ -674,6 +695,7 @@ export declare class SwitcherClient {
|
|
|
674
695
|
requestedModel: string;
|
|
675
696
|
resolvedModel?: string;
|
|
676
697
|
reportedModel?: string;
|
|
698
|
+
reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra";
|
|
677
699
|
decision: "allow" | "alias" | "reject" | "fallback";
|
|
678
700
|
role?: "main" | "subagent" | "fast" | "planning" | "review" | "summary" | "compaction" | "weak" | "editor";
|
|
679
701
|
reason?: string;
|
|
@@ -723,6 +745,7 @@ export declare class SwitcherClient {
|
|
|
723
745
|
requestedModel: string;
|
|
724
746
|
resolvedModel?: string;
|
|
725
747
|
reportedModel?: string;
|
|
748
|
+
reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra";
|
|
726
749
|
decision: "allow" | "alias" | "reject" | "fallback";
|
|
727
750
|
role?: "main" | "subagent" | "fast" | "planning" | "review" | "summary" | "compaction" | "weak" | "editor";
|
|
728
751
|
reason?: string;
|
|
@@ -774,6 +797,7 @@ export declare class SwitcherClient {
|
|
|
774
797
|
requestedModel: string;
|
|
775
798
|
resolvedModel?: string;
|
|
776
799
|
reportedModel?: string;
|
|
800
|
+
reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra";
|
|
777
801
|
decision: "allow" | "alias" | "reject" | "fallback";
|
|
778
802
|
role?: "main" | "subagent" | "fast" | "planning" | "review" | "summary" | "compaction" | "weak" | "editor";
|
|
779
803
|
reason?: string;
|
|
@@ -823,6 +847,7 @@ export declare class SwitcherClient {
|
|
|
823
847
|
requestedModel: string;
|
|
824
848
|
resolvedModel?: string;
|
|
825
849
|
reportedModel?: string;
|
|
850
|
+
reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra";
|
|
826
851
|
decision: "allow" | "alias" | "reject" | "fallback";
|
|
827
852
|
role?: "main" | "subagent" | "fast" | "planning" | "review" | "summary" | "compaction" | "weak" | "editor";
|
|
828
853
|
reason?: string;
|