UNPKG

@casual-simulation/aux-common

Version:
1,867 lines 62.5 kB
import type { AuthorizeActionMissingPermission, DenialReason } from '../common/DenialReason';
import type { NotSupportedError, ServerError } from '../Errors';
import type { ConnectionInfo } from '../common/ConnectionInfo';
import type { RemoteAction, DeviceAction, DeviceActionResult, RemoteActionResult, RemoteActionError, DeviceActionError } from '../common/RemoteActions';
import type { ZodIssue } from 'zod';
import { z } from 'zod';
import type { GenericHttpRequest, GenericHttpResponse } from '../http/GenericHttpInterface';
import type { PublicUserInfo, ResourceKinds, SubjectType } from '../common';
import type { KnownErrorCodes } from '../rpc/ErrorCodes';
/**
 * Defines a websocket event.
 *
 * That is, an event that is used to manage and communicate over a websocket connection.
 *
 * There are currently three types of events:
 * - message: A message that was recieved.
 * - upload_request: A request to upload a large message to a large object store. (This event type only exists to get around message size limits)
 * - upload_response: A response to an upload_request event. (This event type only exists to get around message size limits)
 * - download_request: A request to tell the client to download a message from from a URL. (This event type only exists to get around message size limits)
 */
export type WebsocketEvent = WebsocketMessageEvent | WebsocketUploadRequestEvent | WebsocketUploadResponseEvent | WebsocketDownloadRequestEvent | WebsocketErrorEvent;
export declare enum WebsocketEventTypes {
    Message = 1,
    UploadRequest = 2,
    UploadResponse = 3,
    DownloadRequest = 4,
    Error = 5
}
export declare const websocketEventSchema: z.ZodTuple<[z.ZodNativeEnum<typeof WebsocketEventTypes>, z.ZodNumber], z.ZodAny>;
/**
 * Defines a websocket event that contains a message.
 */
export type WebsocketMessageEvent = [
    type: WebsocketEventTypes.Message,
    id: number,
    data: WebsocketMessage
];
/**
 * Defines a websocket event that contains a request to upload a large message.
 */
export type WebsocketUploadRequestEvent = [
    type: WebsocketEventTypes.UploadRequest,
    id: number
];
export declare const websocketUploadRequestEventSchema: z.ZodTuple<[z.ZodLiteral<WebsocketEventTypes.UploadRequest>, z.ZodNumber], null>;
export interface UploadHttpHeaders {
    [key: string]: string;
}
/**
 * Defines a websocket event that contains a response to an upload request.
 */
export type WebsocketUploadResponseEvent = [
    type: WebsocketEventTypes.UploadResponse,
    id: number,
    uploadUrl: string,
    uploadMethod: string,
    uploadHeaders: UploadHttpHeaders
];
export declare const websocketUploadResponseEventSchema: z.ZodTuple<[z.ZodLiteral<WebsocketEventTypes.UploadResponse>, z.ZodNumber, z.ZodString, z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>], null>;
export type WebsocketErrorCode = ServerError | NotSupportedError | KnownErrorCodes | 'invalid_record_key' | 'unacceptable_connection_token' | 'invalid_token' | 'session_expired' | 'user_is_banned' | 'unacceptable_connection_id' | 'message_not_found' | 'unacceptable_request' | 'record_not_found' | 'not_authorized' | 'action_not_supported' | 'not_logged_in' | 'subscription_limit_reached' | 'inst_not_found' | 'invalid_connection_state';
/**
 * Defines an interface that contains information about an error that occurred.
 */
export interface WebsocketErrorInfo {
    success: false;
    /**
     * The name of the record that the error is associated with.
     */
    recordName?: string | null;
    /**
     * The name of the inst that the error is associated with.
     */
    inst?: string;
    /**
     * The name of the branch that the error is associated with.
     */
    branch?: string;
    /**
     * The error code that occurred.
     */
    errorCode: WebsocketErrorCode;
    /**
     * The error message.
     */
    errorMessage: string;
    /**
     * The list of parsing issues that occurred.
     */
    issues?: ZodIssue[];
    /**
     * The authorization denial reason.
     */
    reason?: DenialReason;
}
export declare const websocketErrorInfoSchema: z.ZodObject<{
    errorCode: z.ZodString;
    errorMessage: z.ZodString;
    issues: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
    reason: z.ZodOptional<z.ZodAny>;
}, "strip", z.ZodTypeAny, {
    errorCode?: string;
    errorMessage?: string;
    issues?: any[];
    reason?: any;
}, {
    errorCode?: string;
    errorMessage?: string;
    issues?: any[];
    reason?: any;
}>;
/**
 * Defines a websocket event that contains a response to an upload request.
 */
export type WebsocketErrorEvent = [
    type: WebsocketEventTypes.Error,
    id: number,
    info: WebsocketErrorInfo
];
export declare const websocketErrorEventSchema: z.ZodTuple<[z.ZodLiteral<WebsocketEventTypes.Error>, z.ZodNumber, z.ZodObject<{
    errorCode: z.ZodString;
    errorMessage: z.ZodString;
    issues: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
    reason: z.ZodOptional<z.ZodAny>;
}, "strip", z.ZodTypeAny, {
    errorCode?: string;
    errorMessage?: string;
    issues?: any[];
    reason?: any;
}, {
    errorCode?: string;
    errorMessage?: string;
    issues?: any[];
    reason?: any;
}>], null>;
/**
 * Defines a websocket event that contains a request to download a large message.
 */
export type WebsocketDownloadRequestEvent = [
    type: WebsocketEventTypes.DownloadRequest,
    id: number,
    downloadUrl: string,
    downloadMethod: string,
    downloadHeaders: UploadHttpHeaders
];
export declare const websocketDownloadRequestEventSchema: z.ZodTuple<[z.ZodLiteral<WebsocketEventTypes.DownloadRequest>, z.ZodNumber, z.ZodString, z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>], null>;
export type WebsocketResponseMessage = LoginResultMessage | WatchBranchResultMessage | TimeSyncResponseMessage | UpdatesReceivedMessage | ReceiveDeviceActionMessage | ConnectedToBranchMessage | DisconnectedFromBranchMessage | RateLimitExceededMessage | WebsocketHttpResponseMessage | WebsocketHttpPartialResponseMessage | RequestMissingPermissionResponseMessage;
export type WebsocketRequestMessage = LoginMessage | WatchBranchMessage | UnwatchBranchMessage | AddUpdatesMessage | SendActionMessage | WatchBranchDevicesMessage | UnwatchBranchDevicesMessage | ConnectionCountMessage | TimeSyncRequestMessage | GetUpdatesMessage | WebsocketHttpRequestMessage | RequestMissingPermissionMessage | RequestMissingPermissionResponseMessage;
export type WebsocketMessage = WebsocketRequestMessage | WebsocketResponseMessage;
/**
 * Defines a login message.
 */
