/** * Dependency shapes and the context-options builder used by * {@link InlineExecutionStrategy}. Kept beside the strategy so the strategy * module stays focused on generator lifecycle and context bookkeeping. * * @module core/inline-execution-strategy.context-options */ import type { ContextOptions } from './context.ts'; import type { ComposedWorkflowInterceptor } from './interceptor.ts'; import type { SearchAttributeSchema, WorkflowFunction } from './types.ts'; import type { WorkflowLogRecord } from './types/workflow-log.ts'; /** Capabilities the engine injects into the inline strategy at construction. */ export interface InlineExecutionDependencies { getRegistration: (workflowType: string, workflowId: string) => { handler: WorkflowFunction; version: string; searchAttributes?: SearchAttributeSchema; } | undefined; getNow: () => number; resolveWorkflowType?: (target: string | Function) => string; maxNestingDepth: number; development?: boolean; getComposedWorkflowInterceptor?: () => ComposedWorkflowInterceptor | null; registerCancelHandler?: (workflowId: string, handler: () => Promise | void) => () => void; /** * Durably record a `ctx.setFinalizerState(value)` payload for a workflow (#446). * The engine stages it as a pending atomic side-effect so it commits with the * next checkpoint or the terminal batch. Absent in worker mode. */ recordFinalizerState?: (workflowId: string, value: unknown) => void; /** * Look up the non-serialized per-run `services` value for a workflow, exposed * to the body as `ctx.services`. Returns `undefined` when none was supplied. */ getWorkflowServices?: (workflowId: string) => unknown; /** * The host log sink (`EngineOptions.onLog`) for `ctx.log` records, or * `undefined` for the default console behavior. Engine-scoped, so it takes no * workflow id. */ getLogSink?: () => ((record: WorkflowLogRecord) => void) | undefined; } /** A registration resolved through {@link InlineExecutionDependencies.getRegistration}, narrowed to the present case. */ export type InlineWorkflowRegistration = NonNullable>; /** Parameters for starting a workflow run on the inline strategy. */ export type InlineStartWorkflowParameters = { workflowId: string; workflowExecutionToken?: string; workflowType: string; input: unknown; checkpoint: ArrayBuffer | Uint8Array; nestingDepth?: number; executionStateOwnerId?: string; startedAt?: number; sleepReferenceTime?: number; deadline?: number; headers?: [string, string][]; }; /** Build the {@link ContextOptions} for a single inline workflow run from the injected dependencies and start parameters. */ export declare function createInlineContextOptions(dependencies: InlineExecutionDependencies, registration: InlineWorkflowRegistration, parameters: InlineStartWorkflowParameters, workflowAbort: AbortController): ContextOptions; /** * Keep only the defined optional inline-strategy dependencies. Under * `exactOptionalPropertyTypes` a key set to `undefined` is rejected while an * absent key is fine, so each optional is included only when present. Lives here * (rather than inline in `createExecutionStrategyBundle`) so its conditional * spreads do not tip that function over the cyclomatic-complexity cap. */ export declare function optionalInlineDependencies(candidates: { [Key in 'getComposedWorkflowInterceptor' | 'registerCancelHandler' | 'recordFinalizerState' | 'getWorkflowServices' | 'getLogSink']: InlineExecutionDependencies[Key] | undefined; }): Partial;