Cosmo Docs
Desktop App

ArtifactManager

Local HTML artifact file storage

packages/desktop/src/main/artifact-manager.ts provides file-based persistence for HTML artifacts — generated documents, dashboards, reports, and other rich content produced by the AI.

Storage Layout

Artifacts live under the app's userData directory:

userData/
└── cosmo-data/
    └── artifacts/
        └── {orgId}/
            └── {workspaceId}/
                ├── index.json           ← Metadata index
                └── {artifactId}.html    ← Artifact content

Each org+workspace combination gets its own directory. The index.json file holds an array of ArtifactMeta objects; the .html files hold the raw content.

Types

ArtifactMeta

FieldTypeDescription
idstringUnique artifact ID (art- + 8-char UUID fragment)
titlestringHuman-readable title
workspaceIdstringOwning workspace
mimeTypestringAlways text/html for now
versionnumberIncremented on every update
createdAtstringISO timestamp
updatedAtstringISO timestamp

ArtifactWithContent

ArtifactMeta extended with content: string (the raw HTML).

Methods

create(orgId, input)

Creates a new artifact:

  1. Generates an ID in the form art-${randomUUID().slice(0, 8)}.
  2. Writes {artifactId}.html with the provided content.
  3. Appends the metadata to index.json.
  4. Returns the new ArtifactMeta.

Input fields: workspaceId, title, content, mimeType?.

read(orgId, artifactId)

Reads {artifactId}.html from disk and returns ArtifactWithContent, or null if the artifact does not exist.

update(orgId, artifactId, input)

Overwrites the .html file with new content and bumps version + updatedAt in the index. Returns the updated ArtifactMeta.

list(orgId, workspaceId)

Returns all ArtifactMeta entries for the given workspace from index.json. Returns an empty array if the workspace has no artifacts yet.

delete(orgId, artifactId)

Removes the .html file and the metadata entry from index.json.

move(orgId, artifactId, targetWorkspaceId)

Moves an artifact to a different workspace:

  1. Reads the existing artifact content.
  2. Creates a new entry under the target workspace directory.
  3. Deletes the old file and metadata entry.

Events

When the AI creates a new artifact via the create_artifact tool delegate, ChatManager calls create() and then emits artifacts:created with the artifactId to the renderer. HubPanel listens for this event and auto-navigates to the artifact viewer.