export interface LoginMessage {
    type: 'login';
    /**
     * The token that should be used to authenticate the connection.
     */
    connectionToken?: string;
    /**
     * The ID that the client wants to use for the connection.
     * Must be unique.
     */
    connectionId?: string;
}
export declare const loginMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"login">;
    connectionToken: z.ZodOptional<z.ZodString>;
    connectionId: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
    type?: "login";
    connectionToken?: string;
    connectionId?: string;
}, {
    type?: "login";
    connectionToken?: string;
    connectionId?: string;
}>;
/**
 * Defines a login result message.
 */
export type LoginResultMessage = LoginResultSuccessMessage | LoginResultFailureMessage;
export interface LoginResultBaseMessage {
    type: 'login_result';
}
export interface LoginResultSuccessMessage extends LoginResultBaseMessage {
    success: true;
    /**
     * The info for the connection.
     */
    info: ConnectionInfo;
}
export interface LoginResultFailureMessage extends LoginResultBaseMessage {
    success: false;
    /**
     * The error code that occurred.
     */
    errorCode: WebsocketErrorCode;
    /**
     * The error message that occurred.
     */
    errorMessage: string;
    /**
     * The authorization denial reason.
     */
    reason?: DenialReason;
}
/**
 * Defines an event which indicates that a branch should be watched.
 */
export interface WatchBranchMessage {
    type: 'repo/watch_branch';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch to watch.
     */
    branch: string;
    /**
     * Whether the branch should be temporary.
     * That is, if the branch data should not be loaded from the database
     * and everything should be deleted once all the watchers have left.
     * Defaults to false.
     */
    temporary?: boolean;
    /**
     * The protocol that should be used.
     * Currently, "updates" is the only supported protocol.
     */
    protocol?: 'updates';
}
export declare const watchBranchMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"repo/watch_branch">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    temporary: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
    type?: "repo/watch_branch";
    recordName?: string;
    inst?: string;
    branch?: string;
    temporary?: boolean;
}, {
    type?: "repo/watch_branch";
    recordName?: string;
    inst?: string;
    branch?: string;
    temporary?: boolean;
}>;
export type WatchBranchResultMessage = WatchBranchResultSuccessMessage | WatchBranchResultFailureMessage;
export interface WatchBranchResultSuccessMessage {
    type: 'repo/watch_branch_result';
    success: true;
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch to watch.
     */
    branch: string;
}
export interface WatchBranchResultFailureMessage {
    type: 'repo/watch_branch_result';
    success: false;
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch to watch.
     */
    branch: string;
    /**
     * The error code that occurred.
     */
    errorCode: WebsocketErrorCode;
    /**
     * The error message that occurred.
     */
    errorMessage: string;
    /**
     * The authorization denial reason.
     */
    reason?: DenialReason;
}
/**
 * Defines an event which indicates that a branch should be unwatched.
 */
export interface UnwatchBranchMessage {
    type: 'repo/unwatch_branch';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch to unwatch.
     */
    branch: string;
}
export declare const unwatchBranchMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"repo/unwatch_branch">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, "strip", z.ZodTypeAny, {
    type?: "repo/unwatch_branch";
    recordName?: string;
    inst?: string;
    branch?: string;
}, {
    type?: "repo/unwatch_branch";
    recordName?: string;
    inst?: string;
    branch?: string;
}>;
/**
 * Defines an event which indicates that devices connected to a branch should be watched.
 */
export interface WatchBranchDevicesMessage {
    type: 'repo/watch_branch_devices';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch to unwatch.
     */
    branch: string;
}
export declare const watchBranchDevicesMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"repo/watch_branch_devices">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, "strip", z.ZodTypeAny, {
    type?: "repo/watch_branch_devices";
    recordName?: string;
    inst?: string;
    branch?: string;
}, {
    type?: "repo/watch_branch_devices";
    recordName?: string;
    inst?: string;
    branch?: string;
}>;
/**
 * Defines an event which indicates that devices connected to a branch should be no longer be watched.
 */
export interface UnwatchBranchDevicesMessage {
    type: 'repo/unwatch_branch_devices';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch to unwatch.
     */
    branch: string;
}
export declare const unwatchBranchDevicesMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"repo/unwatch_branch_devices">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, "strip", z.ZodTypeAny, {
    type?: "repo/unwatch_branch_devices";
    recordName?: string;
    inst?: string;
    branch?: string;
}, {
    type?: "repo/unwatch_branch_devices";
    recordName?: string;
    inst?: string;
    branch?: string;
}>;
/**
 * Defines an event which indicates that some arbitrary updates should be added for the given branch.
 * Note that while all branches support both atoms and updates, they do not support mixed usage.
 * This means that clients which use updates should ignore atoms and vice versa.
 */
export interface AddUpdatesMessage {
    type: 'repo/add_updates';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The branch that the updates are for.
     */
    branch: string;
    /**
     * The updates that should be added.
     */
    updates: string[];
    /**
     * The ID for this "add update" event.
     * Used in the subsequent "update received" event to indicate
     * that this update was received and processed.
     *
     * This property is optional because update IDs are only needed for updates which are sent to the
     * server to be saved. (i.e. the client needs confirmation that it was saved) The server needs no such
     * confirmation, so it does not need to include an update ID.
     */
    updateId?: number;
    /**
     * Whether this message should be treated as the first message
     * after a watch_branch event.
     * This flag MUST be included on the first message as large apiary messages may appear out of order.
     */
    initial?: boolean;
    /**
     * The list of timestamps that the updates occurred at.
     */
    timestamps?: number[];
}
export declare const addUpdatesMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"repo/add_updates">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    updates: z.ZodArray<z.ZodString, "many">;
    updateId: z.ZodOptional<z.ZodNumber>;
    initial: z.ZodOptional<z.ZodBoolean>;
    timestamps: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
}, "strip", z.ZodTypeAny, {
    type?: "repo/add_updates";
    recordName?: string;
    inst?: string;
    branch?: string;
    updates?: string[];
    updateId?: number;
    initial?: boolean;
    timestamps?: number[];
}, {
    type?: "repo/add_updates";
    recordName?: string;
    inst?: string;
    branch?: string;
    updates?: string[];
    updateId?: number;
    initial?: boolean;
    timestamps?: number[];
}>;
/**
 * Defines an event which indicates that the updates for the given branch should be retrieved.
 */
