import { type ChildProcess } from 'node:child_process'; import type { RuntimeAdapterResolver } from './runtime/composition/runtime-adapter-resolver.js'; import { type CliAdapter, type CliUsageSnapshot } from './cli-adapters/base.js'; import { CircuitBreaker } from './circuit-breaker.js'; import { type AwbConfig } from './rest.js'; import type { SubagentManager as SubagentManagerContract, SubagentSpawnArgs, SubagentSpawnResult } from './event-dispatcher.js'; import type { RunSessionBinding } from './base-session-manager.js'; import type { SubagentMonitor, SubagentTapHandle } from './subagent-monitor.js'; export declare function shouldEmitProgressHeartbeat(input: { count: number; lastEmitMs: number; now: number; isActionRoom: boolean; }): boolean; interface SpawnIdentityRecord { trigger_id?: string | null; chat_request_id?: string | null; ticket_id?: string | null; role?: string | null; agent_id?: string | null; } export declare function findDuplicateSpawn(records: Iterable, spec: { kind: 'trigger' | 'chat'; triggerId?: string; chatRequestId?: string; ticketId?: string; role?: string; agentId?: string; }): false | 'duplicate_trigger' | 'duplicate_chat'; export { mentionTriggerId } from './trigger-id.js'; export interface SubagentDelegationConfig { enabled?: boolean; maxConcurrent?: number; ttlMinutes?: number; claudeBin?: string; codexBin?: string; subagentProgressEscalationHours?: number; } export interface SubagentAwareConfig extends AwbConfig { delegation: SubagentDelegationConfig; } interface SubagentRecord { kind: 'trigger' | 'chat'; pid: number; cli_type: string; trigger_id: string | null; audit_session_id?: string; mention_audit_run_token?: string; silent_exit_attempt?: 0 | 1; silent_exit_terminal_reason?: string; silent_exit_family_key?: string; chat_request_id: string | null; ticket_id: string | null; agent_id: string | null; role: string | null; room_id: string | null; started_at: number; expected_completion_at: number; progressEscalatedAt?: number; config_path: string | null; config_path_is_temp: boolean; process_handle: ChildProcess | null; captureOutput: boolean; outLines: string[]; tailLines: string[]; commentSent: boolean; chatReplySent?: boolean; isActionRoom?: boolean; lastAssistantText?: string; tap: SubagentTapHandle | null; usage: CliUsageSnapshot | null; modelChain?: (string | null)[]; chainAttempt?: number; respawnSpec?: SubagentSpawnArgs; onSpawnExit?: () => void; run?: RunSessionBinding | null; stopReason?: string | null; } export interface SubagentExitInfo { pid: number; record: SubagentRecord; code: number | null; signal: NodeJS.Signals | null; durationSec: number; } export interface SubagentInflightWork { ticket_id: string | null; role: string | null; room_id: string | null; } export interface SubagentStopForAgentResult { count: number; inflight: SubagentInflightWork[]; } export declare class SubagentManager implements SubagentManagerContract { #private; readonly circuitBreaker: CircuitBreaker; onExit?: (info: SubagentExitInfo) => void; onHarnessSessionLimit: ((info: { agentId: string; ticketId: string; role: string; reason: string; resetLabel: string; deferUntilMs: number; }) => void) | null; constructor(config: SubagentAwareConfig, circuitBreaker?: CircuitBreaker, adapterResolver?: RuntimeAdapterResolver); setMonitor(monitor: SubagentMonitor | null): void; init(): Promise; get adapter(): CliAdapter; canSpawn(): boolean; spawn(spec: SubagentSpawnArgs): Promise; _handleOneshotExit(record: SubagentRecord, code: number | null): Promise; _sweepOneshotRunOrphans(record: SubagentRecord, runOverride?: RunSessionBinding | null): Promise; _runExitCompletionBackstop(record: SubagentRecord, code: number | null, runOverride?: RunSessionBinding | null): Promise; _scanForCommentTool(record: SubagentRecord, line: string): void; _captureAssistantText(record: SubagentRecord, line: string): void; _maybeEmitChatProgress(record: SubagentRecord, line: string): void; stopForAgent(agentId: string): Promise; stop(reason?: string): Promise; _snapshot(): any[]; _trackForTest(record: SubagentRecord): void; _sweepNow(): Promise; _wireStdioForTest(record: SubagentRecord): void; }