UNPKG

@metamask/ocap-kernel

Version:
123 lines 4.86 kB
import type { VatOneResolution } from "@agoric/swingset-liveslots"; import type { ExtractParams, ExtractResult } from "@metamask/kernel-rpc-methods"; import type { JsonRpcMessage } from "@metamask/kernel-utils"; import { Logger } from "@metamask/logger"; import type { DuplexStream } from "@metamask/streams"; import type { JsonRpcNotification, JsonRpcResponse } from "@metamask/utils"; import type { KernelQueue } from "./KernelQueue.mjs"; import { vatMethodSpecs } from "./rpc/index.mjs"; import type { PingVatResult, VatMethod } from "./rpc/index.mjs"; import type { KernelStore } from "./store/index.mjs"; import type { Message, VatId, VatConfig, VRef, CrankResults } from "./types.mjs"; type MessageFromVat = JsonRpcResponse | JsonRpcNotification; type VatStream = DuplexStream<MessageFromVat, JsonRpcMessage>; type VatConstructorProps = { vatId: VatId; vatConfig: VatConfig; vatStream: VatStream; kernelStore: KernelStore; kernelQueue: KernelQueue; logger?: Logger | undefined; }; export declare class VatHandle { #private; /** The ID of the vat this is the VatHandle for */ readonly vatId: VatId; /** The vat's configuration */ readonly config: VatConfig; /** * Construct a new VatHandle instance. * * @param params - Named constructor parameters. * @param params.vatId - Our vat ID. * @param params.vatConfig - The configuration for this vat. * @param params.vatStream - Communications channel connected to the vat worker. * @param params.kernelStore - The kernel's persistent state store. * @param params.kernelQueue - The kernel's queue. * @param params.logger - Optional logger for error and diagnostic output. */ private constructor(); /** * Create a new VatHandle instance. * * @param params - Named constructor parameters. * @param params.vatId - Our vat ID. * @param params.vatConfig - The configuration for this vat. * @param params.vatStream - Communications channel connected to the vat worker. * @param params.kernelStore - The kernel's persistent state store. * @param params.kernelQueue - The kernel's queue. * @param params.logger - Optional logger for error and diagnostic output. * @returns A promise for the new VatHandle instance. */ static make(params: VatConstructorProps): Promise<VatHandle>; /** * Ping the vat. * * @returns A promise that resolves to the result of the ping. */ ping(): Promise<PingVatResult>; /** * Make a 'message' delivery to the vat. * * @param target - The VRef of the object to which the message is addressed. * @param message - The message to deliver. * @returns The crank results. */ deliverMessage(target: VRef, message: Message): Promise<CrankResults>; /** * Make a 'notify' delivery to the vat. * * @param resolutions - One or more promise resolutions to deliver. * @returns The crank results. */ deliverNotify(resolutions: VatOneResolution[]): Promise<CrankResults>; /** * Make a 'dropExports' delivery to the vat. * * @param vrefs - The VRefs of the exports to be dropped. * @returns The crank results. */ deliverDropExports(vrefs: VRef[]): Promise<CrankResults>; /** * Make a 'retireExports' delivery to the vat. * * @param vrefs - The VRefs of the exports to be retired. * @returns The crank results. */ deliverRetireExports(vrefs: VRef[]): Promise<CrankResults>; /** * Make a 'retireImports' delivery to the vat. * * @param vrefs - The VRefs of the imports to be retired. * @returns The crank results. */ deliverRetireImports(vrefs: VRef[]): Promise<CrankResults>; /** * Make a 'bringOutYourDead' delivery to the vat. * * @returns The crank results. */ deliverBringOutYourDead(): Promise<CrankResults>; /** * Terminates the vat. * * @param terminating - If true, the vat is being killed permanently, so clean * up its state and reject any promises that would be left dangling. * @param error - The error to terminate the vat with. */ terminate(terminating: boolean, error?: Error): Promise<void>; /** * Send a command into the vat. * * @param payload - The payload of the command. * @param payload.method - The method to call. * @param payload.params - The parameters to pass to the method. * @returns A promise that resolves the response to the command. */ sendVatCommand<Method extends VatMethod>({ method, params, }: { method: Method; params: ExtractParams<Method, typeof vatMethodSpecs>; }): Promise<ExtractResult<Method, typeof vatMethodSpecs>>; } export {}; //# sourceMappingURL=VatHandle.d.mts.map