adm
9e6d44fa1a
Add Anthropic Messages endpoint (/v1/messages), stream + non-stream
...
- api::anthropic: AnthropicRequest -> internal ChatRequest (system, text/image/
thinking/tool_use/tool_result blocks, tools input_schema->parameters,
tool_choice, sampling, stop_sequences); ChatResponse -> Anthropic message
(thinking/text/tool_use blocks, stop_reason end_turn/max_tokens/tool_use, usage).
- AnthropicStream translator: message_start / content_block_start/delta/stop /
message_delta / message_stop, with block-index state.
- Refactor service.stream to yield semantic ChatChunk (+ prompt_len); SSE
serialization and the terminal [DONE] moved to the OpenAI route. ChatChunk
carries a #[serde(skip)] usage field for presenters (invisible on the OpenAI
wire). The same engine-driving (abort/stop/disconnect) feeds both formats.
- Route POST /v1/messages; the OpenAI wire is unchanged.
7 new tests (5 conversion unit + 2 HTTP end-to-end); 87 green + 2 ignored;
clippy clean; cargo fmt applied. README updated.
Core cases faithful; deferred: defer_loading/tool_addition/tool_reference,
thinking budget_tokens, prompt-cache token accounting.
2026-11-24 19:58:29 +01:00
adm
b6619d30de
Add optional API key auth and allowed_hosts enforcement
...
- AuthConfig (api_key, allowed_hosts) read from the shared config; router_with_auth
applies an axum middleware before any handler.
- Host not in allowlist -> 403 host_not_allowed; missing/wrong key -> 401
invalid_api_key (accepts Authorization: Bearer <key> or x-api-key); /health open.
- router() stays the open default: backward compatible (no key, wildcard hosts).
- The non-loopback bind warning now fires only when no api_key is configured.
- README updated (auth is a feature, no longer a gap).
4 new tests; 80 green + 2 real-file ignored; clippy clean; cargo fmt applied.
2026-11-24 18:48:05 +01:00
adm
597ac432e1
strata-ctl: Rust control layer for the Strata engine (OpenAI-compatible API)
...
From-scratch rewrite of the Python serve (Python kept as behavioral spec).
- engine: line-protocol supervisor (GEN/T/DONE/STOP/QUIT), silence watchdog,
abort, is_idle probe.
- config: tolerant shared-JSON loader; foreign keys ignored so one file drives
strata-ctl and uostream; CLI --config/--host/--port/--serve.
- inkling: o200k tokenizer wrapper + incremental UTF-8-safe detok; chat template
via minijinja; channel-token dialect (reasoning streamed live); image bridge
(in-process Vision, image=<path>); formatter assembling the API seam.
- api: /v1/chat/completions (stream SSE + non-stream), /v1/models, /health;
reasoning_content; structured tool_calls (llama.cpp --jinja style, client-side
execution); stop sequences with hold-back; abort on client disconnect.
69 tests green + 2 real-file ignored; clippy clean. Text, images and tools
validated live against the real Inkling engine.
2026-11-24 05:28:56 +01:00