/** Max cross-invocation continuations for one sub-agent run. Each continuation * is one ~40s soft-timeout chunk, so ~60 ≈ ~40 minutes of wall-clock work. Two * independent guards bound runaway self-fire: this persisted cap and the * per-invocation `MAX_RUN_LOOP_CONTINUATIONS` inside the run loop. * * Progress-aware continuation: non-progressing chunks count against a much * smaller budget (`MAX_AGENT_TEAM_NO_PROGRESS_CONTINUATIONS`) so a stalled * sub-agent is detected and finalized quickly, while actively-working sub-agents * can run for as long as this absolute cap allows. */ export declare const MAX_AGENT_TEAM_CONTINUATIONS = 60; /** Max consecutive *non-progressing* continuations before the run is finalized. * A chunk that emits no new events, tool calls, or text counts as no-progress. */ export declare const MAX_AGENT_TEAM_NO_PROGRESS_CONTINUATIONS = 3; /** A `running` row whose `updated_at` is older than this is treated as a * dropped dispatch and may be re-claimed / re-fired. Must be comfortably larger * than the processor heartbeat interval so a healthy run is never re-claimed. */ export declare const RUN_DISPATCH_STUCK_AFTER_MS = 15000; /** Hard cutoff after which a stuck row is failed deterministically rather than * retried (side-effectful work may already have happened). Mirrors A2A. */ export declare const RUN_PROCESSING_STUCK_AFTER_MS: number; export type AgentTeamRunQueueStatus = "queued" | "running" | "done" | "failed"; export interface AgentTeamRunPayload { description: string; instructions?: string; model?: string; /** Custom agent profile name (agents/*.md) to brief the sub-agent with. */ agentRef?: string; /** Parent thread to post a completion recap to. */ parentThreadId?: string; /** Display name for the sub-agent tab. */ name?: string; /** Logical-turn id, stable across continuation chunks so durable assistant * messages fold into one. */ turnId: string; } export interface AgentTeamRunQueueRow { taskId: string; threadId: string; runId: string; status: AgentTeamRunQueueStatus; ownerEmail: string | null; orgId: string | null; payload: AgentTeamRunPayload; continuationCount: number; attempts: number; createdAt: number; updatedAt: number; } declare function getAffectedRowCount(result: unknown): number; export interface EnqueueAgentTeamRunInput { taskId: string; threadId: string; runId: string; ownerEmail?: string | null; orgId?: string | null; payload: AgentTeamRunPayload; } export declare function enqueueAgentTeamRun(input: EnqueueAgentTeamRunInput): Promise; /** * Atomically claim a run for processing. Succeeds when the row is `queued`, or * `running` but stale (a dropped dispatch past `RUN_DISPATCH_STUCK_AFTER_MS`). * Flips it to `running`, bumps `attempts`, and stamps `updated_at`. Returns the * claimed row, or null if another invocation already holds it (idempotency). */ export declare function claimAgentTeamRun(taskId: string, options?: { stuckAfterMs?: number; }): Promise; /** Heartbeat: bump `updated_at` while a claimed run is actively processing so a * healthy run isn't re-claimed by the stuck-refire path. * * When `claimedAttempts` is provided the UPDATE is fenced to * `attempts = claimedAttempts`: a superseded invocation (one that was * re-claimed after it stalled) will find the attempts counter has been bumped * and the update will be a no-op, signalling that this invocation should * self-terminate. */ export declare function touchAgentTeamRun(taskId: string, claimedAttempts?: number): Promise; /** * Record a soft-timeout continuation: re-queue the row (so the next * self-fired invocation can claim it) and increment the counter. Returns the * new continuation count, or null if the row wasn't in a continuable state. * * When `claimedAttempts` is provided the UPDATE is fenced to * `attempts = claimedAttempts` so a superseded invocation cannot queue a * spurious continuation. */ export declare function bumpAgentTeamContinuation(taskId: string, claimedAttempts?: number): Promise; /** * Mark a run terminal. * * When `claimedAttempts` is provided the UPDATE is fenced to * `attempts = claimedAttempts` so a superseded invocation cannot overwrite a * freshly-claimed row's status. Returns whether the row was actually updated. */ export declare function completeAgentTeamRun(taskId: string, status: "done" | "failed", claimedAttempts?: number): Promise; /** Task ids of an owner's in-flight (queued/running) sub-agent runs. Used by * the RunsTray data path to self-heal dropped dispatches and dead runs. */ export declare function listActiveAgentTeamTaskIdsForOwner(owner: string, limit?: number): Promise; export declare function getAgentTeamRunDispatchState(taskId: string): Promise; /** Test-only accessor for resetting the cached init promise between specs. */ export declare const _agentTeamRunQueueForTests: { resetInit(): void; getAffectedRowCount: typeof getAffectedRowCount; }; export {}; //# sourceMappingURL=agent-teams-run-queue.d.ts.map