@hasna/switcher 0.2.6 → 0.2.8

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 CHANGED
@@ -11,7 +11,7 @@ source_task: "01a07181-ca8d-70c1-99a2-b276dc5770f3"
11
11
 
12
12
  # Switcher
13
13
 
14
- Launch Claude Code, Codex, Grok Build, OpenCode 2, legacy OpenCode, Kilo, Pi, OMP, DeepSeek Harness, Cline, Hermes, Prime Agent, Gemini CLI or Aider with a chosen compatible provider and its model catalog. An authenticated API owns profiles and run metadata; the CLI starts the native harness on your computer. Import the same HTTP client from `@hasna/switcher/sdk`.
14
+ Launch Claude Code, Codex, Grok Build, OpenCode 2, legacy OpenCode, Kilo, Pi, OMP, DeepSeek Harness, Cline, Hermes, Prime Agent, Antigravity CLI, Junie, Gemini CLI or Aider with a chosen compatible provider and its model catalog. An authenticated API owns profiles and run metadata; the CLI starts the native harness on your computer. Import the same HTTP client from `@hasna/switcher/sdk`.
15
15
 
16
16
  Requires Bun 1.3.14 or newer. Install the native harnesses separately.
17
17
 
@@ -33,6 +33,8 @@ installation guidance for every adapter. If a harness is installed outside
33
33
  | Cline | `cline`, >=3.0.61 | `cline` | [CLI project](https://github.com/cline/cline/tree/main/apps/cli) |
34
34
  | Hermes Agent | `hermes`, >=0.21.0 | NousResearch Hermes Agent official installer | [Quick install](https://github.com/NousResearch/hermes-agent#quick-install) |
35
35
  | Prime Agent | `prime-agent`, >=0.9.2 | PrimeIntellect versioned release artifact | [Project](https://github.com/PrimeIntellect-ai/prime-agent) |
36
+ | Antigravity CLI | `agy`, exactly 1.2.5 | Google official distribution | [Installation](https://antigravity.google/docs/cli/install) |
37
+ | Junie CLI | `junie`, build 3196.5 | JetBrains official distribution | [Documentation](https://junie.jetbrains.com/docs/) |
36
38
  | Gemini CLI | `gemini`, exactly 0.58.0 | `@google/gemini-cli` | [Project](https://github.com/google-gemini/gemini-cli) |
37
39
  | Aider | `aider`, exactly 0.86.2 | `aider-chat` | [Installation](https://aider.chat/docs/install.html) |
38
40
  | Kilo Code | `kilo`, >=7.5.15 | `@kilocode/cli` | [Release v7.5.15](https://github.com/Kilo-Org/kilocode/releases/tag/v7.5.15) |
@@ -109,11 +111,14 @@ Successful inference does not establish browser or computer compatibility for
109
111
  every provider. See the [browser extension guide](https://learn.chatgpt.com/docs/chrome-extension)
110
112
  and [DeepSeek compatibility details](https://api-docs.deepseek.com/guides/responses_api/).
111
113
 
112
- Switcher starts a separate app instance with persistent provider/model state
113
- under `~/.hasna/switcher/state/desktop/PROFILE`. Your regular ChatGPT app and its
114
- signed-in state are preserved. Each profile retains its own local conversations
115
- and preferences across launches; it does not copy the regular app's login or
116
- conversation history. A second launch of the same active profile is refused.
114
+ Switcher starts a separate app instance with private login and Electron state.
115
+ That private overlay remains provider/profile-scoped. `--share-native-state` (or
116
+ an explicit shared-state marker below) projects only the allowlisted native corpus
117
+ into that overlay, so local conversations and instructions can remain available
118
+ without reusing another provider/account's cookies, settings or authentication.
119
+ The canonical Codex corpus is normally `~/.codex`. Your regular ChatGPT app's
120
+ signed-in state is preserved; authentication and cookies are not copied. A second
121
+ launch of the same active provider profile is refused.
117
122
  Keep the launching terminal running until you quit that instance: Switcher owns
118
123
  its inference gateway and stops its own app process on interruption or timeout.
119
124
 
@@ -124,6 +129,112 @@ profile. It does not modify or re-sign the installed app. Select a nonstandard
124
129
  installation with `--app-path /absolute/path/ChatGPT.app`; native CLI arguments,
125
130
  `--executable` and `--backend` are not accepted for desktop launches.
126
131
 
132
+ ### Shared native conversations
133
+
134
+ Sharing is opt-in. Pass `--share-native-state`, set
135
+ `HASNA_CODEX_STATE_HOME`/`HASNA_CLAUDE_STATE_HOME`, or set the compatible
136
+ `SUBSCRIPTIONS_SHARED_HOME_CODEX`/`SUBSCRIPTIONS_SHARED_HOME_CLAUDE` marker.
137
+ Without one of those signals, Switcher keeps its historical provider/account state
138
+ layout and creates no shared links. The command flag selects `~/.codex` or
139
+ `~/.claude`; a custom canonical corpus must be named by a marker. Ambient
140
+ `CODEX_HOME`/`CLAUDE_CONFIG_DIR` is treated only as the current private overlay,
141
+ never silently promoted into the cross-account identity. If both marker forms are
142
+ present they must resolve to the same directory. Markers are consumed by Switcher
143
+ and are not forwarded to provider processes or nested launchers. Directories must
144
+ be absolute, owned and free of writable/symlink redirection. This contract is
145
+ currently supported on Linux and macOS; Windows refuses before creating state.
146
+
147
+ Codex overlays share sessions, archived sessions and `thread-writer-locks`. Native
148
+ skill directories are deliberately excluded: Skills-owned migration and hook
149
+ controls remain authoritative and account-synced skill copies must not enter a
150
+ cross-account corpus. The entire SQLite store uses the canonical
151
+ configuration's `sqlite_home`, or the canonical root; inherited account-specific
152
+ `CODEX_SQLITE_HOME` is ignored. There are no per-database or WAL symlinks.
153
+ `session_index.jsonl` stays an overlay-local native index; legacy index-only names
154
+ remain pending explicit migration. Authentication,
155
+ Electron cookies, `.codex-global-state.json`, plugin caches and worktree metadata
156
+ are not projected between homes. Claude's projects, todos, history and explicit `CLAUDE.md`/`.hasna/instructions`
157
+ policy roots use its common corpus. Commands, agents, rules, credentials, settings,
158
+ native skills and plugin state remain private. Skills continue through the
159
+ reviewed Skills bridge.
160
+
161
+ Both tools share only `.hasna/instructions`, never the rest of `.hasna`. Codex's
162
+ optional `AGENTS.override.md` takes native precedence over `AGENTS.md`; Switcher
163
+ does not create empty versions or dangling links. A later launch links an optional
164
+ file only after the canonical regular file exists and passes validation.
165
+ The desktop config projects only the canonical `instructions`,
166
+ `developer_instructions`, `model_instructions_file`, `compact_prompt`,
167
+ `experimental_compact_prompt_file`, the four
168
+ `include_*_instructions`/`include_environment_context` switches, and
169
+ `project_doc_max_bytes`/`project_doc_fallback_filenames`. Relative model and
170
+ compact instruction files resolve inside the canonical config directory and must be readable trusted
171
+ regular files; they cannot escape into authentication or unrelated state. Native file/config instruction precedence is preserved; routing
172
+ and private authentication settings are rendered separately. Unsupported legacy
173
+ `profile` selection refuses launch rather than silently losing its instructions.
174
+ Codex CLI normally reads these keys directly from its canonical home. When nested
175
+ inside a private authentication home, its audited instruction keys must match the
176
+ canonical projection, including resolved model and compact instruction file paths; missing
177
+ or stale keys visibly refuse launch. Switcher does not rewrite that account's
178
+ configuration or place instruction text in process arguments. Refresh the account
179
+ overlay's instruction projection before retrying a conflicting nested launch.
180
+
181
+ The desktop adapter requests native `thread/list` with all providers and filesystem
182
+ read-repair, then starts, resumes or forks with the current launch provider and model.
183
+ Shared state requires Codex 0.154.0 or newer and the directly verified adapter;
184
+ Ori shared-state/resume support remains refused until separately accepted.
185
+ It disables the supported provider-model fallback on `thread/start`, preserves
186
+ native permissions, and does not rewrite saved transcripts or tool-call IDs. For CLI resume:
187
+
188
+ ```sh
189
+ switcher launch codex --provider PROVIDER --model MODEL --share-native-state -- resume
190
+ switcher launch codex --provider PROVIDER --model MODEL --share-native-state -- resume --last
191
+ switcher launch codex --provider PROVIDER --model MODEL --share-native-state -- resume --all
192
+ switcher launch codex --provider PROVIDER --model MODEL --share-native-state -- resume SESSION_ID
193
+ ```
194
+
195
+ The first three forms use Switcher's cross-provider native catalog discovery,
196
+ then execute native Codex with the exact chosen ID. Shared-state consent also
197
+ means the selected conversation history will be sent through the provider/model
198
+ chosen for this launch; native metadata does not reliably expose an original
199
+ provider/account label, so Switcher does not claim provenance it cannot verify.
200
+ `--all` includes other
201
+ workspaces; normal discovery keeps the current workspace filter. Explicit IDs
202
+ pass directly to native Codex. Discovery sends no inference prompt. Native
203
+ Codex's own picker outside these Switcher forms can still filter by provider.
204
+ Existing nonempty legacy overlay directories are preserved and are never
205
+ silently replaced with links; conflicting state requires an explicit migration.
206
+
207
+ Normal launch reports legacy desktop data as pending migration. Inspect and stage
208
+ an explicit noncredential snapshot with the local native-state command:
209
+
210
+ ```sh
211
+ switcher state import codex --from /absolute/legacy/profile/codex
212
+ # Review planDigest from the dry-run, then bind the exact plan to the mutation:
213
+ switcher state import codex --from /absolute/legacy/profile/codex --entry sessions --apply --plan-digest SHA256
214
+ switcher state import claude --from /absolute/legacy/claude/profile --entry projects --apply --plan-digest SHA256
215
+ ```
216
+
217
+ The default is a read-only plan with a path-redacting `planDigest`. `--apply`
218
+ requires that exact digest, binding explicit mutation consent to the reviewed
219
+ source, destination, selection and file identities. It copies unique allowlisted files, skips byte-identical duplicates, and refuses
220
+ divergent collisions before starting the copy. Recognized native Codex session IDs are also checked across active/archived
221
+ rollouts: divergent versions with different filenames refuse import, while exact
222
+ duplicates are not published twice. `--entry` may be repeated to limit a snapshot.
223
+ Source files stay unchanged; symlinks, hardlinked aliases and
224
+ credential/config/SQLite/index/plugin-cache/native-skill entries cannot be imported.
225
+ All source files are checked again and staged before publishing any new copy.
226
+ No-replace publication never overwrites or deletes a racing writer. If a
227
+ collision appears after publication starts, already published reviewed files are
228
+ preserved and the command requires a new dry-run to reconcile the remainder. Imports are bounded
229
+ to 100,000 entries and 2 GiB per operation.
230
+
231
+ This is **copy-only staging**, not complete migration: the old home can still
232
+ receive writes. Legacy SQLite metadata and index-only display names stay in the
233
+ original, and the pending warning remains. Codex's supported catalog scan repairs
234
+ copied transcript discovery; this does not prove every legacy desktop preference
235
+ or title has migrated. Stop old writers and review their remaining state before
236
+ retiring any old profile. Switcher does not retire or delete it automatically.
237
+
127
238
  `--dry-run` validates app detection and provider/model discovery without opening
128
239
  the app. The SDK offers local installation discovery through `detectChatGPTApp()`;
129
240
  provider/profile/catalog operations continue to use the existing HTTP API.
@@ -303,6 +414,8 @@ Real launches now preflight the local inference credential before catalog refres
303
414
 
304
415
  When a provider credential is missing in an interactive terminal, Switcher uses the trusted `secrets` executable on `PATH` to search metadata only. It displays the selected Secrets account/source and matching vault key references, asks which reference to bind, saves that reference through the existing immutable binding store, resolves the value through the authenticated loopback delivery path, and performs a bounded, non-inference provider authentication check before continuing the original launch. OpenRouter uses its authenticated `GET /api/v1/key` metadata endpoint; its public model catalog is never treated as proof that a key works. Custom providers may declare a relative `credentialCheck` (`GET` or `HEAD`) in provider JSON. Catalog configuration alone is never inferred to validate a credential because a catalog may be public or ignore invalid authorization.
305
416
 
417
+ Discovery requests Secrets' full metadata array with a 257-row limit, preserving compatibility with compact-default and older Secrets CLIs. The extra row detects searches exceeding the 256-reference limit; discovery refuses these results before deduplication and also caps the combined references across searches. Each response remains limited to 256 KiB. This search never requests secret values; broader matches require an explicit vault-key binding.
418
+
306
419
  If no matching key exists, Secrets is unavailable, the selected Keychain/vault cannot be read, or the provider rejects the credential, the structured error names the exact recovery without changing accounts. The first-run binding pins the exact Contracts source and vault authority that were displayed; if that Keychain account, environment tier, profile, or canonical file changes, later launches stop rather than selecting another account. First-run bindings also retain a requirement for a supported provider authentication check, so an unsupported check cannot be bypassed by retrying. Older explicit bindings remain compatible when no safe check is declared; adding `credentialCheck` upgrades them to authenticated preflight without changing their account or origins. Noninteractive launches never prompt and return `credential_setup_required` with explicit binding syntax or the provider environment reference. `--dry-run` preserves its planning contract: it does not search Secrets, create a binding, retrieve a provider credential, or perform provider authentication merely to describe a launch plan. Public and credentialless catalogs may refresh. Authenticated catalogs are read from the saved Switcher snapshot; if none exists, the error names the explicit `switcher models PROVIDER --refresh` command that performs the credential-consuming refresh.
307
420
 
308
421
  For stations that update global tools with Bun, give the vault binding a private, version-pinned npm installation. A later global Bun installation can reset the permissions of its `secrets` executable, including one already repaired, and break every provider using it. The private installation keeps that update path separate. This example uses Secrets `0.4.2`; choose an exact verified release and a **new, unused prefix** for each upgrade:
@@ -419,6 +532,29 @@ Preflight rejects conflicting configured startup commands, blanket approval, upg
419
532
 
420
533
  Aider has no session ID. Each launch writes a separate owner-only transcript under Switcher state, and `--restore-chat-history` copies the last closed conversation for that profile into a new transcript before native restoration. Concurrent runs keep independent history; diagnostic-only runs do not replace it. This does not import an existing standalone Aider transcript. Set `SWITCHER_TEST_AIDER_EXECUTABLE` and run `bun run test:native-aider` for controlled installed-native protocol, edit, history, catalog, hostile-routing and dry-run checks. Paid-provider, Linux and interactive-terminal acceptance remain separate gates.
421
534
 
535
+ ## Antigravity CLI and Junie
536
+
537
+ ```sh
538
+ switcher launch antigravity --provider gemini --model gemini-2.5-flash
539
+ switcher launch junie --provider openrouter --model '~anthropic/claude-sonnet-latest'
540
+ ```
541
+
542
+ Antigravity 1.2.5 uses the native Gemini API. Switcher creates a private native home, supplies the launch directory with `--add-dir`, preserves permission settings and global `GEMINI.md`, and keeps conversations in the profile session directory. Its built-in Flash Lite helper is routed to the policy's `fast` model, which defaults to main. Use `--role-model fast=MODEL` to assign it explicitly. Other non-main roles are unsupported. Global plugins and shared app authentication are not imported, and `~` inside native tools resolves to the private home. Inherited custom routing settings fail preflight.
543
+
544
+ Junie build 3196.5 uses an isolated `custom:switcher` JSON model profile for Chat Completions, Responses or Anthropic Messages. Its primary and faster slots use the managed gateway, with `fast` defaulting to main. Switcher snapshots native user/project settings, disables inherited model/config discovery and keeps a durable profile cache and sessions for native resume. Native permissions, project guidelines and Junie's noninteractive trust behavior remain active. Provider/config/model override flags are reserved. Neither adapter receives the upstream provider key; the child receives an ephemeral gateway credential.
545
+
546
+ The native Gemini preset now uses the distinct `gemini-generate-content` provider ID. Existing saved providers retain their IDs and remain usable by name.
547
+
548
+ ## Claude Code with Amazon Bedrock
549
+
550
+ ```sh
551
+ switcher launch claude --provider bedrock \
552
+ --url https://bedrock-mantle.us-east-1.api.aws/anthropic/v1 \
553
+ --model anthropic.claude-sonnet-5
554
+ ```
555
+
556
+ Use your account's regional Mantle endpoint and a Bedrock API key through `SWITCHER_PROVIDER_BEDROCK`, `AWS_BEARER_TOKEN_BEDROCK`, or a scoped credential binding. Switcher verifies authentication with the same origin's `/v1/models`, discovers the regional catalog, and sends native Anthropic Messages through its managed gateway. AWS credentials and native Bedrock mode are not inherited by the child. IAM/model access, regional availability, billing and key expiry remain provider requirements; catalog visibility alone does not prove inference entitlement. See [Amazon's Messages API contract](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-messages-api.html).
557
+
422
558
  ## Gemini CLI
423
559
 
424
560
  The native Gemini adapter supports exactly Gemini CLI 0.58.0 and the `gemini-generate-content` protocol with `x-api-key` authentication (the native wire header is `x-goog-api-key`). Use `switcher launch gemini --provider gemini --model MODEL`, selecting an ID from the discovered catalog. A compatible custom gateway must implement the same Gemini protocol and discovery contract. Chat Completions, OAuth, Vertex/ADC and Ori are separate interfaces and are not provided by this native adapter.
@@ -511,7 +647,7 @@ Discovery allows at most two retries per page for network failures and HTTP 408,
511
647
  | Harness | Required wire protocol | Native catalog |
512
648
  | --- | --- | --- |
513
649
  | Claude Code ≥2.1.257 | Anthropic Messages | Per-launch `modelPicker` on compatible Claude versions |
514
- | Codex ≥0.153.0 | OpenAI Responses | Startup `model_catalog_json` |
650
+ | Codex ≥0.153.0 | OpenAI Responses | Startup `model_catalog_json`, filtered to the launch policy |
515
651
  | Grok Build ≥1.0.13 | Chat Completions, Responses or Messages | Authenticated loopback remote catalog with upstream model IDs |
516
652
  | OpenCode 2 (tested beta-19157) | Chat Completions, Responses or Messages | Version 2 provider/model configuration and standalone server |
517
653
  | Pi ≥0.85.1 | Chat, Responses, Messages | Provider-scoped native picker and model cycling |
@@ -522,9 +658,13 @@ Discovery allows at most two retries per page for network failures and HTTP 408,
522
658
  | Prime Agent ≥0.9.2 | Chat, Responses, Messages | Native catalog, RPC selection and owned supervisor |
523
659
  | Legacy OpenCode (tested 1.18.29) | Chat, Responses, Messages | Singular-provider models and native diagnostic |
524
660
  | Kilo ≥7.5.15 | Chat, Responses, Messages | Native provider catalog with scoped bridge |
661
+ | Antigravity CLI 1.2.5 | Gemini generateContent | Managed custom model and helper routing |
662
+ | Junie build 3196.5 | Chat, Responses, Messages | Managed custom primary/faster profile |
525
663
  | Gemini CLI 0.58.0 | Gemini generateContent | Exact native dynamic model catalog |
526
664
  | Aider 0.86.2 | Chat, Responses, Messages | Native available-model listing; Responses is buffered |
527
665
 
666
+ New direct Codex launches allow switching among the authenticated eligible catalog snapshot. Explicit and saved restricted policies remain restricted, and their picker shows only permitted models. Subagent and utility models remain pinned to the configured role defaults. See [model policy](docs/MODEL-POLICY.md).
667
+
528
668
  The CLI catalog includes all provider output modalities. Native coding pickers exclude unavailable models and those explicitly lacking a required generation method, text output or tool support; unknown metadata remains unknown. This is a capability filter, not a guarantee of successful tool use. Catalog refresh happens before every launch. Native pickers are startup snapshots, not promised live reloads. OpenCode requires a complete capability object; missing fields use text-only/tool-enabled native defaults with a warning. Its beta `models --standalone` command may return an early empty snapshot; the native `/api/model` API and interactive picker expose the settled catalog.
529
669
 
530
670
  The Claude adapter sets `ANTHROPIC_DEFAULT_MODEL` and the default subagent model to the selected provider model. Explicit subagent definitions and managed model restrictions still apply. These follow the [native model precedence rules](https://code.claude.com/docs/en/model-config).
@@ -577,7 +717,7 @@ Grok uses a per-launch authenticated loopback bridge because its environment ove
577
717
 
578
718
  Hermes uses the same loopback boundary with its documented `custom` provider. The bridge exposes only the Switcher catalog, translates the selected provider's Bearer, `x-api-key` or literal `api-key` credential, and forwards deployment prefixes unchanged. Hermes `state.db` and `sessions/` are linked to a profile-owned stable directory for resume; generated config and bridge credentials remain per-launch. Focused bridge tests cover all three native protocol routes and auth styles, including cleanup of an active stream without caller cancellation. Run `bun scripts/test-native-hermes.ts` with `SWITCHER_TEST_HERMES_EXECUTABLE` for the installed native CLI fixture proof, which performs a real `read_file` loop and deleted-file resume against a generic preset.
579
719
 
580
- Native history and credentials stay with the harness. Resume only with the same profile/provider/model configuration unless the harness explicitly supports a change; cross-provider reasoning/session migration is not provided. Temporary nonsecret picker/config files are removed when the child exits. Run records contain launch/end metadata and initial model, not transcripts or a claim about later native picker selections.
720
+ Codex and Claude can use their [shared native corpus](#shared-native-conversations) only after explicit command or environment consent. Sessions and reviewed instruction roots may cross provider/account overlays; authentication, native skills, settings, plugins and broader capability trees remain private. Other harnesses retain their documented native storage and resume restrictions; cross-provider conversion of incompatible reasoning or session formats is not provided. Temporary nonsecret picker/config files are removed when the child exits. Run records contain launch/end metadata and initial model, not transcripts or a claim about later native picker selections.
581
721
 
582
722
  ## SDK and API
583
723
 
@@ -0,0 +1,7 @@
1
+ import type { HarnessLaunchInput, PreparedLaunch } from "./harness-types";
2
+ export declare const antigravityHelperModel = "gemini-3.1-flash-lite-preview";
3
+ export declare function validateAntigravityConfiguration(cwd: string, env?: NodeJS.ProcessEnv): Promise<{
4
+ home: string;
5
+ settings: any;
6
+ }>;
7
+ export declare function prepareAntigravity(input: HarnessLaunchInput): Promise<PreparedLaunch>;
@@ -0,0 +1,2 @@
1
+ /** The regional AWS Mantle Messages authority documented by Amazon Bedrock. */
2
+ export declare function bedrockMantleOrigin(value: string): string | undefined;
@@ -1,5 +1,6 @@
1
1
  import type { PreparedLaunch } from "./harness-types";
2
2
  import type { ChatGPTInstallation } from "./desktop-apps";
3
+ import { type NativeState } from "./native-state";
3
4
  /** Separate desktop state from the signed-in app. The upstream credential stays
4
5
  * 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>;
6
+ export declare function prepareChatGPTLaunch(native: PreparedLaunch, app: ChatGPTInstallation, stateDir: string, sessionDir: string, sharedState?: NativeState): Promise<PreparedLaunch>;