This commit is contained in:
Luxferre
2026-10-15 23:46:35 +03:00
parent cea7af3504
commit c970d96e91
+11 -8
View File
@@ -46,7 +46,7 @@ bantam.hpp all shared declarations (structs, prototypes, native Json type)
util.cpp string building, UTF-8, prompt-injection filter, color, IDs, MD5
config.cpp config file parsing, env precedence, /models discovery
json.cpp native RFC 8259 JSON engine, request building + response parsing
llm.cpp libcurl HTTP client, OpenCode headers, backoff, SSE streaming
llm.cpp libcurl HTTP client, custom headers, backoff, SSE streaming
tools.cpp bash/read/write tools, oversized-result offloading
session.cpp message copy, session save/load, compaction
render.cpp terminal markdown renderer (native, box-drawing tables)
@@ -326,13 +326,16 @@ that left an empty assistant message in the session), Bantam strips the last
### Custom request headers
All endpoints receive custom request headers mimicking OpenCode:
`User-Agent: opencode/1.18.31 ai-sdk/provider-utils/4.0.23 runtime/bun/1.3.14`,
`x-opencode-client: cli`, `x-opencode-project: global`,
`x-opencode-session: <ses_...>`, and a fresh `x-opencode-request: <msg_...>`
per call (the 12-hex timestamp prefix in `x-opencode-request` is the bitwise
inverse of `x-opencode-session`). The `Authorization: Bearer <api_key>` header
is added whenever `api_key` is set and not `-`.
All requests to the `/chat/completions` and `/models` endpoints are sent with a
minimal, dependency-free header set (see `apply_llm_headers` / `http_get` in
`llm.cpp`):
- `Content-Type: application/json`
- `Expect:` (empty) — suppresses the `Expect: 100-continue` round-trip so large
POST bodies are sent immediately and do not hang behind some proxies.
- `User-Agent: Mozilla/5.0 Bantam/nightly-cpp`
- `Authorization: Bearer <api_key>` — added only when `api_key` is set and is
not `-` (a real key, not the placeholder).
### Prompt-injection defense