export interface GetUpdatesMessage {
    type: 'repo/get_updates';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The branch that the updates are for.
     */
    branch: string;
}
export declare const getUpdatesMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"repo/get_updates">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, "strip", z.ZodTypeAny, {
    type?: "repo/get_updates";
    recordName?: string;
    inst?: string;
    branch?: string;
}, {
    type?: "repo/get_updates";
    recordName?: string;
    inst?: string;
    branch?: string;
}>;
/**
 * Defines an event which indicates that an HTTP request should be made.
 */
export interface WebsocketHttpRequestMessage {
    type: 'http_request';
    /**
     * The ID of the request.
     */
    id: number;
    /**
     * The HTTP request.
     */
    request: Omit<GenericHttpRequest, 'ipAddress'>;
}
export declare const websocketHttpRequestMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"http_request">;
    request: z.ZodObject<{
        path: z.ZodString;
        pathParams: z.ZodObject<{}, "strip", z.ZodString, z.objectOutputType<{}, z.ZodString, "strip">, z.objectInputType<{}, z.ZodString, "strip">>;
        method: z.ZodUnion<[z.ZodLiteral<"GET">, z.ZodLiteral<"POST">, z.ZodLiteral<"PUT">, z.ZodLiteral<"DELETE">, z.ZodLiteral<"HEAD">, z.ZodLiteral<"OPTIONS">]>;
        query: z.ZodObject<{}, "strip", z.ZodString, z.objectOutputType<{}, z.ZodString, "strip">, z.objectInputType<{}, z.ZodString, "strip">>;
        headers: z.ZodObject<{}, "strip", z.ZodString, z.objectOutputType<{}, z.ZodString, "strip">, z.objectInputType<{}, z.ZodString, "strip">>;
        body: z.ZodUnion<[z.ZodString, z.ZodNull]>;
    }, "strip", z.ZodTypeAny, {
        path?: string;
        pathParams?: z.objectOutputType<{}, z.ZodString, "strip">;
        method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS";
        query?: z.objectOutputType<{}, z.ZodString, "strip">;
        headers?: z.objectOutputType<{}, z.ZodString, "strip">;
        body?: string;
    }, {
        path?: string;
        pathParams?: z.objectInputType<{}, z.ZodString, "strip">;
        method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS";
        query?: z.objectInputType<{}, z.ZodString, "strip">;
        headers?: z.objectInputType<{}, z.ZodString, "strip">;
        body?: string;
    }>;
    id: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
    type?: "http_request";
    request?: {
        path?: string;
        pathParams?: z.objectOutputType<{}, z.ZodString, "strip">;
        method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS";
        query?: z.objectOutputType<{}, z.ZodString, "strip">;
        headers?: z.objectOutputType<{}, z.ZodString, "strip">;
        body?: string;
    };
    id?: number;
}, {
    type?: "http_request";
    request?: {
        path?: string;
        pathParams?: z.objectInputType<{}, z.ZodString, "strip">;
        method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS";
        query?: z.objectInputType<{}, z.ZodString, "strip">;
        headers?: z.objectInputType<{}, z.ZodString, "strip">;
        body?: string;
    };
    id?: number;
}>;
export interface WebsocketHttpResponseMessage {
    type: 'http_response';
    /**
     * The ID of the request that this response is for.
     */
    id: number;
    /**
     * The response.
     */
    response: GenericHttpResponse;
}
export interface WebsocketHttpPartialResponseMessage {
    type: 'http_partial_response';
    /**
     * The ID of the request that this response is for.
     */
    id: number;
    /**
     * The index of the partial response.
     */
    index: number;
    /**
     * Whether this message is the final message.
     * If true, then the response will be omitted.
     */
    final?: boolean;
    /**
     * The response.
     */
    response?: Partial<GenericHttpResponse>;
}
/**
 * Defines an event which indicates that some arbitrary updates where added for the given branch.
 */
export interface UpdatesReceivedMessage {
    type: 'repo/updates_received';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The branch that the updates were received for.
     */
    branch: string;
    /**
     * The ID that was included in the original "add update" event.
     */
    updateId: number;
    /**
     * The error code that occurred.
     * If omitted, then no error occurred.
     */
    errorCode?: 'max_size_reached' | 'record_not_found' | 'inst_not_found';
    /**
     * The maximum allowed size for the inst.
     * Only included when the errorCode is set to "max_size_reached".
     */
    maxBranchSizeInBytes?: number;
    /**
     * The size that the inst would be at if the updates were added.
     * Only included when the errorCode is set to "max_size_reached".
     */
    neededBranchSizeInBytes?: number;
}
export declare const updatesReceivedMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"repo/updates_received">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    updateId: z.ZodNumber;
    errorCode: z.ZodOptional<z.ZodEnum<["max_size_reached", "record_not_found", "inst_not_found"]>>;
    maxBranchSizeInBytes: z.ZodOptional<z.ZodNumber>;
    neededBranchSizeInBytes: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
    type?: "repo/updates_received";
    recordName?: string;
    inst?: string;
    branch?: string;
    updateId?: number;
    errorCode?: "record_not_found" | "inst_not_found" | "max_size_reached";
    maxBranchSizeInBytes?: number;
    neededBranchSizeInBytes?: number;
}, {
    type?: "repo/updates_received";
    recordName?: string;
    inst?: string;
    branch?: string;
    updateId?: number;
    errorCode?: "record_not_found" | "inst_not_found" | "max_size_reached";
    maxBranchSizeInBytes?: number;
    neededBranchSizeInBytes?: number;
}>;
/**
 * Sends the given remote action to devices connected to the given branch.
 */
