@hasna/switcher 0.2.9 → 0.2.11
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 +55 -25
- package/dist/claude-user-settings.d.ts +3 -0
- package/dist/cli/index.js +364 -140
- package/dist/index.js +8 -3
- package/dist/mcp/index.js +78 -24
- package/dist/native-state.d.ts +3 -0
- package/dist/opencode-authentication.d.ts +11 -0
- package/dist/sdk.js +8 -3
- package/dist/serve/index.js +2 -2
- package/hasna.contract.json +1 -1
- package/openapi.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -112,9 +112,9 @@ every provider. See the [browser extension guide](https://learn.chatgpt.com/docs
|
|
|
112
112
|
and [DeepSeek compatibility details](https://api-docs.deepseek.com/guides/responses_api/).
|
|
113
113
|
|
|
114
114
|
Switcher starts a separate app instance with private login and Electron state.
|
|
115
|
-
That private overlay remains provider/profile-scoped. `--share-native-state`
|
|
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
|
|
115
|
+
That private overlay remains provider/profile-scoped. For Codex, `--share-native-state`
|
|
116
|
+
(or an explicit shared-state marker below) projects only the allowlisted native corpus
|
|
117
|
+
into that overlay, so local conversations, skills and instructions can remain available
|
|
118
118
|
without reusing another provider/account's cookies, settings or authentication.
|
|
119
119
|
The canonical Codex corpus is normally `~/.codex`. Your regular ChatGPT app's
|
|
120
120
|
signed-in state is preserved; authentication and cookies are not copied. A second
|
|
@@ -131,32 +131,60 @@ installation with `--app-path /absolute/path/ChatGPT.app`; native CLI arguments,
|
|
|
131
131
|
|
|
132
132
|
### Shared native conversations
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
`
|
|
134
|
+
Claude CLI and desktop share their canonical sessions, skills and instructions by
|
|
135
|
+
default. `--no-share-native-state` explicitly disables this projection, even when
|
|
136
|
+
a state marker is inherited. For CLI launches without a configured native home,
|
|
137
|
+
it selects a persistent private home for that Switcher profile. Existing shared
|
|
138
|
+
links, canonical-home overlap or redirected Codex databases refuse isolation;
|
|
139
|
+
Switcher never unlinks them or rewrites their configuration. Select a separate
|
|
140
|
+
profile to keep isolated state. Ori refuses explicit isolation until its native
|
|
141
|
+
state contract is verified; use the direct backend.
|
|
142
|
+
The existing `--share-native-state` flag remains supported; passing both flags is
|
|
143
|
+
an error. Programmatic callers use `shareNativeState: false` for the same opt-out.
|
|
144
|
+
|
|
145
|
+
Codex CLI and ChatGPT default sharing remains pending native writer/artifact
|
|
146
|
+
admission for the private-authentication/shared-corpus contract. Their existing
|
|
147
|
+
`--share-native-state` and marker paths remain available with all current version,
|
|
148
|
+
instruction, collision and adapter checks; a version string alone does not establish
|
|
149
|
+
that broader compatibility. This is a remaining implementation prerequisite.
|
|
150
|
+
|
|
151
|
+
The default corpus is `~/.codex` or `~/.claude`. To select another canonical corpus,
|
|
152
|
+
set `HASNA_CODEX_STATE_HOME`/`HASNA_CLAUDE_STATE_HOME`, or the compatible
|
|
136
153
|
`SUBSCRIPTIONS_SHARED_HOME_CODEX`/`SUBSCRIPTIONS_SHARED_HOME_CLAUDE` marker.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
cross-account corpus. The entire SQLite store uses the canonical
|
|
154
|
+
Ambient `CODEX_HOME`/`CLAUDE_CONFIG_DIR` selects the current private overlay, never
|
|
155
|
+
the cross-account identity. If both marker forms are present they must resolve
|
|
156
|
+
to the same directory. Markers are consumed by Switcher and are not forwarded to
|
|
157
|
+
provider processes or nested launchers. Directories must be absolute, owned and
|
|
158
|
+
free of writable/symlink redirection. Shared projection is supported on Linux
|
|
159
|
+
and macOS; Windows refuses before creating state. An explicit opt-out validates
|
|
160
|
+
corpus identities to reject overlap, without creating a canonical corpus.
|
|
161
|
+
|
|
162
|
+
Codex overlays share sessions, archived sessions, `thread-writer-locks` and
|
|
163
|
+
`skills`. Skill directories use the same guarded projection as sessions: edits
|
|
164
|
+
and deletions remain visible across overlays, and no account copy is merged over
|
|
165
|
+
the canonical Skills projection. Skills-owned authoring, migration and hooks
|
|
166
|
+
remain authoritative. The entire SQLite store uses the canonical
|
|
151
167
|
configuration's `sqlite_home`, or the canonical root; inherited account-specific
|
|
152
168
|
`CODEX_SQLITE_HOME` is ignored. There are no per-database or WAL symlinks.
|
|
153
169
|
`session_index.jsonl` stays an overlay-local native index; legacy index-only names
|
|
154
170
|
remain pending explicit migration. Authentication,
|
|
155
171
|
Electron cookies, `.codex-global-state.json`, plugin caches and worktree metadata
|
|
156
|
-
are not projected between homes. Claude's projects
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
reviewed Skills bridge.
|
|
172
|
+
are not projected between homes. Claude's projects (including their native
|
|
173
|
+
project memories), todos, skills, history and explicit `CLAUDE.md`/`.hasna/instructions`
|
|
174
|
+
policy roots use its common corpus. Commands, agents, rules, credentials, settings
|
|
175
|
+
and plugin state remain private. Skills continue through the reviewed Skills bridge.
|
|
176
|
+
For a new Claude private home, Switcher seeds supported user settings from the
|
|
177
|
+
effective `CLAUDE_CONFIG_DIR` (or `~/.claude`), including permissions, sandbox policy,
|
|
178
|
+
language, output style, thinking/effort and display preferences. The copy stays at
|
|
179
|
+
user-settings scope, so native project/local and managed precedence is preserved.
|
|
180
|
+
Existing private settings and later native edits are retained without overwrite;
|
|
181
|
+
later changes to the original user file are not automatically merged. The selected
|
|
182
|
+
Switcher profile owns model/picker routing. Environment, credential helpers,
|
|
183
|
+
hooks/plugins and other unsupported settings refuse before launch instead of
|
|
184
|
+
silently dropping policy or copying credentials. Authentication files are never copied.
|
|
185
|
+
Existing private skill directories and unsafe links fail before any projection.
|
|
186
|
+
Legacy `state import` still excludes skills: it must not resurrect removed
|
|
187
|
+
Skills-owned entries from an old account copy.
|
|
160
188
|
|
|
161
189
|
Both tools share only `.hasna/instructions`, never the rest of `.hasna`. Codex's
|
|
162
190
|
optional `AGENTS.override.md` takes native precedence over `AGENTS.md`; Switcher
|
|
@@ -412,7 +440,9 @@ Bind an existing vault key once, then launch without an external wrapper. New bi
|
|
|
412
440
|
|
|
413
441
|
Real launches now preflight the local inference credential before catalog refresh and before an interactive model picker. An existing environment credential is preserved without creating a binding. An existing binding remains authoritative, including its exact Secrets operator account and allowed provider origins; a locked source, an unauthorized destination, or rejected provider credential is terminal and never falls through to another account.
|
|
414
442
|
|
|
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
|
|
443
|
+
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 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.
|
|
444
|
+
|
|
445
|
+
OpenCode Zen checks its supplied key with one fixed synthetic question to the documented free `jev-1.13-free` model. Before sending the selected key, Switcher requires rejection of invalid keys through both the legacy and migrated routes: an existing legacy key may also have been migrated. Anonymous `public` credentials and whitespace-containing tokens are rejected. The check uses a shared ten-second deadline and bounded JSON responses, follows no redirects, sends no user prompt or project data, and has no paid-model fallback. The free alias is a limited-time provider offering; if the check becomes unavailable, launch stops with the selected binding preserved. This proves key authentication, not access to every paid model. The coding model and provider chosen for the actual launch remain unchanged. An explicitly configured `credentialCheck` retains precedence. See [OpenCode's Jev endpoint and free-model pricing](https://opencode.ai/docs/zen/#jev).
|
|
416
446
|
|
|
417
447
|
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
448
|
|
|
@@ -717,7 +747,7 @@ Grok uses a per-launch authenticated loopback bridge because its environment ove
|
|
|
717
747
|
|
|
718
748
|
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.
|
|
719
749
|
|
|
720
|
-
|
|
750
|
+
Claude uses its [shared native corpus](#shared-native-conversations) by default, with explicit isolation available. Codex default sharing awaits native writer admission; its existing command/marker selection remains supported. Sessions, skills and reviewed instruction roots may cross provider/account overlays; authentication, 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.
|
|
721
751
|
|
|
722
752
|
## SDK and API
|
|
723
753
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Seed a new private settings scope once, preserving native edits on later
|
|
2
|
+
* launches. No symlink, overwrite, credential migration or precedence change. */
|
|
3
|
+
export declare function prepareClaudeUserSettings(overlayHome: string, environment?: NodeJS.ProcessEnv): Promise<void>;
|