Skip to main content

Module embedded_resource

Module embedded_resource 

Expand description

Materialize embedded resource.blob payloads into the session workspace. Store-agnostic: no RPC SessionStore / file/attach. Shared by ACP inbound and MCP tools/call postprocessing.

Structs§

EmbeddedResourceError
Error while decoding or persisting an embedded blob.
MaterializedResource
Result of writing an embedded resource into the session workspace.

Constants§

MAX_EMBEDDED_FILE_BYTES
Per-file decoded size limit for embedded blobs (matches RPC attach / ACP).

Functions§

content_hash_name
Content-addressed identity <sha256> / <sha256>.<ext> derived from raw bytes (the full hex SHA-256 digest). Shared by blob materialization and outbound delivery URIs so both use the same opaque, URI-safe, collision-resistant name — the identity is the full 256-bit digest and depends on content, never on a caller-supplied filename, so distinct content never aliases one name and reserved characters can’t leak.
decode_embedded_blob
Decode a base64 embedded blob and enforce the size cap, WITHOUT writing anything. Lets a caller validate every prompt part up front so an invalid later part cannot leave earlier parts already materialized on disk.
materialize_bytes
Persist already-read bytes as a content-addressed file under {workspace}/uploads/<sha16>.<safe-ext> and return where it landed. The on-disk name is the content hash (never a caller-supplied filename), the write is no-follow (symlinks at the destination are dropped, not followed), confinement is checked before the write and re-verified after it, and the input is size-capped. filename/mime are display metadata only. Used by both inbound blob intake and outbound deliver_file, so ACP consumers can read this workspace-internal, content-named copy rather than re-opening a caller-supplied path.
materialize_resource_blob
Decode blob_b64, enforce size limits, write under {workspace}/uploads/, and return a prompt marker ([Document: …] or [IMAGE:…]). Thin base64 front door over materialize_bytes.
persist_content_addressed
Persist bytes as a content-addressed file <sha256>.<safe-ext> under {workspace}/uploads/ and return its absolute on-disk path. This is the single hardened persistence substrate shared by ACP/MCP blob intake, outbound deliver_file, and the RPC attachment writer.