API for agents: tokens, /api/v1 for downloads, verify, repair, tags
Brings back the token API that 0.15 removed with deployments, for models only, ported onto the current code (local models, lean client bundles, MiB-rounded disk space): - Scoped bearer tokens (models:read, downloads:create, models:verify, tags:write), stored as SHA-256, managed in Settings -> API tokens. Only /api/v1 accepts them; the rest stays OIDC-only. - /api/v1: Hub lookup, library with the search filters, download requests through the add-model/queue path (idempotent), repair of missing or broken files, verify / deep verify, tags, job status with ?wait=, cancelling or withdrawing the token's own jobs, disk space. - Guardrails for downloads and repairs: approval (default ask), max size per request, minimum free space incl. reserved bytes, agent jobs at once, author allowlist (new downloads only). Approve/reject in the UI, "requested by" badges and filter, activity log per token. - Migration 0027 adds api_tokens, agent_activity and requested_by columns on models and jobs; job state pending_approval. - docs/api.md, docs/agent/SKILL.md and the kaname curl helper; DB-backed API tests. The login gate test now expects /api/v1 to be left to token auth. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7d1a8fb85a
commit
0e0445a418
63 files changed
+5448
-42
No files matched your search
@@ -6,6 +6,43 @@ step 1 (Hugging Face downloader) is released as a minor version.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
The API for AI agents is back, for models: a token-authenticated `/api/v1` lets an agent look up
|
||||
models, download, verify, repair and tag them, within guardrails you set and, by default, only
|
||||
after you approve each download or repair.
|
||||
|
||||
No changes to `compose.yaml` or `.env`. If Kaname is behind a forward-auth proxy, let `/api/v1/`
|
||||
through without forward auth (example in [docs/api.md](docs/api.md)). The new tables and columns are
|
||||
added on start.
|
||||
|
||||
### Added
|
||||
|
||||
- **API tokens** (Settings → API tokens): create (shown once; only a SHA-256 hash is stored), last
|
||||
used, change scopes, revoke, delete. Scopes: `models:read`, `downloads:create`, `models:verify`,
|
||||
`tags:write`. Sent as `Authorization: Bearer kn_…`; only `/api/v1` accepts them, and it accepts
|
||||
nothing else (the rest of Kaname stays OIDC-only). No token can delete models or files, update a
|
||||
model, change settings or manage tokens.
|
||||
- **`/api/v1`** ([docs/api.md](docs/api.md)), compact JSON with error messages that say what to do:
|
||||
- `GET /api/v1/hub/lookup`, `GET /api/v1/models` (the library's search and filters, including
|
||||
"requested by"), `GET /api/v1/models/{id}`, `GET /api/v1/tags`, `GET /api/v1/disk`.
|
||||
- `POST /api/v1/downloads`: repo + pinned commit + a quant (with the recommended companion files,
|
||||
as in Add model) or include globs, optional tags. Repeating a request returns the existing job.
|
||||
- `POST /api/v1/models/{id}/repair`: downloads only the missing or broken files.
|
||||
- `POST /api/v1/models/{id}/verify` (`{"deep": true}` hashes): never needs approval; the finished
|
||||
job lists what's broken.
|
||||
- `POST /api/v1/models/{id}/tags`, `DELETE /api/v1/models/{id}/tags/{name}`.
|
||||
- `GET /api/v1/jobs/{id}?wait=900` holds the request until the job is done instead of polling;
|
||||
`POST /api/v1/jobs/{id}/cancel` cancels or withdraws a job the token requested.
|
||||
- **Guardrails for API downloads and repairs**: approval (default: ask me), max size per request
|
||||
(60 GB), free space to keep, counting what open downloads still need (100 GB), agent jobs at once
|
||||
(2), an optional author allowlist (new downloads only).
|
||||
- **Approval**: an Approve / Reject bar on the model and job pages, "awaiting approval" in the
|
||||
library. Rejecting removes a model the request added, or restores the previous file selection.
|
||||
- **Requested by <token>** on models and jobs, with a "Requested by" filter in the library, and an
|
||||
**activity log** per token that lists every request, including refusals with their error code.
|
||||
- **Agent skill** ([docs/agent/SKILL.md](docs/agent/SKILL.md)) and the `kaname` curl helper
|
||||
([docs/agent/kaname](docs/agent/kaname)): how to check the library, look up, request, follow,
|
||||
verify, repair and tag, and to wait for approval instead of retrying.
|
||||
|
||||
## [0.21.0] - 2026-11-08
|
||||
|
||||
### Added
|
||||
|
||||
Reference in new issue
Block a user