Repository navigation
Closed
Labels
enhancementNew feature or request
Description
What problem does this solve?
Image input exists in tole-core (#212: ImageRef, jailed load, run_turn_with_images), but tole serve has no way to use it:
POST /sessions/{id}/prompttakes{"text"}only. A graphical client cannot attach an image or paste one from the clipboard.- A transcript entry that carries
payload.images(path,mime,bytes,fnv1a64) cannot be rendered by a client: there is no route that returns the bytes, and a remote client (mobile, a browser) has no access to the server's filesystem anyway.
Every graphical client (#527 desktop, #528 mobile, #529 web) needs both, so the server side should land once, before any client starts.
Proposed solution
Three additive routes/fields, all behind the existing bearer token:
- Upload:
POST /sessions/{id}/imageswith the raw bytes as the body. The server sniffs the type (PNG, JPEG, GIF, WebP), enforces the existing 10 MiB cap, spills the file to the existing images directory through the sameresolvepath the CLI uses, and returns the reference (mime,bytes,fnv1a64, an opaque id). - Prompt:
POST /sessions/{id}/promptaccepts an optionalimages: [<ref id>]next totext. The turn records them as durable references exactly as--imagedoes (no blob in the log). Verify that the serve turn path can pass images through torun_turn_with_imagesand add the plumbing if it cannot. - Read:
GET /sessions/{id}/images/{fnv1a64}returns the bytes of an image that is recorded in that session's log, re-checking the jail and the hash like every provider request does. Anything not referenced by the session is a 404.
Limits and safety (this is the part that needs care, because a remote client can fill the disk):
- Upload body size limit equal to the image cap, counted inside the existing 32-connection cap.
- A per-session and a total quota on the spill directory, with a clear error when exceeded.
- Content type is always sniffed from the bytes, never trusted from the request; the read route serves a fixed
Content-Typefrom the recordedmimeplusX-Content-Type-Options: nosniff. - Image text is untrusted content from the model's point of view, as for
--imagetoday.
Open questions
- Raw body vs multipart for the upload (raw keeps the hand-rolled server simple).
- Whether to also accept an inline
data:URL in the prompt as a shortcut for small images (simple, but large JSON bodies). Check the server's current request body limit before deciding. - Whether uploaded-but-unused images are garbage collected, and when.
Alternatives considered
- Only an inline base64
imagesfield in the prompt: no extra route, but no way to render history, and large JSON bodies. - Serve files by path: rejected, remote clients have no shared filesystem and it widens the jail.
Acceptance criteria
- Upload, prompt-with-images and read work end to end in the serve test harness (real binary), including
resumeafter a restart. - A hash or jail mismatch is reported, never silently served.
- Oversized, wrong-type, over-quota and unauthenticated requests are refused with tests.
- No change to the
tole-corepublic API; documented indocs/mobile-control.md.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
feat(serve): image upload, prompt images and image read route (#558)
feat(serve): image upload, prompt images and image read route (#558) (#…