import { S as SessionId, M as Message, J as JsonValue, A as AgentId, T as Timestamp, a as MessageId, b as StreamConfig, U as UsageStats } from './streaming.d-Cj-pZLSI.js'; import { C as CollaborationConfig } from './common.d-iR60eBef.js'; /** * Agent type definitions for AI Kit * Comprehensive types for AI agents and multi-agent systems */ // ============================================================================ // Core Agent Types // ============================================================================ /** * Agent role/type */ type AgentRole = | 'assistant' | 'researcher' | 'analyst' | 'coder' | 'reviewer' | 'planner' | 'executor' | 'coordinator' | 'custom'; /** * Agent status */ type AgentStatus = | 'idle' | 'thinking' | 'working' | 'waiting' | 'paused' | 'error' | 'done'; /** * Agent capability */ interface AgentCapability { readonly name: string; readonly description: string; readonly enabled: boolean; readonly config?: Record; } /** * Agent configuration */ interface AgentConfig { readonly id?: AgentId; readonly name: string; readonly role: AgentRole; readonly description?: string; readonly systemPrompt?: string; readonly capabilities?: readonly AgentCapability[]; readonly tools?: readonly string[]; // Tool IDs readonly model?: string; readonly temperature?: number; readonly maxTokens?: number; readonly maxIterations?: number; readonly timeout?: number; // milliseconds readonly metadata?: Record; } /** * Agent context */ interface AgentContext { readonly sessionId: SessionId; readonly messages: readonly Message[]; readonly variables: Record; readonly state: AgentState; readonly history: readonly AgentAction[]; } /** * Agent state */ interface AgentState { readonly status: AgentStatus; readonly currentTask?: Task; readonly progress?: number; // 0-100 readonly iteration?: number; readonly startTime?: Timestamp; readonly endTime?: Timestamp; readonly error?: Error; readonly metadata?: Record; } /** * Agent action (for audit trail) */ interface AgentAction { readonly id: string; readonly agentId: AgentId; readonly type: AgentActionType; readonly timestamp: Timestamp; readonly input?: JsonValue; readonly output?: JsonValue; readonly duration?: number; // milliseconds readonly success: boolean; readonly error?: Error; readonly metadata?: Record; } /** * Agent action types */ type AgentActionType = | 'message' | 'tool_use' | 'decision' | 'delegation' | 'planning' | 'reflection' | 'memory_access' | 'custom'; // ============================================================================ // Tasks and Goals // ============================================================================ /** * Task priority */ type TaskPriority = 'low' | 'medium' | 'high' | 'critical'; /** * Task status */ type TaskStatus = | 'pending' | 'in_progress' | 'blocked' | 'completed' | 'failed' | 'cancelled'; /** * Task definition */ interface Task { readonly id: string; readonly title: string; readonly description?: string; readonly priority: TaskPriority; readonly status: TaskStatus; readonly assignedTo?: AgentId; readonly dependencies?: readonly string[]; // Task IDs readonly subtasks?: readonly Task[]; readonly deadline?: Timestamp; readonly estimatedDuration?: number; // milliseconds readonly actualDuration?: number; // milliseconds readonly startTime?: Timestamp; readonly endTime?: Timestamp; readonly result?: TaskResult; readonly metadata?: Record; } /** * Task result */ interface TaskResult { readonly success: boolean; readonly output?: JsonValue; readonly error?: Error; readonly artifacts?: readonly Artifact[]; readonly metrics?: TaskMetrics; } /** * Task metrics */ interface TaskMetrics { readonly duration: number; // milliseconds readonly iterations: number; readonly toolCalls: number; readonly tokensUsed: number; readonly cost?: number; } /** * Artifact produced by a task */ interface Artifact { readonly id: string; readonly type: string; readonly name: string; readonly data: JsonValue; readonly mimeType?: string; readonly size?: number; // bytes readonly createdAt: Timestamp; readonly metadata?: Record; } /** * Goal definition (higher-level than task) */ interface Goal { readonly id: string; readonly description: string; readonly success_criteria: readonly string[]; readonly tasks: readonly Task[]; readonly status: 'active' | 'achieved' | 'abandoned'; readonly priority: TaskPriority; readonly deadline?: Timestamp; readonly progress?: number; // 0-100 readonly metadata?: Record; } // ============================================================================ // Agent Communication // ============================================================================ /** * Message between agents */ interface AgentMessage { readonly id: MessageId; readonly from: AgentId; readonly to: AgentId | readonly AgentId[]; readonly type: AgentMessageType; readonly content: string | JsonValue; readonly timestamp: Timestamp; readonly replyTo?: MessageId; readonly priority?: TaskPriority; readonly metadata?: Record; } /** * Agent message types */ type AgentMessageType = | 'request' | 'response' | 'notification' | 'delegation' | 'query' | 'command' | 'broadcast'; /** * Agent communication protocol */ interface AgentProtocol { readonly name: string; readonly version: string; readonly messageFormat: 'json' | 'protobuf' | 'custom'; readonly transport: 'direct' | 'queue' | 'pubsub' | 'custom'; readonly reliability: 'at-most-once' | 'at-least-once' | 'exactly-once'; } // ============================================================================ // Multi-Agent Systems // ============================================================================ /** * Agent team configuration */ interface AgentTeam { readonly id: string; readonly name: string; readonly agents: readonly AgentId[]; readonly coordinator?: AgentId; readonly communicationProtocol?: AgentProtocol; readonly sharedContext?: Record; readonly metadata?: Record; } /** * Agent orchestration plan */ interface OrchestrationPlan { readonly id: string; readonly goal: Goal; readonly steps: readonly OrchestrationStep[]; readonly collaborationConfig: CollaborationConfig; readonly status: 'pending' | 'executing' | 'completed' | 'failed'; readonly startTime?: Timestamp; readonly endTime?: Timestamp; } /** * Orchestration step */ interface OrchestrationStep { readonly id: string; readonly type: 'task' | 'decision' | 'delegation' | 'sync'; readonly assignedTo?: AgentId | readonly AgentId[]; readonly task?: Task; readonly dependencies?: readonly string[]; // Step IDs readonly timeout?: number; readonly status: TaskStatus; } // ============================================================================ // Agent Decision Making // ============================================================================ /** * Decision point */ interface Decision { readonly id: string; readonly question: string; readonly options: readonly DecisionOption[]; readonly selectedOption?: string; readonly confidence?: number; // 0-1 readonly reasoning?: string; readonly timestamp: Timestamp; readonly agentId: AgentId; } /** * Decision option */ interface DecisionOption { readonly id: string; readonly label: string; readonly description?: string; readonly score?: number; readonly pros?: readonly string[]; readonly cons?: readonly string[]; readonly metadata?: Record; } /** * Decision strategy */ type DecisionStrategy = | 'greedy' // Choose highest scored option | 'random' // Random selection | 'epsilon-greedy' // Explore vs exploit | 'unanimous' // All agents must agree | 'majority' // Majority vote | 'weighted' // Weighted voting | 'custom'; // ============================================================================ // Agent Planning // ============================================================================ /** * Planning strategy */ type PlanningStrategy = | 'forward' // Forward chaining | 'backward' // Backward chaining (goal-driven) | 'hierarchical' // Hierarchical task network | 'reactive' // React to environment | 'deliberative' // Think then act | 'hybrid'; // Mix of reactive and deliberative /** * Plan */ interface Plan { readonly id: string; readonly goal: string; readonly strategy: PlanningStrategy; readonly steps: readonly PlanStep[]; readonly alternatives?: readonly Plan[]; readonly estimatedCost?: number; readonly estimatedDuration?: number; // milliseconds readonly confidence?: number; // 0-1 readonly metadata?: Record; } /** * Plan step */ interface PlanStep { readonly id: string; readonly action: string; readonly description?: string; readonly preconditions?: readonly string[]; readonly effects?: readonly string[]; readonly cost?: number; readonly duration?: number; // milliseconds readonly alternatives?: readonly PlanStep[]; } /** * Learning experience */ interface Experience { readonly id: string; readonly state: JsonValue; readonly action: JsonValue; readonly reward: number; readonly nextState: JsonValue; readonly done: boolean; readonly timestamp: Timestamp; readonly metadata?: Record; } // ============================================================================ // Agent Memory // ============================================================================ /** * Agent memory types */ type MemoryType = 'episodic' | 'semantic' | 'procedural' | 'working'; /** * Memory entry */ interface MemoryEntry { readonly id: string; readonly type: MemoryType; readonly content: JsonValue; readonly importance: number; // 0-1 readonly accessCount: number; readonly createdAt: Timestamp; readonly lastAccessedAt?: Timestamp; readonly expiresAt?: Timestamp; readonly metadata?: Record; } // ============================================================================ // Agent Reflection and Self-Improvement // ============================================================================ /** * Reflection result */ interface Reflection { readonly id: string; readonly trigger: 'periodic' | 'error' | 'completion' | 'manual'; readonly focus: 'performance' | 'strategy' | 'learning' | 'general'; readonly insights: readonly string[]; readonly improvements: readonly Improvement[]; readonly timestamp: Timestamp; readonly agentId: AgentId; } /** * Proposed improvement */ interface Improvement { readonly id: string; readonly category: 'process' | 'strategy' | 'communication' | 'learning'; readonly description: string; readonly expectedImpact: 'low' | 'medium' | 'high'; readonly implemented: boolean; readonly metadata?: Record; } // ============================================================================ // Agent Execution // ============================================================================ /** * Agent execution options */ interface AgentExecutionOptions { readonly sessionId?: SessionId; readonly context?: Partial; readonly streamConfig?: StreamConfig; readonly timeout?: number; // milliseconds readonly maxIterations?: number; readonly tools?: readonly string[]; readonly callbacks?: AgentCallbacks; readonly metadata?: Record; } /** * Agent callbacks */ interface AgentCallbacks { readonly onStateChange?: (state: AgentState) => void | Promise; readonly onAction?: (action: AgentAction) => void | Promise; readonly onDecision?: (decision: Decision) => void | Promise; readonly onTaskStart?: (task: Task) => void | Promise; readonly onTaskComplete?: (task: Task, result: TaskResult) => void | Promise; readonly onError?: (error: Error) => void | Promise; readonly onMessage?: (message: AgentMessage) => void | Promise; } /** * Agent execution result */ interface AgentExecutionResult { readonly success: boolean; readonly output?: JsonValue; readonly messages: readonly Message[]; readonly actions: readonly AgentAction[]; readonly usage: UsageStats; readonly duration: number; // milliseconds readonly error?: Error; readonly artifacts?: readonly Artifact[]; readonly metadata?: Record; } // ============================================================================ // Agent Interface // ============================================================================ /** * Core agent interface */ interface Agent { readonly id: AgentId; readonly config: AgentConfig; readonly state: AgentState; // Execution execute(input: string, options?: AgentExecutionOptions): Promise; executeTask(task: Task, options?: AgentExecutionOptions): Promise; // Communication sendMessage(message: Omit): Promise; receiveMessage(message: AgentMessage): Promise; // State management getState(): AgentState; updateState(updates: Partial): void; reset(): void; // Memory remember(entry: Omit): Promise; recall(query: string, type?: MemoryType): Promise; forget(entryId: string): Promise; // Planning plan(goal: string, strategy?: PlanningStrategy): Promise; // Reflection reflect(focus?: Reflection['focus']): Promise; // Lifecycle start(): Promise; stop(): Promise; pause(): void; resume(): void; } /** * Agent factory function type */ type AgentFactory = (config: AgentConfig) => Promise | Agent; export type { AgentContext as A, AgentFactory as B, Decision as D, Experience as E, Goal as G, Improvement as I, MemoryType as M, OrchestrationPlan as O, PlanningStrategy as P, Reflection as R, TaskPriority as T, AgentRole as a, AgentStatus as b, AgentCapability as c, AgentConfig as d, AgentState as e, AgentAction as f, AgentActionType as g, TaskStatus as h, Task as i, TaskResult as j, TaskMetrics as k, Artifact as l, AgentMessage as m, AgentMessageType as n, AgentProtocol as o, AgentTeam as p, OrchestrationStep as q, DecisionOption as r, DecisionStrategy as s, Plan as t, PlanStep as u, MemoryEntry as v, AgentExecutionOptions as w, AgentCallbacks as x, AgentExecutionResult as y, Agent as z };