// dist/schemas/actor-inspector/v3.ts
import * as bare from "@rivetkit/bare-ts";
var config = /* @__PURE__ */ bare.Config({});
function readPatchStateRequest(bc) {
  return {
    state: bare.readData(bc)
  };
}
function writePatchStateRequest(bc, x) {
  bare.writeData(bc, x.state);
}
function readActionRequest(bc) {
  return {
    id: bare.readUint(bc),
    name: bare.readString(bc),
    args: bare.readData(bc)
  };
}
function writeActionRequest(bc, x) {
  bare.writeUint(bc, x.id);
  bare.writeString(bc, x.name);
  bare.writeData(bc, x.args);
}
function readStateRequest(bc) {
  return {
    id: bare.readUint(bc)
  };
}
function writeStateRequest(bc, x) {
  bare.writeUint(bc, x.id);
}
function readConnectionsRequest(bc) {
  return {
    id: bare.readUint(bc)
  };
}
function writeConnectionsRequest(bc, x) {
  bare.writeUint(bc, x.id);
}
function readRpcsListRequest(bc) {
  return {
    id: bare.readUint(bc)
  };
}
function writeRpcsListRequest(bc, x) {
  bare.writeUint(bc, x.id);
}
function readTraceQueryRequest(bc) {
  return {
    id: bare.readUint(bc),
    startMs: bare.readUint(bc),
    endMs: bare.readUint(bc),
    limit: bare.readUint(bc)
  };
}
function writeTraceQueryRequest(bc, x) {
  bare.writeUint(bc, x.id);
  bare.writeUint(bc, x.startMs);
  bare.writeUint(bc, x.endMs);
  bare.writeUint(bc, x.limit);
}
function readQueueRequest(bc) {
  return {
    id: bare.readUint(bc),
    limit: bare.readUint(bc)
  };
}
function writeQueueRequest(bc, x) {
  bare.writeUint(bc, x.id);
  bare.writeUint(bc, x.limit);
}
function readWorkflowHistoryRequest(bc) {
  return {
    id: bare.readUint(bc)
  };
}
function writeWorkflowHistoryRequest(bc, x) {
  bare.writeUint(bc, x.id);
}
function readDatabaseSchemaRequest(bc) {
  return {
    id: bare.readUint(bc)
  };
}
function writeDatabaseSchemaRequest(bc, x) {
  bare.writeUint(bc, x.id);
}
function readDatabaseTableRowsRequest(bc) {
  return {
    id: bare.readUint(bc),
    table: bare.readString(bc),
    limit: bare.readUint(bc),
    offset: bare.readUint(bc)
  };
}
function writeDatabaseTableRowsRequest(bc, x) {
  bare.writeUint(bc, x.id);
  bare.writeString(bc, x.table);
  bare.writeUint(bc, x.limit);
  bare.writeUint(bc, x.offset);
}
function readToServerBody(bc) {
  const offset = bc.offset;
  const tag = bare.readU8(bc);
  switch (tag) {
    case 0:
      return { tag: "PatchStateRequest", val: readPatchStateRequest(bc) };
    case 1:
      return { tag: "StateRequest", val: readStateRequest(bc) };
    case 2:
      return { tag: "ConnectionsRequest", val: readConnectionsRequest(bc) };
    case 3:
      return { tag: "ActionRequest", val: readActionRequest(bc) };
    case 4:
      return { tag: "RpcsListRequest", val: readRpcsListRequest(bc) };
    case 5:
      return { tag: "TraceQueryRequest", val: readTraceQueryRequest(bc) };
    case 6:
      return { tag: "QueueRequest", val: readQueueRequest(bc) };
    case 7:
      return { tag: "WorkflowHistoryRequest", val: readWorkflowHistoryRequest(bc) };
    case 8:
      return { tag: "DatabaseSchemaRequest", val: readDatabaseSchemaRequest(bc) };
    case 9:
      return { tag: "DatabaseTableRowsRequest", val: readDatabaseTableRowsRequest(bc) };
    default: {
      bc.offset = offset;
      throw new bare.BareError(offset, "invalid tag");
    }
  }
}
function writeToServerBody(bc, x) {
  switch (x.tag) {
    case "PatchStateRequest": {
      bare.writeU8(bc, 0);
      writePatchStateRequest(bc, x.val);
      break;
    }
    case "StateRequest": {
      bare.writeU8(bc, 1);
      writeStateRequest(bc, x.val);
      break;
    }
    case "ConnectionsRequest": {
      bare.writeU8(bc, 2);
      writeConnectionsRequest(bc, x.val);
      break;
    }
    case "ActionRequest": {
      bare.writeU8(bc, 3);
      writeActionRequest(bc, x.val);
      break;
    }
    case "RpcsListRequest": {
      bare.writeU8(bc, 4);
      writeRpcsListRequest(bc, x.val);
      break;
    }
    case "TraceQueryRequest": {
      bare.writeU8(bc, 5);
      writeTraceQueryRequest(bc, x.val);
      break;
    }
    case "QueueRequest": {
      bare.writeU8(bc, 6);
      writeQueueRequest(bc, x.val);
      break;
    }
    case "WorkflowHistoryRequest": {
      bare.writeU8(bc, 7);
      writeWorkflowHistoryRequest(bc, x.val);
      break;
    }
    case "DatabaseSchemaRequest": {
      bare.writeU8(bc, 8);
      writeDatabaseSchemaRequest(bc, x.val);
      break;
    }
    case "DatabaseTableRowsRequest": {
      bare.writeU8(bc, 9);
      writeDatabaseTableRowsRequest(bc, x.val);
      break;
    }
  }
}
function readToServer(bc) {
  return {
    body: readToServerBody(bc)
  };
}
function writeToServer(bc, x) {
  writeToServerBody(bc, x.body);
}
function encodeToServer(x) {
  const bc = new bare.ByteCursor(
    new Uint8Array(config.initialBufferLength),
    config
  );
  writeToServer(bc, x);
  return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
}
function decodeToServer(bytes) {
  const bc = new bare.ByteCursor(bytes, config);
  const result = readToServer(bc);
  if (bc.offset < bc.view.byteLength) {
    throw new bare.BareError(bc.offset, "remaining bytes");
  }
  return result;
}
function readState(bc) {
  return bare.readData(bc);
}
function writeState(bc, x) {
  bare.writeData(bc, x);
}
function readConnection(bc) {
  return {
    id: bare.readString(bc),
    details: bare.readData(bc)
  };
}
function writeConnection(bc, x) {
  bare.writeString(bc, x.id);
  bare.writeData(bc, x.details);
}
function readWorkflowHistory(bc) {
  return bare.readData(bc);
}
function writeWorkflowHistory(bc, x) {
  bare.writeData(bc, x);
}
function read0(bc) {
  const len = bare.readUintSafe(bc);
  if (len === 0) {
    return [];
  }
  const result = [readConnection(bc)];
  for (let i = 1; i < len; i++) {
    result[i] = readConnection(bc);
  }
  return result;
}
function write0(bc, x) {
  bare.writeUintSafe(bc, x.length);
  for (let i = 0; i < x.length; i++) {
    writeConnection(bc, x[i]);
  }
}
function read1(bc) {
  return bare.readBool(bc) ? readState(bc) : null;
}
function write1(bc, x) {
  bare.writeBool(bc, x !== null);
  if (x !== null) {
    writeState(bc, x);
  }
}
function read2(bc) {
  const len = bare.readUintSafe(bc);
  if (len === 0) {
    return [];
  }
  const result = [bare.readString(bc)];
  for (let i = 1; i < len; i++) {
    result[i] = bare.readString(bc);
  }
  return result;
}
function write2(bc, x) {
  bare.writeUintSafe(bc, x.length);
  for (let i = 0; i < x.length; i++) {
    bare.writeString(bc, x[i]);
  }
}
function read3(bc) {
  return bare.readBool(bc) ? readWorkflowHistory(bc) : null;
}
function write3(bc, x) {
  bare.writeBool(bc, x !== null);
  if (x !== null) {
    writeWorkflowHistory(bc, x);
  }
}
function readInit(bc) {
  return {
    connections: read0(bc),
    state: read1(bc),
    isStateEnabled: bare.readBool(bc),
    rpcs: read2(bc),
    isDatabaseEnabled: bare.readBool(bc),
    queueSize: bare.readUint(bc),
    workflowHistory: read3(bc),
    isWorkflowEnabled: bare.readBool(bc)
  };
}
function writeInit(bc, x) {
  write0(bc, x.connections);
  write1(bc, x.state);
  bare.writeBool(bc, x.isStateEnabled);
  write2(bc, x.rpcs);
  bare.writeBool(bc, x.isDatabaseEnabled);
  bare.writeUint(bc, x.queueSize);
  write3(bc, x.workflowHistory);
  bare.writeBool(bc, x.isWorkflowEnabled);
}
function readConnectionsResponse(bc) {
  return {
    rid: bare.readUint(bc),
    connections: read0(bc)
  };
}
function writeConnectionsResponse(bc, x) {
  bare.writeUint(bc, x.rid);
  write0(bc, x.connections);
}
function readStateResponse(bc) {
  return {
    rid: bare.readUint(bc),
    state: read1(bc),
    isStateEnabled: bare.readBool(bc)
  };
}
function writeStateResponse(bc, x) {
  bare.writeUint(bc, x.rid);
  write1(bc, x.state);
  bare.writeBool(bc, x.isStateEnabled);
}
function readActionResponse(bc) {
  return {
    rid: bare.readUint(bc),
    output: bare.readData(bc)
  };
}
function writeActionResponse(bc, x) {
  bare.writeUint(bc, x.rid);
  bare.writeData(bc, x.output);
}
function readTraceQueryResponse(bc) {
  return {
    rid: bare.readUint(bc),
    payload: bare.readData(bc)
  };
}
function writeTraceQueryResponse(bc, x) {
  bare.writeUint(bc, x.rid);
  bare.writeData(bc, x.payload);
}
function readQueueMessageSummary(bc) {
  return {
    id: bare.readUint(bc),
    name: bare.readString(bc),
    createdAtMs: bare.readUint(bc)
  };
}
function writeQueueMessageSummary(bc, x) {
  bare.writeUint(bc, x.id);
  bare.writeString(bc, x.name);
  bare.writeUint(bc, x.createdAtMs);
}
function read4(bc) {
  const len = bare.readUintSafe(bc);
  if (len === 0) {
    return [];
  }
  const result = [readQueueMessageSummary(bc)];
  for (let i = 1; i < len; i++) {
    result[i] = readQueueMessageSummary(bc);
  }
  return result;
}
function write4(bc, x) {
  bare.writeUintSafe(bc, x.length);
  for (let i = 0; i < x.length; i++) {
    writeQueueMessageSummary(bc, x[i]);
  }
}
function readQueueStatus(bc) {
  return {
    size: bare.readUint(bc),
    maxSize: bare.readUint(bc),
    messages: read4(bc),
    truncated: bare.readBool(bc)
  };
}
function writeQueueStatus(bc, x) {
  bare.writeUint(bc, x.size);
  bare.writeUint(bc, x.maxSize);
  write4(bc, x.messages);
  bare.writeBool(bc, x.truncated);
}
function readQueueResponse(bc) {
  return {
    rid: bare.readUint(bc),
    status: readQueueStatus(bc)
  };
}
function writeQueueResponse(bc, x) {
  bare.writeUint(bc, x.rid);
  writeQueueStatus(bc, x.status);
}
function readWorkflowHistoryResponse(bc) {
  return {
    rid: bare.readUint(bc),
    history: read3(bc),
    isWorkflowEnabled: bare.readBool(bc)
  };
}
function writeWorkflowHistoryResponse(bc, x) {
  bare.writeUint(bc, x.rid);
  write3(bc, x.history);
  bare.writeBool(bc, x.isWorkflowEnabled);
}
function readDatabaseSchemaResponse(bc) {
  return {
    rid: bare.readUint(bc),
    schema: bare.readData(bc)
  };
}
function writeDatabaseSchemaResponse(bc, x) {
  bare.writeUint(bc, x.rid);
  bare.writeData(bc, x.schema);
}
function readDatabaseTableRowsResponse(bc) {
  return {
    rid: bare.readUint(bc),
    result: bare.readData(bc)
  };
}
function writeDatabaseTableRowsResponse(bc, x) {
  bare.writeUint(bc, x.rid);
  bare.writeData(bc, x.result);
}
function readStateUpdated(bc) {
  return {
    state: readState(bc)
  };
}
function writeStateUpdated(bc, x) {
  writeState(bc, x.state);
}
function readQueueUpdated(bc) {
  return {
    queueSize: bare.readUint(bc)
  };
}
function writeQueueUpdated(bc, x) {
  bare.writeUint(bc, x.queueSize);
}
function readWorkflowHistoryUpdated(bc) {
  return {
    history: readWorkflowHistory(bc)
  };
}
function writeWorkflowHistoryUpdated(bc, x) {
  writeWorkflowHistory(bc, x.history);
}
function readRpcsListResponse(bc) {
  return {
    rid: bare.readUint(bc),
    rpcs: read2(bc)
  };
}
function writeRpcsListResponse(bc, x) {
  bare.writeUint(bc, x.rid);
  write2(bc, x.rpcs);
}
function readConnectionsUpdated(bc) {
  return {
    connections: read0(bc)
  };
}
function writeConnectionsUpdated(bc, x) {
  write0(bc, x.connections);
}
function readError(bc) {
  return {
    message: bare.readString(bc)
  };
}
function writeError(bc, x) {
  bare.writeString(bc, x.message);
}
function readToClientBody(bc) {
  const offset = bc.offset;
  const tag = bare.readU8(bc);
  switch (tag) {
    case 0:
      return { tag: "StateResponse", val: readStateResponse(bc) };
    case 1:
      return { tag: "ConnectionsResponse", val: readConnectionsResponse(bc) };
    case 2:
      return { tag: "ActionResponse", val: readActionResponse(bc) };
    case 3:
      return { tag: "ConnectionsUpdated", val: readConnectionsUpdated(bc) };
    case 4:
      return { tag: "QueueUpdated", val: readQueueUpdated(bc) };
    case 5:
      return { tag: "StateUpdated", val: readStateUpdated(bc) };
    case 6:
      return { tag: "WorkflowHistoryUpdated", val: readWorkflowHistoryUpdated(bc) };
    case 7:
      return { tag: "RpcsListResponse", val: readRpcsListResponse(bc) };
    case 8:
      return { tag: "TraceQueryResponse", val: readTraceQueryResponse(bc) };
    case 9:
      return { tag: "QueueResponse", val: readQueueResponse(bc) };
    case 10:
      return { tag: "WorkflowHistoryResponse", val: readWorkflowHistoryResponse(bc) };
    case 11:
      return { tag: "Error", val: readError(bc) };
    case 12:
      return { tag: "Init", val: readInit(bc) };
    case 13:
      return { tag: "DatabaseSchemaResponse", val: readDatabaseSchemaResponse(bc) };
    case 14:
      return { tag: "DatabaseTableRowsResponse", val: readDatabaseTableRowsResponse(bc) };
    default: {
      bc.offset = offset;
      throw new bare.BareError(offset, "invalid tag");
    }
  }
}
function writeToClientBody(bc, x) {
  switch (x.tag) {
    case "StateResponse": {
      bare.writeU8(bc, 0);
      writeStateResponse(bc, x.val);
      break;
    }
    case "ConnectionsResponse": {
      bare.writeU8(bc, 1);
      writeConnectionsResponse(bc, x.val);
      break;
    }
    case "ActionResponse": {
      bare.writeU8(bc, 2);
      writeActionResponse(bc, x.val);
      break;
    }
    case "ConnectionsUpdated": {
      bare.writeU8(bc, 3);
      writeConnectionsUpdated(bc, x.val);
      break;
    }
    case "QueueUpdated": {
      bare.writeU8(bc, 4);
      writeQueueUpdated(bc, x.val);
      break;
    }
    case "StateUpdated": {
      bare.writeU8(bc, 5);
      writeStateUpdated(bc, x.val);
      break;
    }
    case "WorkflowHistoryUpdated": {
      bare.writeU8(bc, 6);
      writeWorkflowHistoryUpdated(bc, x.val);
      break;
    }
    case "RpcsListResponse": {
      bare.writeU8(bc, 7);
      writeRpcsListResponse(bc, x.val);
      break;
    }
    case "TraceQueryResponse": {
      bare.writeU8(bc, 8);
      writeTraceQueryResponse(bc, x.val);
      break;
    }
    case "QueueResponse": {
      bare.writeU8(bc, 9);
      writeQueueResponse(bc, x.val);
      break;
    }
    case "WorkflowHistoryResponse": {
      bare.writeU8(bc, 10);
      writeWorkflowHistoryResponse(bc, x.val);
      break;
    }
    case "Error": {
      bare.writeU8(bc, 11);
      writeError(bc, x.val);
      break;
    }
    case "Init": {
      bare.writeU8(bc, 12);
      writeInit(bc, x.val);
      break;
    }
    case "DatabaseSchemaResponse": {
      bare.writeU8(bc, 13);
      writeDatabaseSchemaResponse(bc, x.val);
      break;
    }
    case "DatabaseTableRowsResponse": {
      bare.writeU8(bc, 14);
      writeDatabaseTableRowsResponse(bc, x.val);
      break;
    }
  }
}
function readToClient(bc) {
  return {
    body: readToClientBody(bc)
  };
}
function writeToClient(bc, x) {
  writeToClientBody(bc, x.body);
}
function encodeToClient(x) {
  const bc = new bare.ByteCursor(
    new Uint8Array(config.initialBufferLength),
    config
  );
  writeToClient(bc, x);
  return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
}
function decodeToClient(bytes) {
  const bc = new bare.ByteCursor(bytes, config);
  const result = readToClient(bc);
  if (bc.offset < bc.view.byteLength) {
    throw new bare.BareError(bc.offset, "remaining bytes");
  }
  return result;
}

