@meshagent/meshagent 0.39.3 → 0.39.5

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 (53) hide show
  1. package/CHANGELOG.md +10 -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/browser/room-client.d.ts +3 -1
  7. package/dist/browser/room-client.js +23 -7
  8. package/dist/esm/agent-client.js +18 -12
  9. package/dist/esm/agent.js +26 -18
  10. package/dist/esm/api_keys.js +21 -11
  11. package/dist/esm/client.js +13 -7
  12. package/dist/esm/completer.js +5 -1
  13. package/dist/esm/containers-client.js +85 -80
  14. package/dist/esm/datasets-client.js +105 -95
  15. package/dist/esm/developer-client.js +15 -11
  16. package/dist/esm/document.js +20 -11
  17. package/dist/esm/entrypoint.d.ts +1426 -1464
  18. package/dist/esm/entrypoint.js +12 -1
  19. package/dist/esm/event-emitter.js +5 -1
  20. package/dist/esm/helpers.js +23 -15
  21. package/dist/esm/index.js +49 -33
  22. package/dist/esm/lk-client.js +12 -7
  23. package/dist/esm/lk-protocol.js +8 -4
  24. package/dist/esm/memory-client.js +11 -7
  25. package/dist/esm/meshagent-client.js +88 -79
  26. package/dist/esm/messaging-client.js +37 -33
  27. package/dist/esm/package.json +1 -0
  28. package/dist/esm/participant-token.js +62 -34
  29. package/dist/esm/participant.js +9 -3
  30. package/dist/esm/protocol.js +43 -29
  31. package/dist/esm/queues-client.js +17 -12
  32. package/dist/esm/requirement.js +11 -4
  33. package/dist/esm/response.js +34 -22
  34. package/dist/esm/room-client.d.ts +3 -1
  35. package/dist/esm/room-client.js +154 -133
  36. package/dist/esm/room-event.js +21 -9
  37. package/dist/esm/room-server-client.js +18 -13
  38. package/dist/esm/runtime.js +10 -1
  39. package/dist/esm/schema.js +18 -9
  40. package/dist/esm/secrets-client.js +35 -31
  41. package/dist/esm/services-client.js +13 -9
  42. package/dist/esm/storage-client.js +38 -32
  43. package/dist/esm/stream-controller.js +5 -1
  44. package/dist/esm/sync-client.js +42 -38
  45. package/dist/esm/tool-content-type.js +5 -1
  46. package/dist/esm/utils.js +20 -10
  47. package/dist/esm/version.js +4 -1
  48. package/dist/node/entrypoint.d.ts +1426 -1464
  49. package/dist/node/meshagent-client.js +7 -2
  50. package/dist/node/package.json +1 -0
  51. package/dist/node/room-client.d.ts +3 -1
  52. package/dist/node/room-client.js +23 -7
  53. package/package.json +1 -1
@@ -45,6 +45,11 @@ function serializeServiceSpec(service) {
45
45
  agents,
46
46
  });
47
47
  }
48
+ function serializeCreateServiceSpec(service) {
49
+ const payload = serializeServiceSpec(service);
50
+ delete payload.id;
51
+ return payload;
52
+ }
48
53
  const globalScope = globalThis;
