import type { AgentResult, ContextUsage } from '../core/types/agent-types.js'; import type { ContinuationSink } from './types.js'; import type { NormalizedEvent } from './normalize/event-types.js'; /** Background-task continuation feature gate. */ export declare function isBgContinuationEnabled(): boolean; /** Grace period for work-done-but-unnotified tasks (CORTEX_BG_GRACE_S, default 90s). */ export declare function getBgGraceMs(): number; /** Max hold for still-running tasks (CORTEX_BG_WAIT_MAX_S, default 30min). */ export declare function getBgMaxWaitMs(): number; /** Background work remaining on a turn result: running + finished-but-unnotified. */ export declare function remainingBg(result: { pendingBackgroundTasks?: number; undeliveredBackgroundTasks?: number; } | null | undefined): number; /** Backend and result prerequisites shared by explicit and legacy inline waiting. */ export declare function canAwaitBgContinuation(backend: string, result: AgentResult | null | undefined, canRegisterSink: boolean): boolean; /** Legacy inline policy: settings-enabled thread turns wait; interactive turns do not. */ export declare function shouldAwaitBgInline(backend: string, threadId: string | null | undefined, result: AgentResult | null | undefined, canRegisterSink: boolean): boolean; export interface WaitForBgOpts { proc: { setContinuationSink?: (sink: ContinuationSink) => void; }; baseResult: AgentResult; /** Continuation assistant text forwarded here (the step's transcript/stream callback). */ onAssistantText?: ((text: string) => void) | null; onToolUse?: ((name: string, input: any, toolUseId: string) => void) | null; onToolResult?: ((toolUseId: string, content: string, isError: boolean) => void) | null; onContextUsage?: ((usage: ContextUsage) => void | Promise) | null; onEvent?: ((event: NormalizedEvent) => void) | null; graceMs?: number; maxWaitMs?: number; /** Wait without ambient release timers until continuation completion or supervised stop. */ completionOnly?: boolean; /** Process termination boundary required by completion-only waits. */ stopPromise?: Promise; /** Injectable timers for tests. Production timers are unref'd. */ timers?: { set: (fn: () => void, ms: number) => unknown; clear: (h: unknown) => void; }; } export declare function waitForBgContinuation(opts: WaitForBgOpts): Promise;