import type { WorkflowResultWaiter } from './engine-internal-types.ts'; import { WorkflowHandle } from './handles.ts'; import type { EngineInternals } from './internals.ts'; export declare function createWorkflowHandleWithResultPromise(internals: EngineInternals, workflowId: string): WorkflowHandle; export declare function createWorkflowResultWaiter(internals: EngineInternals, workflowId: string): WorkflowResultWaiter; export declare function getWorkflowResultPromise(internals: EngineInternals, workflowId: string): Promise; /** * Result promise for a parent generator parked on `ctx.startChild()`'s * default `parentClosePolicy: 'await'` — the ONLY intended caller (see * `child-workflow.ts`'s `executeChildWorkflow`, which must call this instead * of the plain `childHandle.result()` / `handle.result()` path). Identical to * {@link getWorkflowResultPromise} except the waiter this settles is marked * generator-owned for `parentWorkflowId`: under `ownership: 'workflow-lease'` * a settle attempt first confirms `parentWorkflowId` still holds the claim * generation it parked under (`confirmWakeOwnership`, `'child-completion'`), * fencing duplicate generator advancement (WFT-79 F1) — see * {@link bootstrapWorkflowResultResolver}. Top-level, non-generator callers * must keep using {@link getWorkflowResultPromise}, which stays unfenced by * design: cross-engine `handle.result()` polling has no generator to * duplicate and must remain settleable from durable state alone. * * If `internals.resultResolvers` already holds a waiter for `workflowId` — * e.g. an observational `handle.result()` caller got there first — that * SHARED waiter is untouched: {@link fenceResultOnParentGeneration} wraps * only THIS caller's derived promise, so the observational caller's own * promise settles normally from the shared waiter regardless of the parent's * claim generation. See that function's doc for why fencing lives on the * parent's view instead of the shared waiter itself. */ export declare function getGeneratorOwnedWorkflowResultPromise(internals: EngineInternals, workflowId: string, parentWorkflowId: string): Promise; /** * Settle result waiters for workflows this engine does not own, whose terminal * transition lands on another engine and so never touches this engine's * in-memory resolver map. * * Exported for `backgroundTasks: 'manual'`, where no timer runs and the host * drives every background step through an awaited `runMaintenance()`. */ export declare function pollPendingCrossEngineResultWaiters(internals: EngineInternals): Promise; /** * Outcome of one {@link bootstrapWorkflowResultResolver} attempt, used by * this file's callers to decide whether to keep polling: * * - `'settled'`: the waiter was resolved or rejected. * - `'pending'`: no terminal result yet (still running, or a transient read * failure under a guaranteed-retry ownership mode). Keep polling. * * A generator-owned caller's discarded parent generation needs no outcome * here at all: `fenceResultOnParentGeneration` withholds settlement on that * caller's own derived promise, independent of whether the SHARED waiter * this function settles ever resolves. */ type ResultResolutionOutcome = 'settled' | 'pending'; export declare function bootstrapWorkflowResultResolver(internals: EngineInternals, workflowId: string, waiter: WorkflowResultWaiter): Promise; export declare function cacheHandle(internals: EngineInternals, workflowId: string, handle: WorkflowHandle): void; export {};