@cherrystudio/provider-registry 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +166 -2
- package/data/models.json +22694 -0
- package/data/provider-models.json +41090 -0
- package/data/providers.json +2716 -0
- package/dist/bundled-catalog.cjs +12 -0
- package/dist/bundled-catalog.d.cts +5 -0
- package/dist/bundled-catalog.d.mts +5 -0
- package/dist/bundled-catalog.mjs +11 -0
- package/dist/bundled-models--P3b6A6o.mjs +25220 -0
- package/dist/bundled-models-uS9C7ldF.cjs +25224 -0
- package/dist/bundled-models.cjs +3 -0
- package/dist/bundled-models.d.cts +5 -0
- package/dist/bundled-models.d.mts +5 -0
- package/dist/bundled-models.mjs +2 -0
- package/dist/bundled-provider-models-CT2Ha5w2.cjs +37586 -0
- package/dist/bundled-provider-models-y-RYjBUH.mjs +37582 -0
- package/dist/bundled-provider-models.cjs +3 -0
- package/dist/bundled-provider-models.d.cts +5 -0
- package/dist/bundled-provider-models.d.mts +5 -0
- package/dist/bundled-provider-models.mjs +2 -0
- package/dist/bundled-providers-BZisTfNC.cjs +2174 -0
- package/dist/bundled-providers-BiPpU5W4.mjs +2170 -0
- package/dist/bundled-providers.cjs +3 -0
- package/dist/bundled-providers.d.cts +5 -0
- package/dist/bundled-providers.d.mts +5 -0
- package/dist/bundled-providers.mjs +2 -0
- package/dist/catalog-DElG_l-8.mjs +369 -0
- package/dist/catalog-DurdOhD0.cjs +442 -0
- package/dist/catalog-XJyrtwI9.d.cts +53 -0
- package/dist/catalog-XJyrtwI9.d.mts +53 -0
- package/dist/index.cjs +2620 -0
- package/dist/index.d.cts +3932 -0
- package/dist/index.d.mts +3932 -0
- package/dist/index.mjs +2549 -0
- package/dist/model-NFEbqWMs.mjs +665 -0
- package/dist/model-kwW2vWDI.cjs +855 -0
- package/dist/provider-D14qMZsE.mjs +431 -0
- package/dist/provider-DkSIaann.cjs +527 -0
- package/dist/provider-models-BjKC53mr.cjs +85 -0
- package/dist/provider-models-BkxD9T17.mjs +67 -0
- package/dist/provider-models-DuZBXGmP.d.cts +28692 -0
- package/dist/provider-models-DuZBXGmP.d.mts +28692 -0
- package/dist/registry-BjETdicx.d.mts +35 -0
- package/dist/registry-Di5ULW6Z.d.cts +35 -0
- package/dist/registry-loader.cjs +170 -0
- package/dist/registry-loader.d.cts +64 -0
- package/dist/registry-loader.d.mts +64 -0
- package/dist/registry-loader.mjs +156 -0
- package/package.json +146 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Cherry Studio contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,167 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cherrystudio/provider-registry
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Cross-platform AI provider and model catalogs, Zod schemas, and lookup utilities.
|
|
4
|
+
The core works without filesystem access, networking, timers, or application services.
|
|
5
|
+
Node file loading is available separately through `/node`.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @cherrystudio/provider-registry zod@^4.4.3
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The first release is versioned as `0.1.0` through Changesets and uses the `latest` tag.
|
|
14
|
+
Zod is a peer dependency so applications can
|
|
15
|
+
compose the exported schemas with the same Zod installation.
|
|
16
|
+
|
|
17
|
+
## Bundled catalog
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { createRegistry } from '@cherrystudio/provider-registry'
|
|
21
|
+
import { bundledCatalog } from '@cherrystudio/provider-registry/data'
|
|
22
|
+
|
|
23
|
+
const registry = createRegistry(bundledCatalog)
|
|
24
|
+
const provider = registry.findProvider('openai')
|
|
25
|
+
const model = registry.findModel('gpt-6.1-sol')
|
|
26
|
+
const override = registry.findOverride('cherryin', 'qwen/qwen3.5-9b')
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The bundle contains all three validated catalogs and is usable offline, including
|
|
30
|
+
on first launch. Importing the core alone does not load any catalog JSON.
|
|
31
|
+
|
|
32
|
+
| Entry | Exports |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `@cherrystudio/provider-registry` | `createRegistry`, `parseModelSnapshot`, schemas, types, enums, manifest contract and pure utilities |
|
|
35
|
+
| `@cherrystudio/provider-registry/data` | `bundledCatalog` |
|
|
36
|
+
| `@cherrystudio/provider-registry/data/providers` | `bundledProviders` |
|
|
37
|
+
| `@cherrystudio/provider-registry/data/models` | `bundledModels` |
|
|
38
|
+
| `@cherrystudio/provider-registry/data/provider-models` | `bundledProviderModels` |
|
|
39
|
+
| `@cherrystudio/provider-registry/node` | File readers, `RegistryLoader` and Desktop manifest compatibility policy |
|
|
40
|
+
|
|
41
|
+
Raw JSON is also exported as `/data/providers.json`, `/data/models.json`, and
|
|
42
|
+
`/data/provider-models.json`. Each file retains its content-hash `version`.
|
|
43
|
+
The JavaScript data entries avoid platform-specific JSON import syntax.
|
|
44
|
+
|
|
45
|
+
## Query contract
|
|
46
|
+
|
|
47
|
+
`createRegistry(catalog)` accepts a validated `RegistryCatalog`. Treat its input
|
|
48
|
+
records and returned records as read-only; the core does not deep-clone or freeze them.
|
|
49
|
+
Query lists are typed as read-only arrays.
|
|
50
|
+
|
|
51
|
+
| Method | Result |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| `listProviders()` | Trusted provider definitions |
|
|
54
|
+
| `listModels()` | Base models in this snapshot |
|
|
55
|
+
| `getOverridesForProvider(providerId)` | Provider-specific overrides, not a complete list of served models |
|
|
56
|
+
| `findProvider(providerId)` | Exact provider match, or `null` |
|
|
57
|
+
| `findModel(modelId)` | Exact model match, then size-preserving normalized fallback, or `null` |
|
|
58
|
+
| `findOverride(providerId, modelId)` | Exact canonical/API ID match before normalized fallback, or `null` |
|
|
59
|
+
|
|
60
|
+
A missing model size never falls back to another size. Canonical provider lookups
|
|
61
|
+
prefer the self variant when dated API variants coexist; each dated variant remains
|
|
62
|
+
addressable by its own API ID. Normalization only locates metadata: retain the API ID
|
|
63
|
+
returned by model discovery or explicitly supplied by the user when making requests.
|
|
64
|
+
A normalized catalog key is not a replacement request ID.
|
|
65
|
+
|
|
66
|
+
The existing `lookupRegistryModel()` convenience function uses the same matching
|
|
67
|
+
rules and resolves an API alias through its override's canonical model ID.
|
|
68
|
+
|
|
69
|
+
## Downloaded snapshots
|
|
70
|
+
|
|
71
|
+
Applications own download, validation against the manifest, persistence and activation.
|
|
72
|
+
Parse both model files before creating a replacement registry:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { createRegistry, parseModelSnapshot } from '@cherrystudio/provider-registry'
|
|
76
|
+
import { bundledProviders } from '@cherrystudio/provider-registry/data/providers'
|
|
77
|
+
|
|
78
|
+
const snapshot = parseModelSnapshot({
|
|
79
|
+
models: JSON.parse(modelsText),
|
|
80
|
+
providerModels: JSON.parse(providerModelsText)
|
|
81
|
+
})
|
|
82
|
+
const replacement = createRegistry({ ...snapshot, providers: bundledProviders })
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`modelsText` and `providerModelsText` above are application-provided strings.
|
|
86
|
+
`parseModelSnapshot` validates their structure and applies the schemas' per-entry
|
|
87
|
+
forward compatibility. It does not check manifest hashes, runtime support, or freshness.
|
|
88
|
+
Invalid envelopes throw; incompatible entries and unknown list vocabulary are omitted
|
|
89
|
+
according to the shared schemas. Provider routing is not part of this input.
|
|
90
|
+
|
|
91
|
+
Before activation, the application must validate the manifest, both file versions,
|
|
92
|
+
and its runtime's supported semantics. Switch the complete snapshot together. An
|
|
93
|
+
application can start from bundled data, restore a compatible newer saved snapshot,
|
|
94
|
+
and check remote updates in the background. A failed update leaves the current view
|
|
95
|
+
usable. Creating a replacement registry does not mutate an existing registry.
|
|
96
|
+
|
|
97
|
+
Content hashes prove identity, not chronological order. Workflow revisions are only
|
|
98
|
+
comparable within their publication stream. Applications must retain source/schema
|
|
99
|
+
provenance when deciding whether saved or remote data supersedes a bundled snapshot;
|
|
100
|
+
this package does not invent an ordering from hashes or npm versions.
|
|
101
|
+
|
|
102
|
+
Unsigned remote data may update models and provider-model overrides, but must not
|
|
103
|
+
replace trusted provider connections, destinations, or credentials. Applications
|
|
104
|
+
continue to own custom providers, user overrides, product exclusions, and runtime
|
|
105
|
+
capability projection. Recognizing a reasoning dialect in the schema does not mean
|
|
106
|
+
that an application's Pi or AI SDK adapter can execute it.
|
|
107
|
+
|
|
108
|
+
## Node file loading
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { createRequire } from 'node:module'
|
|
112
|
+
import { RegistryLoader } from '@cherrystudio/provider-registry/node'
|
|
113
|
+
|
|
114
|
+
const require = createRequire(import.meta.url)
|
|
115
|
+
const loader = new RegistryLoader({
|
|
116
|
+
models: require.resolve('@cherrystudio/provider-registry/data/models.json'),
|
|
117
|
+
providers: require.resolve('@cherrystudio/provider-registry/data/providers.json'),
|
|
118
|
+
providerModels: require.resolve('@cherrystudio/provider-registry/data/provider-models.json')
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
const model = loader.findModel('gpt-4o')
|
|
122
|
+
loader.invalidate()
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The Node loader reads lazily, shares the portable lookup indexes, and releases cached
|
|
126
|
+
data after its idle timeout. `readModelRegistry`, `readProviderRegistry`, and
|
|
127
|
+
`readProviderModelRegistry` remain available for one-shot reads.
|
|
128
|
+
|
|
129
|
+
## Compatibility and platform boundaries
|
|
130
|
+
|
|
131
|
+
- Package versions describe the public JavaScript/TypeScript API.
|
|
132
|
+
- `REGISTRY_SCHEMA_VERSION` describes the remote JSON publication lane.
|
|
133
|
+
- `REGISTRY_MIN_APP_VERSION` is the Desktop semantic floor for that lane, not a
|
|
134
|
+
Mobile application version or proof that another runtime supports every field.
|
|
135
|
+
- `CatalogManifestSchema` and file/schema constants are available from the core.
|
|
136
|
+
The existing Desktop `isCatalogManifestCompatible(manifest, appVersion)` policy
|
|
137
|
+
remains in `/node`; Mobile owns download admission and old-cache restoration.
|
|
138
|
+
- The root and data entries support ESM, CommonJS and React Native export conditions.
|
|
139
|
+
They contain no Node filesystem or Electron imports. Actual Expo/device acceptance
|
|
140
|
+
remains part of a consuming application's integration checks.
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
The three `data/*.json` files are generated. Edit `src/creators/` or `src/providers/`
|
|
145
|
+
and run the generator; never hand-edit catalog data. Contributor instructions and
|
|
146
|
+
architecture documentation live in this package's source repository.
|
|
147
|
+
|
|
148
|
+
From the monorepo root:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pnpm --filter @cherrystudio/provider-registry build
|
|
152
|
+
pnpm --filter @cherrystudio/provider-registry test:package
|
|
153
|
+
pnpm --filter @cherrystudio/provider-registry compat:check
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
`test:package` builds and installs a tarball outside the workspace, checks both module
|
|
157
|
+
formats and declarations, builds the portable surface for browsers, and exercises
|
|
158
|
+
React Native export resolution. It requires access to the npm registry.
|
|
159
|
+
|
|
160
|
+
Before publishing a new incompatible remote schema, increment `REGISTRY_SCHEMA_VERSION`
|
|
161
|
+
in `src/catalog.ts` by one and run `pnpm --filter @cherrystudio/provider-registry compat:baseline`.
|
|
162
|
+
Frozen baselines in `compat/` must not be rewritten. Runtime-semantic additions that
|
|
163
|
+
raise the Desktop version floor require a new stream; existing streams retain theirs.
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
MIT. See [LICENSE](./LICENSE).
|