@hasna/switcher 0.1.7 → 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 +166 -4
- package/dist/chatgpt-launch.d.ts +5 -0
- package/dist/claude-desktop-launch.d.ts +11 -0
- package/dist/cli/index.js +1122 -368
- 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 +26 -4
- 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 +199 -69
- package/dist/inference-gateway.d.ts +2 -0
- package/dist/launcher.d.ts +6 -0
- package/dist/mcp/index.js +145 -78
- 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 +156 -0
- package/dist/sdk.js +199 -69
- package/dist/serve/index.js +290 -74
- package/openapi.json +210 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -47,6 +47,139 @@ switcher --help
|
|
|
47
47
|
switcher doctor
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
## ChatGPT desktop with a provider
|
|
51
|
+
|
|
52
|
+
From 0.1.9, use the installed macOS ChatGPT app with a selected provider and model:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
switcher launch chatgpt --provider deepseek --model deepseek-flash
|
|
56
|
+
switcher launch chatgpt --provider openrouter --model anthropic/claude-sonnet-4.6
|
|
57
|
+
switcher launch chatgpt --provider my-provider --model my-model
|
|
58
|
+
switcher launch chatgpt --provider deepseek --model deepseek-flash --dry-run
|
|
59
|
+
switcher launch chatgpt --provider deepseek --model deepseek-flash --reasoning max \
|
|
60
|
+
--dangerously-bypass-approvals-and-sandbox
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This runs **local Codex conversations inside the unified ChatGPT app** through
|
|
64
|
+
Switcher's provider gateway. ChatGPT cloud Chat/Work, Preview Edit and other
|
|
65
|
+
account-only features use their own service and are outside this routing path.
|
|
66
|
+
The classic ChatGPT app (`com.openai.chat`) cannot use this launcher. The current
|
|
67
|
+
unified ChatGPT app and its former Codex name (`com.openai.codex`) are supported;
|
|
68
|
+
the bundled Codex runtime must meet the Codex CLI minimum above.
|
|
69
|
+
|
|
70
|
+
Providers must support the Responses protocol and the selected model's tool
|
|
71
|
+
calling. DeepSeek, OpenRouter, OpenAI and other Responses-compatible presets
|
|
72
|
+
use the same provider/model catalog and credential bindings as terminal Codex.
|
|
73
|
+
Use `switcher models PROVIDER` to find exact model IDs. Custom providers can be
|
|
74
|
+
registered with `switcher providers add NAME --url URL --protocol openai-responses`.
|
|
75
|
+
There is no automatic conversion from Chat Completions or Anthropic Messages.
|
|
76
|
+
|
|
77
|
+
For third-party Responses endpoints, Switcher converts the desktop's unpaired
|
|
78
|
+
`codex_app` task-message outputs to ordinary user input, preserving their full
|
|
79
|
+
text and images. This supports creating a task and sending follow-up messages
|
|
80
|
+
without the missing-`call_id` errors from strict providers. Paired tool results
|
|
81
|
+
keep their original format; OpenAI's own endpoint receives native messages.
|
|
82
|
+
|
|
83
|
+
`--reasoning EFFORT` sets the initial effort (also supported for direct terminal
|
|
84
|
+
Codex launches). DeepSeek's picker exposes none, low, high and max; its Responses
|
|
85
|
+
API maps minimal to low and medium/xhigh to high. Other models can declare an
|
|
86
|
+
exact `reasoningEfforts` array through `models add/update --file FILE`. An explicit
|
|
87
|
+
effort also enables that choice for models whose catalog omits effort metadata;
|
|
88
|
+
the provider must support it. The app can change effort per conversation, and
|
|
89
|
+
routing events record the value actually sent upstream.
|
|
90
|
+
|
|
91
|
+
`--dangerously-bypass-approvals-and-sandbox` explicitly selects full access:
|
|
92
|
+
commands can edit files and use the network without approval prompts or a
|
|
93
|
+
sandbox. Without that flag, desktop launches start with workspace-write and
|
|
94
|
+
on-request approvals. These are startup defaults; the app's own permission
|
|
95
|
+
controls and managed requirements still apply. Start a new conversation after
|
|
96
|
+
changing launch defaults; existing conversations can retain their own settings.
|
|
97
|
+
|
|
98
|
+
Switcher starts a separate app instance with persistent provider/model state
|
|
99
|
+
under `~/.hasna/switcher/state/desktop/PROFILE`. Your regular ChatGPT app and its
|
|
100
|
+
signed-in state are preserved. Each profile retains its own local conversations
|
|
101
|
+
and preferences across launches; it does not copy the regular app's login or
|
|
102
|
+
conversation history. A second launch of the same active profile is refused.
|
|
103
|
+
Keep the launching terminal running until you quit that instance: Switcher owns
|
|
104
|
+
its inference gateway and stops its own app process on interruption or timeout.
|
|
105
|
+
|
|
106
|
+
Upstream API keys remain in the Switcher gateway. Only a temporary loopback
|
|
107
|
+
credential reaches the child; its private auth file is removed after exit.
|
|
108
|
+
Switcher refuses to overwrite authentication added manually to a provider
|
|
109
|
+
profile. It does not modify or re-sign the installed app. Select a nonstandard
|
|
110
|
+
installation with `--app-path /absolute/path/ChatGPT.app`; native CLI arguments,
|
|
111
|
+
`--executable` and `--backend` are not accepted for desktop launches.
|
|
112
|
+
|
|
113
|
+
`--dry-run` validates app detection and provider/model discovery without opening
|
|
114
|
+
the app. The SDK offers local installation discovery through `detectChatGPTApp()`;
|
|
115
|
+
provider/profile/catalog operations continue to use the existing HTTP API.
|
|
116
|
+
|
|
117
|
+
The opt-in `test:native-chatgpt-runtime` script exercises the installed app's
|
|
118
|
+
bundled runtime against a real provider using a fresh isolated profile. Set
|
|
119
|
+
`SWITCHER_NATIVE_CHATGPT_PROVIDER` and `SWITCHER_NATIVE_CHATGPT_MODEL` to run it.
|
|
120
|
+
It verifies selected-model configuration, direct responses, delegated task
|
|
121
|
+
creation, follow-up delivery, and history replay against the real provider.
|
|
122
|
+
It is separate from visual desktop acceptance.
|
|
123
|
+
|
|
124
|
+
References: [OpenAI custom provider configuration](https://learn.chatgpt.com/docs/config-file/config-advanced),
|
|
125
|
+
[community desktop custom-model profiles](https://github.com/ademisler/codex-desktop-custom-models),
|
|
126
|
+
[reported signed-in provider routing issue](https://github.com/openai/codex/issues/37245),
|
|
127
|
+
and [Preview Edit routing limitation](https://github.com/openai/codex/issues/37315),
|
|
128
|
+
and [DeepSeek thinking controls](https://api-docs.deepseek.com/guides/thinking_mode/).
|
|
129
|
+
|
|
130
|
+
## Claude desktop with a provider
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
switcher launch claude-desktop --provider deepseek --model deepseek-flash
|
|
134
|
+
switcher launch claude-desktop --provider my-messages-provider --model vendor/model
|
|
135
|
+
switcher launch claude-desktop --provider deepseek --model deepseek-flash --dry-run
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Requires macOS and Claude desktop 1.52386.0 or newer. This uses the app's
|
|
139
|
+
supported third-party gateway mode and its own downloaded Claude Code engine;
|
|
140
|
+
a separately installed Claude Code CLI is not required. `launch claude` keeps
|
|
141
|
+
launching the terminal CLI. `detectClaudeDesktopApp()` is available in the SDK.
|
|
142
|
+
|
|
143
|
+
The provider must implement Anthropic Messages, including streaming and tool
|
|
144
|
+
calling for the chosen model. DeepSeek and compatible gateway presets select
|
|
145
|
+
the Messages endpoint automatically. Saved provider IDs retain their explicit
|
|
146
|
+
protocol. Switcher does not convert Chat Completions or Responses into Messages.
|
|
147
|
+
A configured provider works in both desktop apps when it offers both required
|
|
148
|
+
APIs; a preset's existence is not proof that every model supports every feature.
|
|
149
|
+
|
|
150
|
+
Claude uses its vendor-supported `~/Library/Application Support/Claude-3p`
|
|
151
|
+
profile, separate from the regular signed-in Claude profile. Only one third-party
|
|
152
|
+
instance can run at a time; quit it before switching providers. Switcher adds a
|
|
153
|
+
temporary configuration-library entry, leases that profile, and restores the
|
|
154
|
+
previous selection on exit. Its conversations remain in Claude-3p. Configuration
|
|
155
|
+
changes made outside Switcher are preserved and reported for review. Managed
|
|
156
|
+
Claude configurations are not overridden. No app patching, re-signing or
|
|
157
|
+
restricted development flags are used.
|
|
158
|
+
|
|
159
|
+
The selected model fills Claude's normal, planning and fast model slots using
|
|
160
|
+
explicit gateway aliases. `--role-model planning=MODEL` and `--role-model
|
|
161
|
+
fast=MODEL` can select different models from the same provider. The gateway
|
|
162
|
+
records the actual upstream model. Display labels identify your provider model;
|
|
163
|
+
the aliases do not change that model into an Anthropic model.
|
|
164
|
+
|
|
165
|
+
Choose effort and permissions in Claude's own controls; the model must support
|
|
166
|
+
what Claude sends. Switcher's `--reasoning` and
|
|
167
|
+
`--dangerously-bypass-approvals-and-sandbox` flags currently apply to Codex and
|
|
168
|
+
ChatGPT, and are rejected for Claude desktop. Cowork and account-dependent
|
|
169
|
+
features retain their native requirements. Only a temporary scoped loopback
|
|
170
|
+
credential is written to the private configuration file; the upstream provider
|
|
171
|
+
key stays in Switcher. Keep Switcher running while using the launched instance.
|
|
172
|
+
|
|
173
|
+
Live acceptance on macOS used DeepSeek `deepseek-flash`: ChatGPT local Codex
|
|
174
|
+
returned the requested test marker with reasoning and Full access visible;
|
|
175
|
+
Claude's third-party chat returned its requested marker, with successful gateway
|
|
176
|
+
traces identifying `deepseek-flash`. Other compatible providers have adapter
|
|
177
|
+
coverage, not a claim of live acceptance on every model.
|
|
178
|
+
|
|
179
|
+
References: [Claude third-party gateway](https://claude.com/docs/third-party/claude-desktop/gateway),
|
|
180
|
+
[configuration library and model tiers](https://claude.com/docs/third-party/claude-desktop/configuration),
|
|
181
|
+
and [CC Switch's Claude desktop integration](https://github.com/Chenx-13/cc_switch/blob/main/docs/user-manual/en/2-providers/2.6-claude-desktop.md).
|
|
182
|
+
|
|
50
183
|
## Direct launch
|
|
51
184
|
|
|
52
185
|
The direct launch flow is available from 0.1.1. The additional OMP, DeepSeek Harness, Cline, Hermes, Prime Agent, legacy OpenCode, Kilo, Gemini CLI and Aider adapters are introduced in 0.1.2. Version 0.1.0 requires explicit API/provider/profile setup.
|
|
@@ -291,16 +424,45 @@ Claude Code with a non-Claude model is experimental and unsupported by Anthropic
|
|
|
291
424
|
|
|
292
425
|
For Claude Code using the official DeepSeek Messages endpoint, Switcher defaults `CLAUDE_CODE_AUTO_COMPACT_WINDOW` to `786432`, following [DeepSeek's integration guidance](https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code/). An explicitly set environment value takes precedence. Recognized provider context-overflow errors become a sanitized `prompt is too long` error so the native client can compact or guide recovery; unrelated errors retain the sanitized upstream status. Existing launches must pick up the compaction setting or start a new launch to use this default.
|
|
293
426
|
|
|
294
|
-
|
|
427
|
+
DeepSeek officially released V4.1 Flash on 2026-09-10. Its API model ID is `deepseek-flash`, as documented in the [official release notes](https://api-docs.deepseek.com/updates/) and [API quick start](https://api-docs.deepseek.com/). New DeepSeek presets include that model with text/image input and tool support, and support Chat Completions, Anthropic Messages, and Responses (for Codex). Saved providers and profiles keep their existing model selections. Configure an existing provider explicitly to adopt the new model:
|
|
295
428
|
|
|
296
429
|
```sh
|
|
297
|
-
switcher models add
|
|
430
|
+
switcher models add deepseek-messages deepseek-flash --name "DeepSeek V4.1 Flash"
|
|
431
|
+
switcher launch claude --provider deepseek-messages --model deepseek-flash
|
|
432
|
+
# Or create the documented Responses preset and select the model directly:
|
|
433
|
+
switcher launch codex --provider deepseek --model deepseek-flash
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Configure a new model on any saved provider without editing the provider's JSON:
|
|
437
|
+
|
|
438
|
+
```sh
|
|
439
|
+
switcher models add my-provider vendor/new-model --name "New model"
|
|
440
|
+
switcher models add my-provider vendor/detailed-model --file model.json
|
|
441
|
+
switcher models config my-provider
|
|
442
|
+
switcher models list my-provider --refresh
|
|
443
|
+
switcher models update my-provider vendor/new-model --name "Preview" --expires-on 2027-01-01
|
|
444
|
+
switcher models remove my-provider vendor/new-model
|
|
298
445
|
switcher models my-provider --refresh
|
|
299
446
|
```
|
|
300
447
|
|
|
301
|
-
|
|
448
|
+
A model JSON object needs `id` and `name`; it can also carry `contextWindow`, `maxOutputTokens`, `inputModalities`, `outputModalities`, `supportedParameters`, `supportedGenerationMethods`, `available`, `description`, and `expiresOn`. The file ID must match the command. Unknown fields, raw credential fields, invalid dates and blank/control-character model IDs are rejected. `models update` replaces that model's saved metadata: omit an optional field from the replacement to clear it. `models config` reads only saved settings and makes no provider request. SDK clients expose `addModel`, `updateModel`, and `removeModel`; MCP exposes `models_add`, `models_update`, and `models_remove` with the same behavior.
|
|
449
|
+
|
|
450
|
+
For providers using discovery, configured models live in `additionalModels`; discovery still runs and its errors still block launch. Additions merge by ID and override only supplied remote metadata. Removing an addition reveals any upstream entry with the same ID. For manual catalogs, model commands edit `manualModels`. Edits use the provider's current version and fail on concurrent changes rather than overwriting them. Existing profiles are not silently repointed when a model is removed or replaced.
|
|
451
|
+
|
|
452
|
+
`--expires-on` is optional and accepts a real `YYYY-MM-DD` date, inclusive in UTC. Expired models remain visible with `expired: true` and `codingEligible: false`; new launches, policy roles, native picker catalogs and subsequent gateway requests reject them. Existing processes are not stopped. Expiry is operator metadata, not a guarantee of upstream availability.
|
|
453
|
+
|
|
454
|
+
Create an arbitrary provider with a starter model or a JSON array of model objects:
|
|
455
|
+
|
|
456
|
+
```sh
|
|
457
|
+
switcher providers add deployment --url https://inference.example/v1 --protocol openai-responses \
|
|
458
|
+
--credential-env SWITCHER_PROVIDER_DEPLOYMENT --catalog-format none --model team/deployment
|
|
459
|
+
switcher providers add catalog-provider --url https://inference.example/v1 --protocol openai-chat \
|
|
460
|
+
--credential-env SWITCHER_PROVIDER_CUSTOM --models-file models.json
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
`--catalog-format none` explicitly selects a manual catalog and avoids model discovery. Without it, starter models supplement discovery. Credential flags store reference names only; use the existing credential binding commands to configure their source.
|
|
302
464
|
|
|
303
|
-
For
|
|
465
|
+
For advanced provider settings, use `providers add ID --file provider.json` with `manualModels` when discovery is unavailable. Each model needs `id` and `name`; optional fields are `contextWindow`, `maxOutputTokens`, `inputModalities`, `outputModalities`, `supportedParameters`, and `available`. Use `catalogBaseUrl` and `modelsPath` for a separate discovery root/path; CLI equivalents are `--catalog-url` and `--models-path`. Use `catalogFormat: "ollama"` for `/api/tags`. Mistral presets select a capability-aware parser, including archived status. Together presets select its native bare-array parser. Fireworks requires `--catalog-account-id ID` or an explicit catalog URL and retains count evidence across its paginated account catalog. DashScope requires an explicit region/workspace `--catalog-url` with `--catalog-format dashscope`. Z.AI currently requires an explicit catalog or manual models because its documented API has no model-list contract. MiniMax defaults to its `.cn` Open Platform endpoints; use an explicit authority and credential reference for another product or region. A different authenticated catalog origin requires an explicit `catalogCredentialEnv`; a public catalog can declare `catalogAuthStyle: "none"`. Standard credential aliases are resolved only for the matching built-in provider origin. The default parser follows Anthropic-style `has_more/last_id` pagination and otherwise expects an OpenAI-style `data` array. HTTP redirects are rejected.
|
|
304
466
|
|
|
305
467
|
Grok uses a per-launch authenticated loopback bridge because its environment overlay cannot define providers. The bridge serves model metadata and forwards the selected protocol unchanged. It holds upstream credentials only in memory; Grok receives an ephemeral local token. The same bridge handles credentialless endpoints and OpenCode auth-header mismatches. Bridged requests are limited to 4 MiB and four minutes. Grok resumes retain the selected profile model. Use `-- --resume SESSION_ID -p PROMPT` for headless continuation, or omit the prompt and type after the interactive session loads. Interactive resume with an inline positional prompt is rejected because the native client can send it before applying the selected model. Grok 1.0.13 passed source and installed development CLI resume checks against a controlled Messages fixture and live DeepSeek Flash. OpenCode's provider identity stays stable across temporary bridge ports; `-- run --session SESSION_ID PROMPT` resumes with fresh launch settings. The installed beta-19157 passed two-process Messages resume checks against a controlled local upstream and live DeepSeek Flash, including a proof-file read and preserved history. Other provider/protocol and registry-release cells remain tracked separately in COMPATIBILITY.md.
|
|
306
468
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PreparedLaunch } from "./harness-types";
|
|
2
|
+
import type { ChatGPTInstallation } from "./desktop-apps";
|
|
3
|
+
/** Separate desktop state from the signed-in app. The upstream credential stays
|
|
4
|
+
* in the parent gateway. SQLite releases the profile lease even after a crash. */
|
|
5
|
+
export declare function prepareChatGPTLaunch(native: PreparedLaunch, app: ChatGPTInstallation, stateDir: string, sessionDir: string): Promise<PreparedLaunch>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ClaudeDesktopInstallation } from "./desktop-apps";
|
|
2
|
+
import type { HarnessLaunchInput, PreparedLaunch } from "./harness-types";
|
|
3
|
+
export declare const claudeDesktopDataDirectory: () => string;
|
|
4
|
+
type DesktopSystem = {
|
|
5
|
+
userData: string;
|
|
6
|
+
assertAvailable: () => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
/** Use the vendor-supported local configuration library, preserving the prior
|
|
9
|
+
* selection. The signed app rejects custom userData development overrides. */
|
|
10
|
+
export declare function prepareClaudeDesktopLaunch(input: HarnessLaunchInput, app: ClaudeDesktopInstallation, sessionDir: string, system?: DesktopSystem): Promise<PreparedLaunch>;
|
|
11
|
+
export {};
|