/** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */ /** * Agents domain state, tracks all spawned agent sessions including * subagents, WRFC chain agents, and orchestrator agents. */ import type { AgentUsage } from '../../../../events/agents.js'; /** States for the agent lifecycle machine. */ export type AgentLifecycleState = 'spawning' | 'running' | 'awaiting_message' | 'awaiting_tool' | 'finalizing' | 'completed' | 'failed' | 'cancelled'; /** Classification of the agent's role. */ export type AgentRole = 'orchestrator' | 'engineer' | 'reviewer' | 'fixer' | 'integrator' | 'gatekeeper' | 'subagent' | 'background'; /** A WRFC chain reference for agent grouping. */ export interface AgentWrfcRef { /** ID of the WRFC chain this agent belongs to. */ chainId: string; /** The agent's role within that chain. */ chainRole: 'owner' | 'orchestrator' | 'engineer' | 'reviewer' | 'fixer' | 'integrator' | 'verifier'; /** Stable phase order for display: owner=0, engineer=1, reviewer=2, fixer=3, verifier=4. */ phaseOrder?: number | undefined; } /** * Full runtime agent record. Every spawned agent has one of these. */ export interface RuntimeAgent { /** Unique agent ID. */ id: string; /** Human-readable label for display. */ label: string; /** Agent role classification. */ role: AgentRole; /** Current lifecycle state. */ status: AgentLifecycleState; /** Provider the agent is running on. */ providerId: string; /** Model ID the agent is using. */ modelId: string; /** ID of the parent agent that spawned this one (undefined = root). */ parentAgentId?: string | undefined; /** IDs of agents spawned by this agent. */ childAgentIds: string[]; /** WRFC chain reference if this agent is part of a WRFC workflow. */ wrfcRef?: AgentWrfcRef | undefined; /** Task ID this agent is executing (from tasks domain). */ taskId?: string | undefined; /** Path to the agent's session file. */ sessionFile?: string | undefined; /** Number of turns completed by this agent. */ turnCount: number; /** Number of tool calls made by this agent. */ toolCallCount: number; /** * Accumulated token usage for this agent's run. Undefined means no usage * data has landed yet, never fabricated as zeros (honest-UX: an agent * that hasn't reported usage is distinct from one that used zero tokens). */ usage?: AgentUsage | undefined; /** Latest accumulated output from the agent (for live display). */ latestOutput: string; /** Latest progress string emitted by the agent. */ latestProgress?: string | undefined; /** Epoch ms when the agent was spawned. */ spawnedAt: number; /** Epoch ms when the agent completed/failed/cancelled. */ endedAt?: number | undefined; /** Final result payload from the agent (populated on completion). */ result?: unknown | undefined; /** Error message if status === 'failed'. */ error?: string | undefined; /** Correlation ID for tracing across agent boundaries. */ correlationId?: string | undefined; } /** * AgentDomainState, all spawned agents across all subsystems. */ export interface AgentDomainState { /** Monotonic revision counter; increments on every mutation. */ revision: number; /** Timestamp of last mutation (Date.now()). */ lastUpdatedAt: number; /** Subsystem that triggered the last mutation. */ source: string; /** All known agents keyed by agent ID. */ agents: Map; /** IDs of currently active (non-terminal) agents. */ activeAgentIds: string[]; /** Total agents spawned this session. */ totalSpawned: number; /** Total agents that completed successfully. */ totalCompleted: number; /** Total agents that failed. */ totalFailed: number; /** Maximum concurrent agents this session. */ peakConcurrency: number; } /** * Returns the default initial state for the agents domain. */ export declare function createInitialAgentsState(): AgentDomainState; //# sourceMappingURL=agents.d.ts.map