import type { Hono, Context as HonoContext } from "hono"; import type { ActorKey, Encoding, UniversalWebSocket } from "@/actor/mod"; import type { ActorQuery, CrashPolicy } from "@/client/query"; import type { IssuedToken, IssueTokenOptions } from "@/client/auth"; import type { RegistryConfig } from "@/registry/config"; import type { GetUpgradeWebSocket } from "@/utils"; export type GatewayTarget = { directId: string } | ActorQuery; export interface GatewayRequestOptions { skipReadyWait?: boolean; } export function shouldSkipReadyWait( options: GatewayRequestOptions = {}, ): boolean { return options.skipReadyWait === true; } export interface EngineControlClient { issueToken(options: IssueTokenOptions): Promise; getForId(input: GetForIdInput): Promise; getWithKey(input: GetWithKeyInput): Promise; getOrCreateWithKey(input: GetOrCreateWithKeyInput): Promise; createActor(input: CreateInput): Promise; /** Forks the actor `actorId` into a new actor of the same name, started on a copy of its database. */ forkActor(input: ForkInput): Promise; listActors(input: ListActorsInput): Promise; sendRequest( target: GatewayTarget, actorRequest: Request, options?: GatewayRequestOptions, ): Promise; openWebSocket( path: string, target: GatewayTarget, encoding: Encoding, params: unknown, options?: GatewayRequestOptions, ): Promise; /** Refresh a credential rejected during this WebSocket handshake, if supported. */ refreshAuthToken?(ws: UniversalWebSocket): Promise; proxyRequest( c: HonoContext, actorRequest: Request, actorId: string, ): Promise; proxyWebSocket( c: HonoContext, path: string, actorId: string, encoding: Encoding, params: unknown, ): Promise; buildGatewayUrl( target: GatewayTarget, options?: GatewayRequestOptions, ): Promise; displayInformation(): RuntimeDisplayInformation; extraStartupLog?: () => Record; modifyRuntimeRouter?: (config: RegistryConfig, router: Hono) => void; setGetUpgradeWebSocket(getUpgradeWebSocket: GetUpgradeWebSocket): void; shutdown?(): void; /** * Test-only helper that simulates an abrupt actor crash. */ hardCrashActor?(actorId: string): Promise; } export interface RuntimeDisplayInformation { properties: Record; } export interface GetForIdInput { c?: HonoContext | undefined; name: string; actorId: string; } export interface GetWithKeyInput { c?: HonoContext | undefined; name: string; key: ActorKey; } export interface GetOrCreateWithKeyInput { c?: HonoContext | undefined; name: string; key: ActorKey; input?: unknown; region?: string; crashPolicy?: CrashPolicy; /** Overrides the client's configured pool name for this actor. */ poolName?: string; } export interface CreateInput { c?: HonoContext | undefined; name: string; key: ActorKey; input?: unknown; region?: string; crashPolicy?: CrashPolicy; /** Overrides the client's configured pool name for this actor. */ poolName?: string; } export interface ForkInput { c?: HonoContext | undefined; /** The source actor. */ actorId: string; /** The new actor's key; omitted for a keyless actor. */ key?: ActorKey; /** The fork input, given to the new actor's `onFork` hook. */ input?: unknown; } export interface ListActorsInput { c?: HonoContext | undefined; name: string; key?: string; includeDestroyed?: boolean; } export interface ActorOutput { actorId: string; name: string; key: ActorKey; createTs?: number; startTs?: number | null; connectableTs?: number | null; sleepTs?: number | null; destroyTs?: number | null; error?: unknown; }