Agent skill: kaname helper script, declared env vars, less polling

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-20 16:24:51 +02:00
1 parent 93edb198d8
commit 981c4170fc
3 files changed
+46 -18

No files matched your search

+7
View File
@@ -6,6 +6,13 @@ step 1 (Hugging Face downloader) is released as a minor version.
## [Unreleased]
### Fixed
- Agent skill (`docs/agent/SKILL.md`) works with how Hermes Agent runs commands: a `kaname` helper
script (`docs/agent/kaname`) instead of a shell function that didn't survive between commands,
`KANAME_URL`/`KANAME_TOKEN` declared in the frontmatter, and far less polling (none while a
request waits for approval, one check around the ETA while downloading).
## [0.10.0] - 2026-10-20
An API for AI agents: a token-authenticated `/api/v1` lets a program look up models, request
+37 -18
View File
@@ -1,6 +1,11 @@
---
name: kaname-models
description: Find, request and track downloads of local LLMs (Hugging Face models, GGUF quants) on the user's Kaname server. Use when the user asks to get, download, add or check a model, or asks which models are available locally or how much disk space is left.
required_environment_variables:
- name: KANAME_URL
prompt: Kaname base URL (no trailing slash)
- name: KANAME_TOKEN
prompt: Kaname API token (kn_…)
---
# Kaname: local model downloads
@@ -14,16 +19,25 @@ Every call needs two environment variables:
- `KANAME_URL`: e.g. `https://models.example.com` (no trailing slash)
- `KANAME_TOKEN`: the API token (`kn_…`). Never print it or put it in a URL.
## Setup
The examples use `kaname`, a small wrapper around `curl` that adds the token and JSON headers. The
user installs it once:
```bash
k() { curl -sS -H "Authorization: Bearer $KANAME_TOKEN" -H "Content-Type: application/json" "$@"; }
mkdir -p ~/.local/bin && curl -fsSL https://git.linxweiler.xyz/pascallinxweiler/Kaname/raw/branch/main/docs/agent/kaname -o ~/.local/bin/kaname && chmod +x ~/.local/bin/kaname
```
If `kaname` is not found, write out the full command in each call instead:
`curl -sS -H "Authorization: Bearer $KANAME_TOKEN" -H "Content-Type: application/json" …`
(every command runs in a fresh shell, so don't define a shell function for it).
All responses are JSON. Errors are `{"error": {"code", "message"}}`; the message says what to do.
## 0. Know your limits
```bash
k "$KANAME_URL/api/v1"
kaname "$KANAME_URL/api/v1"
```
Shows your token name, scopes and the guardrails. The defaults:
@@ -37,8 +51,8 @@ Shows your token name, scopes and the guardrails. The defaults:
## 1. Is it already here?
```bash
k "$KANAME_URL/api/v1/models?q=qwen3%208b"
k "$KANAME_URL/api/v1/models?author=unsloth&quant=Q4_K_M&status=ready"
kaname "$KANAME_URL/api/v1/models?q=qwen3%208b"
kaname "$KANAME_URL/api/v1/models?author=unsloth&quant=Q4_K_M&status=ready"
```
Filters: `q`, `author`, `family`, `quant`, `tag`, `status`, `requested_by` (comma-separate values).
@@ -47,14 +61,14 @@ If the model is there with `status: ready`, you're done. Don't request it again.
## 2. Look up the repo
```bash
k "$KANAME_URL/api/v1/hub/lookup?repo=unsloth/Qwen3-8B-GGUF"
kaname "$KANAME_URL/api/v1/hub/lookup?repo=unsloth/Qwen3-8B-GGUF"
```
Note `sha` (the commit) and pick a quant from `quants` (each has a `size`). Choose one that fits the
user's request and the limits: check `size` against `maxRequestSize`, and check space with:
```bash
k "$KANAME_URL/api/v1/disk" # availableForRequests = what a request may still use
kaname "$KANAME_URL/api/v1/disk" # availableForRequests = what a request may still use
```
If `gated` is not `false`, the download only works if the user's Hugging Face account has access.
@@ -62,7 +76,7 @@ If `gated` is not `false`, the download only works if the user's Hugging Face ac
## 3. Request the download
```bash
k -X POST "$KANAME_URL/api/v1/downloads" \
kaname -X POST "$KANAME_URL/api/v1/downloads" \
-d '{"repoId":"unsloth/Qwen3-8B-GGUF","sha":"<sha from lookup>","quant":"Q4_K_M"}'
```
@@ -80,17 +94,22 @@ Answer:
## 4. Follow it
```bash
k "$KANAME_URL/api/v1/jobs/<jobId>"
kaname "$KANAME_URL/api/v1/jobs/<jobId>"
```
`state`: `pending_approval` → `queued` → `downloading` → `verifying` → `completed`. `progress.percent`
and `etaSeconds` show how far it is; `next` says what to do. Poll gently: every few minutes while
pending, about once a minute while downloading. Add `?log=20` only when you need to explain a
failure.
`state`: `pending_approval` → `queued` → `downloading` → `verifying` → `completed`. Every check
costs a full round of your context, so check rarely:
- `completed`: tell the user it's ready.
- `cancelled`: the user rejected or cancelled it. Don't ask again unless the user says so.
- `failed`: report `error.message` to the user. Don't loop on retries.
- **`pending_approval`:** do **not** poll. Tell the user what you requested and that it awaits
their approval in Kaname, then stop. Check again only when the user says it's approved, or, if
the user asks for it, schedule a single one-off check later with your cron/scheduling tool.
- **`queued` / `downloading` / `verifying`:** check at most once, around the reported
`etaSeconds`; if there is no ETA, once after about 10 minutes. Never loop in short intervals.
- **`completed`:** tell the user it's ready.
- **`cancelled`:** the user rejected or cancelled it. Don't ask again unless the user says so.
- **`failed`:** report `error.message` to the user. Don't loop on retries.
Add `?log=20` only when you need to explain a failure.
## When a request is refused
@@ -98,12 +117,12 @@ failure.
| --- | --- |
| `too_large` | Pick a smaller quant (or fewer files) that fits `maxRequestSize`. |
| `disk_space` | Pick a smaller quant, or tell the user the disk is full. |
| `too_many_jobs` | Wait until one of your downloads has finished, then try again. Don't spin. |
| `too_many_jobs` | Don't wait in a loop: tell the user your earlier downloads are still pending or running, and stop. Request again later when the user asks. |
| `author_not_allowed` | Find the model from an allowed author, or ask the user. |
| `already_exists` | The repo is in the library at another commit; the user updates it in Kaname. |
| `busy` | That model has a download in progress; wait for it. |
| `busy` | That model has a download in progress; tell the user and stop. |
| `gated_no_access`, `gated_no_token` | The user must accept the model's terms on Hugging Face. |
| `disk_unknown` | Kaname's worker is offline; try again later or tell the user. |
| `disk_unknown` | Kaname's worker is offline; tell the user and stop. |
| `unauthorized`, `forbidden` | Your token is wrong, revoked or lacks a scope: tell the user. |
Never try to work around a guardrail (e.g. by splitting one big download into several requests).
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
exec curl -sS -H "Authorization: Bearer $KANAME_TOKEN" -H "Content-Type: application/json" "$@"