@meshagent/meshagent 0.42.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/browser/agent-client.d.ts +4 -4
  3. package/dist/browser/agent-client.js +16 -16
  4. package/dist/browser/agent.d.ts +6 -6
  5. package/dist/browser/agent.js +57 -57
  6. package/dist/browser/api_keys.js +7 -3
  7. package/dist/browser/containers-client.d.ts +21 -3
  8. package/dist/browser/containers-client.js +126 -78
  9. package/dist/browser/datasets-client.d.ts +1 -1
  10. package/dist/browser/datasets-client.js +83 -83
  11. package/dist/browser/developer-client.d.ts +3 -3
  12. package/dist/browser/developer-client.js +11 -11
  13. package/dist/browser/document.d.ts +2 -2
  14. package/dist/browser/document.js +3 -3
  15. package/dist/browser/helpers.d.ts +4 -4
  16. package/dist/browser/helpers.js +9 -9
  17. package/dist/browser/index.d.ts +35 -35
  18. package/dist/browser/index.js +35 -35
  19. package/dist/browser/memory-client.d.ts +1 -1
  20. package/dist/browser/memory-client.js +6 -6
  21. package/dist/browser/meshagent-client.d.ts +1 -1
  22. package/dist/browser/meshagent-client.js +78 -78
  23. package/dist/browser/messaging-client.d.ts +4 -4
  24. package/dist/browser/messaging-client.js +33 -33
  25. package/dist/browser/participant-token.d.ts +1 -1
  26. package/dist/browser/participant-token.js +5 -5
  27. package/dist/browser/participant.d.ts +1 -1
  28. package/dist/browser/protocol.d.ts +7 -4
  29. package/dist/browser/protocol.js +36 -20
  30. package/dist/browser/queues-client.d.ts +1 -1
  31. package/dist/browser/queues-client.js +10 -10
  32. package/dist/browser/response.js +11 -11
  33. package/dist/browser/room-client.d.ts +23 -17
  34. package/dist/browser/room-client.js +138 -130
  35. package/dist/browser/room-server-client.d.ts +2 -2
  36. package/dist/browser/room-server-client.js +10 -10
  37. package/dist/browser/secrets-client.d.ts +3 -3
  38. package/dist/browser/secrets-client.js +30 -30
  39. package/dist/browser/services-client.d.ts +2 -2
  40. package/dist/browser/services-client.js +8 -8
  41. package/dist/browser/storage-client.d.ts +5 -5
  42. package/dist/browser/storage-client.js +30 -30
  43. package/dist/browser/sync-client.d.ts +4 -4
  44. package/dist/browser/sync-client.js +38 -38
  45. package/dist/browser/toolkit-config.d.ts +3 -3
  46. package/dist/esm/agent-client.d.ts +4 -4
  47. package/dist/esm/agent-client.js +19 -25
  48. package/dist/esm/agent.d.ts +6 -6
  49. package/dist/esm/agent.js +73 -93
  50. package/dist/esm/api_keys.js +12 -21
  51. package/dist/esm/client.js +7 -13
  52. package/dist/esm/completer.js +1 -5
  53. package/dist/esm/containers-client.d.ts +21 -3
  54. package/dist/esm/containers-client.js +132 -89
  55. package/dist/esm/datasets-client.d.ts +1 -1
  56. package/dist/esm/datasets-client.js +101 -111
  57. package/dist/esm/developer-client.d.ts +3 -3
  58. package/dist/esm/developer-client.js +11 -15
  59. package/dist/esm/document.d.ts +2 -2
  60. package/dist/esm/document.js +11 -20
  61. package/dist/esm/entrypoint.js +1 -12
  62. package/dist/esm/event-emitter.js +1 -5
  63. package/dist/esm/helpers.d.ts +4 -4
  64. package/dist/esm/helpers.js +15 -23
  65. package/dist/esm/index.d.ts +35 -35
  66. package/dist/esm/index.js +35 -51
  67. package/dist/esm/memory-client.d.ts +1 -1
  68. package/dist/esm/memory-client.js +7 -11
  69. package/dist/esm/meshagent-client.d.ts +1 -1
  70. package/dist/esm/meshagent-client.js +79 -83
  71. package/dist/esm/messaging-client.d.ts +4 -4
  72. package/dist/esm/messaging-client.js +33 -37
  73. package/dist/esm/oauth-scopes.js +2 -5
  74. package/dist/esm/participant-token.d.ts +1 -1
  75. package/dist/esm/participant-token.js +34 -62
  76. package/dist/esm/participant.d.ts +1 -1
  77. package/dist/esm/participant.js +3 -9
  78. package/dist/esm/protocol.d.ts +7 -4
  79. package/dist/esm/protocol.js +48 -46
  80. package/dist/esm/queues-client.d.ts +1 -1
  81. package/dist/esm/queues-client.js +12 -17
  82. package/dist/esm/requirement.js +4 -11
  83. package/dist/esm/response.js +22 -34
  84. package/dist/esm/room-client.d.ts +23 -17
  85. package/dist/esm/room-client.js +140 -137
  86. package/dist/esm/room-event.js +9 -21
  87. package/dist/esm/room-server-client.d.ts +2 -2
  88. package/dist/esm/room-server-client.js +13 -18
  89. package/dist/esm/runtime.js +1 -10
  90. package/dist/esm/schema.js +9 -18
  91. package/dist/esm/secrets-client.d.ts +3 -3
  92. package/dist/esm/secrets-client.js +31 -35
  93. package/dist/esm/services-client.d.ts +2 -2
  94. package/dist/esm/services-client.js +9 -13
  95. package/dist/esm/storage-client.d.ts +5 -5
  96. package/dist/esm/storage-client.js +32 -38
  97. package/dist/esm/stream-controller.js +1 -5
  98. package/dist/esm/sync-client.d.ts +4 -4
  99. package/dist/esm/sync-client.js +38 -42
  100. package/dist/esm/tool-content-type.js +1 -5
  101. package/dist/esm/toolkit-config.d.ts +3 -3
  102. package/dist/esm/toolkit-config.js +5 -13
  103. package/dist/esm/utils.js +10 -20
  104. package/dist/esm/version.js +1 -4
  105. package/dist/node/agent-client.d.ts +4 -4
  106. package/dist/node/agent-client.js +16 -16
  107. package/dist/node/agent.d.ts +6 -6
  108. package/dist/node/agent.js +57 -57
  109. package/dist/node/api_keys.js +7 -3
  110. package/dist/node/containers-client.d.ts +21 -3
  111. package/dist/node/containers-client.js +126 -78
  112. package/dist/node/datasets-client.d.ts +1 -1
  113. package/dist/node/datasets-client.js +83 -83
  114. package/dist/node/developer-client.d.ts +3 -3
  115. package/dist/node/developer-client.js +11 -11
  116. package/dist/node/document.d.ts +2 -2
  117. package/dist/node/document.js +3 -3
  118. package/dist/node/helpers.d.ts +4 -4
  119. package/dist/node/helpers.js +9 -9
  120. package/dist/node/index.d.ts +35 -35
  121. package/dist/node/index.js +35 -35
  122. package/dist/node/memory-client.d.ts +1 -1
  123. package/dist/node/memory-client.js +6 -6
  124. package/dist/node/meshagent-client.d.ts +1 -1
  125. package/dist/node/meshagent-client.js +78 -78
  126. package/dist/node/messaging-client.d.ts +4 -4
  127. package/dist/node/messaging-client.js +33 -33
  128. package/dist/node/participant-token.d.ts +1 -1
  129. package/dist/node/participant-token.js +5 -5
  130. package/dist/node/participant.d.ts +1 -1
  131. package/dist/node/protocol.d.ts +7 -4
  132. package/dist/node/protocol.js +36 -20
  133. package/dist/node/queues-client.d.ts +1 -1
  134. package/dist/node/queues-client.js +10 -10
  135. package/dist/node/response.js +11 -11
  136. package/dist/node/room-client.d.ts +23 -17
  137. package/dist/node/room-client.js +138 -130
  138. package/dist/node/room-server-client.d.ts +2 -2
  139. package/dist/node/room-server-client.js +10 -10
  140. package/dist/node/secrets-client.d.ts +3 -3
  141. package/dist/node/secrets-client.js +30 -30
  142. package/dist/node/services-client.d.ts +2 -2
  143. package/dist/node/services-client.js +8 -8
  144. package/dist/node/storage-client.d.ts +5 -5
  145. package/dist/node/storage-client.js +30 -30
  146. package/dist/node/sync-client.d.ts +4 -4
  147. package/dist/node/sync-client.js +38 -38
  148. package/dist/node/toolkit-config.d.ts +3 -3
  149. package/package.json +11 -5
  150. package/dist/browser/lk-client.d.ts +0 -18
  151. package/dist/browser/lk-client.js +0 -33
  152. package/dist/browser/lk-protocol.d.ts +0 -22
  153. package/dist/browser/lk-protocol.js +0 -37
  154. package/dist/esm/lk-client.d.ts +0 -18
  155. package/dist/esm/lk-client.js +0 -33
  156. package/dist/esm/lk-protocol.d.ts +0 -22
  157. package/dist/esm/lk-protocol.js +0 -37
  158. package/dist/node/lk-client.d.ts +0 -18
  159. package/dist/node/lk-client.js +0 -33
  160. package/dist/node/lk-protocol.d.ts +0 -22
  161. package/dist/node/lk-protocol.js +0 -37
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DatasetsClient = exports.DatasetUuid = exports.DatasetJson = exports.DatasetStruct = exports.DatasetDate = exports.DatasetExpression = exports.DatasetValueEncoder = void 0;
4
- const apache_arrow_1 = require("apache-arrow");
5
- const room_server_client_1 = require("./room-server-client");
6
- const response_1 = require("./response");
1
+ import { Schema, Table, tableFromIPC, tableToIPC } from "apache-arrow";
2
+ import { RoomServerException } from "./room-server-client.js";
3
+ import { BinaryContent, ControlContent, EmptyContent, ErrorContent, JsonContent } from "./response.js";
7
4
  const ARROW_IPC_STREAM_MIME_TYPE = "application/vnd.apache.arrow.stream";
