feat: expose model database updates through the public Go SDK
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #256 de @ezynda3 — fusionado
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
- Lenguaje dominante
- Go
- Estrellas
- 146
- Forks
- 31
- Merge medio
- 4 h 35 min
- PR fusionados (30 d)
- 54
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de mark3labs/kit
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 24/100
mark3labs/kit#253 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de mark3labs/kit
Issues similares
-
Handler accepts zero/negative NNCP_MAX_RETRIES and NNCP backoff values, stalling policies or hot-loopingPosiblemente ocupada @NopeCharon la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nmstate/kubernetes-nmstate#1604 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
bug raised-by:desk
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
medici-finance/assay#4723 ·
Los mantenedores suelen responder en 1 día
-
[doc-healer] DDUw improvement: retry integrity-filtered issue reads with direct single-item lookupsAbiertoautomation documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
flannel-io/flannel#2608 ·
Los mantenedores suelen responder en 2 días