/** * Inline execution strategy: runs workflows on the main thread. * * This strategy drives async generators directly in the calling context, * emitting {@link WorkerOutboundMessage} to the engine via a callback. * It is the default execution model and preserves the original behavior * where the engine manages generators, abort controllers, and contexts * in-process. * * @module core/inline-execution-strategy */ import { Context } from './context.ts'; import type { ExecutionStrategy } from './execution-strategy.ts'; import type { InlineExecutionDependencies, InlineStartWorkflowParameters } from './inline-execution-strategy.context-options.ts'; import type { FailureCategory, OperationOutcome, WorkerOutboundMessage } from './types.ts'; export declare class InlineExecutionStrategy implements ExecutionStrategy { #private; constructor(dependencies: InlineExecutionDependencies); onMessage(handler: (message: WorkerOutboundMessage) => void | Promise): void; startWorkflow(parameters: InlineStartWorkflowParameters): void; resumeWorkflow(parameters: { workflowId: string; checkpoint: ArrayBuffer | Uint8Array; operationResult: OperationOutcome; }): void; cancelWorkflow(workflowId: string): void; /** * Evict a workflow's in-memory execution state (generator, abort controller, * live context, tracked turns/advances). * * By default this is a hard eviction: nothing about the run stays reachable — * which is what the suspend/general teardown path requires. The inline * `waitForSignal` parking optimization opts into `retainContext: true` so the * run's Context survives in `#parkedContexts` and its `ctx.onQuery` handlers * stay callable while the run is parked. Retention is therefore strictly * opt-in at the one call site that wants it; every other caller gets eviction. */ parkWorkflow(workflowId: string, options?: { retainContext?: boolean; }): void; /** Returns the live Context for a workflow, or `undefined` if not running. For parked workflows use {@link getParkedContext}. */ getContext(workflowId: string): Context | undefined; /** Returns the retained Context for a parked workflow, or `undefined` if not parked or already cleaned up. */ getParkedContext(workflowId: string): Context | undefined; /** * Drop any retained parked Context for a workflow without touching the abort * controller or other live state. Terminal cleanup calls this so a workflow * that reached a terminal status while parked (e.g. a failed resume, or normal * completion of a run that had parked) cannot keep resolving `ctx.onQuery` * handlers from a stale parked Context — and so the Context is not retained * for the engine's lifetime. */ clearParkedContext(workflowId: string): void; getAbortController(workflowId: string): AbortController | undefined; waitForWorkflowTurn(workflowId: string): Promise | undefined; abortWorkflowAdvanceForShutdown(workflowId: string): void; waitForWorkflowAdvance(workflowId: string): Promise | undefined; hasGenerator(workflowId: string): boolean; /** * Resume the generator with a value (used by the engine after inline * operation processing like timers, signals, etc.). */ continueWorkflow(workflowId: string, value: unknown): void; /** * Throw an error into the generator (used by the engine for propagating * activity failures, etc.). */ throwIntoWorkflow(workflowId: string, error: unknown, operationFailureCategory?: FailureCategory): void; /** * Synchronously evict a workflow's live/parked context, generator, and * abort controller the moment a same-engine reclaim begins (WFT-79) — * BEFORE `onReclaimed`'s `recoverPendingAsyncActivities`/`resumeFromLifecycle` * await anything. `takeover()` installing a new local epoch does not, by * itself, evict this engine's OLD in-memory state for a workflow it * previously held and was deposed from (deposition only drops the claim * registry entry; contexts/generators survive — see `index.ts`'s * `onWorkflowClaimReclaimed`). Without this, `query()` and * `tryInlineUpdateHandler()`'s engine-id-only staleness check * (`isWorkflowClaimedByAnotherEngine`) sees the SAME engine as both the old * and new holder and answers "not stale," serving reads/handler invocations * from the pre-reclaim closure throughout the async-activity reload and * force-replay preparation window. Evicting here makes that window * observably contextless instead — `query()` falls through to its * documented not-locally-owned/undefined handling, and * `tryInlineUpdateHandler()` falls through to `'not-owned-locally'` — until * `adoptWorkflow` installs the fresh generation. */ evictContextForReclaim(workflowId: string): void; /** * Store a context and generator created externally (engine resume path). * Clears any retained parked context so a concurrent query sees the new * live context rather than the stale parked one. */ adoptWorkflow(workflowId: string, generator: AsyncGenerator, context: Context, abortController: AbortController): void; [Symbol.dispose](): void; [Symbol.asyncDispose](): Promise; }