Codex.Files (Codex SDK v0.7.2)

Copy Markdown View Source

Attachment staging helpers mirroring the Python SDK file APIs.

Summary

Functions

Attaches an Attachment to the supplied ThreadOptions.

Deprecated alias retained for backwards compatibility.

Removes staged files that are not marked as persistent.

Lists staged attachments currently cached.

Lists staged attachments with explicit success/error tuples.

Returns high-level staging metrics including counts and total bytes.

Resets the staging directory and manifest.

Stages a file for future attachment invocation.

Returns the staging directory path.

Functions

attach(opts, attachment)

Attaches an Attachment to the supplied ThreadOptions.

cleanup!()

@spec cleanup!() :: :ok | {:error, term()}

Deprecated alias retained for backwards compatibility.

force_cleanup()

@spec force_cleanup() :: :ok | {:error, term()}

Removes staged files that are not marked as persistent.

list_staged()

@spec list_staged() :: [Codex.Files.Attachment.t()]

Lists staged attachments currently cached.

list_staged_result()

@spec list_staged_result() :: {:ok, [Codex.Files.Attachment.t()]} | {:error, term()}

Lists staged attachments with explicit success/error tuples.

metrics()

@spec metrics() :: map() | {:error, term()}

Returns high-level staging metrics including counts and total bytes.

reset!()

@spec reset!() :: :ok | {:error, term()}

Resets the staging directory and manifest.

stage(path, opts \\ [])

@spec stage(
  Path.t(),
  keyword()
) :: {:ok, Codex.Files.Attachment.t()} | {:error, term()}

Stages a file for future attachment invocation.

Options:

  • :name - override the attachment name (defaults to the basename of path)
  • :persist - keep file around indefinitely (default: false)
  • :ttl_ms - custom time-to-live for ephemeral attachments. Accepts :infinity or a non-negative integer in milliseconds. Defaults to Application.get_env/3 lookups of :attachment_ttl_ms and falls back to 24 hours.

staging_dir()

@spec staging_dir() :: Path.t()

Returns the staging directory path.