export interface SendActionMessage {
    type: 'repo/send_action';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The branch.
     */
    branch: string;
    /**
     * The action to send.
     */
    action: RemoteAction | RemoteActionResult | RemoteActionError;
}
export declare const sendActionMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"repo/send_action">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    action: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
        connectionId: z.ZodOptional<z.ZodString>;
        sessionId: z.ZodOptional<z.ZodString>;
        userId: z.ZodOptional<z.ZodString>;
        broadcast: z.ZodOptional<z.ZodBoolean>;
        type: z.ZodLiteral<"remote">;
        event: z.ZodAny;
        allowBatching: z.ZodOptional<z.ZodBoolean>;
        taskId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
    }, "strip", z.ZodTypeAny, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote";
        event?: any;
        allowBatching?: boolean;
        taskId?: string | number;
    }, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote";
        event?: any;
        allowBatching?: boolean;
        taskId?: string | number;
    }>, z.ZodObject<{
        connectionId: z.ZodOptional<z.ZodString>;
        sessionId: z.ZodOptional<z.ZodString>;
        userId: z.ZodOptional<z.ZodString>;
        broadcast: z.ZodOptional<z.ZodBoolean>;
        type: z.ZodLiteral<"remote_result">;
        result: z.ZodOptional<z.ZodAny>;
        taskId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
    }, "strip", z.ZodTypeAny, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_result";
        result?: any;
        taskId?: string | number;
    }, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_result";
        result?: any;
        taskId?: string | number;
    }>, z.ZodObject<{
        connectionId: z.ZodOptional<z.ZodString>;
        sessionId: z.ZodOptional<z.ZodString>;
        userId: z.ZodOptional<z.ZodString>;
        broadcast: z.ZodOptional<z.ZodBoolean>;
        type: z.ZodLiteral<"remote_error">;
        error: z.ZodAny;
        taskId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
    }, "strip", z.ZodTypeAny, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_error";
        error?: any;
        taskId?: string | number;
    }, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_error";
        error?: any;
        taskId?: string | number;
    }>]>;
}, "strip", z.ZodTypeAny, {
    type?: "repo/send_action";
    recordName?: string;
    inst?: string;
    branch?: string;
    action?: {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote";
        event?: any;
        allowBatching?: boolean;
        taskId?: string | number;
    } | {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_result";
        result?: any;
        taskId?: string | number;
    } | {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_error";
        error?: any;
        taskId?: string | number;
    };
}, {
    type?: "repo/send_action";
    recordName?: string;
    inst?: string;
    branch?: string;
    action?: {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote";
        event?: any;
        allowBatching?: boolean;
        taskId?: string | number;
    } | {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_result";
        result?: any;
        taskId?: string | number;
    } | {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_error";
        error?: any;
        taskId?: string | number;
    };
}>;
/**
 * Sends the given device action to devices connected to the given branch.
 */
export interface ReceiveDeviceActionMessage {
    type: 'repo/receive_action';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The branch that the action is for.
     */
    branch: string;
    /**
     * The action that should be sent.
     */
    action: DeviceAction | DeviceActionResult | DeviceActionError;
}
export declare const receiveDeviceActionMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"repo/receive_action">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    action: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
        type: z.ZodLiteral<"device">;
        connection: z.ZodObject<{
            connectionId: z.ZodString;
            sessionId: z.ZodString;
            userId: z.ZodString;
        }, "strip", z.ZodTypeAny, {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        }, {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        }>;
        event: z.ZodAny;
        taskId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
    }, "strip", z.ZodTypeAny, {
        type?: "device";
        connection?: {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        };
        event?: any;
        taskId?: string | number;
    }, {
        type?: "device";
        connection?: {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        };
        event?: any;
        taskId?: string | number;
    }>, z.ZodObject<{
        type: z.ZodLiteral<"device_result">;
        result: z.ZodAny;
        taskId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
        connection: z.ZodObject<{
            connectionId: z.ZodString;
            sessionId: z.ZodString;
            userId: z.ZodString;
        }, "strip", z.ZodTypeAny, {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        }, {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        }>;
    }, "strip", z.ZodTypeAny, {
        type?: "device_result";
        result?: any;
        taskId?: string | number;
        connection?: {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        };
    }, {
        type?: "device_result";
        result?: any;
        taskId?: string | number;
        connection?: {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        };
    }>, z.ZodObject<{
        type: z.ZodLiteral<"device_error">;
        error: z.ZodAny;
        taskId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
        connection: z.ZodObject<{
            connectionId: z.ZodString;
            sessionId: z.ZodString;
            userId: z.ZodString;
        }, "strip", z.ZodTypeAny, {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        }, {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        }>;
    }, "strip", z.ZodTypeAny, {
        type?: "device_error";
        error?: any;
        taskId?: string | number;
        connection?: {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        };
    }, {
        type?: "device_error";
        error?: any;
        taskId?: string | number;
        connection?: {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        };
    }>]>;
}, "strip", z.ZodTypeAny, {
    type?: "repo/receive_action";
    recordName?: string;
    inst?: string;
    branch?: string;
    action?: {
        type?: "device";
        connection?: {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        };
        event?: any;
        taskId?: string | number;
    } | {
        type?: "device_result";
        result?: any;
        taskId?: string | number;
        connection?: {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        };
    } | {
        type?: "device_error";
        error?: any;
        taskId?: string | number;
        connection?: {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        };
    };
}, {
    type?: "repo/receive_action";
    recordName?: string;
    inst?: string;
    branch?: string;
    action?: {
        type?: "device";
        connection?: {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        };
        event?: any;
        taskId?: string | number;
    } | {
        type?: "device_result";
        result?: any;
        taskId?: string | number;
        connection?: {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        };
    } | {
        type?: "device_error";
        error?: any;
        taskId?: string | number;
        connection?: {
            connectionId?: string;
            sessionId?: string;
            userId?: string;
        };
    };
}>;
/**
 * Defines an event which indicates that a connection has been made to a branch.
 */
export interface ConnectedToBranchMessage {
    type: 'repo/connected_to_branch';
    /**
     * Whether this event is for WATCH_DEVICES listeners or WATCH_BRANCH_DEVICES listeners.
     * If true, then listeners for a specific branch should ignore the event.
     */
    broadcast: boolean;
    /**
     * The name of the branch that was connected.
     */
    branch: WatchBranchMessage;
    /**
     * The info of session that connected.
     */
    connection: ConnectionInfo;
}
export declare const connectedToBranchMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"repo/connected_to_branch">;
    broadcast: z.ZodBoolean;
    branch: z.ZodObject<{
        type: z.ZodLiteral<"repo/watch_branch">;
        recordName: z.ZodNullable<z.ZodString>;
        inst: z.ZodString;
        branch: z.ZodString;
        temporary: z.ZodOptional<z.ZodBoolean>;
    }, "strip", z.ZodTypeAny, {
        type?: "repo/watch_branch";
        recordName?: string;
        inst?: string;
        branch?: string;
        temporary?: boolean;
    }, {
        type?: "repo/watch_branch";
        recordName?: string;
        inst?: string;
        branch?: string;
        temporary?: boolean;
    }>;
    connection: z.ZodObject<{
        connectionId: z.ZodString;
        sessionId: z.ZodString;
        userId: z.ZodString;
    }, "strip", z.ZodTypeAny, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
    }, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
    }>;
}, "strip", z.ZodTypeAny, {
    type?: "repo/connected_to_branch";
    broadcast?: boolean;
    branch?: {
        type?: "repo/watch_branch";
        recordName?: string;
        inst?: string;
        branch?: string;
        temporary?: boolean;
    };
    connection?: {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
    };
}, {
    type?: "repo/connected_to_branch";
    broadcast?: boolean;
    branch?: {
        type?: "repo/watch_branch";
        recordName?: string;
        inst?: string;
        branch?: string;
        temporary?: boolean;
    };
    connection?: {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
    };
}>;
/**
 * Defines an event which indicates that a connection has been removed from a branch.
 */
