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 contentEach 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
| Field | Type | Description |
|---|---|---|
id | string | Unique artifact ID (art- + 8-char UUID fragment) |
title | string | Human-readable title |
workspaceId | string | Owning workspace |
mimeType | string | Always text/html for now |
version | number | Incremented on every update |
createdAt | string | ISO timestamp |
updatedAt | string | ISO timestamp |
ArtifactWithContent
ArtifactMeta extended with content: string (the raw HTML).
Methods
create(orgId, input)
Creates a new artifact:
- Generates an ID in the form
art-${randomUUID().slice(0, 8)}. - Writes
{artifactId}.htmlwith the provided content. - Appends the metadata to
index.json. - 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:
- Reads the existing artifact content.
- Creates a new entry under the target workspace directory.
- 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.