feat: refresh models from a hosted catalog - #1928
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit aeb795a. Configure here.
|
|
||
| - name: Publish catalog to R2 | ||
| env: | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} |
There was a problem hiding this comment.
The R2 credential used here should be confirmed bucket-scoped and write-only, since a broader token would make this workflow the catalog's weakest link. Nothing in-repo can verify this — flagging for a one-time check in the Cloudflare dashboard.
[written by prime-agent, checked by snimu]
There was a problem hiding this comment.
Agreed. This cannot be verified from the repository. I am leaving this thread open and escalating a one-time Cloudflare dashboard check that the workflow credential is restricted to the intended bucket with the narrowest available object-write permission.

Part of ENG-5435. Supersedes #1633.
What changed
model-catalog.jsonto the existing Prime Agent R2 origin every day and on manual dispatch.models.jsondefinitions, model overrides, private Prime routes, and extension providers above the hosted catalog.Safety
api,baseUrl, and headers stay pinned to a matching transport bundled in the installed Prime Agent release.PI_OFFLINE=1disables network refreshes.PRIME_AGENT_MODEL_CATALOG_URLoverrides the endpoint for development.Validation
npm run checkpackages/ai/test/model-catalog-format.test.ts: 4 passedpackages/ai/test/model-compat-schema.test.ts: 2 passedpackages/coding-agent/test/remote-model-catalog.test.ts: 11 passedpackages/coding-agent/test/model-registry.test.ts: 72 passedpackages/coding-agent/test/version-check.test.ts: 6 passedpackages/coding-agent/test/package-manager.test.ts: 95 passedpackages/coding-agent/test/tools-manager.test.ts: 6 passedNote
Medium Risk
Changes which models users see and at what price, with merge rules that block remote transport redirects but still trust hosted metadata for matched transports; publication strict mode limits bad uploads, but runtime uses lenient parsing with
skipInvalidModels.Overview
Adds a hosted, versioned model catalog so public model names, capabilities, and pricing can update without a Prime Agent release.
A new GitHub Actions workflow runs daily (and on dispatch): it generates the aggregate catalog in strict mode, validates it, and uploads
model-catalog.jsonto R2.packages/aiintroducescreateModelCatalog/parseModelCatalog, shared compat schemas, avalidate-model-catalogscript, and strictergenerate-modelsbehavior whenPRIME_AGENT_MODEL_CATALOG_STRICT=1(failed or empty upstream sources abort publication).Prime Agent loads built-ins by merging the hosted list into the release-bundled catalog via
remote-model-catalog.ts: remote rows update metadata but pinapi,baseUrl, and headers to a matching bundled transport; truncated or invalid responses fall back to a 24h atomic disk cache or bundled models.ModelRegistryreads the cache at startup and refreshes asynchronously;PI_OFFLINE=1andPRIME_AGENT_MODEL_CATALOG_URLcontrol network behavior. Localmodels.jsonoverrides and extension providers still win on conflicts.Reviewed by Cursor Bugbot for commit 97d6e39. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add hosted model catalog with daily refresh and validated disk cache
createModelCatalogandparseModelCatalogin model-catalog.ts with a versioned TypeBox schema, deterministic sorting, and duplicate detectionModelRegistryin model-registry.ts now loads the cached catalog on startup, refreshes it asynchronously, and merges remote metadata before applying local overrides;PI_OFFLINEskips refreshgenerate-models.tsgains a strict mode (PRIME_AGENT_MODEL_CATALOG_STRICT) that fails fast on missing/empty provider catalogs and can emit a catalog toPRIME_AGENT_MODEL_CATALOG_OUTPUT; it now setsprocess.exitCode = 1on fatal errors instead of silent loggingChanges since #1928 opened
readCachedRemoteModelCatalogfrom throwing on malformed caches [95dfe25]refreshRemoteModelCatalogin thecoding-agentpackage requiring the providednowtimestamp to be greater than or equal tofetchedAtbefore treating cached model catalog data as fresh, and added test coverage verifying that a fetch is triggered whennowis earlier than the cachedfetchedAttimestamp [97d6e39]Macroscope summarized a1abe48.