v1.2.0:7 — add SparkControl AI provider + fix base-URL footgun
SparkControl is a self-hosted local-inference gateway with an OpenAI-compatible API, reached over the internal same-box StartOS address (http://spark-control.startos:9999/v1, plain HTTP). It takes no API key, so generateOpenAIStyle gained a { requireApiKey } option and now omits the Authorization header when no key is set. The Settings form auto-detects the loaded vLLM model via SparkControl's /api/endpoints probe, mirroring the Ollama auto-detect; it's $0 in the cost UI. Custom-URL => admin-only + SSRF-guarded, same as Ollama. Also fixes a config footgun behind the empty-response report: a custom base URL could ride along to a fixed-URL provider (claude/openai/gemini) whose form field is hidden, get stored, and be silently ignored (the provider always hits its hardcoded endpoint). Both config write paths now null baseUrl for non-custom-URL providers, and the form clears it on provider change. No schema/data change (AIConfigProfile.provider is free-text). 259 tests pass; built + sideloaded to immense-voyage.local with a clean non-root launch.
This commit is contained in:
@@ -47,11 +47,34 @@ stores the JSON in the (reused) `parsedProgram` column.
|
||||
|
||||
- Each provider yields an async iterable of `GenerateChunk` (`text` / `usage` / `done` /
|
||||
`error`); add new ones under `lib/ai/providers/` and register in `index.ts`.
|
||||
`openai.ts` exports both `openai` and `openai-compatible`, so the four provider files
|
||||
register **5** providers (`claude`, `openai`, `openai-compatible`, `gemini`, `ollama`).
|
||||
`openai.ts` exports both `openai` and `openai-compatible`, so the five provider files
|
||||
register **6** providers (`claude`, `openai`, `openai-compatible`, `gemini`, `ollama`,
|
||||
`sparkcontrol`).
|
||||
- **SparkControl** (`sparkcontrol.ts`) — the operator's own self-hosted local-inference
|
||||
gateway. OpenAI-compatible wire format, so it reuses `generateOpenAIStyle` with
|
||||
`{ requireApiKey: false }` (keyless on the LAN — the streamer omits the `Authorization`
|
||||
header when no key is set). Reached over the **internal same-box StartOS address**
|
||||
(`http://spark-control.startos:9999/v1`, plain HTTP — no TLS, no cert-skip). Custom base
|
||||
URL ⇒ SSRF-guarded + admin-only, same as Ollama. The Settings UI auto-detects the loaded
|
||||
vLLM model via `app/api/ai/sparkcontrol/model` (probes SparkControl's `/api/endpoints`
|
||||
→ `vllm.model`), mirroring the Ollama `/api/tags` auto-detect. Free in the cost UI.
|
||||
- **Base-URL hygiene:** only custom-URL providers (`requiresBaseUrl`: ollama,
|
||||
openai-compatible, sparkcontrol) store a base URL. Both config write paths
|
||||
(`configs` POST + `[id]` PATCH) null it for fixed-URL providers, and the Settings form
|
||||
clears it on provider change — otherwise a stale URL silently rides along to
|
||||
claude/openai/gemini, which ignore it and hit their hardcoded endpoints.
|
||||
- Streaming AI uses SSE; partial JSON is recovered with `lib/ai/lenientJson.ts`.
|
||||
- Pricing/model menus live in `lib/ai/pricing.ts` (`PRICES`, `MODEL_MENU`) — keep them
|
||||
paired so every menu model has a price entry (there's a test enforcing this).
|
||||
- **Adding a provider** (precedent: `sparkcontrol`, 1.2.0:7) is a fan-out across ~8 spots —
|
||||
miss one and it half-works: the provider file + `ProviderId` union (`types.ts`) + register
|
||||
in `providers/index.ts` (`ALL` + `PROVIDER_ORDER`); the zod `provider` enum in **both**
|
||||
`configs` POST and `[id]` PATCH (+ `defaultName` PRETTY map); the UI `PROVIDERS` list in
|
||||
`AIIntegration.tsx` (`requiresKey`/`requiresUrl` must mirror the server `requiresApiKey`/
|
||||
`requiresBaseUrl`); `MODEL_MENU` (`[]` if no curated menu) + an `estimateCost` branch
|
||||
(free/null for self-hosted). A custom-URL provider is admin-only + SSRF-guarded everywhere
|
||||
(configs POST/PATCH, `ai/test`, any probe route) and must appear in those routes' 403
|
||||
enumeration strings. `ai/test` and `generate` work for free once it's in `getProvider`.
|
||||
|
||||
## SSRF / provider-URL safety
|
||||
|
||||
|
||||
Reference in New Issue
Block a user