@meshagent/meshagent 0.39.3 → 0.39.4

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 (48) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +134 -21
  3. package/dist/browser/entrypoint.d.ts +1426 -1464
  4. package/dist/browser/meshagent-client.js +7 -2
  5. package/dist/browser/package.json +1 -0
  6. package/dist/esm/agent-client.js +18 -12
  7. package/dist/esm/agent.js +26 -18
  8. package/dist/esm/api_keys.js +21 -11
  9. package/dist/esm/client.js +13 -7
  10. package/dist/esm/completer.js +5 -1
  11. package/dist/esm/containers-client.js +85 -80
  12. package/dist/esm/datasets-client.js +105 -95
  13. package/dist/esm/developer-client.js +15 -11
  14. package/dist/esm/document.js +20 -11
  15. package/dist/esm/entrypoint.d.ts +1426 -1464
  16. package/dist/esm/entrypoint.js +12 -1
  17. package/dist/esm/event-emitter.js +5 -1
  18. package/dist/esm/helpers.js +23 -15
  19. package/dist/esm/index.js +49 -33
  20. package/dist/esm/lk-client.js +12 -7
  21. package/dist/esm/lk-protocol.js +8 -4
  22. package/dist/esm/memory-client.js +11 -7
  23. package/dist/esm/meshagent-client.js +88 -79
  24. package/dist/esm/messaging-client.js +37 -33
  25. package/dist/esm/package.json +1 -0
  26. package/dist/esm/participant-token.js +62 -34
  27. package/dist/esm/participant.js +9 -3
  28. package/dist/esm/protocol.js +43 -29
  29. package/dist/esm/queues-client.js +17 -12
  30. package/dist/esm/requirement.js +11 -4
  31. package/dist/esm/response.js +34 -22
  32. package/dist/esm/room-client.js +134 -129
  33. package/dist/esm/room-event.js +21 -9
  34. package/dist/esm/room-server-client.js +18 -13
  35. package/dist/esm/runtime.js +10 -1
  36. package/dist/esm/schema.js +18 -9
  37. package/dist/esm/secrets-client.js +35 -31
  38. package/dist/esm/services-client.js +13 -9
  39. package/dist/esm/storage-client.js +38 -32
  40. package/dist/esm/stream-controller.js +5 -1
  41. package/dist/esm/sync-client.js +42 -38
  42. package/dist/esm/tool-content-type.js +5 -1
  43. package/dist/esm/utils.js +20 -10
  44. package/dist/esm/version.js +4 -1
  45. package/dist/node/entrypoint.d.ts +1426 -1464
  46. package/dist/node/meshagent-client.js +7 -2
  47. package/dist/node/package.json +1 -0
  48. package/package.json +1 -1
@@ -1,8 +1,11 @@
1
- import { FileDeletedEvent, FileMovedEvent, FileUpdatedEvent } from "./room-event";
2
- import { BinaryContent, ControlContent, ErrorContent, JsonContent, FileContent } from "./response";
3
- import { unpackMessage } from "./utils";
4
- import { EventEmitter } from "./event-emitter";
5
- import { RoomServerException } from "./room-server-client";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StorageClient = exports.StorageEntry = exports.FileHandle = void 0;
4
+ const room_event_1 = require("./room-event");
5
+ const response_1 = require("./response");
6
+ const utils_1 = require("./utils");
7
+ const event_emitter_1 = require("./event-emitter");
8
+ const room_server_client_1 = require("./room-server-client");
6
9
  const _DEFAULT_UPLOAD_MIME_TYPE = "application/octet-stream";
