A Rust localhost broker for inspecting OpenAI-compatible chat requests and fulfilling them through a manual JSON buffer. The same process accepts typed, read-only observations from browser and desktop perception producers.
This project is a fun take on a model server. It preserves incoming chat JSON, exposes pending requests, and waits for a deliberate response at /v1/buffer.
Dependencies:
- Tasket Communication Daemon at CommanderTurtle/macrohelp : Macro HTTPD
- Dangerously greppable markdown files at CommanderTurtle/regedited : Zone'd ripgrep sorted by index
flowchart LR
Client["OpenAI-compatible client"] --> Chat["Rust chat and buffer daemon"]
Chat --> Files["Atomic latest-state files and JSONL history"]
Buffer["Human or local response tool"] --> Chat
DOM["Surfingkeys DOM producer"] --> Vision["Typed observation endpoint"]
Desktop["Optional Python UIA / OCR / CV"] --> Vision
Vision --> Files
The daemon is the transport boundary. Vision producers cannot click, type, or execute actions. Separate opt-in perception pipes call an already running NInfer model or a cold OCR helper; the original manual chat/buffer flow is unchanged.
cargo build --release
./target/release/firebend serveBash: run bash scripts/pathadd.sh once and reload your shell for firebend and its short name fbd. Both are complete executables. Run fbd --help for examples. On Windows use .\target\release\fbd.exe serve or .\scripts\Start.ps1.
See the quick start for the first request, PATH setup and MCP registration.
fbd --help # categorized syntax table
fbd --help --ex 1 # PowerShell example summary
fbd count --help --ex 1 # five detailed PowerShell examples for count
fbd count --help --ex 2 # Bash
fbd count --help --ex 3 # Python
fbd count --help --ex 4 # CMD
fbd count --help --ex 5 # advanced PowerShell one-liners
fbd count --help --ex 6 # advanced Bash one-liners
fbd count --help --ex 7 # advanced Python one-liners
fbd count --help --ex 8 # advanced CMD one-liners
firebend -ex powershell
firebend -ex script powershellUse -ex [script] <powershell|repl|python|bash|bat> for the embedded cookbooks and script templates. Printing a guide writes only its contents to stdout; it never contacts the daemon. For example, fbd -ex script bash > count.sh exports a script you can run with bash count.sh photo.jpg "birds on a wire".
The daemon listens on http://127.0.0.1:5087. Configure appsettings.json or use fbd --config /path/to/settings.json serve; OPENAI_BUFFER_Daemon__* variables override individual settings. Set DataDirectory to move state files off the Desktop and ImageDirectory to change what latest searches.
All routes and both stdio MCP servers are compiled in by default. The manual broker and Cereal need no model runtime. Model-backed image routes use an already-running multimodal agent with native image-capable Jev at NinferBaseUrl. OCR and desktop observation provision their locked Python environment with uv on demand. To provision ahead of time, run fbd setup, or sh build.sh to build and provision together. First use needs network access for uncached dependencies and model weights. Tesseract mode uses the system tesseract binary; REH video extraction uses ffmpeg and ffprobe.
These are local vision descriptions, not numeric vector embeddings. All five routes accept the image directly; none consumes the attachment staged by /v1/file or changes your saved Jev framework. Upload bytes with an image MIME type or application/octet-stream; a local path or {"path":"..."} is also accepted.
fbd embeddings screenshot.png
fbd count photo.jpg "birds"
fbd bboxcount photo.jpg "birds" > annotated.json
curl -fsS --data-binary @photo.jpg -H 'Content-Type: image/jpeg' \
'http://127.0.0.1:5087/v1/count?target=birds'
fbd mathpixel equation.png| Route | Result |
|---|---|
| POST /v1/embeddings | All legible text, comma-separated classification, and named objects grounded with Jev. |
| POST /v1/count | The active model describes the requested type and proposes distinct visible instances; Jev locates each. count is the number of returned objects, not a model estimate. |
| POST /v1/bboxembeddings, /v1/bboxcount | The corresponding JSON plus annotated with an inline PNG, including when nothing matched. |
| POST /v1/mathpixel | Jev scores whether mathematical notation is visible. Only a score above MathConfidence (default 0.45) calls the vision model. Returns only latex, inline, display, equation, noul. The first four are null below or at the threshold. |
Object boxes use the same normalized edges as /v1/bboxask. The vision model owns the inventory and transcription. Each object stays in the result with its measured Jev noul (0–1), even when that score is zero. An inaccessible backend, malformed response or expired deadline is an HTTP error, not a successful zero count. Math conversion checks LaTeX grouping and environments without executing TeX.
Start a waiting request in one terminal:
$body = @{ model = 'manual-buffer-model'; messages = @(@{ role = 'user'; content = 'Hello' }) } | ConvertTo-Json -Depth 20
Invoke-RestMethod http://127.0.0.1:5087/v1/chat/completions -Method Post -ContentType application/json -Body $bodyFulfill it from another terminal:
Invoke-RestMethod http://127.0.0.1:5087/v1/buffer -Method Post -ContentType application/json -Body '{"content":"Hello from the buffer."}'/v1/buffer may receive a simple content value or a complete response containing choices. A request_id targets a particular pending request; otherwise the oldest pending request is completed.
| Method | Path | Behavior |
|---|---|---|
GET |
/health |
Process and queue health |
GET |
/v1/models |
Local compatibility model |
POST |
/v1/chat/completions |
Wait for a buffer response; SSE supported |
GET/POST |
/v1/buffer |
Inspect or fulfill the pending queue |
GET |
/v1/pending |
Pending request metadata |
GET |
/v1/requests/latest |
Latest untouched request |
GET |
/v1/vision/schema |
Bundled observation schema |
GET/POST |
/v1/vision/observations |
Observation status or ingestion |
GET |
/v1/vision/observations/latest |
Latest accepted observation |
POST |
/v1/macro |
Replace the persistent Tasket .scht pointer or set it to off |
POST |
/v1/rgd1 ... /v1/rgd5 |
Replace one persistent Regedited command slot |
POST |
/v1/zuko |
Convert submitted text into %TEMP%\tempreg.txt, then optionally call Tasket |
POST |
/v1/iroh |
Run one Regedited slot, wrap the clipboard, then optionally call Tasket |
POST |
/v1/message |
Submit text/attachments; wait for a Markdown reply |
POST |
/v1/format |
Prettify model JSON, a message/content entry, SSE capture, or piped text |
GET/POST/DELETE |
/v1/file |
Inspect, stage, or clear one-use attachment paths |
GET/POST |
/v1/multichat |
Inspect preservation mode; 1 enables, 0 clears history and disables |
POST |
/v1/delimiter |
Set a literal output marker; 0 clears and disables capture |
GET/POST |
/v1/check |
Consume captured output, or extract it from piped text |
GET/POST |
/v1/requests/{requestId} |
Privately retrieve/reply to a waiting new message |
GET/POST |
/v1/jevset |
Draft/refine a native Jev framework; Y activates, N clears draft/history/activation. No picture, so noul/choice/score only - a picture belongs to the …image routes |
GET/POST |
/v1/jevsetimage |
The same conversation with a picture attached: the model is shown it, and the framework names the path you sent; box is available as a fourth type. A JSON body carrying questions is stored as your hand-edit with no model call |
POST |
/v1/jevask |
Evaluate one text/JSON state with the activated framework |
POST |
/v1/jevaskimage |
The same ask with the picture in the request: ?image= path/data URL, or posted bytes with ?state=; stateless, and it replaces the framework's picture for that call |
GET/POST |
/v1/bboxset |
Name the things to look for; refinements, Y agrees, N drops, an integer 1-8 sets how many entries one look checks |
GET/POST |
/v1/bboxask |
One picture (bytes, path, data URL or latest): one native request per agreed entry, coordinates per entry, plus the picture with the findings drawn on it and optional cut-outs |
GET/POST |
/v1/bboxcrop |
Cut-out bytes for ?top=&bottom=&left=&right= or ?boxes=, or those boxes drawn again over the picture; no plan, no model asked |
GET/POST |
/v1/cereal |
Programmatic raster-to-text; 1/2/3 select 32/128/256 detail; zero inference |
GET/POST |
/v1/ocr |
One-shot OCR; 0 selects Tesseract, 1 selects Paddle (startup default) |
Other common /v1 POST routes are logged compatibility stubs and return 501; the daemon does not falsely claim those capabilities.
See Markdown messages and pipes for curl examples, model-relay handoff, MIME handling, newline repair, sessions, delimiters, bounded retries, and lifecycle rules. These are additive: existing buffer, Zuko/Iroh, and vision clients keep their contracts. The daemon does not start an inference model or automatically click a continuation button.
See one-shot perception and Jev for NInfer configuration,
the image → cereal → Jev card pipeline, draft/activation rules and cold OCR setup.
These routes never consume /v1/file attachments or poll while idle.
uv sync --project optional_vision --extra all --group dev
uv run --project optional_vision buffer-vision doctor
uv run --project optional_vision buffer-vision observe --cv --output observation.json --overlay observation.png
uv run --project optional_vision buffer-vision observe --cv --postThe preference order is DOM, UI Automation, OCR, then generic CV geometry. See optional_vision/README.md and docs/ARCHITECTURE.md.
./scripts/Test-All.ps1This runs the native and headless compatibility benches. Desktop capture is opt-in with -CaptureDesktop.
These routes share one replaceable Regedited output file:
%TEMP%\tempreg.txt (Windows)
/tmp/tempreg.txt (Linux/macOS: Path.GetTempPath())
Every Zuko or Iroh call creates a blank canonical one-index Regedited document, then pipes the submitted or captured multiline text through rgd rs as i1z1. Regedited owns the final zone range and any relocation bookkeeping. The resulting text is available as:
rgd load $env:TEMP\tempreg.txt
rgd rg i1z1 --clipSet the Tasket macro pointer with a literal filename. Posting another filename replaces it persistently:
Invoke-RestMethod 'http://127.0.0.1:5087/v1/macro' -Method Post -ContentType 'text/plain' -Body 'something.scht'After Zuko or Iroh writes tempreg.txt, the daemon posts this saved filename to Tasket at http://127.0.0.1:7777/run.
The current macrohelp HTTPD authenticates that dispatch with an X-Tasket-Key header. This exists on Linux only: the Omarchy HTTPD infers its key from a server nonce and provisions it into its own env file; Windows Tasket builds still dispatch unauthenticated. The daemon resolves the key fresh on every dispatch, so restarting the HTTPD (which can re-provision the key) needs no daemon restart. Resolution order: the explicit Daemon:TasketApiKey setting (env override OPENAI_BUFFER_Daemon__TasketApiKey), then MACROHELP_API_KEY from a provisioned env file (${XDG_DATA_HOME:-~/.local/share}/macrohelp/http-daemon/.env, or %LOCALAPPDATA%\Macrohelp\http-daemon\.env if one is ever provisioned there), then no header at all, which keeps unauthenticated Tasket builds working.
To generate tempreg.txt without invoking Tasket, persist the literal value off:
Invoke-RestMethod 'http://127.0.0.1:5087/v1/macro' -Method Post -ContentType 'text/plain' -Body 'off'off affects only the final Tasket dispatch. Zuko and Iroh still create the template, populate it through rgd rs, and replace %TEMP%\tempreg.txt.
Send plain multiline Markdown to Zuko:
$text = @'
# Work item
Keep this multiline body exactly as written.
'@
Invoke-RestMethod 'http://127.0.0.1:5087/v1/zuko' -Method Post -ContentType 'text/plain' -Body $textZuko preserves the multiline Markdown apart from newline normalization. A JSON string or a JSON object containing content, text, or markdown is accepted as well.
Each numbered endpoint persistently stores one Regedited invocation beginning with rgd (arguments, not a shell pipeline):
Invoke-RestMethod 'http://127.0.0.1:5087/v1/rgd1' -Method Post -ContentType 'text/plain' -Body 'rgd rg C:\path\to\registry.txt i4z2 --clip'Use /v1/rgd2, /v1/rgd3, /v1/rgd4, and /v1/rgd5 identically. Posting a new command to a slot replaces only that slot. Commands may use any native Regedited operation, but the stored text must begin with rgd.
Posting its number to Iroh runs that saved command, reads the current clipboard, replaces %TEMP%\tempreg.txt with the clipboard as i1z1, and invokes the macro currently designated by /v1/macro:
Invoke-RestMethod 'http://127.0.0.1:5087/v1/iroh' -Method Post -ContentType 'text/plain' -Body '1'Iroh accepts only the literal selector 1, 2, 3, 4, or 5. The selected command is run first; the clipboard content present afterward becomes the complete i1z1 payload. With /v1/macro set to off, the same file is produced and Tasket is skipped.
If the chat request contains "stream": true, the daemon returns an SSE stream. While waiting, it emits SSE comments like : thinking 2026-... so compatible clients keep the connection alive without receiving fake assistant text. When /v1/buffer receives the response, the daemon sends the final content chunk and data: [DONE].
fbd mcp serves picture/Jev tools and fbd mcp ask serves the configurable buffer relay. See the MCP setup guide. Run sh scripts/integrate.sh to check the stdio MCP, daemon, and active model catalog; --mcp-only needs neither HTTP service. To register with OMP, preview with sh scripts/integrate.sh install --dry-run, then run sh scripts/integrate.sh install. Use status to inspect or uninstall to remove the entry. The Ask server can submit larger-model requests through Zuko, observe configured Regedited results, and recover the last temporary payload without becoming part of the daemon process.
- The daemon binds to
127.0.0.1by default and requires no API key. - Unsupported
/v1/*POST endpoints are logged and return a structured501JSON body. - Multimodal Chat Completions bodies are preserved exactly, including
image_urlcontent parts. - Vision producers remain separate from the daemon. See integrations/surfingkeys for the DOM producer and contracts/vision-observation.schema.json for the observation contract.
- The older
PiProxyVLLMproxy is reference material only; it is intentionally not bundled into this daemon.
AGPL-3.0-only. See LICENSE.
