agent: share_file tool + containment-checked download endpoint

The agent can hand the user a same-origin download link for a file on its
filesystem (outbound complement to uploads). share_file(path, name?) returns a
Markdown link the GUI renders as a download chip.

Safety is containment, not trust: a shared path must canonicalize inside the
session personal folder or the shared uploads/ dir (.. and symlink escapes
refused), regular files only, 64 MiB cap. GET /api/sessions/{id}/download
re-validates independently (author != verifier), forces attachment +
application/octet-stream + nosniff, bare 400 out-of-bounds, 404 unknown session.

TOOL_USE seed migration appends the share_file manual without clobbering
user-edited rows. README documents the tool surface, endpoint and boundary;
Status refreshed to the verified 191 passed / 3 ignored.
This commit is contained in:
adm committed 2026-11-29 01:23:18 +01:00
1 parent 28568f0e89
commit 2f5b263d4e
11 files changed
+668 -15

No files matched your search

+10
View File
@@ -169,6 +169,16 @@ body.resizing { cursor: col-resize; user-select: none; }
.content.rendered li > ul, .content.rendered li > ol { margin: 0.2em 0; }
.content.rendered a { color: var(--accent); text-decoration: none; }
.content.rendered a:hover { text-decoration: underline; }
/* Agent-shared download links read as a distinct chip; the server already forces
Content-Disposition: attachment, so clicking downloads rather than navigates. */
.content.rendered a.download-link {
display: inline-flex; align-items: center; gap: 6px;
padding: 3px 10px; margin: 2px 0;
background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
color: var(--accent); font-size: 0.85rem; text-decoration: none;
}
.content.rendered a.download-link::before { content: "\2B07"; font-size: 0.9em; }
.content.rendered a.download-link:hover { border-color: var(--accent); text-decoration: none; }
.content.rendered blockquote {
margin: 0 0 0.6em; padding: 0.2em 0 0.2em 0.9em;
border-left: 3px solid var(--border); color: var(--muted);