@hasna/switcher 0.2.11 → 0.2.13

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.11";
71
+ var version = "0.2.13";
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.11",
925
+ version: "0.2.13",
926
926
  description: "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
927
927
  },
928
928
  security: [
@@ -0,0 +1,84 @@
1
+ # Claude Desktop gateway adapter
2
+
3
+ `@hasna/switcher/claude-desktop` exposes `preflightClaudeDesktopGateway({codeConfigDir})`
4
+ and `prepareClaudeDesktopGatewayLaunch({gateway:{url,token},codeConfigDir,label})`.
5
+ The supplied gateway must be authenticated HTTP on an explicit loopback port.
6
+ The adapter does not resolve provider credentials or start a Switcher inference server.
7
+
8
+ The Node path requires Node 24.20 or newer in the Node 24 release line and
9
+ `node:sqlite`; the measured runtime is Node 24.20.0. Bun uses its own SQLite
10
+ driver with the same exclusive lease. Missing runtime support fails closed and
11
+ never installs a runtime. The subpath bundles its public implementation and
12
+ uses no private package imports.
13
+
14
+ Preflight reads only existing native state, policy, app metadata and lease state.
15
+ Preparation verifies native `GET /v1/models?limit=1000` with `anthropic-version`,
16
+ following encoded `after_id` cursors for at most three pages, then acquires
17
+ the shared Claude-3p lease, preserves and reads back incumbent selection/config
18
+ bytes, and selects an owned gateway generation. It enables native model discovery
19
+ without supplying `inferenceModels`, which would override discovery. The bearer
20
+ capability uses the gateway credential field; it is never a custom header or
21
+ returned environment field.
22
+
23
+ The prepared result has empty arguments, the native executable, and only
24
+ `CLAUDE_CONFIG_DIR` plus `CLAUDE_SECURESTORAGE_CONFIG_DIR` pointing to the supplied
25
+ canonical root. It creates no shared-state symlinks or copies. Existing native
26
+ permissions, hooks, preferences and history remain at their original scope.
27
+ Unresolved native endpoint/credential/model routing, unsafe directory redirects,
28
+ and layouts beyond bounded inspection are refused without rewriting the root.
29
+
30
+ Call `beforeLaunch()` after all other awaited admission work, immediately before
31
+ spawning a new owned app child. Keep the broker and lease alive until that child
32
+ and its owned process group settle, then call `cleanup()`. Do not reuse another
33
+ window or infer success from an early single-instance forwarding exit.
34
+ After its asynchronous layout and availability checks, `beforeLaunch()` performs
35
+ bounded synchronous reads of root identity, effective settings and the owned
36
+ selection, with no further await before returning. This closes its asynchronous
37
+ handoff gaps; it does not make the subsequent spawn atomic against unrelated
38
+ same-user processes that can still change files.
39
+
40
+ Cleanup restores exact original selection bytes and admitted file permissions
41
+ only for its matching generation. The version 4 recovery receipt binds both;
42
+ foreign permission changes are conflicts, just like foreign content changes.
43
+ Existing settings must belong to the current user and their primary group.
44
+ On macOS, settings with ACLs or file flags are refused before selection. Extended
45
+ attributes are copied exactly, checked by digest and retained in a readback-verified
46
+ original capsule until restoration succeeds. This includes ordinary macOS provenance
47
+ attributes. An
48
+ unavailable or inconclusive native metadata inspection also refuses admission.
49
+ The adapter repeats this check before replacing settings; it never strips
50
+ metadata to make a launch succeed.
51
+ Foreign edits and conflicted recovery receipts are retained and reported.
52
+ Restoration checks the receipt-bound current selection again when its writer
53
+ starts and before replacement. Read-only original modes remain supported; only
54
+ the verified private preparation copy is made writable. Legacy recovery formats
55
+ require their original owning version; they are not silently
56
+ adopted. Successful recovery removes the generated config and preparation file,
57
+ retains the readback-verified original capsule, and renames the receipt to
58
+ `.switcher-selection.json.recovered-*`; generated metadata is removed when the
59
+ original was absent. A successful replacement also retains its moved-aside
60
+ original as `_meta.json.<uuid>.previous`. A conflict preserves the foreign file
61
+ beside the original capsule and receipt. The original account and configuration
62
+ files are preserved. Live disposal remains subject to the owning preservation
63
+ and recovery rules.
64
+
65
+ The catalog must complete within the existing eight-second, one-MiB budget.
66
+ Malformed, repeating or over-three-page discovery is refused before selection.
67
+ At least one entry must be native-visible: a conservative standard Claude family
68
+ ID/alias, or a bounded gateway ID carrying a recognized `anthropic_family_tier`.
69
+ The tier is supplied by the upstream gateway, never inferred from a provider.
70
+ Exact IDs and `is_family_default` metadata stay in the broker's response; native
71
+ Desktop resolves its family aliases. No model IDs or message bodies are rewritten.
72
+ See [Claude's gateway contract](https://claude.com/docs/third-party/claude-desktop/gateway).
73
+ Request shape and tier support were checked against Claude Desktop 2.19675.0.
74
+
75
+ The broker must admit catalog reads for its existing allocation, including
76
+ encoded cursors, without inference admission, quota resets or account rotation.
77
+ Switcher cannot supply that consumer capability or attest another broker's
78
+ account authority merely by probing its catalog.
79
+
80
+ This source preparation has no native acceptance or release verdict. Actual
81
+ model/modelPicker precedence,
82
+ supported existing descendant links, and newly owned native process attribution
83
+ must be verified before release/integration claims. In particular, CLI inference
84
+ does not establish Desktop Chat or embedded Code acceptance.
@@ -4,7 +4,7 @@
4
4
  "name": "switcher",
5
5
  "class": "cli-with-store",
6
6
  "contractVersion": "v1",
7
- "kitVersion": "1.3.3",
7
+ "kitVersion": "1.3.7",
8
8
  "description": "Universal provider and model switcher with API-first local and hosted operation. CLI, MCP and SDK resolve one authenticated HTTP authority through @hasna/contracts and fail closed when hosted configuration is missing or invalid. HASNA_SWITCHER_LOCAL=1 deliberately selects an owned loopback API backed by SQLite; hosted https://api.hasna.com/switcher uses PostgreSQL and signed revocable API keys. Provider credentials remain local to the launcher and are never stored or returned by the service.",
9
9
  "bins": [
10
10
  "switcher",
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.11",
5
+ "version": "0.2.13",
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.11",
3
+ "version": "0.2.13",
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",
@@ -17,6 +17,10 @@
17
17
  "./sdk": {
18
18
  "types": "./dist/sdk.d.ts",
19
19
  "import": "./dist/sdk.js"
20
+ },
21
+ "./claude-desktop": {
22
+ "types": "./dist/claude-desktop.d.ts",
23
+ "import": "./dist/claude-desktop.js"
20
24
  }
21
25
  },
22
26
  "files": [
@@ -27,7 +31,8 @@
27
31
  "Dockerfile",
28
32
  "README.md",
29
33
  "LICENSE",
30
- "docs/MODEL-POLICY.md"
34
+ "docs/MODEL-POLICY.md",
35
+ "docs/CLAUDE-DESKTOP-GATEWAY.md"
31
36
  ],
32
37
  "publishConfig": {
33
38
  "registry": "https://registry.npmjs.org",
@@ -41,7 +46,7 @@
41
46
  "generate": "bun scripts/generate.ts",
42
47
  "check:generated": "bun scripts/generate.ts --check",
43
48
  "typecheck": "tsc --noEmit",
44
- "test": "bun test",
49
+ "test": "bun test --timeout 30000",
45
50
  "contract:check": "bun ./node_modules/@hasna/contracts/dist/cli/contracts-cli.js repo-conformance .",
46
51
  "verify": "bun run check:generated && bun run typecheck && bun run test && bun run build && bun run contract:check",
47
52
  "test:postgres": "bun scripts/pg-test-gate.mjs",
@@ -72,7 +77,7 @@
72
77
  "@types/pg": "8.23.1"
73
78
  },
74
79
  "dependencies": {
75
- "@hasna/contracts": "1.3.3",
80
+ "@hasna/contracts": "1.3.7",
76
81
  "@modelcontextprotocol/sdk": "^1.29.0",
77
82
  "jsonc-parser": "3.3.1",
78
83
  "yaml": "2.9.0",