Skip to content

feat(data): migrate provider/model data and finalize provider APIs#14034

Closed
jidan745le wants to merge 34 commits intoCherryHQ:v2from
jidan745le:feat/v2/provider-catalog-runtime-minimal
Closed

feat(data): migrate provider/model data and finalize provider APIs#14034
jidan745le wants to merge 34 commits intoCherryHQ:v2from
jidan745le:feat/v2/provider-catalog-runtime-minimal

Conversation

@jidan745le
Copy link
Copy Markdown
Collaborator

What this PR does

Before this PR:

  • v2 migration did not include provider/model data migration from legacy llm state.
  • Provider/model data APIs and handlers were incomplete in the current branch snapshot.
  • @cherrystudio/provider-catalog runtime integration and related data-layer files were not fully wired for this branch.

After this PR:

  • Add provider/model migration path (ProviderModelMigrator + mappings) and register it in v2 migrator flow.
  • Add provider/model schemas, services, handlers, shared API schemas/types, and catalog reader package integration.
  • Complete provider API endpoints (catalog-models, auth-config, api-keys) and align services with lifecycle DI patterns.

Fixes #

None

Why we need it and why it was done in this way

The following tradeoffs were made:

  • Kept migration and data API implementation within current v2 architecture (handler -> service -> db schema) instead of adding temporary compatibility layers.
  • Resolved rebase conflicts by preserving upstream migration meta lineage and keeping this branch’s provider/model feature changes on top.

The following alternatives were considered:

  • Keep temporary relative imports and partial service wiring; rejected because it leaves unstable runtime/module resolution and incomplete API contracts.
  • Split into multiple PRs; deferred to keep this migration + provider data API integration reviewable as one feature unit.

Links to places where the discussion took place:

  • N/A

Breaking changes

None.

Special notes for your reviewer

  • This branch was rebased onto latest upstream/v2 and conflict-resolved.
  • Please focus review on migration flow (ProviderModelMigrator) and provider/model service contracts.

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

Release note

Migrate legacy provider/model configuration into v2 data tables and complete provider/model data APIs for v2 runtime.

Signed-off-by: jidan745le <420511176@qq.com>
Add v2 provider-model migration mappings and registration, then align provider handlers/services with lifecycle DI and API contracts so migration generation and node typecheck both pass.

Signed-off-by: jidan745le <420511176@qq.com>
Made-with: Cursor
@jidan745le jidan745le marked this pull request as ready for review April 4, 2026 10:30
@jidan745le jidan745le requested a review from a team April 4, 2026 10:30
@jidan745le jidan745le requested a review from 0xfullex as a code owner April 4, 2026 10:30
jidan745le and others added 6 commits April 4, 2026 18:39
Add an empty changeset file so CI changeset-check passes for this non-release provider/model runtime integration work.

Signed-off-by: jidan745le <420511176@qq.com>
Made-with: Cursor
…path

Drop redundant assertions flagged by oxlint and keep only required runtime-shape casts so CI test:lint passes.

Signed-off-by: jidan745le <420511176@qq.com>
Made-with: Cursor
Remove duplicate 0007 migration and regenerate migration artifacts as 0009 to keep drizzle journal order consistent with existing 0007/0008 chain.

Signed-off-by: jidan745le <420511176@qq.com>
Made-with: Cursor
The catalog service initialization was missing from the startup
sequence, causing preset provider/model data (capabilities,
context windows, pricing, baseUrls) to never sync from protobuf
catalog files into SQLite on each launch.

Signed-off-by: jidan745le <420511176@qq.com>
@DeJeune
Copy link
Copy Markdown
Collaborator

DeJeune commented Apr 5, 2026

Note

This issue/comment/review was translated by Claude.

No renaming.


Original Content

没有重命名

@DeJeune DeJeune added the v2 label Apr 5, 2026
@jidan745le
Copy link
Copy Markdown
Collaborator Author

jidan745le commented Apr 5, 2026

Note

This issue/comment/review was translated by Claude.

No renaming.
Let me confirm, is this saying the folder name provider-catalog should be changed to catalog-registry?


Original Content

我确认下 这个是不是说文件夹名 provider-catalog 改成 catalog-registry

@DeJeune
Copy link
Copy Markdown
Collaborator

DeJeune commented Apr 5, 2026

No renaming.
Let me confirm, is this saying the folder name provider-catalog should be changed to catalog-registry?

provider-registry

0xfullex and others added 11 commits April 5, 2026 23:21
Signed-off-by: jidan745le <420511176@qq.com>
Signed-off-by: jidan745le <420511176@qq.com>
… DataApi

