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§
- Embedded
Resource Error - Error while decoding or persisting an embedded blob.
- Materialized
Resource - 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
bytesas 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/mimeare display metadata only. Used by both inbound blob intake and outbounddeliver_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 overmaterialize_bytes. - persist_
content_ addressed - Persist
bytesas 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, outbounddeliver_file, and the RPC attachment writer.