// src/schemas/actor-inspector/versioned.ts
import { createVersionedDataHandler } from "vbare";

// dist/schemas/actor-inspector/v1.ts
import * as bare2 from "@rivetkit/bare-ts";
var config2 = /* @__PURE__ */ bare2.Config({});
function readPatchStateRequest2(bc) {
  return {
    state: bare2.readData(bc)
  };
}
function writePatchStateRequest2(bc, x) {
  bare2.writeData(bc, x.state);
}
function readActionRequest2(bc) {
  return {
    id: bare2.readUint(bc),
    name: bare2.readString(bc),
    args: bare2.readData(bc)
  };
}
function writeActionRequest2(bc, x) {
  bare2.writeUint(bc, x.id);
  bare2.writeString(bc, x.name);
  bare2.writeData(bc, x.args);
}
function readStateRequest2(bc) {
  return {
    id: bare2.readUint(bc)
  };
}
function writeStateRequest2(bc, x) {
  bare2.writeUint(bc, x.id);
}
function readConnectionsRequest2(bc) {
  return {
    id: bare2.readUint(bc)
  };
}
function writeConnectionsRequest2(bc, x) {
  bare2.writeUint(bc, x.id);
}
function readEventsRequest(bc) {
  return {
    id: bare2.readUint(bc)
  };
}
function writeEventsRequest(bc, x) {
  bare2.writeUint(bc, x.id);
}
function readClearEventsRequest(bc) {
  return {
    id: bare2.readUint(bc)
  };
}
function writeClearEventsRequest(bc, x) {
  bare2.writeUint(bc, x.id);
}
function readRpcsListRequest2(bc) {
  return {
    id: bare2.readUint(bc)
  };
}
function writeRpcsListRequest2(bc, x) {
  bare2.writeUint(bc, x.id);
}
function readToServerBody2(bc) {
  const offset = bc.offset;
  const tag = bare2.readU8(bc);
  switch (tag) {
    case 0:
      return { tag: "PatchStateRequest", val: readPatchStateRequest2(bc) };
    case 1:
      return { tag: "StateRequest", val: readStateRequest2(bc) };
    case 2:
      return { tag: "ConnectionsRequest", val: readConnectionsRequest2(bc) };
    case 3:
      return { tag: "ActionRequest", val: readActionRequest2(bc) };
    case 4:
      return { tag: "EventsRequest", val: readEventsRequest(bc) };
    case 5:
      return { tag: "ClearEventsRequest", val: readClearEventsRequest(bc) };
    case 6:
      return { tag: "RpcsListRequest", val: readRpcsListRequest2(bc) };
    default: {
      bc.offset = offset;
      throw new bare2.BareError(offset, "invalid tag");
    }
  }
}
function writeToServerBody2(bc, x) {
  switch (x.tag) {
    case "PatchStateRequest": {
      bare2.writeU8(bc, 0);
      writePatchStateRequest2(bc, x.val);
      break;
    }
    case "StateRequest": {
      bare2.writeU8(bc, 1);
      writeStateRequest2(bc, x.val);
      break;
    }
    case "ConnectionsRequest": {
      bare2.writeU8(bc, 2);
      writeConnectionsRequest2(bc, x.val);
      break;
    }
    case "ActionRequest": {
      bare2.writeU8(bc, 3);
      writeActionRequest2(bc, x.val);
      break;
    }
    case "EventsRequest": {
      bare2.writeU8(bc, 4);
      writeEventsRequest(bc, x.val);
      break;
    }
    case "ClearEventsRequest": {
      bare2.writeU8(bc, 5);
      writeClearEventsRequest(bc, x.val);
      break;
    }
    case "RpcsListRequest": {
      bare2.writeU8(bc, 6);
      writeRpcsListRequest2(bc, x.val);
      break;
    }
  }
}
function readToServer2(bc) {
  return {
    body: readToServerBody2(bc)
  };
}
function writeToServer2(bc, x) {
  writeToServerBody2(bc, x.body);
}
function encodeToServer2(x) {
  const bc = new bare2.ByteCursor(
    new Uint8Array(config2.initialBufferLength),
    config2
  );
  writeToServer2(bc, x);
  return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
}
function decodeToServer2(bytes) {
  const bc = new bare2.ByteCursor(bytes, config2);
  const result = readToServer2(bc);
  if (bc.offset < bc.view.byteLength) {
    throw new bare2.BareError(bc.offset, "remaining bytes");
  }
  return result;
}
function readState2(bc) {
  return bare2.readData(bc);
}
function writeState2(bc, x) {
  bare2.writeData(bc, x);
}
function readConnection2(bc) {
  return {
    id: bare2.readString(bc),
    details: bare2.readData(bc)
  };
}
function writeConnection2(bc, x) {
  bare2.writeString(bc, x.id);
  bare2.writeData(bc, x.details);
}
function readActionEvent(bc) {
  return {
    name: bare2.readString(bc),
    args: bare2.readData(bc),
    connId: bare2.readString(bc)
  };
}
function writeActionEvent(bc, x) {
  bare2.writeString(bc, x.name);
  bare2.writeData(bc, x.args);
  bare2.writeString(bc, x.connId);
}
function readBroadcastEvent(bc) {
  return {
    eventName: bare2.readString(bc),
    args: bare2.readData(bc)
  };
}
function writeBroadcastEvent(bc, x) {
  bare2.writeString(bc, x.eventName);
  bare2.writeData(bc, x.args);
}
function readSubscribeEvent(bc) {
  return {
    eventName: bare2.readString(bc),
    connId: bare2.readString(bc)
  };
}
function writeSubscribeEvent(bc, x) {
  bare2.writeString(bc, x.eventName);
  bare2.writeString(bc, x.connId);
}
function readUnSubscribeEvent(bc) {
  return {
    eventName: bare2.readString(bc),
    connId: bare2.readString(bc)
  };
}
function writeUnSubscribeEvent(bc, x) {
  bare2.writeString(bc, x.eventName);
  bare2.writeString(bc, x.connId);
}
function readFiredEvent(bc) {
  return {
    eventName: bare2.readString(bc),
    args: bare2.readData(bc),
    connId: bare2.readString(bc)
  };
}
function writeFiredEvent(bc, x) {
  bare2.writeString(bc, x.eventName);
  bare2.writeData(bc, x.args);
  bare2.writeString(bc, x.connId);
}
function readEventBody(bc) {
  const offset = bc.offset;
  const tag = bare2.readU8(bc);
  switch (tag) {
    case 0:
      return { tag: "ActionEvent", val: readActionEvent(bc) };
    case 1:
      return { tag: "BroadcastEvent", val: readBroadcastEvent(bc) };
    case 2:
      return { tag: "SubscribeEvent", val: readSubscribeEvent(bc) };
    case 3:
      return { tag: "UnSubscribeEvent", val: readUnSubscribeEvent(bc) };
    case 4:
      return { tag: "FiredEvent", val: readFiredEvent(bc) };
    default: {
      bc.offset = offset;
      throw new bare2.BareError(offset, "invalid tag");
    }
  }
}
function writeEventBody(bc, x) {
  switch (x.tag) {
    case "ActionEvent": {
      bare2.writeU8(bc, 0);
      writeActionEvent(bc, x.val);
      break;
    }
    case "BroadcastEvent": {
      bare2.writeU8(bc, 1);
      writeBroadcastEvent(bc, x.val);
      break;
    }
    case "SubscribeEvent": {
      bare2.writeU8(bc, 2);
      writeSubscribeEvent(bc, x.val);
      break;
    }
    case "UnSubscribeEvent": {
      bare2.writeU8(bc, 3);
      writeUnSubscribeEvent(bc, x.val);
      break;
    }
    case "FiredEvent": {
      bare2.writeU8(bc, 4);
      writeFiredEvent(bc, x.val);
      break;
    }
  }
}
function readEvent(bc) {
  return {
    id: bare2.readString(bc),
    timestamp: bare2.readUint(bc),
    body: readEventBody(bc)
  };
}
function writeEvent(bc, x) {
  bare2.writeString(bc, x.id);
  bare2.writeUint(bc, x.timestamp);
  writeEventBody(bc, x.body);
}
function read02(bc) {
  const len = bare2.readUintSafe(bc);
  if (len === 0) {
    return [];
  }
  const result = [readConnection2(bc)];
  for (let i = 1; i < len; i++) {
    result[i] = readConnection2(bc);
  }
  return result;
}
function write02(bc, x) {
  bare2.writeUintSafe(bc, x.length);
  for (let i = 0; i < x.length; i++) {
    writeConnection2(bc, x[i]);
  }
}
function read12(bc) {
  const len = bare2.readUintSafe(bc);
  if (len === 0) {
    return [];
  }
  const result = [readEvent(bc)];
  for (let i = 1; i < len; i++) {
    result[i] = readEvent(bc);
  }
  return result;
}
function write12(bc, x) {
  bare2.writeUintSafe(bc, x.length);
  for (let i = 0; i < x.length; i++) {
    writeEvent(bc, x[i]);
  }
}
function read22(bc) {
  return bare2.readBool(bc) ? readState2(bc) : null;
}
function write22(bc, x) {
  bare2.writeBool(bc, x !== null);
  if (x !== null) {
    writeState2(bc, x);
  }
}
function read32(bc) {
  const len = bare2.readUintSafe(bc);
  if (len === 0) {
    return [];
  }
  const result = [bare2.readString(bc)];
  for (let i = 1; i < len; i++) {
    result[i] = bare2.readString(bc);
  }
  return result;
}
function write32(bc, x) {
  bare2.writeUintSafe(bc, x.length);
  for (let i = 0; i < x.length; i++) {
    bare2.writeString(bc, x[i]);
  }
}
function readInit2(bc) {
  return {
    connections: read02(bc),
    events: read12(bc),
    state: read22(bc),
    isStateEnabled: bare2.readBool(bc),
    rpcs: read32(bc),
    isDatabaseEnabled: bare2.readBool(bc)
  };
}
function writeInit2(bc, x) {
  write02(bc, x.connections);
  write12(bc, x.events);
  write22(bc, x.state);
  bare2.writeBool(bc, x.isStateEnabled);
  write32(bc, x.rpcs);
  bare2.writeBool(bc, x.isDatabaseEnabled);
}
function readConnectionsResponse2(bc) {
  return {
    rid: bare2.readUint(bc),
    connections: read02(bc)
  };
}
function writeConnectionsResponse2(bc, x) {
  bare2.writeUint(bc, x.rid);
  write02(bc, x.connections);
}
function readStateResponse2(bc) {
  return {
    rid: bare2.readUint(bc),
    state: read22(bc),
    isStateEnabled: bare2.readBool(bc)
  };
}
function writeStateResponse2(bc, x) {
  bare2.writeUint(bc, x.rid);
  write22(bc, x.state);
  bare2.writeBool(bc, x.isStateEnabled);
}
function readEventsResponse(bc) {
  return {
    rid: bare2.readUint(bc),
    events: read12(bc)
  };
}
function writeEventsResponse(bc, x) {
  bare2.writeUint(bc, x.rid);
  write12(bc, x.events);
}
function readActionResponse2(bc) {
  return {
    rid: bare2.readUint(bc),
    output: bare2.readData(bc)
  };
}
function writeActionResponse2(bc, x) {
  bare2.writeUint(bc, x.rid);
  bare2.writeData(bc, x.output);
}
function readStateUpdated2(bc) {
  return {
    state: readState2(bc)
  };
}
function writeStateUpdated2(bc, x) {
  writeState2(bc, x.state);
}
function readEventsUpdated(bc) {
  return {
    events: read12(bc)
  };
}
function writeEventsUpdated(bc, x) {
  write12(bc, x.events);
}
function readRpcsListResponse2(bc) {
  return {
    rid: bare2.readUint(bc),
    rpcs: read32(bc)
  };
}
function writeRpcsListResponse2(bc, x) {
  bare2.writeUint(bc, x.rid);
  write32(bc, x.rpcs);
}
function readConnectionsUpdated2(bc) {
  return {
    connections: read02(bc)
  };
}
function writeConnectionsUpdated2(bc, x) {
  write02(bc, x.connections);
}
function readError2(bc) {
  return {
    message: bare2.readString(bc)
  };
}
function writeError2(bc, x) {
  bare2.writeString(bc, x.message);
}
function readToClientBody2(bc) {
  const offset = bc.offset;
  const tag = bare2.readU8(bc);
  switch (tag) {
    case 0:
      return { tag: "StateResponse", val: readStateResponse2(bc) };
    case 1:
      return { tag: "ConnectionsResponse", val: readConnectionsResponse2(bc) };
    case 2:
      return { tag: "EventsResponse", val: readEventsResponse(bc) };
    case 3:
      return { tag: "ActionResponse", val: readActionResponse2(bc) };
    case 4:
      return { tag: "ConnectionsUpdated", val: readConnectionsUpdated2(bc) };
    case 5:
      return { tag: "EventsUpdated", val: readEventsUpdated(bc) };
    case 6:
      return { tag: "StateUpdated", val: readStateUpdated2(bc) };
    case 7:
      return { tag: "RpcsListResponse", val: readRpcsListResponse2(bc) };
    case 8:
      return { tag: "Error", val: readError2(bc) };
    case 9:
      return { tag: "Init", val: readInit2(bc) };
    default: {
      bc.offset = offset;
      throw new bare2.BareError(offset, "invalid tag");
    }
  }
}
function writeToClientBody2(bc, x) {
  switch (x.tag) {
    case "StateResponse": {
      bare2.writeU8(bc, 0);
      writeStateResponse2(bc, x.val);
      break;
    }
    case "ConnectionsResponse": {
      bare2.writeU8(bc, 1);
      writeConnectionsResponse2(bc, x.val);
      break;
    }
    case "EventsResponse": {
      bare2.writeU8(bc, 2);
      writeEventsResponse(bc, x.val);
      break;
    }
    case "ActionResponse": {
      bare2.writeU8(bc, 3);
      writeActionResponse2(bc, x.val);
      break;
    }
    case "ConnectionsUpdated": {
      bare2.writeU8(bc, 4);
      writeConnectionsUpdated2(bc, x.val);
      break;
    }
    case "EventsUpdated": {
      bare2.writeU8(bc, 5);
      writeEventsUpdated(bc, x.val);
      break;
    }
    case "StateUpdated": {
      bare2.writeU8(bc, 6);
      writeStateUpdated2(bc, x.val);
      break;
    }
    case "RpcsListResponse": {
      bare2.writeU8(bc, 7);
      writeRpcsListResponse2(bc, x.val);
      break;
    }
    case "Error": {
      bare2.writeU8(bc, 8);
      writeError2(bc, x.val);
      break;
    }
    case "Init": {
      bare2.writeU8(bc, 9);
      writeInit2(bc, x.val);
      break;
    }
  }
}
function readToClient2(bc) {
  return {
    body: readToClientBody2(bc)
  };
}
function writeToClient2(bc, x) {
  writeToClientBody2(bc, x.body);
}
function encodeToClient2(x) {
  const bc = new bare2.ByteCursor(
    new Uint8Array(config2.initialBufferLength),
    config2
  );
  writeToClient2(bc, x);
  return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
}
function decodeToClient2(bytes) {
  const bc = new bare2.ByteCursor(bytes, config2);
  const result = readToClient2(bc);
  if (bc.offset < bc.view.byteLength) {
    throw new bare2.BareError(bc.offset, "remaining bytes");
  }
  return result;
}