7
10
  const _UPLOAD_MIME_TYPES_BY_SUFFIX = new Map([
8
11
  [".tar.gz", "application/x-tar"],
@@ -38,7 +41,7 @@ const _UPLOAD_MIME_TYPES_BY_EXTENSION = new Map([
38
41
  [".zip", "application/zip"],
39
42
  ]);
40
43
  function _unexpectedStorageResponseError(operation) {
41
- return new RoomServerException(`unexpected return type from storage.${operation}`);
44
+ return new room_server_client_1.RoomServerException(`unexpected return type from storage.${operation}`);
42
45
  }
43
46
  function _parseStorageTimestamp(value, operation) {
44
47
  if (value == null) {
@@ -53,12 +56,13 @@ function _parseStorageTimestamp(value, operation) {
53
56
  }
54
57
  return timestamp;
55
58
  }
56
- export class FileHandle {
59
+ class FileHandle {
57
60
  constructor({ id }) {
58
61
  this.id = id;
59
62
  }
60
63
  }
61
- export class StorageEntry {
64
+ exports.FileHandle = FileHandle;
65
+ class StorageEntry {
62
66
  constructor({ name, isFolder, size = null, createdAt = null, updatedAt = null }) {
63
67
  this.name = name;
64
68
  this.isFolder = isFolder;
@@ -75,7 +79,8 @@ export class StorageEntry {
75
79
  .replace(/\.[^/.]+$/, "");
76
80
  }
77
81
  }
78
- export class StorageClient extends EventEmitter {
82
+ exports.StorageEntry = StorageEntry;
83
+ class StorageClient extends event_emitter_1.EventEmitter {
79
84
  constructor({ room }) {
80
85
  super();
81
86
  this.client = room;
@@ -87,8 +92,8 @@ export class StorageClient extends EventEmitter {
87
92
  if (!this.client.isActiveProtocol(protocol)) {
88
93
  return;
89
94
  }
90
- const [data, _] = unpackMessage(bytes || new Uint8Array());
91
- const event = new FileUpdatedEvent({ path: data["path"], participantId: data["participant_id"] });
95
+ const [data, _] = (0, utils_1.unpackMessage)(bytes || new Uint8Array());
96
+ const event = new room_event_1.FileUpdatedEvent({ path: data["path"], participantId: data["participant_id"] });
92
97
  this.client.emit(event);
93
98
  this.emit('file.updated', event);
94
99
  }
@@ -96,8 +101,8 @@ export class StorageClient extends EventEmitter {
96
101
  if (!this.client.isActiveProtocol(protocol)) {
97
102
  return;
98
103
  }
99
- const [data, _] = unpackMessage(bytes || new Uint8Array());
100
- const event = new FileDeletedEvent({ path: data["path"], participantId: data["participant_id"] });
104
+ const [data, _] = (0, utils_1.unpackMessage)(bytes || new Uint8Array());
105
+ const event = new room_event_1.FileDeletedEvent({ path: data["path"], participantId: data["participant_id"] });
101
106
  this.client.emit(event);
102
107
  this.emit('file.deleted', event);
103
108
  }
@@ -105,8 +110,8 @@ export class StorageClient extends EventEmitter {
105
110
  if (!this.client.isActiveProtocol(protocol)) {
106
111
  return;
107
112
  }
108
- const [data, _] = unpackMessage(bytes || new Uint8Array());
109
- const event = new FileMovedEvent({
113
+ const [data, _] = (0, utils_1.unpackMessage)(bytes || new Uint8Array());
114
+ const event = new room_event_1.FileMovedEvent({
110
115
  sourcePath: data["source_path"],
111
116
  destinationPath: data["destination_path"],
112
117
  participantId: data["participant_id"],
@@ -141,7 +146,7 @@ export class StorageClient extends EventEmitter {
141
146
  }
142
147
  async list(path) {
143
148
  const response = await this._invoke("list", { path });
144
- if (!(response instanceof JsonContent) || !Array.isArray(response.json["files"])) {
149
+ if (!(response instanceof response_1.JsonContent) || !Array.isArray(response.json["files"])) {
145
150
  throw this._unexpectedResponseError("list");
146
151
  }
147
152
  const files = response.json["files"];
@@ -151,7 +156,7 @@ export class StorageClient extends EventEmitter {
151
156
  }
152
157
  async stat(path) {
153
158
  const response = await this._invoke("stat", { path });
154
- if (!(response instanceof JsonContent) || typeof response.json["exists"] !== "boolean") {
159
+ if (!(response instanceof response_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
155
160
  throw this._unexpectedResponseError("stat");
156
161
  }
157
162
  if (!response.json["exists"]) {
@@ -171,7 +176,7 @@ export class StorageClient extends EventEmitter {
171
176
  }
172
177
  async exists(path) {
173
178
  const result = await this._invoke("exists", { path });
174
- if (!(result instanceof JsonContent)) {
179
+ if (!(result instanceof response_1.JsonContent)) {
175
180
  throw this._unexpectedResponseError("exists");
176
181
  }
177
182
  return result.json["exists"];
@@ -230,16 +235,16 @@ export class StorageClient extends EventEmitter {
230
235
  });
231
236
  try {
232
237
  for await (const chunk of response) {
233
- if (chunk instanceof ErrorContent) {
234
- throw new RoomServerException(chunk.text, chunk.code);
238
+ if (chunk instanceof response_1.ErrorContent) {
239
+ throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
235
240
  }
236
- if (chunk instanceof ControlContent) {
241
+ if (chunk instanceof response_1.ControlContent) {
237
242
  if (chunk.method === "close") {
238
243
  return;
239
244
  }
240
245
  throw this._unexpectedResponseError("upload");
241
246
  }
242
- if (!(chunk instanceof BinaryContent)) {
247
+ if (!(chunk instanceof response_1.BinaryContent)) {
243
248
  throw this._unexpectedResponseError("upload");
244
249
  }
245
250
  if (chunk.headers["kind"] !== "pull") {
@@ -295,7 +300,7 @@ export class StorageClient extends EventEmitter {
295
300
  data.set(part, offset);
296
301
  offset += part.length;
297
302
  }
298
- return new FileContent({ data, name, mimeType });
303
+ return new response_1.FileContent({ data, name, mimeType });
299
304
  }
300
305
  async downloadStream(path, { chunkSize = 64 * 1024, } = {}) {
301
306
  const input = new _StorageDownloadInputStream({ path, chunkSize });
@@ -312,10 +317,10 @@ export class StorageClient extends EventEmitter {
312
317
  let bytesReceived = 0;
313
318
  try {
314
319
  for await (const chunk of response) {
315
- if (chunk instanceof ErrorContent) {
316
- throw new RoomServerException(chunk.text, chunk.code);
320
+ if (chunk instanceof response_1.ErrorContent) {
321
+ throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
317
322
  }
318
- if (chunk instanceof ControlContent) {
323
+ if (chunk instanceof response_1.ControlContent) {
319
324
  if (chunk.method === "close") {
320
325
  if (!metadataReceived || expectedSize == null || bytesReceived !== expectedSize) {
321
326
  throw self._unexpectedResponseError("download");
@@ -324,7 +329,7 @@ export class StorageClient extends EventEmitter {
324
329
  }
325
330
  throw self._unexpectedResponseError("download");
326
331
  }
327
- if (!(chunk instanceof BinaryContent)) {
332
+ if (!(chunk instanceof response_1.BinaryContent)) {
328
333
  throw self._unexpectedResponseError("download");
329
334
  }
330
335
  const kind = chunk.headers["kind"];
@@ -370,12 +375,13 @@ export class StorageClient extends EventEmitter {
370
375
  }
371
376
  async downloadUrl(path) {
372
377
  const response = await this._invoke("download_url", { path });
373
- if (!(response instanceof JsonContent)) {
378
+ if (!(response instanceof response_1.JsonContent)) {
374
379
  throw this._unexpectedResponseError("download_url");
375
380
  }
376
381
  return response.json["url"];
377
382
  }
378
383
  }
384
+ exports.StorageClient = StorageClient;
379
385
  class _StorageDownloadInputStream {
380
386
  constructor({ path, chunkSize }) {
381
387
  this.closed = false;
@@ -407,7 +413,7 @@ class _StorageDownloadInputStream {
407
413
  }
408
414
  }
409
415
  async *stream() {
410
- yield new BinaryContent({
416
+ yield new response_1.BinaryContent({
411
417
  data: new Uint8Array(0),
412
418
  headers: {
413
419
  kind: "start",
@@ -428,7 +434,7 @@ class _StorageDownloadInputStream {
428
434
  continue;
429
435
  }
430
436
  this.pendingPulls -= 1;
431
- yield new BinaryContent({
437
+ yield new response_1.BinaryContent({
432
438
  data: new Uint8Array(0),
433
439
  headers: { kind: "pull" },
434
440
  });
@@ -515,7 +521,7 @@ class _StorageUploadInputStream {
515
521
  return combined;
516
522
  }
517
523
  async *stream() {
518
- yield new BinaryContent({
524
+ yield new response_1.BinaryContent({
519
525
  data: new Uint8Array(0),
520
526
  headers: {
521
527
  kind: "start",
@@ -545,7 +551,7 @@ class _StorageUploadInputStream {
545
551
  if (chunk == null) {
546
552
  return;
547
553
  }
548
- yield new BinaryContent({
554
+ yield new response_1.BinaryContent({
549
555
  data: chunk,
550
556
  headers: { kind: "data" },
551
557
  });
@@ -1,4 +1,7 @@
1
- export class StreamController {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamController = void 0;
4
+ class StreamController {
2
5
  constructor() {
3
6
  this.closed = false;
4
7
  this.subs = new Set();
@@ -72,3 +75,4 @@ export class StreamController {
72
75
  }
73
76
  }
74
77
  }
78
+ exports.StreamController = StreamController;
@@ -1,10 +1,13 @@
1
- import { Completer } from "./completer";
2
- import { EventEmitter } from "./event-emitter";
3
- import { MeshSchema } from "./schema";
4
- import { BinaryContent, ControlContent, ErrorContent } from "./response";
5
- import { MeshDocument, RoomServerException } from "./room-server-client";
6
- import { applyBackendChanges, unregisterDocument } from "./runtime";
7
- import { decoder, encoder, RefCount } from "./utils";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SyncClient = void 0;
4
+ const completer_1 = require("./completer");
5
+ const event_emitter_1 = require("./event-emitter");
6
+ const schema_1 = require("./schema");
7
+ const response_1 = require("./response");
8
+ const room_server_client_1 = require("./room-server-client");
9
+ const runtime_1 = require("./runtime");
10
+ const utils_1 = require("./utils");
8
11
  function normalizeSyncPath(path) {
9
12
  let normalized = path;
10
13
  while (normalized.startsWith("./")) {
@@ -24,7 +27,7 @@ function parseSyncOpenStateChunkHeaders(headers) {
24
27
  typeof headers["schema"] !== "object" ||
25
28
  headers["schema"] == null ||
26
29
  Array.isArray(headers["schema"])) {
27
- throw new RoomServerException("unexpected return type from sync.open");
30
+ throw new room_server_client_1.RoomServerException("unexpected return type from sync.open");
28
31
  }
29
32
  return {
30
33
  kind: "state",
@@ -35,7 +38,7 @@ function parseSyncOpenStateChunkHeaders(headers) {
35
38
  function parseSyncOpenOutputChunkHeaders(headers) {
36
39
  const kind = headers["kind"];
37
40
  if ((kind !== "state" && kind !== "sync") || typeof headers["path"] !== "string") {
38
- throw new RoomServerException("unexpected return type from sync.open");
41
+ throw new room_server_client_1.RoomServerException("unexpected return type from sync.open");
39
42
  }
40
43
  return {
41
44
  kind,
@@ -67,7 +70,7 @@ class SyncOpenStreamState {
67
70
  });
68
71
  }
69
72
  async *inputStream() {
70
- yield new BinaryContent({
73
+ yield new response_1.BinaryContent({
71
74
  data: new Uint8Array(),
72
75
  headers: {
73
76
  kind: "start",
@@ -110,12 +113,12 @@ class SyncOpenStreamState {
110
113
  throw this._error;
111
114
  }
112
115
  if (this._error !== undefined) {
113
- throw new RoomServerException(`sync stream failed: ${String(this._error)}`);
116
+ throw new room_server_client_1.RoomServerException(`sync stream failed: ${String(this._error)}`);
114
117
  }
115
118
  if (this._inputClosed) {
116
- throw new RoomServerException("attempted to sync to a document that is not connected");
119
+ throw new room_server_client_1.RoomServerException("attempted to sync to a document that is not connected");
117
120
  }
118
- this._enqueueChunk(new BinaryContent({
121
+ this._enqueueChunk(new response_1.BinaryContent({
119
122
  data,
120
123
  headers: { kind: "sync" },
121
124
  }));
@@ -125,7 +128,7 @@ class SyncOpenStreamState {
125
128
  }
126
129
  }
127
130
  SyncOpenStreamState.INPUT_STREAM_CLOSE = Symbol("sync-open-input-close");
128
- export class SyncClient extends EventEmitter {
131
+ class SyncClient extends event_emitter_1.EventEmitter {
129
132
  constructor({ room }) {
130
133
  super();
131
134
  this._connectingDocuments = {};
@@ -138,7 +141,7 @@ export class SyncClient extends EventEmitter {
138
141
  }
139
142
  start() {
140
143
  if (this._started) {
141
- throw new RoomServerException("client already started");
144
+ throw new room_server_client_1.RoomServerException("client already started");
142
145
  }
143
146
  this._started = true;
144
147
  }
@@ -148,7 +151,7 @@ export class SyncClient extends EventEmitter {
148
151
  streamState.closeInputStream();
149
152
  }
150
153
  for (const doc of Object.values(this._connectedDocuments)) {
151
- unregisterDocument(doc.ref.id);
154
+ (0, runtime_1.unregisterDocument)(doc.ref.id);
152
155
  }
153
156
  Object.keys(this._documentStreams).forEach((key) => delete this._documentStreams[key]);
154
157
  Object.keys(this._documentConfigs).forEach((key) => delete this._documentConfigs[key]);
@@ -158,7 +161,7 @@ export class SyncClient extends EventEmitter {
158
161
  this._started = false;
159
162
  }
160
163
  _unexpectedResponseError(operation) {
161
- return new RoomServerException(`unexpected return type from sync.${operation}`);
164
+ return new room_server_client_1.RoomServerException(`unexpected return type from sync.${operation}`);
162
165
  }
163
166
  async _invoke(operation, input) {
164
167
  return await this.room.invoke({
@@ -169,7 +172,7 @@ export class SyncClient extends EventEmitter {
169
172
  }
170
173
  _applySyncPayload(rc, payload) {
171
174
  if (payload.length > 0) {
172
- applyBackendChanges(rc.ref.id, decoder.decode(payload));
175
+ (0, runtime_1.applyBackendChanges)(rc.ref.id, utils_1.decoder.decode(payload));
173
176
  }
174
177
  if (!rc.ref.isSynchronized) {
175
178
  rc.ref.setSynchronizedComplete();
@@ -199,7 +202,7 @@ export class SyncClient extends EventEmitter {
199
202
  connected.count += 1;
200
203
  return connected.ref;
201
204
  }
202
- const connecting = new Completer();
205
+ const connecting = new completer_1.Completer();
203
206
  this._connectingDocuments[normalizedPath] = connecting.fut;
204
207
  try {
205
208
  const config = {
@@ -213,8 +216,8 @@ export class SyncClient extends EventEmitter {
213
216
  vector: null,
214
217
  initialJson: initialJson ?? null,
215
218
  });
216
- const resolvedSchema = MeshSchema.fromJson(openResult.stateHeaders.schema);
217
- const doc = new MeshDocument({
219
+ const resolvedSchema = schema_1.MeshSchema.fromJson(openResult.stateHeaders.schema);
220
+ const doc = new room_server_client_1.MeshDocument({
218
221
  schema: resolvedSchema,
219
222
  sendChangesToBackend: (base64) => {
220
223
  const currentStream = this._documentStreams[normalizedPath];
@@ -222,13 +225,13 @@ export class SyncClient extends EventEmitter {
222
225
  return;
223
226
  }
224
227
  try {
225
- currentStream.queueSync(encoder.encode(base64));
228
+ currentStream.queueSync(utils_1.encoder.encode(base64));
226
229
  }
227
230
  catch {
228
231
  }
229
232
  },
230
233
  });
231
- const rc = new RefCount(doc);
234
+ const rc = new utils_1.RefCount(doc);
232
235
  this._connectedDocuments[normalizedPath] = rc;
233
236
  this._documentConfigs[normalizedPath] = config;
234
237
  this._documentStreams[normalizedPath] = openResult.streamState;
@@ -256,7 +259,7 @@ export class SyncClient extends EventEmitter {
256
259
  const normalizedPath = normalizeSyncPath(path);
257
260
  const rc = this._connectedDocuments[normalizedPath];
258
261
  if (rc == null) {
259
- throw new RoomServerException(`Not connected to ${normalizedPath}`);
262
+ throw new room_server_client_1.RoomServerException(`Not connected to ${normalizedPath}`);
260
263
  }
261
264
  rc.count -= 1;
262
265
  if (rc.count === 0) {
@@ -271,11 +274,11 @@ export class SyncClient extends EventEmitter {
271
274
  await streamState.wait();
272
275
  }
273
276
  finally {
274
- unregisterDocument(rc.ref.id);
277
+ (0, runtime_1.unregisterDocument)(rc.ref.id);
275
278
  }
276
279
  }
277
280
  else {
278
- unregisterDocument(rc.ref.id);
281
+ (0, runtime_1.unregisterDocument)(rc.ref.id);
279
282
  }
280
283
  })();
281
284
  this._closingDocuments[normalizedPath] = closeFuture;
@@ -293,11 +296,11 @@ export class SyncClient extends EventEmitter {
293
296
  async sync(path, data) {
294
297
  const normalizedPath = normalizeSyncPath(path);
295
298
  if (this._connectedDocuments[normalizedPath] == null) {
296
- throw new RoomServerException("attempted to sync to a document that is not connected");
299
+ throw new room_server_client_1.RoomServerException("attempted to sync to a document that is not connected");
297
300
  }
298
301
  const streamState = this._documentStreams[normalizedPath];
299
302
  if (streamState == null) {
300
- throw new RoomServerException("attempted to sync to a document that is not connected");
303
+ throw new room_server_client_1.RoomServerException("attempted to sync to a document that is not connected");
301
304
  }
302
305
  streamState.queueSync(data);
303
306
  }
@@ -309,21 +312,21 @@ export class SyncClient extends EventEmitter {
309
312
  return;
310
313
  }
311
314
  const chunk = next.value;
312
- if (chunk instanceof ErrorContent) {
313
- throw new RoomServerException(chunk.text, chunk.code);
315
+ if (chunk instanceof response_1.ErrorContent) {
316
+ throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
314
317
  }
315
- if (chunk instanceof ControlContent) {
318
+ if (chunk instanceof response_1.ControlContent) {
316
319
  if (chunk.method === "close") {
317
320
  return;
318
321
  }
319
322
  throw this._unexpectedResponseError("open");
320
323
  }
321
- if (!(chunk instanceof BinaryContent)) {
324
+ if (!(chunk instanceof response_1.BinaryContent)) {
322
325
  throw this._unexpectedResponseError("open");
323
326
  }
324
327
  const headers = parseSyncOpenOutputChunkHeaders(chunk.headers);
325
328
  if (normalizeSyncPath(headers.path) !== path) {
326
- throw new RoomServerException("sync.open stream returned a mismatched path");
329
+ throw new room_server_client_1.RoomServerException("sync.open stream returned a mismatched path");
327
330
  }
328
331
  this._applySyncPayload(rc, chunk.data);
329
332
  }
@@ -352,18 +355,18 @@ export class SyncClient extends EventEmitter {
352
355
  iterator = responseStream[Symbol.asyncIterator]();
353
356
  const first = await iterator.next();
354
357
  if (first.done || first.value === undefined) {
355
- throw new RoomServerException("sync.open stream closed before the initial document state was returned");
358
+ throw new room_server_client_1.RoomServerException("sync.open stream closed before the initial document state was returned");
356
359
  }
357
360
  const firstChunk = first.value;
358
- if (firstChunk instanceof ErrorContent) {
359
- throw new RoomServerException(firstChunk.text, firstChunk.code);
361
+ if (firstChunk instanceof response_1.ErrorContent) {
362
+ throw new room_server_client_1.RoomServerException(firstChunk.text, firstChunk.code);
360
363
  }
361
- if (!(firstChunk instanceof BinaryContent)) {
364
+ if (!(firstChunk instanceof response_1.BinaryContent)) {
362
365
  throw this._unexpectedResponseError("open");
363
366
  }
364
367
  const stateHeaders = parseSyncOpenStateChunkHeaders(firstChunk.headers);
365
368
  if (normalizeSyncPath(stateHeaders.path) !== path) {
366
- throw new RoomServerException("sync.open stream returned a mismatched path");
369
+ throw new room_server_client_1.RoomServerException("sync.open stream returned a mismatched path");
367
370
  }
368
371
  return {
369
372
  streamState,
@@ -418,3 +421,4 @@ export class SyncClient extends EventEmitter {
418
421
  }
419
422
  }
420
423
  }
424
+ exports.SyncClient = SyncClient;
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ToolContentSpec = void 0;
1
4
  const SUPPORTED_TOOL_CONTENT_TYPES = new Set([
2
5
  "json",
3
6
  "text",
@@ -8,7 +11,7 @@ const SUPPORTED_TOOL_CONTENT_TYPES = new Set([
8
11
  function isRecord(value) {
9
12
  return typeof value === "object" && value !== null;
10
13
  }
11
- export class ToolContentSpec {
14
+ class ToolContentSpec {
12
15
  constructor({ types, stream = false, schema, }) {
13
16
  if (!Array.isArray(types) || types.length === 0) {
14
17
  throw new Error("ToolContentSpec.types must contain at least one supported type");
@@ -62,3 +65,4 @@ export class ToolContentSpec {
62
65
  return new ToolContentSpec({ types, stream, schema });
63
66
  }
64
67
  }
68
+ exports.ToolContentSpec = ToolContentSpec;
package/dist/esm/utils.js CHANGED
@@ -1,22 +1,31 @@
1
- import { TextDecoder, TextEncoder } from "@kayahr/text-encoding";
2
- const encoder = new TextEncoder();
3
- const decoder = new TextDecoder();
4
- export { encoder, decoder };
5
- export function splitMessagePayload(packet) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RefCount = exports.decoder = exports.encoder = void 0;
4
+ exports.splitMessagePayload = splitMessagePayload;
5
+ exports.splitMessageHeader = splitMessageHeader;
6
+ exports.unpackMessage = unpackMessage;
7
+ exports.packMessage = packMessage;
8
+ exports.mergeUint8Arrays = mergeUint8Arrays;
9
+ const text_encoding_1 = require("@kayahr/text-encoding");
10
+ const encoder = new text_encoding_1.TextEncoder();
11
+ exports.encoder = encoder;
12
+ const decoder = new text_encoding_1.TextDecoder();
13
+ exports.decoder = decoder;
14
+ function splitMessagePayload(packet) {
6
15
  const dataView = new DataView(packet.buffer, packet.byteOffset, packet.byteLength);
7
16
  const headerSize = dataView.getUint32(4, false) + dataView.getUint32(0, false) * Math.pow(2, 32);
8
17
  return packet.subarray(8 + headerSize, packet.length);
9
18
  }
10
- export function splitMessageHeader(packet) {
19
+ function splitMessageHeader(packet) {
11
20
  const dataView = new DataView(packet.buffer, packet.byteOffset, packet.byteLength);
12
21
  const headerSize = dataView.getUint32(4, false) + dataView.getUint32(0, false) * Math.pow(2, 32);
13
22
  const payload = packet.subarray(8, 8 + headerSize);
14
23
  return decoder.decode(payload);
15
24
  }
16
- export function unpackMessage(packet) {
25
+ function unpackMessage(packet) {
17
26
  return [JSON.parse(splitMessageHeader(packet)), splitMessagePayload(packet)];
18
27
  }
19
- export function packMessage(request, data) {
28
+ function packMessage(request, data) {
20
29
  const jsonMessage = encoder.encode(JSON.stringify(request));
21
30
  const size = jsonMessage.length;
22
31
  const header = new Uint8Array(4 * 2);
@@ -25,7 +34,7 @@ export function packMessage(request, data) {
25
34
  dataView.setUint32(4, size & 0xffffffff, false);
26
35
  return mergeUint8Arrays(header, jsonMessage, data ?? new Uint8Array(0));
27
36
  }
28
- export function mergeUint8Arrays(...arrays) {
37
+ function mergeUint8Arrays(...arrays) {
29
38
  const totalSize = arrays.reduce((acc, e) => acc + e.length, 0);
30
39
  const merged = new Uint8Array(totalSize);
31
40
  arrays.forEach((array, i, arrays) => {
@@ -36,9 +45,10 @@ export function mergeUint8Arrays(...arrays) {
36
45
  });
37
46
  return merged;
38
47
  }
39
- export class RefCount {
48
+ class RefCount {
40
49
  constructor(ref) {
41
50
  this.ref = ref;
42
51
  this.count = 1;
43
52
  }
44
53
  }
54
+ exports.RefCount = RefCount;
@@ -1 +1,4 @@
1
- export const __version__ = "0.36.3";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.__version__ = void 0;
4
+ exports.__version__ = "0.36.3";