Sagents.FileSystem.FileMetadata (Sagents v0.4.2)

Copy Markdown

Metadata for a file entry in the virtual filesystem.

Since all content is text (for LLM work), mime_type typically indicates the format: text/plain, text/markdown, application/json, etc.

Summary

Functions

Creates a changeset for file metadata.

Creates new metadata for file content with optional custom attributes.

Updates metadata timestamps and checksum for modified content.

Types

t()

@type t() :: %Sagents.FileSystem.FileMetadata{
  checksum: String.t() | nil,
  created_at: DateTime.t() | nil,
  custom: map(),
  encoding: String.t(),
  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 with optional custom attributes.

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

Updates metadata timestamps and checksum for modified content.

Preserves existing metadata fields (custom, created_at, mime_type, encoding) and only updates content-related fields. Accepts optional opts to override specific fields (e.g. :custom, :mime_type).

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