fix(agent-core-v2): fall back to a checked-in models.dev snapshot in source builds - #3042
fix(agent-core-v2): fall back to a checked-in models.dev snapshot in source builds#3042bj456736 wants to merge 1 commit into
Conversation
…source builds The built-in catalog fallback was injected only through the __KIMI_CODE_BUILT_IN_CATALOG__ define, which just the release workflows populate. Any build bundling agent-core-v2 from source — the desktop app bundles @moonshot-ai/* sources directly — got an undefined snapshot, so a failed models.dev fetch surfaced as catalog_unavailable instead of using the built-in directory. Check in a stripped snapshot next to builtInModelsDev.ts (?raw import, the pattern this package already uses) and prefer the define when present: releases still ship a fresh catalog, source builds get the checked-in one. Regenerate with pnpm --filter @moonshot-ai/agent-core-v2 catalog:update.
|
|
@codex review |
commit: |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Problem
The built-in models.dev catalog fallback (#2110) is injected only through the
__KIMI_CODE_BUILT_IN_CATALOG__build-time define, which just the release / pkg-pr-new / native-build workflows populate (viaKIMI_CODE_BUILT_IN_CATALOG_FILE). Any build bundling agent-core-v2 from source — notably the desktop app, which bundles@moonshot-ai/*sources directly with its own tsdown config — getsundefinedfor the snapshot. A failed models.dev fetch then surfaces ascatalog_unavailable("目录加载失败,请检查网络后重试") instead of using the built-in directory.Fix
packages/agent-core-v2/src/app/kosongConfig/builtInModelsDev.snapshot.json(generated byapps/kimi-code/scripts/update-catalog.mjs; 191 providers) and read it with a?rawimport — the pattern this package already uses — as the default when the define is absent. Release builds still inject a fresh catalog through the define, which keeps priority.pnpm --filter @moonshot-ai/agent-core-v2 catalog:updateto regenerate the checked-in snapshot.builtInCatalogoverride tosetModelsDevUpstreamForTestso the no-snapshotCATALOG_UNAVAILABLEpath stays covered.Downstream source bundlers (the desktop app) pick the fallback up automatically — no change needed there beyond bumping the submodule.
Tests
No changeset: not perceivable for CLI release users (they already ship the fresh define snapshot); the user-facing surface is the desktop app, which covers it on its side.