import type { DatabaseSync } from 'node:sqlite'; import type { Config } from '../../config/schema.js'; import { LocalWorktreeManager } from '../../execution-environments/local-worktree-manager.js'; import { type ScenePrincipal, type SceneTemplate } from '../contracts.js'; import type { SceneActivationAdapter } from '../activationAdapter.js'; import { type FollowUpExecutor } from './agentExecutor.js'; import { verifyTaskWorkspace } from '../../agent/commands/approved-verification.js'; import { SceneSourceRegistry } from './contracts.js'; import { TaskBranchInventory } from './branchInventory.js'; /** Scene orchestration owns source cursors, not a second Task/TaskRun lifecycle. */ export declare class SceneTaskExecutionService implements SceneActivationAdapter { private readonly db; private readonly deps; readonly id = "task"; readonly branches: TaskBranchInventory; private readonly scenes; private readonly tasks; private readonly runs; private readonly application; private readonly environments; private readonly executor; private readonly resources; readonly sources: SceneSourceRegistry; private readonly active; private polling?; private stopped; private readonly stopController; private recovered; constructor(db: DatabaseSync, deps: { config: () => Config; sources: SceneSourceRegistry; executor?: FollowUpExecutor; worktrees?: LocalWorktreeManager; stateDir?: string; verify?: typeof verifyTaskWorkspace; stopVerification?: (name: string) => Promise; }); private binding; private principal; private image; private parse; private source; private sourceAuthorized; preflight(principal: ScenePrincipal, template: SceneTemplate, value: unknown): Promise<{ ready: boolean; missing: string[]; }>; create(principal: ScenePrincipal, template: SceneTemplate, value: unknown): Promise<{ activation: import("@xopcai/gateway-contract/src/scenes.js").SceneActivation; task: { id: string; title: string; phase: "backlog" | "ready" | "active" | "review" | "closed"; priority: "low" | "normal" | "high" | "critical"; source: string; latestContractVersion: number; boardRank: number; version: number; createdAt: number; updatedAt: number; body?: string; resolution?: "cancelled" | "done" | "duplicate" | "wont_do"; dueAt?: number; projectId?: string; milestoneId?: string; parentTaskId?: string; ownerId?: string; delegateAgentId?: string; locale?: "en" | "zh"; contract?: { taskId: string; version: number; objective: string; expectedOutputs: string[]; acceptanceCriteria: string[]; constraints: string[]; approvalRequired: string[]; assumptions: string[]; risks: string[]; acceptancePolicy: "verified_auto" | "verified_then_review" | "manual"; outputDestinations: Record[]; createdBy: { kind: "user" | "agent" | "system" | "integration"; id?: string; }; createdAt: number; }; closedAt?: number; }; input: { source: { provider: string; reference: Record; }; goal: string; instruction: string; resource: "worktree" | "none" | "artifacts"; capabilities: ("workspace.read" | "workspace.write" | "verification.run")[]; projectId?: string; verificationCommand?: string; sourceUrl?: string; }; environment: import("../../execution-environments/types.js").ExecutionEnvironment; observedRevision: number; deliveredRevision: number; processedRevision: number; artifactPath: string; source: Record; delivery: string; lastError: string; nextPollAt: number; run: { id: string; taskId: string; rootRunId: string; attempt: number; status: "failed" | "succeeded" | "waiting" | "cancelled" | "queued" | "running" | "verifying"; executorKind: "agent" | "workflow" | "human" | "external"; executorRef: Record; trigger: Record; correlationId: string; idempotencyKey: string; contractVersion: number; queuedAt: number; retryPolicy: Record; version: number; parentRunId?: string; causationId?: string; contextSnapshotId?: string; policySnapshot?: Record; conversationId?: string; scheduledAt?: number; startedAt?: number; heartbeatAt?: number; completedAt?: number; timeoutAt?: number; leaseOwner?: string; leaseExpiresAt?: number; retryOfRunId?: string; terminalCode?: string; terminalMessage?: string; }; receipt: { runId: string; status: "failed" | "succeeded" | "cancelled"; summary: string; changes: { kind: "source" | "artifact" | "test" | "state"; title: string; summary: string; provenance: "user" | "external" | "tool" | "judge"; strength: "observed" | "verified"; observedAt: number; uri?: string; verifies?: string[]; }[]; evidence: { kind: "source" | "artifact" | "test" | "state"; title: string; summary: string; provenance: "user" | "external" | "tool" | "judge"; strength: "observed" | "verified"; observedAt: number; uri?: string; verifies?: string[]; }[]; verification: { status: "failed" | "passed" | "unverified"; checks: { criterion: string; status: "failed" | "passed" | "unverified"; evidenceTitles: string[]; }[]; }; remainingWork: string[]; needsUser: boolean; finalizedAt: number; nextAction?: string; completionVerdict?: "partial" | "achieved" | "not_achieved"; failure?: { code: string; phase: string; recoveryAction: string; }; judgment?: { recommendation: string; reasons: string[]; rejectedAlternatives: { option: string; reason: string; }[]; confidence: number; uncertainty?: string; }; contextTraceId?: string; }; }>; private contract; get(principal: ScenePrincipal, id: string): { activation: import("@xopcai/gateway-contract/src/scenes.js").SceneActivation; task: { id: string; title: string; phase: "backlog" | "ready" | "active" | "review" | "closed"; priority: "low" | "normal" | "high" | "critical"; source: string; latestContractVersion: number; boardRank: number; version: number; createdAt: number; updatedAt: number; body?: string; resolution?: "cancelled" | "done" | "duplicate" | "wont_do"; dueAt?: number; projectId?: string; milestoneId?: string; parentTaskId?: string; ownerId?: string; delegateAgentId?: string; locale?: "en" | "zh"; contract?: { taskId: string; version: number; objective: string; expectedOutputs: string[]; acceptanceCriteria: string[]; constraints: string[]; approvalRequired: string[]; assumptions: string[]; risks: string[]; acceptancePolicy: "verified_auto" | "verified_then_review" | "manual"; outputDestinations: Record[]; createdBy: { kind: "user" | "agent" | "system" | "integration"; id?: string; }; createdAt: number; }; closedAt?: number; }; input: { source: { provider: string; reference: Record; }; goal: string; instruction: string; resource: "worktree" | "none" | "artifacts"; capabilities: ("workspace.read" | "workspace.write" | "verification.run")[]; projectId?: string; verificationCommand?: string; sourceUrl?: string; }; environment: import("../../execution-environments/types.js").ExecutionEnvironment; observedRevision: number; deliveredRevision: number; processedRevision: number; artifactPath: string; source: Record; delivery: string; lastError: string; nextPollAt: number; run: { id: string; taskId: string; rootRunId: string; attempt: number; status: "failed" | "succeeded" | "waiting" | "cancelled" | "queued" | "running" | "verifying"; executorKind: "agent" | "workflow" | "human" | "external"; executorRef: Record; trigger: Record; correlationId: string; idempotencyKey: string; contractVersion: number; queuedAt: number; retryPolicy: Record; version: number; parentRunId?: string; causationId?: string; contextSnapshotId?: string; policySnapshot?: Record; conversationId?: string; scheduledAt?: number; startedAt?: number; heartbeatAt?: number; completedAt?: number; timeoutAt?: number; leaseOwner?: string; leaseExpiresAt?: number; retryOfRunId?: string; terminalCode?: string; terminalMessage?: string; }; receipt: { runId: string; status: "failed" | "succeeded" | "cancelled"; summary: string; changes: { kind: "source" | "artifact" | "test" | "state"; title: string; summary: string; provenance: "user" | "external" | "tool" | "judge"; strength: "observed" | "verified"; observedAt: number; uri?: string; verifies?: string[]; }[]; evidence: { kind: "source" | "artifact" | "test" | "state"; title: string; summary: string; provenance: "user" | "external" | "tool" | "judge"; strength: "observed" | "verified"; observedAt: number; uri?: string; verifies?: string[]; }[]; verification: { status: "failed" | "passed" | "unverified"; checks: { criterion: string; status: "failed" | "passed" | "unverified"; evidenceTitles: string[]; }[]; }; remainingWork: string[]; needsUser: boolean; finalizedAt: number; nextAction?: string; completionVerdict?: "partial" | "achieved" | "not_achieved"; failure?: { code: string; phase: string; recoveryAction: string; }; judgment?: { recommendation: string; reasons: string[]; rejectedAlternatives: { option: string; reason: string; }[]; confidence: number; uncertainty?: string; }; contextTraceId?: string; }; }; list(principal: ScenePrincipal): { activation: import("@xopcai/gateway-contract/src/scenes.js").SceneActivation; task: { id: string; title: string; phase: "backlog" | "ready" | "active" | "review" | "closed"; priority: "low" | "normal" | "high" | "critical"; source: string; latestContractVersion: number; boardRank: number; version: number; createdAt: number; updatedAt: number; body?: string; resolution?: "cancelled" | "done" | "duplicate" | "wont_do"; dueAt?: number; projectId?: string; milestoneId?: string; parentTaskId?: string; ownerId?: string; delegateAgentId?: string; locale?: "en" | "zh"; contract?: { taskId: string; version: number; objective: string; expectedOutputs: string[]; acceptanceCriteria: string[]; constraints: string[]; approvalRequired: string[]; assumptions: string[]; risks: string[]; acceptancePolicy: "verified_auto" | "verified_then_review" | "manual"; outputDestinations: Record[]; createdBy: { kind: "user" | "agent" | "system" | "integration"; id?: string; }; createdAt: number; }; closedAt?: number; }; input: { source: { provider: string; reference: Record; }; goal: string; instruction: string; resource: "worktree" | "none" | "artifacts"; capabilities: ("workspace.read" | "workspace.write" | "verification.run")[]; projectId?: string; verificationCommand?: string; sourceUrl?: string; }; environment: import("../../execution-environments/types.js").ExecutionEnvironment; observedRevision: number; deliveredRevision: number; processedRevision: number; artifactPath: string; source: Record; delivery: string; lastError: string; nextPollAt: number; run: { id: string; taskId: string; rootRunId: string; attempt: number; status: "failed" | "succeeded" | "waiting" | "cancelled" | "queued" | "running" | "verifying"; executorKind: "agent" | "workflow" | "human" | "external"; executorRef: Record; trigger: Record; correlationId: string; idempotencyKey: string; contractVersion: number; queuedAt: number; retryPolicy: Record; version: number; parentRunId?: string; causationId?: string; contextSnapshotId?: string; policySnapshot?: Record; conversationId?: string; scheduledAt?: number; startedAt?: number; heartbeatAt?: number; completedAt?: number; timeoutAt?: number; leaseOwner?: string; leaseExpiresAt?: number; retryOfRunId?: string; terminalCode?: string; terminalMessage?: string; }; receipt: { runId: string; status: "failed" | "succeeded" | "cancelled"; summary: string; changes: { kind: "source" | "artifact" | "test" | "state"; title: string; summary: string; provenance: "user" | "external" | "tool" | "judge"; strength: "observed" | "verified"; observedAt: number; uri?: string; verifies?: string[]; }[]; evidence: { kind: "source" | "artifact" | "test" | "state"; title: string; summary: string; provenance: "user" | "external" | "tool" | "judge"; strength: "observed" | "verified"; observedAt: number; uri?: string; verifies?: string[]; }[]; verification: { status: "failed" | "passed" | "unverified"; checks: { criterion: string; status: "failed" | "passed" | "unverified"; evidenceTitles: string[]; }[]; }; remainingWork: string[]; needsUser: boolean; finalizedAt: number; nextAction?: string; completionVerdict?: "partial" | "achieved" | "not_achieved"; failure?: { code: string; phase: string; recoveryAction: string; }; judgment?: { recommendation: string; reasons: string[]; rejectedAlternatives: { option: string; reason: string; }[]; confidence: number; uncertainty?: string; }; contextTraceId?: string; }; }[]; allowsTaskNotification(taskId: string): boolean; listProjectBranches(principal: ScenePrincipal, projectId: string): Promise<{ projectId: string; repositoryRoot: string; checkoutDirty: boolean; branches: { ref: string; sha: string; subject: string; worktree: string; taskId: string; activationId: string; association: string; changedSinceConfirmation: boolean; }[]; }>; associateBranch(principal: ScenePrincipal, input: unknown): Promise<{ taskId: string; association: string; ref: string; sha: string; subject: string; worktree: string; activationId: string; changedSinceConfirmation: boolean; }>; configure(principal: ScenePrincipal, id: string, expectedRevision: number, value: unknown): Promise<{ activation: import("@xopcai/gateway-contract/src/scenes.js").SceneActivation; task: { id: string; title: string; phase: "backlog" | "ready" | "active" | "review" | "closed"; priority: "low" | "normal" | "high" | "critical"; source: string; latestContractVersion: number; boardRank: number; version: number; createdAt: number; updatedAt: number; body?: string; resolution?: "cancelled" | "done" | "duplicate" | "wont_do"; dueAt?: number; projectId?: string; milestoneId?: string; parentTaskId?: string; ownerId?: string; delegateAgentId?: string; locale?: "en" | "zh"; contract?: { taskId: string; version: number; objective: string; expectedOutputs: string[]; acceptanceCriteria: string[]; constraints: string[]; approvalRequired: string[]; assumptions: string[]; risks: string[]; acceptancePolicy: "verified_auto" | "verified_then_review" | "manual"; outputDestinations: Record[]; createdBy: { kind: "user" | "agent" | "system" | "integration"; id?: string; }; createdAt: number; }; closedAt?: number; }; input: { source: { provider: string; reference: Record; }; goal: string; instruction: string; resource: "worktree" | "none" | "artifacts"; capabilities: ("workspace.read" | "workspace.write" | "verification.run")[]; projectId?: string; verificationCommand?: string; sourceUrl?: string; }; environment: import("../../execution-environments/types.js").ExecutionEnvironment; observedRevision: number; deliveredRevision: number; processedRevision: number; artifactPath: string; source: Record; delivery: string; lastError: string; nextPollAt: number; run: { id: string; taskId: string; rootRunId: string; attempt: number; status: "failed" | "succeeded" | "waiting" | "cancelled" | "queued" | "running" | "verifying"; executorKind: "agent" | "workflow" | "human" | "external"; executorRef: Record; trigger: Record; correlationId: string; idempotencyKey: string; contractVersion: number; queuedAt: number; retryPolicy: Record; version: number; parentRunId?: string; causationId?: string; contextSnapshotId?: string; policySnapshot?: Record; conversationId?: string; scheduledAt?: number; startedAt?: number; heartbeatAt?: number; completedAt?: number; timeoutAt?: number; leaseOwner?: string; leaseExpiresAt?: number; retryOfRunId?: string; terminalCode?: string; terminalMessage?: string; }; receipt: { runId: string; status: "failed" | "succeeded" | "cancelled"; summary: string; changes: { kind: "source" | "artifact" | "test" | "state"; title: string; summary: string; provenance: "user" | "external" | "tool" | "judge"; strength: "observed" | "verified"; observedAt: number; uri?: string; verifies?: string[]; }[]; evidence: { kind: "source" | "artifact" | "test" | "state"; title: string; summary: string; provenance: "user" | "external" | "tool" | "judge"; strength: "observed" | "verified"; observedAt: number; uri?: string; verifies?: string[]; }[]; verification: { status: "failed" | "passed" | "unverified"; checks: { criterion: string; status: "failed" | "passed" | "unverified"; evidenceTitles: string[]; }[]; }; remainingWork: string[]; needsUser: boolean; finalizedAt: number; nextAction?: string; completionVerdict?: "partial" | "achieved" | "not_achieved"; failure?: { code: string; phase: string; recoveryAction: string; }; judgment?: { recommendation: string; reasons: string[]; rejectedAlternatives: { option: string; reason: string; }[]; confidence: number; uncertainty?: string; }; contextTraceId?: string; }; }>; transition(principal: ScenePrincipal, id: string, expectedRevision: number, status: 'active' | 'paused' | 'archived'): Promise<{ activation: import("@xopcai/gateway-contract/src/scenes.js").SceneActivation; task: { id: string; title: string; phase: "backlog" | "ready" | "active" | "review" | "closed"; priority: "low" | "normal" | "high" | "critical"; source: string; latestContractVersion: number; boardRank: number; version: number; createdAt: number; updatedAt: number; body?: string; resolution?: "cancelled" | "done" | "duplicate" | "wont_do"; dueAt?: number; projectId?: string; milestoneId?: string; parentTaskId?: string; ownerId?: string; delegateAgentId?: string; locale?: "en" | "zh"; contract?: { taskId: string; version: number; objective: string; expectedOutputs: string[]; acceptanceCriteria: string[]; constraints: string[]; approvalRequired: string[]; assumptions: string[]; risks: string[]; acceptancePolicy: "verified_auto" | "verified_then_review" | "manual"; outputDestinations: Record[]; createdBy: { kind: "user" | "agent" | "system" | "integration"; id?: string; }; createdAt: number; }; closedAt?: number; }; input: { source: { provider: string; reference: Record; }; goal: string; instruction: string; resource: "worktree" | "none" | "artifacts"; capabilities: ("workspace.read" | "workspace.write" | "verification.run")[]; projectId?: string; verificationCommand?: string; sourceUrl?: string; }; environment: import("../../execution-environments/types.js").ExecutionEnvironment; observedRevision: number; deliveredRevision: number; processedRevision: number; artifactPath: string; source: Record; delivery: string; lastError: string; nextPollAt: number; run: { id: string; taskId: string; rootRunId: string; attempt: number; status: "failed" | "succeeded" | "waiting" | "cancelled" | "queued" | "running" | "verifying"; executorKind: "agent" | "workflow" | "human" | "external"; executorRef: Record; trigger: Record; correlationId: string; idempotencyKey: string; contractVersion: number; queuedAt: number; retryPolicy: Record; version: number; parentRunId?: string; causationId?: string; contextSnapshotId?: string; policySnapshot?: Record; conversationId?: string; scheduledAt?: number; startedAt?: number; heartbeatAt?: number; completedAt?: number; timeoutAt?: number; leaseOwner?: string; leaseExpiresAt?: number; retryOfRunId?: string; terminalCode?: string; terminalMessage?: string; }; receipt: { runId: string; status: "failed" | "succeeded" | "cancelled"; summary: string; changes: { kind: "source" | "artifact" | "test" | "state"; title: string; summary: string; provenance: "user" | "external" | "tool" | "judge"; strength: "observed" | "verified"; observedAt: number; uri?: string; verifies?: string[]; }[]; evidence: { kind: "source" | "artifact" | "test" | "state"; title: string; summary: string; provenance: "user" | "external" | "tool" | "judge"; strength: "observed" | "verified"; observedAt: number; uri?: string; verifies?: string[]; }[]; verification: { status: "failed" | "passed" | "unverified"; checks: { criterion: string; status: "failed" | "passed" | "unverified"; evidenceTitles: string[]; }[]; }; remainingWork: string[]; needsUser: boolean; finalizedAt: number; nextAction?: string; completionVerdict?: "partial" | "achieved" | "not_achieved"; failure?: { code: string; phase: string; recoveryAction: string; }; judgment?: { recommendation: string; reasons: string[]; rejectedAlternatives: { option: string; reason: string; }[]; confidence: number; uncertainty?: string; }; contextTraceId?: string; }; }>; private enabled; private observe; private decisions; private enqueue; tick(): Promise; private poll; private recoverInterrupted; /** Called by the existing agent TaskRun dispatcher, never a second dispatch queue. */ executeTask(runId: string, conversationId: string): Promise; private executionIntent; private execute; private fail; stop(): Promise; }