import type { ComposedWorkflowInterceptor } from '../interceptor.ts'; import type { SearchAttributeSchema, SearchAttributeValue } from '../types.ts'; import type { WorkflowLogRecord } from '../types/workflow-log.ts'; import type { Context, ContextOptions } from './index.ts'; export interface ContextInternals { context: Context; abortController: AbortController; stepIndex: number; accumulatedResults: Map | undefined; checkpointLocals: Record; stateSession: Record | undefined; searchAttributes: Record; searchAttributeSchema: SearchAttributeSchema | undefined; workflowInterceptor: ComposedWorkflowInterceptor | null | undefined; pendingAttributeChanges: Record | undefined; updateHandlers: Map unknown> | undefined; updateValidators: Map unknown> | undefined; queryHandlers: Map unknown> | undefined; exposedValues: Map unknown> | undefined; memoCache: Map | undefined; deadline: number | undefined; getNow: () => number; sleepReferenceTime: number | undefined; explainMode: boolean; nestingDepth: number; executionStateOwnerId: string; resolveWorkflowType: ((target: string | Function) => string) | undefined; registerCancelHandler: ((handler: () => Promise | void) => () => void) | undefined; services: unknown; /** * Host sink for `ctx.log` records (`EngineOptions.onLog`), or `undefined` for the * default console behavior. Captured by value when the `ctx.log` getter first * builds its logger; `onLog` is fixed at engine construction, so there is nothing * to re-read per emit. */ logSink: ((record: WorkflowLogRecord) => void) | undefined; /** * Engine callback that durably records `ctx.setFinalizerState(value)` payloads * (#446); `undefined` in speculative branches, where the branch reuses this * inline {@link Context} but the engine leaves the callback unset, so * `ctx.setFinalizerState` throws a descriptive guard error. (Worker-mode * generators never reach this field at all — they receive a reduced worker-side * context that does not carry `setFinalizerState`, so the call fails there with a * `TypeError`.) Finalizer *registration* and teardown are unaffected — those run * on the engine host in every mode (#564). Injected at context construction, * mirroring {@link registerCancelHandler}. */ recordFinalizerState: ((value: unknown) => void) | undefined; } export declare function initializeInternals(context: Context, options: ContextOptions, initialSessionState: Record | undefined): void; export declare function getInternals(context: Context): ContextInternals; /** * Non-throwing probe: is `value` a concrete {@link Context} with initialized * internals? Used to distinguish the inline-mode `Context` (which carries the * `stepIndex`/`accumulatedResults` replay machinery) from the minimal * worker-mode `WorkerWorkflowContext`, which is a different shape. WeakMap * `.has` accepts any object key and returns `false` for non-`Context` objects, * so this is safe to call on any context-shaped value. */ export declare function hasContextInternals(value: object): value is Context;