diff --git a/CHANGELOG.md b/CHANGELOG.md index be5da24..8082897 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,23 @@ step 1 (Hugging Face downloader) is released as a minor version. ## [Unreleased] +First part of model testing: runtimes. Starting containers with a model comes next. + +### Added + +- **Runtimes** (Settings → Runtimes): container images that serve models. Presets for the official + llama.cpp CPU server (`ghcr.io/ggml-org/llama.cpp:server`) and vLLM CPU + (`vllm/vllm-openai-cpu:v0.31.0`), plus your own images from any registry (e.g. patched forks) with + an engine type (llama.cpp- or vLLM-compatible), environment, extra arguments, shared memory, + device passthrough (only `/dev/dri…`, `/dev/kfd`) and an opt-in "NUMA tuning" switch (the + `CAP_SYS_NICE` + `seccomp=unconfined` that vLLM recommends on CPU; off by default). +- Pull and update runtime images from the UI, with progress and readable errors. +- Docker host card: Docker version, CPU model and features (AVX2, AVX-512, AMX, …), memory, and the + network and models source the worker detected from its own container. +- `docker-proxy` service (`tecnativa/docker-socket-proxy:v0.5.0`) in both compose files; the worker + reaches Docker only through it (`DOCKER_HOST`). New settings `DOCKER_HOST`, + `KANAME_DOCKER_NETWORK`, `KANAME_MODELS_SOURCE` (see the wiki). + ## [0.6.0] - 2026-10-06 Delete models (with their files), verify and deep verify, one-click repair, and update checks diff --git a/README.md b/README.md index e2cdeb8..0dfdad0 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,9 @@ More guides are in the [wiki](https://git.linxweiler.xyz/pascallinxweiler/Kaname updating is always your click. If a repo (or its pinned commit) disappears from Hugging Face, the model is flagged and your local copy is kept. - **Delete:** removes the model and, if you want, its files from disk. +- **Runtimes:** register llama.cpp, vLLM or your own fork images and pull them from Settings → Runtimes + (groundwork for testing model configs). See the + [wiki](https://git.linxweiler.xyz/pascallinxweiler/Kaname/wiki/Runtimes). - **Jobs:** each download has a page with per-file progress and the full `hf` log. ## How it works diff --git a/compose.yaml b/compose.yaml index 8b6d920..bf95e6f 100644 --- a/compose.yaml +++ b/compose.yaml @@ -16,6 +16,11 @@ services: worker: <<: *app command: worker + environment: + DATABASE_URL: file:/data/app.db + MODELS_DIR: /models + HF_HOME: /data/hf-home + DOCKER_HOST: tcp://docker-proxy:2375 volumes: [data:/data, models:/models] web: @@ -23,6 +28,23 @@ services: ports: ["${WEB_PORT:-3000}:3000"] volumes: [data:/data] + # Docker API for runtimes (llama.cpp / vLLM containers), limited to what Kaname needs: + # containers, images, networks, info. Not reachable from outside the compose network. + # Remove this service (and DOCKER_HOST on the worker) to run Kaname as a pure downloader. + docker-proxy: + image: tecnativa/docker-socket-proxy:v0.5.0 + environment: + CONTAINERS: 1 + IMAGES: 1 + INFO: 1 + NETWORKS: 1 + POST: 1 + ALLOW_START: 1 + ALLOW_STOP: 1 + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + restart: unless-stopped + volumes: data: models: diff --git a/deploy/compose.yaml b/deploy/compose.yaml index f903f68..f166c81 100644 --- a/deploy/compose.yaml +++ b/deploy/compose.yaml @@ -8,6 +8,8 @@ services: image: git.linxweiler.xyz/pascallinxweiler/kaname:${KANAME_VERSION:-latest} command: worker env_file: .env + environment: + DOCKER_HOST: tcp://docker-proxy:2375 volumes: - ${KANAME_DATA_DIR:-./data}:/data # SQLite DB, shared with web (local disk, not NFS) - ${KANAME_MODELS_DIR:-./models}:/models # downloaded models (a host-mounted NAS share works) @@ -20,3 +22,20 @@ services: volumes: - ${KANAME_DATA_DIR:-./data}:/data restart: unless-stopped + + # Docker API for runtimes (llama.cpp / vLLM containers), limited to what Kaname needs: + # containers, images, networks, info. Not reachable from outside the compose network. + # Remove this service (and DOCKER_HOST on the worker) to run Kaname as a pure downloader. + docker-proxy: + image: tecnativa/docker-socket-proxy:v0.5.0 + environment: + CONTAINERS: 1 + IMAGES: 1 + INFO: 1 + NETWORKS: 1 + POST: 1 + ALLOW_START: 1 + ALLOW_STOP: 1 + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + restart: unless-stopped diff --git a/drizzle/0010_runtimes.sql b/drizzle/0010_runtimes.sql new file mode 100644 index 0000000..2861b1a --- /dev/null +++ b/drizzle/0010_runtimes.sql @@ -0,0 +1,26 @@ +CREATE TABLE `runtimes` ( + `id` text PRIMARY KEY NOT NULL, + `name` text NOT NULL, + `engine` text NOT NULL, + `image` text NOT NULL, + `description` text, + `env` text DEFAULT '{}' NOT NULL, + `extra_args` text DEFAULT '[]' NOT NULL, + `devices` text DEFAULT '[]' NOT NULL, + `shm_size_mb` integer, + `numa_tuning` integer DEFAULT false NOT NULL, + `preset` text, + `image_state` text DEFAULT 'unknown' NOT NULL, + `image_id` text, + `image_size` integer, + `image_created` text, + `pull_requested_at` integer, + `pull_started_at` integer, + `pull_progress` text, + `pull_error` text, + `image_checked_at` integer, + `created_at` integer NOT NULL, + `updated_at` integer NOT NULL +); +--> statement-breakpoint +ALTER TABLE `worker_state` ADD `docker` text; \ No newline at end of file diff --git a/drizzle/meta/0010_snapshot.json b/drizzle/meta/0010_snapshot.json new file mode 100644 index 0000000..5977807 --- /dev/null +++ b/drizzle/meta/0010_snapshot.json @@ -0,0 +1,1209 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "e8b2de90-0b1c-4264-93cd-886b041d5660", + "prevId": "b3b76363-6bde-4c57-b048-9d265bbcac6f", + "tables": { + "job_files": { + "name": "job_files", + "columns": { + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_file_id": { + "name": "model_file_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expected_bytes": { + "name": "expected_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "done_bytes": { + "name": "done_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "job_files_job_id_jobs_id_fk": { + "name": "job_files_job_id_jobs_id_fk", + "tableFrom": "job_files", + "tableTo": "jobs", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "job_files_model_file_id_model_files_id_fk": { + "name": "job_files_model_file_id_model_files_id_fk", + "tableFrom": "job_files", + "tableTo": "model_files", + "columnsFrom": [ + "model_file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "job_files_job_id_model_file_id_pk": { + "columns": [ + "job_id", + "model_file_id" + ], + "name": "job_files_job_id_model_file_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "job_logs": { + "name": "job_logs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ts": { + "name": "ts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "stream": { + "name": "stream", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "line": { + "name": "line", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "job_logs_job_idx": { + "name": "job_logs_job_idx", + "columns": [ + "job_id", + "id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "job_logs_job_id_jobs_id_fk": { + "name": "job_logs_job_id_jobs_id_fk", + "tableFrom": "job_logs", + "tableTo": "jobs", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "jobs": { + "name": "jobs", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_sha": { + "name": "target_sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'queued'" + }, + "attempt": { + "name": "attempt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "total_bytes": { + "name": "total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "done_bytes": { + "name": "done_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "speed_bps": { + "name": "speed_bps", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "eta_seconds": { + "name": "eta_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "exit_code": { + "name": "exit_code", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_code": { + "name": "error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cancel_requested_at": { + "name": "cancel_requested_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "jobs_state_idx": { + "name": "jobs_state_idx", + "columns": [ + "state" + ], + "isUnique": false + }, + "jobs_model_idx": { + "name": "jobs_model_idx", + "columns": [ + "model_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "jobs_model_id_models_id_fk": { + "name": "jobs_model_id_models_id_fk", + "tableFrom": "jobs", + "tableTo": "models", + "columnsFrom": [ + "model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "local_folders": { + "name": "local_folders", + "columns": { + "path": { + "name": "path", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "files": { + "name": "files", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "file_count": { + "name": "file_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total_bytes": { + "name": "total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "commit": { + "name": "commit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scanned_at": { + "name": "scanned_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "model_files": { + "name": "model_files", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "blob_oid": { + "name": "blob_oid", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lfs_sha256": { + "name": "lfs_sha256", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "selected": { + "name": "selected", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "checked_at": { + "name": "checked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "model_files_model_path_uq": { + "name": "model_files_model_path_uq", + "columns": [ + "model_id", + "path" + ], + "isUnique": true + } + }, + "foreignKeys": { + "model_files_model_id_models_id_fk": { + "name": "model_files_model_id_models_id_fk", + "tableFrom": "model_files", + "tableTo": "models", + "columnsFrom": [ + "model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "model_revisions": { + "name": "model_revisions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sha": { + "name": "sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "pinned_at": { + "name": "pinned_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "superseded_at": { + "name": "superseded_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "model_revisions_model_idx": { + "name": "model_revisions_model_idx", + "columns": [ + "model_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "model_revisions_model_id_models_id_fk": { + "name": "model_revisions_model_id_models_id_fk", + "tableFrom": "model_revisions", + "tableTo": "models", + "columnsFrom": [ + "model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "model_tags": { + "name": "model_tags", + "columns": { + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tag_id": { + "name": "tag_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "model_tags_tag_idx": { + "name": "model_tags_tag_idx", + "columns": [ + "tag_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "model_tags_model_id_models_id_fk": { + "name": "model_tags_model_id_models_id_fk", + "tableFrom": "model_tags", + "tableTo": "models", + "columnsFrom": [ + "model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "model_tags_tag_id_tags_id_fk": { + "name": "model_tags_tag_id_tags_id_fk", + "tableFrom": "model_tags", + "tableTo": "tags", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "model_tags_model_id_tag_id_pk": { + "columns": [ + "model_id", + "tag_id" + ], + "name": "model_tags_model_id_tag_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "models": { + "name": "models", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "repo_type": { + "name": "repo_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'model'" + }, + "repo_id": { + "name": "repo_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tracked_revision": { + "name": "tracked_revision", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'main'" + }, + "pinned_sha": { + "name": "pinned_sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "local_path": { + "name": "local_path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "include_patterns": { + "name": "include_patterns", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "exclude_patterns": { + "name": "exclude_patterns", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "remote_sha": { + "name": "remote_sha", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_checked_at": { + "name": "last_checked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_check_error": { + "name": "last_check_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hub_state": { + "name": "hub_state", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hub_missing_since": { + "name": "hub_missing_since", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "update_diff": { + "name": "update_diff", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_verified_at": { + "name": "last_verified_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "downloaded_at": { + "name": "downloaded_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "base_models": { + "name": "base_models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "base_relation": { + "name": "base_relation", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "author_avatar_url": { + "name": "author_avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "architecture": { + "name": "architecture", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pipeline_tag": { + "name": "pipeline_tag", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "license": { + "name": "license", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hub_tags": { + "name": "hub_tags", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata_fetched_at": { + "name": "metadata_fetched_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "models_repo_uq": { + "name": "models_repo_uq", + "columns": [ + "repo_type", + "repo_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "runtimes": { + "name": "runtimes", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "engine": { + "name": "engine", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "env": { + "name": "env", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "extra_args": { + "name": "extra_args", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "devices": { + "name": "devices", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "shm_size_mb": { + "name": "shm_size_mb", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "numa_tuning": { + "name": "numa_tuning", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "preset": { + "name": "preset", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_state": { + "name": "image_state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'unknown'" + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_size": { + "name": "image_size", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_created": { + "name": "image_created", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pull_requested_at": { + "name": "pull_requested_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pull_started_at": { + "name": "pull_started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pull_progress": { + "name": "pull_progress", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pull_error": { + "name": "pull_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_checked_at": { + "name": "image_checked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "settings": { + "name": "settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tags": { + "name": "tags", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "tags_slug_uq": { + "name": "tags_slug_uq", + "columns": [ + "slug" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "worker_state": { + "name": "worker_state", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "instance_id": { + "name": "instance_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pid": { + "name": "pid", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hf_version": { + "name": "hf_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models_dir_free_bytes": { + "name": "models_dir_free_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models_dir_total_bytes": { + "name": "models_dir_total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "heartbeat_at": { + "name": "heartbeat_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scan_requested_at": { + "name": "scan_requested_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "docker": { + "name": "docker", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index d0c66df..a6143cb 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -71,6 +71,13 @@ "when": 1791238659338, "tag": "0009_verify_update", "breakpoints": true + }, + { + "idx": 10, + "version": "6", + "when": 1791242201063, + "tag": "0010_runtimes", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/app/(app)/settings/layout.tsx b/src/app/(app)/settings/layout.tsx index 18798a6..4f467d0 100644 --- a/src/app/(app)/settings/layout.tsx +++ b/src/app/(app)/settings/layout.tsx @@ -1,10 +1,11 @@ -import { DownloadIcon, TagIcon, TagsIcon } from "lucide-react"; +import { BoxesIcon, DownloadIcon, TagIcon, TagsIcon } from "lucide-react"; import { SettingsNav } from "./settings-nav"; const SECTIONS = [ { href: "/settings/labels", label: "File labels", icon: }, { href: "/settings/tags", label: "Tags", icon: }, { href: "/settings/downloads", label: "Downloads", icon: }, + { href: "/settings/runtimes", label: "Runtimes", icon: }, ]; export default function SettingsLayout({ children }: LayoutProps<"/settings">) { diff --git a/src/app/(app)/settings/runtimes/page.tsx b/src/app/(app)/settings/runtimes/page.tsx new file mode 100644 index 0000000..4ca438e --- /dev/null +++ b/src/app/(app)/settings/runtimes/page.tsx @@ -0,0 +1,12 @@ +import type { Metadata } from "next"; +import { getDockerInfo, listRuntimes } from "@/lib/runtimes"; +import { getWorkerStatus } from "@/lib/worker-status"; +import { RuntimesView } from "./runtimes-view"; + +export const dynamic = "force-dynamic"; +export const metadata: Metadata = { title: "Runtimes · Settings" }; + +export default async function RuntimesPage() { + const [runtimes, docker, worker] = await Promise.all([listRuntimes(), getDockerInfo(), getWorkerStatus()]); + return ; +} diff --git a/src/app/(app)/settings/runtimes/runtime-form.tsx b/src/app/(app)/settings/runtimes/runtime-form.tsx new file mode 100644 index 0000000..0dd351f --- /dev/null +++ b/src/app/(app)/settings/runtimes/runtime-form.tsx @@ -0,0 +1,187 @@ +"use client"; + +import { useState } from "react"; +import { Button } from "@/components/ui/button"; +import { Checkbox } from "@/components/ui/checkbox"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import type { RuntimeEngine } from "@/lib/db/schema"; +import { formatEnvLines, parseEnvLines, type RuntimeInput, RuntimeValidationError, validateRuntime } from "@/lib/runtimes-shared"; +import { cn } from "@/lib/utils"; + +const ENGINES: { id: RuntimeEngine; label: string; hint: string }[] = [ + { id: "llama.cpp", label: "llama.cpp-compatible", hint: "llama-server command line, GGUF models" }, + { id: "vllm", label: "vLLM-compatible", hint: "vllm serve command line, safetensors models" }, +]; + +const textareaClass = + "min-h-20 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 font-mono text-xs outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 dark:bg-input/30"; + +/** Create/edit a runtime. Validates locally with the same rules as the server. */ +export function RuntimeForm({ + initial, + submitLabel, + onSubmit, + onCancel, +}: { + initial: RuntimeInput; + submitLabel: string; + onSubmit: (value: RuntimeInput) => Promise; + onCancel: () => void; +}) { + const [name, setName] = useState(initial.name); + const [engine, setEngine] = useState(initial.engine); + const [image, setImage] = useState(initial.image); + const [description, setDescription] = useState(initial.description ?? ""); + const [envText, setEnvText] = useState(formatEnvLines(initial.env ?? {})); + const [argsText, setArgsText] = useState((initial.extraArgs ?? []).join("\n")); + const [devicesText, setDevicesText] = useState((initial.devices ?? []).join(", ")); + const [shm, setShm] = useState(initial.shmSizeMb != null ? String(initial.shmSizeMb) : ""); + const [numa, setNuma] = useState(!!initial.numaTuning); + const [error, setError] = useState(null); + const [saving, setSaving] = useState(false); + + async function submit(e: React.FormEvent) { + e.preventDefault(); + let value: RuntimeInput; + try { + value = validateRuntime({ + name, + engine, + image, + description, + env: parseEnvLines(envText), + extraArgs: argsText.split("\n"), + devices: devicesText.split(/[,\s]+/), + shmSizeMb: shm.trim() ? Number(shm) : null, + numaTuning: numa, + }); + } catch (err) { + setError(err instanceof RuntimeValidationError ? err.message : String(err)); + return; + } + setError(null); + setSaving(true); + try { + await onSubmit(value); + } finally { + setSaving(false); + } + } + + return ( +
+
+
+ + setName(e.target.value)} maxLength={60} placeholder="vLLM XPU (Arc patches)" /> +
+
+ + setImage(e.target.value)} + spellCheck={false} + className="font-mono text-xs" + placeholder="registry.example.com/org/image:tag" + /> +
+
+ +
+ +
+ {ENGINES.map((e) => ( + + ))} +
+

+ Decides how Kaname builds the command line. Forks with the same CLI (e.g. patched vLLM builds) use the same type. +

+
+ +
+ + setDescription(e.target.value)} maxLength={2000} /> +
+ +
+
+ +