feat: file/image upload + separated framework root (sessions/data/uploads)
- POST /api/uploads: base64 -> shared ~/.strata-ctl/uploads store (uuid+ext), content-sniffed kind (image/text/binary), text token-counted via the model tokenizer; metadata persisted in a new uploads table. - Chat attachments routed by kind: images -> Vision bridge (multipart image_url), small text (<=2000 tokens) inlined, large text/binary -> path + shell_exec reminder; binaries never inlined. Attachment context persisted with the turn. - GUI: attach button + file picker, removable chips, attachments sent with the turn and shown on the user bubble; cleared on session switch. - Framework root ~/.strata-ctl separated by type: sessions/<name>/, data/ (SQLite, moved from ~/.config/strata-ctl), uploads/. Legacy DB copied once on first run. - count_tokens seam on Formatter (real tokenizer override) + ChatService. - i18n: upload errors + attachment markers (backend) and attach.* (GUI), it+en. - 121 tests + 2 ignored; clippy/fmt clean; validated live (upload routing, real tokenizer count, image->Vision answered "Rosso", new layout).
This commit is contained in:
1 parent
498e3dbc1b
commit
65f8111ba2
19 files changed
+672
-47
No files matched your search
@@ -102,6 +102,8 @@ offline, same-origin so no CORS). It is a thin client over a **session-aware API
|
||||
their token usage.
|
||||
- `GET /api/stats` — aggregate counters (sessions, messages, prompt/completion tokens).
|
||||
- `GET/PUT /api/settings/defaults` — the global default settings template.
|
||||
- `POST /api/uploads` — store an uploaded file (base64) in the shared upload dir;
|
||||
returns metadata (kind, token count, path). Attach the returned id to a chat turn.
|
||||
- `PATCH /api/sessions/{id}` — rename (only before the first interaction) and/or
|
||||
replace the session's own settings instance.
|
||||
|
||||
@@ -112,19 +114,34 @@ affects only *future* sessions — no retroactive surprises. The user jots the
|
||||
chat's purpose in **notes**. The framework assigns an evocative name (a curated
|
||||
word list); it is editable only before the first interaction, then **immutable**.
|
||||
At that first interaction a personal workspace folder is created
|
||||
(`~/.strata-ctl/<name>/`, configurable via `workspace_root`) and a structural
|
||||
identity reminder ("your name is …, your personal folder is …") is prepended to
|
||||
the model's context — not an editable setting. The GUI exposes all of this in a
|
||||
⚙️ settings panel (per-session or general).
|
||||
(`~/.strata-ctl/sessions/<name>/`, under the configurable `workspace_root`) and a
|
||||
structural identity reminder ("your name is …, your personal folder is …") is
|
||||
prepended to the model's context — not an editable setting. The GUI exposes all of
|
||||
this in a ⚙️ settings panel (per-session or general).
|
||||
|
||||
**Uploads.** The 📎 button attaches files and images. Bytes land in a single
|
||||
**shared** store (`~/.strata-ctl/uploads/`, filename converted to a uuid keeping the
|
||||
extension); nothing is bulk-injected into context. Content is classified by
|
||||
*sniffing* (not extension) and routed: **images** go through the Vision bridge
|
||||
(pixels, not a path); **small text** (≤ ~2000 tokens, measured with the model's own
|
||||
tokenizer) is inlined; **large text and binaries** are handed to the agent as a path
|
||||
with a reminder to inspect them selectively via `shell_exec` — binaries never enter
|
||||
the context directly. The `shell_exec` output cap is a second safety net.
|
||||
|
||||
The standard `/v1` API stays **stateless**; conversation context lives server-side
|
||||
in an embedded **SQLite** database (default `~/.config/strata-ctl/sessions.db`,
|
||||
in an embedded **SQLite** database (default `~/.strata-ctl/data/sessions.db`,
|
||||
override with `db_path`). Storage sits behind a `Store` trait so it can be swapped
|
||||
(the planned direction is **ArangoDB**, multi-model: KV / documents / graphs / vector
|
||||
indexes) or complemented by another DBMS for advanced analytics later, without
|
||||
touching the API or the GUI. This is the foundation for multi-session, statistics and
|
||||
advanced settings to grow on top.
|
||||
|
||||
**Framework root.** All persistent state lives under `~/.strata-ctl/` (the Linux
|
||||
user's home; override with `workspace_root`), separated by content type:
|
||||
`sessions/<name>/` (agent workspace folders), `data/` (the SQLite database),
|
||||
`uploads/` (uploaded files). A legacy DB at `~/.config/strata-ctl/sessions.db` is
|
||||
copied into `data/` once on first run (the original is left in place).
|
||||
|
||||
## Agent mode
|
||||
|
||||
The GUI model can **act**, not just chat. Toggle the 🤖 button and the model runs as
|
||||
@@ -188,8 +205,10 @@ uses `tracing`; set `RUST_LOG` to control verbosity (default `info`).
|
||||
|
||||
The config is the same JSON the other Strata tools use. Keys acted on here include
|
||||
`exe`, `args`, `cwd`, `tokenizer`, `model_name`, `host`, `port`, `reasoning_effort`,
|
||||
`sampling`, `api_key`, `allowed_hosts`, `db_path` (GUI session database), and the
|
||||
optional `startup_timeout_secs` / `silence_timeout_secs`. Everything else (`arch`,
|
||||
`sampling`, `api_key`, `allowed_hosts`, `db_path` (GUI session database),
|
||||
`workspace_root` (framework root), `system_prompt` (general default), `language`
|
||||
(UI/prompt catalog, default `it`), and the optional `startup_timeout_secs` /
|
||||
`silence_timeout_secs`. Everything else (`arch`,
|
||||
`mcp_servers`, `cors_origins`, …) is preserved untouched and reported as ignored —
|
||||
unknown keys never break startup.
|
||||
|
||||
@@ -210,10 +229,11 @@ later adaptation round.
|
||||
|
||||
## Status
|
||||
|
||||
Working and tested (115 tests, plus 2 real-file tests run on demand). Text, images,
|
||||
Working and tested (121 tests, plus 2 real-file tests run on demand). Text, images,
|
||||
the full client-side tool loop, the Anthropic endpoint, the web GUI (session
|
||||
context, streaming, stats) and **agent mode** (the model using `shell_exec` on the
|
||||
host) have been validated live against the real Inkling engine.
|
||||
context, streaming, stats, **file/image upload**) and **agent mode** (the model
|
||||
using `shell_exec` on the host) have been validated live against the real Inkling
|
||||
engine.
|
||||
|
||||
Not yet implemented (honest gaps): forced `tool_choice` (`required` / named function
|
||||
returns a clear 400), multi-slot batching, logprobs / structured output, automatic
|
||||
@@ -221,9 +241,10 @@ engine restart after a crash, a full SSRF guard against DNS rebinding, and the
|
||||
OpenAI Responses native endpoint. The Anthropic adapter covers the core cases but
|
||||
not yet the `defer_loading` / `tool_addition` / `tool_reference` tool machinery, the
|
||||
thinking `budget_tokens` mapping, or prompt-cache token accounting. The GUI agent's
|
||||
**isolated mode** (Docker-container runner) and GUI file/image upload are still to
|
||||
come; base/host agent mode, per-session settings (copy-on-create), session notes,
|
||||
immutable names and personal workspace folders work.
|
||||
**isolated mode** (Docker-container runner) is still to come; base/host agent mode,
|
||||
per-session settings (copy-on-create), session notes, immutable names, personal
|
||||
workspace folders and file/image upload (shared store, token-based routing,
|
||||
images via Vision) work.
|
||||
|
||||
## License and credits
|
||||
|
||||
|
||||
Reference in new issue
Block a user