@meshagent/meshagent 0.42.2 → 0.43.1

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 +13 -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 +3 -3
  8. package/dist/browser/containers-client.js +76 -76
  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 +3 -3
  54. package/dist/esm/containers-client.js +82 -87
  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 +3 -3
  111. package/dist/node/containers-client.js +76 -76
  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,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Meshagent = void 0;
4
- const helpers_1 = require("./helpers");
5
- const requirement_1 = require("./requirement");
6
- const participant_token_1 = require("./participant-token");
7
- const utils_1 = require("./utils");
1
+ import { meshagentBaseUrl } from "./helpers.js";
2
+ import { RoomException } from "./requirement.js";
3
+ import { ApiScope } from "./participant-token.js";
4
+ import { decoder, encoder } from "./utils.js";
8
5
  function pruneUndefinedValues(value) {
9
6
  if (Array.isArray(value)) {
10
7
  const prunedItems = value
@@ -95,9 +92,9 @@ function normalizeBinary(data) {
95
92
  }
96
93
  return new Uint8Array(data);
97
94
  }
98
- class Meshagent {
95
+ export class Meshagent {
99
96
  constructor({ baseUrl, token } = {}) {
100
- const resolvedBaseUrl = (0, helpers_1.meshagentBaseUrl)(baseUrl).replace(/\/+$/, "");
97
+ const resolvedBaseUrl = meshagentBaseUrl(baseUrl).replace(/\/+$/, "");
101
98
  this.baseUrl = resolvedBaseUrl || "https://api.meshagent.com";
102
99
  const envToken = typeof process !== "undefined" ? process.env?.MESHAGENT_API_KEY : undefined;
103
100
  this.token = token ?? envToken ?? undefined;
@@ -152,7 +149,7 @@ class Meshagent {
152
149
  catch {
153
150
  message = "<unable to read body>";
154
151
  }
155
- throw new requirement_1.RoomException(`Failed to ${action}. Status code: ${response.status}, body: ${message}`);
152
+ throw new RoomException(`Failed to ${action}. Status code: ${response.status}, body: ${message}`);
156
153
  }
157
154
  switch (responseType) {
158
155
  case "json":
@@ -171,15 +168,15 @@ class Meshagent {
171
168
  }
172
169
  parseRoomShare(data) {
173
170
  if (!data || typeof data !== "object") {
174
- throw new requirement_1.RoomException("Invalid room share payload: expected object");
171
+ throw new RoomException("Invalid room share payload: expected object");
175
172
  }
176
173
  const { id, project_id: projectId, projectId: projectIdAlt, settings } = data;
177
174
  if (typeof id !== "string") {
178
- throw new requirement_1.RoomException("Invalid room share payload: missing id");
175
+ throw new RoomException("Invalid room share payload: missing id");
179
176
  }
180
177
  const finalProjectId = typeof projectIdAlt === "string" ? projectIdAlt : typeof projectId === "string" ? projectId : undefined;
181
178
  if (!finalProjectId) {
182
- throw new requirement_1.RoomException("Invalid room share payload: missing project id");
179
+ throw new RoomException("Invalid room share payload: missing project id");
183
180
  }
184
181
  return {
185
182
  id,
@@ -189,23 +186,23 @@ class Meshagent {
189
186
  }
190
187
  parseRoomSession(data) {
191
188
  if (!data || typeof data !== "object") {
192
- throw new requirement_1.RoomException("Invalid room session payload");
189
+ throw new RoomException("Invalid room session payload");
193
190
  }
194
191
  const { id, room_id: roomIdRaw, roomId, room_name: roomNameRaw, roomName, created_at: createdRaw, createdAt, is_active: isActiveRaw, isActive, participants } = data;
195
192
  if (typeof id !== "string") {
196
- throw new requirement_1.RoomException("Invalid room session payload: missing id");
193
+ throw new RoomException("Invalid room session payload: missing id");
197
194
  }
198
195
  const roomNameValue = typeof roomName === "string" ? roomName : roomNameRaw;
199
196
  if (typeof roomNameValue !== "string") {
200
- throw new requirement_1.RoomException("Invalid room session payload: missing room name");
197
+ throw new RoomException("Invalid room session payload: missing room name");
201
198
  }
202
199
  const created = typeof createdAt === "string" ? createdAt : createdRaw;
203
200
  if (typeof created !== "string") {
204
- throw new requirement_1.RoomException("Invalid room session payload: missing created_at");
201
+ throw new RoomException("Invalid room session payload: missing created_at");
205
202
  }
206
203
  const isActiveValue = typeof isActive === "boolean" ? isActive : isActiveRaw;
207
204
  if (typeof isActiveValue !== "boolean") {
208
- throw new requirement_1.RoomException("Invalid room session payload: missing is_active");
205
+ throw new RoomException("Invalid room session payload: missing is_active");
209
206
  }
210
207
  return {
211
208
  id,
@@ -218,11 +215,11 @@ class Meshagent {
218
215
  }
219
216
  parseRoom(data) {
220
217
  if (!data || typeof data !== "object") {
221
- throw new requirement_1.RoomException("Invalid room payload");
218
+ throw new RoomException("Invalid room payload");
222
219
  }
223
220
  const { id, name, metadata, annotations } = data;
224
221
  if (typeof id !== "string" || typeof name !== "string") {
225
- throw new requirement_1.RoomException("Invalid room payload: missing id or name");
222
+ throw new RoomException("Invalid room payload: missing id or name");
226
223
  }
227
224
  return {
228
225
  id,
@@ -233,7 +230,7 @@ class Meshagent {
233
230
  }
234
231
  parseRoute(data) {
235
232
  if (!data || typeof data !== "object") {
236
- throw new requirement_1.RoomException("Invalid route payload: expected object");
233
+ throw new RoomException("Invalid route payload: expected object");
237
234
  }
238
235
  if (data.spec && typeof data.spec === "object") {
239
236
  return { domain: String(data.domain ?? data.spec.domain), spec: data.spec };
@@ -251,11 +248,11 @@ class Meshagent {
251
248
  },
252
249
  };
253
250
  }
254
- throw new requirement_1.RoomException("Invalid route payload: missing spec");
251
+ throw new RoomException("Invalid route payload: missing spec");
255
252
  }
256
253
  parseFeed(data) {
257
254
  if (!data || typeof data !== "object") {
258
- throw new requirement_1.RoomException("Invalid feed payload");
255
+ throw new RoomException("Invalid feed payload");
259
256
  }
260
257
  const { id, project_id: projectIdRaw, projectId, created_at: createdAtRaw, createdAt, name, description, visibility, paused, annotations, message_schema: messageSchemaRaw, messageSchema, } = data;
261
258
  const projectIdValue = typeof projectId === "string"
@@ -281,7 +278,7 @@ class Meshagent {
281
278
  typeof createdAtValue !== "string" ||
282
279
  typeof name !== "string" ||
283
280
  visibilityValue === undefined) {
284
- throw new requirement_1.RoomException("Invalid feed payload: missing required fields");
281
+ throw new RoomException("Invalid feed payload: missing required fields");
285
282
  }
286
283
  return {
287
284
  id,
@@ -297,7 +294,7 @@ class Meshagent {
297
294
  }
298
295
  parseFeedSubscription(data) {
299
296
  if (!data || typeof data !== "object") {
300
- throw new requirement_1.RoomException("Invalid feed subscription payload");
297
+ throw new RoomException("Invalid feed subscription payload");
301
298
  }
302
299
  const { id, feed_id: feedIdRaw, feedId, project_id: projectIdRaw, projectId, room, room_id: roomIdRaw, roomId, path, filename_datetime_format: filenameDatetimeFormatRaw, filenameDatetimeFormat, created_at: createdAtRaw, createdAt, annotations, } = data;
303
300
  const feedIdValue = typeof feedId === "string" ? feedId : feedIdRaw;
@@ -315,7 +312,7 @@ class Meshagent {
315
312
  typeof room !== "string" ||
316
313
  typeof path !== "string" ||
317
314
  typeof createdAtValue !== "string") {
318
- throw new requirement_1.RoomException("Invalid feed subscription payload: missing required fields");
315
+ throw new RoomException("Invalid feed subscription payload: missing required fields");
319
316
  }
320
317
  return {
321
318
  id,
@@ -331,7 +328,7 @@ class Meshagent {
331
328
  }
332
329
  parseLLMLogger(data) {
333
330
  if (!data || typeof data !== "object") {
334
- throw new requirement_1.RoomException("Invalid LLM logger payload");
331
+ throw new RoomException("Invalid LLM logger payload");
335
332
  }
336
333
  const { id, project_id: projectIdRaw, projectId, destination_feed_id: destinationFeedIdRaw, destinationFeedId, filter_expression: filterExpressionRaw, filterExpression, paused, created_at: createdAtRaw, createdAt, annotations, } = data;
337
334
  const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
@@ -343,7 +340,7 @@ class Meshagent {
343
340
  typeof destinationFeedIdValue !== "string" ||
344
341
  typeof filterExpressionValue !== "string" ||
345
342
  typeof createdAtValue !== "string") {
346
- throw new requirement_1.RoomException("Invalid LLM logger payload: missing required fields");
343
+ throw new RoomException("Invalid LLM logger payload: missing required fields");
347
344
  }
348
345
  return {
349
346
  id,
@@ -357,7 +354,7 @@ class Meshagent {
357
354
  }
358
355
  parseProjectRepository(data) {
359
356
  if (!data || typeof data !== "object") {
360
- throw new requirement_1.RoomException("Invalid repository payload");
357
+ throw new RoomException("Invalid repository payload");
361
358
  }
362
359
  const { id, project_id: projectIdRaw, projectId, name, description, annotations, created_at: createdAtRaw, createdAt, } = data;
363
360
  const projectIdValue = typeof projectId === "string"
@@ -371,7 +368,7 @@ class Meshagent {
371
368
  ? createdAtRaw
372
369
  : undefined;
373
370
  if (typeof id !== "string" || typeof projectIdValue !== "string" || typeof name !== "string" || typeof createdAtValue !== "string") {
374
- throw new requirement_1.RoomException("Invalid repository payload: missing required fields");
371
+ throw new RoomException("Invalid repository payload: missing required fields");
375
372
  }
376
373
  return {
377
374
  id,
@@ -384,44 +381,44 @@ class Meshagent {
384
381
  }
385
382
  parseProjectRoomGrant(data) {
386
383
  if (!data || typeof data !== "object") {
387
- throw new requirement_1.RoomException("Invalid room grant payload");
384
+ throw new RoomException("Invalid room grant payload");
388
385
  }
389
386
  const roomData = data.room;
390
387
  const room = this.parseRoom(roomData);
391
388
  const userId = data.user_id ?? data.userId;
392
389
  if (typeof userId !== "string") {
393
- throw new requirement_1.RoomException("Invalid room grant payload: missing user_id");
390
+ throw new RoomException("Invalid room grant payload: missing user_id");
394
391
  }
395
392
  const permissionsRaw = data.permissions;
396
- const permissions = permissionsRaw && typeof permissionsRaw === "object" ? participant_token_1.ApiScope.fromJSON(permissionsRaw) : new participant_token_1.ApiScope();
393
+ const permissions = permissionsRaw && typeof permissionsRaw === "object" ? ApiScope.fromJSON(permissionsRaw) : new ApiScope();
397
394
  return { room, userId, permissions };
398
395
  }
399
396
  parseProjectRoomGrantCount(data) {
400
397
  const roomData = (data && typeof data === "object") ? (data.room ?? { id: data.room_id, name: data.room_name, metadata: data.metadata ?? {} }) : undefined;
401
398
  if (!roomData) {
402
- throw new requirement_1.RoomException("Invalid room grant count payload: missing room");
399
+ throw new RoomException("Invalid room grant count payload: missing room");
403
400
  }
404
401
  const room = this.parseRoom(roomData);
405
402
  const count = data.count;
406
403
  if (typeof count !== "number") {
407
- throw new requirement_1.RoomException("Invalid room grant count payload: missing count");
404
+ throw new RoomException("Invalid room grant count payload: missing count");
408
405
  }
409
406
  return { room, count };
410
407
  }
411
408
  parseProjectUserGrantCount(data) {
412
409
  if (!data || typeof data !== "object") {
413
- throw new requirement_1.RoomException("Invalid room grant user count payload");
410
+ throw new RoomException("Invalid room grant user count payload");
414
411
  }
415
412
  const { user_id: userIdRaw, userId, count, first_name: firstNameRaw, firstName, last_name: lastNameRaw, lastName, email } = data;
416
413
  const userIdValue = typeof userId === "string" ? userId : userIdRaw;
417
414
  if (typeof userIdValue !== "string") {
418
- throw new requirement_1.RoomException("Invalid room grant user count payload: missing user_id");
415
+ throw new RoomException("Invalid room grant user count payload: missing user_id");
419
416
  }
420
417
  if (typeof count !== "number") {
421
- throw new requirement_1.RoomException("Invalid room grant user count payload: missing count");
418
+ throw new RoomException("Invalid room grant user count payload: missing count");
422
419
  }
423
420
  if (typeof email !== "string") {
424
- throw new requirement_1.RoomException("Invalid room grant user count payload: missing email");
421
+ throw new RoomException("Invalid room grant user count payload: missing email");
425
422
  }
426
423
  return {
427
424
  userId: userIdValue,
@@ -433,11 +430,11 @@ class Meshagent {
433
430
  }
434
431
  parseBalance(data) {
435
432
  if (!data || typeof data !== "object") {
436
- throw new requirement_1.RoomException("Invalid balance payload");
433
+ throw new RoomException("Invalid balance payload");
437
434
  }
438
435
  const balanceValue = data.balance;
439
436
  if (typeof balanceValue !== "number") {
440
- throw new requirement_1.RoomException("Invalid balance payload: missing balance");
437
+ throw new RoomException("Invalid balance payload: missing balance");
441
438
  }
442
439
  const threshold = data.auto_recharge_threshold ?? data.autoRechargeThreshold;
443
440
  const amount = data.auto_recharge_amount ?? data.autoRechargeAmount;
@@ -457,15 +454,15 @@ class Meshagent {
457
454
  }
458
455
  parseTransaction(data) {
459
456
  if (!data || typeof data !== "object") {
460
- throw new requirement_1.RoomException("Invalid transaction payload");
457
+ throw new RoomException("Invalid transaction payload");
461
458
  }
462
459
  const { id, amount, reference, referenceType, reference_type: referenceTypeRaw, description, created_at: createdAtRaw, createdAt } = data;
463
460
  if (typeof id !== "string" || typeof amount !== "number" || typeof description !== "string") {
464
- throw new requirement_1.RoomException("Invalid transaction payload: missing fields");
461
+ throw new RoomException("Invalid transaction payload: missing fields");
465
462
  }
466
463
  const createdValue = typeof createdAt === "string" ? createdAt : createdAtRaw;
467
464
  if (typeof createdValue !== "string") {
468
- throw new requirement_1.RoomException("Invalid transaction payload: missing created_at");
465
+ throw new RoomException("Invalid transaction payload: missing created_at");
469
466
  }
470
467
  const referenceTypeValue = typeof referenceType === "string" ? referenceType : referenceTypeRaw;
471
468
  return {
@@ -479,7 +476,7 @@ class Meshagent {
479
476
  }
480
477
  parseSecret(data) {
481
478
  if (!data || typeof data !== "object") {
482
- throw new requirement_1.RoomException("Invalid secret payload");
479
+ throw new RoomException("Invalid secret payload");
483
480
  }
484
481
  const type = data.type;
485
482
  if (type === "docker") {
@@ -487,7 +484,7 @@ class Meshagent {
487
484
  const username = data.username;
488
485
  const password = data.password;
489
486
  if (typeof server !== "string" || typeof username !== "string" || typeof password !== "string") {
490
- throw new requirement_1.RoomException("Invalid docker secret payload");
487
+ throw new RoomException("Invalid docker secret payload");
491
488
  }
492
489
  return {
493
490
  id: typeof data.id === "string" ? data.id : undefined,
@@ -502,7 +499,7 @@ class Meshagent {
502
499
  if (type === "keys") {
503
500
  const record = data.data;
504
501
  if (!record || typeof record !== "object") {
505
- throw new requirement_1.RoomException("Invalid keys secret payload");
502
+ throw new RoomException("Invalid keys secret payload");
506
503
  }
507
504
  return {
508
505
  id: typeof data.id === "string" ? data.id : undefined,
@@ -511,15 +508,15 @@ class Meshagent {
511
508
  data: record,
512
509
  };
513
510
  }
514
- throw new requirement_1.RoomException(`Unknown secret type: ${type}`);
511
+ throw new RoomException(`Unknown secret type: ${type}`);
515
512
  }
516
513
  parseManagedSecretInfo(data) {
517
514
  if (!data || typeof data !== "object") {
518
- throw new requirement_1.RoomException("Invalid managed secret payload");
515
+ throw new RoomException("Invalid managed secret payload");
519
516
  }
520
517
  const { id, type, name, delegated_to: delegatedToRaw, delegatedTo } = data;
521
518
  if (typeof id !== "string" || typeof type !== "string" || typeof name !== "string") {
522
- throw new requirement_1.RoomException("Invalid managed secret payload: missing id, type, or name");
519
+ throw new RoomException("Invalid managed secret payload: missing id, type, or name");
523
520
  }
524
521
  const delegatedToValue = typeof delegatedTo === "string"
525
522
  ? delegatedTo
@@ -537,7 +534,7 @@ class Meshagent {
537
534
  const secret = this.parseManagedSecretInfo(data);
538
535
  const dataBase64 = data.data_base64 ?? data.dataBase64;
539
536
  if (typeof dataBase64 !== "string") {
540
- throw new requirement_1.RoomException("Invalid managed secret payload: missing data_base64");
537
+ throw new RoomException("Invalid managed secret payload: missing data_base64");
541
538
  }
542
539
  return {
543
540
  ...secret,
@@ -548,18 +545,18 @@ class Meshagent {
548
545
  parseSecretPayload(secret, rawData) {
549
546
  let payload;
550
547
  try {
551
- payload = JSON.parse(utils_1.decoder.decode(rawData));
548
+ payload = JSON.parse(decoder.decode(rawData));
552
549
  }
553
550
  catch {
554
- throw new requirement_1.RoomException(`Invalid secret payload for ${secret.id}`);
551
+ throw new RoomException(`Invalid secret payload for ${secret.id}`);
555
552
  }
556
553
  if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
557
- throw new requirement_1.RoomException(`Invalid secret payload for ${secret.id}`);
554
+ throw new RoomException(`Invalid secret payload for ${secret.id}`);
558
555
  }
559
556
  if (secret.type === "docker") {
560
557
  const { server, username, password, email } = payload;
561
558
  if (typeof server !== "string" || typeof username !== "string" || typeof password !== "string") {
562
- throw new requirement_1.RoomException(`Invalid secret payload for ${secret.id}`);
559
+ throw new RoomException(`Invalid secret payload for ${secret.id}`);
563
560
  }
564
561
  return {
565
562
  id: secret.id,
@@ -573,7 +570,7 @@ class Meshagent {
573
570
  }
574
571
  const entries = Object.entries(payload);
575
572
  if (entries.some(([, value]) => typeof value !== "string")) {
576
- throw new requirement_1.RoomException(`Invalid secret payload for ${secret.id}`);
573
+ throw new RoomException(`Invalid secret payload for ${secret.id}`);
577
574
  }
578
575
  return {
579
576
  id: secret.id,
@@ -606,7 +603,7 @@ class Meshagent {
606
603
  return null;
607
604
  }
608
605
  if (typeof data !== "object") {
609
- throw new requirement_1.RoomException("Invalid connector payload");
606
+ throw new RoomException("Invalid connector payload");
610
607
  }
611
608
  const { openai_connector_id: openaiConnectorIdRaw, openaiConnectorId, server_url: serverUrlRaw, serverUrl, client_secret_id: clientSecretIdRaw, clientSecretId, } = data;
612
609
  return {
@@ -645,14 +642,14 @@ class Meshagent {
645
642
  }
646
643
  parseExternalOAuthClientRegistration(data) {
647
644
  if (!data || typeof data !== "object") {
648
- throw new requirement_1.RoomException("Invalid external oauth registration payload");
645
+ throw new RoomException("Invalid external oauth registration payload");
649
646
  }
650
647
  const { id, delegated_to: delegatedToRaw, delegatedTo, connector, oauth, client_id: clientIdRaw, clientId, client_secret: clientSecretRaw, clientSecret, } = data;
651
648
  const delegatedToValue = typeof delegatedTo === "string" ? delegatedTo : delegatedToRaw;
652
649
  const clientIdValue = typeof clientId === "string" ? clientId : clientIdRaw;
653
650
  const clientSecretValue = typeof clientSecret === "string" ? clientSecret : clientSecretRaw;
654
651
  if (typeof id !== "string" || typeof delegatedToValue !== "string" || typeof clientIdValue !== "string") {
655
- throw new requirement_1.RoomException("Invalid external oauth registration payload: missing fields");
652
+ throw new RoomException("Invalid external oauth registration payload: missing fields");
656
653
  }
657
654
  return {
658
655
  id,
@@ -665,7 +662,7 @@ class Meshagent {
665
662
  }
666
663
  parseOAuthClient(data) {
667
664
  if (!data || typeof data !== "object") {
668
- throw new requirement_1.RoomException("Invalid OAuth client payload");
665
+ throw new RoomException("Invalid OAuth client payload");
669
666
  }
670
667
  const { client_id: clientIdRaw, clientId, client_secret: clientSecretRaw, clientSecret, grant_types: grantTypesRaw, grantTypes, response_types: responseTypesRaw, responseTypes, redirect_uris: redirectUrisRaw, redirectUris, scope, project_id: projectIdRaw, projectId, metadata } = data;
671
668
  const clientIdValue = typeof clientId === "string" ? clientId : clientIdRaw;
@@ -681,7 +678,7 @@ class Meshagent {
681
678
  !Array.isArray(redirectUrisValue) ||
682
679
  typeof scope !== "string" ||
683
680
  typeof projectIdValue !== "string") {
684
- throw new requirement_1.RoomException("Invalid OAuth client payload: missing required fields");
681
+ throw new RoomException("Invalid OAuth client payload: missing required fields");
685
682
  }
686
683
  return {
687
684
  clientId: clientIdValue,
@@ -696,14 +693,14 @@ class Meshagent {
696
693
  }
697
694
  parseRoomConnectionInfo(data) {
698
695
  if (!data || typeof data !== "object") {
699
- throw new requirement_1.RoomException("Invalid room connection payload");
696
+ throw new RoomException("Invalid room connection payload");
700
697
  }
701
698
  const { jwt, room_name: roomNameRaw, roomName, project_id: projectIdRaw, projectId, room_url: roomUrlRaw, roomUrl } = data;
702
699
  const roomNameValue = typeof roomName === "string" ? roomName : roomNameRaw;
703
700
  const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
704
701
  const roomUrlValue = typeof roomUrl === "string" ? roomUrl : roomUrlRaw;
705
702
  if (typeof jwt !== "string" || typeof roomNameValue !== "string" || typeof projectIdValue !== "string" || typeof roomUrlValue !== "string") {
706
- throw new requirement_1.RoomException("Invalid room connection payload: missing fields");
703
+ throw new RoomException("Invalid room connection payload: missing fields");
707
704
  }
708
705
  return { jwt, roomName: roomNameValue, projectId: projectIdValue, roomUrl: roomUrlValue };
709
706
  }
@@ -738,7 +735,7 @@ class Meshagent {
738
735
  });
739
736
  const role = payload?.role;
740
737
  if (role !== "member" && role !== "admin" && role !== "developer") {
741
- throw new requirement_1.RoomException("Invalid role payload");
738
+ throw new RoomException("Invalid role payload");
742
739
  }
743
740
  return role;
744
741
  }
@@ -877,7 +874,7 @@ class Meshagent {
877
874
  });
878
875
  const enabled = data?.["enabled"];
879
876
  if (typeof enabled !== "boolean") {
880
- throw new requirement_1.RoomException("Invalid status payload: expected boolean 'enabled'");
877
+ throw new RoomException("Invalid status payload: expected boolean 'enabled'");
881
878
  }
882
879
  return enabled;
883
880
  }
@@ -910,7 +907,7 @@ class Meshagent {
910
907
  });
911
908
  const url = data?.["checkout_url"];
912
909
  if (typeof url !== "string") {
913
- throw new requirement_1.RoomException("Invalid subscription payload: expected 'checkout_url' string");
910
+ throw new RoomException("Invalid subscription payload: expected 'checkout_url' string");
914
911
  }
915
912
  return url;
916
913
  }
@@ -922,7 +919,7 @@ class Meshagent {
922
919
  });
923
920
  const url = data?.["checkout_url"];
924
921
  if (typeof url !== "string") {
925
- throw new requirement_1.RoomException("Invalid credits payload: expected 'checkout_url' string");
922
+ throw new RoomException("Invalid credits payload: expected 'checkout_url' string");
926
923
  }
927
924
  return url;
928
925
  }
@@ -951,7 +948,7 @@ class Meshagent {
951
948
  });
952
949
  const usage = data?.["usage"];
953
950
  if (!Array.isArray(usage)) {
954
- throw new requirement_1.RoomException("Invalid usage payload: expected 'usage' to be a list");
951
+ throw new RoomException("Invalid usage payload: expected 'usage' to be a list");
955
952
  }
956
953
  return usage.filter((item) => item && typeof item === "object");
957
954
  }
@@ -1050,14 +1047,14 @@ class Meshagent {
1050
1047
  }
1051
1048
  parseMailbox(item) {
1052
1049
  if (!item || typeof item !== "object") {
1053
- throw new requirement_1.RoomException("Invalid mailbox payload");
1050
+ throw new RoomException("Invalid mailbox payload");
1054
1051
  }
1055
1052
  const { address, room, room_id, queue } = item;
1056
1053
  if (typeof address !== "string" || typeof room !== "string" || typeof queue !== "string") {
1057
- throw new requirement_1.RoomException("Invalid mailbox payload: missing fields");
1054
+ throw new RoomException("Invalid mailbox payload: missing fields");
1058
1055
  }
1059
1056
  if (room_id !== undefined && typeof room_id !== "string") {
1060
- throw new requirement_1.RoomException("Invalid mailbox payload: invalid room_id");
1057
+ throw new RoomException("Invalid mailbox payload: invalid room_id");
1061
1058
  }
1062
1059
  return { address, room, roomId: room_id, queue };
1063
1060
  }
@@ -1311,7 +1308,7 @@ class Meshagent {
1311
1308
  action: "create service",
1312
1309
  });
1313
1310
  if (!data || typeof data !== "object" || typeof data.id !== "string") {
1314
- throw new requirement_1.RoomException("Invalid create service response payload");
1311
+ throw new RoomException("Invalid create service response payload");
1315
1312
  }
1316
1313
  return data.id;
1317
1314
  }
@@ -1322,7 +1319,7 @@ class Meshagent {
1322
1319
  action: "create room service",
1323
1320
  });
1324
1321
  if (!data || typeof data !== "object" || typeof data.id !== "string") {
1325
- throw new requirement_1.RoomException("Invalid create room service response payload");
1322
+ throw new RoomException("Invalid create room service response payload");
1326
1323
  }
1327
1324
  return data.id;
1328
1325
  }
@@ -1356,7 +1353,7 @@ class Meshagent {
1356
1353
  }
1357
1354
  async updateService(projectId, serviceId, service) {
1358
1355
  if (!service.id) {
1359
- throw new requirement_1.RoomException("Service id must be set to update a service");
1356
+ throw new RoomException("Service id must be set to update a service");
1360
1357
  }
1361
1358
  await this.request(`/accounts/projects/${projectId}/services/${serviceId}`, {
1362
1359
  method: "PUT",
@@ -1397,7 +1394,7 @@ class Meshagent {
1397
1394
  action: "create project secret",
1398
1395
  });
1399
1396
  if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
1400
- throw new requirement_1.RoomException("Invalid create project secret response payload");
1397
+ throw new RoomException("Invalid create project secret response payload");
1401
1398
  }
1402
1399
  return payload.id;
1403
1400
  }
@@ -1449,7 +1446,7 @@ class Meshagent {
1449
1446
  action: "create room secret",
1450
1447
  });
1451
1448
  if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
1452
- throw new requirement_1.RoomException("Invalid create room secret response payload");
1449
+ throw new RoomException("Invalid create room secret response payload");
1453
1450
  }
1454
1451
  return payload.id;
1455
1452
  }
@@ -1507,19 +1504,19 @@ class Meshagent {
1507
1504
  projectId,
1508
1505
  name: secret.name,
1509
1506
  type: secret.type,
1510
- data: utils_1.encoder.encode(JSON.stringify(this.toSecretPayload(secret).data)),
1507
+ data: encoder.encode(JSON.stringify(this.toSecretPayload(secret).data)),
1511
1508
  });
1512
1509
  }
1513
1510
  async updateSecret(projectId, secret) {
1514
1511
  if (!secret.id) {
1515
- throw new requirement_1.RoomException("Secret id is required to update a secret");
1512
+ throw new RoomException("Secret id is required to update a secret");
1516
1513
  }
1517
1514
  await this.updateProjectSecret({
1518
1515
  projectId,
1519
1516
  secretId: secret.id,
1520
1517
  name: secret.name,
1521
1518
  type: secret.type,
1522
- data: utils_1.encoder.encode(JSON.stringify(this.toSecretPayload(secret).data)),
1519
+ data: encoder.encode(JSON.stringify(this.toSecretPayload(secret).data)),
1523
1520
  });
1524
1521
  }
1525
1522
  async deleteSecret(projectId, secretId) {
@@ -1547,7 +1544,7 @@ class Meshagent {
1547
1544
  action: "create project external oauth registration",
1548
1545
  });
1549
1546
  if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
1550
- throw new requirement_1.RoomException("Invalid create project external oauth registration response payload");
1547
+ throw new RoomException("Invalid create project external oauth registration response payload");
1551
1548
  }
1552
1549
  return payload.id;
1553
1550
  }
@@ -1602,7 +1599,7 @@ class Meshagent {
1602
1599
  action: "create room external oauth registration",
1603
1600
  });
1604
1601
  if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
1605
- throw new requirement_1.RoomException("Invalid create room external oauth registration response payload");
1602
+ throw new RoomException("Invalid create room external oauth registration response payload");
1606
1603
  }
1607
1604
  return payload.id;
1608
1605
  }
@@ -1654,7 +1651,7 @@ class Meshagent {
1654
1651
  if (permissions) {
1655
1652
  const serialized = {};
1656
1653
  for (const [key, value] of Object.entries(permissions)) {
1657
- serialized[key] = value instanceof participant_token_1.ApiScope ? value.toJSON() : value;
1654
+ serialized[key] = value instanceof ApiScope ? value.toJSON() : value;
1658
1655
  }
1659
1656
  payload["permissions"] = serialized;
1660
1657
  }
@@ -1944,4 +1941,3 @@ class Meshagent {
1944
1941
  });
1945
1942
  }
1946
1943
  }
1947
- exports.Meshagent = Meshagent;
@@ -1,7 +1,7 @@
1
- import { EventEmitter } from "./event-emitter";
2
- import { Participant, RemoteParticipant } from "./participant";
3
- import { RoomClient } from "./room-client";
4
- import { RoomMessageEvent } from "./room-event";
1
+ import { EventEmitter } from "./event-emitter.js";
2
+ import { Participant, RemoteParticipant } from "./participant.js";
3
+ import { RoomClient } from "./room-client.js";
4
+ import { RoomMessageEvent } from "./room-event.js";
5
5
  type MessagePayload = Record<string, unknown>;
6
6
  export declare class MessagingClient extends EventEmitter<RoomMessageEvent> {
7
7
  private readonly client;