// dist/schemas/actor-inspector/v2.ts
import * as bare3 from "@rivetkit/bare-ts";
var config3 = /* @__PURE__ */ bare3.Config({});
function readPatchStateRequest3(bc) {
  return {
    state: bare3.readData(bc)
  };
}
function writePatchStateRequest3(bc, x) {
  bare3.writeData(bc, x.state);
}
function readActionRequest3(bc) {
  return {
    id: bare3.readUint(bc),
    name: bare3.readString(bc),
    args: bare3.readData(bc)
  };
}
function writeActionRequest3(bc, x) {
  bare3.writeUint(bc, x.id);
  bare3.writeString(bc, x.name);
  bare3.writeData(bc, x.args);
}
function readStateRequest3(bc) {
  return {
    id: bare3.readUint(bc)
  };
}
function writeStateRequest3(bc, x) {
  bare3.writeUint(bc, x.id);
}
function readConnectionsRequest3(bc) {
  return {
    id: bare3.readUint(bc)
  };
}
function writeConnectionsRequest3(bc, x) {
  bare3.writeUint(bc, x.id);
}
function readRpcsListRequest3(bc) {
  return {
    id: bare3.readUint(bc)
  };
}
function writeRpcsListRequest3(bc, x) {
  bare3.writeUint(bc, x.id);
}
function readTraceQueryRequest2(bc) {
  return {
    id: bare3.readUint(bc),
    startMs: bare3.readUint(bc),
    endMs: bare3.readUint(bc),
    limit: bare3.readUint(bc)
  };
}
function writeTraceQueryRequest2(bc, x) {
  bare3.writeUint(bc, x.id);
  bare3.writeUint(bc, x.startMs);
  bare3.writeUint(bc, x.endMs);
  bare3.writeUint(bc, x.limit);
}
function readQueueRequest2(bc) {
  return {
    id: bare3.readUint(bc),
    limit: bare3.readUint(bc)
  };
}
function writeQueueRequest2(bc, x) {
  bare3.writeUint(bc, x.id);
  bare3.writeUint(bc, x.limit);
}
function readWorkflowHistoryRequest2(bc) {
  return {
    id: bare3.readUint(bc)
  };
}
function writeWorkflowHistoryRequest2(bc, x) {
  bare3.writeUint(bc, x.id);
}
function readToServerBody3(bc) {
  const offset = bc.offset;
  const tag = bare3.readU8(bc);
  switch (tag) {
    case 0:
      return { tag: "PatchStateRequest", val: readPatchStateRequest3(bc) };
    case 1:
      return { tag: "StateRequest", val: readStateRequest3(bc) };
    case 2:
      return { tag: "ConnectionsRequest", val: readConnectionsRequest3(bc) };
    case 3:
      return { tag: "ActionRequest", val: readActionRequest3(bc) };
    case 4:
      return { tag: "RpcsListRequest", val: readRpcsListRequest3(bc) };
    case 5:
      return { tag: "TraceQueryRequest", val: readTraceQueryRequest2(bc) };
    case 6:
      return { tag: "QueueRequest", val: readQueueRequest2(bc) };
    case 7:
      return { tag: "WorkflowHistoryRequest", val: readWorkflowHistoryRequest2(bc) };
    default: {
      bc.offset = offset;
      throw new bare3.BareError(offset, "invalid tag");
    }
  }
}
function writeToServerBody3(bc, x) {
  switch (x.tag) {
    case "PatchStateRequest": {
      bare3.writeU8(bc, 0);
      writePatchStateRequest3(bc, x.val);
      break;
    }
    case "StateRequest": {
      bare3.writeU8(bc, 1);
      writeStateRequest3(bc, x.val);
      break;
    }
    case "ConnectionsRequest": {
      bare3.writeU8(bc, 2);
      writeConnectionsRequest3(bc, x.val);
      break;
    }
    case "ActionRequest": {
      bare3.writeU8(bc, 3);
      writeActionRequest3(bc, x.val);
      break;
    }
    case "RpcsListRequest": {
      bare3.writeU8(bc, 4);
      writeRpcsListRequest3(bc, x.val);
      break;
    }
    case "TraceQueryRequest": {
      bare3.writeU8(bc, 5);
      writeTraceQueryRequest2(bc, x.val);
      break;
    }
    case "QueueRequest": {
      bare3.writeU8(bc, 6);
      writeQueueRequest2(bc, x.val);
      break;
    }
    case "WorkflowHistoryRequest": {
      bare3.writeU8(bc, 7);
      writeWorkflowHistoryRequest2(bc, x.val);
      break;
    }
  }
}
function readToServer3(bc) {
  return {
    body: readToServerBody3(bc)
  };
}
function writeToServer3(bc, x) {
  writeToServerBody3(bc, x.body);
}
function encodeToServer3(x) {
  const bc = new bare3.ByteCursor(
    new Uint8Array(config3.initialBufferLength),
    config3
  );
  writeToServer3(bc, x);
  return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
}
function decodeToServer3(bytes) {
  const bc = new bare3.ByteCursor(bytes, config3);
  const result = readToServer3(bc);
  if (bc.offset < bc.view.byteLength) {
    throw new bare3.BareError(bc.offset, "remaining bytes");
  }
  return result;
}
function readState3(bc) {
  return bare3.readData(bc);
}
function writeState3(bc, x) {
  bare3.writeData(bc, x);
}
function readConnection3(bc) {
  return {
    id: bare3.readString(bc),
    details: bare3.readData(bc)
  };
}
function writeConnection3(bc, x) {
  bare3.writeString(bc, x.id);
  bare3.writeData(bc, x.details);
}
function readWorkflowHistory2(bc) {
  return bare3.readData(bc);
}
function writeWorkflowHistory2(bc, x) {
  bare3.writeData(bc, x);
}
function read03(bc) {
  const len = bare3.readUintSafe(bc);
  if (len === 0) {
    return [];
  }
  const result = [readConnection3(bc)];
  for (let i = 1; i < len; i++) {
    result[i] = readConnection3(bc);
  }
  return result;
}
function write03(bc, x) {
  bare3.writeUintSafe(bc, x.length);
  for (let i = 0; i < x.length; i++) {
    writeConnection3(bc, x[i]);
  }
}
function read13(bc) {
  return bare3.readBool(bc) ? readState3(bc) : null;
}
function write13(bc, x) {
  bare3.writeBool(bc, x !== null);
  if (x !== null) {
    writeState3(bc, x);
  }
}
function read23(bc) {
  const len = bare3.readUintSafe(bc);
  if (len === 0) {
    return [];
  }
  const result = [bare3.readString(bc)];
  for (let i = 1; i < len; i++) {
    result[i] = bare3.readString(bc);
  }
  return result;
}
function write23(bc, x) {
  bare3.writeUintSafe(bc, x.length);
  for (let i = 0; i < x.length; i++) {
    bare3.writeString(bc, x[i]);
  }
}
function read33(bc) {
  return bare3.readBool(bc) ? readWorkflowHistory2(bc) : null;
}
function write33(bc, x) {
  bare3.writeBool(bc, x !== null);
  if (x !== null) {
    writeWorkflowHistory2(bc, x);
  }
}
function readInit3(bc) {
  return {
    connections: read03(bc),
    state: read13(bc),
    isStateEnabled: bare3.readBool(bc),
    rpcs: read23(bc),
    isDatabaseEnabled: bare3.readBool(bc),
    queueSize: bare3.readUint(bc),
    workflowHistory: read33(bc),
    isWorkflowEnabled: bare3.readBool(bc)
  };
}
function writeInit3(bc, x) {
  write03(bc, x.connections);
  write13(bc, x.state);
  bare3.writeBool(bc, x.isStateEnabled);
  write23(bc, x.rpcs);
  bare3.writeBool(bc, x.isDatabaseEnabled);
  bare3.writeUint(bc, x.queueSize);
  write33(bc, x.workflowHistory);
  bare3.writeBool(bc, x.isWorkflowEnabled);
}
function readConnectionsResponse3(bc) {
  return {
    rid: bare3.readUint(bc),
    connections: read03(bc)
  };
}
function writeConnectionsResponse3(bc, x) {
  bare3.writeUint(bc, x.rid);
  write03(bc, x.connections);
}
function readStateResponse3(bc) {
  return {
    rid: bare3.readUint(bc),
    state: read13(bc),
    isStateEnabled: bare3.readBool(bc)
  };
}
function writeStateResponse3(bc, x) {
  bare3.writeUint(bc, x.rid);
  write13(bc, x.state);
  bare3.writeBool(bc, x.isStateEnabled);
}
function readActionResponse3(bc) {
  return {
    rid: bare3.readUint(bc),
    output: bare3.readData(bc)
  };
}
function writeActionResponse3(bc, x) {
  bare3.writeUint(bc, x.rid);
  bare3.writeData(bc, x.output);
}
function readTraceQueryResponse2(bc) {
  return {
    rid: bare3.readUint(bc),
    payload: bare3.readData(bc)
  };
}
function writeTraceQueryResponse2(bc, x) {
  bare3.writeUint(bc, x.rid);
  bare3.writeData(bc, x.payload);
}
function readQueueMessageSummary2(bc) {
  return {
    id: bare3.readUint(bc),
    name: bare3.readString(bc),
    createdAtMs: bare3.readUint(bc)
  };
}
function writeQueueMessageSummary2(bc, x) {
  bare3.writeUint(bc, x.id);
  bare3.writeString(bc, x.name);
  bare3.writeUint(bc, x.createdAtMs);
}
function read42(bc) {
  const len = bare3.readUintSafe(bc);
  if (len === 0) {
    return [];
  }
  const result = [readQueueMessageSummary2(bc)];
  for (let i = 1; i < len; i++) {
    result[i] = readQueueMessageSummary2(bc);
  }
  return result;
}
function write42(bc, x) {
  bare3.writeUintSafe(bc, x.length);
  for (let i = 0; i < x.length; i++) {
    writeQueueMessageSummary2(bc, x[i]);
  }
}
function readQueueStatus2(bc) {
  return {
    size: bare3.readUint(bc),
    maxSize: bare3.readUint(bc),
    messages: read42(bc),
    truncated: bare3.readBool(bc)
  };
}
function writeQueueStatus2(bc, x) {
  bare3.writeUint(bc, x.size);
  bare3.writeUint(bc, x.maxSize);
  write42(bc, x.messages);
  bare3.writeBool(bc, x.truncated);
}
function readQueueResponse2(bc) {
  return {
    rid: bare3.readUint(bc),
    status: readQueueStatus2(bc)
  };
}
function writeQueueResponse2(bc, x) {
  bare3.writeUint(bc, x.rid);
  writeQueueStatus2(bc, x.status);
}
function readWorkflowHistoryResponse2(bc) {
  return {
    rid: bare3.readUint(bc),
    history: read33(bc),
    isWorkflowEnabled: bare3.readBool(bc)
  };
}
function writeWorkflowHistoryResponse2(bc, x) {
  bare3.writeUint(bc, x.rid);
  write33(bc, x.history);
  bare3.writeBool(bc, x.isWorkflowEnabled);
}
function readStateUpdated3(bc) {
  return {
    state: readState3(bc)
  };
}
function writeStateUpdated3(bc, x) {
  writeState3(bc, x.state);
}
function readQueueUpdated2(bc) {
  return {
    queueSize: bare3.readUint(bc)
  };
}
function writeQueueUpdated2(bc, x) {
  bare3.writeUint(bc, x.queueSize);
}
function readWorkflowHistoryUpdated2(bc) {
  return {
    history: readWorkflowHistory2(bc)
  };
}
function writeWorkflowHistoryUpdated2(bc, x) {
  writeWorkflowHistory2(bc, x.history);
}
function readRpcsListResponse3(bc) {
  return {
    rid: bare3.readUint(bc),
    rpcs: read23(bc)
  };
}
function writeRpcsListResponse3(bc, x) {
  bare3.writeUint(bc, x.rid);
  write23(bc, x.rpcs);
}
function readConnectionsUpdated3(bc) {
  return {
    connections: read03(bc)
  };
}
function writeConnectionsUpdated3(bc, x) {
  write03(bc, x.connections);
}
function readError3(bc) {
  return {
    message: bare3.readString(bc)
  };
}
function writeError3(bc, x) {
  bare3.writeString(bc, x.message);
}
function readToClientBody3(bc) {
  const offset = bc.offset;
  const tag = bare3.readU8(bc);
  switch (tag) {
    case 0:
      return { tag: "StateResponse", val: readStateResponse3(bc) };
    case 1:
      return { tag: "ConnectionsResponse", val: readConnectionsResponse3(bc) };
    case 2:
      return { tag: "ActionResponse", val: readActionResponse3(bc) };
    case 3:
      return { tag: "ConnectionsUpdated", val: readConnectionsUpdated3(bc) };
    case 4:
      return { tag: "QueueUpdated", val: readQueueUpdated2(bc) };
    case 5:
      return { tag: "StateUpdated", val: readStateUpdated3(bc) };
    case 6:
      return { tag: "WorkflowHistoryUpdated", val: readWorkflowHistoryUpdated2(bc) };
    case 7:
      return { tag: "RpcsListResponse", val: readRpcsListResponse3(bc) };
    case 8:
      return { tag: "TraceQueryResponse", val: readTraceQueryResponse2(bc) };
    case 9:
      return { tag: "QueueResponse", val: readQueueResponse2(bc) };
    case 10:
      return { tag: "WorkflowHistoryResponse", val: readWorkflowHistoryResponse2(bc) };
    case 11:
      return { tag: "Error", val: readError3(bc) };
    case 12:
      return { tag: "Init", val: readInit3(bc) };
    default: {
      bc.offset = offset;
      throw new bare3.BareError(offset, "invalid tag");
    }
  }
}
function writeToClientBody3(bc, x) {
  switch (x.tag) {
    case "StateResponse": {
      bare3.writeU8(bc, 0);
      writeStateResponse3(bc, x.val);
      break;
    }
    case "ConnectionsResponse": {
      bare3.writeU8(bc, 1);
      writeConnectionsResponse3(bc, x.val);
      break;
    }
    case "ActionResponse": {
      bare3.writeU8(bc, 2);
      writeActionResponse3(bc, x.val);
      break;
    }
    case "ConnectionsUpdated": {
      bare3.writeU8(bc, 3);
      writeConnectionsUpdated3(bc, x.val);
      break;
    }
    case "QueueUpdated": {
      bare3.writeU8(bc, 4);
      writeQueueUpdated2(bc, x.val);
      break;
    }
    case "StateUpdated": {
      bare3.writeU8(bc, 5);
      writeStateUpdated3(bc, x.val);
      break;
    }
    case "WorkflowHistoryUpdated": {
      bare3.writeU8(bc, 6);
      writeWorkflowHistoryUpdated2(bc, x.val);
      break;
    }
    case "RpcsListResponse": {
      bare3.writeU8(bc, 7);
      writeRpcsListResponse3(bc, x.val);
      break;
    }
    case "TraceQueryResponse": {
      bare3.writeU8(bc, 8);
      writeTraceQueryResponse2(bc, x.val);
      break;
    }
    case "QueueResponse": {
      bare3.writeU8(bc, 9);
      writeQueueResponse2(bc, x.val);
      break;
    }
    case "WorkflowHistoryResponse": {
      bare3.writeU8(bc, 10);
      writeWorkflowHistoryResponse2(bc, x.val);
      break;
    }
    case "Error": {
      bare3.writeU8(bc, 11);
      writeError3(bc, x.val);
      break;
    }
    case "Init": {
      bare3.writeU8(bc, 12);
      writeInit3(bc, x.val);
      break;
    }
  }
}
function readToClient3(bc) {
  return {
    body: readToClientBody3(bc)
  };
}
function writeToClient3(bc, x) {
  writeToClientBody3(bc, x.body);
}
function encodeToClient3(x) {
  const bc = new bare3.ByteCursor(
    new Uint8Array(config3.initialBufferLength),
    config3
  );
  writeToClient3(bc, x);
  return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
}
function decodeToClient3(bytes) {
  const bc = new bare3.ByteCursor(bytes, config3);
  const result = readToClient3(bc);
  if (bc.offset < bc.view.byteLength) {
    throw new bare3.BareError(bc.offset, "remaining bytes");
  }
  return result;
}