Signed-off-by: jidan745le <420511176@qq.com>
Signed-off-by: jidan745le <420511176@qq.com>
Signed-off-by: jidan745le <420511176@qq.com>
Signed-off-by: jidan745le <420511176@qq.com>
Signed-off-by: jidan745le <420511176@qq.com>
…dpointConfigs

Merge three separate provider endpoint fields into a single
`endpointConfigs` map keyed by EndpointType. Each entry holds
baseUrl, modelsApiUrls, and reasoningFormatType in one place.
Also removes unused `createdAt` from ApiKeyEntry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
Rename the entire provider-catalog package, service, and all related
references to provider-registry for clearer naming semantics.

- Package: @cherrystudio/provider-catalog → @cherrystudio/provider-registry
- Directory: packages/provider-catalog → packages/provider-registry
- Proto namespace: catalog.v1 → registry.v1
- Service: ProviderCatalogService → ProviderRegistryService
- All type/function/variable names updated accordingly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
DeJeune and others added 4 commits April 6, 2026 23:09
rateLimit depends on the user's API plan, not the model itself —
not appropriate for preset registry data. Also remove inherited
reserved fields since registry.v1 has no legacy data to maintain
compatibility with.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
…I design

- Convert RegistryService to lifecycle-managed ProviderRegistryService
  (@Injectable, @ServicePhase, @dependsOn, BaseService)
- Register in serviceRegistry.ts; remove manual init from index.ts
- Replace singleton imports with application.get('ProviderRegistryService')
- Move /models/resolve to POST /providers/:providerId/registry-models
  (RESTful: same resource path, different HTTP methods)
- Rename ResolveModelsDto to EnrichModelsDto (providerId from URL params)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
…-minimal' into feat/v2/provider-renderer-on-minimal
…odel

Migrate renderer consumer code to match the new consolidated
endpointConfigs schema (replaces separate baseUrls, modelsApiUrls,
reasoningFormatTypes fields) and catalog→registry rename.

- Replace provider.baseUrls?.[ep] with endpointConfigs?.[ep]?.baseUrl
  in ProviderSetting, CherryINSettings, DMXAPISettings, ManageModelsPopup
- Rename replaceBaseUrlDomain → replaceEndpointConfigDomain (preserves
  other EndpointConfig fields like reasoningFormatType)
- Update v1ProviderShim to read baseUrl from endpointConfigs
- Rename useProviderCatalogModels → useProviderRegistryModels, update
  endpoint from catalog-models to registry-models
- Replace removed /models/resolve with /providers/:id/registry-models POST
- Update tests to reflect all of the above

Signed-off-by: jidan745le <420511176@qq.com>
@kangfenmao

This comment was marked as resolved.

@kangfenmao

This comment was marked as outdated.

@DeJeune

This comment was marked as outdated.

@0xfullex

This comment was marked as resolved.

DeJeune and others added 3 commits April 7, 2026 15:30
…ings

