@hasna/switcher 0.2.7 → 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 +117 -6
- package/dist/chatgpt-launch.d.ts +2 -1
- package/dist/cli/index.js +1190 -65
- package/dist/codex-session-discovery.d.ts +24 -0
- package/dist/codex-state-bridge.d.ts +14 -0
- package/dist/codex-state-bridge.js +568 -0
- package/dist/harness-arguments.d.ts +8 -0
- package/dist/harness-types.d.ts +2 -0
- package/dist/launcher.d.ts +3 -0
- package/dist/mcp/index.js +6 -3
- package/dist/native-state-import.d.ts +44 -0
- package/dist/native-state.d.ts +32 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -111,11 +111,14 @@ Successful inference does not establish browser or computer compatibility for
|
|
|
111
111
|
every provider. See the [browser extension guide](https://learn.chatgpt.com/docs/chrome-extension)
|
|
112
112
|
and [DeepSeek compatibility details](https://api-docs.deepseek.com/guides/responses_api/).
|
|
113
113
|
|
|
114
|
-
Switcher starts a separate app instance with
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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.
|
|
119
122
|
Keep the launching terminal running until you quit that instance: Switcher owns
|
|
120
123
|
its inference gateway and stops its own app process on interruption or timeout.
|
|
121
124
|
|
|
@@ -126,6 +129,112 @@ profile. It does not modify or re-sign the installed app. Select a nonstandard
|
|
|
126
129
|
installation with `--app-path /absolute/path/ChatGPT.app`; native CLI arguments,
|
|
127
130
|
`--executable` and `--backend` are not accepted for desktop launches.
|
|
128
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
|
+
|
|
129
238
|
`--dry-run` validates app detection and provider/model discovery without opening
|
|
130
239
|
the app. The SDK offers local installation discovery through `detectChatGPTApp()`;
|
|
131
240
|
provider/profile/catalog operations continue to use the existing HTTP API.
|
|
@@ -305,6 +414,8 @@ Real launches now preflight the local inference credential before catalog refres
|
|
|
305
414
|
|
|
306
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.
|
|
307
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
|
+
|
|
308
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.
|
|
309
420
|
|
|
310
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:
|
|
@@ -606,7 +717,7 @@ Grok uses a per-launch authenticated loopback bridge because its environment ove
|
|
|
606
717
|
|
|
607
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.
|
|
608
719
|
|
|
609
|
-
|
|
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.
|
|
610
721
|
|
|
611
722
|
## SDK and API
|
|
612
723
|
|
package/dist/chatgpt-launch.d.ts
CHANGED
|
@@ -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>;
|