// src/schemas/actor-inspector/versioned.ts
var CURRENT_VERSION = 3;
var EVENTS_DROPPED_ERROR = "inspector.events_dropped";
var WORKFLOW_HISTORY_DROPPED_ERROR = "inspector.workflow_history_dropped";
var QUEUE_DROPPED_ERROR = "inspector.queue_dropped";
var TRACE_DROPPED_ERROR = "inspector.trace_dropped";
var DATABASE_DROPPED_ERROR = "inspector.database_dropped";
var v1ToClientToV2 = (v1Data) => {
  if (v1Data.body.tag === "Init") {
    const init = v1Data.body.val;
    return {
      body: {
        tag: "Init",
        val: {
          connections: init.connections,
          state: init.state,
          isStateEnabled: init.isStateEnabled,
          rpcs: init.rpcs,
          isDatabaseEnabled: init.isDatabaseEnabled,
          queueSize: 0n,
          workflowHistory: null,
          isWorkflowEnabled: false
        }
      }
    };
  }
  if (v1Data.body.tag === "EventsUpdated" || v1Data.body.tag === "EventsResponse") {
    return {
      body: {
        tag: "Error",
        val: {
          message: EVENTS_DROPPED_ERROR
        }
      }
    };
  }
  return v1Data;
};
var v2ToClientToV1 = (v2Data) => {
  if (v2Data.body.tag === "Init") {
    const init = v2Data.body.val;
    return {
      body: {
        tag: "Init",
        val: {
          connections: init.connections,
          events: [],
          state: init.state,
          isStateEnabled: init.isStateEnabled,
          rpcs: init.rpcs,
          isDatabaseEnabled: init.isDatabaseEnabled
        }
      }
    };
  }
  if (v2Data.body.tag === "WorkflowHistoryUpdated" || v2Data.body.tag === "WorkflowHistoryResponse") {
    return {
      body: {
        tag: "Error",
        val: {
          message: WORKFLOW_HISTORY_DROPPED_ERROR
        }
      }
    };
  }
  if (v2Data.body.tag === "QueueUpdated") {
    return {
      body: {
        tag: "Error",
        val: {
          message: QUEUE_DROPPED_ERROR
        }
      }
    };
  }
  if (v2Data.body.tag === "QueueResponse") {
    return {
      body: {
        tag: "Error",
        val: {
          message: QUEUE_DROPPED_ERROR
        }
      }
    };
  }
  if (v2Data.body.tag === "TraceQueryResponse") {
    return {
      body: {
        tag: "Error",
        val: {
          message: TRACE_DROPPED_ERROR
        }
      }
    };
  }
  return v2Data;
};
var v2ToClientToV3 = (v2Data) => {
  return v2Data;
};
var v3ToClientToV2 = (v3Data) => {
  if (v3Data.body.tag === "DatabaseSchemaResponse" || v3Data.body.tag === "DatabaseTableRowsResponse") {
    return {
      body: {
        tag: "Error",
        val: {
          message: DATABASE_DROPPED_ERROR
        }
      }
    };
  }
  return v3Data;
};
var v1ToServerToV2 = (v1Data) => {
  if (v1Data.body.tag === "EventsRequest" || v1Data.body.tag === "ClearEventsRequest") {
    throw new Error("Cannot convert events requests to v2");
  }
  return v1Data;
};
var v2ToServerToV1 = (v2Data) => {
  if (v2Data.body.tag === "TraceQueryRequest" || v2Data.body.tag === "QueueRequest" || v2Data.body.tag === "WorkflowHistoryRequest") {
    throw new Error("Cannot convert v2-only requests to v1");
  }
  return v2Data;
};
var v2ToServerToV3 = (v2Data) => {
  return v2Data;
};
var v3ToServerToV2 = (v3Data) => {
  if (v3Data.body.tag === "DatabaseSchemaRequest" || v3Data.body.tag === "DatabaseTableRowsRequest") {
    throw new Error("Cannot convert v3-only database requests to v2");
  }
  return v3Data;
};
var TO_SERVER_VERSIONED = createVersionedDataHandler({
  serializeVersion: (data, version) => {
    switch (version) {
      case 1:
        return encodeToServer2(data);
      case 2:
        return encodeToServer3(data);
      case 3:
        return encodeToServer(data);
      default:
        throw new Error(`Unknown version ${version}`);
    }
  },
  deserializeVersion: (bytes, version) => {
    switch (version) {
      case 1:
        return decodeToServer2(bytes);
      case 2:
        return decodeToServer3(bytes);
      case 3:
        return decodeToServer(bytes);
      default:
        throw new Error(`Unknown version ${version}`);
    }
  },
  deserializeConverters: () => [v1ToServerToV2, v2ToServerToV3],
  serializeConverters: () => [v3ToServerToV2, v2ToServerToV1]
});
var TO_CLIENT_VERSIONED = createVersionedDataHandler({
  serializeVersion: (data, version) => {
    switch (version) {
      case 1:
        return encodeToClient2(data);
      case 2:
        return encodeToClient3(data);
      case 3:
        return encodeToClient(data);
      default:
        throw new Error(`Unknown version ${version}`);
    }
  },
  deserializeVersion: (bytes, version) => {
    switch (version) {
      case 1:
        return decodeToClient2(bytes);
      case 2:
        return decodeToClient3(bytes);
      case 3:
        return decodeToClient(bytes);
      default:
        throw new Error(`Unknown version ${version}`);
    }
  },
  deserializeConverters: () => [v1ToClientToV2, v2ToClientToV3],
  serializeConverters: () => [v3ToClientToV2, v2ToClientToV1]
});

