import { z } from "zod"; import type { ActorIdentity } from "../actor/identity.js"; import type { HostSocketEffect, SocketQuery } from "../actor/socketProtocol.js"; import type { JsonValue } from "../json.js"; import type { JsonText } from "../payload/json-text.js"; import type { SessionFrame } from "../payload/session-frames.js"; declare function parseActorSessionServerMessage({ head, parts }: SessionFrame): ActorSessionServerMessage; declare function detachReply(reply: ActorExecutorReply): DetachedReply; declare function detachEffects(effects: readonly HostSocketEffect[]): SessionPart[]; declare function failedReply(code: string, message: string): FailedReply; declare const invokeCommandSchema: z.ZodObject<{ type: z.ZodLiteral<"invoke">; request_id: z.ZodString; method: z.ZodString; }, z.core.$strip>; declare const websocketEventCommandSchema: z.ZodObject<{ type: z.ZodLiteral<"websocket_event">; request_id: z.ZodString; event: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"connect">; connection: z.ZodObject<{ id: z.ZodString; metadata: z.ZodType>; tags: z.ZodArray; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"message">; connection_id: z.ZodString; message: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"text">; data: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"binary">; data: z.ZodString; }, z.core.$strip>], "type">; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"disconnect">; connection: z.ZodObject<{ id: z.ZodString; metadata: z.ZodType>; tags: z.ZodArray; }, z.core.$strip>; code: z.ZodNumber; reason: z.ZodString; was_clean: z.ZodBoolean; }, z.core.$strip>], "type">; connections: z.ZodArray>; tags: z.ZodArray; }, z.core.$strip>>; }, z.core.$strip>; declare const evictCommandSchema: z.ZodObject<{ type: z.ZodLiteral<"evict">; graceful: z.ZodBoolean; }, z.core.$strip>; declare const executorCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"invoke">; request_id: z.ZodString; method: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"websocket_event">; request_id: z.ZodString; event: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"connect">; connection: z.ZodObject<{ id: z.ZodString; metadata: z.ZodType>; tags: z.ZodArray; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"message">; connection_id: z.ZodString; message: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"text">; data: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"binary">; data: z.ZodString; }, z.core.$strip>], "type">; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"disconnect">; connection: z.ZodObject<{ id: z.ZodString; metadata: z.ZodType>; tags: z.ZodArray; }, z.core.$strip>; code: z.ZodNumber; reason: z.ZodString; was_clean: z.ZodBoolean; }, z.core.$strip>], "type">; connections: z.ZodArray>; tags: z.ZodArray; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"evict">; graceful: z.ZodBoolean; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"hydrate">; }, z.core.$strip>], "type">; declare const actorSessionServerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"attached">; protocol: z.ZodLiteral<34>; actor: z.ZodObject<{ project_id: z.ZodString; actor_name: z.ZodString; actor_id: z.ZodString; }, z.core.$strict>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"actor_result">; call_id: z.ZodNumber; outcome: z.ZodType>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"socket_connections">; message_id: z.ZodNumber; connections: z.ZodUnion>; tags: z.ZodArray; }, z.core.$strip>>, z.ZodNumber]>; error: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"command">; message_id: z.ZodNumber; command: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"invoke">; request_id: z.ZodString; method: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"websocket_event">; request_id: z.ZodString; event: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"connect">; connection: z.ZodObject<{ id: z.ZodString; metadata: z.ZodType>; tags: z.ZodArray; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"message">; connection_id: z.ZodString; message: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"text">; data: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"binary">; data: z.ZodString; }, z.core.$strip>], "type">; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"disconnect">; connection: z.ZodObject<{ id: z.ZodString; metadata: z.ZodType>; tags: z.ZodArray; }, z.core.$strip>; code: z.ZodNumber; reason: z.ZodString; was_clean: z.ZodBoolean; }, z.core.$strip>], "type">; connections: z.ZodArray>; tags: z.ZodArray; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"evict">; graceful: z.ZodBoolean; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"hydrate">; }, z.core.$strip>], "type">; }, z.core.$strip>], "type">; type InvokeCommand = z.infer & InvocationArguments & AssignedActor; type EvictCommand = z.infer; /** A command as its line has it, without the parts that follow. */ type CommandLine = z.infer; type ActorExecutorCommand = Exclude | (Extract & InvocationArguments); type ActorExecutionCommand = Exclude; /** A command with the actor this process was assigned. */ type AssignedCommand = ActorExecutorCommand & AssignedActor; type ActorSessionServerLine = z.infer; type ActorSessionServerMessage = Exclude | (Omit, "command"> & { command: ActorExecutorCommand; }); type ActorExecutorReply = InvokedReply | WebSocketHandledReply | FailedReply | EvictedReply | { readonly type: "hydrated"; }; type ReplyHead = { readonly type: "invoked" | "websocket_handled"; readonly sequence?: number; } | FailedReply | EvictedReply | { readonly type: "hydrated"; }; /** What follows a line: a string, or the text of a result or a socket message, which is already UTF-8. */ type SessionPart = string | JsonText; type DetachedReply = ReplyHead & { readonly parts?: readonly SessionPart[]; }; type ActorSessionClientMessage = { readonly type: "actor_call"; readonly call_id: number; readonly call: ActorCallRequest; } | { readonly type: "residency"; readonly resident: boolean; } | AttachMessage | { readonly type: "ready_for_invocation"; readonly message_id: number; } | { readonly type: "get_connections"; readonly message_id: number; readonly query?: SocketQuery; } | { readonly type: "log"; readonly message_id?: number; readonly level: LogLevel; readonly message: string; } | { readonly type: "socket_effects"; readonly message_id: number; } | { readonly type: "reply"; readonly message_id: number; readonly reply: ReplyHead; }; interface AttachMessage { readonly type: "attach"; readonly protocol: 34; readonly actor_names: readonly string[]; } /** An invocation's arguments, which follow its command's line as a part. */ interface InvocationArguments { readonly args: JsonValue[]; } interface ActorCallRequest { readonly request_id: string; readonly actor_name: string; readonly actor_id: string; readonly method: string; readonly args: readonly JsonValue[]; } interface AssignedActor { readonly actor: ActorIdentity; } interface InvokedReply { readonly type: "invoked"; readonly sequence?: number; /** The result as JSON. It is encoded once, before the commit, so a result that has no JSON fails the call. */ readonly result: JsonText; readonly effects?: readonly HostSocketEffect[]; } interface WebSocketHandledReply { readonly type: "websocket_handled"; readonly sequence?: number; readonly effects: readonly HostSocketEffect[]; } interface FailedReply { readonly type: "failed"; readonly code: string; readonly message: string; } interface EvictedReply { readonly type: "evicted"; } type LogLevel = "debug" | "info" | "warn" | "error"; interface ActorLog { /** The command that wrote the line. Absent for output from outside any command. */ readonly messageId?: number; readonly level: LogLevel; readonly message: string; } type WebSocketEventCommand = z.infer & AssignedActor; export { detachEffects, detachReply, failedReply, parseActorSessionServerMessage }; export type { ActorCallRequest, ActorLog, LogLevel, ActorExecutionCommand, ActorExecutorCommand, ActorExecutorReply, ActorSessionClientMessage, ActorSessionServerMessage, AssignedCommand, DetachedReply, EvictCommand, FailedReply, InvokeCommand, SessionPart, WebSocketEventCommand }; //# sourceMappingURL=protocol.d.ts.map