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:
1 parent
28568f0e89
commit
2f5b263d4e
11 files changed
+668
-15
No files matched your search
+2
-1
@@ -15,7 +15,7 @@ use std::sync::Arc;
|
||||
use super::anthropic::{self, AnthropicRequest, AnthropicStream};
|
||||
use super::service::ChatService;
|
||||
use super::types::{ApiErrorEnvelope, ChatRequest, ModelCard, ModelList};
|
||||
use super::{sessions, uploads, web};
|
||||
use super::{files, sessions, uploads, web};
|
||||
use crate::store::Store;
|
||||
|
||||
/// Build the router. Mount this inside any axum `Router` or serve it directly.
|
||||
@@ -81,6 +81,7 @@ fn build_router(state: AppState, auth: AuthConfig) -> Router {
|
||||
.route("/api/sessions/{id}/messages", get(sessions::get_messages))
|
||||
.route("/api/sessions/{id}/notepad", get(sessions::get_notepad))
|
||||
.route("/api/sessions/{id}/chat", post(sessions::session_chat))
|
||||
.route("/api/sessions/{id}/download", get(files::download))
|
||||
.route(
|
||||
"/api/uploads",
|
||||
// Uploads arrive as base64 JSON: a 32 MiB decoded file becomes
|
||||
|
||||
Reference in new issue
Block a user