// dist/schemas/transport/v1.ts
import * as bare4 from "@rivetkit/bare-ts";
var config4 = /* @__PURE__ */ bare4.Config({});
function readWorkflowCbor(bc) {
  return bare4.readData(bc);
}
function writeWorkflowCbor(bc, x) {
  bare4.writeData(bc, x);
}
function readWorkflowNameIndex(bc) {
  return bare4.readU32(bc);
}
function writeWorkflowNameIndex(bc, x) {
  bare4.writeU32(bc, x);
}
function readWorkflowLoopIterationMarker(bc) {
  return {
    loop: readWorkflowNameIndex(bc),
    iteration: bare4.readU32(bc)
  };
}
function writeWorkflowLoopIterationMarker(bc, x) {
  writeWorkflowNameIndex(bc, x.loop);
  bare4.writeU32(bc, x.iteration);
}
function readWorkflowPathSegment(bc) {
  const offset = bc.offset;
  const tag = bare4.readU8(bc);
  switch (tag) {
    case 0:
      return { tag: "WorkflowNameIndex", val: readWorkflowNameIndex(bc) };
    case 1:
      return { tag: "WorkflowLoopIterationMarker", val: readWorkflowLoopIterationMarker(bc) };
    default: {
      bc.offset = offset;
      throw new bare4.BareError(offset, "invalid tag");
    }
  }
}
function writeWorkflowPathSegment(bc, x) {
  switch (x.tag) {
    case "WorkflowNameIndex": {
      bare4.writeU8(bc, 0);
      writeWorkflowNameIndex(bc, x.val);
      break;
    }
    case "WorkflowLoopIterationMarker": {
      bare4.writeU8(bc, 1);
      writeWorkflowLoopIterationMarker(bc, x.val);
      break;
    }
  }
}
function readWorkflowLocation(bc) {
  const len = bare4.readUintSafe(bc);
  if (len === 0) {
    return [];
  }
  const result = [readWorkflowPathSegment(bc)];
  for (let i = 1; i < len; i++) {
    result[i] = readWorkflowPathSegment(bc);
  }
  return result;
}
function writeWorkflowLocation(bc, x) {
  bare4.writeUintSafe(bc, x.length);
  for (let i = 0; i < x.length; i++) {
    writeWorkflowPathSegment(bc, x[i]);
  }
}
function readWorkflowEntryStatus(bc) {
  const offset = bc.offset;
  const tag = bare4.readU8(bc);
  switch (tag) {
    case 0:
      return "PENDING" /* PENDING */;
    case 1:
      return "RUNNING" /* RUNNING */;
    case 2:
      return "COMPLETED" /* COMPLETED */;
    case 3:
      return "FAILED" /* FAILED */;
    case 4:
      return "EXHAUSTED" /* EXHAUSTED */;
    default: {
      bc.offset = offset;
      throw new bare4.BareError(offset, "invalid tag");
    }
  }
}
function writeWorkflowEntryStatus(bc, x) {
  switch (x) {
    case "PENDING" /* PENDING */: {
      bare4.writeU8(bc, 0);
      break;
    }
    case "RUNNING" /* RUNNING */: {
      bare4.writeU8(bc, 1);
      break;
    }
    case "COMPLETED" /* COMPLETED */: {
      bare4.writeU8(bc, 2);
      break;
    }
    case "FAILED" /* FAILED */: {
      bare4.writeU8(bc, 3);
      break;
    }
    case "EXHAUSTED" /* EXHAUSTED */: {
      bare4.writeU8(bc, 4);
      break;
    }
  }
}
function readWorkflowSleepState(bc) {
  const offset = bc.offset;
  const tag = bare4.readU8(bc);
  switch (tag) {
    case 0:
      return "PENDING" /* PENDING */;
    case 1:
      return "COMPLETED" /* COMPLETED */;
    case 2:
      return "INTERRUPTED" /* INTERRUPTED */;
    default: {
      bc.offset = offset;
      throw new bare4.BareError(offset, "invalid tag");
    }
  }
}
function writeWorkflowSleepState(bc, x) {
  switch (x) {
    case "PENDING" /* PENDING */: {
      bare4.writeU8(bc, 0);
      break;
    }
    case "COMPLETED" /* COMPLETED */: {
      bare4.writeU8(bc, 1);
      break;
    }
    case "INTERRUPTED" /* INTERRUPTED */: {
      bare4.writeU8(bc, 2);
      break;
    }
  }
}
function readWorkflowBranchStatusType(bc) {
  const offset = bc.offset;
  const tag = bare4.readU8(bc);
  switch (tag) {
    case 0:
      return "PENDING" /* PENDING */;
    case 1:
      return "RUNNING" /* RUNNING */;
    case 2:
      return "COMPLETED" /* COMPLETED */;
    case 3:
      return "FAILED" /* FAILED */;
    case 4:
      return "CANCELLED" /* CANCELLED */;
    default: {
      bc.offset = offset;
      throw new bare4.BareError(offset, "invalid tag");
    }
  }
}
function writeWorkflowBranchStatusType(bc, x) {
  switch (x) {
    case "PENDING" /* PENDING */: {
      bare4.writeU8(bc, 0);
      break;
    }
    case "RUNNING" /* RUNNING */: {
      bare4.writeU8(bc, 1);
      break;
    }
    case "COMPLETED" /* COMPLETED */: {
      bare4.writeU8(bc, 2);
      break;
    }
    case "FAILED" /* FAILED */: {
      bare4.writeU8(bc, 3);
      break;
    }
    case "CANCELLED" /* CANCELLED */: {
      bare4.writeU8(bc, 4);
      break;
    }
  }
}
function read04(bc) {
  return bare4.readBool(bc) ? readWorkflowCbor(bc) : null;
}
function write04(bc, x) {
  bare4.writeBool(bc, x !== null);
  if (x !== null) {
    writeWorkflowCbor(bc, x);
  }
}
function read14(bc) {
  return bare4.readBool(bc) ? bare4.readString(bc) : null;
}
function write14(bc, x) {
  bare4.writeBool(bc, x !== null);
  if (x !== null) {
    bare4.writeString(bc, x);
  }
}
function readWorkflowStepEntry(bc) {
  return {
    output: read04(bc),
    error: read14(bc)
  };
}
function writeWorkflowStepEntry(bc, x) {
  write04(bc, x.output);
  write14(bc, x.error);
}
function readWorkflowLoopEntry(bc) {
  return {
    state: readWorkflowCbor(bc),
    iteration: bare4.readU32(bc),
    output: read04(bc)
  };
}
function writeWorkflowLoopEntry(bc, x) {
  writeWorkflowCbor(bc, x.state);
  bare4.writeU32(bc, x.iteration);
  write04(bc, x.output);
}
function readWorkflowSleepEntry(bc) {
  return {
    deadline: bare4.readU64(bc),
    state: readWorkflowSleepState(bc)
  };
}
function writeWorkflowSleepEntry(bc, x) {
  bare4.writeU64(bc, x.deadline);
  writeWorkflowSleepState(bc, x.state);
}
function readWorkflowMessageEntry(bc) {
  return {
    name: bare4.readString(bc),
    messageData: readWorkflowCbor(bc)
  };
}
function writeWorkflowMessageEntry(bc, x) {
  bare4.writeString(bc, x.name);
  writeWorkflowCbor(bc, x.messageData);
}
function readWorkflowRollbackCheckpointEntry(bc) {
  return {
    name: bare4.readString(bc)
  };
}
function writeWorkflowRollbackCheckpointEntry(bc, x) {
  bare4.writeString(bc, x.name);
}
function readWorkflowBranchStatus(bc) {
  return {
    status: readWorkflowBranchStatusType(bc),
    output: read04(bc),
    error: read14(bc)
  };
}
function writeWorkflowBranchStatus(bc, x) {
  writeWorkflowBranchStatusType(bc, x.status);
  write04(bc, x.output);
  write14(bc, x.error);
}
function read24(bc) {
  const len = bare4.readUintSafe(bc);
  const result = /* @__PURE__ */ new Map();
  for (let i = 0; i < len; i++) {
    const offset = bc.offset;
    const key = bare4.readString(bc);
    if (result.has(key)) {
      bc.offset = offset;
      throw new bare4.BareError(offset, "duplicated key");
    }
    result.set(key, readWorkflowBranchStatus(bc));
  }
  return result;
}
function write24(bc, x) {
  bare4.writeUintSafe(bc, x.size);
  for (const kv of x) {
    bare4.writeString(bc, kv[0]);
    writeWorkflowBranchStatus(bc, kv[1]);
  }
}
function readWorkflowJoinEntry(bc) {
  return {
    branches: read24(bc)
  };
}
function writeWorkflowJoinEntry(bc, x) {
  write24(bc, x.branches);
}
function readWorkflowRaceEntry(bc) {
  return {
    winner: read14(bc),
    branches: read24(bc)
  };
}
function writeWorkflowRaceEntry(bc, x) {
  write14(bc, x.winner);
  write24(bc, x.branches);
}
function readWorkflowRemovedEntry(bc) {
  return {
    originalType: bare4.readString(bc),
    originalName: read14(bc)
  };
}
function writeWorkflowRemovedEntry(bc, x) {
  bare4.writeString(bc, x.originalType);
  write14(bc, x.originalName);
}
function readWorkflowEntryKind(bc) {
  const offset = bc.offset;
  const tag = bare4.readU8(bc);
  switch (tag) {
    case 0:
      return { tag: "WorkflowStepEntry", val: readWorkflowStepEntry(bc) };
    case 1:
      return { tag: "WorkflowLoopEntry", val: readWorkflowLoopEntry(bc) };
    case 2:
      return { tag: "WorkflowSleepEntry", val: readWorkflowSleepEntry(bc) };
    case 3:
      return { tag: "WorkflowMessageEntry", val: readWorkflowMessageEntry(bc) };
    case 4:
      return { tag: "WorkflowRollbackCheckpointEntry", val: readWorkflowRollbackCheckpointEntry(bc) };
    case 5:
      return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
    case 6:
      return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
    case 7:
      return { tag: "WorkflowRemovedEntry", val: readWorkflowRemovedEntry(bc) };
    default: {
      bc.offset = offset;
      throw new bare4.BareError(offset, "invalid tag");
    }
  }
}
function writeWorkflowEntryKind(bc, x) {
  switch (x.tag) {
    case "WorkflowStepEntry": {
      bare4.writeU8(bc, 0);
      writeWorkflowStepEntry(bc, x.val);
      break;
    }
    case "WorkflowLoopEntry": {
      bare4.writeU8(bc, 1);
      writeWorkflowLoopEntry(bc, x.val);
      break;
    }
    case "WorkflowSleepEntry": {
      bare4.writeU8(bc, 2);
      writeWorkflowSleepEntry(bc, x.val);
      break;
    }
    case "WorkflowMessageEntry": {
      bare4.writeU8(bc, 3);
      writeWorkflowMessageEntry(bc, x.val);
      break;
    }
    case "WorkflowRollbackCheckpointEntry": {
      bare4.writeU8(bc, 4);
      writeWorkflowRollbackCheckpointEntry(bc, x.val);
      break;
    }
    case "WorkflowJoinEntry": {
      bare4.writeU8(bc, 5);
      writeWorkflowJoinEntry(bc, x.val);
      break;
    }
    case "WorkflowRaceEntry": {
      bare4.writeU8(bc, 6);
      writeWorkflowRaceEntry(bc, x.val);
      break;
    }
    case "WorkflowRemovedEntry": {
      bare4.writeU8(bc, 7);
      writeWorkflowRemovedEntry(bc, x.val);
      break;
    }
  }
}
function readWorkflowEntry(bc) {
  return {
    id: bare4.readString(bc),
    location: readWorkflowLocation(bc),
    kind: readWorkflowEntryKind(bc)
  };
}
function writeWorkflowEntry(bc, x) {
  bare4.writeString(bc, x.id);
  writeWorkflowLocation(bc, x.location);
  writeWorkflowEntryKind(bc, x.kind);
}
function read34(bc) {
  return bare4.readBool(bc) ? bare4.readU64(bc) : null;
}
function write34(bc, x) {
  bare4.writeBool(bc, x !== null);
  if (x !== null) {
    bare4.writeU64(bc, x);
  }
}
function readWorkflowEntryMetadata(bc) {
  return {
    status: readWorkflowEntryStatus(bc),
    error: read14(bc),
    attempts: bare4.readU32(bc),
    lastAttemptAt: bare4.readU64(bc),
    createdAt: bare4.readU64(bc),
    completedAt: read34(bc),
    rollbackCompletedAt: read34(bc),
    rollbackError: read14(bc)
  };
}
function writeWorkflowEntryMetadata(bc, x) {
  writeWorkflowEntryStatus(bc, x.status);
  write14(bc, x.error);
  bare4.writeU32(bc, x.attempts);
  bare4.writeU64(bc, x.lastAttemptAt);
  bare4.writeU64(bc, x.createdAt);
  write34(bc, x.completedAt);
  write34(bc, x.rollbackCompletedAt);
  write14(bc, x.rollbackError);
}
function read43(bc) {
  const len = bare4.readUintSafe(bc);
  if (len === 0) {
    return [];
  }
  const result = [bare4.readString(bc)];
  for (let i = 1; i < len; i++) {
    result[i] = bare4.readString(bc);
  }
  return result;
}
function write43(bc, x) {
  bare4.writeUintSafe(bc, x.length);
  for (let i = 0; i < x.length; i++) {
    bare4.writeString(bc, x[i]);
  }
}
function read5(bc) {
  const len = bare4.readUintSafe(bc);
  if (len === 0) {
    return [];
  }
  const result = [readWorkflowEntry(bc)];
  for (let i = 1; i < len; i++) {
    result[i] = readWorkflowEntry(bc);
  }
  return result;
}
function write5(bc, x) {
  bare4.writeUintSafe(bc, x.length);
  for (let i = 0; i < x.length; i++) {
    writeWorkflowEntry(bc, x[i]);
  }
}
function read6(bc) {
  const len = bare4.readUintSafe(bc);
  const result = /* @__PURE__ */ new Map();
  for (let i = 0; i < len; i++) {
    const offset = bc.offset;
    const key = bare4.readString(bc);
    if (result.has(key)) {
      bc.offset = offset;
      throw new bare4.BareError(offset, "duplicated key");
    }
    result.set(key, readWorkflowEntryMetadata(bc));
  }
  return result;
}
function write6(bc, x) {
  bare4.writeUintSafe(bc, x.size);
  for (const kv of x) {
    bare4.writeString(bc, kv[0]);
    writeWorkflowEntryMetadata(bc, kv[1]);
  }
}
function readWorkflowHistory3(bc) {
  return {
    nameRegistry: read43(bc),
    entries: read5(bc),
    entryMetadata: read6(bc)
  };
}
function writeWorkflowHistory3(bc, x) {
  write43(bc, x.nameRegistry);
  write5(bc, x.entries);
  write6(bc, x.entryMetadata);
}
function encodeWorkflowHistory(x) {
  const bc = new bare4.ByteCursor(
    new Uint8Array(config4.initialBufferLength),
    config4
  );
  writeWorkflowHistory3(bc, x);
  return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset);
}
function decodeWorkflowHistory(bytes) {
  const bc = new bare4.ByteCursor(bytes, config4);
  const result = readWorkflowHistory3(bc);
  if (bc.offset < bc.view.byteLength) {
    throw new bare4.BareError(bc.offset, "remaining bytes");
  }
  return result;
}

