import type { ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationPromise, ObjectContext, Rand, Request, RestatePromise, RunAction, RunOptions, SendOptions, WorkflowContext } from "./context.js";
import type * as vm from "./endpoint/handlers/vm/sdk_shared_core_wasm_bindings.js";
import { TerminalError } from "./types/errors.js";
import type { Client, SendClient } from "./types/rpc.js";
import { HandlerKind } from "./types/rpc.js";
import type { Duration, JournalValueCodec, Serde, Service, ServiceDefinitionFrom, VirtualObject, VirtualObjectDefinitionFrom, Workflow, WorkflowDefinitionFrom } from "@restatedev/restate-sdk-core";
import type { ReadableStreamDefaultReader, WritableStreamDefaultWriter } from "node:stream/web";
import { CompletablePromise } from "./utils/completable_promise.js";
import type { AsyncResultValue } from "./promises.js";
import { PromisesExecutor } from "./promises.js";
export declare class ContextImpl implements ObjectContext, WorkflowContext {
    readonly coreVm: vm.WasmVM;
    readonly input: vm.WasmInput;
    readonly console: Console;
    readonly handlerKind: HandlerKind;
    private readonly vmLogger;
    private readonly invocationRequest;
    private readonly invocationEndPromise;
    readonly journalValueCodec: JournalValueCodec;
    private readonly asTerminalError?;
    readonly rand: Rand;
    readonly date: ContextDate;
    private readonly outputPump;
    private readonly runClosuresTracker;
    readonly promisesExecutor: PromisesExecutor;
    readonly defaultSerde: Serde<any>;
    constructor(coreVm: vm.WasmVM, input: vm.WasmInput, console: Console, handlerKind: HandlerKind, vmLogger: Console, invocationRequest: Request, invocationEndPromise: CompletablePromise<void>, inputReader: ReadableStreamDefaultReader<Uint8Array>, outputWriter: WritableStreamDefaultWriter<Uint8Array>, journalValueCodec: JournalValueCodec, defaultSerde?: Serde<any>, asTerminalError?: ((error: any) => TerminalError | undefined) | undefined);
    cancel(invocationId: InvocationId): void;
    attach<T>(invocationId: InvocationId, serde?: Serde<T>): RestatePromise<T>;
    get key(): string;
    request(): Request;
    get<T>(name: string, serde?: Serde<T>): RestatePromise<T | null>;
    stateKeys(): RestatePromise<Array<string>>;
    set<T>(name: string, value: T, serde?: Serde<T>): void;
    clear(name: string): void;
    clearAll(): void;
    genericCall<REQ = Uint8Array, RES = Uint8Array>(call: GenericCall<REQ, RES>): InvocationPromise<RES>;
    genericSend<REQ = Uint8Array>(send: GenericSend<REQ>): InvocationHandle;
    serviceClient<D>({ name }: ServiceDefinitionFrom<D>): Client<Service<D>>;
    objectClient<D>({ name }: VirtualObjectDefinitionFrom<D>, key: string): Client<VirtualObject<D>>;
    workflowClient<D>({ name }: WorkflowDefinitionFrom<D>, key: string): Client<Workflow<D>>;
    serviceSendClient<D>({ name }: ServiceDefinitionFrom<D>, opts?: SendOptions): SendClient<Service<D>>;
    objectSendClient<D>({ name }: VirtualObjectDefinitionFrom<D>, key: string, opts?: SendOptions): SendClient<VirtualObject<D>>;
    workflowSendClient<D>({ name }: WorkflowDefinitionFrom<D>, key: string, opts?: SendOptions): SendClient<Workflow<D>>;
    run<T>(nameOrAction: string | RunAction<T>, actionSecondParameter?: RunAction<T>, options?: RunOptions<T>): RestatePromise<T>;
    sleep(duration: number | Duration, name?: string): RestatePromise<void>;
    awakeable<T>(serde?: Serde<T>): {
        id: string;
        promise: RestatePromise<T>;
    };
    resolveAwakeable<T>(id: string, payload?: T, serde?: Serde<T>): void;
    rejectAwakeable(id: string, reason: string): void;
    promise<T>(name: string, serde?: Serde<T>): DurablePromise<T>;
    static createCombinator<T extends readonly RestatePromise<unknown>[]>(combinatorConstructor: (promises: Promise<any>[]) => Promise<any>, promises: T): RestatePromise<unknown>;
    private processNonCompletableEntry;
    processCompletableEntry<T, U>(commandType: vm.WasmCommandType, prepare: () => T, vmCall: (vm: vm.WasmVM, t: T) => number, ...completers: Array<Completer>): RestatePromise<U>;
    promiseExecutorErrorCallback(e: unknown): void;
    handleInvocationEndError(e: unknown, notify_vm_error?: (vm: vm.WasmVM, error: Error) => void): void;
}
export declare class RunClosuresTracker {
    private currentRunWaitPoint?;
    private runsToExecute;
    executeRun(handle: number): void;
    registerRunClosure(handle: number, runClosure: () => Promise<any>): void;
    awaitNextCompletedRun(): Promise<void>;
    private unblockCurrentRunWaitPoint;
}
type Completer = (value: AsyncResultValue, prom: CompletablePromise<any>) => Promise<boolean>;
export {};
//# sourceMappingURL=context_impl.d.ts.map