import type { ThinkingLevel } from "@caupulican/pi-agent-core/types"; import type { Api, Model, Usage } from "@caupulican/pi-ai"; import type { IsolatedCompletionOptions, IsolatedCompletionResult } from "../agent-session-contracts.ts"; import type { WorkerRequest } from "../autonomy/contracts.ts"; import type { LaneToolSurface } from "../autonomy/lane-tool-surface.ts"; import type { ModelCapabilityProfile } from "../model-capability.ts"; import type { ArtifactContract, AttemptUsageSnapshot, ExecutionGrant } from "../orchestration/contracts.ts"; import type { StartedDelegationAttempt } from "../orchestration/delegation-ledger.ts"; import { WorkerActionJournal } from "./worker-action-journal.ts"; import type { AppliedActionsReport, WorkerAction } from "./worker-actions.ts"; import type { WorkerAgentControlCoordinator } from "./worker-agent-control-coordinator.ts"; import type { WorkerConversation, WorkerConversationRetentionPolicy } from "./worker-conversation-store.ts"; import type { WorkerExecutionPlan } from "./worker-execution-policy.ts"; import type { WorkerLifecycle } from "./worker-lifecycle.ts"; import { type WorkerRunOutcome } from "./worker-runner.ts"; export interface RecoveredWorkerTerminalCompletion { text: string; usage: Usage; stopReason: string; } /** The live mutable state that must be visible to session disposal before provider work yields. */ export interface WorkerAttemptExecutionLedger { changedFiles: Set; getUsage(): AttemptUsageSnapshot; } export interface WorkerAttemptExecutionResult { rawOutcome: WorkerRunOutcome; usage: AttemptUsageSnapshot; changedFiles: readonly string[]; outputArtifact?: ArtifactContract; } export declare function runProviderCompletionWithBackoff(args: { attempt: () => Promise; /** Release per-attempt provider reservations before waiting; the final failure is rethrown. */ onAttemptFailure: () => void; provider: string; laneId: string; warn: (message: string) => void; signal?: AbortSignal; }): Promise; /** * The provider/tool-loop portion of a prepared worker attempt. * * Admission, durable leasing, grant compilation, terminalization, notification, verification, and * scheduling remain outside this boundary. This unit owns only the ordered worker conversation: * persist assistant tool requests before execution, append messages before mailbox acknowledgements, * checkpoint cumulative usage before later boundaries, and compact only the provider projection. */ export interface WorkerAttemptExecutorOptions { request: WorkerRequest; grant: ExecutionGrant; executionPlan: WorkerExecutionPlan; toolSurface: LaneToolSurface; conversation: WorkerConversation; lifecycle: Pick; laneId: string; agentId: string; durableHandle: StartedDelegationAttempt; parentSessionId: string; agentDir: string; cwd: string; model: Model; thinkingLevel?: ThinkingLevel; laneCapability: Pick; soul?: string; workerResourceSystemPrompt: string; initialUsage: AttemptUsageSnapshot; hasPersistedUsageCheckpoint: boolean; usageReportId: string; processCapable: boolean; verificationSubjectTaskId?: string; recoveredTerminal?: RecoveredWorkerTerminalCompletion; retentionPolicy?: WorkerConversationRetentionPolicy; signal?: AbortSignal; runIsolatedCompletion(options: IsolatedCompletionOptions): Promise; agentControl: Pick; applyActions?(actions: readonly WorkerAction[], actionJournal?: WorkerActionJournal): AppliedActionsReport; warn(message: string): void; } /** * Constructs one execution exactly once. The caller registers {@link ledger} before calling * {@link run}, allowing synchronous disposal to observe mutations and cumulative usage while the * provider/tool loop is suspended. */ export declare function createWorkerAttemptExecutor(options: WorkerAttemptExecutorOptions): { ledger: WorkerAttemptExecutionLedger; checkpointUsage(summary: string): AttemptUsageSnapshot; run(): Promise; }; //# sourceMappingURL=worker-attempt-executor.d.ts.map