import type * as native from "@bastani/atomic-natives"; import type { AgentMessage } from "@earendil-works/pi-agent-core"; import type { AgentSessionEvent } from "../agent-session.js"; import type { SessionManager } from "../session-manager.ts"; import type { TaskCompletionSource } from "./completion-ordering.js"; import type * as C from "./contracts.js"; export type TaskTranscriptSource = Pick & { readonly completionSource?: TaskCompletionSource; /** Viewer-only subscription; updates never publish task lifecycle events. */ subscribe?(listener: (event: AgentSessionEvent) => void): () => void; getStreamingMessage?(): AgentMessage | undefined; }; export declare const DEFAULT_AGENT_WAIT_BUDGET_MS = 30000; /** These objects are live authority, not DTOs, restart tokens or model arguments. */ declare class Capability { #private; toJSON(): never; } declare class HostCapability extends Capability { readonly kind = "host"; } declare class OwnerCapability extends Capability { readonly kind = "owner"; } declare class TaskCapability extends Capability { readonly kind = "task"; } declare class WaitCapability extends Capability { readonly kind = "wait"; } declare class SubscriptionCapability extends Capability { readonly kind = "subscription"; } declare class StdinCapability extends Capability { readonly kind = "stdin"; } export type StdinLease = StdinCapability; export type HostSession = HostCapability; export type OwnerLease = OwnerCapability; export type TaskLease = TaskCapability; export type WaitLease = WaitCapability; export type SubscriptionLease = SubscriptionCapability; export type FakeRunnerContext = { ref: C.NativeTaskRef; signal: AbortSignal; reportActivity(report: C.ActivityReport): C.Result; /** Bind existing child history while holding the admitted runner authority. */ bindTranscript(session: TaskTranscriptSource): void; }; /** Independent cleanup evidence: an outcome alone never proves resource release. */ export type FakeExecution = { result: Promise; cleanup: Promise; }; export type TrustedTaskHost = { scope: C.OwnerScope; /** Owner-host observation settings; never an execution deadline. */ tasks?: { wait?: C.TaskWaitConfiguration; }; /** The existing host/tool refusal throws here, before native admission. */ authorizeCommandLaunch?(intent: C.CommandIntent): void; authorizeLaunch(intent: C.AgentIntent): void; resourceAdmission?: import("../sdk-types.ts").ResourceAdmission; onTaskSettled?(ref: C.NativeTaskRef, receipt: C.SettlementReceipt): void; createRunner(context: FakeRunnerContext, intent: C.AgentIntent): FakeExecution; }; /** Reads only history bound by the admitted runner, never a caller-selected session. */ export declare function taskTranscriptSource(task: TaskLease): C.Result<{ session: TaskTranscriptSource; taskId: C.TaskId; }, C.Failure<"UnknownTask" | "TranscriptUnavailable">>; /** History the runner produced; a forked child's inherited parent entries are excluded. */ export declare function taskOwnTranscriptEntries(task: TaskLease): ReturnType | undefined; export declare class TaskSubscription { #private; /** Reconciliation supplements the RFC snapshot/cursor/iterable contract with the events it applied. */ onReconcile: (snapshot: C.OwnerSnapshot, events: readonly C.NativeEvent[]) => void; readonly events: AsyncIterable; readonly lease: SubscriptionLease; constructor(actor: native.TaskSupervisor, initial: native.NativeTaskSubscription, onDispose: () => void); get snapshot(): C.OwnerSnapshot; get cursor(): C.Cursor; /** Consumer exceptions are observable without breaking the native wake or fallback poll. */ get failure(): Error | undefined; /** Callback payloads are authentic hints; only the journal/snapshot is authoritative. */ wake(_hint: native.NativeEvent): void; drain(): void; dispose(clear?: boolean): void; } export declare class TaskSupervisor { #private; bindHostSession(binding: TrustedTaskHost): HostSession; openTaskOwner(host: HostSession, scope: C.OwnerScope): C.Result; startCommandTask(owner: OwnerLease, intent: C.CommandIntent, operation: C.OperationId, signal?: AbortSignal): Promise>; /** Caller must hold launch authorization closed while this snapshot drains. */ drainCommandAdmissions(owner: OwnerLease): Promise; taskStdin(task: TaskLease): C.Result; writeTaskInput(input: StdinLease, operation: C.OperationId, data: C.InputData): Promise>; readTaskOutput(task: TaskLease, range: C.OutputRange): Promise>; startAgentTask(owner: OwnerLease, intent: C.AgentIntent, operation: C.OperationId, schedule?: (dispatch: () => Promise) => void): Promise>; taskReference(task: TaskLease): C.NativeTaskRef; waitForTask(task: TaskLease, budgetMs?: number, designation?: HostSession): Promise>; /** Resolve only a task admitted under this live owner; IDs alone confer no authority. */ lookupTask(owner: OwnerLease, taskId: C.TaskId): C.Result; waitForTaskId(owner: OwnerLease, taskId: C.TaskId, budgetMs?: number, onRegistered?: (wait: WaitLease) => void): Promise>; foregroundTask(task: TaskLease, budgetMs?: number): Promise>; waitId(wait: WaitLease): C.WaitId; findWait(id: C.WaitId): WaitLease | undefined; observeTaskWait(wait: WaitLease): Promise>; yieldTaskWait(wait: WaitLease, reason: C.YieldReason): C.Result; disposeTaskWait(wait: WaitLease): C.Result; initialObservation(task: TaskLease, policy?: C.WaitPolicy, onRegistered?: (wait: WaitLease) => void): Promise>; cancelTask(task: TaskLease, cause: C.CancelCause): Promise>; closeTaskOwner(owner: OwnerLease, cause: C.OwnerCloseCause): Promise>; /** * The bounded stream carries only authentic deltas. Overflow/native reset publishes * snapshot/cursor then ends the current iterator, even with no surviving delta. * Reconcile on completion; obtain a new iterator on the same events iterable to * continue observing. Apply snapshots first and ignore deltas at/below their cursor. * onReconcile is optional; consumer failures never disable the fallback poll. */ watchOwnerTasks(owner: OwnerLease, from?: C.Cursor): C.Result; } export {}; //# sourceMappingURL=supervisor.d.ts.map