@hasna/switcher 0.1.8 → 0.2.0
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 +161 -3
- package/dist/chatgpt-launch.d.ts +5 -0
- package/dist/claude-desktop-launch.d.ts +11 -0
- package/dist/cli/index.js +1232 -403
- 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/gemini-bridge.d.ts +2 -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 +13 -3
- package/dist/hermes-backend.d.ts +2 -1
- package/dist/index.js +164 -64
- package/dist/inference-gateway.d.ts +4 -1
- package/dist/launcher.d.ts +6 -0
- package/dist/lib/local-opt-in.d.ts +30 -0
- package/dist/mcp/index.js +4960 -89
- package/dist/model-policy-schema.d.ts +6 -0
- package/dist/presets.d.ts +2 -0
- package/dist/provider-request.d.ts +15 -0
- package/dist/provider-stream.d.ts +3 -1
- package/dist/reasoning.d.ts +10 -0
- package/dist/runtime.d.ts +2 -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 +5 -3
package/dist/index.js
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
// src/domain.ts
|
|
2
|
-
import { z as
|
|
2
|
+
import { z as z3 } from "zod";
|
|
3
3
|
|
|
4
|
-
// src/
|
|
4
|
+
// src/reasoning.ts
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
6
|
+
var reasoningEffortSchema = z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]);
|
|
7
|
+
|
|
8
|
+
// src/model-policy-schema.ts
|
|
9
|
+
import { z as z2 } from "zod";
|
|
10
|
+
var policyModelIdSchema = z2.string().min(1).max(300).regex(/^[^\u0000-\u001f\u007f]+$/);
|
|
11
|
+
var modelPolicyRoleSchema = z2.enum(["subagent", "fast", "planning", "review", "summary", "compaction", "weak", "editor"]);
|
|
12
|
+
var boundedModelList = z2.array(policyModelIdSchema).max(500);
|
|
13
|
+
var aliasSchema = z2.string().regex(/^[A-Za-z0-9._/-]{1,120}$/).refine((v) => !["__proto__", "prototype", "constructor"].includes(v));
|
|
14
|
+
var boundedModelMap = z2.record(aliasSchema, policyModelIdSchema).superRefine((value, ctx) => {
|
|
11
15
|
if (Object.keys(value).length > 200)
|
|
12
16
|
ctx.addIssue({ code: "custom", message: "Model policy maps may contain at most 200 entries." });
|
|
13
17
|
});
|
|
14
|
-
var fallbacksSchema =
|
|
18
|
+
var fallbacksSchema = z2.record(policyModelIdSchema, z2.array(policyModelIdSchema).max(20)).superRefine((value, ctx) => {
|
|
15
19
|
if (Object.keys(value).length > 200)
|
|
16
20
|
ctx.addIssue({ code: "custom", message: "Model policy fallback maps may contain at most 200 entries." });
|
|
17
21
|
});
|
|
18
|
-
var modelPolicySchema =
|
|
19
|
-
version:
|
|
20
|
-
roles:
|
|
22
|
+
var modelPolicySchema = z2.object({
|
|
23
|
+
version: z2.literal(1).default(1),
|
|
24
|
+
roles: z2.object({
|
|
21
25
|
subagent: policyModelIdSchema.optional(),
|
|
22
26
|
fast: policyModelIdSchema.optional(),
|
|
23
27
|
planning: policyModelIdSchema.optional(),
|
|
@@ -31,26 +35,27 @@ var modelPolicySchema = z.object({
|
|
|
31
35
|
aliases: boundedModelMap.optional(),
|
|
32
36
|
fallbacks: fallbacksSchema.optional()
|
|
33
37
|
}).strict();
|
|
34
|
-
var routingDecisionSchema =
|
|
35
|
-
var routingEventRoleSchema =
|
|
36
|
-
var routingEventSchema =
|
|
37
|
-
at:
|
|
38
|
-
requestId:
|
|
38
|
+
var routingDecisionSchema = z2.enum(["allow", "alias", "reject", "fallback"]);
|
|
39
|
+
var routingEventRoleSchema = z2.enum(["main", ...modelPolicyRoleSchema.options]);
|
|
40
|
+
var routingEventSchema = z2.object({
|
|
41
|
+
at: z2.string().datetime({ offset: true }),
|
|
42
|
+
requestId: z2.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/),
|
|
39
43
|
requestedModel: policyModelIdSchema,
|
|
40
44
|
resolvedModel: policyModelIdSchema.optional(),
|
|
41
45
|
reportedModel: policyModelIdSchema.optional(),
|
|
46
|
+
reasoningEffort: reasoningEffortSchema.optional(),
|
|
42
47
|
decision: routingDecisionSchema,
|
|
43
48
|
role: routingEventRoleSchema.optional(),
|
|
44
|
-
reason:
|
|
45
|
-
upstreamStatus:
|
|
49
|
+
reason: z2.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),
|
|
50
|
+
upstreamStatus: z2.number().int().min(100).max(599).optional()
|
|
46
51
|
}).strict();
|
|
47
|
-
var routingEventsSchema =
|
|
52
|
+
var routingEventsSchema = z2.array(routingEventSchema).max(1000);
|
|
48
53
|
// src/domain.ts
|
|
49
|
-
var harnessSchema =
|
|
50
|
-
var protocolSchema =
|
|
51
|
-
var idSchema =
|
|
52
|
-
var label =
|
|
53
|
-
var envRef =
|
|
54
|
+
var harnessSchema = z3.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]);
|
|
55
|
+
var protocolSchema = z3.enum(["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]);
|
|
56
|
+
var idSchema = z3.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
|
|
57
|
+
var label = z3.string().min(1).max(200);
|
|
58
|
+
var envRef = z3.string().regex(/^SWITCHER_PROVIDER_[A-Z0-9_]+$/);
|
|
54
59
|
function endpoint(value) {
|
|
55
60
|
let url;
|
|
56
61
|
try {
|
|
@@ -63,85 +68,86 @@ function endpoint(value) {
|
|
|
63
68
|
throw new Fault(400, "invalid_url", "URL must use HTTPS, contain no credentials/query/fragment, or use HTTP on loopback.");
|
|
64
69
|
return url.href.replace(/\/+$/, "");
|
|
65
70
|
}
|
|
66
|
-
var urlSchema =
|
|
71
|
+
var urlSchema = z3.string().max(2000).superRefine((v, ctx) => {
|
|
67
72
|
try {
|
|
68
73
|
endpoint(v);
|
|
69
74
|
} catch {
|
|
70
75
|
ctx.addIssue({ code: "custom", message: "Invalid endpoint URL" });
|
|
71
76
|
}
|
|
72
77
|
}).transform(endpoint);
|
|
73
|
-
var expiresOnSchema =
|
|
78
|
+
var expiresOnSchema = z3.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) => {
|
|
74
79
|
const day = new Date(`${value}T00:00:00.000Z`);
|
|
75
80
|
return Number.isFinite(day.getTime()) && day.toISOString().slice(0, 10) === value;
|
|
76
81
|
}, "Use a real calendar date in YYYY-MM-DD format.");
|
|
77
|
-
var modelSchema =
|
|
78
|
-
id:
|
|
82
|
+
var modelSchema = z3.object({
|
|
83
|
+
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."),
|
|
79
84
|
name: label,
|
|
80
|
-
description:
|
|
81
|
-
available:
|
|
85
|
+
description: z3.string().max(8000).optional(),
|
|
86
|
+
available: z3.boolean().optional(),
|
|
82
87
|
expiresOn: expiresOnSchema.optional(),
|
|
83
|
-
contextWindow:
|
|
84
|
-
maxOutputTokens:
|
|
85
|
-
inputModalities:
|
|
86
|
-
outputModalities:
|
|
87
|
-
supportedParameters:
|
|
88
|
-
|
|
88
|
+
contextWindow: z3.number().int().positive().optional(),
|
|
89
|
+
maxOutputTokens: z3.number().int().positive().optional(),
|
|
90
|
+
inputModalities: z3.array(z3.string().max(50)).max(20).optional(),
|
|
91
|
+
outputModalities: z3.array(z3.string().max(50)).max(20).optional(),
|
|
92
|
+
supportedParameters: z3.array(z3.string().max(100)).max(100).optional(),
|
|
93
|
+
reasoningEfforts: z3.array(reasoningEffortSchema).max(8).optional(),
|
|
94
|
+
supportedGenerationMethods: z3.array(z3.string().min(1).max(100)).max(100).optional()
|
|
89
95
|
}).strict();
|
|
90
|
-
var providerInputSchema =
|
|
96
|
+
var providerInputSchema = z3.object({
|
|
91
97
|
id: idSchema,
|
|
92
98
|
name: label,
|
|
93
99
|
baseUrl: urlSchema,
|
|
94
100
|
protocol: protocolSchema,
|
|
95
101
|
credentialEnv: envRef.optional(),
|
|
96
|
-
authStyle:
|
|
102
|
+
authStyle: z3.enum(["bearer", "x-api-key", "api-key"]).default("bearer"),
|
|
97
103
|
catalogBaseUrl: urlSchema.optional(),
|
|
98
|
-
catalogFormat:
|
|
99
|
-
catalogAuthStyle:
|
|
104
|
+
catalogFormat: z3.enum(["openai", "ollama", "mistral", "together", "fireworks", "dashscope", "gemini", "none"]).optional(),
|
|
105
|
+
catalogAuthStyle: z3.enum(["bearer", "x-api-key", "api-key", "none"]).optional(),
|
|
100
106
|
catalogCredentialEnv: envRef.optional(),
|
|
101
|
-
catalogAccountId:
|
|
102
|
-
modelsPath:
|
|
103
|
-
manualModels:
|
|
104
|
-
additionalModels:
|
|
107
|
+
catalogAccountId: z3.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/).optional(),
|
|
108
|
+
modelsPath: z3.string().regex(/^[a-zA-Z0-9_/-]+$/).max(200).default("models"),
|
|
109
|
+
manualModels: z3.array(modelSchema).max(1e4).default([]),
|
|
110
|
+
additionalModels: z3.array(modelSchema).max(1e4).optional()
|
|
105
111
|
}).strict().refine((p) => !p.modelsPath.split("/").includes("..") && !p.modelsPath.startsWith("/"), "modelsPath must be relative");
|
|
106
|
-
var providerPresetSchema =
|
|
112
|
+
var providerPresetSchema = z3.object({
|
|
107
113
|
id: idSchema,
|
|
108
114
|
name: label,
|
|
109
115
|
credentialEnv: envRef.optional(),
|
|
110
|
-
credentialAliases:
|
|
111
|
-
protocols:
|
|
116
|
+
credentialAliases: z3.array(z3.string().regex(/^[A-Z][A-Z0-9_]+$/)),
|
|
117
|
+
protocols: z3.array(z3.object({
|
|
112
118
|
protocol: protocolSchema,
|
|
113
119
|
baseUrl: urlSchema.optional(),
|
|
114
|
-
authStyle:
|
|
120
|
+
authStyle: z3.enum(["bearer", "x-api-key", "api-key"]),
|
|
115
121
|
catalogBaseUrl: urlSchema.optional(),
|
|
116
|
-
catalogFormat:
|
|
117
|
-
catalogAuthStyle:
|
|
118
|
-
modelsPath:
|
|
119
|
-
notes:
|
|
122
|
+
catalogFormat: z3.enum(["openai", "ollama", "mistral", "together", "fireworks", "dashscope", "gemini", "none"]),
|
|
123
|
+
catalogAuthStyle: z3.enum(["bearer", "x-api-key", "api-key", "none"]).optional(),
|
|
124
|
+
modelsPath: z3.string(),
|
|
125
|
+
notes: z3.array(z3.string())
|
|
120
126
|
}).strict()).min(1),
|
|
121
|
-
sources:
|
|
122
|
-
verification:
|
|
127
|
+
sources: z3.array(z3.string().url()),
|
|
128
|
+
verification: z3.literal("documented")
|
|
123
129
|
}).strict();
|
|
124
|
-
var profileInputSchema =
|
|
130
|
+
var profileInputSchema = z3.object({
|
|
125
131
|
id: idSchema,
|
|
126
132
|
name: label,
|
|
127
133
|
providerId: idSchema,
|
|
128
134
|
harness: harnessSchema,
|
|
129
|
-
model:
|
|
135
|
+
model: z3.string().min(1).max(300),
|
|
130
136
|
modelPolicy: modelPolicySchema.optional()
|
|
131
137
|
}).strict();
|
|
132
|
-
var runInputSchema =
|
|
133
|
-
modelPolicyVersion:
|
|
138
|
+
var runInputSchema = z3.object({
|
|
139
|
+
modelPolicyVersion: z3.literal(1),
|
|
134
140
|
profileId: idSchema,
|
|
135
141
|
harness: harnessSchema,
|
|
136
|
-
model:
|
|
142
|
+
model: z3.string().min(1).max(300),
|
|
137
143
|
modelPolicy: modelPolicySchema.optional(),
|
|
138
|
-
planToken:
|
|
144
|
+
planToken: z3.string().regex(/^[a-f0-9]{64}$/)
|
|
139
145
|
}).strict();
|
|
140
|
-
var runUpdateSchema =
|
|
141
|
-
status:
|
|
142
|
-
exitCode:
|
|
146
|
+
var runUpdateSchema = z3.object({
|
|
147
|
+
status: z3.enum(["exited", "failed", "interrupted"]),
|
|
148
|
+
exitCode: z3.number().int().min(0).max(255),
|
|
143
149
|
routingEvents: routingEventsSchema.optional(),
|
|
144
|
-
routingEventsDropped:
|
|
150
|
+
routingEventsDropped: z3.number().int().min(0).max(1e6).optional()
|
|
145
151
|
}).strict();
|
|
146
152
|
|
|
147
153
|
class Fault extends Error {
|
|
@@ -339,6 +345,98 @@ function providerFromPreset(presetId, options = {}) {
|
|
|
339
345
|
}] : []
|
|
340
346
|
});
|
|
341
347
|
}
|
|
348
|
+
// src/desktop-apps.ts
|
|
349
|
+
import { execFile } from "node:child_process";
|
|
350
|
+
import { access, stat } from "node:fs/promises";
|
|
351
|
+
import { constants } from "node:fs";
|
|
352
|
+
import { homedir } from "node:os";
|
|
353
|
+
import { isAbsolute, join } from "node:path";
|
|
354
|
+
import { promisify } from "node:util";
|
|
355
|
+
var execute = promisify(execFile);
|
|
356
|
+
var host = {
|
|
357
|
+
platform: process.platform,
|
|
358
|
+
home: homedir(),
|
|
359
|
+
async run(command, args) {
|
|
360
|
+
const { stdout } = await execute(command, args, { encoding: "utf8", timeout: 8000, maxBuffer: 64 * 1024, env: { PATH: "/usr/bin:/bin", HOME: homedir() } });
|
|
361
|
+
return stdout.trim();
|
|
362
|
+
},
|
|
363
|
+
async executable(path) {
|
|
364
|
+
try {
|
|
365
|
+
await access(path, constants.X_OK);
|
|
366
|
+
return (await stat(path)).isFile();
|
|
367
|
+
} catch {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
async isDirectory(path) {
|
|
372
|
+
try {
|
|
373
|
+
return (await stat(path)).isDirectory();
|
|
374
|
+
} catch {
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
async function detectChatGPTApp(appPath, system = host) {
|
|
380
|
+
if (system.platform !== "darwin")
|
|
381
|
+
throw new Fault(422, "unsupported_platform", "ChatGPT provider launches currently require the macOS desktop app.");
|
|
382
|
+
let candidates;
|
|
383
|
+
if (appPath !== undefined)
|
|
384
|
+
candidates = [appPath];
|
|
385
|
+
else {
|
|
386
|
+
candidates = ["ChatGPT.app", "Codex.app"].flatMap((name) => [join(system.home, "Applications", name), join("/Applications", name)]);
|
|
387
|
+
try {
|
|
388
|
+
const found = await system.run("/usr/bin/osascript", ["-l", "JavaScript", "-e", 'ObjC.import("AppKit"); const url = $.NSWorkspace.sharedWorkspace.URLForApplicationWithBundleIdentifier("com.openai.codex"); url.isNil() ? "" : ObjC.unwrap(url.path);']);
|
|
389
|
+
if (found)
|
|
390
|
+
candidates.push(found);
|
|
391
|
+
} catch {}
|
|
392
|
+
}
|
|
393
|
+
for (const path of new Set(candidates)) {
|
|
394
|
+
if (!isAbsolute(path) || !path.endsWith(".app") || !await system.isDirectory(path))
|
|
395
|
+
continue;
|
|
396
|
+
const plist = join(path, "Contents/Info.plist");
|
|
397
|
+
const field = (name) => system.run("/usr/bin/plutil", ["-extract", name, "raw", "-o", "-", plist]);
|
|
398
|
+
try {
|
|
399
|
+
const bundleId = await field("CFBundleIdentifier");
|
|
400
|
+
if (bundleId !== "com.openai.codex")
|
|
401
|
+
continue;
|
|
402
|
+
const name = await field("CFBundleExecutable"), version = await field("CFBundleShortVersionString");
|
|
403
|
+
if (!/^[A-Za-z0-9 _-]+$/.test(name))
|
|
404
|
+
continue;
|
|
405
|
+
const executable = join(path, "Contents/MacOS", name), codexExecutable = join(path, "Contents/Resources/codex");
|
|
406
|
+
if (await system.executable(executable) && await system.executable(codexExecutable))
|
|
407
|
+
return { path, executable, codexExecutable, bundleId, version };
|
|
408
|
+
} catch {}
|
|
409
|
+
}
|
|
410
|
+
throw new Fault(404, "app_not_installed", "Install the current ChatGPT/Codex macOS app or use --app-path with its absolute .app path. Legacy ChatGPT Classic cannot run custom Codex providers.");
|
|
411
|
+
}
|
|
412
|
+
async function detectClaudeDesktopApp(appPath, system = host) {
|
|
413
|
+
if (system.platform !== "darwin")
|
|
414
|
+
throw new Fault(422, "unsupported_platform", "Claude desktop provider launches currently require macOS.");
|
|
415
|
+
const candidates = appPath === undefined ? [join(system.home, "Applications/Claude.app"), "/Applications/Claude.app"] : [appPath];
|
|
416
|
+
if (appPath === undefined)
|
|
417
|
+
try {
|
|
418
|
+
const found = await system.run("/usr/bin/osascript", ["-l", "JavaScript", "-e", 'ObjC.import("AppKit"); const url = $.NSWorkspace.sharedWorkspace.URLForApplicationWithBundleIdentifier("com.anthropic.claudefordesktop"); url.isNil() ? "" : ObjC.unwrap(url.path);']);
|
|
419
|
+
if (found)
|
|
420
|
+
candidates.push(found);
|
|
421
|
+
} catch {}
|
|
422
|
+
for (const path of new Set(candidates)) {
|
|
423
|
+
if (!isAbsolute(path) || !path.endsWith(".app") || !await system.isDirectory(path))
|
|
424
|
+
continue;
|
|
425
|
+
const field = (name) => system.run("/usr/bin/plutil", ["-extract", name, "raw", "-o", "-", join(path, "Contents/Info.plist")]);
|
|
426
|
+
try {
|
|
427
|
+
const bundleId = await field("CFBundleIdentifier");
|
|
428
|
+
if (bundleId !== "com.anthropic.claudefordesktop")
|
|
429
|
+
continue;
|
|
430
|
+
const name = await field("CFBundleExecutable"), version = await field("CFBundleShortVersionString");
|
|
431
|
+
if (!/^[A-Za-z0-9 _-]+$/.test(name))
|
|
432
|
+
continue;
|
|
433
|
+
const executable = join(path, "Contents/MacOS", name);
|
|
434
|
+
if (await system.executable(executable))
|
|
435
|
+
return { path, executable, bundleId, version };
|
|
436
|
+
} catch {}
|
|
437
|
+
}
|
|
438
|
+
throw new Fault(404, "app_not_installed", "Install the current Claude macOS desktop app or supply its absolute .app path with --app-path.");
|
|
439
|
+
}
|
|
342
440
|
|
|
343
441
|
// src/sdk.ts
|
|
344
442
|
class SwitcherError extends Error {
|
|
@@ -555,6 +653,8 @@ function clientFromEnv(env = process.env, options = {}) {
|
|
|
555
653
|
}
|
|
556
654
|
export {
|
|
557
655
|
providerFromPreset,
|
|
656
|
+
detectClaudeDesktopApp,
|
|
657
|
+
detectChatGPTApp,
|
|
558
658
|
clientFromEnv,
|
|
559
659
|
SwitcherError,
|
|
560
660
|
SwitcherClient
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type ProviderRequestTiming } from "./provider-request";
|
|
2
|
+
import { type ReasoningEffort } from "./reasoning";
|
|
1
3
|
import type { HarnessLaunchInput } from "./harness-types";
|
|
2
4
|
import { type CompiledModelPolicy } from "./model-policy";
|
|
3
5
|
export type RoutingEvent = {
|
|
@@ -6,6 +8,7 @@ export type RoutingEvent = {
|
|
|
6
8
|
requestedModel: string;
|
|
7
9
|
resolvedModel?: string;
|
|
8
10
|
reportedModel?: string;
|
|
11
|
+
reasoningEffort?: ReasoningEffort;
|
|
9
12
|
decision: "allow" | "alias" | "reject" | "fallback";
|
|
10
13
|
reason?: string;
|
|
11
14
|
upstreamStatus?: number;
|
|
@@ -16,7 +19,7 @@ type GatewayInput = HarnessLaunchInput & {
|
|
|
16
19
|
onRoutingEvent?: (event: RoutingEvent) => void;
|
|
17
20
|
};
|
|
18
21
|
/** A per-launch credential boundary: the native client never receives the provider key. */
|
|
19
|
-
export declare function createInferenceGateway(input: GatewayInput): {
|
|
22
|
+
export declare function createInferenceGateway(input: GatewayInput, timing?: ProviderRequestTiming): {
|
|
20
23
|
baseUrl: string;
|
|
21
24
|
token: string;
|
|
22
25
|
cleanup: () => Promise<void>;
|
package/dist/launcher.d.ts
CHANGED
|
@@ -2,10 +2,16 @@ import type { PreparedLaunch } from "./harness-types";
|
|
|
2
2
|
import { SwitcherClient } from "./sdk";
|
|
3
3
|
import { type LaunchPlan, type ProviderInput } from "./domain";
|
|
4
4
|
import { type OriContract } from "./ori-backend";
|
|
5
|
+
import type { ChatGPTInstallation, ClaudeDesktopInstallation } from "./desktop-apps";
|
|
6
|
+
import type { ReasoningEffort } from "./reasoning";
|
|
5
7
|
import type { RoutingEvent } from "./inference-gateway";
|
|
6
8
|
export { childEnvironment } from "./harness-environment";
|
|
7
9
|
export type LaunchBackend = "direct" | "ori";
|
|
8
10
|
export type LaunchOptions = {
|
|
11
|
+
desktop?: ChatGPTInstallation;
|
|
12
|
+
claudeDesktop?: ClaudeDesktopInstallation;
|
|
13
|
+
reasoning?: ReasoningEffort;
|
|
14
|
+
dangerouslyBypassApprovalsAndSandbox?: boolean;
|
|
9
15
|
backend?: LaunchBackend;
|
|
10
16
|
oriExecutable?: string;
|
|
11
17
|
cwd?: string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The deliberate unhosted opt-in, canonical name first. */
|
|
2
|
+
export declare const SWITCHER_LOCAL_OPT_IN_ENV_KEYS: readonly ["HASNA_SWITCHER_LOCAL", "SWITCHER_LOCAL"];
|
|
3
|
+
/** The Keychain item the shared resolver reads for this app (account: HASNA_STATION or the short hostname). */
|
|
4
|
+
export declare const SWITCHER_KEYCHAIN_ITEM = "hasna.credentials.switcher.api-key";
|
|
5
|
+
/** The canonical credentials file, as operators know it. */
|
|
6
|
+
export declare const SWITCHER_CREDENTIALS_FILE = "~/.hasna/switcher/config/credentials";
|
|
7
|
+
export type SwitcherLocalOptInEnv = Record<string, string | undefined>;
|
|
8
|
+
/** True when the operator deliberately asked for the unhosted on-box run. */
|
|
9
|
+
export declare function isSwitcherLocalOptIn(env?: SwitcherLocalOptInEnv): boolean;
|
|
10
|
+
/** Every env name that can configure a Switcher authority or credential, resolver-derived. */
|
|
11
|
+
export declare function switcherAuthorityEnvKeys(): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Does the ENVIRONMENT itself declare a Switcher authority or credential?
|
|
14
|
+
*
|
|
15
|
+
* Deliberately narrower than "does a credential resolve": answering it must not
|
|
16
|
+
* touch the Keychain or the filesystem. A DECLARED variable counts even when
|
|
17
|
+
* blank — Switcher has always let Contracts refuse a blank override loudly
|
|
18
|
+
* rather than fall through to another identity or to local data.
|
|
19
|
+
*/
|
|
20
|
+
export declare function hasSwitcherEnvAuthorityIntent(env?: SwitcherLocalOptInEnv): boolean;
|
|
21
|
+
/** True when this environment should be served by the on-box local run. */
|
|
22
|
+
export declare function selectsSwitcherLocalMode(env?: SwitcherLocalOptInEnv): boolean;
|
|
23
|
+
/** The credential sources a fail-closed refusal names. Never a value. */
|
|
24
|
+
export declare function switcherCredentialSources(env?: SwitcherLocalOptInEnv): string[];
|
|
25
|
+
/** The one-line refusal for "nothing configured": tiers consulted plus the opt-in, never a value. */
|
|
26
|
+
export declare function remoteConfigMissingMessage(env?: SwitcherLocalOptInEnv): string;
|
|
27
|
+
/** Print the LOCAL-mode notice once per process. `write` is a test seam. */
|
|
28
|
+
export declare function announceSwitcherLocalMode(home: string, write?: (line: string) => void): void;
|
|
29
|
+
/** Test seam. */
|
|
30
|
+
export declare function resetSwitcherLocalModeAnnouncement(): void;
|