import type { ActorRef, TaskCommand, TaskChangeSource, TaskCreateRequest, TaskResultPolicy, TaskRunReceipt } from '@xopcai/gateway-contract'; import { type TaskReadModel } from './task-read-model-projector.js'; import type { TurnContextRef } from '../agent/source-context/types.js'; import { type WorkspaceFileInput } from './task-handoff.js'; import { type UnconfirmedToolEffect } from '../agent/orchestration/turn-recovery.js'; export type TaskApplicationResult = { ok: true; model: TaskReadModel; runId?: string; } | { ok: false; reason: 'not_found' | 'conflict' | 'invalid_transition' | 'blocked'; model?: TaskReadModel; }; export type TaskRevisionApplicationResult = TaskApplicationResult | { ok: false; reason: 'invalid_reference'; model: TaskReadModel; }; export type TaskFollowUpAction = 'updated_allocation' | 'steered_running' | 'unblocked_and_resumed' | 'continued_warm_session' | 'reallocated_continuation' | 'saved_while_waiting_authorization'; export type TaskFollowUpResult = { ok: true; action: TaskFollowUpAction; model: TaskReadModel; runId?: string; conversationId?: string; } | { ok: false; reason: 'not_found' | 'cancelled' | 'invalid_transition'; model?: TaskReadModel; }; type TaskRunRetry = { runId: string; readOnly: boolean; originalRequestAt?: number; decisionWaitIds: string[]; }; export declare class TaskApplicationService { #private; create(input: TaskCreateRequest, actor?: ActorRef, options?: { linkRunningOriginInput?: boolean; resultPolicy?: TaskResultPolicy; workspaceHandoff?: { prompt: string; files: readonly WorkspaceFileInput[]; }; }): TaskApplicationResult; /** Atomically open a new work revision; allocation and source IO remain background work. */ reviseCompleted(input: { taskId: string; conversationId: string; baselineResultId: string; baselineVersion: string; expectedVersion: number; instruction: string; idempotencyKey: string; sourceRefs?: TurnContextRef[]; supersedesEntryIds?: string[]; }): TaskRevisionApplicationResult; /** * Unified state-adaptive follow-up on an existing Task: * - allocating / unstarted: merges new direction into brief and resets pending/blocked allocation * - running / queued: posts steer instruction to active Worker * - waiting: auto-resolves collaboration / user_input / paused / run_decision waits and resumes * - completed / review / failed: wakes existing Worker session with full warm context (or reallocates if needed) */ followUp(input: { taskId: string; conversationId: string; instruction?: string; idempotencyKey: string; sourceRefs?: TurnContextRef[]; requestedAgentId?: string; timeRange?: { from: string; to: string; timezone: string; expression: string; }; }): TaskFollowUpResult; execute(input: { taskId: string; idempotencyKey: string; expectedVersion: number; command: TaskCommand; actor?: ActorRef; triggerContext?: Record; source?: TaskChangeSource; retry?: TaskRunRetry; allocationSources?: TurnContextRef[]; }): TaskApplicationResult; completeRun(input: { runId: string; expectedRunVersion: number; receipt: Omit; actor?: ActorRef; terminalCode?: string; terminalMessage?: string; suppressAttention?: boolean; resultText?: string; hostArtifact?: { id: string; sha256?: string; }; reviewedInstructionSequence?: number; unconfirmedEffect?: UnconfirmedToolEffect; }): TaskApplicationResult; private start; private lifecycle; private recordCommand; private readCommand; private enqueueEvent; } export {};