- Remove protobuf toolchain (proto files, buf config, generated code,
  @bufbuild/* dependencies)
- Convert registry data from .pb binary to .json files
- Replace proto-generated types with Zod-inferred types
- Rewrite registry-reader to use JSON.parse + Zod validation
- Simplify ProviderRegistryService and modelMerger by removing
  proto conversion layers (buildEndpointConfigsFromProto, CASE_TO_TYPE,
  extractReasoningFormatType)
- Convert all enums from numeric TypeScript enum to string-valued
  as-const objects (EndpointType, ModelCapability, Modality, Currency,
  ReasoningEffort) for debuggability
- Regenerate Drizzle migration to match current schema

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
The registry data uses "2026.03.09" format (from proto), but the
VersionSchema regex only allowed "YYYY-MM-DD". This caused Zod
validation to fail silently when loading registry JSON, resulting
in empty model data and no enrichment of capabilities/modalities.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
registry-reader.ts uses node:fs which crashes in renderer. Split into
a separate @cherrystudio/provider-registry/node sub-path export so
the main entry stays browser-compatible.

Also fix endpointType casts from number to string in renderer popups.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
@DeJeune

This comment was marked as outdated.

DeJeune and others added 3 commits April 7, 2026 15:53
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
- Add void to all floating promises in ProviderSettings components
- Remove closeDelay prop (not in TooltipProps)
- Fix unused destructured variable with delete pattern

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
@kangfenmao
Copy link
Copy Markdown
Collaborator

kangfenmao commented Apr 7, 2026

Note

This comment was translated by Claude.

Unstable reference causing infinite loop. Fixed.

image
  1. The content area on the right side of the provider cannot be displayed properly
  2. Switching providers causes crashes

It is recommended to delete the cherrystudo.sqlite file and restart for testing.


Original Content

引用不稳定导致死循环 已修复

image
  1. 服务商右侧内容区域无法正常显示
  2. 切换服务商会导致崩溃

建议删除 cherrystudo.sqlite 文件之后重新启动进行测试

DeJeune and others added 3 commits April 7, 2026 20:13
- ManageModelsPopup: replace Math.floor(Number(defaultChatEndpoint))
  with direct string enum access (was producing NaN after string enum
  migration, causing model list to fail loading)
- provider.v2.ts: fix replaceEndpointConfigDomain type signature from
  Record<number, ...> to Record<EndpointType, ...>, remove Number(key)
  conversions
- Update test file to use string EndpointType keys

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: suyao <sy20010504@gmail.com>
…-render loop

When data is undefined (loading), `data ?? []` created a new array reference on every render, causing ModelList's useEffect to loop indefinitely via setDisplayedModelGroups with a new object each cycle.

Use a module-level EMPTY_MODELS constant with useMemo, matching the pattern already used by useProviders.

Signed-off-by: jidan745le <420511176@qq.com>
Made-with: Cursor
Signed-off-by: jidan745le <420511176@qq.com>
Made-with: Cursor
DeJeune added a commit that referenced this pull request Apr 10, 2026
…nd only) (#14115)

### What this PR does

Before this PR:
- v2 migration did not include provider/model data migration from legacy
`llm` state.
- Provider/model data APIs and handlers were incomplete.
- `@cherrystudio/provider-registry` (formerly provider-catalog) package
was not integrated into the data layer.

After this PR:
- Add provider/model migration path (`ProviderModelMigrator` + mappings)
and register it in v2 migrator flow.
- Add `@cherrystudio/provider-registry` package with JSON-based registry
data, Zod-validated schemas, and lifecycle-managed
`ProviderRegistryService`.
- Complete provider/model schemas, services, handlers, shared API
schemas/types, and model merger utility.
- Complete provider API endpoints (`registry-models`, `auth-config`,
`api-keys`) aligned with lifecycle DI patterns.

**Note:** This PR is intentionally scoped to backend/data-layer only.
Renderer consumer migration will be submitted in a separate PR to
maintain domain separation.

Fixes #

N/A

### Why we need it and why it was done in this way

The following tradeoffs were made:
- Kept migration and data API implementation within current v2
architecture (handler -> service -> db schema) instead of adding
temporary compatibility layers.
- Replaced protobuf toolchain with JSON + Zod validation for simpler
data pipeline and better debuggability.
- Converted all numeric enums to string-valued `as-const` objects
(EndpointType, ModelCapability, Modality, etc.) for runtime
debuggability.
- Unified separate `baseUrls`, `modelsApiUrls`, `reasoningFormatTypes`
fields into a single `endpointConfigs` map keyed by EndpointType.

The following alternatives were considered:
- Keep protobuf-based registry data; rejected due to complexity of proto
toolchain and poor debuggability of binary data.
- Include renderer consumer migration in same PR; deferred to separate
PR for cleaner domain boundaries.

Links to places where the discussion took place:
- Original combined PR: #14034

### Breaking changes

None.

### Special notes for your reviewer

- This is a backend-only extraction from #14034, which contained both
backend and renderer consumer code. The renderer migration will follow
in a separate PR.
- Please focus review on migration flow (`ProviderModelMigrator`),
provider/model service contracts, and the registry package design.
- The `@cherrystudio/provider-registry` package was renamed from
`provider-catalog` and uses JSON data files instead of protobuf.

### Checklist

- [x] PR: The PR description is expressive enough and will help future
contributors
- [x] Code: Write code that humans can understand and Keep it simple
- [x] Refactor: You have left the code cleaner than you found it (Boy
Scout Rule)
- [ ] Upgrade: Impact of this change on upgrade flows was considered and
addressed if required
- [ ] Documentation: Not required (internal data layer, no user-facing
changes)
- [x] Self-review: I have reviewed my own code

### Release note

```release-note
NONE
```

---------

Signed-off-by: jidan745le <420511176@qq.com>
Signed-off-by: suyao <sy20010504@gmail.com>
Co-authored-by: suyao <sy20010504@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: fullex <106392080+0xfullex@users.noreply.github.com>
@jidan745le jidan745le closed this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants