feat: expose model database updates through the public Go SDK
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #256 来自 @ezynda3 —— 已合并
评估
调研方向
Start by reading pkg/kit/models.go, cmd/update_models.go, and internal/models/cache.go at the pinned commit to understand current update logic. Extract the operation into reusable Kit code and expose it via pkg/kit as UpdateModels. Add hermetic tests with temp dirs and local HTTP servers; done means public SDK updates models atomically with CLI behavior unchanged.
由索引模型根据 Issue 内容生成。
描述
Feature Description
Expose the kit update-models operation through github.com/mark3labs/kit/pkg/kit. Embedders should be able to update the shared model database without installing or executing the Kit CLI.
The SDK should support the existing source choices: default models.dev URL (including all model types), KIT_MODELS_URL, an explicit HTTP(S) URL, a local JSON file, and reset to the embedded database. Keep cache paths, schema versions, catalog decoding, and conditional HTTP requests inside Kit.
Motivation / Use Case
BONNIE wants bonnie update models and ./my-agent update models in compiled agent binaries: https://github.com/mark3labs/bonnie/issues/59.
BONNIE imports only Kit's public SDK. At its pinned Kit v0.136.0 (c50c75cbdd467614092116b049d5fcf43d6dc6b5):
pkg/kit/models.go:5-41exposes registry queries, but no update operation.cmd/update_models.go:50-168owns source selection, download, local-file import, and reset. It writes directly to stderr and starts its timeout fromcontext.Background().internal/models/cache.go:34-73owns schema version 3 and the sharedproviders.jsondata path. The write and remove functions are also internal (lines 111-148).
These internal functions cannot be imported by an external Go module. Writing the cache independently would couple BONNIE to Kit's private schema. This is a request for a supported public operation, not for public access to the private cache structs.
Proposed Implementation
Extract the operation into reusable Kit code and make both the Kit CLI and a public SDK wrapper use it. Exact API names are open; an illustrative shape is:
func UpdateModels(ctx context.Context, opts UpdateModelsOptions) (UpdateModelsResult, error)
Requested contract:
- Accept caller cancellation and use a bounded network timeout (the CLI currently uses 30 seconds).
- Return structured results for updated, not-modified, and reset states, with provider/model counts where applicable. Do not print, parse CLI arguments, start a model, or require provider credentials.
- Preserve Kit's shared cache location and schema handling; support ETag/304 behavior without allowing a validator from one source to mask data from another source.
- Validate input before replacing the cache. A failed download or invalid input must not destroy the previous usable cache; use atomic replacement so readers do not see a partial file.
- Document whether an already loaded registry sees updates. Restart/next-process visibility is sufficient for BONNIE; live registry reload is not required.
- Add hermetic tests with temporary data directories and local HTTP servers for source selection, 200/304 responses, malformed/empty data, cancellation, failed writes, and embedded reset. Keep CLI behavior compatible.
Alternatives Considered
- I've considered workarounds or alternative approaches
Installing/executing Kit separately defeats the standalone-binary use case. Importing kit/internal/models is not allowed by Go. Copying Kit's updater or independently maintaining its cache schema would create a second implementation that can drift.
Checklist
- I've searched existing issues and this hasn't been requested yet
Searched open and closed issues for model update API, update-models, and model database. No matching public-updater request was found. This request follows the existing public-SDK pattern used for provider OAuth login (#180).
- 主要语言
- Go
- 星标
- 146
- 派生
- 31
- 平均合并
- 4 小时 33 分钟
- 30 天内合并 PR
- 55
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 78/100
slavakurilyak/awesome-ai-agents#880 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
apache/openserverless#282 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
agent-butler-finding bug
难度 2/5 1-3 小时 新手友好度 78/100
jordansmall/spindrift#6161 ·
维护者通常 1 天内回复