Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

8.7 KB
Raw Blame

Pictures into the chat, generated files back out

  • Date: 2026-08-26
  • Type: feature
  • Scope: server, docs
  • PR: #496

中文版

A picture pasted into Feishu or Telegram now reaches the Agent instead of the "text only" notice, and a run's reply is followed into the chat by the files it named. Both directions run over the existing connector seam, so a third channel implements them the same way.

Inbound images

  • An inbound image becomes the same input the web composer submits: the caption (where the channel has one) as user text, then one image_url part per image carrying a base64 data: URL. A model without vision folds those into scratchpad files exactly as it does for a pasted image.
  • A caption counts as the message's text only for an actual PHOTO. Telegram attaches captions to documents, video and audio too, and none of those is delivered — a picture dragged in uncompressed arrives as a document — so running the model on the caption alone would have it answer confidently about a file it never received. Those keep getting the not-supported notice. A group's photo caption gets the same @mention stripping a text message does.
  • Feishu takes the image from the message's image_key through im.v1.messageResource.get; Telegram takes the largest variant of message.photo through getFile and the file endpoint, with message.caption as the message's text.
  • The connector seam carries images as lazily-fetched handles rather than bytes, so a redelivered message is dropped before anything is downloaded, and the size cap rides into the fetch — an oversize transfer is refused at the byte that crosses it instead of being buffered and measured afterwards.
  • The ceiling is the server's existing inline-image limit (INLINE_IMAGE_MAX_BYTES, 20MB), since these images land in the conversation and the Trace exactly as the composer's do; it also matches Telegram's own 20MB bot download limit.
  • In aggregate there is a second bound: a rolling per-binding byte budget (two full-size images per ten minutes). Per image the ceiling was always there; without a budget, anyone who can DM the bot could write a few hundred MB of base64 into one Session's Trace, which is read back whole into a single string on every history page and every resume. The composer reaches that ceiling only through an authenticated user; this path has no authentication at all. The overflow gets its own notice — nothing is wrong with the picture, there have just been too many.
  • An image that is too large, one past the budget and one the channel refuses answer with three different bilingual notices, and none of them starts a Task — a model asked about a picture it never received would answer confidently about nothing. A refusal the bot's own permissions caused names the scopes and carries the channel's own console link, so it is ten seconds of work rather than a log to go and read: on Feishu, receiving a message and downloading the files in it are separate permissions, and an app can have the first without the second.
  • The not-supported notice now names what is supported. Stickers, voice, video and files still get it; inbound files stay out of scope.

Outbound files

  • When a run ends, the files its reply MENTIONED AND THIS RUN PRODUCED follow the text into the chat: path-like tokens that resolve inside the Workspace, exist, and were written at or after the run started, wherever in the reply they appear — so what arrives is the output the Agent pointed at rather than everything the run happened to write. The Web App's file card reads inline code only, which is too strict for a chat, where a reply naming a file in an ordinary sentence would otherwise deliver nothing.
  • The modification time is not a nicety, it is what keeps the loose match safe. A reply is steerable by whoever is in the chat, and on a mention-only rule a group member who asks "what's in secrets.json?" gets the file uploaded by the very sentence that declined to paste it — the refusal becomes the disclosure. "Files this run wrote" is also what the feature always claimed to be.
  • ./chart.png and .eslintrc.json now resolve. The edge-punctuation trim stripped leading dots along with trailing ones, so the first became an absolute path outside the Workspace and the second a file that is not there — and "saved to ./out/report.pdf" is an entirely ordinary way for a reply to hand something over.
  • Images (.png/.jpg/.jpeg/.gif/.webp) are sent as pictures so a chart renders in the chat; everything else is sent as a file. The kind is decided by the file the read actually reached, not by the name the reply spelled: an in-Workspace report.png -> report.pdf (the everyday "latest" symlink) would otherwise be posted to the image endpoint named report.pdf, which Telegram rejects. Feishu uploads to im.v1.image.create / im.v1.file.create and sends the returned key; Telegram posts sendPhoto / sendDocument as multipart.
  • Path resolution, containment and existence come from the same WorkspaceFilesService the Files panel reads through — a path that leaves the Workspace, by .. or through a symlink, is refused there rather than by a second copy of the rules.
  • Caps: at most 5 files per run, at most 10MB per image and 30MB per file — the tighter of each channel's own limits (Feishu 10MB image / 30MB file, Telegram 10MB sendPhoto / 50MB sendDocument). A file a cap drops is named in the chat; a batch cut short says how many were left behind.
  • Every way a mentioned file does not arrive is now said in the chat: over a byte cap, past the count cap, no such file inside the Workspace, or an upload the channel refused — the last of which previously reached error_records and nowhere the person in the chat could look, so the feature simply appeared not to work. The one deliberate silence is a file the run did not write: a reply mentioning the config it read is the ordinary case, and announcing every one of those would bury the notices that matter.
  • Sends ride the same per-entry chain as the text, so files arrive after the reply that named them and in the order it named them; a failed upload is recorded as an error and does not stop the files behind it.

Why no Telegram upload ever left the process

  • sendPhoto / sendDocument posted the literal 17 bytes [object FormData] as text/plain, and the Bot API answered "there is no document in the request". The startup entry replaces globalThis.fetch with undici's so outbound traffic follows the proxy dispatcher; undici's fetch brand-checks a FormData body against its own class, and new FormData() is Node's built-in — a different class. The check failed and the body fell through to String(body).
  • The transport now imports fetch AND FormData from undici, as a matched pair, with a comment at the construction site saying why: importing only FormData from undici while calling globalThis.fetch inverts exactly the same bug. Proxy support is unchanged — undici's fetch resolves the global dispatcher per call, which is the contract net/proxy.ts is written against. Blob needs no change: globalThis.Blob IS node:buffer's Blob, and undici's FormData accepts it.
  • It failed 100% in production and 0% in CI, because installGlobalProxyDispatcher() runs only in the real server entry — in tests globalThis.fetch is still the runtime's own, and that pairing happens to work. So the guard is a test that drives the transport exactly as production builds it, points undici's global dispatcher at a local http.createServer, and asserts on the bytes that arrive: multipart/form-data, a document part, the file's name and its contents. Both realm mismatches turn it red.

Two Feishu failures the adapter could not report

  • A refusal to a streamed request arrives with the reason inside the response stream, unread: im.v1.messageResource.get is fetched as a stream, so on an error axios hands back the stream rather than a parsed {code, msg}, and reading it straight off yields "Request failed with status code 400" — the one thing the user cannot act on, hiding the one they can. The body is drained and parsed, and code, msg and log_id are reported the way the ordinary calls already report them.
  • Every call this adapter makes now has a deadline. The Lark SDK's default transport is a bare axios.create() with no timeout, and every outbound message of a Session goes out on one serial chain — so a request the API accepts and never answers parked every later reply, approval notice and file for that Session, silently, with no error record and no status change, until the binding was toggled or the server restarted. Telegram has had one on both directions since it landed.