Skip to content

API Reference parrot.storage.exports

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.storage.exports

View source

Tenant-partitioned file exports (PA-12): what a Studio export tool writes, and who may download it.

Keys are {tenant}/{agent}/{export_id}/{filename}, built from the SERVER-bound tool scope — never from anything the LLM or the client chose — and every segment is validated (no separators, no .., no control characters), so a key can never address another partition. A file is readable only through :meth:ArtifactStore.get_export with the caller's own tenant (anything else is None: the download route answers 404, never 403), only until its TTL (STUDIO_ARTIFACT_TTL_SECONDS, default 7 days) and is refused at write time above STUDIO_ARTIFACT_MAX_BYTES (default 50 MB).

Attribute DEFAULT_MAX_BYTES

Attribute DEFAULT_TTL_SECONDS

Attribute DEFAULT_URL_BASE

Attribute EXPORT_PREFIX

Class ExportError

Base of the export store refusals.

Class ExportRef

What a tool returns to the LLM about a stored export.

Parameter Type Default Description
key str
url str
filename str
bytes int
content_type str
expires_at float

Fields:

Field Type Default Description
key str
url str
filename str
bytes int
content_type str
expires_at float

Method ExportRef.public

{url, filename, bytes}: all the LLM (and the user) need.

public() -> dict[str, Any]

Returns: dict[str, Any]

Class ExportTooLarge

The file is above STUDIO_ARTIFACT_MAX_BYTES.

Class InvalidExportKey

A key segment that could address another partition or path (.., separators, control characters…).

Attribute NO_TENANT

Attribute STUDIO_EXPORTS_URL_BASE_KEY

Function build_export_key

{tenant}/{agent}/{export_id}/{filename} from validated parts.

build_export_key(tenant: str | None, agent: str | None, export_id: str, filename: str) -> str

Parameter Type Default Description
tenant str | None
agent str | None
export_id str
filename str

Returns: str

Function export_url_base

The URL prefix of the download route for the CURRENT request (app[STUDIO_EXPORTS_URL_BASE_KEY], a host prefix may carry {tenant}-style placeholders resolved from the request's route); the default otherwise.

export_url_base() -> str

Returns: str

Function guess_content_type

Content type by extension (application/octet-stream when unknown).

guess_content_type(filename: str) -> str

Parameter Type Default Description
filename str

Returns: str

Function max_bytes

STUDIO_ARTIFACT_MAX_BYTES (a positive integer; the default when unset or malformed).

max_bytes() -> int

Returns: int

Function parse_export_key

(tenant, agent, export_id, filename) of a key; :class:InvalidExportKey for anything crafted.

parse_export_key(key: str) -> tuple[str, str, str, str]

Parameter Type Default Description
key str

Returns: tuple[str, str, str, str]

Function partition_segment

A validated key segment; :class:InvalidExportKey otherwise.

An empty tenant is :data:NO_TENANT; a caller-supplied tenant that IS the marker is refused (it would read the untenanted partition), while the marker inside an already-built key (from_key) is the partition itself.

partition_segment(value: str | None, *, what: str, from_key: bool = False) -> str

Parameter Type Default Description
value str | None
what str
from_key bool False

Returns: str

Function safe_filename

The base name of name with every path part and unsafe character removed (never empty, never hidden).

safe_filename(name: str) -> str

Parameter Type Default Description
name str

Returns: str

Function ttl_seconds

STUDIO_ARTIFACT_TTL_SECONDS (a positive integer; the default when unset or malformed).

ttl_seconds() -> int

Returns: int

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally