Skip to main content
Hugs
A hug’s page has no network. Files go in as attachments, come back through upload slots, and everything is read, uploaded and downloaded through the host, with the viewer’s permissions.

Attachments: files the page shows

The agent uploads workspace files and passes them with the ask:
  • ctx.attach(paths) takes paths or globs inside the workspace, with an optional label — at most 25 files of 25 MB each. A file that can’t be attached (no match, too large, outside the workspace) is logged and left out.
  • Each attachment is { artifact_id, name, size, content_type, sha256 }. Pass the artifact_ids in the params, so the page knows which file is which.
  • On a resume (wait: 'yield'), don’t attach again: ctx.hug.resumed().length > 0.
In the page, hug.attachments lists them:
To use the bytes yourself:
compare-versions reads two text files this way and shows images with file_url; image-markup draws on an image loaded with file_url. read_file works for an attachment, the viewer’s own uploads, and — in view mode — the files in the answer being shown. At most 10 reads at once and 50 MB per page.

Upload slots: files people send

A file() field in the definition is an upload slot:
In the page, <cliq-file key="evidence"> does the whole thing. By hand:
upload rejects with a HugError — upload_cancelled, file_too_large, file_type, upload_failed. The file is checked against the slot by the host and again by CliqHub (by declared type, extension and first bytes). In the agent, the answer holds the reference, not the bytes:
A later phase can save every file people sent with cliq hug files (Asking people).

Downloads

The host saves the file for the person — the frame can’t download by itself. <cliq-attachment> has a Download button.
Opens in a new tab. A URL that appears in the Hug’s params opens at once; any other is shown to the person first, so a page can’t send people somewhere unexpected. Only http and https.