export interface DisconnectedFromBranchMessage {
    type: 'repo/disconnected_from_branch';
    /**
     * Whether this event is for WATCH_DEVICES listeners or WATCH_BRANCH_DEVICES listeners.
     * If true, then listeners for a specific branch should ignore the event.
     */
    broadcast: boolean;
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     */
    inst: string;
    /**
     * The name of the branch that was disconnected.
     */
    branch: string;
    /**
     * The info of session that disconnected.
     */
    connection: ConnectionInfo;
}
export declare const disconnectedFromBranchMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"repo/disconnected_from_branch">;
    broadcast: z.ZodBoolean;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    connection: z.ZodObject<{
        connectionId: z.ZodString;
        sessionId: z.ZodString;
        userId: z.ZodString;
    }, "strip", z.ZodTypeAny, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
    }, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
    }>;
}, "strip", z.ZodTypeAny, {
    type?: "repo/disconnected_from_branch";
    broadcast?: boolean;
    recordName?: string;
    inst?: string;
    branch?: string;
    connection?: {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
    };
}, {
    type?: "repo/disconnected_from_branch";
    broadcast?: boolean;
    recordName?: string;
    inst?: string;
    branch?: string;
    connection?: {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
    };
}>;
export interface ConnectionCountMessage {
    type: 'repo/connection_count';
    /**
     * The name of the record that the branch is for.
     * Null if the branch should be public and non-permanent.
     */
    recordName: string | null;
    /**
     * The name of the inst.
     * Null if all connections should be counted.
     */
    inst: string | null;
    /**
     * The name of the branch.
     * Null if all connections should be counted.
     */
    branch: string | null;
    /**
     * The number of connections.
     */
    count?: number;
}
export declare const connectionCountMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"repo/connection_count">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodNullable<z.ZodString>;
    branch: z.ZodNullable<z.ZodString>;
    count: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
    type?: "repo/connection_count";
    recordName?: string;
    inst?: string;
    branch?: string;
    count?: number;
}, {
    type?: "repo/connection_count";
    recordName?: string;
    inst?: string;
    branch?: string;
    count?: number;
}>;
/**
 * Defines an event which attempts to perform a time sync.
 */
export interface TimeSyncRequestMessage {
    type: 'sync/time';
    /**
     * The ID of the sync request.
     */
    id: number;
    /**
     * The client time in miliseconds since Jan 1 1970 UTC-0 that the request was made at.
     */
    clientRequestTime: number;
}
export declare const timeSyncRequestMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"sync/time">;
    id: z.ZodNumber;
    clientRequestTime: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
    type?: "sync/time";
    id?: number;
    clientRequestTime?: number;
}, {
    type?: "sync/time";
    id?: number;
    clientRequestTime?: number;
}>;
/**
 * Defines an event which is the response for a time sync.
 */
