/** * @fileoverview Canonical Agent type definitions for the Vorion Platform. * * This file provides the authoritative definitions for agent-related types, * unifying the various representations found across packages into a single * canonical source with Zod validation schemas. * * Agent types cover: * - Agent lifecycle status * - Runtime operational status * - Capabilities and permissions * - Configuration and settings * - Performance metrics * - Task management * * @module @vorionsys/contracts/canonical/agent */ import { z } from 'zod'; /** * Canonical agent lifecycle status. * * Represents the administrative/lifecycle state of an agent in the platform. * This is distinct from runtime operational status. * * States: * - `draft`: Initial creation, not yet deployed * - `training`: Undergoing training/certification * - `active`: Deployed and operational * - `suspended`: Temporarily disabled (can be reactivated) * - `archived`: Permanently deactivated (historical record) * * @example * ```typescript * const status: AgentLifecycleStatus = 'active'; * ``` */ export type AgentLifecycleStatus = 'draft' | 'training' | 'active' | 'suspended' | 'archived'; /** * Array of all lifecycle statuses in logical order. */ export declare const AGENT_LIFECYCLE_STATUSES: readonly AgentLifecycleStatus[]; /** * Human-readable labels for lifecycle statuses. */ export declare const AGENT_LIFECYCLE_LABELS: Readonly>; /** * Color codes for lifecycle statuses (for UI display). */ export declare const AGENT_LIFECYCLE_COLORS: Readonly>; /** * Zod schema for AgentLifecycleStatus validation. */ export declare const agentLifecycleStatusSchema: z.ZodEnum<["draft", "training", "active", "suspended", "archived"]>; /** * Canonical agent runtime operational status. * * Represents the current operational state of an agent during execution. * Used for real-time monitoring and coordination. * * States: * - `IDLE`: Ready and waiting for tasks * - `WORKING`: Actively processing a task * - `PAUSED`: Temporarily halted (can resume) * - `ERROR`: In error state requiring attention * - `OFFLINE`: Not connected/available * * @example * ```typescript * const status: AgentRuntimeStatus = 'WORKING'; * ``` */ export type AgentRuntimeStatus = 'IDLE' | 'WORKING' | 'PAUSED' | 'ERROR' | 'OFFLINE'; /** * Array of all runtime statuses. */ export declare const AGENT_RUNTIME_STATUSES: readonly AgentRuntimeStatus[]; /** * Human-readable labels for runtime statuses. */ export declare const AGENT_RUNTIME_LABELS: Readonly>; /** * Color codes for runtime statuses (for UI display). */ export declare const AGENT_RUNTIME_COLORS: Readonly>; /** * Zod schema for AgentRuntimeStatus validation. */ export declare const agentRuntimeStatusSchema: z.ZodEnum<["IDLE", "WORKING", "PAUSED", "ERROR", "OFFLINE"]>; /** * Canonical permission-based agent capability. * * Represents what actions an agent is authorized to perform. * Used for permission enforcement and delegation. * * Capabilities: * - `execute`: Can execute tasks locally * - `external`: Can make external API calls * - `delegate`: Can delegate tasks to other agents * - `spawn`: Can create/spawn new agents * - `admin`: Has administrative privileges * * @example * ```typescript * const caps: AgentPermission[] = ['execute', 'external']; * ``` */ export type AgentPermission = 'execute' | 'external' | 'delegate' | 'spawn' | 'admin'; /** * Array of all agent permissions. */ export declare const AGENT_PERMISSIONS: readonly AgentPermission[]; /** * Descriptions for each permission. */ export declare const AGENT_PERMISSION_DESCRIPTIONS: Readonly>; /** * Zod schema for AgentPermission validation. */ export declare const agentPermissionSchema: z.ZodEnum<["execute", "external", "delegate", "spawn", "admin"]>; /** * Collaboration mode types for agent interactions. */ export type CollaborationMode = 'DELEGATE' | 'CONSULT' | 'PARALLEL' | 'SEQUENTIAL' | 'CONSENSUS'; /** * Array of all collaboration modes. */ export declare const COLLABORATION_MODES: readonly CollaborationMode[]; /** * Zod schema for CollaborationMode validation. */ export declare const collaborationModeSchema: z.ZodEnum<["DELEGATE", "CONSULT", "PARALLEL", "SEQUENTIAL", "CONSENSUS"]>; /** * Extended agent capability definition with domain and skills. * * Provides detailed capability information for agent matching and routing. */ export interface AgentCapability { /** Primary domain of expertise (e.g., 'security', 'data-analysis') */ domain: string; /** Specific skills within the domain */ skills: string[]; /** Minimum trust score required to handle tasks in this domain (0-1000). This is a routing requirement, not a stored trust score on the agent identity. */ trustLevel: number; /** Autonomy level (0-7, maps to TrustBand) */ autonomyLevel: number; /** Preferred modes for collaboration */ collaborationPreference: CollaborationMode[]; } /** * Zod schema for AgentCapability validation. */ export declare const agentCapabilitySchema: z.ZodObject<{ domain: z.ZodString; skills: z.ZodArray; trustLevel: z.ZodNumber; autonomyLevel: z.ZodNumber; collaborationPreference: z.ZodArray, "many">; }, "strip", z.ZodTypeAny, { domain: string; skills: string[]; trustLevel: number; autonomyLevel: number; collaborationPreference: ("DELEGATE" | "CONSULT" | "PARALLEL" | "SEQUENTIAL" | "CONSENSUS")[]; }, { domain: string; skills: string[]; trustLevel: number; autonomyLevel: number; collaborationPreference: ("DELEGATE" | "CONSULT" | "PARALLEL" | "SEQUENTIAL" | "CONSENSUS")[]; }>; /** Inferred type from schema */ export type AgentCapabilityInput = z.input; /** * Agent specialization categories. * * Predefined categories for agent domain expertise. */ export type AgentSpecialization = 'core' | 'customer_service' | 'technical' | 'creative' | 'research' | 'education' | 'security' | 'data_analysis' | 'development' | 'operations'; /** * Array of all specializations. */ export declare const AGENT_SPECIALIZATIONS: readonly AgentSpecialization[]; /** * Human-readable labels for specializations. */ export declare const AGENT_SPECIALIZATION_LABELS: Readonly>; /** * Zod schema for AgentSpecialization validation. */ export declare const agentSpecializationSchema: z.ZodEnum<["core", "customer_service", "technical", "creative", "research", "education", "security", "data_analysis", "development", "operations"]>; /** * Runtime operational metrics for agent monitoring. * * Used for real-time health monitoring and load balancing. */ export interface AgentRuntimeMetrics { /** CPU usage percentage (0-100) */ cpuUsage?: number; /** Memory usage percentage (0-100) */ memoryUsage?: number; /** Number of tasks in queue */ taskQueue?: number; /** Number of currently active tasks */ activeTasks?: number; /** Uptime in milliseconds */ uptime?: number; /** Custom metrics for domain-specific monitoring */ customMetrics?: Record; } /** * Zod schema for AgentRuntimeMetrics validation. */ export declare const agentRuntimeMetricsSchema: z.ZodObject<{ cpuUsage: z.ZodOptional; memoryUsage: z.ZodOptional; taskQueue: z.ZodOptional; activeTasks: z.ZodOptional; uptime: z.ZodOptional; customMetrics: z.ZodOptional>; }, "strip", z.ZodTypeAny, { cpuUsage?: number | undefined; memoryUsage?: number | undefined; taskQueue?: number | undefined; activeTasks?: number | undefined; uptime?: number | undefined; customMetrics?: Record | undefined; }, { cpuUsage?: number | undefined; memoryUsage?: number | undefined; taskQueue?: number | undefined; activeTasks?: number | undefined; uptime?: number | undefined; customMetrics?: Record | undefined; }>; /** Inferred type from schema */ export type AgentRuntimeMetricsInput = z.input; /** * Performance metrics for agent quality assessment. * * Used for trust scoring, performance reviews, and optimization. */ export interface AgentPerformanceMetrics { /** Total number of tasks completed */ tasksCompleted: number; /** Total number of tasks that failed */ tasksFailed: number; /** Average quality score (0-1) */ averageQuality: number; /** Average response time in milliseconds */ averageResponseTime: number; /** User satisfaction score (0-1) */ userSatisfaction: number; /** Rate of escalations to higher authority (0-1) */ escalationRate: number; /** Collaboration effectiveness score (0-1) */ collaborationScore: number; } /** * Zod schema for AgentPerformanceMetrics validation. */ export declare const agentPerformanceMetricsSchema: z.ZodObject<{ tasksCompleted: z.ZodNumber; tasksFailed: z.ZodNumber; averageQuality: z.ZodNumber; averageResponseTime: z.ZodNumber; userSatisfaction: z.ZodNumber; escalationRate: z.ZodNumber; collaborationScore: z.ZodNumber; }, "strip", z.ZodTypeAny, { tasksCompleted: number; tasksFailed: number; averageQuality: number; averageResponseTime: number; userSatisfaction: number; escalationRate: number; collaborationScore: number; }, { tasksCompleted: number; tasksFailed: number; averageQuality: number; averageResponseTime: number; userSatisfaction: number; escalationRate: number; collaborationScore: number; }>; /** Inferred type from schema */ export type AgentPerformanceMetricsInput = z.input; /** * Task priority levels. */ export type TaskPriority = 'low' | 'medium' | 'high' | 'critical'; /** * Array of all task priorities in ascending order. */ export declare const TASK_PRIORITIES: readonly TaskPriority[]; /** * Zod schema for TaskPriority validation. */ export declare const taskPrioritySchema: z.ZodEnum<["low", "medium", "high", "critical"]>; /** * Task status values. */ export type TaskStatus = 'queued' | 'assigned' | 'active' | 'paused' | 'completed' | 'failed' | 'delegated' | 'cancelled'; /** * Array of all task statuses. */ export declare const TASK_STATUSES: readonly TaskStatus[]; /** * Zod schema for TaskStatus validation. */ export declare const taskStatusSchema: z.ZodEnum<["queued", "assigned", "active", "paused", "completed", "failed", "delegated", "cancelled"]>; /** * Task source indicating where the task originated. */ export type TaskSource = 'system' | 'user' | 'agent' | 'collaboration' | 'proactive' | 'scheduled'; /** * Array of all task sources. */ export declare const TASK_SOURCES: readonly TaskSource[]; /** * Zod schema for TaskSource validation. */ export declare const taskSourceSchema: z.ZodEnum<["system", "user", "agent", "collaboration", "proactive", "scheduled"]>; /** * Canonical agent task definition. * * Comprehensive task structure for agent workloads. */ export interface AgentTask { /** Unique task identifier */ id: string; /** Agent ID this task is assigned to */ agentId: string; /** Type/category of the task */ taskType: string; /** Human-readable title */ title?: string; /** Detailed description */ description: string; /** Task context and parameters */ context: Record; /** Priority level */ priority: TaskPriority; /** Current status */ status: TaskStatus; /** Origin of the task */ source: TaskSource; /** Reference ID for the source (e.g., user ID, agent ID) */ sourceId?: string; /** ID of agent/entity that assigned the task */ assignedBy?: string; /** ID of agent task was delegated to */ delegatedTo?: string; /** Scheduled execution time */ scheduledFor?: Date | string; /** Deadline for completion */ deadline?: Date | string; /** When the task started processing */ startedAt?: Date | string; /** When the task completed */ completedAt?: Date | string; /** Task creation timestamp */ createdAt: Date | string; /** Task input data */ input?: Record; /** Task output/result */ output?: Record; /** Error message if failed */ error?: string; /** Additional metadata */ metadata?: Record; } /** * Zod schema for AgentTask validation. */ export declare const agentTaskSchema: z.ZodObject<{ id: z.ZodString; agentId: z.ZodString; taskType: z.ZodString; title: z.ZodOptional; description: z.ZodString; context: z.ZodRecord; priority: z.ZodEnum<["low", "medium", "high", "critical"]>; status: z.ZodEnum<["queued", "assigned", "active", "paused", "completed", "failed", "delegated", "cancelled"]>; source: z.ZodEnum<["system", "user", "agent", "collaboration", "proactive", "scheduled"]>; sourceId: z.ZodOptional; assignedBy: z.ZodOptional; delegatedTo: z.ZodOptional; scheduledFor: z.ZodOptional>; deadline: z.ZodOptional>; startedAt: z.ZodOptional>; completedAt: z.ZodOptional>; createdAt: z.ZodUnion<[z.ZodDate, z.ZodString]>; input: z.ZodOptional>; output: z.ZodOptional>; error: z.ZodOptional; metadata: z.ZodOptional>; }, "strip", z.ZodTypeAny, { id: string; status: "active" | "completed" | "failed" | "queued" | "assigned" | "paused" | "delegated" | "cancelled"; createdAt: string | Date; description: string; agentId: string; taskType: string; context: Record; priority: "low" | "medium" | "high" | "critical"; source: "agent" | "system" | "user" | "collaboration" | "proactive" | "scheduled"; error?: string | undefined; metadata?: Record | undefined; title?: string | undefined; sourceId?: string | undefined; assignedBy?: string | undefined; delegatedTo?: string | undefined; scheduledFor?: string | Date | undefined; deadline?: string | Date | undefined; startedAt?: string | Date | undefined; completedAt?: string | Date | undefined; input?: Record | undefined; output?: Record | undefined; }, { id: string; status: "active" | "completed" | "failed" | "queued" | "assigned" | "paused" | "delegated" | "cancelled"; createdAt: string | Date; description: string; agentId: string; taskType: string; context: Record; priority: "low" | "medium" | "high" | "critical"; source: "agent" | "system" | "user" | "collaboration" | "proactive" | "scheduled"; error?: string | undefined; metadata?: Record | undefined; title?: string | undefined; sourceId?: string | undefined; assignedBy?: string | undefined; delegatedTo?: string | undefined; scheduledFor?: string | Date | undefined; deadline?: string | Date | undefined; startedAt?: string | Date | undefined; completedAt?: string | Date | undefined; input?: Record | undefined; output?: Record | undefined; }>; /** Inferred type from schema */ export type AgentTaskInput = z.input; /** * Agent persona/personality configuration. */ export interface AgentPersona { /** Display name */ displayName: string; /** Avatar URL */ avatar?: string; /** Communication/voice style descriptor */ voiceStyle?: string; /** Personality traits (e.g., 'professional', 'friendly') */ traits: string[]; /** Default greeting message */ greeting?: string; /** Default farewell message */ farewell?: string; /** Default error response */ errorResponse?: string; } /** * Zod schema for AgentPersona validation. */ export declare const agentPersonaSchema: z.ZodObject<{ displayName: z.ZodString; avatar: z.ZodOptional; voiceStyle: z.ZodOptional; traits: z.ZodArray; greeting: z.ZodOptional; farewell: z.ZodOptional; errorResponse: z.ZodOptional; }, "strip", z.ZodTypeAny, { displayName: string; traits: string[]; avatar?: string | undefined; voiceStyle?: string | undefined; greeting?: string | undefined; farewell?: string | undefined; errorResponse?: string | undefined; }, { displayName: string; traits: string[]; avatar?: string | undefined; voiceStyle?: string | undefined; greeting?: string | undefined; farewell?: string | undefined; errorResponse?: string | undefined; }>; /** Inferred type from schema */ export type AgentPersonaInput = z.input; /** * MCP (Model Context Protocol) server configuration. */ export interface MCPServerConfig { /** Server name/identifier */ name: string; /** Server URL */ url: string; /** Whether the server is enabled */ enabled: boolean; /** Minimum trust score required to use this server */ minTrustScore?: number; /** Server capabilities/features */ capabilities?: string[]; /** Additional configuration */ config?: Record; } /** * Zod schema for MCPServerConfig validation. */ export declare const mcpServerConfigSchema: z.ZodObject<{ name: z.ZodString; url: z.ZodString; enabled: z.ZodBoolean; minTrustScore: z.ZodOptional; capabilities: z.ZodOptional>; config: z.ZodOptional>; }, "strip", z.ZodTypeAny, { name: string; url: string; enabled: boolean; minTrustScore?: number | undefined; capabilities?: string[] | undefined; config?: Record | undefined; }, { name: string; url: string; enabled: boolean; minTrustScore?: number | undefined; capabilities?: string[] | undefined; config?: Record | undefined; }>; /** Inferred type from schema */ export type MCPServerConfigInput = z.input; /** * User role for permission context. */ export type UserRole = 'owner' | 'admin' | 'operator' | 'viewer' | 'both'; /** * Zod schema for UserRole validation. */ export declare const userRoleSchema: z.ZodEnum<["owner", "admin", "operator", "viewer", "both"]>; /** * Comprehensive agent configuration for runtime. * * This is the main configuration structure used when initializing * an agent for execution. */ export interface AgentConfig { /** Unique agent identifier */ agentId: string; /** Owner/user identifier */ userId: string; /** User's role/permissions */ userRole: UserRole; /** Agent lifecycle status */ status: AgentLifecycleStatus; /** Current trust score (0-1000) */ trustScore: number; /** Last activity timestamp */ lastActivity?: Date | string; /** Agent name */ name: string; /** Agent description */ description?: string; /** Domain specialization */ specialization?: AgentSpecialization | string; /** Personality traits */ personalityTraits?: string[]; /** Custom system prompt */ systemPrompt?: string; /** Enabled capabilities/skills */ capabilities: string[]; /** Agent permissions */ permissions?: AgentPermission[]; /** AI model identifier */ model?: string; /** Temperature for generation */ temperature?: number; /** Maximum tokens for responses */ maxTokens?: number; /** Configured MCP servers */ mcpServers?: MCPServerConfig[]; /** Environment variables */ environment?: Record; /** Current session identifier */ sessionId?: string; /** Current conversation identifier */ conversationId?: string; /** Message count in current session */ messageCount?: number; } /** * Zod schema for AgentConfig validation. */ export declare const agentConfigSchema: z.ZodObject<{ agentId: z.ZodString; userId: z.ZodString; userRole: z.ZodEnum<["owner", "admin", "operator", "viewer", "both"]>; status: z.ZodEnum<["draft", "training", "active", "suspended", "archived"]>; trustScore: z.ZodNumber; lastActivity: z.ZodOptional>; name: z.ZodString; description: z.ZodOptional; specialization: z.ZodOptional, z.ZodString]>>; personalityTraits: z.ZodOptional>; systemPrompt: z.ZodOptional; capabilities: z.ZodArray; permissions: z.ZodOptional, "many">>; model: z.ZodOptional; temperature: z.ZodOptional; maxTokens: z.ZodOptional; mcpServers: z.ZodOptional; capabilities: z.ZodOptional>; config: z.ZodOptional>; }, "strip", z.ZodTypeAny, { name: string; url: string; enabled: boolean; minTrustScore?: number | undefined; capabilities?: string[] | undefined; config?: Record | undefined; }, { name: string; url: string; enabled: boolean; minTrustScore?: number | undefined; capabilities?: string[] | undefined; config?: Record | undefined; }>, "many">>; environment: z.ZodOptional>; sessionId: z.ZodOptional; conversationId: z.ZodOptional; messageCount: z.ZodOptional; }, "strip", z.ZodTypeAny, { name: string; status: "active" | "draft" | "training" | "suspended" | "archived"; agentId: string; capabilities: string[]; userId: string; userRole: "operator" | "admin" | "owner" | "viewer" | "both"; trustScore: number; description?: string | undefined; lastActivity?: string | Date | undefined; specialization?: string | undefined; personalityTraits?: string[] | undefined; systemPrompt?: string | undefined; permissions?: ("execute" | "external" | "delegate" | "spawn" | "admin")[] | undefined; model?: string | undefined; temperature?: number | undefined; maxTokens?: number | undefined; mcpServers?: { name: string; url: string; enabled: boolean; minTrustScore?: number | undefined; capabilities?: string[] | undefined; config?: Record | undefined; }[] | undefined; environment?: Record | undefined; sessionId?: string | undefined; conversationId?: string | undefined; messageCount?: number | undefined; }, { name: string; status: "active" | "draft" | "training" | "suspended" | "archived"; agentId: string; capabilities: string[]; userId: string; userRole: "operator" | "admin" | "owner" | "viewer" | "both"; trustScore: number; description?: string | undefined; lastActivity?: string | Date | undefined; specialization?: string | undefined; personalityTraits?: string[] | undefined; systemPrompt?: string | undefined; permissions?: ("execute" | "external" | "delegate" | "spawn" | "admin")[] | undefined; model?: string | undefined; temperature?: number | undefined; maxTokens?: number | undefined; mcpServers?: { name: string; url: string; enabled: boolean; minTrustScore?: number | undefined; capabilities?: string[] | undefined; config?: Record | undefined; }[] | undefined; environment?: Record | undefined; sessionId?: string | undefined; conversationId?: string | undefined; messageCount?: number | undefined; }>; /** Inferred type from schema */ export type AgentConfigInput = z.input; /** * Type guard for AgentLifecycleStatus. */ export declare function isAgentLifecycleStatus(value: unknown): value is AgentLifecycleStatus; /** * Type guard for AgentRuntimeStatus. */ export declare function isAgentRuntimeStatus(value: unknown): value is AgentRuntimeStatus; /** * Type guard for AgentPermission. */ export declare function isAgentPermission(value: unknown): value is AgentPermission; /** * Type guard for AgentSpecialization. */ export declare function isAgentSpecialization(value: unknown): value is AgentSpecialization; /** * Type guard for TaskPriority. */ export declare function isTaskPriority(value: unknown): value is TaskPriority; /** * Type guard for TaskStatus. */ export declare function isTaskStatus(value: unknown): value is TaskStatus; /** * Type guard for TaskSource. */ export declare function isTaskSource(value: unknown): value is TaskSource; /** * Checks if an agent can transition to a new lifecycle status. * * Valid transitions: * - draft -> training, active * - training -> active, suspended, draft * - active -> suspended, archived * - suspended -> active, archived * - archived -> (no transitions allowed) * * @param current - Current lifecycle status * @param target - Target lifecycle status * @returns True if transition is valid */ export declare function canTransitionLifecycleStatus(current: AgentLifecycleStatus, target: AgentLifecycleStatus): boolean; /** * Converts runtime status to lifecycle status where applicable. * * @param runtimeStatus - Agent runtime status * @returns Corresponding lifecycle status or null if no direct mapping */ export declare function runtimeToLifecycleStatus(runtimeStatus: AgentRuntimeStatus): AgentLifecycleStatus | null; /** * Gets the numeric priority value for sorting. * * @param priority - Task priority * @returns Numeric value (0-3, higher = more urgent) */ export declare function getTaskPriorityValue(priority: TaskPriority): number; /** * Compares two task priorities. * * @param a - First priority * @param b - Second priority * @returns -1 if a < b, 0 if equal, 1 if a > b */ export declare function compareTaskPriorities(a: TaskPriority, b: TaskPriority): -1 | 0 | 1; /** * Maps legacy status strings to canonical AgentLifecycleStatus. * * @deprecated Use AgentLifecycleStatus directly. This is for migration only. */ export declare const LEGACY_STATUS_MAP: Readonly>; /** * Converts a legacy status string to canonical AgentLifecycleStatus. * * @deprecated Use AgentLifecycleStatus directly. This is for migration only. * @param legacyStatus - Legacy status string * @returns Canonical status or 'draft' if not recognized */ export declare function legacyToLifecycleStatus(legacyStatus: string): AgentLifecycleStatus; /** * Maps legacy AgentStatus from SDK (uppercase) to canonical types. * * @deprecated Use AgentRuntimeStatus directly. This is for migration only. */ export declare const LEGACY_RUNTIME_STATUS_MAP: Readonly>; /** * Converts a legacy runtime status to canonical AgentRuntimeStatus. * * @deprecated Use AgentRuntimeStatus directly. This is for migration only. * @param legacyStatus - Legacy status string * @returns Canonical runtime status or 'OFFLINE' if not recognized */ export declare function legacyToRuntimeStatus(legacyStatus: string): AgentRuntimeStatus;