8
- class DatasetValueEncoder {
5
+ export class DatasetValueEncoder {
9
6
  }
10
- exports.DatasetValueEncoder = DatasetValueEncoder;
11
- class DatasetExpression extends DatasetValueEncoder {
7
+ export class DatasetExpression extends DatasetValueEncoder {
12
8
  constructor(expression) {
13
9
  super();
14
10
  const normalized = expression.trim();
@@ -26,8 +22,7 @@ class DatasetExpression extends DatasetValueEncoder {
26
22
  return this.expression;
27
23
  }
28
24
  }
29
- exports.DatasetExpression = DatasetExpression;
30
- class DatasetDate extends DatasetValueEncoder {
25
+ export class DatasetDate extends DatasetValueEncoder {
31
26
  constructor(value) {
32
27
  super();
33
28
  const normalized = value.trim();
@@ -46,8 +41,7 @@ class DatasetDate extends DatasetValueEncoder {
46
41
  return this.value;
47
42
  }
48
43
  }
49
- exports.DatasetDate = DatasetDate;
50
- class DatasetStruct extends DatasetValueEncoder {
44
+ export class DatasetStruct extends DatasetValueEncoder {
51
45
  constructor(fields) {
52
46
  super();
53
47
  this.fields = Object.fromEntries(Object.entries(fields).map(([key, value]) => {
@@ -66,8 +60,7 @@ class DatasetStruct extends DatasetValueEncoder {
66
60
  };
67
61
  }
68
62
  }
69
- exports.DatasetStruct = DatasetStruct;
70
- class DatasetJson extends DatasetValueEncoder {
63
+ export class DatasetJson extends DatasetValueEncoder {
71
64
  constructor(value) {
72
65
  super();
73
66
  this.value = normalizeDatasetJsonValue(value);
@@ -81,14 +74,13 @@ class DatasetJson extends DatasetValueEncoder {
81
74
  };
82
75
  }
83
76
  }
84
- exports.DatasetJson = DatasetJson;
85
77
  const globalScope = globalThis;
86
78
  const UUID_HEX_REGEX = /^[0-9a-f]{32}$/;
87
79
  const ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
88
80
  function normalizeUuidHex(value) {
89
81
  const normalized = value.trim().toLowerCase().replace(/-/g, "");
90
82
  if (!UUID_HEX_REGEX.test(normalized)) {
91
- throw new room_server_client_1.RoomServerException("invalid uuid format");
83
+ throw new RoomServerException("invalid uuid format");
92
84
  }
93
85
  return normalized;
94
86
  }
@@ -99,7 +91,7 @@ function formatUuidHex(value) {
99
91
  `${value.substring(16, 20)}-` +
100
92
  `${value.substring(20)}`);
101
93
  }
102
- class DatasetUuid {
94
+ export class DatasetUuid {
103
95
  constructor(value) {
104
96
  this.value = formatUuidHex(normalizeUuidHex(value));
105
97
  }
@@ -107,7 +99,6 @@ class DatasetUuid {
107
99
  return this.value;
108
100
  }
109
101
  }
110
- exports.DatasetUuid = DatasetUuid;
111
102
  function bytesToBase64(bytes) {
112
103
  if (globalScope.Buffer) {
113
104
  return globalScope.Buffer.from(bytes).toString("base64");
@@ -191,7 +182,7 @@ function encodeRecordValue(value) {
191
182
  };
192
183
  }
193
184
  if (isRecord(value)) {
194
- throw new room_server_client_1.RoomServerException("dataset object values must use DatasetStruct or DatasetJson");
185
+ throw new RoomServerException("dataset object values must use DatasetStruct or DatasetJson");
195
186
  }
196
187
  return value;
197
188
  }
@@ -216,62 +207,62 @@ function datasetSqlLiteral(value) {
216
207
  }
217
208
  function decodeRecordValue(value) {
218
209
  if (Array.isArray(value)) {
219
- throw new room_server_client_1.RoomServerException("dataset list values must use a {'list': [...]} wrapper");
210
+ throw new RoomServerException("dataset list values must use a {'list': [...]} wrapper");
220
211
  }
221
212
  if (!isRecord(value)) {
222
213
  return value;
223
214
  }
224
215
  const entries = Object.entries(value);
225
216
  if (entries.length !== 1) {
226
- throw new room_server_client_1.RoomServerException("dataset object values must use a single-key type wrapper");
217
+ throw new RoomServerException("dataset object values must use a single-key type wrapper");
227
218
  }
228
219
  const [wrapper, payload] = entries[0];
229
220
  switch (wrapper) {
230
221
  case "binary":
231
222
  if (typeof payload !== "string") {
232
- throw new room_server_client_1.RoomServerException("dataset binary values must be base64 strings");
223
+ throw new RoomServerException("dataset binary values must be base64 strings");
233
224
  }
234
225
  return base64ToBytes(payload);
235
226
  case "uuid":
236
227
  if (typeof payload !== "string") {
237
- throw new room_server_client_1.RoomServerException("dataset uuid values must be strings");
228
+ throw new RoomServerException("dataset uuid values must be strings");
238
229
  }
239
230
  return new DatasetUuid(payload);
240
231
  case "expression":
241
232
  if (typeof payload !== "string") {
242
- throw new room_server_client_1.RoomServerException("dataset expression values must be strings");
233
+ throw new RoomServerException("dataset expression values must be strings");
243
234
  }
244
235
  return new DatasetExpression(payload);
245
236
  case "date":
246
237
  if (typeof payload !== "string") {
247
- throw new room_server_client_1.RoomServerException("dataset date values must be strings");
238
+ throw new RoomServerException("dataset date values must be strings");
248
239
  }
249
240
  return new DatasetDate(payload);
250
241
  case "timestamp":
251
242
  if (typeof payload !== "string") {
252
- throw new room_server_client_1.RoomServerException("dataset timestamp values must be strings");
243
+ throw new RoomServerException("dataset timestamp values must be strings");
253
244
  }
254
245
  {
255
246
  const parsed = new Date(payload);
256
247
  if (Number.isNaN(parsed.getTime())) {
257
- throw new room_server_client_1.RoomServerException("dataset timestamp value is not valid");
248
+ throw new RoomServerException("dataset timestamp value is not valid");
258
249
  }
259
250
  return parsed;
260
251
  }
261
252
  case "list":
262
253
  if (!Array.isArray(payload)) {
263
- throw new room_server_client_1.RoomServerException("dataset list values must be arrays");
254
+ throw new RoomServerException("dataset list values must be arrays");
264
255
  }
265
256
  return payload.map((item) => decodeRecordValue(item));
266
257
  case "struct":
267
258
  if (!isRecord(payload)) {
268
- throw new room_server_client_1.RoomServerException("dataset struct values must be objects");
259
+ throw new RoomServerException("dataset struct values must be objects");
269
260
  }
270
261
  return new DatasetStruct(Object.fromEntries(Object.entries(payload).map(([key, item]) => [key, decodeRecordValue(item)])));
271
262
  case "json":
272
263
  return new DatasetJson(normalizeDatasetJsonValue(payload));
273
264
  default:
274
- throw new room_server_client_1.RoomServerException(`unsupported dataset value wrapper '${wrapper}'`);
265
+ throw new RoomServerException(`unsupported dataset value wrapper '${wrapper}'`);
275
266
  }
276
267
  }
277
268
  function encodeDatasetRecord(record) {
@@ -290,28 +281,28 @@ function rowsChunk(records) {
290
281
  }
291
282
  function recordsFromRowsChunk(payload, operation) {
292
283
  if (!isRecord(payload) || payload.kind !== "rows" || !Array.isArray(payload.rows)) {
293
- throw new room_server_client_1.RoomServerException(`unexpected return type from datasets.${operation}`);
284
+ throw new RoomServerException(`unexpected return type from datasets.${operation}`);
294
285
  }
295
286
  return payload.rows.map((row) => {
296
287
  if (!isRecord(row) || !Array.isArray(row.columns)) {
297
- throw new room_server_client_1.RoomServerException(`unexpected return type from datasets.${operation}`);
288
+ throw new RoomServerException(`unexpected return type from datasets.${operation}`);
298
289
  }
299
290
  return Object.fromEntries(row.columns.map((column) => {
300
291
  if (!isRecord(column) || typeof column.name !== "string") {
301
- throw new room_server_client_1.RoomServerException(`unexpected return type from datasets.${operation}`);
292
+ throw new RoomServerException(`unexpected return type from datasets.${operation}`);
302
293
  }
303
294
  try {
304
295
  return [column.name, decodeRecordValue(column.value)];
305
296
  }
306
297
  catch {
307
- throw new room_server_client_1.RoomServerException(`unexpected return type from datasets.${operation}`);
298
+ throw new RoomServerException(`unexpected return type from datasets.${operation}`);
308
299
  }
309
300
  }));
310
301
  });
311
302
  }
312
303
  function rowChunkList(records, rowsPerChunk = 128) {
313
304
  if (rowsPerChunk <= 0) {
314
- throw new room_server_client_1.RoomServerException("rowsPerChunk must be greater than zero");
305
+ throw new RoomServerException("rowsPerChunk must be greater than zero");
315
306
  }
316
307
  const chunks = [];
317
308
  for (let index = 0; index < records.length; index += rowsPerChunk) {
@@ -346,14 +337,14 @@ function normalizeTableRefs(tables) {
346
337
  }
347
338
  function tableIndexFromJson(value) {
348
339
  if (!isRecord(value) || typeof value.name !== "string" || typeof value.type !== "string" || !Array.isArray(value.columns)) {
349
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_indexes");
340
+ throw new RoomServerException("unexpected return type from datasets.list_indexes");
350
341
  }
351
342
  return {
352
343
  name: value.name,
353
344
  type: value.type,
354
345
  columns: value.columns.map((column) => {
355
346
  if (typeof column !== "string") {
356
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_indexes");
347
+ throw new RoomServerException("unexpected return type from datasets.list_indexes");
357
348
  }
358
349
  return column;
359
350
  }),
@@ -368,7 +359,7 @@ function tableIndexFromJson(value) {
368
359
  }
369
360
  function optimizeResultFromJson(value) {
370
361
  if (!isRecord(value)) {
371
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.optimize");
362
+ throw new RoomServerException("unexpected return type from datasets.optimize");
372
363
  }
373
364
  return {
374
365
  compaction: typeof value.compaction_json === "string" ? JSON.parse(value.compaction_json) : isRecord(value.compaction) ? value.compaction : null,
@@ -378,32 +369,32 @@ function optimizeResultFromJson(value) {
378
369
  }
379
370
  function tableStatsFromJson(value) {
380
371
  if (!isRecord(value)) {
381
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.stats");
372
+ throw new RoomServerException("unexpected return type from datasets.stats");
382
373
  }
383
374
  const dataset = typeof value.dataset_json === "string" ? JSON.parse(value.dataset_json) : value.dataset;
384
375
  const data = typeof value.data_json === "string" ? JSON.parse(value.data_json) : value.data;
385
376
  if (!isRecord(dataset) || !isRecord(data)) {
386
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.stats");
377
+ throw new RoomServerException("unexpected return type from datasets.stats");
387
378
  }
388
379
  return { dataset, data };
389
380
  }
390
381
  function tableVersionFromJson(value) {
391
382
  if (!isRecord(value) || typeof value.metadata_json !== "string" || typeof value.timestamp !== "string" || typeof value.version !== "number") {
392
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_versions");
383
+ throw new RoomServerException("unexpected return type from datasets.list_versions");
393
384
  }
394
385
  const timestamp = new Date(value.timestamp);
395
386
  if (Number.isNaN(timestamp.getTime())) {
396
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_versions");
387
+ throw new RoomServerException("unexpected return type from datasets.list_versions");
397
388
  }
398
389
  let metadata;
399
390
  try {
400
391
  metadata = JSON.parse(value.metadata_json);
401
392
  }
402
393
  catch (_) {
403
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_versions");
394
+ throw new RoomServerException("unexpected return type from datasets.list_versions");
404
395
  }
405
396
  if (!isRecord(metadata)) {
406
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_versions");
397
+ throw new RoomServerException("unexpected return type from datasets.list_versions");
407
398
  }
408
399
  return {
409
400
  version: value.version,
@@ -413,27 +404,27 @@ function tableVersionFromJson(value) {
413
404
  }
414
405
  function tableBranchFromJson(value) {
415
406
  if (!isRecord(value) || typeof value.name !== "string") {
416
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_branches");
407
+ throw new RoomServerException("unexpected return type from datasets.list_branches");
417
408
  }
418
409
  if (value.parent_branch != null && typeof value.parent_branch !== "string") {
419
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_branches");
410
+ throw new RoomServerException("unexpected return type from datasets.list_branches");
420
411
  }
421
412
  if (value.parent_version != null
422
413
  && (typeof value.parent_version !== "number" || !Number.isInteger(value.parent_version))) {
423
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_branches");
414
+ throw new RoomServerException("unexpected return type from datasets.list_branches");
424
415
  }
425
416
  if (value.manifest_size != null
426
417
  && (typeof value.manifest_size !== "number" || !Number.isInteger(value.manifest_size))) {
427
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_branches");
418
+ throw new RoomServerException("unexpected return type from datasets.list_branches");
428
419
  }
429
420
  let createdAt = null;
430
421
  if (value.created_at != null) {
431
422
  if (typeof value.created_at !== "string") {
432
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_branches");
423
+ throw new RoomServerException("unexpected return type from datasets.list_branches");
433
424
  }
434
425
  createdAt = new Date(value.created_at);
435
426
  if (Number.isNaN(createdAt.getTime())) {
436
- throw new room_server_client_1.RoomServerException("unexpected return type from datasets.list_branches");
427
+ throw new RoomServerException("unexpected return type from datasets.list_branches");
437
428
  }
438
429
  }
439
430
  return {
@@ -499,7 +490,7 @@ class DatasetWriteInputStream {
499
490
  });
500
491
  }
501
492
  async *stream() {
502
- yield new response_1.JsonContent({ json: this.start });
493
+ yield new JsonContent({ json: this.start });
503
494
  while (!this.closed) {
504
495
  await this.waitForPull();
505
496
  if (this.closed) {
@@ -512,7 +503,7 @@ class DatasetWriteInputStream {
512
503
  if (nextChunk.value.length === 0) {
513
504
  continue;
514
505
  }
515
- yield new response_1.JsonContent({ json: rowsChunk(nextChunk.value) });
506
+ yield new JsonContent({ json: rowsChunk(nextChunk.value) });
516
507
  }
517
508
  }
518
509
  }
@@ -528,18 +519,18 @@ async function* toAsyncArrowIterable(chunks) {
528
519
  }
529
520
  }
530
521
  function schemaToIPC(schema) {
531
- return (0, apache_arrow_1.tableToIPC)(new apache_arrow_1.Table(schema, []), "stream");
522
+ return tableToIPC(new Table(schema, []), "stream");
532
523
  }
533
524
  function tableFromIPCBytes(data) {
534
- const table = (0, apache_arrow_1.tableFromIPC)(data);
525
+ const table = tableFromIPC(data);
535
526
  if (table instanceof Promise) {
536
- throw new room_server_client_1.RoomServerException("unexpected async Arrow IPC result");
527
+ throw new RoomServerException("unexpected async Arrow IPC result");
537
528
  }
538
529
  return table;
539
530
  }
540
531
  function tableFromChunks(chunks) {
541
532
  if (chunks.length === 0) {
542
- return new apache_arrow_1.Table(new apache_arrow_1.Schema([]), []);
533
+ return new Table(new Schema([]), []);
543
534
  }
544
535
  const [first, ...rest] = chunks;
545
536
  return first.concat(...rest);
@@ -591,7 +582,7 @@ class DatasetArrowWriteInputStream {
591
582
  });
592
583
  }
593
584
  async *stream() {
594
- yield new response_1.BinaryContent({
585
+ yield new BinaryContent({
595
586
  data: this.schema == null ? new Uint8Array() : schemaToIPC(this.schema),
596
587
  headers: this.start,
597
588
  });
@@ -607,8 +598,8 @@ class DatasetArrowWriteInputStream {
607
598
  if (nextChunk.value.numRows === 0) {
608
599
  continue;
609
600
  }
610
- yield new response_1.BinaryContent({
611
- data: (0, apache_arrow_1.tableToIPC)(nextChunk.value, "stream"),
601
+ yield new BinaryContent({
602
+ data: tableToIPC(nextChunk.value, "stream"),
612
603
  headers: { kind: "data", content_type: ARROW_IPC_STREAM_MIME_TYPE },
613
604
  });
614
605
  }
@@ -655,13 +646,13 @@ class DatasetReadInputStream {
655
646
  });
656
647
  }
657
648
  async *stream() {
658
- yield new response_1.JsonContent({ json: this.start });
649
+ yield new JsonContent({ json: this.start });
659
650
  while (!this.closed) {
660
651
  await this.waitForPull();
661
652
  if (this.closed) {
662
653
  return;
663
654
  }
664
- yield new response_1.JsonContent({ json: { kind: "pull" } });
655
+ yield new JsonContent({ json: { kind: "pull" } });
665
656
  }
666
657
  }
667
658
  }
@@ -706,26 +697,26 @@ class DatasetArrowReadInputStream {
706
697
  });
707
698
  }
708
699
  async *stream() {
709
- yield new response_1.BinaryContent({ data: new Uint8Array(), headers: this.start });
700
+ yield new BinaryContent({ data: new Uint8Array(), headers: this.start });
710
701
  while (!this.closed) {
711
702
  await this.waitForPull();
712
703
  if (this.closed) {
713
704
  return;
714
705
  }
715
- yield new response_1.BinaryContent({ data: new Uint8Array(), headers: { kind: "pull" } });
706
+ yield new BinaryContent({ data: new Uint8Array(), headers: { kind: "pull" } });
716
707
  }
717
708
  }
718
709
  }
719
- class DatasetsClient {
710
+ export class DatasetsClient {
720
711
  constructor({ room }) {
721
712
  this.room = room;
722
713
  }
723
714
  _unexpectedResponseError(operation) {
724
- return new room_server_client_1.RoomServerException(`unexpected return type from datasets.${operation}`);
715
+ return new RoomServerException(`unexpected return type from datasets.${operation}`);
725
716
  }
726
717
  async invoke(operation, input) {
727
718
  const response = await this.room.invoke({ toolkit: "dataset", tool: operation, input });
728
- if (response instanceof response_1.JsonContent) {
719
+ if (response instanceof JsonContent) {
729
720
  return response;
730
721
  }
731
722
  if (response == null) {
@@ -743,23 +734,23 @@ class DatasetsClient {
743
734
  const response = await this.invokeStream(operation, input.stream());
744
735
  try {
745
736
  for await (const chunk of response) {
746
- if (chunk instanceof response_1.ErrorContent) {
747
- throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
737
+ if (chunk instanceof ErrorContent) {
738
+ throw new RoomServerException(chunk.text, chunk.code);
748
739
  }
749
- if (chunk instanceof response_1.ControlContent) {
740
+ if (chunk instanceof ControlContent) {
750
741
  if (chunk.method === "close") {
751
742
  return;
752
743
  }
753
744
  throw this._unexpectedResponseError(operation);
754
745
  }
755
- if (chunk instanceof response_1.BinaryContent) {
746
+ if (chunk instanceof BinaryContent) {
756
747
  if (chunk.headers.kind !== "pull") {
757
748
  throw this._unexpectedResponseError(operation);
758
749
  }
759
750
  input.requestNext();
760
751
  continue;
761
752
  }
762
- if (!(chunk instanceof response_1.JsonContent) || chunk.json.kind !== "pull") {
753
+ if (!(chunk instanceof JsonContent) || chunk.json.kind !== "pull") {
763
754
  throw this._unexpectedResponseError(operation);
764
755
  }
765
756
  input.requestNext();
@@ -775,16 +766,16 @@ class DatasetsClient {
775
766
  input.requestNext();
776
767
  try {
777
768
  for await (const chunk of response) {
778
- if (chunk instanceof response_1.ErrorContent) {
779
- throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
769
+ if (chunk instanceof ErrorContent) {
770
+ throw new RoomServerException(chunk.text, chunk.code);
780
771
  }
781
- if (chunk instanceof response_1.ControlContent) {
772
+ if (chunk instanceof ControlContent) {
782
773
  if (chunk.method === "close") {
783
774
  return;
784
775
  }
785
776
  throw this._unexpectedResponseError(operation);
786
777
  }
787
- if (!(chunk instanceof response_1.JsonContent)) {
778
+ if (!(chunk instanceof JsonContent)) {
788
779
  throw this._unexpectedResponseError(operation);
789
780
  }
790
781
  yield recordsFromRowsChunk(chunk.json, operation);
@@ -801,16 +792,16 @@ class DatasetsClient {
801
792
  input.requestNext();
802
793
  try {
803
794
  for await (const chunk of response) {
804
- if (chunk instanceof response_1.ErrorContent) {
805
- throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
795
+ if (chunk instanceof ErrorContent) {
796
+ throw new RoomServerException(chunk.text, chunk.code);
806
797
  }
807
- if (chunk instanceof response_1.ControlContent) {
798
+ if (chunk instanceof ControlContent) {
808
799
  if (chunk.method === "close") {
809
800
  return;
810
801
  }
811
802
  throw this._unexpectedResponseError(operation);
812
803
  }
813
- if (!(chunk instanceof response_1.BinaryContent) || chunk.headers.kind !== "data") {
804
+ if (!(chunk instanceof BinaryContent) || chunk.headers.kind !== "data") {
814
805
  throw this._unexpectedResponseError(operation);
815
806
  }
816
807
  yield tableFromIPCBytes(chunk.data);
@@ -826,7 +817,7 @@ class DatasetsClient {
826
817
  namespace: namespace ?? null,
827
818
  branch: branch ?? null,
828
819
  });
829
- if (!(response instanceof response_1.JsonContent)) {
820
+ if (!(response instanceof JsonContent)) {
830
821
  throw this._unexpectedResponseError("list_tables");
831
822
  }
832
823
  return Array.isArray(response.json.tables) ? response.json.tables : [];
@@ -846,7 +837,7 @@ class DatasetsClient {
846
837
  return this.createTable({
847
838
  name,
848
839
  schema,
849
- data: data == null ? undefined : data instanceof apache_arrow_1.Table ? [data] : data,
840
+ data: data == null ? undefined : data instanceof Table ? [data] : data,
850
841
  mode,
851
842
  namespace,
852
843
  branch,
@@ -888,7 +879,7 @@ class DatasetsClient {
888
879
  async createTableFromData({ name, data, mode = "create", namespace, branch, metadata }) {
889
880
  return this.createTable({
890
881
  name,
891
- data: data == null ? undefined : data instanceof apache_arrow_1.Table ? [data] : data,
882
+ data: data == null ? undefined : data instanceof Table ? [data] : data,
892
883
  mode,
893
884
  namespace,
894
885
  branch,
@@ -972,8 +963,8 @@ class DatasetsClient {
972
963
  });
973
964
  }
974
965
  async addColumns({ table, newColumns, namespace, branch }) {
975
- if (newColumns instanceof apache_arrow_1.Schema) {
976
- await this.invokeContent("add_columns", new response_1.BinaryContent({
966
+ if (newColumns instanceof Schema) {
967
+ await this.invokeContent("add_columns", new BinaryContent({
977
968
  data: schemaToIPC(newColumns),
978
969
  headers: {
979
970
  table,
@@ -1064,8 +1055,8 @@ class DatasetsClient {
1064
1055
  return tableFromChunks(await this.sql({ query, tables, params, namespace, branch }));
1065
1056
  }
1066
1057
  async openSqlQuery({ query, tables, params, namespace, branch }) {
1067
- const response = await this.invokeContent("open_sql_query", new response_1.BinaryContent({
1068
- data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
1058
+ const response = await this.invokeContent("open_sql_query", new BinaryContent({
1059
+ data: params == null ? new Uint8Array() : tableToIPC(params, "stream"),
1069
1060
  headers: {
1070
1061
  query,
1071
1062
  tables: normalizeTableRefs(tables ?? []),
@@ -1073,7 +1064,7 @@ class DatasetsClient {
1073
1064
  branch: branch ?? null,
1074
1065
  },
1075
1066
  }));
1076
- if (!(response instanceof response_1.BinaryContent)) {
1067
+ if (!(response instanceof BinaryContent)) {
1077
1068
  throw this._unexpectedResponseError("open_sql_query");
1078
1069
  }
1079
1070
  const queryId = response.headers.query_id;
@@ -1087,8 +1078,8 @@ class DatasetsClient {
1087
1078
  };
1088
1079
  }
1089
1080
  async executeSql({ query, tables, params, namespace, branch }) {
1090
- const response = await this.invokeContent("execute_sql", new response_1.BinaryContent({
1091
- data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
1081
+ const response = await this.invokeContent("execute_sql", new BinaryContent({
1082
+ data: params == null ? new Uint8Array() : tableToIPC(params, "stream"),
1092
1083
  headers: {
1093
1084
  query,
1094
1085
  tables: normalizeTableRefs(tables ?? []),
@@ -1096,7 +1087,7 @@ class DatasetsClient {
1096
1087
  branch: branch ?? null,
1097
1088
  },
1098
1089
  }));
1099
- if (response instanceof response_1.BinaryContent) {
1090
+ if (response instanceof BinaryContent) {
1100
1091
  if (response.headers.kind !== "query") {
1101
1092
  throw this._unexpectedResponseError("execute_sql");
1102
1093
  }
@@ -1110,7 +1101,7 @@ class DatasetsClient {
1110
1101
  queryId,
1111
1102
  };
1112
1103
  }
1113
- if (response instanceof response_1.JsonContent) {
1104
+ if (response instanceof JsonContent) {
1114
1105
  if (response.json.kind !== "statement"
1115
1106
  || typeof response.json.rows_affected !== "number"
1116
1107
  || !Number.isInteger(response.json.rows_affected)) {
@@ -1126,7 +1117,7 @@ class DatasetsClient {
1126
1117
  async *sqlStream({ query, tables, params, namespace, branch }) {
1127
1118
  const result = await this.executeSql({ query, tables, params, namespace, branch });
1128
1119
  if (result.kind === "statement") {
1129
- throw new room_server_client_1.RoomServerException(`SQL statement did not return rows; rows_affected=${result.rowsAffected}`);
1120
+ throw new RoomServerException(`SQL statement did not return rows; rows_affected=${result.rowsAffected}`);
1130
1121
  }
1131
1122
  const opened = result;
1132
1123
  try {
@@ -1144,21 +1135,21 @@ class DatasetsClient {
1144
1135
  }
1145
1136
  async closeSqlQuery({ queryId }) {
1146
1137
  const response = await this.room.invoke({ toolkit: "dataset", tool: "close_sql_query", input: { query_id: queryId } });
1147
- if (!(response instanceof response_1.EmptyContent)) {
1138
+ if (!(response instanceof EmptyContent)) {
1148
1139
  throw this._unexpectedResponseError("close_sql_query");
1149
1140
  }
1150
1141
  }
1151
1142
  async cancelSqlQuery({ queryId }) {
1152
1143
  const response = await this.room.invoke({ toolkit: "dataset", tool: "cancel_sql_query", input: { query_id: queryId } });
1153
- if (!(response instanceof response_1.JsonContent)
1144
+ if (!(response instanceof JsonContent)
1154
1145
  || !["cancelled", "cancelling", "not_cancellable"].includes(response.json.status)) {
1155
1146
  throw this._unexpectedResponseError("cancel_sql_query");
1156
1147
  }
1157
1148
  return { status: response.json.status };
1158
1149
  }
1159
1150
  async executeSqlStatement({ query, tables, params, namespace, branch }) {
1160
- const response = await this.invokeContent("execute_sql_statement", new response_1.BinaryContent({
1161
- data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
1151
+ const response = await this.invokeContent("execute_sql_statement", new BinaryContent({
1152
+ data: params == null ? new Uint8Array() : tableToIPC(params, "stream"),
1162
1153
  headers: {
1163
1154
  query,
1164
1155
  tables: normalizeTableRefs(tables ?? []),
@@ -1166,7 +1157,7 @@ class DatasetsClient {
1166
1157
  branch: branch ?? null,
1167
1158
  },
1168
1159
  }));
1169
- if (!(response instanceof response_1.JsonContent)
1160
+ if (!(response instanceof JsonContent)
1170
1161
  || typeof response.json.rows_affected !== "number"
1171
1162
  || !Number.isInteger(response.json.rows_affected)) {
1172
1163
  throw this._unexpectedResponseError("execute_sql_statement");
@@ -1233,16 +1224,16 @@ class DatasetsClient {
1233
1224
  input.requestNext();
1234
1225
  try {
1235
1226
  for await (const chunk of response) {
1236
- if (chunk instanceof response_1.ErrorContent) {
1237
- throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
1227
+ if (chunk instanceof ErrorContent) {
1228
+ throw new RoomServerException(chunk.text, chunk.code);
1238
1229
  }
1239
- if (chunk instanceof response_1.ControlContent) {
1230
+ if (chunk instanceof ControlContent) {
1240
1231
  if (chunk.method === "close") {
1241
1232
  return;
1242
1233
  }
1243
1234
  throw this._unexpectedResponseError("watch_table");
1244
1235
  }
1245
- if (chunk instanceof response_1.BinaryContent) {
1236
+ if (chunk instanceof BinaryContent) {
1246
1237
  if (chunk.headers.kind !== "data") {
1247
1238
  throw this._unexpectedResponseError("watch_table");
1248
1239
  }
@@ -1260,7 +1251,7 @@ class DatasetsClient {
1260
1251
  input.requestNext();
1261
1252
  continue;
1262
1253
  }
1263
- if (chunk instanceof response_1.JsonContent) {
1254
+ if (chunk instanceof JsonContent) {
1264
1255
  if (!isRecord(chunk.json)) {
1265
1256
  throw this._unexpectedResponseError("watch_table");
1266
1257
  }
@@ -1299,7 +1290,7 @@ class DatasetsClient {
1299
1290
  branch: branch ?? null,
1300
1291
  version: version ?? null,
1301
1292
  });
1302
- if (!(response instanceof response_1.JsonContent) || typeof response.json.count !== "number" || !Number.isInteger(response.json.count)) {
1293
+ if (!(response instanceof JsonContent) || typeof response.json.count !== "number" || !Number.isInteger(response.json.count)) {
1303
1294
  throw this._unexpectedResponseError("count");
1304
1295
  }
1305
1296
  return response.json.count;
@@ -1315,7 +1306,7 @@ class DatasetsClient {
1315
1306
  version: version ?? null,
1316
1307
  },
1317
1308
  });
1318
- if (!(response instanceof response_1.BinaryContent)) {
1309
+ if (!(response instanceof BinaryContent)) {
1319
1310
  throw this._unexpectedResponseError("inspect");
1320
1311
  }
1321
1312
  return tableFromIPCBytes(response.data).schema;
@@ -1331,7 +1322,7 @@ class DatasetsClient {
1331
1322
  branch: branch ?? null,
1332
1323
  config: config ?? null,
1333
1324
  });
1334
- if (!(response instanceof response_1.JsonContent)) {
1325
+ if (!(response instanceof JsonContent)) {
1335
1326
  throw this._unexpectedResponseError("optimize");
1336
1327
  }
1337
1328
  return optimizeResultFromJson(response.json);
@@ -1344,7 +1335,7 @@ class DatasetsClient {
1344
1335
  version: version ?? null,
1345
1336
  max_rows_per_group: maxRowsPerGroup ?? null,
1346
1337
  });
1347
- if (!(response instanceof response_1.JsonContent)) {
1338
+ if (!(response instanceof JsonContent)) {
1348
1339
  throw this._unexpectedResponseError("stats");
1349
1340
  }
1350
1341
  return tableStatsFromJson(response.json);
@@ -1362,7 +1353,7 @@ class DatasetsClient {
1362
1353
  namespace: namespace ?? null,
1363
1354
  branch: branch ?? null,
1364
1355
  });
1365
- if (!(response instanceof response_1.JsonContent) || !Array.isArray(response.json.versions)) {
1356
+ if (!(response instanceof JsonContent) || !Array.isArray(response.json.versions)) {
1366
1357
  throw this._unexpectedResponseError("list_versions");
1367
1358
  }
1368
1359
  return response.json.versions.map((version) => tableVersionFromJson(version));
@@ -1381,7 +1372,7 @@ class DatasetsClient {
1381
1372
  branch: branch ?? null,
1382
1373
  version: version ?? null,
1383
1374
  });
1384
- if (!(response instanceof response_1.JsonContent) || !Array.isArray(response.json.indexes)) {
1375
+ if (!(response instanceof JsonContent) || !Array.isArray(response.json.indexes)) {
1385
1376
  throw this._unexpectedResponseError("list_indexes");
1386
1377
  }
1387
1378
  return response.json.indexes.map((index) => tableIndexFromJson(index));
@@ -1390,7 +1381,7 @@ class DatasetsClient {
1390
1381
  const response = await this.invoke("list_branches", {
1391
1382
  namespace: namespace ?? null,
1392
1383
  });
1393
- if (!(response instanceof response_1.JsonContent) || !Array.isArray(response.json.branches)) {
1384
+ if (!(response instanceof JsonContent) || !Array.isArray(response.json.branches)) {
1394
1385
  throw this._unexpectedResponseError("list_branches");
1395
1386
  }
1396
1387
  return response.json.branches.map((branch) => tableBranchFromJson(branch));
@@ -1414,4 +1405,3 @@ class DatasetsClient {
1414
1405
  });
1415
1406
  }
1416
1407
  }
1417
- exports.DatasetsClient = DatasetsClient;