Artifact Administration API
Use for explicit retained artifact editing, history/version navigation and server-controlled streaming. Ordinary generation uses durable runtime content/media jobs, shared budgets and version-bound suggestions. Private runtime file delivery uses immutable asset references and authenticated HTTP.
Usage boundary
Access the namespace on an explicitly configured root Cortex client. Host JWT and deployment-operator transports are distinct; validate current resource scope and do not infer authority from AuthContext metadata. See administrative operations.
Content, versions and streaming sessions
create requires memory space, title and content. Kind defaults to text and streaming state to draft; an artifact ID may be supplied or generated. Optional kind config, owner, tags, metadata and conversation/memory references describe the record. get returns null when absent. update writes content and a new version; metadata updates merge while supplied tags replace the prior tags. changeSummary and changedBy annotate version history.
getHistory returns ArtifactVersion[]; getVersion returns a retained version or null. Undo/redo report success, previous/current version and whether further undo/redo is available. Streaming mutations require the exact artifact/session identity: start establishes a session; append accepts chunks; pause/resume preserve state; cancel reports whether content was preserved; finalize creates the requested retained version and reports content length, bytes and duration. Do not append to a different or completed session.
import type { Cortex } from '@cortexmemory/sdk';
export async function saveApprovedArtifact(cortex: Cortex, memorySpaceId: string) {
const artifact = await cortex.artifacts.create({ memorySpaceId,
title: 'Delivery plan', content: 'Deliver on Tuesday.', kind: 'text' });
const updated = await cortex.artifacts.update(artifact.artifactId,
'Deliver on Wednesday.', { changeSummary: 'Confirmed new window', changedBy: 'user-123' });
const history = await cortex.artifacts.getHistory(updated.artifactId);
return { artifact: updated, history };
}
delete defaults to soft deletion; hard deletion reports the exact binary disposition and retained-version protection. detachFile reports whether bytes were actually deleted, protected or missing; a detached reference does not prove physical byte erasure. File upload/delivery helpers belong to the explicit compatibility record surface. Runtime apps use private assets and durable content/media jobs, including immutable input references, saved operation reconciliation and policy-controlled generation. Do not start a second artifact model loop in an application.
Parameter and result contracts
These are reference definitions for the explicit server APIs. Optional fields use ?; timestamps are milliseconds since epoch unless an operation accepts a Date. Resource identifiers and participant metadata do not grant runtime authority.
ArtifactKind
export type ArtifactKind =
| "text"
| "code"
| "sheet"
| "video"
| "image"
| "diagram"
| "html"
| "custom";
StreamingState
export type StreamingState =
| "draft"
| "streaming"
| "paused"
| "final"
| "error";
CreateArtifactOptions
export interface CreateArtifactOptions extends GraphSyncOption {
memorySpaceId: string;
title: string;
content: string;
kind?: ArtifactKind;
kindConfig?: ArtifactKindConfig;
streamingState?: StreamingState;
artifactId?: string;
tenantId?: string;
userId?: string;
agentId?: string;
participantId?: string;
description?: string;
metadata?: Record<string, unknown>;
tags?: string[];
conversationRef?: {
conversationId: string;
messageId?: string;
turnIndex?: number;
};
memoryRefs?: ArtifactMemoryRef[];
}
| Field | Meaning and defaults |
|---|---|
memorySpaceId | Memory space ID (required) |
title | Artifact title (required) |
content | Initial content (required) |
kind | Artifact kind (default: "text") |
kindConfig | Kind-specific configuration |
streamingState | Initial streaming state (default: "draft") |
artifactId | Custom artifact ID (auto-generated if not provided) |
tenantId | Multi-tenancy: SaaS platform isolation |
userId | User who owns this artifact |
agentId | Agent who owns this artifact |
participantId | Participant ID for Hive Mode tracking |
description | Brief description |
metadata | Custom metadata |
tags | Initial tags |
conversationRef | Reference to source conversation |
memoryRefs | References to source memories |
Also inherits GraphSyncOption. See shared contracts.
Artifact
export interface Artifact extends GraphCaptureMetadata {
_id: string;
artifactId: string;
memorySpaceId: string;
tenantId?: string;
userId?: string;
agentId?: string;
participantId?: string;
kind: ArtifactKind;
kindConfig?: ArtifactKindConfig;
content?: string;
fileRef?: ArtifactFileRef;
title: string;
description?: string;
tags: string[];
streamingState: StreamingState;
streamingMetadata?: StreamingMetadata;
version: number;
versionPointer: number;
versionHistory: ArtifactVersion[];
attachedFiles?: FileReference[];
conversationRef?: {
conversationId: string;
messageId?: string;
turnIndex?: number;
};
memoryRefs?: ArtifactMemoryRef[];
collaborators?: ArtifactCollaborator[];
stats?: ArtifactStats;
metadata?: Record<string, unknown>;
createdAt: number;
updatedAt: number;
lastAccessedAt?: number;
accessCount?: number;
isDeleted?: boolean;
deletedAt?: number;
deletedBy?: string;
}
| Field | Meaning and defaults |
|---|---|
_id | Convex document ID |
artifactId | Public artifact identifier |
memorySpaceId | Memory space this artifact belongs to |
tenantId | Multi-tenancy: SaaS platform isolation |
userId | User who owns this artifact |
agentId | Agent who owns this artifact |
participantId | Participant ID for Hive Mode tracking |
kind | Artifact kind for content type |
kindConfig | Kind-specific configuration |
content | Inline content (<1MB) |
fileRef | File reference for large content (>1MB) |
title | Display title |
description | Brief description |
tags | Tags for categorization |
streamingState | Streaming lifecycle state |
streamingMetadata | Streaming session metadata |
version | Current version number |
versionPointer | Active version pointer for undo/redo navigation |
versionHistory | Version history for undo/redo |
attachedFiles | Currently attached files |
conversationRef | Reference to source conversation |
memoryRefs | References to source memories |
collaborators | Collaborators for shared artifacts |
stats | Content statistics |
metadata | Custom metadata |
createdAt | When the artifact was created |
updatedAt | When the artifact was last updated |
lastAccessedAt | When the artifact was last accessed |
accessCount | Total access count |
isDeleted | Whether the artifact is deleted |
deletedAt | When the artifact was deleted |
deletedBy | Who deleted the artifact |
Also inherits GraphCaptureMetadata. See shared contracts.
UpdateArtifactOptions
export interface UpdateArtifactOptions extends GraphSyncOption {
title?: string;
kind?: ArtifactKind;
metadata?: Record<string, unknown>;
tags?: string[];
changeSummary?: string;
changedBy?: string;
}
| Field | Meaning and defaults |
|---|---|
title | Optional new title |
kind | Optional new kind |
metadata | Optional metadata updates (merged with existing) |
tags | Optional tag updates (replaces existing) |
changeSummary | Brief description of changes for version history |
changedBy | User or agent who made this change |
Also inherits GraphSyncOption. See shared contracts.
ListArtifactsFilter
export interface ListArtifactsFilter {
memorySpaceId: string;
tenantId?: string;
userId?: string;
agentId?: string;
participantId?: string;
kind?: ArtifactKind;
streamingState?: StreamingState;
tags?: string[];
tagMatch?: "any" | "all";
titleContains?: string;
createdAfter?: number;
createdBefore?: number;
updatedAfter?: number;
updatedBefore?: number;
limit?: number;
offset?: number;
sortBy?: "createdAt" | "updatedAt";
sortOrder?: "asc" | "desc";
includeDeleted?: boolean;
}
| Field | Meaning and defaults |
|---|---|
memorySpaceId | Memory space ID (required) |
tenantId | Filter by tenant ID |
userId | Filter by user ID |
agentId | Filter by agent ID |
participantId | Filter by participant ID |
kind | Filter by kind |
streamingState | Filter by streaming state |
tags | Filter by tags (any match) |
tagMatch | Tag match mode |
titleContains | Title search (contains, case-insensitive) |
createdAfter | Filter by creation date |
updatedAfter | Filter by update date |
limit | Result limit (default: 50, max: 1000) |
offset | Pagination offset |
sortBy | Sort field |
sortOrder | Sort direction |
includeDeleted | Include soft-deleted artifacts |
GetArtifactHistoryOptions
export interface GetArtifactHistoryOptions {
limit?: number;
offset?: number;
sortOrder?: "asc" | "desc";
}
| Field | Meaning and defaults |
|---|---|
limit | Limit number of versions returned |
offset | Pagination offset |
sortOrder | Sort order (asc = oldest first, desc = newest first) |
ArtifactVersion
export interface ArtifactVersion {
version: number;
content?: string;
fileRef?: ArtifactFileRef;
title?: string;
timestamp: number;
changedBy?: string;
changeType: "create" | "update" | "undo" | "redo";
changeSummary?: string;
}
| Field | Meaning and defaults |
|---|---|
version | Version number (1-based, auto-incremented) |
content | Content at this version (if inline) |
fileRef | File reference at this version (if stored in file storage) |
title | Title at this version |
timestamp | When this version was created |
changedBy | Who made this change (agentId or userId) |
changeType | Type of change |
changeSummary | Brief description of changes |
StartStreamingParams
export interface StartStreamingParams {
artifactId: string;
}
| Field | Meaning and defaults |
|---|---|
artifactId | Artifact ID to stream to |
AppendContentParams
export interface AppendContentParams {
artifactId: string;
sessionId: string;
chunk: string;
}
| Field | Meaning and defaults |
|---|---|
artifactId | Artifact ID |
sessionId | Session ID from startStreaming |
chunk | Content chunk to append |
StreamingSessionParams
export interface StreamingSessionParams {
artifactId: string;
sessionId: string;
}
| Field | Meaning and defaults |
|---|---|
artifactId | Artifact ID |
sessionId | Session ID from startStreaming |
FinalizeStreamingParams
export interface FinalizeStreamingParams {
artifactId: string;
sessionId: string;
changeSummary?: string;
}
| Field | Meaning and defaults |
|---|---|
artifactId | Artifact ID |
sessionId | Session ID from startStreaming |
changeSummary | Summary of the streaming session for version history |
DeleteArtifactResult
export interface DeleteArtifactResult {
binaryDispositions?: Array<{ storageId: string; disposition: BinaryDisposition }>;
deleted: boolean;
artifactId: string;
versionsPurged?: number;
filesDetached?: number;
}
| Field | Meaning and defaults |
|---|---|
binaryDispositions | Per-blob outcome; metadata deletion does not imply shared-byte erasure. |
deleted | Whether the artifact was deleted |
artifactId | ID of the deleted artifact |
versionsPurged | Number of versions purged (hard delete only) |
filesDetached | Number of files detached (hard delete only) |
BinaryDisposition
export type BinaryDisposition = "deleted" | "protected" | "missing";
Public methods
The following signatures describe the TypeScript namespace. Parameter and result fields are defined on this page; the installed @cortexmemory/sdk declarations also provide their compile-time types. Signatures are reference notation, not application code to execute.
create
Sync artifact to graph database (if configured) Update artifact in graph database Delete artifact from graph database Create a new artifact
cortex.artifacts.create(options: CreateArtifactOptions): Promise<Artifact>
get
Get an artifact by ID
cortex.artifacts.get(artifactId: string): Promise<Artifact | null>
update
Update an artifact's content (creates a new version)
cortex.artifacts.update(artifactId: string, content: string, options?: UpdateArtifactOptions): Promise<Artifact>
delete
Delete an artifact
cortex.artifacts.delete(artifactId: string, hard = false): Promise<DeleteArtifactResult>
list
List artifacts with filtering
cortex.artifacts.list(filter: ListArtifactsFilter): Promise<Artifact[]>
count
Count artifacts matching filter
cortex.artifacts.count(filter: CountArtifactsFilter): Promise<number>
undo
Undo the last change to an artifact
cortex.artifacts.undo(artifactId: string): Promise<{ success: boolean; artifactId: string; previousVersion: number; currentVersion: number; canUndo: boolean; canRedo: boolean; }>
redo
Redo a previously undone change
cortex.artifacts.redo(artifactId: string): Promise<{ success: boolean; artifactId: string; previousVersion: number; currentVersion: number; canUndo: boolean; canRedo: boolean; }>
getHistory
Get the version history of an artifact
cortex.artifacts.getHistory(artifactId: string, options?: GetArtifactHistoryOptions): Promise<ArtifactVersion[]>
getVersion
Get a specific version of an artifact
cortex.artifacts.getVersion(artifactId: string, version: number): Promise<ArtifactVersion | null>
startStreaming
Start a streaming session for an artifact
cortex.artifacts.startStreaming(params: StartStreamingParams): Promise<{ success: boolean; sessionId: string; artifactId: string; startedAt: number; previousState: StreamingState; currentState: StreamingState; }>
appendContent
Append a content chunk to a streaming artifact
cortex.artifacts.appendContent(params: AppendContentParams): Promise<{ success: boolean; artifactId: string; sessionId: string; chunkIndex?: number; chunkBytes: number; totalBytesReceived: number; contentLength: number; progress?: number; timestamp: number; }>
pauseStreaming
Pause an active streaming session
cortex.artifacts.pauseStreaming(params: StreamingSessionParams): Promise<{ success: boolean; artifactId: string; sessionId: string; pausedAt: number; previousState: string; currentState: string; bytesReceived: number; contentPreserved: boolean; }>
resumeStreaming
Resume a paused streaming session
cortex.artifacts.resumeStreaming(params: StreamingSessionParams): Promise<{ success: boolean; artifactId: string; sessionId: string; resumedAt: number; previousState: string; currentState: string; bytesReceived: number; }>
cancelStreaming
Cancel an active streaming session
cortex.artifacts.cancelStreaming(params: StreamingSessionParams): Promise<{ success: boolean; artifactId: string; sessionId: string; cancelledAt: number; previousState: StreamingState; currentState: string; contentPreserved: boolean; bytesReceived: number; contentLength: number; }>
finalizeStreaming
Finalize a streaming session
cortex.artifacts.finalizeStreaming(params: FinalizeStreamingParams): Promise<{ success: boolean; artifactId: string; sessionId: string; finalizedAt: number; previousState: string; currentState: string; contentLength: number; bytesReceived: number; totalDurationMs: number; versionCreated: boolean; version: number; }>
setStreamingState
Set the streaming state of an artifact
cortex.artifacts.setStreamingState(artifactId: string, streamingState: StreamingState): Promise<{ success: boolean; artifactId: string; previousState: StreamingState; currentState: StreamingState; updatedAt: number; }>
uploadFile
Asset upload and delivery require a qualified authenticated backend capability.
cortex.artifacts.uploadFile(params: { artifactId: string; file: Blob; filename: string; mimeType: string; metadata?: Record<string, unknown>; }): Promise<{ success: boolean; artifactId: string; fileRef: { storageId: string; mimeType: string; size: number; checksum?: string; originalFilename?: string; }; version: number; updatedAt: number; }>
getFileUrl
Asset upload and delivery require a qualified authenticated backend capability.
cortex.artifacts.getFileUrl(artifactId: string): Promise<string | null>
detachFile
Detach a file from an artifact
cortex.artifacts.detachFile(artifactId: string, deleteFile = false): Promise<{ success: boolean; artifactId: string; previousFileRef: { storageId: string; mimeType: string; size: number; originalFilename?: string; }; /** True only when bytes were removed; retained versions may protect them. */ fileDeleted: boolean; binaryDisposition?: "deleted" | "protected" | "missing"; version: number; updatedAt: number; }>
Errors and lifecycle
Validation, missing capability, authorization, stale version and partial/unknown committed outcomes are explicit. Inspect operation/write/deletion receipts before recovery; do not repeat an external effect under a new identity after uncertainty. Close owned clients and graph resources at the end of the server workflow.
See runtime client for ordinary app execution and error handling for recovery boundaries.