export interface TimeSyncResponseMessage {
    type: 'sync/time/response';
    /**
     * The ID of the sync request.
     */
    id: number;
    /**
     * The client time in miliseconds since Jan 1 1970 UTC-0 that the request was made at.
     */
    clientRequestTime: number;
    /**
     * The time that the server received the request at in miliseconds since Jan 1 1970 UTC-0.
     */
    serverReceiveTime: number;
    /**
     * The time that the server sent this response at in miliseconds since Jan 1 1970 UTC-0.
     */
    serverTransmitTime: number;
}
export declare const timeSyncResponseMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"sync/time/response">;
    id: z.ZodNumber;
    clientRequestTime: z.ZodNumber;
    serverReceiveTime: z.ZodNumber;
    serverTransmitTime: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
    type?: "sync/time/response";
    id?: number;
    clientRequestTime?: number;
    serverReceiveTime?: number;
    serverTransmitTime?: number;
}, {
    type?: "sync/time/response";
    id?: number;
    clientRequestTime?: number;
    serverReceiveTime?: number;
    serverTransmitTime?: number;
}>;
export interface RequestMissingPermissionMessage {
    type: 'permission/request/missing';
    /**
     * The permission that should be requested.
     */
    reason: AuthorizeActionMissingPermission;
    /**
     * The info of session that requested the permission.
     */
    connection?: ConnectionInfo;
    /**
     * The info about the user that is requesting the permission.
     */
    user?: PublicUserInfo;
}
export declare const requestMissingPermissionMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"permission/request/missing">;
    reason: z.ZodObject<{
        type: z.ZodLiteral<"missing_permission">;
        recordName: z.ZodString;
        resourceKind: z.ZodEnum<["data", "file", "event", "marker", "role", "inst", "loom", "ai.sloyd", "ai.hume", "ai.openai.realtime", "webhook", "notification", "package", "package.version", "search"]>;
        resourceId: z.ZodString;
        action: z.ZodEnum<["create", "read", "update", "updateData", "delete", "list", "sendAction", "assign", "unassign", "grant", "revoke", "increment", "count", "grantPermission", "revokePermission", "run", "send", "subscribe", "unsubscribe", "listSubscriptions"]>;
        subjectType: z.ZodEnum<["user", "inst", "role"]>;
        subjectId: z.ZodString;
    }, "strip", z.ZodTypeAny, {
        type?: "missing_permission";
        recordName?: string;
        resourceKind?: "search" | "inst" | "data" | "event" | "role" | "file" | "marker" | "loom" | "ai.sloyd" | "ai.hume" | "ai.openai.realtime" | "webhook" | "notification" | "package" | "package.version";
        resourceId?: string;
        action?: "create" | "read" | "update" | "delete" | "assign" | "unassign" | "increment" | "count" | "list" | "grantPermission" | "revokePermission" | "grant" | "revoke" | "sendAction" | "updateData" | "run" | "send" | "subscribe" | "unsubscribe" | "listSubscriptions";
        subjectType?: "inst" | "user" | "role";
        subjectId?: string;
    }, {
        type?: "missing_permission";
        recordName?: string;
        resourceKind?: "search" | "inst" | "data" | "event" | "role" | "file" | "marker" | "loom" | "ai.sloyd" | "ai.hume" | "ai.openai.realtime" | "webhook" | "notification" | "package" | "package.version";
        resourceId?: string;
        action?: "create" | "read" | "update" | "delete" | "assign" | "unassign" | "increment" | "count" | "list" | "grantPermission" | "revokePermission" | "grant" | "revoke" | "sendAction" | "updateData" | "run" | "send" | "subscribe" | "unsubscribe" | "listSubscriptions";
        subjectType?: "inst" | "user" | "role";
        subjectId?: string;
    }>;
}, "strip", z.ZodTypeAny, {
    type?: "permission/request/missing";
    reason?: {
        type?: "missing_permission";
        recordName?: string;
        resourceKind?: "search" | "inst" | "data" | "event" | "role" | "file" | "marker" | "loom" | "ai.sloyd" | "ai.hume" | "ai.openai.realtime" | "webhook" | "notification" | "package" | "package.version";
        resourceId?: string;
        action?: "create" | "read" | "update" | "delete" | "assign" | "unassign" | "increment" | "count" | "list" | "grantPermission" | "revokePermission" | "grant" | "revoke" | "sendAction" | "updateData" | "run" | "send" | "subscribe" | "unsubscribe" | "listSubscriptions";
        subjectType?: "inst" | "user" | "role";
        subjectId?: string;
    };
}, {
    type?: "permission/request/missing";
    reason?: {
        type?: "missing_permission";
        recordName?: string;
        resourceKind?: "search" | "inst" | "data" | "event" | "role" | "file" | "marker" | "loom" | "ai.sloyd" | "ai.hume" | "ai.openai.realtime" | "webhook" | "notification" | "package" | "package.version";
        resourceId?: string;
        action?: "create" | "read" | "update" | "delete" | "assign" | "unassign" | "increment" | "count" | "list" | "grantPermission" | "revokePermission" | "grant" | "revoke" | "sendAction" | "updateData" | "run" | "send" | "subscribe" | "unsubscribe" | "listSubscriptions";
        subjectType?: "inst" | "user" | "role";
        subjectId?: string;
    };
}>;
export type RequestMissingPermissionResponseMessage = RequestMissingPermissionResponseSuccessMessage | RequestMissingPermissionResponseFailureMessage;
export interface RequestMissingPermissionResponseSuccessMessage {
    type: 'permission/request/missing/response';
    success: true;
    recordName: string;
    resourceKind: ResourceKinds;
    resourceId: string;
    subjectType: SubjectType;
    subjectId: string;
    /**
     * The connection that responded to the request.
     */
    connection?: ConnectionInfo;
}
export interface RequestMissingPermissionResponseFailureMessage {
    type: 'permission/request/missing/response';
    success: false;
    recordName: string;
    resourceKind: ResourceKinds;
    resourceId: string;
    subjectType: SubjectType;
    subjectId: string;
    errorCode: WebsocketErrorCode;
    errorMessage: string;
    /**
     * The connection that responded to the request.
     */
    connection?: ConnectionInfo;
}
export declare const requestMissingPermissionResponseMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"permission/request/missing/response">;
    success: z.ZodBoolean;
    recordName: z.ZodString;
    resourceKind: z.ZodEnum<["data", "file", "event", "marker", "role", "inst", "loom", "ai.sloyd", "ai.hume", "ai.openai.realtime", "webhook", "notification", "package", "package.version", "search"]>;
    resourceId: z.ZodString;
    subjectType: z.ZodEnum<["user", "inst", "role"]>;
    subjectId: z.ZodString;
    errorCode: z.ZodOptional<z.ZodString>;
    errorMessage: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
    type?: "permission/request/missing/response";
    success?: boolean;
    recordName?: string;
    resourceKind?: "search" | "inst" | "data" | "event" | "role" | "file" | "marker" | "loom" | "ai.sloyd" | "ai.hume" | "ai.openai.realtime" | "webhook" | "notification" | "package" | "package.version";
    resourceId?: string;
    subjectType?: "inst" | "user" | "role";
    subjectId?: string;
    errorCode?: string;
    errorMessage?: string;
}, {
    type?: "permission/request/missing/response";
    success?: boolean;
    recordName?: string;
    resourceKind?: "search" | "inst" | "data" | "event" | "role" | "file" | "marker" | "loom" | "ai.sloyd" | "ai.hume" | "ai.openai.realtime" | "webhook" | "notification" | "package" | "package.version";
    resourceId?: string;
    subjectType?: "inst" | "user" | "role";
    subjectId?: string;
    errorCode?: string;
    errorMessage?: string;
}>;
export interface RateLimitExceededMessage {
    type: 'rate_limit_exceeded';
    retryAfter: number;
    totalHits: number;
}
export declare const rateLimitExceededMessageSchema: z.ZodObject<{
    type: z.ZodLiteral<"rate_limit_exceeded">;
    retryAfter: z.ZodNumber;
    totalHits: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
    type?: "rate_limit_exceeded";
    retryAfter?: number;
    totalHits?: number;
}, {
    type?: "rate_limit_exceeded";
    retryAfter?: number;
    totalHits?: number;
}>;
export declare const websocketRequestMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
    type: z.ZodLiteral<"login">;
    connectionToken: z.ZodOptional<z.ZodString>;
    connectionId: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
    type?: "login";
    connectionToken?: string;
    connectionId?: string;
}, {
    type?: "login";
    connectionToken?: string;
    connectionId?: string;
}>, z.ZodObject<{
    type: z.ZodLiteral<"repo/watch_branch">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    temporary: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
    type?: "repo/watch_branch";
    recordName?: string;
    inst?: string;
    branch?: string;
    temporary?: boolean;
}, {
    type?: "repo/watch_branch";
    recordName?: string;
    inst?: string;
    branch?: string;
    temporary?: boolean;
}>, z.ZodObject<{
    type: z.ZodLiteral<"repo/unwatch_branch">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, "strip", z.ZodTypeAny, {
    type?: "repo/unwatch_branch";
    recordName?: string;
    inst?: string;
    branch?: string;
}, {
    type?: "repo/unwatch_branch";
    recordName?: string;
    inst?: string;
    branch?: string;
}>, z.ZodObject<{
    type: z.ZodLiteral<"repo/add_updates">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    updates: z.ZodArray<z.ZodString, "many">;
    updateId: z.ZodOptional<z.ZodNumber>;
    initial: z.ZodOptional<z.ZodBoolean>;
    timestamps: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
}, "strip", z.ZodTypeAny, {
    type?: "repo/add_updates";
    recordName?: string;
    inst?: string;
    branch?: string;
    updates?: string[];
    updateId?: number;
    initial?: boolean;
    timestamps?: number[];
}, {
    type?: "repo/add_updates";
    recordName?: string;
    inst?: string;
    branch?: string;
    updates?: string[];
    updateId?: number;
    initial?: boolean;
    timestamps?: number[];
}>, z.ZodObject<{
    type: z.ZodLiteral<"repo/send_action">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
    action: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
        connectionId: z.ZodOptional<z.ZodString>;
        sessionId: z.ZodOptional<z.ZodString>;
        userId: z.ZodOptional<z.ZodString>;
        broadcast: z.ZodOptional<z.ZodBoolean>;
        type: z.ZodLiteral<"remote">;
        event: z.ZodAny;
        allowBatching: z.ZodOptional<z.ZodBoolean>;
        taskId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
    }, "strip", z.ZodTypeAny, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote";
        event?: any;
        allowBatching?: boolean;
        taskId?: string | number;
    }, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote";
        event?: any;
        allowBatching?: boolean;
        taskId?: string | number;
    }>, z.ZodObject<{
        connectionId: z.ZodOptional<z.ZodString>;
        sessionId: z.ZodOptional<z.ZodString>;
        userId: z.ZodOptional<z.ZodString>;
        broadcast: z.ZodOptional<z.ZodBoolean>;
        type: z.ZodLiteral<"remote_result">;
        result: z.ZodOptional<z.ZodAny>;
        taskId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
    }, "strip", z.ZodTypeAny, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_result";
        result?: any;
        taskId?: string | number;
    }, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_result";
        result?: any;
        taskId?: string | number;
    }>, z.ZodObject<{
        connectionId: z.ZodOptional<z.ZodString>;
        sessionId: z.ZodOptional<z.ZodString>;
        userId: z.ZodOptional<z.ZodString>;
        broadcast: z.ZodOptional<z.ZodBoolean>;
        type: z.ZodLiteral<"remote_error">;
        error: z.ZodAny;
        taskId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
    }, "strip", z.ZodTypeAny, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_error";
        error?: any;
        taskId?: string | number;
    }, {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_error";
        error?: any;
        taskId?: string | number;
    }>]>;
}, "strip", z.ZodTypeAny, {
    type?: "repo/send_action";
    recordName?: string;
    inst?: string;
    branch?: string;
    action?: {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote";
        event?: any;
        allowBatching?: boolean;
        taskId?: string | number;
    } | {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_result";
        result?: any;
        taskId?: string | number;
    } | {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_error";
        error?: any;
        taskId?: string | number;
    };
}, {
    type?: "repo/send_action";
    recordName?: string;
    inst?: string;
    branch?: string;
    action?: {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote";
        event?: any;
        allowBatching?: boolean;
        taskId?: string | number;
    } | {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_result";
        result?: any;
        taskId?: string | number;
    } | {
        connectionId?: string;
        sessionId?: string;
        userId?: string;
        broadcast?: boolean;
        type?: "remote_error";
        error?: any;
        taskId?: string | number;
    };
}>, z.ZodObject<{
    type: z.ZodLiteral<"repo/watch_branch_devices">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, "strip", z.ZodTypeAny, {
    type?: "repo/watch_branch_devices";
    recordName?: string;
    inst?: string;
    branch?: string;
}, {
    type?: "repo/watch_branch_devices";
    recordName?: string;
    inst?: string;
    branch?: string;
}>, z.ZodObject<{
    type: z.ZodLiteral<"repo/unwatch_branch_devices">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, "strip", z.ZodTypeAny, {
    type?: "repo/unwatch_branch_devices";
    recordName?: string;
    inst?: string;
    branch?: string;
}, {
    type?: "repo/unwatch_branch_devices";
    recordName?: string;
    inst?: string;
    branch?: string;
}>, z.ZodObject<{
    type: z.ZodLiteral<"repo/connection_count">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodNullable<z.ZodString>;
    branch: z.ZodNullable<z.ZodString>;
    count: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
    type?: "repo/connection_count";
    recordName?: string;
    inst?: string;
    branch?: string;
    count?: number;
}, {
    type?: "repo/connection_count";
    recordName?: string;
    inst?: string;
    branch?: string;
    count?: number;
}>, z.ZodObject<{
    type: z.ZodLiteral<"sync/time">;
    id: z.ZodNumber;
    clientRequestTime: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
    type?: "sync/time";
    id?: number;
    clientRequestTime?: number;
}, {
    type?: "sync/time";
    id?: number;
    clientRequestTime?: number;
}>, z.ZodObject<{
    type: z.ZodLiteral<"repo/get_updates">;
    recordName: z.ZodNullable<z.ZodString>;
    inst: z.ZodString;
    branch: z.ZodString;
}, "strip", z.ZodTypeAny, {
    type?: "repo/get_updates";
    recordName?: string;
    inst?: string;
    branch?: string;
}, {
    type?: "repo/get_updates";
    recordName?: string;
    inst?: string;
    branch?: string;
}>, z.ZodObject<{
    type: z.ZodLiteral<"http_request">;
    request: z.ZodObject<{
        path: z.ZodString;
        pathParams: z.ZodObject<{}, "strip", z.ZodString, z.objectOutputType<{}, z.ZodString, "strip">, z.objectInputType<{}, z.ZodString, "strip">>;
        method: z.ZodUnion<[z.ZodLiteral<"GET">, z.ZodLiteral<"POST">, z.ZodLiteral<"PUT">, z.ZodLiteral<"DELETE">, z.ZodLiteral<"HEAD">, z.ZodLiteral<"OPTIONS">]>;
        query: z.ZodObject<{}, "strip", z.ZodString, z.objectOutputType<{}, z.ZodString, "strip">, z.objectInputType<{}, z.ZodString, "strip">>;
        headers: z.ZodObject<{}, "strip", z.ZodString, z.objectOutputType<{}, z.ZodString, "strip">, z.objectInputType<{}, z.ZodString, "strip">>;
        body: z.ZodUnion<[z.ZodString, z.ZodNull]>;
    }, "strip", z.ZodTypeAny, {
        path?: string;
        pathParams?: z.objectOutputType<{}, z.ZodString, "strip">;
        method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS";
        query?: z.objectOutputType<{}, z.ZodString, "strip">;
        headers?: z.objectOutputType<{}, z.ZodString, "strip">;
        body?: string;
    }, {
        path?: string;
        pathParams?: z.objectInputType<{}, z.ZodString, "strip">;
        method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS";
        query?: z.objectInputType<{}, z.ZodString, "strip">;
        headers?: z.objectInputType<{}, z.ZodString, "strip">;
        body?: string;
    }>;
    id: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
    type?: "http_request";
    request?: {
        path?: string;
        pathParams?: z.objectOutputType<{}, z.ZodString, "strip">;
        method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS";
        query?: z.objectOutputType<{}, z.ZodString, "strip">;
        headers?: z.objectOutputType<{}, z.ZodString, "strip">;
        body?: string;
    };
    id?: number;
}, {
    type?: "http_request";
    request?: {
        path?: string;
        pathParams?: z.objectInputType<{}, z.ZodString, "strip">;
        method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS";
        query?: z.objectInputType<{}, z.ZodString, "strip">;
        headers?: z.objectInputType<{}, z.ZodString, "strip">;
        body?: string;
    };
    id?: number;
}>, z.ZodObject<{
    type: z.ZodLiteral<"permission/request/missing">;
    reason: z.ZodObject<{
        type: z.ZodLiteral<"missing_permission">;
        recordName: z.ZodString;
        resourceKind: z.ZodEnum<["data", "file", "event", "marker", "role", "inst", "loom", "ai.sloyd", "ai.hume", "ai.openai.realtime", "webhook", "notification", "package", "package.version", "search"]>;
        resourceId: z.ZodString;
        action: z.ZodEnum<["create", "read", "update", "updateData", "delete", "list", "sendAction", "assign", "unassign", "grant", "revoke", "increment", "count", "grantPermission", "revokePermission", "run", "send", "subscribe", "unsubscribe", "listSubscriptions"]>;
        subjectType: z.ZodEnum<["user", "inst", "role"]>;
        subjectId: z.ZodString;
    }, "strip", z.ZodTypeAny, {
        type?: "missing_permission";
        recordName?: string;
        resourceKind?: "search" | "inst" | "data" | "event" | "role" | "file" | "marker" | "loom" | "ai.sloyd" | "ai.hume" | "ai.openai.realtime" | "webhook" | "notification" | "package" | "package.version";
        resourceId?: string;
        action?: "create" | "read" | "update" | "delete" | "assign" | "unassign" | "increment" | "count" | "list" | "grantPermission" | "revokePermission" | "grant" | "revoke" | "sendAction" | "updateData" | "run" | "send" | "subscribe" | "unsubscribe" | "listSubscriptions";
        subjectType?: "inst" | "user" | "role";
        subjectId?: string;
    }, {
        type?: "missing_permission";
        recordName?: string;
        resourceKind?: "search" | "inst" | "data" | "event" | "role" | "file" | "marker" | "loom" | "ai.sloyd" | "ai.hume" | "ai.openai.realtime" | "webhook" | "notification" | "package" | "package.version";
        resourceId?: string;
        action?: "create" | "read" | "update" | "delete" | "assign" | "unassign" | "increment" | "count" | "list" | "grantPermission" | "revokePermission" | "grant" | "revoke" | "sendAction" | "updateData" | "run" | "send" | "subscribe" | "unsubscribe" | "listSubscriptions";
        subjectType?: "inst" | "user" | "role";
        subjectId?: string;
    }>;
}, "strip", z.ZodTypeAny, {
    type?: "permission/request/missing";
    reason?: {
        type?: "missing_permission";
        recordName?: string;
        resourceKind?: "search" | "inst" | "data" | "event" | "role" | "file" | "marker" | "loom" | "ai.sloyd" | "ai.hume" | "ai.openai.realtime" | "webhook" | "notification" | "package" | "package.version";
        resourceId?: string;
        action?: "create" | "read" | "update" | "delete" | "assign" | "unassign" | "increment" | "count" | "list" | "grantPermission" | "revokePermission" | "grant" | "revoke" | "sendAction" | "updateData" | "run" | "send" | "subscribe" | "unsubscribe" | "listSubscriptions";
        subjectType?: "inst" | "user" | "role";
        subjectId?: string;
    };
}, {
    type?: "permission/request/missing";
    reason?: {
        type?: "missing_permission";
        recordName?: string;
        resourceKind?: "search" | "inst" | "data" | "event" | "role" | "file" | "marker" | "loom" | "ai.sloyd" | "ai.hume" | "ai.openai.realtime" | "webhook" | "notification" | "package" | "package.version";
        resourceId?: string;
        action?: "create" | "read" | "update" | "delete" | "assign" | "unassign" | "increment" | "count" | "list" | "grantPermission" | "revokePermission" | "grant" | "revoke" | "sendAction" | "updateData" | "run" | "send" | "subscribe" | "unsubscribe" | "listSubscriptions";
        subjectType?: "inst" | "user" | "role";
        subjectId?: string;
    };
}>, z.ZodObject<{
    type: z.ZodLiteral<"permission/request/missing/response">;
    success: z.ZodBoolean;
    recordName: z.ZodString;
    resourceKind: z.ZodEnum<["data", "file", "event", "marker", "role", "inst", "loom", "ai.sloyd", "ai.hume", "ai.openai.realtime", "webhook", "notification", "package", "package.version", "search"]>;
    resourceId: z.ZodString;
    subjectType: z.ZodEnum<["user", "inst", "role"]>;
    subjectId: z.ZodString;
    errorCode: z.ZodOptional<z.ZodString>;
    errorMessage: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
    type?: "permission/request/missing/response";
    success?: boolean;
    recordName?: string;
    resourceKind?: "search" | "inst" | "data" | "event" | "role" | "file" | "marker" | "loom" | "ai.sloyd" | "ai.hume" | "ai.openai.realtime" | "webhook" | "notification" | "package" | "package.version";
    resourceId?: string;
    subjectType?: "inst" | "user" | "role";
    subjectId?: string;
    errorCode?: string;
    errorMessage?: string;
}, {
    type?: "permission/request/missing/response";
    success?: boolean;
    recordName?: string;
    resourceKind?: "search" | "inst" | "data" | "event" | "role" | "file" | "marker" | "loom" | "ai.sloyd" | "ai.hume" | "ai.openai.realtime" | "webhook" | "notification" | "package" | "package.version";
    resourceId?: string;
    subjectType?: "inst" | "user" | "role";
    subjectId?: string;
    errorCode?: string;
    errorMessage?: string;
}>]>;
//# sourceMappingURL=WebsocketEvents.d.ts.map