import type { CompositeObserver } from "#src/observer"; import type { IdempotencyKey, MergeResult, SubagentRecord, SubagentStatus } from "#src/types"; export declare class DurableTracker { private cache; private idempotencyCache; /** In-flight merge promises keyed by agentId — used by get-result to await merge completion (F15). */ private mergePromises; private observer?; constructor(observer?: CompositeObserver); /** * Create a new task with status "pending". * Writes state BEFORE returning (caller should call start() to transition to running AFTER backend.start()). */ createTask(id: string, partial: Partial): SubagentRecord; /** * Transition a task to a new state with epoch validation. * Throws on invalid transition. */ transitionTo(id: string, newStatus: SubagentStatus): SubagentRecord | null; /** * Update a task from pending to running (after backend.start() succeeds). */ markRunning(id: string, recoveryId: string, pid: number): SubagentRecord | null; /** * Interrupt an agent — transition from running to interrupted. * Sets guardStopped and an optional reason. */ interruptAgent(id: string, reason?: string): SubagentRecord | null; /** * Resume an interrupted agent — special-case transition from * interrupted back to running. * Clears completedAt and increments epoch. */ resumeAgent(id: string): SubagentRecord | null; /** * Set result for a completed task. */ setResult(id: string, result: string): boolean; /** * Set error for a failed task. */ setError(id: string, error: string): boolean; /** * Set the result of a worktree auto-merge attempt. * No-op if the record doesn't exist. */ setMergeResult(id: string, result: MergeResult): boolean; setWorktreeContext(id: string, context: string): boolean; /** * Persist the stable tmux window ID captured atomically at window * creation (design D3). Construction-time metadata, not a lifecycle * decision — callable directly by the spawner, like `markRunning`. */ setWindowId(id: string, windowId: string): boolean; /** * Persist the per-parent tmux socket the agent's window was spawned on * (ADR 0003). Construction-time metadata like `setWindowId` — callable * directly by the spawner. */ setSocketPath(id: string, socketPath: string): boolean; /** * Record the latest context usage (tokens) sensed from session-file * analysis. Feeds the widget's health bar. In-memory only (no state write * per poll — this changes every few seconds and is reconstructible). */ setContextTokens(id: string, tokens: number, contextWindow?: number): boolean; /** * Record the latest observed turn count sensed from session-file analysis. * Feeds the widget's mana lane for harnesses whose turn count comes from * session-file parsing rather than per-turn status events (e.g. cmd). Not a * lifecycle transition — the single-transition-authority rule is untouched * (sibling of {@link setContextTokens}). In-memory only (reconstructible). */ setTurnCount(id: string, turns: number): boolean; /** * Record the tool the agent is most recently invoking, sensed from * session-file analysis. Feeds the widget's cast lane for harnesses WITHOUT * a live status stream (e.g. cmd); pi's `StatusPoller` owns `currentTool` * there. Not a lifecycle transition (sibling of {@link setTurnCount}). * In-memory only. Pass `undefined` to clear. */ setCurrentTool(id: string, tool: string | undefined): boolean; /** * Mark the agent's result as retrieved by the parent * (`get_subagent_result`). The widget uses this as the ACKNOWLEDGMENT that * releases a lingering failed/crashed frame (design D5). Idempotent. */ markResultRetrieved(id: string): boolean; /** * Count a `get_subagent_result` call against a still-pending/running agent * (poll-discipline capability). Returns the new count so the running-branch * message can surface it. Presentation/behavioral metadata only — no * lifecycle transition, and terminal-status calls never increment. */ incrementPollCount(id: string): number; /** Record a steer/threshold nudge for the steered debuff (short TTL). */ setLastSteeredAt(id: string): boolean; /** Record a resume-after-interrupt for the resumed debuff. */ setResumedAt(id: string): boolean; /** * Store a promise that resolves with the merge result for an agent. * Called by the spawner before the merge starts so that get-result * can await it if the agent completes before the merge finishes. */ setMergePromise(id: string, promise: Promise): void; /** * Get the in-flight merge promise for an agent, if any. * Returns undefined if no merge was pending for this agent. */ getMergePromise(id: string): Promise | undefined; get(id: string): SubagentRecord | undefined; getAll(): SubagentRecord[]; getAllIds(): string[]; get size(): number; /** * Load all persisted state from disk into memory. */ loadFromDisk(): void; /** * Remove a task's state from disk and cache. */ remove(id: string): boolean; /** * Clear all in-memory state (does not touch disk). */ clear(): void; /** * Check if an idempotency key has been seen and is still valid. */ isIdempotent(key: IdempotencyKey): boolean; /** * Store a completed idempotency key with its result. */ storeIdempotencyKey(key: IdempotencyKey, result: string): void; /** * Get the stored result for an idempotency key. */ getIdempotencyResult(key: IdempotencyKey): string | undefined; private getTaskDir; private writeState; private appendEvent; private sweepIdempotencyKeys; } export { DurableTracker as SubagentTracker }; //# sourceMappingURL=tracker.d.ts.map