Agent Metadata API
This namespace manages registry metadata, configuration and explicit cascades. Executable Agent publication uses guarded agentDefinitions:publishVersion, pinned registry hashes/tools/context and policies. A metadata registration is not a published runtime Agent.
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.
Metadata registrations and executable definitions
register requires an ID/name and accepts description, tenant, metadata/config and optional memory space. It returns RegisteredAgent with registration status/timestamps. get returns null when absent; list/count filters select the registry; update changes registration metadata. These are metadata registry entries: an executable backend Agent is published through the administrator definition/registration workflow described in backend setup.
import type { Cortex } from '@cortexmemory/sdk';
export async function inspectApprovedRegistry(cortex: Cortex, agentId: string) {
const agent = await cortex.agents.get(agentId);
if (!agent) return null;
return agent;
}
unregister defaults to removing the registration only; dryRun previews that registry operation. cascade: true is retained in the options for compatibility but throws AgentRegistryCapabilityError with TRUSTED_BACKEND_CASCADE_REQUIRED before dispatch. Agent-wide child cleanup requires trusted backend execution with authorized coverage; participant IDs do not prove universal ownership. A successful registry-only result reports zero child-data counts. If a write commits without read permission to reveal its row, AgentRegistryWriteReceiptError reports AGENT_REGISTRY_WRITE_COMMITTED_READ_UNAVAILABLE, outcome: "committed", retryable: false and an acceptance receipt. Bulk deletion can similarly report AGENT_REGISTRY_COMMITTED_RESULT_UNAVAILABLE after a committed delete whose IDs cannot be disclosed. Do not retry these committed writes/deletes. Exports return selected metadata in JSON/CSV and reported counts; they do not export private model credentials or complete user ownership closures.
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.
AgentRegistration
export interface AgentRegistration {
memorySpaceId?: string;
id: string;
tenantId?: string;
name: string;
description?: string;
metadata?: Record<string, unknown>;
config?: Record<string, unknown>;
}
RegisteredAgent
export interface RegisteredAgent {
memorySpaceId?: string;
id: string;
tenantId?: string;
name: string;
description?: string;
metadata: Record<string, unknown>;
config: Record<string, unknown>;
status: "active" | "inactive" | "archived";
registeredAt: number;
updatedAt: number;
lastActive?: number;
stats?: AgentStats;
}
AgentFilters
export interface AgentFilters {
memorySpaceId?: string;
tenantId?: string;
metadata?: Record<string, unknown>;
name?: string;
capabilities?: string[];
capabilitiesMatch?: "any" | "all";
status?: "active" | "inactive" | "archived";
registeredAfter?: number;
registeredBefore?: number;
lastActiveAfter?: number;
lastActiveBefore?: number;
limit?: number;
offset?: number;
sortBy?: "name" | "registeredAt" | "lastActive";
sortOrder?: "asc" | "desc";
}
| Field | Meaning and defaults |
|---|---|
tenantId | Filter by tenant ID (database-level filter - safe to use with offset/limit) |
metadata | Filter by metadata key-value pairs (client-side filter - see pagination limitation) |
name | Filter by agent name, case-insensitive partial match (client-side filter - see pagination limitation) |
capabilities | Filter by capabilities (client-side filter - see pagination limitation) |
capabilitiesMatch | Match mode for capabilities: "any" (default) matches agents with at least one capability, "all" requires all capabilities |
status | Filter by agent status (database-level filter - safe to use with offset/limit) |
lastActiveAfter | Filter agents last active after this timestamp (client-side filter - see pagination limitation) |
lastActiveBefore | Filter agents last active before this timestamp (client-side filter - see pagination limitation) |
limit | Maximum number of results to return (applied at database level before client-side filters) |
offset | Number of results to skip (applied at database level before client-side filters). WARNING: Using offset with metadata, name, capabilities, or timestamp filters may produce unexpected results. See AgentFilters documentation for details. |
AgentStats
export interface AgentStats {
totalMemories: number;
totalConversations: number;
totalFacts: number;
memorySpacesActive: number;
lastActive?: number;
}
AgentRegistryScope
interface AgentRegistryScope { tenantId?: string; memorySpaceId?: string; }
Use the explicit domain selectors on get/configure/exists/unregister when required. They must agree with authenticated tenant authority.
UnregisterAgentOptions
export interface UnregisterAgentOptions {
cascade?: boolean;
verify?: boolean;
dryRun?: boolean;
}
| Field | Meaning and defaults |
|---|---|
cascade | Retained compatibility option, default false; true throws TRUSTED_BACKEND_CASCADE_REQUIRED. |
verify | Run verification after deletion (default: true) |
dryRun | Preview what would be deleted without actually deleting (default: false) |
UnregisterAgentResult
export interface UnregisterAgentResult {
agentId: string;
unregisteredAt: number;
conversationsDeleted: number;
conversationMessagesDeleted: number;
memoriesDeleted: number;
factsDeleted: number;
graphNodesDeleted?: number;
verification: {
complete: boolean;
issues: string[];
};
totalDeleted: number;
deletedLayers: string[];
memorySpacesAffected: string[];
}
ExportAgentsOptions
export interface ExportAgentsOptions {
filters?: AgentFilters;
format: "json" | "csv";
includeMetadata?: boolean;
includeStats?: boolean;
}
ExportAgentsResult
export interface ExportAgentsResult {
format: "json" | "csv";
data: string;
count: number;
exportedAt: number;
}
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.
register
Register an agent in the registry
cortex.agents.register(agent: AgentRegistration): Promise<RegisteredAgent>
get
Get agent registration by ID
cortex.agents.get(agentId: string, scope?: AgentRegistryScope): Promise<RegisteredAgent | null>
list
List agents with filters
cortex.agents.list(filters?: AgentFilters): Promise<RegisteredAgent[]>
search
Search agents (alias for list with filters)
cortex.agents.search(filters: AgentFilters): Promise<RegisteredAgent[]>
count
Count registered agents
cortex.agents.count(filters?: AgentFilters): Promise<number>
update
Update agent registration
cortex.agents.update(agentId: string, updates: Partial<AgentRegistration> & { status?: string }): Promise<RegisteredAgent>
configure
Configure agent settings
cortex.agents.configure(agentId: string, config: Record<string, unknown>, scope?: AgentRegistryScope): Promise<void>
exists
Check if agent is registered
cortex.agents.exists(agentId: string, scope?: AgentRegistryScope): Promise<boolean>
unregister
Unregister agent with optional cascade deletion by participantId
cortex.agents.unregister(agentId: string, options?: UnregisterAgentOptions & AgentRegistryScope): Promise<UnregisterAgentResult>
unregisterMany
Unregister multiple agents matching filters
cortex.agents.unregisterMany(filters: AgentFilters, options?: UnregisterAgentOptions): Promise<{ deleted: number; agentIds: string[]; totalDataDeleted?: number; }>
updateMany
Update multiple agents matching filters
cortex.agents.updateMany(filters: AgentFilters, updates: Partial<AgentRegistration>): Promise<{ updated: number; agentIds: string[] }>
export
Export registered agents matching filters
cortex.agents.export(options: ExportAgentsOptions): Promise<ExportAgentsResult>
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.