import type { AgentSessionRunner } from './agent-session-runner.js'; import type { AwbConfig } from './rest.js'; import type { RunSessionBinding } from './base-session-manager.js'; import type { ManagedAgentContextRegistry } from './managed-agent-context.js'; import type { WorktreeManager, WorktreeMode } from './worktree-manager.js'; import type { ChatReplyMode } from './prompts.js'; import { DispatchBlockTracker, InflightDispatchTracker } from './dispatch-preflight.js'; import type { RetryScheduler } from './dispatch-preflight.js'; import { SessionLimitDeferStore } from './session-limit-defer.js'; import type { HarnessSpec, RuntimeProfileSpec, ResolvedEffortPreset } from './cli-adapters/base.js'; import type { AgentRuntimeConfig } from './runtime/runtime-types.js'; import type { RuntimeSupervisor } from './runtime/runtime-supervisor.js'; interface ResolvedEnvironmentConfig { repositories: Array<{ resource_id?: string; url: string; target_dir: string; branch: string; post_clone_commands: string[]; }>; env_vars: Record; setup_commands: string[]; setup_timeout_seconds: number; version: number; } export declare function ordinaryWorkBoardsForChat(config: AwbConfig, usesNativeMcp: boolean, isActionRoom: boolean): Promise; export declare function parseHarnessConfig(raw: unknown): HarnessSpec | null; export declare function parseRuntimeProfile(raw: unknown): RuntimeProfileSpec | null; export declare function resolveTriggerRuntimeProfile(rawCliRuntimeProfile: unknown, instanceOverride: RuntimeProfileSpec | null | undefined): RuntimeProfileSpec | null; export declare function resolveRoomBroadcastRuntimeProfile(payload: any, responderAgentId: string, instanceOverride: RuntimeProfileSpec | null | undefined): RuntimeProfileSpec | null; export declare const PI_TICKET_DISPATCH_BLOCK_REASON = "pi_ticket_mcp_unsupported"; export declare const PI_TICKET_DISPATCH_BLOCK_COMMENT: string; export declare function parseEffortPreset(raw: unknown): ResolvedEffortPreset | null; export declare function parseEnvironmentConfig(raw: unknown): ResolvedEnvironmentConfig | null; export declare function resolveBootstrapRepository(baseRepo: unknown, baseBranch: unknown, environment: ResolvedEnvironmentConfig | null): { resourceId: string; url: string; branch: string; defaultBranch: string | null; } | null; export declare function parseWorktreeMode(raw: unknown): WorktreeMode | undefined; export declare function buildDispatchEnvVars(boardEnv: Record | null | undefined, cwd: string | undefined, worktreeMode: WorktreeMode | undefined, ticketId: unknown): Record; export declare function validateWorktreeProvisioningInputs(args: { mode: WorktreeMode | undefined; hasAgentContext: boolean; hasManager: boolean; ticketId?: string; role?: string; repositoryResourceId?: string; }): string | null; export declare const AGENT_CHAIN_DEPTH_CAP = 3; export interface AgentExecutionContext { agent_id: string; workspace_id: string; api_key: string; cwd: string; mcp_config_path: string; cli: string; cli_home_dir: string; extra_env?: Record; credential_provider?: string | null; credential_id?: string | null; model?: string | null; runtime_config?: AgentRuntimeConfig | null; } export interface SubagentSpawnArgs { kind: 'trigger' | 'chat'; taskText: string; rolePrompt: string; triggerId?: string; chatRequestId?: string; ticketId: string; agentId: string; role?: string; triggerSource?: string; _silentExitAttempt?: 0 | 1; roomId?: string; isActionRoom?: boolean; agentContext?: AgentExecutionContext; harness?: HarnessSpec | null; runtimeProfile?: RuntimeProfileSpec | null; effortPreset?: ResolvedEffortPreset | null; ttlMinutes?: number; envVars?: Record; _modelChain?: (string | null)[]; _chainAttempt?: number; onExit?: () => void; run?: RunSessionBinding; circuitBreakerDecision?: string | null; } export interface SubagentSpawnResult { spawned: boolean; pid?: number; reason?: string; detail?: string; serverKey?: string; } export interface SubagentManager { canSpawn(): boolean; spawn(args: SubagentSpawnArgs): Promise; } export interface ChatDispatchArgs { roomId: string; agentId: string; senderId: string; senderName: string; messageId?: string; createdAt: string; content: string; rolePrompt: string; roomName?: string; isActionRoom?: boolean; provisionedWorkFolder?: string; onProgress?: (stage: string) => void; agentContext?: AgentExecutionContext; runtimeProfile?: RuntimeProfileSpec | null; attachments?: any[]; run?: RunSessionBinding; onExit?: () => void; } export interface ChatDispatchResult { dispatched: boolean; pid?: number; firstTurn?: boolean; reason?: string; } export interface ChatSessionManager { dispatch(args: ChatDispatchArgs): Promise; recordRoomMessage(payload: any): void; } export interface ColumnPrompt { name?: string; content?: string; } export interface TicketTriggerArgs { ticketId: string; role: string; triggerId: string; agentId: string; rolePrompt: string; ticketPrompt: string; columnPrompt: ColumnPrompt | null; ticket: any; forceRespawn: boolean; triggerSource?: string; agentContext?: AgentExecutionContext; maxConcurrentTicketsPerAgent?: number; harness?: HarnessSpec | null; runtimeProfile?: RuntimeProfileSpec | null; effortPreset?: ResolvedEffortPreset | null; envVars?: Record; worktreeInstructions?: string; dispatchReserved?: boolean; } export interface DispatchReservation { acquired: boolean; live: boolean; evicted?: 'stale' | 'safety_valve' | 'dead_pid'; nonce?: string; } export interface TicketDispatchResult { dispatched: boolean; pid?: number; firstTurn?: boolean; reason?: string; } export interface TicketSessionManager { dispatchTrigger(args: TicketTriggerArgs): Promise; tryReserveDispatch?(ticketId: string, role: string, agentId: string): DispatchReservation; releaseDispatch?(ticketId: string, role: string, agentId: string, nonce?: string): void; attachDispatchPid?(ticketId: string, role: string, agentId: string, nonce: string | undefined, pid: number): void; forwardCommentMention(ticketId: string, mention: any, targetAgentId?: string): boolean; forwardBoardUpdate(ticketId: string, ev: any): boolean; hasInflightOrLiveDispatch?(ticketId: string, role: string, agentId: string): boolean; } export type DispatchSeatKind = 'authoritative' | 'fallback'; export interface DispatchSeat { transferred: boolean; release: () => void; promote: (pid: number) => void; } export interface CreateDispatchSeatArgs { kind: DispatchSeatKind; ticketId: string; role: string; agentId: string; nonce?: string; tsm?: TicketSessionManager | null; inflightDispatch: InflightDispatchTracker; inflightKey?: string | null; onReleased?: () => void; } export declare function createDispatchSeat(args: CreateDispatchSeatArgs): DispatchSeat; export interface FsBrowserResult { ok: boolean; error?: string; code?: string; [key: string]: any; } export interface FsBrowser { handle(args: { op: string; path: string; offset?: number; limit?: number; name?: string; }): Promise; } export interface PromptComposer { composeTriggerPrompt(ticket: any, rolePrompt: string, ticketPrompt: string, ticketId: string, columnPrompt: ColumnPrompt | null, extraInstructions?: string | null): string; composeChatPrompt(rolePrompt: string, history: any[], newMessage: string, roomId?: string, usesNativeMcp?: ChatReplyMode, workFolder?: string): string; composeChatRoomPrompt(roomId: string, history: any[], msg: { content: string; sender_name: string; sender_id: string; }, attachments?: any[], usesNativeMcp?: ChatReplyMode, historyAttachments?: Map, roomName?: string, isActionRoom?: boolean, workFolder?: string, ordinaryWorkBoards?: Array<{ id: string; name: string; description?: string; }>): string; composeCommentMentionPrompt(ticket: any, rolePrompt: string, mention: any, ticketId: string): string; } export interface AgentManagerCommandSink { handle(raw: string): Promise; } export interface EventDispatcherDeps { subagentManager?: SubagentManager | null; chatSessionManager?: ChatSessionManager | null; ticketSessionManager?: TicketSessionManager | null; runtimeProfileOverride?: RuntimeProfileSpec | null; agentSessionRunner?: AgentSessionRunner | null; fsBrowser?: FsBrowser | null; prompts?: PromptComposer | null; agentManagerCommandHandler?: AgentManagerCommandSink | null; managedAgentContexts?: ManagedAgentContextRegistry | null; worktreeManager?: WorktreeManager | null; inflightDispatchTracker?: InflightDispatchTracker | null; dispatchBlockTracker?: DispatchBlockTracker | null; poolReclaimTrigger?: (() => Promise) | null; poolRetryScheduler?: RetryScheduler | null; poolRetryMaxAttempts?: number | null; sessionLimitDeferStore?: SessionLimitDeferStore | null; runtimeSupervisor?: RuntimeSupervisor | null; } export declare class EventDispatcher { #private; dispatchSuppressionCounts(): Record; dispatchBlockCounts(): Record; wakePoolRetries(reason: string): void; pendingPoolRetryCount(): number; recordHarnessSessionLimit(info: { agentId: string; ticketId?: string; role?: string; deferUntilMs: number; reason?: string; resetLabel?: string; }): { opened: boolean; }; sessionDeferState(agentId: string): ReturnType; pendingSessionDeferCount(agentId?: string): number; constructor(config: AwbConfig, deps?: EventDispatcherDeps); dispatch(eventType: string, raw: string): void | Promise; handleAgentSessionRequest(raw: string): Promise; handleFsRequest(raw: string): Promise; handleTrigger(raw: string, opts?: { onDispatched?: (pid: number | null) => void; }): Promise; handleChatRequest(raw: string): Promise; handleCommentMention(raw: string): Promise; handleBoardUpdate(raw: string): void; handleChatRoomMessage(raw: string): Promise; } export {};