Skip to main content

Crate ocserve_http

Crate ocserve_http 

Source
Expand description

ocserve-http: axum router, auth, byte-golden SSE, upstream error envelope.

Modules§

compress
Content negotiation for the web surfaces (WEBUI-PLAN.md W1/W2).
doc
GET /doc — the OpenAPI contract (freeze parity).
embedded_ui
Embedded, version-matched web UI (WEBUI-PLAN P6).
pty
/pty/* — terminal session routes (web-UI integrated terminal, VS Code, SDK clients). Freeze parity: shapes captured live against opencode 1.18.31 (2026-10-08, bench/pty/PTY-PLAN.md).
sync
Handler error: normal envelopes + Effect HttpApi tagged decode errors (freeze parity: ?before= → body exactly {“_tag”:“BadRequest”} §1090). Legacy→ocserve delta sync (development bridge; user: “development machinery until the final migration”). Additive-only: pulls messages/ parts for sessions that exist in BOTH databases, emits live SSE so an open oc-remote view updates, refreshes session title/time (legacy wins for imported sessions — documented divergence, TESTING §1.6).
tui
/tui/* external-controller group (PLAN §17; freeze parity probed live 2026-10-08 against upstream 1.18.31).
ui
Web-UI backend support (Phase 7): upstream-parity CORS + the catch-all UI proxy.
v2
v2 /api/* surface (opencode 1.18.31 contract).
vcs
/vcs/* — git status/diff/info, freeze-parity (WEBUI-PLAN W5).
watch
H1: config hot-reload for EXTERNAL edits (vim/TUI writing the shared files) + the single reconcile pipeline that PATCH/auth paths also use.

Structs§

ApiError
Upstream error envelope: {“name”:“NotFoundError”,“data”:{“message”:“…”}} (captured live).
AppState
App state shared by handlers.
LlmRegistry
LLM endpoint resolution for the prompt runner (assembled by Runtime).
Payloads
WireEntry
One wire-cache entry: identity bytes, precomputed compressed variants, and a strong ETag over the identity body (WEBUI-PLAN W1/W2).
Wires
Real runtime pieces passed at construction (no interior mutability, no unsafe).

Enums§

HttpError

Constants§

FREEZE_VERSION
Freeze (PLAN §3): version reported by /global/health.
PAGE_MEMO_ENTRY_CAP
PAGE_MEMO_MAX_BYTES
PAGE_MEMO_MAX_ENTRIES
Count + BYTE bounds (F9c): the first cap (32) thrashed against the fixture’s 200-session spread working set (VU150/300 spread fell to 3,794 rps, p95 278ms — every rotation missed and paid the full assemble path; arrival never recovered from it). Working set ≈ sessions x pages-per-loop ≈ 600 keys; typical pages are 10-50KB so a 64 MiB total budget holds the whole set (env: OCSERVE_PAGE_MEMO_MB).

Functions§

config_write_path
W4 config-write target: default = the SHARED opencode.json (drop-in contract — both servers read it); OCSERVE_CONFIG_WRITE=overlay switches to a ocserve-owned file that layers over the base at load (never touches the other server’s config).
deep_merge
Pre-assembled payloads for config-derived routes (built by ocserve’s Runtime::load(); kept crate-local so http doesn’t depend on cli). JSON deep merge: objects merge recursively, everything else (arrays, scalars) replaces. Used by overlay layering + PATCH /config (W4).
expand_command
v1 command template expansion (prompt.ts command()): $N placeholders (last position swallows the remaining args), then $ARGUMENTS, then append rule. !…`` shell snippets (ConfigMarkdown.shell) are NOT evaluated — neither built-in template uses them (documented gap for exotic config commands).
forked_title
Freeze getForkedTitle (session.ts): /^(.+) \(fork #(\d+)\)$/ → base (fork #(n+1)), otherwise title (fork #1). Ported with string ops (regex .+ needs ≥1 char before the suffix → idx > 0, greedy match → last occurrence → rfind).
js_to_date_string
Freeze default session title (session.ts parentTitlePrefix + ISO) — JS Date.prototype.toDateString() (“Mon Oct 12 2026”) — the env block’s “Today’s date” line (system.ts:environment). Days-from-civil, no date crate.
keypaths
JSON key-path projection: $, $.a, $.a[].b, … (values ignored). Shared oracle for keys-mode golden comparisons (manifest mode=keys).
page_memo_enabled
page_memo_stats
(hits, misses, entries) for the load report / tests.
router
Router for the P0 surface. Auth is an AppState decision (freeze §3).
split_command_args
v1 argsRegex tokenizer: quoted strings or non-space runs, then quoteTrimRegex strips one leading/trailing quote per token.
sse_expected_headers
Header values the SSE route must carry (asserted by tests against golden bytes).
start_plugin_event_pump
P0e: forward bus frames to the plugin sidecar’s event hook (v1 plugin/index.ts:255-259). Lagged frames are skipped (upstream is fire-and-forget); a closed bus ends the pump. Never blocks publishers.

Type Aliases§

ConfigReloader
Boot-injected config reloader (W4): Runtime::load lives in ocserve — the closure avoids a crate cycle; None in tests. Returns derived payloads AND a rebuilt LLM registry (H2 — auth/provider/default-model edits apply without restart). Callers go through watch::reconcile, never the raw fn.
PromptTask
session → (generation, background prompt task) for POST /abort.