Sagents.FileSystem.FileMetadata (Sagents v0.8.0-rc.6)

Copy Markdown

Metadata for a file entry in the virtual filesystem.

Tracks size, timestamps, checksum, and mime_type. The mime_type field exists so multi-modal LLMs and downstream tools can route binary content (PDFs, images) correctly even when the path extension is ambiguous or absent.

Summary

Functions

Creates a changeset for file metadata.

Creates new metadata for file content.

Updates metadata timestamps and checksum for modified content.

Types

t()

@type t() :: %Sagents.FileSystem.FileMetadata{
  checksum: String.t() | nil,
  created_at: DateTime.t() | nil,
  mime_type: String.t(),
  modified_at: DateTime.t() | nil,
  size: integer() | nil
}

Functions

changeset(metadata \\ %FileMetadata{}, attrs)

Creates a changeset for file metadata.

new(content, opts \\ [])

Creates new metadata for file content.

Accepts optional :mime_type to override the default "text/markdown".

update_for_modification(metadata, new_content, opts \\ [])

Updates metadata timestamps and checksum for modified content.

Preserves existing metadata fields (created_at, mime_type) and only updates content-related fields. Accepts an optional :mime_type opt to override that field.

Returns {:ok, metadata} or {:error, changeset}.