@hasna/switcher 0.2.21 → 0.2.23

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.
@@ -68,7 +68,7 @@ function canonicalPolicyJSON(value) {
68
68
  return JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b))) : item);
69
69
  }
70
70
  // package.json
71
- var version = "0.2.21";
71
+ var version = "0.2.23";
72
72
 
73
73
  // src/version.ts
74
74
  var VERSION = version;
@@ -922,7 +922,7 @@ var openapi_default = {
922
922
  openapi: "3.0.3",
923
923
  info: {
924
924
  title: "Switcher API",
925
- version: "0.2.21",
925
+ version: "0.2.23",
926
926
  description: "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
927
927
  },
928
928
  security: [
@@ -119,6 +119,33 @@ SWITCHER_GATEWAY=local switcher launch ... # use the per-launch gateway of 0.2
119
119
  harness never started removes its file. A running gateway older than 0.2.21 refuses
120
120
  the route; the launch then registers as before and prints a warning naming
121
121
  `switcher gateway install`.
122
+ Sessions dispatched by 0.2.19 to 0.2.22 without a durable route (before 0.2.21, or
123
+ under a gateway that refused the route) replay a picker-only
124
+ `claude-settings-<digest>.json` from the same folder, and Claude's background host
125
+ restarts them without `ANTHROPIC_BASE_URL` or a token, so they come up "Not logged
126
+ in". Since 0.2.23 a launch with a durable route also writes its `env` block (the same
127
+ loopback base URL and launch token as its route file) into each of those picker
128
+ files: only this user's regular files with a model picker, mode 0600 and a single
129
+ link. Each is rewritten in place by an atomic rename, each time a launch with a route
130
+ starts, so the files carry the newest such launch's route. Such a session reaches
131
+ that launch the next time its host starts it. When the service stops accepting the
132
+ launch's token, or the launch is revoked, it removes the block again from each picker
133
+ file whose token is that launch's (single-link files only), leaving the picker byte
134
+ for byte as it was; a file a later launch gave its own route keeps that route. Each
135
+ rewrite is synced before its rename; a temporary file an interrupted rewrite left
136
+ behind is removed with the route when it carries that launch's token, or when it is a
137
+ partial write last modified more than a minute earlier (so a write still in progress
138
+ is never removed). Taking the route back needs a 0.2.23 or later gateway, which says
139
+ so in its answer to the route registration (`releasesAdoptedRoutes: true`). With an
140
+ older gateway (0.2.21 or 0.2.22) the launch keeps its own route file but gives its
141
+ route to no earlier picker file, and prints a warning naming `switcher gateway install`.
142
+ Since 0.2.23 a launch without a route (`SWITCHER_GATEWAY=local`, a persistent gateway
143
+ that is unavailable or refused the launch or the route) never uses those files: it
144
+ writes its own picker-only `claude-picker-<digest>.json`, and no route is ever written
145
+ into a `claude-picker-*` file, so Claude never applies another launch's route over
146
+ its environment. A session such a launch started is not reached by a later route
147
+ either. A session pinned to a per-launch `launch-XXXXXX/claude-settings.json` from
148
+ before 0.2.19 is not reached and needs a new `switcher launch`.
122
149
 
123
150
  Every request is dispatched by its token to that launch's own handler. One launch
124
151
  cannot use another launch's credential, catalog, aliases or fallbacks.
@@ -172,7 +199,12 @@ While the service runs, a client always gets an HTTP answer it can show:
172
199
  create the directory first.
173
200
  - Provider credentials are never written to disk, logs, unit files or command lines,
174
201
  and neither are launch tokens, with one exception: a Claude launch's durable route
175
- file (step 7) holds that launch's token. The file is created once, exclusively, mode
202
+ file (step 7) holds that launch's token. Since 0.2.23 so do the profile's
203
+ `claude-settings-<digest>.json` picker files from earlier launches that the newest
204
+ launch with a route gave its route to (step 7). Those are not created once: each launch
205
+ with a route rewrites them in place by an atomic rename of a private (0600) temporary
206
+ file in the same folder, and only when each is this user's regular 0600 file with a
207
+ single link. The route file itself is created once, exclusively, mode
176
208
  0600, in a settings folder that must be a real directory owned by the user with mode
177
209
  0700 (otherwise the launch is refused), under the 0700 Switcher state folder. The token
178
210
  is accepted only by this gateway on `127.0.0.1` and reaches only that launch's
@@ -252,8 +284,9 @@ While the service runs, a client always gets an HTTP answer it can show:
252
284
  launch after a host restart.
253
285
  - A launch that ended before the service ran 0.2.19 has no record, so a session that
254
286
  still uses it gets `switcher_gateway_launch_unknown`.
255
- - Claude's picker settings (`--settings`) are written to
256
- `state/sessions/claude/<profile>/settings/claude-settings-<digest>.json`, outside the
287
+ - Claude's picker settings (`--settings`) of a launch without a durable route are written
288
+ to `state/sessions/claude/<profile>/settings/claude-picker-<digest>.json`
289
+ (`claude-settings-<digest>.json` before 0.2.23), outside the
257
290
  launch's temporary folder, because the background host replays that path when it
258
291
  restarts a session. Sessions started by 0.2.18 or older name a path in a launch folder
259
292
  that may be gone; Claude then refuses to start them ("Settings file not found") until
package/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.0.3",
3
3
  "info": {
4
4
  "title": "Switcher API",
5
- "version": "0.2.21",
5
+ "version": "0.2.23",
6
6
  "description": "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
7
7
  },
8
8
  "security": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/switcher",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "type": "module",
5
5
  "description": "Universal provider and model switcher for coding harnesses with an API, SDK and self-hosted storage",
6
6
  "license": "Apache-2.0",