@hasna/switcher 0.2.11 → 0.2.12
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/dist/claude-desktop-gateway.d.ts +30 -0
- package/dist/claude-desktop-launch.d.ts +2 -3
- package/dist/claude-desktop-models.d.ts +2 -0
- package/dist/claude-desktop.d.ts +6 -0
- package/dist/claude-desktop.js +5007 -0
- package/dist/cli/index.js +367 -155
- package/dist/desktop-apps.d.ts +3 -0
- package/dist/desktop-selection.d.ts +20 -0
- package/dist/desktop-state.d.ts +11 -1
- package/dist/index.js +5362 -86
- package/dist/mcp/index.js +6315 -368
- package/dist/native-state.d.ts +2 -0
- package/dist/private-directory.d.ts +2 -0
- package/dist/runtime.d.ts +1 -1
- package/dist/sdk.js +5362 -86
- package/dist/serve/index.js +2 -2
- package/docs/CLAUDE-DESKTOP-GATEWAY.md +69 -0
- package/hasna.contract.json +1 -1
- package/openapi.json +1 -1
- package/package.json +8 -3
package/dist/serve/index.js
CHANGED
|
@@ -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.
|
|
71
|
+
var version = "0.2.12";
|
|
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.
|
|
925
|
+
version: "0.2.12",
|
|
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,69 @@
|
|
|
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 3 recovery receipt binds both;
|
|
42
|
+
foreign permission changes are conflicts, just like foreign content changes.
|
|
43
|
+
Foreign edits and conflicted recovery receipts are retained and reported. Legacy
|
|
44
|
+
recovery formats require their original owning version; they are not silently
|
|
45
|
+
adopted. Successful cleanup removes only the generated config, receipt and a
|
|
46
|
+
generated metadata file when the original was absent; the original account and
|
|
47
|
+
configuration files are preserved. Live disposal remains subject to the owning
|
|
48
|
+
preservation and recovery rules.
|
|
49
|
+
|
|
50
|
+
The catalog must complete within the existing eight-second, one-MiB budget.
|
|
51
|
+
Malformed, repeating or over-three-page discovery is refused before selection.
|
|
52
|
+
At least one entry must be native-visible: a conservative standard Claude family
|
|
53
|
+
ID/alias, or a bounded gateway ID carrying a recognized `anthropic_family_tier`.
|
|
54
|
+
The tier is supplied by the upstream gateway, never inferred from a provider.
|
|
55
|
+
Exact IDs and `is_family_default` metadata stay in the broker's response; native
|
|
56
|
+
Desktop resolves its family aliases. No model IDs or message bodies are rewritten.
|
|
57
|
+
See [Claude's gateway contract](https://claude.com/docs/third-party/claude-desktop/gateway).
|
|
58
|
+
Request shape and tier support were checked against Claude Desktop 2.19675.0.
|
|
59
|
+
|
|
60
|
+
The broker must admit catalog reads for its existing allocation, including
|
|
61
|
+
encoded cursors, without inference admission, quota resets or account rotation.
|
|
62
|
+
Switcher cannot supply that consumer capability or attest another broker's
|
|
63
|
+
account authority merely by probing its catalog.
|
|
64
|
+
|
|
65
|
+
This source preparation has no native acceptance or release verdict. Actual
|
|
66
|
+
model/modelPicker precedence,
|
|
67
|
+
supported existing descendant links, and newly owned native process attribution
|
|
68
|
+
must be verified before release/integration claims. In particular, CLI inference
|
|
69
|
+
does not establish Desktop Chat or embedded Code acceptance.
|
package/hasna.contract.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "switcher",
|
|
5
5
|
"class": "cli-with-store",
|
|
6
6
|
"contractVersion": "v1",
|
|
7
|
-
"kitVersion": "1.3.
|
|
7
|
+
"kitVersion": "1.3.5",
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/switcher",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
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",
|
|
@@ -72,7 +77,7 @@
|
|
|
72
77
|
"@types/pg": "8.23.1"
|
|
73
78
|
},
|
|
74
79
|
"dependencies": {
|
|
75
|
-
"@hasna/contracts": "1.3.
|
|
80
|
+
"@hasna/contracts": "1.3.5",
|
|
76
81
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
77
82
|
"jsonc-parser": "3.3.1",
|
|
78
83
|
"yaml": "2.9.0",
|