SuperPi.Artifacts (super_pi v0.1.0)

Copy Markdown View Source

Explicit storage for files that an agent wants to keep.

A scratch workspace disappears when its task ends or its node fails. An artifact does not: it is stored by name in the database, scoped to one conversation, and survives restarts and failover. The agent uses three tools:

ToolPurpose
artifact_putSave text (content) or a workspace file (path) under name. A second put replaces it.
artifact_getReturn an artifact, or write it to a workspace file (to_path).
artifact_listList the artifacts of the conversation.

The backend is SuperPi.Artifacts.Store. The default stores blobs in the repo (SuperPi.Artifacts.Ecto: PostgreSQL, or SQLite on a single node). Another backend (for example an S3-compatible bucket) implements the behaviour and is set with config :super_pi, artifact_store: MyStore.

Limits: artifact_max_bytes per artifact (default 10 MiB) and artifact_max_count per conversation (default 200). Names are A-Z a-z 0-9 . _ - /, up to 200 characters, with no .. segment and no leading slash.

Summary

Types

result()

@type result() :: {:ok, term()} | {:error, term()}

Functions

delete(conversation_id, name)

@spec delete(integer(), String.t()) :: :ok | {:error, term()}

get(conversation_id, name)

@spec get(integer(), String.t()) :: result()

list(conversation_id)

@spec list(integer()) :: [map()]

max_bytes()

max_count()

put(conversation_id, name, data, content_type \\ "application/octet-stream")

@spec put(integer(), String.t(), binary(), String.t()) :: result()

store()

tool_names()

tool_specs()

Tool specifications for the three artifact tools.

valid_name?(name)

@spec valid_name?(term()) :: boolean()

Validates an artifact name.