49
54
  function bytesToBase64(bytes) {
50
55
  if (globalScope.Buffer) {
@@ -1261,7 +1266,7 @@ class Meshagent {
1261
1266
  async createService(projectId, service) {
1262
1267
  const data = await this.request(`/accounts/projects/${projectId}/services`, {
1263
1268
  method: "POST",
1264
- json: serializeServiceSpec(service),
1269
+ json: serializeCreateServiceSpec(service),
1265
1270
  action: "create service",
1266
1271
  });
1267
1272
  if (!data || typeof data !== "object" || typeof data.id !== "string") {
@@ -1272,7 +1277,7 @@ class Meshagent {
1272
1277
  async createRoomService(projectId, roomName, service) {
1273
1278
  const data = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/services`, {
1274
1279
  method: "POST",
1275
- json: serializeServiceSpec(service),
1280
+ json: serializeCreateServiceSpec(service),
1276
1281
  action: "create room service",
1277
1282
  });
1278
1283
  if (!data || typeof data !== "object" || typeof data.id !== "string") {
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -85,7 +85,8 @@ export declare class RoomClient {
85
85
  private _roomName;
86
86
  private _roomUrl;
87
87
  private _sessionId;
88
- private static readonly RECONNECT_RETRY_INTERVAL_MS;
88
+ private static readonly RECONNECT_RETRY_BASE_DELAY_MS;
89
+ private static readonly RECONNECT_RETRY_MAX_DELAY_MS;
89
90
  private readonly _handleRoomReadyBound;
90
91
  private readonly _handleRoomStatusBound;
91
92
  private readonly _handleParticipantBound;
@@ -151,6 +152,7 @@ export declare class RoomClient {
151
152
  private _completeReconnect;
152
153
  private _replaceProtocol;
153
154
  private _remainingReconnectTimeout;
155
+ private _reconnectRetryDelay;
154
156
  private _attemptInitialProtocolStartup;
155
157
  private _attemptReconnect;
156
158
  private _formatDuration;
@@ -29,6 +29,12 @@ class ProtocolStartupFailure extends Error {
29
29
  this.reason = reason;
30
30
  }
31
31
  }
32
+ function isRetryableStartupClose({ kind, reason, }) {
33
+ if (kind === protocol_1.ProtocolCloseKind.ERROR) {
34
+ return true;
35
+ }
36
+ return (reason ?? "").toLowerCase().includes("1013");
37
+ }
32
38
  class RoomClientTerminalState {
33
39
  constructor({ requestMessage, toolCallMessage, messageSendMessage, }) {
34
40
  this.requestMessage = requestMessage;
@@ -655,7 +661,8 @@ class RoomClient {
655
661
  }
656
662
  catch (error) {
657
663
  if (error instanceof ProtocolStartupFailure) {
658
- if (error.kind !== protocol_1.ProtocolCloseKind.ERROR || this._reconnectTimeout === 0) {
664
+ if (!isRetryableStartupClose({ kind: error.kind, reason: error.reason })
665
+ || this._reconnectTimeout === 0) {
659
666
  this._setStartupTerminalState({
660
667
  closeKind: error.kind,
661
668
  closeReason: error.reason,
@@ -691,7 +698,8 @@ class RoomClient {
691
698
  }
692
699
  const closeKind = this._protocolInstance.closeKind;
693
700
  const protocolCloseReason = normalizeCloseReason(this._protocolInstance.closeReason);
694
- if (closeKind != null && closeKind !== protocol_1.ProtocolCloseKind.ERROR) {
701
+ if (closeKind != null
702
+ && !isRetryableStartupClose({ kind: closeKind, reason: protocolCloseReason })) {
695
703
  this._setStartupTerminalState({
696
704
  closeKind,
697
705
  closeReason: protocolCloseReason,
@@ -770,6 +778,9 @@ class RoomClient {
770
778
  const remaining = deadline - Date.now();
771
779
  return remaining <= 0 ? 0 : remaining;
772
780
  }
781
+ _reconnectRetryDelay({ retryCount }) {
782
+ return Math.min(RoomClient.RECONNECT_RETRY_MAX_DELAY_MS, RoomClient.RECONNECT_RETRY_BASE_DELAY_MS * (2 ** retryCount));
783
+ }
773
784
  async _attemptInitialProtocolStartup({ protocol, remaining, }) {
774
785
  void protocol;
775
786
  if (remaining == null) {
@@ -865,11 +876,13 @@ class RoomClient {
865
876
  };
866
877
  const deadline = this._reconnectTimeout == null ? null : Date.now() + this._reconnectTimeout;
867
878
  let firstAttempt = true;
879
+ let retryCount = 0;
868
880
  while (!this._closing) {
869
881
  if (firstAttempt) {
870
882
  firstAttempt = false;
871
883
  if (this._reconnectTimeout == null) {
872
- await new Promise((resolve) => setTimeout(resolve, RoomClient.RECONNECT_RETRY_INTERVAL_MS));
884
+ await new Promise((resolve) => setTimeout(resolve, this._reconnectRetryDelay({ retryCount })));
885
+ retryCount += 1;
873
886
  }
874
887
  }
875
888
  else {
@@ -877,12 +890,14 @@ class RoomClient {
877
890
  if (remaining != null && remaining === 0) {
878
891
  return this._timedOutRetryResult({ disconnectReason: failureReason });
879
892
  }
893
+ const backoffDelay = this._reconnectRetryDelay({ retryCount });
880
894
  const delay = remaining == null
881
- ? RoomClient.RECONNECT_RETRY_INTERVAL_MS
882
- : Math.min(remaining, RoomClient.RECONNECT_RETRY_INTERVAL_MS);
895
+ ? backoffDelay
896
+ : Math.min(remaining, backoffDelay);
883
897
  if (delay > 0) {
884
898
  await new Promise((resolve) => setTimeout(resolve, delay));
885
899
  }
900
+ retryCount += 1;
886
901
  }
887
902
  const remaining = this._remainingReconnectTimeout(deadline);
888
903
  if (remaining != null && remaining === 0) {
@@ -917,7 +932,7 @@ class RoomClient {
917
932
  if (error instanceof ProtocolStartupFailure) {
918
933
  recordFailureReason(error.reason);
919
934
  await this._closeProtocol(nextProtocol);
920
- if (error.kind !== protocol_1.ProtocolCloseKind.ERROR) {
935
+ if (!isRetryableStartupClose({ kind: error.kind, reason: error.reason })) {
921
936
  return {
922
937
  connected: false,
923
938
  closeKind: error.kind,
@@ -1430,4 +1445,5 @@ class RoomClient {
1430
1445
  }
1431
1446
  }
1432
1447
  exports.RoomClient = RoomClient;
1433
- RoomClient.RECONNECT_RETRY_INTERVAL_MS = 1000;
1448
+ RoomClient.RECONNECT_RETRY_BASE_DELAY_MS = 500;
1449
+ RoomClient.RECONNECT_RETRY_MAX_DELAY_MS = 30000;
@@ -1,11 +1,14 @@
1
- import { ToolContentSpec } from "./tool-content-type";
2
- export class ToolDescription {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentsClient = exports.ToolkitDescription = exports.ToolDescription = void 0;
4
+ const tool_content_type_1 = require("./tool-content-type");
5
+ class ToolDescription {
3
6
  constructor({ title, name, description, inputSchema, inputSpec, outputSpec, outputSchema, thumbnailUrl, defs, pricing }) {
4
7
  this.title = title;
5
8
  this.name = name;
6
9
  this.description = description;
7
10
  if (inputSpec !== undefined && inputSchema !== undefined) {
8
- this.inputSpec = new ToolContentSpec({
11
+ this.inputSpec = new tool_content_type_1.ToolContentSpec({
9
12
  types: [...inputSpec.types],
10
13
  stream: inputSpec.stream,
11
14
  schema: inputSchema,
@@ -15,14 +18,14 @@ export class ToolDescription {
15
18
  this.inputSpec = inputSpec;
16
19
  }
17
20
  else if (inputSchema !== undefined) {
18
- this.inputSpec = new ToolContentSpec({
21
+ this.inputSpec = new tool_content_type_1.ToolContentSpec({
19
22
  types: ["json"],
20
23
  stream: false,
21
24
  schema: inputSchema,
22
25
  });
23
26
  }
24
27
  if (outputSpec !== undefined && outputSchema !== undefined) {
25
- this.outputSpec = new ToolContentSpec({
28
+ this.outputSpec = new tool_content_type_1.ToolContentSpec({
26
29
  types: [...outputSpec.types],
27
30
  stream: outputSpec.stream,
28
31
  schema: outputSchema,
@@ -32,7 +35,7 @@ export class ToolDescription {
32
35
  this.outputSpec = outputSpec;
33
36
  }
34
37
  else if (outputSchema !== undefined) {
35
- this.outputSpec = new ToolContentSpec({
38
+ this.outputSpec = new tool_content_type_1.ToolContentSpec({
36
39
  types: ["json"],
37
40
  stream: false,
38
41
  schema: outputSchema,
@@ -49,7 +52,8 @@ export class ToolDescription {
49
52
  return this.outputSpec?.schema;
50
53
  }
51
54
  }
52
- export class ToolkitDescription {
55
+ exports.ToolDescription = ToolDescription;
56
+ class ToolkitDescription {
53
57
  constructor({ title, name, description, tools, thumbnailUrl, participantId }) {
54
58
  this.title = title;
55
59
  this.name = name;
@@ -98,9 +102,9 @@ export class ToolkitDescription {
98
102
  name: tool["name"],
99
103
  description: tool["description"],
100
104
  inputSchema: tool["input_schema"],
101
- inputSpec: ToolContentSpec.fromJson(tool["input_spec"]),
105
+ inputSpec: tool_content_type_1.ToolContentSpec.fromJson(tool["input_spec"]),
102
106
  outputSchema: tool["output_schema"],
103
- outputSpec: ToolContentSpec.fromJson(tool["output_spec"]),
107
+ outputSpec: tool_content_type_1.ToolContentSpec.fromJson(tool["output_spec"]),
104
108
  thumbnailUrl: tool["thumbnail_url"],
105
109
  defs: tool["defs"],
106
110
  pricing: tool["pricing"],
@@ -116,9 +120,9 @@ export class ToolkitDescription {
116
120
  name: toolName,
117
121
  description: tool["description"],
118
122
  inputSchema: tool["input_schema"],
119
- inputSpec: ToolContentSpec.fromJson(tool["input_spec"]),
123
+ inputSpec: tool_content_type_1.ToolContentSpec.fromJson(tool["input_spec"]),
120
124
  outputSchema: tool["output_schema"],
121
- outputSpec: ToolContentSpec.fromJson(tool["output_spec"]),
125
+ outputSpec: tool_content_type_1.ToolContentSpec.fromJson(tool["output_spec"]),
122
126
  thumbnailUrl: tool["thumbnail_url"],
123
127
  defs: tool["defs"],
124
128
  pricing: tool["pricing"],
@@ -135,7 +139,8 @@ export class ToolkitDescription {
135
139
  });
136
140
  }
137
141
  }
138
- export class AgentsClient {
142
+ exports.ToolkitDescription = ToolkitDescription;
143
+ class AgentsClient {
139
144
  constructor({ room }) {
140
145
  this.client = room;
141
146
  }
@@ -149,3 +154,4 @@ export class AgentsClient {
149
154
  return await this.client.invoke(params);
150
155
  }
151
156
  }
157
+ exports.AgentsClient = AgentsClient;
package/dist/esm/agent.js CHANGED
@@ -1,15 +1,19 @@
1
- import { ErrorContent } from "./response";
2
- import { RoomServerException } from "./room-server-client";
3
- import { ToolContentSpec } from "./tool-content-type";
4
- import { unpackMessage } from "./utils";
5
- import { RoomStatusEvent } from "./room-event";
6
- export class Tool {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RemoteTaskRunner = exports.HostedToolkit = exports.Toolkit = exports.Tool = void 0;
4
+ exports.startHostedToolkit = startHostedToolkit;
5
+ const response_1 = require("./response");
6
+ const room_server_client_1 = require("./room-server-client");
7
+ const tool_content_type_1 = require("./tool-content-type");
8
+ const utils_1 = require("./utils");
9
+ const room_event_1 = require("./room-event");
10
+ class Tool {
7
11
  constructor({ name, description, title, inputSchema, inputSpec, outputSpec, outputSchema, thumbnailUrl }) {
8
12
  this.name = name;
9
13
  this.description = description;
10
14
  this.title = title;
11
15
  if (inputSpec !== undefined && inputSchema !== undefined) {
12
- this.inputSpec = new ToolContentSpec({
16
+ this.inputSpec = new tool_content_type_1.ToolContentSpec({
13
17
  types: [...inputSpec.types],
14
18
  stream: inputSpec.stream,
15
19
  schema: inputSchema,
@@ -19,14 +23,14 @@ export class Tool {
19
23
  this.inputSpec = inputSpec;
20
24
  }
21
25
  else if (inputSchema !== undefined) {
22
- this.inputSpec = new ToolContentSpec({
26
+ this.inputSpec = new tool_content_type_1.ToolContentSpec({
23
27
  types: ["json"],
24
28
  stream: false,
25
29
  schema: inputSchema,
26
30
  });
27
31
  }
28
32
  if (outputSpec !== undefined && outputSchema !== undefined) {
29
- this.outputSpec = new ToolContentSpec({
33
+ this.outputSpec = new tool_content_type_1.ToolContentSpec({
30
34
  types: [...outputSpec.types],
31
35
  stream: outputSpec.stream,
32
36
  schema: outputSchema,
@@ -36,7 +40,7 @@ export class Tool {
36
40
  this.outputSpec = outputSpec;
37
41
  }
38
42
  else if (outputSchema !== undefined) {
39
- this.outputSpec = new ToolContentSpec({
43
+ this.outputSpec = new tool_content_type_1.ToolContentSpec({
40
44
  types: ["json"],
41
45
  stream: false,
42
46
  schema: outputSchema,
@@ -51,7 +55,8 @@ export class Tool {
51
55
  return this.outputSpec?.schema;
52
56
  }
53
57
  }
54
- export class Toolkit {
58
+ exports.Tool = Tool;
59
+ class Toolkit {
55
60
  constructor({ name, title = name, description = "", thumbnailUrl, tools, rules = [] }) {
56
61
  this.name = name;
57
62
  this.title = title;
@@ -84,7 +89,8 @@ export class Toolkit {
84
89
  return this.getTool(name).execute(args);
85
90
  }
86
91
  }
87
- export class HostedToolkit {
92
+ exports.Toolkit = Toolkit;
93
+ class HostedToolkit {
88
94
  constructor({ toolkit, stopHostedToolkit }) {
89
95
  this.toolkit = toolkit;
90
96
  this._stopHostedToolkit = stopHostedToolkit;
@@ -93,6 +99,7 @@ export class HostedToolkit {
93
99
  await this._stopHostedToolkit();
94
100
  }
95
101
  }
102
+ exports.HostedToolkit = HostedToolkit;
96
103
  class _RemoteToolkitWrapper {
97
104
  constructor({ toolkit, room }) {
98
105
  this._toolCallHandler = this._toolCall.bind(this);
@@ -105,7 +112,7 @@ class _RemoteToolkitWrapper {
105
112
  }
106
113
  async start({ public_: isPublic = false } = {}) {
107
114
  if (this._started) {
108
- throw new RoomServerException(`toolkit '${this.toolkit.name}' is already started`);
115
+ throw new room_server_client_1.RoomServerException(`toolkit '${this.toolkit.name}' is already started`);
109
116
  }
110
117
  this._public = isPublic;
111
118
  this.client.protocol.addHandler(`room.tool_call.${this.toolkit.name}`, this._toolCallHandler);
@@ -171,7 +178,7 @@ class _RemoteToolkitWrapper {
171
178
  });
172
179
  }
173
180
  _onRoomEvent(event) {
174
- if (!this._started || !(event instanceof RoomStatusEvent)) {
181
+ if (!this._started || !(event instanceof room_event_1.RoomStatusEvent)) {
175
182
  return;
176
183
  }
177
184
  if (event.status === "disconnected") {
@@ -187,7 +194,7 @@ class _RemoteToolkitWrapper {
187
194
  return;
188
195
  }
189
196
  try {
190
- const [message, _] = unpackMessage(data);
197
+ const [message, _] = (0, utils_1.unpackMessage)(data);
191
198
  const toolName = message["name"];
192
199
  const rawArguments = message["arguments"];
193
200
  let args;
@@ -214,12 +221,12 @@ class _RemoteToolkitWrapper {
214
221
  await this.client.protocol.send("room.tool_call_response", response.pack(), { id: messageId });
215
222
  }
216
223
  catch (e) {
217
- const err = new ErrorContent({ text: String(e) });
224
+ const err = new response_1.ErrorContent({ text: String(e) });
218
225
  await this.client.protocol.send("room.tool_call_response", err.pack(), { id: messageId });
219
226
  }
220
227
  }
221
228
  }
222
- export async function startHostedToolkit({ room, toolkit, public_: isPublic = false }) {
229
+ async function startHostedToolkit({ room, toolkit, public_: isPublic = false }) {
223
230
  const wrapper = new _RemoteToolkitWrapper({ toolkit, room });
224
231
  await wrapper.start({ public_: isPublic });
225
232
  return new HostedToolkit({
@@ -227,7 +234,7 @@ export async function startHostedToolkit({ room, toolkit, public_: isPublic = fa
227
234
  stopHostedToolkit: () => wrapper.stop(),
228
235
  });
229
236
  }
230
- export class RemoteTaskRunner {
237
+ class RemoteTaskRunner {
231
238
  constructor({ name, description, client, inputSchema, outputSchema, supportsTools = false, required = [], }) {
232
239
  this.client = client;
233
240
  this.name = name;
@@ -246,3 +253,4 @@ export class RemoteTaskRunner {
246
253
  }
247
254
  }
248
255
  }
256
+ exports.RemoteTaskRunner = RemoteTaskRunner;
@@ -1,4 +1,14 @@
1
- import { encode as base64Encode, decode as base64Decode } from "base-64";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.base36Encode = base36Encode;
4
+ exports.base36Decode = base36Decode;
5
+ exports.compressUuid = compressUuid;
6
+ exports.decompressUuid = decompressUuid;
7
+ exports.base64CompressUuid = base64CompressUuid;
8
+ exports.base64DecompressUuid = base64DecompressUuid;
9
+ exports.parseApiKey = parseApiKey;
10
+ exports.encodeApiKey = encodeApiKey;
11
+ const base_64_1 = require("base-64");
2
12
  const BASE36_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
3
13
  const BASE36 = 36n;
4
14
  const UUID_HEX_REGEX = /^[0-9a-f]{32}$/;
@@ -14,7 +24,7 @@ function toBigInt(value) {
14
24
  }
15
25
  throw new TypeError("number must be an integer");
16
26
  }
17
- export function base36Encode(value) {
27
+ function base36Encode(value) {
18
28
  const number = toBigInt(value);
19
29
  if (number < 0n) {
20
30
  throw new RangeError("number must be non-negative");
@@ -31,7 +41,7 @@ export function base36Encode(value) {
31
41
  }
32
42
  return base36;
33
43
  }
34
- export function base36Decode(numberStr) {
44
+ function base36Decode(numberStr) {
35
45
  const sanitized = numberStr.trim().toLowerCase();
36
46
  if (sanitized === "") {
37
47
  return 0n;
@@ -85,7 +95,7 @@ function bytesToBase64(bytes) {
85
95
  if (globalScope.btoa) {
86
96
  return globalScope.btoa(binary);
87
97
  }
88
- return base64Encode(binary);
98
+ return (0, base_64_1.encode)(binary);
89
99
  }
90
100
  function base64ToBytes(base64) {
91
101
  if (globalScope.Buffer) {
@@ -97,7 +107,7 @@ function base64ToBytes(base64) {
97
107
  binary = globalScope.atob(base64);
98
108
  }
99
109
  else {
100
- binary = base64Decode(base64);
110
+ binary = (0, base_64_1.decode)(base64);
101
111
  }
102
112
  const bytes = new Uint8Array(binary.length);
103
113
  for (let i = 0; i < binary.length; i += 1) {
@@ -105,17 +115,17 @@ function base64ToBytes(base64) {
105
115
  }
106
116
  return bytes;
107
117
  }
108
- export function compressUuid(guidString) {
118
+ function compressUuid(guidString) {
109
119
  const hex = normalizeUuidHex(guidString);
110
120
  const guidInt = BigInt(`0x${hex}`);
111
121
  return base36Encode(guidInt);
112
122
  }
113
- export function decompressUuid(compressedUuid) {
123
+ function decompressUuid(compressedUuid) {
114
124
  const guidInt = base36Decode(compressedUuid);
115
125
  const hex = guidInt.toString(16).padStart(32, "0");
116
126
  return formatUuidFromHex(hex);
117
127
  }
118
- export function base64CompressUuid(id) {
128
+ function base64CompressUuid(id) {
119
129
  const hex = normalizeUuidHex(id);
120
130
  const bytes = hexToBytes(hex);
121
131
  const base64 = bytesToBase64(bytes)
@@ -123,7 +133,7 @@ export function base64CompressUuid(id) {
123
133
  .replace(/\//g, "_");
124
134
  return base64.replace(/-/g, ".").replace(/=+$/g, "");
125
135
  }
126
- export function base64DecompressUuid(id) {
136
+ function base64DecompressUuid(id) {
127
137
  let base64 = id.replace(/\./g, "-");
128
138
  const paddingNeeded = base64.length % 4;
129
139
  if (paddingNeeded !== 0) {
@@ -154,7 +164,7 @@ function splitApiKey(key) {
154
164
  }
155
165
  return { idPart, projectPart, secret };
156
166
  }
157
- export function parseApiKey(key) {
167
+ function parseApiKey(key) {
158
168
  if (!key.startsWith("ma-")) {
159
169
  throw new Error("invalid api key");
160
170
  }
@@ -165,7 +175,7 @@ export function parseApiKey(key) {
165
175
  secret,
166
176
  };
167
177
  }
168
- export function encodeApiKey(key) {
178
+ function encodeApiKey(key) {
169
179
  return ("ma-" +
170
180
  base64CompressUuid(key.id) +
171
181
  "-" +
@@ -1,5 +1,8 @@
1
- import { v4 as uuid } from "uuid";
2
- export class XmlElement {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientXmlDocument = exports.XmlText = exports.XmlElement = void 0;
4
+ const uuid_1 = require("uuid");
5
+ class XmlElement {
3
6
  constructor(parent, { tagName, attributes }, doc) {
4
7
  this._data = {
5
8
  tagName,
@@ -66,7 +69,7 @@ export class XmlElement {
66
69
  });
67
70
  }
68
71
  createChildElement(tagName, attributes) {
69
- const newId = uuid();
72
+ const newId = (0, uuid_1.v4)();
70
73
  const elementData = {
71
74
  name: tagName,
72
75
  attributes: {
@@ -93,7 +96,7 @@ export class XmlElement {
93
96
  return this.getNodeByID(newId);
94
97
  }
95
98
  createChildElementAt(index, tagName, attributes) {
96
- const newId = uuid();
99
+ const newId = (0, uuid_1.v4)();
97
100
  const elementData = {
98
101
  name: tagName,
99
102
  attributes: {
@@ -131,7 +134,7 @@ export class XmlElement {
131
134
  throw new Error("Text does not belong to this node");
132
135
  }
133
136
  }
134
- const newId = uuid();
137
+ const newId = (0, uuid_1.v4)();
135
138
  const elementData = {
136
139
  name: tagName,
137
140
  attributes: {
@@ -185,7 +188,8 @@ export class XmlElement {
185
188
  return this._data.children;
186
189
  }
187
190
  }
188
- export class XmlText {
191
+ exports.XmlElement = XmlElement;
192
+ class XmlText {
189
193
  constructor(parent, data, doc) {
190
194
  this._data = data;
191
195
  this.parent = parent;
@@ -242,7 +246,8 @@ export class XmlText {
242
246
  return this.parent?.id;
243
247
  }
244
248
  }
245
- export class ClientXmlDocument {
249
+ exports.XmlText = XmlText;
250
+ class ClientXmlDocument {
246
251
  constructor({ id, sendChanges, }) {
247
252
  this._root = new XmlElement(null, { tagName: "root", attributes: {} }, this);
248
253
  this.sendChanges = sendChanges;
@@ -441,3 +446,4 @@ export class ClientXmlDocument {
441
446
  }
442
447
  }
443
448
  }
449
+ exports.ClientXmlDocument = ClientXmlDocument;
@@ -1,4 +1,7 @@
1
- export class Completer {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Completer = void 0;
4
+ class Completer {
2
5
  constructor() {
3
6
  this.completed = false;
4
7
  this.fut = new Promise((resolve, reject) => {
@@ -19,3 +22,4 @@ export class Completer {
19
22
  this.reject(reason);
20
23
  }
21
24
  }
25
+ exports.Completer = Completer;