// package.json
var package_default = {
  name: "rivetkit",
  version: "2.1.1",
  description: "Lightweight libraries for building stateful actors on edge platforms",
  license: "Apache-2.0",
  keywords: [
    "rivetkit",
    "stateful",
    "serverless",
    "actors",
    "agents",
    "realtime",
    "websocket",
    "actors",
    "framework"
  ],
  files: [
    "dist",
    "src",
    "deno.json",
    "bun.json",
    "package.json"
  ],
  type: "module",
  exports: {
    ".": {
      import: {
        types: "./dist/tsup/mod.d.ts",
        default: "./dist/tsup/mod.js"
      },
      require: {
        types: "./dist/tsup/mod.d.cts",
        default: "./dist/tsup/mod.cjs"
      }
    },
    "./workflow": {
      import: {
        types: "./dist/tsup/workflow/mod.d.ts",
        default: "./dist/tsup/workflow/mod.js"
      },
      require: {
        types: "./dist/tsup/workflow/mod.d.cts",
        default: "./dist/tsup/workflow/mod.cjs"
      }
    },
    "./client": {
      import: {
        browser: {
          types: "./dist/browser/client.d.ts",
          default: "./dist/browser/client.js"
        },
        types: "./dist/tsup/client/mod.d.ts",
        default: "./dist/tsup/client/mod.js"
      },
      require: {
        types: "./dist/tsup/client/mod.d.cts",
        default: "./dist/tsup/client/mod.cjs"
      }
    },
    "./log": {
      import: {
        types: "./dist/tsup/common/log.d.ts",
        default: "./dist/tsup/common/log.js"
      },
      require: {
        types: "./dist/tsup/common/log.d.cts",
        default: "./dist/tsup/common/log.cjs"
      }
    },
    "./errors": {
      import: {
        types: "./dist/tsup/actor/errors.d.ts",
        default: "./dist/tsup/actor/errors.js"
      },
      require: {
        types: "./dist/tsup/actor/errors.d.cts",
        default: "./dist/tsup/actor/errors.cjs"
      }
    },
    "./utils": {
      import: {
        types: "./dist/tsup/utils.d.ts",
        default: "./dist/tsup/utils.js"
      },
      require: {
        types: "./dist/tsup/utils.d.cts",
        default: "./dist/tsup/utils.cjs"
      }
    },
    "./driver-helpers": {
      import: {
        types: "./dist/tsup/driver-helpers/mod.d.ts",
        default: "./dist/tsup/driver-helpers/mod.js"
      },
      require: {
        types: "./dist/tsup/driver-helpers/mod.d.cts",
        default: "./dist/tsup/driver-helpers/mod.cjs"
      }
    },
    "./driver-helpers/websocket": {
      import: {
        types: "./dist/tsup/common/websocket.d.ts",
        default: "./dist/tsup/common/websocket.js"
      },
      require: {
        types: "./dist/tsup/common/websocket.d.cts",
        default: "./dist/tsup/common/websocket.cjs"
      }
    },
    "./driver-test-suite": {
      import: {
        types: "./dist/tsup/driver-test-suite/mod.d.ts",
        default: "./dist/tsup/driver-test-suite/mod.js"
      },
      require: {
        types: "./dist/tsup/driver-test-suite/mod.d.cts",
        default: "./dist/tsup/driver-test-suite/mod.cjs"
      }
    },
    "./serve-test-suite": {
      import: {
        types: "./dist/tsup/serve-test-suite/mod.d.ts",
        default: "./dist/tsup/serve-test-suite/mod.js"
      },
      require: {
        types: "./dist/tsup/serve-test-suite/mod.d.cts",
        default: "./dist/tsup/serve-test-suite/mod.cjs"
      }
    },
    "./topologies/coordinate": {
      import: {
        types: "./dist/tsup/topologies/coordinate/mod.d.ts",
        default: "./dist/tsup/topologies/coordinate/mod.js"
      },
      require: {
        types: "./dist/tsup/topologies/coordinate/mod.d.cts",
        default: "./dist/tsup/topologies/coordinate/mod.cjs"
      }
    },
    "./topologies/partition": {
      import: {
        types: "./dist/tsup/topologies/partition/mod.d.ts",
        default: "./dist/tsup/topologies/partition/mod.js"
      },
      require: {
        types: "./dist/tsup/topologies/partition/mod.d.cts",
        default: "./dist/tsup/topologies/partition/mod.cjs"
      }
    },
    "./test": {
      import: {
        types: "./dist/tsup/test/mod.d.ts",
        default: "./dist/tsup/test/mod.js"
      },
      require: {
        types: "./dist/tsup/test/mod.d.cts",
        default: "./dist/tsup/test/mod.cjs"
      }
    },
    "./inspector": {
      import: {
        types: "./dist/tsup/inspector/mod.d.ts",
        default: "./dist/tsup/inspector/mod.js"
      },
      require: {
        types: "./dist/tsup/inspector/mod.d.cts",
        default: "./dist/tsup/inspector/mod.cjs"
      }
    },
    "./inspector/client": {
      import: {
        types: "./dist/browser/inspector/client.d.ts",
        default: "./dist/browser/inspector/client.js"
      }
    },
    "./db": {
      import: {
        types: "./dist/tsup/db/mod.d.ts",
        default: "./dist/tsup/db/mod.js"
      },
      require: {
        types: "./dist/tsup/db/mod.d.cts",
        default: "./dist/tsup/db/mod.cjs"
      }
    },
    "./db/drizzle": {
      import: {
        types: "./dist/tsup/db/drizzle/mod.d.ts",
        default: "./dist/tsup/db/drizzle/mod.js"
      },
      require: {
        types: "./dist/tsup/db/drizzle/mod.d.cts",
        default: "./dist/tsup/db/drizzle/mod.cjs"
      }
    }
  },
  engines: {
    node: ">=22.0.0"
  },
  sideEffects: [
    "./dist/tsup/chunk-*.js",
    "./dist/tsup/chunk-*.cjs"
  ],
  scripts: {
    build: "tsup src/mod.ts src/client/mod.ts src/common/log.ts src/common/websocket.ts src/actor/errors.ts src/topologies/coordinate/mod.ts src/topologies/partition/mod.ts src/utils.ts src/driver-helpers/mod.ts src/driver-test-suite/mod.ts src/serve-test-suite/mod.ts src/test/mod.ts src/inspector/mod.ts src/workflow/mod.ts src/db/mod.ts src/db/drizzle/mod.ts",
    "build:browser": "tsup --config tsup.browser.config.ts",
    "build:schema": "./scripts/compile-bare.ts compile schemas/client-protocol/v1.bare -o dist/schemas/client-protocol/v1.ts && ./scripts/compile-bare.ts compile schemas/client-protocol/v2.bare -o dist/schemas/client-protocol/v2.ts && ./scripts/compile-bare.ts compile schemas/client-protocol/v3.bare -o dist/schemas/client-protocol/v3.ts && ./scripts/compile-bare.ts compile schemas/file-system-driver/v1.bare -o dist/schemas/file-system-driver/v1.ts && ./scripts/compile-bare.ts compile schemas/file-system-driver/v2.bare -o dist/schemas/file-system-driver/v2.ts && ./scripts/compile-bare.ts compile schemas/file-system-driver/v3.bare -o dist/schemas/file-system-driver/v3.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v1.bare -o dist/schemas/actor-persist/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v2.bare -o dist/schemas/actor-persist/v2.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v3.bare -o dist/schemas/actor-persist/v3.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v4.bare -o dist/schemas/actor-persist/v4.ts && ./scripts/compile-bare.ts compile schemas/persist/v1.bare -o dist/schemas/persist/v1.ts && ./scripts/compile-bare.ts compile schemas/transport/v1.bare -o dist/schemas/transport/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-inspector/v1.bare -o dist/schemas/actor-inspector/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-inspector/v2.bare -o dist/schemas/actor-inspector/v2.ts && ./scripts/compile-bare.ts compile schemas/actor-inspector/v3.bare -o dist/schemas/actor-inspector/v3.ts",
    "check-types": "tsc --noEmit",
    lint: "biome check .",
    "lint:fix": "biome check --write .",
    format: "biome format .",
    "format:write": "biome format --write .",
    test: "vitest run",
    "test:watch": "vitest",
    "manager-openapi-gen": "tsx scripts/manager-openapi-gen.ts",
    "dump-asyncapi": "tsx scripts/dump-asyncapi.ts",
    "registry-config-schema-gen": "tsx scripts/registry-config-schema-gen.ts",
    "actor-config-schema-gen": "tsx scripts/actor-config-schema-gen.ts",
    "build:pack-inspector": "tsx scripts/pack-inspector.ts"
  },
  dependencies: {
    "@hono/standard-validator": "^0.1.3",
    "@hono/zod-openapi": "^1.1.5",
    "@rivetkit/bare-ts": "^0.6.2",
    "@rivetkit/engine-runner": "workspace:*",
    "@rivetkit/fast-json-patch": "^3.1.2",
    "@rivetkit/on-change": "^6.0.2-rc.1",
    "@rivetkit/sqlite-vfs": "workspace:*",
    "@rivetkit/traces": "workspace:*",
    "@rivetkit/virtual-websocket": "workspace:*",
    "@rivetkit/workflow-engine": "workspace:*",
    "cbor-x": "^1.6.0",
    "get-port": "^7.1.0",
    hono: "^4.7.0",
    invariant: "^2.2.4",
    nanoevents: "^9.1.0",
    "p-retry": "^6.2.1",
    pino: "^9.5.0",
    tar: "^7.5.0",
    uuid: "^12.0.0",
    vbare: "^0.0.4",
    "@rivetkit/sqlite": "^0.1.1",
    zod: "^4.1.0"
  },
  devDependencies: {
    "@bare-ts/tools": "^0.13.0",
    "@biomejs/biome": "^2.3",
    "@hono/node-server": "^1.18.2",
    "@hono/node-ws": "^1.1.1",
    "@standard-schema/spec": "^1.0.0",
    "@types/invariant": "^2",
    "@types/node": "^22.13.1",
    "@types/ws": "^8",
    "@vitest/ui": "3.1.1",
    "cli-table3": "^0.6.5",
    commander: "^12.1.0",
    eventsource: "^4.0.0",
    "local-pkg": "^0.5.1",
    tsup: "^8.4.0",
    tsx: "^4.19.4",
    typescript: "^5.7.3",
    "vite-tsconfig-paths": "^5.1.4",
    vitest: "^3.1.1",
    ws: "^8.18.1",
    "zod-to-json-schema": "^3.25.0"
  },
  peerDependencies: {
    "@hono/node-server": "^1.14.0",
    "@hono/node-ws": "^1.1.1",
    "drizzle-kit": "^0.31.2",
    "drizzle-orm": "^0.44.2",
    eventsource: "^4.0.0",
    ws: "^8.0.0"
  },
  peerDependenciesMeta: {
    "@hono/node-server": {
      optional: true
    },
    "@hono/node-ws": {
      optional: true
    },
    "drizzle-kit": {
      optional: true
    },
    "drizzle-orm": {
      optional: true
    },
    eventsource: {
      optional: true
    },
    ws: {
      optional: true
    }
  },
  stableVersion: "0.8.0"
};

