import type { ContextOperationRequest } from '../context.ts'; import type { CoordinatedUpdateResult } from '../types.ts'; import type { UpdateRequest, UpdateResponse } from '../updates.ts'; import type { EngineInternals } from './internals.ts'; export type UpdateCallbacks = { dispatchEvent: (event: Event) => boolean; broadcast: (message: { type: 'update:completed'; workflowId: string; updateId: string; }) => void; completeOperation: (workflowId: string, value: unknown) => void; guardTerminalWorkflow: (workflowId: string) => Promise; guardTerminalWorkflowAfterCoordinatedRequest: (workflowId: string, updateId: string) => Promise; persistCoordinatedUpdateResponse: (workflowId: string, updateName: string, updateId: string, idempotencyKey: string | undefined, value: unknown) => Promise; deliverCoordinatedUpdateToWaiterIfAvailable: (workflowId: string, updateRequest: UpdateRequest, dispatchReceivedEvent?: boolean) => Promise; dispatchPendingUpdateReceived: (workflowId: string, updateName: string, updateRequest: UpdateRequest) => void; createCoordinatedUpdateResponder: (workflowId: string, updateName: string, updateRequest: UpdateRequest) => (value: unknown) => void; findPendingUpdateByName: (workflowId: string, name: string) => Promise; schedulePendingInlineUpdateDrain: (workflowId: string) => void; }; export declare function update(internals: EngineInternals, workflowId: string, name: string, payload: unknown, options: { timeout?: number; } | undefined, callbacks: UpdateCallbacks): Promise; /** * `handled: false` used to conflate two reasons: no live local context at all * (`'not-owned-locally'`, possible under `ownership: 'workflow-lease'` when * another engine holds the claim) versus a live context with no handler * registered for `name` (`'no-handler'`). See the `update()` call site for * why neither is routed differently — the reason is exposed so a caller that * DOES care (tests, future routing) can tell them apart. */ export type InlineUpdateAttemptResult = { handled: true; value: unknown; } | { handled: false; reason: 'not-owned-locally' | 'no-handler'; }; export declare function tryInlineUpdateHandler(internals: EngineInternals, workflowId: string, name: string, payload: unknown, callbacks: UpdateCallbacks): Promise; /** Retrieve the result of a coordinated update by its ID. */ export declare function getUpdateResult(internals: EngineInternals, updateId: string): Promise; /** * Submit a coordinated update request. Handles idempotency checking, * creates the request, and waits for a response within the timeout. */ export declare function submitCoordinatedUpdate(internals: EngineInternals, workflowId: string, name: string, payload: unknown, options: { timeout?: number; idempotencyKey?: string; } | undefined, callbacks: UpdateCallbacks): Promise; export declare function processWaitUpdateOperation(internals: EngineInternals, workflowId: string, operation: Extract, callbacks: UpdateCallbacks): Promise; export declare function dispatchPendingUpdateReceived(_internals: EngineInternals, workflowId: string, updateName: string, updateRequest: UpdateRequest, callbacks: Pick): void; export declare function createCoordinatedUpdateResponder(_internals: EngineInternals, workflowId: string, updateName: string, updateRequest: UpdateRequest, callbacks: Pick): (value: unknown) => void; export declare function deliverCoordinatedUpdateToWaiterIfAvailable(internals: EngineInternals, workflowId: string, updateRequest: UpdateRequest, dispatchReceivedEvent: boolean | undefined, callbacks: UpdateCallbacks): Promise; export declare function findPendingUpdateByName(internals: EngineInternals, workflowId: string, name: string): Promise;