Skip to main content

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[];
}
FieldMeaning and defaults
memorySpaceIdMemory space ID (required)
titleArtifact title (required)
contentInitial content (required)
kindArtifact kind (default: "text")
kindConfigKind-specific configuration
streamingStateInitial streaming state (default: "draft")
artifactIdCustom artifact ID (auto-generated if not provided)
tenantIdMulti-tenancy: SaaS platform isolation
userIdUser who owns this artifact
agentIdAgent who owns this artifact
participantIdParticipant ID for Hive Mode tracking
descriptionBrief description
metadataCustom metadata
tagsInitial tags
conversationRefReference to source conversation
memoryRefsReferences 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;
}
FieldMeaning and defaults
_idConvex document ID
artifactIdPublic artifact identifier
memorySpaceIdMemory space this artifact belongs to
tenantIdMulti-tenancy: SaaS platform isolation
userIdUser who owns this artifact
agentIdAgent who owns this artifact
participantIdParticipant ID for Hive Mode tracking
kindArtifact kind for content type
kindConfigKind-specific configuration
contentInline content (<1MB)
fileRefFile reference for large content (>1MB)
titleDisplay title
descriptionBrief description
tagsTags for categorization
streamingStateStreaming lifecycle state
streamingMetadataStreaming session metadata
versionCurrent version number
versionPointerActive version pointer for undo/redo navigation
versionHistoryVersion history for undo/redo
attachedFilesCurrently attached files
conversationRefReference to source conversation
memoryRefsReferences to source memories
collaboratorsCollaborators for shared artifacts
statsContent statistics
metadataCustom metadata
createdAtWhen the artifact was created
updatedAtWhen the artifact was last updated
lastAccessedAtWhen the artifact was last accessed
accessCountTotal access count
isDeletedWhether the artifact is deleted
deletedAtWhen the artifact was deleted
deletedByWho 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;
}
FieldMeaning and defaults
titleOptional new title
kindOptional new kind
metadataOptional metadata updates (merged with existing)
tagsOptional tag updates (replaces existing)
changeSummaryBrief description of changes for version history
changedByUser 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;
}
FieldMeaning and defaults
memorySpaceIdMemory space ID (required)
tenantIdFilter by tenant ID
userIdFilter by user ID
agentIdFilter by agent ID
participantIdFilter by participant ID
kindFilter by kind
streamingStateFilter by streaming state
tagsFilter by tags (any match)
tagMatchTag match mode
titleContainsTitle search (contains, case-insensitive)
createdAfterFilter by creation date
updatedAfterFilter by update date
limitResult limit (default: 50, max: 1000)
offsetPagination offset
sortBySort field
sortOrderSort direction
includeDeletedInclude soft-deleted artifacts

GetArtifactHistoryOptions​

export interface GetArtifactHistoryOptions {
limit?: number;
offset?: number;
sortOrder?: "asc" | "desc";
}
FieldMeaning and defaults
limitLimit number of versions returned
offsetPagination offset
sortOrderSort 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;
}
FieldMeaning and defaults
versionVersion number (1-based, auto-incremented)
contentContent at this version (if inline)
fileRefFile reference at this version (if stored in file storage)
titleTitle at this version
timestampWhen this version was created
changedByWho made this change (agentId or userId)
changeTypeType of change
changeSummaryBrief description of changes

StartStreamingParams​

export interface StartStreamingParams {
artifactId: string;
}
FieldMeaning and defaults
artifactIdArtifact ID to stream to

AppendContentParams​

export interface AppendContentParams {
artifactId: string;
sessionId: string;
chunk: string;
}
FieldMeaning and defaults
artifactIdArtifact ID
sessionIdSession ID from startStreaming
chunkContent chunk to append

StreamingSessionParams​

export interface StreamingSessionParams {
artifactId: string;
sessionId: string;
}
FieldMeaning and defaults
artifactIdArtifact ID
sessionIdSession ID from startStreaming

FinalizeStreamingParams​

export interface FinalizeStreamingParams {
artifactId: string;
sessionId: string;
changeSummary?: string;
}
FieldMeaning and defaults
artifactIdArtifact ID
sessionIdSession ID from startStreaming
changeSummarySummary 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;
}
FieldMeaning and defaults
binaryDispositionsPer-blob outcome; metadata deletion does not imply shared-byte erasure.
deletedWhether the artifact was deleted
artifactIdID of the deleted artifact
versionsPurgedNumber of versions purged (hard delete only)
filesDetachedNumber 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.