// src/utils.ts
var VERSION = package_default.version;
function toUint8Array(data) {
  if (data instanceof Uint8Array) {
    return data;
  } else if (data instanceof ArrayBuffer) {
    return new Uint8Array(data);
  } else if (ArrayBuffer.isView(data)) {
    return new Uint8Array(
      data.buffer.slice(
        data.byteOffset,
        data.byteOffset + data.byteLength
      )
    );
  } else {
    throw new TypeError("Input must be ArrayBuffer or ArrayBufferView");
  }
}
function bufferToArrayBuffer(buf) {
  return buf.buffer.slice(
    buf.byteOffset,
    buf.byteOffset + buf.byteLength
  );
}

// src/inspector/transport.ts
function encodeWorkflowHistoryTransport(history) {
  return bufferToArrayBuffer(encodeWorkflowHistory(history));
}
function decodeWorkflowHistoryTransport(data) {
  return decodeWorkflowHistory(toUint8Array(data));
}
export {
  CURRENT_VERSION,
  TO_CLIENT_VERSIONED,
  TO_SERVER_VERSIONED,
  decodeToClient,
  decodeToServer,
  decodeWorkflowHistoryTransport,
  encodeToClient,
  encodeToServer,
  encodeWorkflowHistoryTransport,
  readActionRequest,
  readActionResponse,
  readConnection,
  readConnectionsRequest,
  readConnectionsResponse,
  readConnectionsUpdated,
  readDatabaseSchemaRequest,
  readDatabaseSchemaResponse,
  readDatabaseTableRowsRequest,
  readDatabaseTableRowsResponse,
  readError,
  readInit,
  readPatchStateRequest,
  readQueueMessageSummary,
  readQueueRequest,
  readQueueResponse,
  readQueueStatus,
  readQueueUpdated,
  readRpcsListRequest,
  readRpcsListResponse,
  readState,
  readStateRequest,
  readStateResponse,
  readStateUpdated,
  readToClient,
  readToClientBody,
  readToServer,
  readToServerBody,
  readTraceQueryRequest,
  readTraceQueryResponse,
  readWorkflowHistory,
  readWorkflowHistoryRequest,
  readWorkflowHistoryResponse,
  readWorkflowHistoryUpdated,
  writeActionRequest,
  writeActionResponse,
  writeConnection,
  writeConnectionsRequest,
  writeConnectionsResponse,
  writeConnectionsUpdated,
  writeDatabaseSchemaRequest,
  writeDatabaseSchemaResponse,
  writeDatabaseTableRowsRequest,
  writeDatabaseTableRowsResponse,
  writeError,
  writeInit,
  writePatchStateRequest,
  writeQueueMessageSummary,
  writeQueueRequest,
  writeQueueResponse,
  writeQueueStatus,
  writeQueueUpdated,
  writeRpcsListRequest,
  writeRpcsListResponse,
  writeState,
  writeStateRequest,
  writeStateResponse,
  writeStateUpdated,
  writeToClient,
  writeToClientBody,
  writeToServer,
  writeToServerBody,
  writeTraceQueryRequest,
  writeTraceQueryResponse,
  writeWorkflowHistory,
  writeWorkflowHistoryRequest,
  writeWorkflowHistoryResponse,
  writeWorkflowHistoryUpdated
};
//# sourceMappingURL=client.js.map