/** * Ambient workflow-execution scope for implicit steps (P6.1, Design Law 10). * * The undici dispatcher interceptor (`http-interceptor.ts`) is installed once, * process-wide, and composes with whatever global dispatcher is present * (including OTel auto-instrumentation — we never reassign `globalThis.fetch`). * Whether a given `fetch` is an implicit durable step or a byte-identical * pass-through is decided by THIS AsyncLocalStorage: a store is established * around each workflow-execution slice (in `execute.ts` for the server worker * and in the lite driver); outside a slice the store is undefined and the * interceptor does nothing. * * Both `WorkflowContext` (server) and `WorkflowContextLite` (embedded) provide * an `ImplicitStepHost` implementation, so the interceptor drives them * identically (Design Law 3). */ import type { ImplicitStepsConfig } from './http-effect.js'; /** * The narrow surface the interceptor needs from a running workflow context. * Implemented by WorkflowContext and WorkflowContextLite. */ export interface ImplicitStepHost { readonly runId: string; readonly implicitConfig: ImplicitStepsConfig; /** * Called synchronously by the interceptor, in source call order, BEFORE * any checkpoint lookup — consumes the step's occurrence index and returns * the full step_key (Design Laws 1, 9). MUST be called exactly once per * intercepted fetch, whether it ends up replayed, executed, or errored. */ nextHttpStepKey(identitySource: string): { stepSeq: number; stepKey: string; }; /** * Look up a completed HTTP-effect checkpoint for this step. Returns the * decoded record for replay, or undefined on first encounter. Throws * NonDeterminismError if a checkpoint exists at this seq with a different * step_key (control-flow drift). */ lookupHttpEffect(stepSeq: number, stepKey: string, method: string, url: string): import('./http-effect.js').HttpEffectRecord | undefined; /** Fail before an unrecorded implicit network effect is dispatched. */ assertImplicitEffectAllowed(): void; /** * Record a freshly-executed HTTP effect DURABLY (Design Law 2, per step, * every tier): the server path sends a mid-slice RecordEffects session * frame and resolves after the DurableAck (P9.3 eager flush); the lite * path writes the checkpoint through the embedded engine and awaits the * WAL commit. `meta` is optional LLM token/cost metadata (P3.1). */ recordHttpEffect(stepSeq: number, stepKey: string, record: import('./http-effect.js').HttpEffectRecord, meta?: Record): void | Promise; /** * Adjust the in-flight implicit-HTTP counter (+1 when a first-encounter * fetch is dispatched to the network, -1 when it settles/records/errors). * The server driver's collect-then-suspend loop treats a nonzero count as a * pending action so it does NOT declare quiescence while a fetch is still on * the wire (which would otherwise look like a stall). */ markHttpInFlight(delta: number): void; } /** Run `fn` with `host` as the active implicit-step scope. */ export declare function runInWorkflowScope(host: ImplicitStepHost, fn: () => T): T; /** The active host, or undefined outside a workflow slice (→ pass-through). */ export declare function activeHost(): ImplicitStepHost | undefined;