/** * Agent status file management and sibling folder helpers. * Spec: §5.5 — Per-Agent Status Files * Spec: §2.1 — Filesystem Layout */ import type { AgentStatusFile, AgentLifecycle } from "@pi-orca/core"; /** * Get the .orca sibling folder for a session directory. * Spec: §2.1 — session-sibling directory structure * * @param sessionPath - Path to session (relative to ~/.pi/agent/sessions/) * @returns Absolute path to .orca folder */ export declare function getOrcaSiblingDir(sessionPath: string): string; /** * Get the agents subdirectory within the .orca folder. * * @param sessionPath - Path to session * @returns Absolute path to .orca/agents/ folder */ export declare function getAgentStatusDir(sessionPath: string): string; /** * Get the path to an agent's status YAML file. * * @param sessionPath - Path to session * @param agentId - Agent ID * @returns Absolute path to agents/.yaml */ export declare function getAgentStatusPath(sessionPath: string, agentId: string): string; /** * Read a single agent status file. * * @param sessionPath - Path to session * @param agentId - Agent ID * @returns Parsed status or null if file doesn't exist */ export declare function readAgentStatus(sessionPath: string, agentId: string): Promise; /** * Write (or update) an agent status file atomically. * Spec: §3.1.1 — writes go through heartbeat.update() after spawn. * * @param sessionPath - Path to session * @param agentId - Agent ID * @param status - Status data to write */ export declare function writeAgentStatus(sessionPath: string, agentId: string, status: AgentStatusFile): Promise; /** * List all agent status files for a session. * * @param sessionPath - Path to session * @returns Array of (agentId, AgentStatusFile) tuples */ export declare function listAgentStatuses(sessionPath: string): Promise>; /** * Check if an agent status is in a terminal state. * * @param status - Agent status file * @returns True if status is completed, failed, orphaned, or abandoned */ export declare function isTerminalStatus(status: AgentStatusFile): boolean; /** * Check if an agent is still running. * * @param status - Agent status file * @returns True if status is running */ export declare function isRunningStatus(status: AgentStatusFile): boolean; /** * Final status-flush policy for operator-initiated /agents stop. * Called by SDK / RPC / tmux stop functions after abort+cleanup. * * The `wasIdle` snapshot must be taken BEFORE issuing abort so we can * tell idle-stop (→ completed) from mid-turn stop (→ failed/aborted), * since the child's own shutdown handler may have written failed/aborted * to disk by the time we get here. * * Preserves a genuine natural completion (completed/completed) if it * landed in the race window between snapshot and flush. */ export declare function flushStopTerminalStatus(parentSessionPath: string, agentId: string, opts: { wasIdle: boolean; resultFallback?: string; }): Promise; /** * Check if a persistent agent is between prompts. * * @param status - Agent status file * @returns True if status is idle */ export declare function isIdleStatus(status: AgentStatusFile): boolean; /** * Create an initial status file for a newly spawned agent. * Spec: §3.1.1a — initial population with status: "running" * * @param params - Initial status parameters * @returns New AgentStatusFile with status: "running" */ export declare function createInitialStatus(params: { agentId: string; templateName: string; sessionId: string; sessionPath: string; parentSessionId: string; parentSessionPath: string; rootSessionPath: string; pid?: number; isolation: "sdk" | "process" | "tmux"; lifecycle?: AgentLifecycle; model: string; context: "fresh" | "fork"; originalTask: string; spawnedAt: string; labels: Record; }): AgentStatusFile; /** * Get cost summary file path (parent-level aggregation). * Spec: §3.2.1a — cost-summary.yaml * * @param sessionPath - Parent session path * @returns Path to cost-summary.yaml */ export declare function getCostSummaryPath(sessionPath: string): string; /** * Read the cost summary. * * @param sessionPath - Parent session path * @returns Cost summary or null if doesn't exist */ export declare function readCostSummary(sessionPath: string): Promise<{ inputTokens: number; outputTokens: number; totalCost: number; updatedAt?: string; agentCount?: number; } | null>; /** * Write the cost summary atomically. * * @param sessionPath - Parent session path * @param summary - Cost summary data */ export declare function writeCostSummary(sessionPath: string, summary: { inputTokens: number; outputTokens: number; totalCost: number; updatedAt: string; agentCount: number; }): Promise; //# sourceMappingURL=status.d.ts.map