@meshagent/meshagent 0.42.2 → 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.
- package/CHANGELOG.md +7 -0
- package/dist/browser/agent-client.d.ts +4 -4
- package/dist/browser/agent-client.js +16 -16
- package/dist/browser/agent.d.ts +6 -6
- package/dist/browser/agent.js +57 -57
- package/dist/browser/api_keys.js +7 -3
- package/dist/browser/containers-client.d.ts +3 -3
- package/dist/browser/containers-client.js +76 -76
- package/dist/browser/datasets-client.d.ts +1 -1
- package/dist/browser/datasets-client.js +83 -83
- package/dist/browser/developer-client.d.ts +3 -3
- package/dist/browser/developer-client.js +11 -11
- package/dist/browser/document.d.ts +2 -2
- package/dist/browser/document.js +3 -3
- package/dist/browser/helpers.d.ts +4 -4
- package/dist/browser/helpers.js +9 -9
- package/dist/browser/index.d.ts +35 -35
- package/dist/browser/index.js +35 -35
- package/dist/browser/memory-client.d.ts +1 -1
- package/dist/browser/memory-client.js +6 -6
- package/dist/browser/meshagent-client.d.ts +1 -1
- package/dist/browser/meshagent-client.js +78 -78
- package/dist/browser/messaging-client.d.ts +4 -4
- package/dist/browser/messaging-client.js +33 -33
- package/dist/browser/participant-token.d.ts +1 -1
- package/dist/browser/participant-token.js +5 -5
- package/dist/browser/participant.d.ts +1 -1
- package/dist/browser/protocol.d.ts +7 -4
- package/dist/browser/protocol.js +36 -20
- package/dist/browser/queues-client.d.ts +1 -1
- package/dist/browser/queues-client.js +10 -10
- package/dist/browser/response.js +11 -11
- package/dist/browser/room-client.d.ts +23 -17
- package/dist/browser/room-client.js +138 -130
- package/dist/browser/room-server-client.d.ts +2 -2
- package/dist/browser/room-server-client.js +10 -10
- package/dist/browser/secrets-client.d.ts +3 -3
- package/dist/browser/secrets-client.js +30 -30
- package/dist/browser/services-client.d.ts +2 -2
- package/dist/browser/services-client.js +8 -8
- package/dist/browser/storage-client.d.ts +5 -5
- package/dist/browser/storage-client.js +30 -30
- package/dist/browser/sync-client.d.ts +4 -4
- package/dist/browser/sync-client.js +38 -38
- package/dist/browser/toolkit-config.d.ts +3 -3
- package/dist/esm/agent-client.d.ts +4 -4
- package/dist/esm/agent-client.js +19 -25
- package/dist/esm/agent.d.ts +6 -6
- package/dist/esm/agent.js +73 -93
- package/dist/esm/api_keys.js +12 -21
- package/dist/esm/client.js +7 -13
- package/dist/esm/completer.js +1 -5
- package/dist/esm/containers-client.d.ts +3 -3
- package/dist/esm/containers-client.js +82 -87
- package/dist/esm/datasets-client.d.ts +1 -1
- package/dist/esm/datasets-client.js +101 -111
- package/dist/esm/developer-client.d.ts +3 -3
- package/dist/esm/developer-client.js +11 -15
- package/dist/esm/document.d.ts +2 -2
- package/dist/esm/document.js +11 -20
- package/dist/esm/entrypoint.js +1 -12
- package/dist/esm/event-emitter.js +1 -5
- package/dist/esm/helpers.d.ts +4 -4
- package/dist/esm/helpers.js +15 -23
- package/dist/esm/index.d.ts +35 -35
- package/dist/esm/index.js +35 -51
- package/dist/esm/memory-client.d.ts +1 -1
- package/dist/esm/memory-client.js +7 -11
- package/dist/esm/meshagent-client.d.ts +1 -1
- package/dist/esm/meshagent-client.js +79 -83
- package/dist/esm/messaging-client.d.ts +4 -4
- package/dist/esm/messaging-client.js +33 -37
- package/dist/esm/oauth-scopes.js +2 -5
- package/dist/esm/participant-token.d.ts +1 -1
- package/dist/esm/participant-token.js +34 -62
- package/dist/esm/participant.d.ts +1 -1
- package/dist/esm/participant.js +3 -9
- package/dist/esm/protocol.d.ts +7 -4
- package/dist/esm/protocol.js +48 -46
- package/dist/esm/queues-client.d.ts +1 -1
- package/dist/esm/queues-client.js +12 -17
- package/dist/esm/requirement.js +4 -11
- package/dist/esm/response.js +22 -34
- package/dist/esm/room-client.d.ts +23 -17
- package/dist/esm/room-client.js +140 -137
- package/dist/esm/room-event.js +9 -21
- package/dist/esm/room-server-client.d.ts +2 -2
- package/dist/esm/room-server-client.js +13 -18
- package/dist/esm/runtime.js +1 -10
- package/dist/esm/schema.js +9 -18
- package/dist/esm/secrets-client.d.ts +3 -3
- package/dist/esm/secrets-client.js +31 -35
- package/dist/esm/services-client.d.ts +2 -2
- package/dist/esm/services-client.js +9 -13
- package/dist/esm/storage-client.d.ts +5 -5
- package/dist/esm/storage-client.js +32 -38
- package/dist/esm/stream-controller.js +1 -5
- package/dist/esm/sync-client.d.ts +4 -4
- package/dist/esm/sync-client.js +38 -42
- package/dist/esm/tool-content-type.js +1 -5
- package/dist/esm/toolkit-config.d.ts +3 -3
- package/dist/esm/toolkit-config.js +5 -13
- package/dist/esm/utils.js +10 -20
- package/dist/esm/version.js +1 -4
- package/dist/node/agent-client.d.ts +4 -4
- package/dist/node/agent-client.js +16 -16
- package/dist/node/agent.d.ts +6 -6
- package/dist/node/agent.js +57 -57
- package/dist/node/api_keys.js +7 -3
- package/dist/node/containers-client.d.ts +3 -3
- package/dist/node/containers-client.js +76 -76
- package/dist/node/datasets-client.d.ts +1 -1
- package/dist/node/datasets-client.js +83 -83
- package/dist/node/developer-client.d.ts +3 -3
- package/dist/node/developer-client.js +11 -11
- package/dist/node/document.d.ts +2 -2
- package/dist/node/document.js +3 -3
- package/dist/node/helpers.d.ts +4 -4
- package/dist/node/helpers.js +9 -9
- package/dist/node/index.d.ts +35 -35
- package/dist/node/index.js +35 -35
- package/dist/node/memory-client.d.ts +1 -1
- package/dist/node/memory-client.js +6 -6
- package/dist/node/meshagent-client.d.ts +1 -1
- package/dist/node/meshagent-client.js +78 -78
- package/dist/node/messaging-client.d.ts +4 -4
- package/dist/node/messaging-client.js +33 -33
- package/dist/node/participant-token.d.ts +1 -1
- package/dist/node/participant-token.js +5 -5
- package/dist/node/participant.d.ts +1 -1
- package/dist/node/protocol.d.ts +7 -4
- package/dist/node/protocol.js +36 -20
- package/dist/node/queues-client.d.ts +1 -1
- package/dist/node/queues-client.js +10 -10
- package/dist/node/response.js +11 -11
- package/dist/node/room-client.d.ts +23 -17
- package/dist/node/room-client.js +138 -130
- package/dist/node/room-server-client.d.ts +2 -2
- package/dist/node/room-server-client.js +10 -10
- package/dist/node/secrets-client.d.ts +3 -3
- package/dist/node/secrets-client.js +30 -30
- package/dist/node/services-client.d.ts +2 -2
- package/dist/node/services-client.js +8 -8
- package/dist/node/storage-client.d.ts +5 -5
- package/dist/node/storage-client.js +30 -30
- package/dist/node/sync-client.d.ts +4 -4
- package/dist/node/sync-client.js +38 -38
- package/dist/node/toolkit-config.d.ts +3 -3
- package/package.json +11 -5
- package/dist/browser/lk-client.d.ts +0 -18
- package/dist/browser/lk-client.js +0 -33
- package/dist/browser/lk-protocol.d.ts +0 -22
- package/dist/browser/lk-protocol.js +0 -37
- package/dist/esm/lk-client.d.ts +0 -18
- package/dist/esm/lk-client.js +0 -33
- package/dist/esm/lk-protocol.d.ts +0 -22
- package/dist/esm/lk-protocol.js +0 -37
- package/dist/node/lk-client.d.ts +0 -18
- package/dist/node/lk-client.js +0 -33
- package/dist/node/lk-protocol.d.ts +0 -22
- package/dist/node/lk-protocol.js +0 -37
package/dist/node/sync-client.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SyncClient = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
4
|
+
const completer_js_1 = require("./completer.js");
|
|
5
|
+
const event_emitter_js_1 = require("./event-emitter.js");
|
|
6
|
+
const schema_js_1 = require("./schema.js");
|
|
7
|
+
const response_js_1 = require("./response.js");
|
|
8
|
+
const room_server_client_js_1 = require("./room-server-client.js");
|
|
9
|
+
const runtime_js_1 = require("./runtime.js");
|
|
10
|
+
const utils_js_1 = require("./utils.js");
|
|
11
11
|
function normalizeSyncPath(path) {
|
|
12
12
|
let normalized = path;
|
|
13
13
|
while (normalized.startsWith("./")) {
|
|
@@ -27,7 +27,7 @@ function parseSyncOpenStateChunkHeaders(headers) {
|
|
|
27
27
|
typeof headers["schema"] !== "object" ||
|
|
28
28
|
headers["schema"] == null ||
|
|
29
29
|
Array.isArray(headers["schema"])) {
|
|
30
|
-
throw new
|
|
30
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from sync.open");
|
|
31
31
|
}
|
|
32
32
|
return {
|
|
33
33
|
kind: "state",
|
|
@@ -38,7 +38,7 @@ function parseSyncOpenStateChunkHeaders(headers) {
|
|
|
38
38
|
function parseSyncOpenOutputChunkHeaders(headers) {
|
|
39
39
|
const kind = headers["kind"];
|
|
40
40
|
if ((kind !== "state" && kind !== "sync") || typeof headers["path"] !== "string") {
|
|
41
|
-
throw new
|
|
41
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from sync.open");
|
|
42
42
|
}
|
|
43
43
|
return {
|
|
44
44
|
kind,
|
|
@@ -70,7 +70,7 @@ class SyncOpenStreamState {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
async *inputStream() {
|
|
73
|
-
yield new
|
|
73
|
+
yield new response_js_1.BinaryContent({
|
|
74
74
|
data: new Uint8Array(),
|
|
75
75
|
headers: {
|
|
76
76
|
kind: "start",
|
|
@@ -113,12 +113,12 @@ class SyncOpenStreamState {
|
|
|
113
113
|
throw this._error;
|
|
114
114
|
}
|
|
115
115
|
if (this._error !== undefined) {
|
|
116
|
-
throw new
|
|
116
|
+
throw new room_server_client_js_1.RoomServerException(`sync stream failed: ${String(this._error)}`);
|
|
117
117
|
}
|
|
118
118
|
if (this._inputClosed) {
|
|
119
|
-
throw new
|
|
119
|
+
throw new room_server_client_js_1.RoomServerException("attempted to sync to a document that is not connected");
|
|
120
120
|
}
|
|
121
|
-
this._enqueueChunk(new
|
|
121
|
+
this._enqueueChunk(new response_js_1.BinaryContent({
|
|
122
122
|
data,
|
|
123
123
|
headers: { kind: "sync" },
|
|
124
124
|
}));
|
|
@@ -128,7 +128,7 @@ class SyncOpenStreamState {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
SyncOpenStreamState.INPUT_STREAM_CLOSE = Symbol("sync-open-input-close");
|
|
131
|
-
class SyncClient extends
|
|
131
|
+
class SyncClient extends event_emitter_js_1.EventEmitter {
|
|
132
132
|
constructor({ room }) {
|
|
133
133
|
super();
|
|
134
134
|
this._connectingDocuments = {};
|
|
@@ -141,7 +141,7 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
141
141
|
}
|
|
142
142
|
start() {
|
|
143
143
|
if (this._started) {
|
|
144
|
-
throw new
|
|
144
|
+
throw new room_server_client_js_1.RoomServerException("client already started");
|
|
145
145
|
}
|
|
146
146
|
this._started = true;
|
|
147
147
|
}
|
|
@@ -151,7 +151,7 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
151
151
|
streamState.closeInputStream();
|
|
152
152
|
}
|
|
153
153
|
for (const doc of Object.values(this._connectedDocuments)) {
|
|
154
|
-
(0,
|
|
154
|
+
(0, runtime_js_1.unregisterDocument)(doc.ref.id);
|
|
155
155
|
}
|
|
156
156
|
Object.keys(this._documentStreams).forEach((key) => delete this._documentStreams[key]);
|
|
157
157
|
Object.keys(this._documentConfigs).forEach((key) => delete this._documentConfigs[key]);
|
|
@@ -161,7 +161,7 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
161
161
|
this._started = false;
|
|
162
162
|
}
|
|
163
163
|
_unexpectedResponseError(operation) {
|
|
164
|
-
return new
|
|
164
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from sync.${operation}`);
|
|
165
165
|
}
|
|
166
166
|
async _invoke(operation, input) {
|
|
167
167
|
return await this.room.invoke({
|
|
@@ -172,7 +172,7 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
172
172
|
}
|
|
173
173
|
_applySyncPayload(rc, payload) {
|
|
174
174
|
if (payload.length > 0) {
|
|
175
|
-
(0,
|
|
175
|
+
(0, runtime_js_1.applyBackendChanges)(rc.ref.id, utils_js_1.decoder.decode(payload));
|
|
176
176
|
}
|
|
177
177
|
if (!rc.ref.isSynchronized) {
|
|
178
178
|
rc.ref.setSynchronizedComplete();
|
|
@@ -202,7 +202,7 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
202
202
|
connected.count += 1;
|
|
203
203
|
return connected.ref;
|
|
204
204
|
}
|
|
205
|
-
const connecting = new
|
|
205
|
+
const connecting = new completer_js_1.Completer();
|
|
206
206
|
this._connectingDocuments[normalizedPath] = connecting.fut;
|
|
207
207
|
try {
|
|
208
208
|
const config = {
|
|
@@ -216,8 +216,8 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
216
216
|
vector: null,
|
|
217
217
|
initialJson: initialJson ?? null,
|
|
218
218
|
});
|
|
219
|
-
const resolvedSchema =
|
|
220
|
-
const doc = new
|
|
219
|
+
const resolvedSchema = schema_js_1.MeshSchema.fromJson(openResult.stateHeaders.schema);
|
|
220
|
+
const doc = new room_server_client_js_1.MeshDocument({
|
|
221
221
|
schema: resolvedSchema,
|
|
222
222
|
sendChangesToBackend: (base64) => {
|
|
223
223
|
const currentStream = this._documentStreams[normalizedPath];
|
|
@@ -225,13 +225,13 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
227
227
|
try {
|
|
228
|
-
currentStream.queueSync(
|
|
228
|
+
currentStream.queueSync(utils_js_1.encoder.encode(base64));
|
|
229
229
|
}
|
|
230
230
|
catch {
|
|
231
231
|
}
|
|
232
232
|
},
|
|
233
233
|
});
|
|
234
|
-
const rc = new
|
|
234
|
+
const rc = new utils_js_1.RefCount(doc);
|
|
235
235
|
this._connectedDocuments[normalizedPath] = rc;
|
|
236
236
|
this._documentConfigs[normalizedPath] = config;
|
|
237
237
|
this._documentStreams[normalizedPath] = openResult.streamState;
|
|
@@ -259,7 +259,7 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
259
259
|
const normalizedPath = normalizeSyncPath(path);
|
|
260
260
|
const rc = this._connectedDocuments[normalizedPath];
|
|
261
261
|
if (rc == null) {
|
|
262
|
-
throw new
|
|
262
|
+
throw new room_server_client_js_1.RoomServerException(`Not connected to ${normalizedPath}`);
|
|
263
263
|
}
|
|
264
264
|
rc.count -= 1;
|
|
265
265
|
if (rc.count === 0) {
|
|
@@ -274,11 +274,11 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
274
274
|
await streamState.wait();
|
|
275
275
|
}
|
|
276
276
|
finally {
|
|
277
|
-
(0,
|
|
277
|
+
(0, runtime_js_1.unregisterDocument)(rc.ref.id);
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
else {
|
|
281
|
-
(0,
|
|
281
|
+
(0, runtime_js_1.unregisterDocument)(rc.ref.id);
|
|
282
282
|
}
|
|
283
283
|
})();
|
|
284
284
|
this._closingDocuments[normalizedPath] = closeFuture;
|
|
@@ -296,11 +296,11 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
296
296
|
async sync(path, data) {
|
|
297
297
|
const normalizedPath = normalizeSyncPath(path);
|
|
298
298
|
if (this._connectedDocuments[normalizedPath] == null) {
|
|
299
|
-
throw new
|
|
299
|
+
throw new room_server_client_js_1.RoomServerException("attempted to sync to a document that is not connected");
|
|
300
300
|
}
|
|
301
301
|
const streamState = this._documentStreams[normalizedPath];
|
|
302
302
|
if (streamState == null) {
|
|
303
|
-
throw new
|
|
303
|
+
throw new room_server_client_js_1.RoomServerException("attempted to sync to a document that is not connected");
|
|
304
304
|
}
|
|
305
305
|
streamState.queueSync(data);
|
|
306
306
|
}
|
|
@@ -312,21 +312,21 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
314
|
const chunk = next.value;
|
|
315
|
-
if (chunk instanceof
|
|
316
|
-
throw new
|
|
315
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
316
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
317
317
|
}
|
|
318
|
-
if (chunk instanceof
|
|
318
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
319
319
|
if (chunk.method === "close") {
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
322
|
throw this._unexpectedResponseError("open");
|
|
323
323
|
}
|
|
324
|
-
if (!(chunk instanceof
|
|
324
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
325
325
|
throw this._unexpectedResponseError("open");
|
|
326
326
|
}
|
|
327
327
|
const headers = parseSyncOpenOutputChunkHeaders(chunk.headers);
|
|
328
328
|
if (normalizeSyncPath(headers.path) !== path) {
|
|
329
|
-
throw new
|
|
329
|
+
throw new room_server_client_js_1.RoomServerException("sync.open stream returned a mismatched path");
|
|
330
330
|
}
|
|
331
331
|
this._applySyncPayload(rc, chunk.data);
|
|
332
332
|
}
|
|
@@ -355,18 +355,18 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
355
355
|
iterator = responseStream[Symbol.asyncIterator]();
|
|
356
356
|
const first = await iterator.next();
|
|
357
357
|
if (first.done || first.value === undefined) {
|
|
358
|
-
throw new
|
|
358
|
+
throw new room_server_client_js_1.RoomServerException("sync.open stream closed before the initial document state was returned");
|
|
359
359
|
}
|
|
360
360
|
const firstChunk = first.value;
|
|
361
|
-
if (firstChunk instanceof
|
|
362
|
-
throw new
|
|
361
|
+
if (firstChunk instanceof response_js_1.ErrorContent) {
|
|
362
|
+
throw new room_server_client_js_1.RoomServerException(firstChunk.text, firstChunk.code);
|
|
363
363
|
}
|
|
364
|
-
if (!(firstChunk instanceof
|
|
364
|
+
if (!(firstChunk instanceof response_js_1.BinaryContent)) {
|
|
365
365
|
throw this._unexpectedResponseError("open");
|
|
366
366
|
}
|
|
367
367
|
const stateHeaders = parseSyncOpenStateChunkHeaders(firstChunk.headers);
|
|
368
368
|
if (normalizeSyncPath(stateHeaders.path) !== path) {
|
|
369
|
-
throw new
|
|
369
|
+
throw new room_server_client_js_1.RoomServerException("sync.open stream returned a mismatched path");
|
|
370
370
|
}
|
|
371
371
|
return {
|
|
372
372
|
streamState,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ConnectorRef, OAuthClientConfig, ServiceSpec } from "./meshagent-client";
|
|
2
|
-
import type { RemoteParticipant } from "./participant";
|
|
3
|
-
import type { RoomClient } from "./room-client";
|
|
1
|
+
import type { ConnectorRef, OAuthClientConfig, ServiceSpec } from "./meshagent-client.js";
|
|
2
|
+
import type { RemoteParticipant } from "./participant.js";
|
|
3
|
+
import type { RoomClient } from "./room-client.js";
|
|
4
4
|
export declare class MCPHeader {
|
|
5
5
|
readonly name: string;
|
|
6
6
|
readonly value: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshagent/meshagent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"description": "Meshagent Client",
|
|
5
5
|
"homepage": "https://github.com/meshagent/meshagent-ts",
|
|
6
6
|
"scripts": {
|
|
@@ -8,17 +8,24 @@
|
|
|
8
8
|
"build": "mkdir -p dist && ./scripts/build.sh",
|
|
9
9
|
"build-browser-test": "node ./build-browser-test.js"
|
|
10
10
|
},
|
|
11
|
-
"author": "
|
|
11
|
+
"author": "Timu, LLC",
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"main": "./dist/node/index.js",
|
|
14
14
|
"types": "./dist/node/index.d.ts",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
17
|
"types": "./dist/node/index.d.ts",
|
|
18
|
+
"node": {
|
|
19
|
+
"import": "./dist/esm/index.js",
|
|
20
|
+
"require": "./dist/node/index.js"
|
|
21
|
+
},
|
|
22
|
+
"browser": {
|
|
23
|
+
"import": "./dist/esm/index.js",
|
|
24
|
+
"require": "./dist/browser/index.js"
|
|
25
|
+
},
|
|
18
26
|
"import": "./dist/esm/index.js",
|
|
19
|
-
"browser": "./dist/browser/index.js",
|
|
20
27
|
"require": "./dist/node/index.js",
|
|
21
|
-
"default": "./dist/
|
|
28
|
+
"default": "./dist/esm/index.js"
|
|
22
29
|
},
|
|
23
30
|
"./package.json": "./package.json"
|
|
24
31
|
},
|
|
@@ -49,7 +56,6 @@
|
|
|
49
56
|
"base-64": "^1.0.0",
|
|
50
57
|
"isomorphic-ws": "^5.0.0",
|
|
51
58
|
"jose": "^6.0.8",
|
|
52
|
-
"livekit-client": "^2.15.5",
|
|
53
59
|
"uuid": "^14.0.0",
|
|
54
60
|
"ws": "^8.18.0",
|
|
55
61
|
"yjs": "^13.6.28"
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { RoomClient } from './room-client';
|
|
2
|
-
export declare class LivekitConnectionInfo {
|
|
3
|
-
url: string;
|
|
4
|
-
token: string;
|
|
5
|
-
constructor({ url, token }: {
|
|
6
|
-
url: string;
|
|
7
|
-
token: string;
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
export declare class LivekitClient {
|
|
11
|
-
room: RoomClient;
|
|
12
|
-
constructor({ room }: {
|
|
13
|
-
room: RoomClient;
|
|
14
|
-
});
|
|
15
|
-
getConnectionInfo({ breakoutRoom }: {
|
|
16
|
-
breakoutRoom?: string;
|
|
17
|
-
}): Promise<LivekitConnectionInfo>;
|
|
18
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LivekitClient = exports.LivekitConnectionInfo = void 0;
|
|
4
|
-
const response_1 = require("./response");
|
|
5
|
-
const room_server_client_1 = require("./room-server-client");
|
|
6
|
-
class LivekitConnectionInfo {
|
|
7
|
-
constructor({ url, token }) {
|
|
8
|
-
this.url = url;
|
|
9
|
-
this.token = token;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.LivekitConnectionInfo = LivekitConnectionInfo;
|
|
13
|
-
class LivekitClient {
|
|
14
|
-
constructor({ room }) {
|
|
15
|
-
this.room = room;
|
|
16
|
-
}
|
|
17
|
-
async getConnectionInfo({ breakoutRoom }) {
|
|
18
|
-
const response = await this.room.invoke({
|
|
19
|
-
toolkit: 'livekit',
|
|
20
|
-
tool: 'connect',
|
|
21
|
-
input: { breakout_room: breakoutRoom ?? null },
|
|
22
|
-
});
|
|
23
|
-
if (!(response instanceof response_1.JsonContent)) {
|
|
24
|
-
throw new room_server_client_1.RoomServerException('unexpected return type from livekit.connect');
|
|
25
|
-
}
|
|
26
|
-
const { url, token } = response.json;
|
|
27
|
-
if (typeof url !== 'string' || typeof token !== 'string') {
|
|
28
|
-
throw new room_server_client_1.RoomServerException('unexpected return type from livekit.connect');
|
|
29
|
-
}
|
|
30
|
-
return new LivekitConnectionInfo({ url, token });
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.LivekitClient = LivekitClient;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ProtocolChannel } from './protocol';
|
|
2
|
-
import type { Room, RemoteParticipant } from 'livekit-client';
|
|
3
|
-
export type DataHandler = (data: Uint8Array) => void;
|
|
4
|
-
export type StartOptions = {
|
|
5
|
-
onDone?: () => void;
|
|
6
|
-
onError?: (error: unknown) => void;
|
|
7
|
-
};
|
|
8
|
-
export declare class LivekitProtocolChannel implements ProtocolChannel {
|
|
9
|
-
private room;
|
|
10
|
-
private remote;
|
|
11
|
-
private topic;
|
|
12
|
-
private onDataReceived?;
|
|
13
|
-
private boundOnData?;
|
|
14
|
-
constructor({ room, remote, topic }: {
|
|
15
|
-
room: Room;
|
|
16
|
-
remote: RemoteParticipant;
|
|
17
|
-
topic: string;
|
|
18
|
-
});
|
|
19
|
-
start(onDataReceived: (data: Uint8Array) => void, _opts?: StartOptions): void;
|
|
20
|
-
sendData(data: Uint8Array): Promise<void>;
|
|
21
|
-
dispose(): void;
|
|
22
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LivekitProtocolChannel = void 0;
|
|
4
|
-
const livekit_client_1 = require("livekit-client");
|
|
5
|
-
class LivekitProtocolChannel {
|
|
6
|
-
constructor({ room, remote, topic }) {
|
|
7
|
-
this.room = room;
|
|
8
|
-
this.remote = remote;
|
|
9
|
-
this.topic = topic;
|
|
10
|
-
}
|
|
11
|
-
start(onDataReceived, _opts) {
|
|
12
|
-
this.onDataReceived = onDataReceived;
|
|
13
|
-
this.boundOnData = (payload, participant, ...rest) => {
|
|
14
|
-
const identityMatches = participant?.identity === this.remote.identity;
|
|
15
|
-
const topicArg = rest?.[rest.length - 1] ?? undefined;
|
|
16
|
-
if (topicArg === this.topic && identityMatches) {
|
|
17
|
-
this.onDataReceived?.(payload);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
this.room.on(livekit_client_1.RoomEvent.DataReceived, this.boundOnData);
|
|
21
|
-
}
|
|
22
|
-
async sendData(data) {
|
|
23
|
-
await this.room.localParticipant.publishData(data, {
|
|
24
|
-
reliable: true,
|
|
25
|
-
topic: this.topic,
|
|
26
|
-
destinationIdentities: [this.remote.identity],
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
dispose() {
|
|
30
|
-
if (this.boundOnData) {
|
|
31
|
-
this.room.off(livekit_client_1.RoomEvent.DataReceived, this.boundOnData);
|
|
32
|
-
}
|
|
33
|
-
this.boundOnData = undefined;
|
|
34
|
-
this.onDataReceived = undefined;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.LivekitProtocolChannel = LivekitProtocolChannel;
|
package/dist/esm/lk-client.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { RoomClient } from './room-client';
|
|
2
|
-
export declare class LivekitConnectionInfo {
|
|
3
|
-
url: string;
|
|
4
|
-
token: string;
|
|
5
|
-
constructor({ url, token }: {
|
|
6
|
-
url: string;
|
|
7
|
-
token: string;
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
export declare class LivekitClient {
|
|
11
|
-
room: RoomClient;
|
|
12
|
-
constructor({ room }: {
|
|
13
|
-
room: RoomClient;
|
|
14
|
-
});
|
|
15
|
-
getConnectionInfo({ breakoutRoom }: {
|
|
16
|
-
breakoutRoom?: string;
|
|
17
|
-
}): Promise<LivekitConnectionInfo>;
|
|
18
|
-
}
|
package/dist/esm/lk-client.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LivekitClient = exports.LivekitConnectionInfo = void 0;
|
|
4
|
-
const response_1 = require("./response");
|
|
5
|
-
const room_server_client_1 = require("./room-server-client");
|
|
6
|
-
class LivekitConnectionInfo {
|
|
7
|
-
constructor({ url, token }) {
|
|
8
|
-
this.url = url;
|
|
9
|
-
this.token = token;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.LivekitConnectionInfo = LivekitConnectionInfo;
|
|
13
|
-
class LivekitClient {
|
|
14
|
-
constructor({ room }) {
|
|
15
|
-
this.room = room;
|
|
16
|
-
}
|
|
17
|
-
async getConnectionInfo({ breakoutRoom }) {
|
|
18
|
-
const response = await this.room.invoke({
|
|
19
|
-
toolkit: 'livekit',
|
|
20
|
-
tool: 'connect',
|
|
21
|
-
input: { breakout_room: breakoutRoom ?? null },
|
|
22
|
-
});
|
|
23
|
-
if (!(response instanceof response_1.JsonContent)) {
|
|
24
|
-
throw new room_server_client_1.RoomServerException('unexpected return type from livekit.connect');
|
|
25
|
-
}
|
|
26
|
-
const { url, token } = response.json;
|
|
27
|
-
if (typeof url !== 'string' || typeof token !== 'string') {
|
|
28
|
-
throw new room_server_client_1.RoomServerException('unexpected return type from livekit.connect');
|
|
29
|
-
}
|
|
30
|
-
return new LivekitConnectionInfo({ url, token });
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.LivekitClient = LivekitClient;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ProtocolChannel } from './protocol';
|
|
2
|
-
import type { Room, RemoteParticipant } from 'livekit-client';
|
|
3
|
-
export type DataHandler = (data: Uint8Array) => void;
|
|
4
|
-
export type StartOptions = {
|
|
5
|
-
onDone?: () => void;
|
|
6
|
-
onError?: (error: unknown) => void;
|
|
7
|
-
};
|
|
8
|
-
export declare class LivekitProtocolChannel implements ProtocolChannel {
|
|
9
|
-
private room;
|
|
10
|
-
private remote;
|
|
11
|
-
private topic;
|
|
12
|
-
private onDataReceived?;
|
|
13
|
-
private boundOnData?;
|
|
14
|
-
constructor({ room, remote, topic }: {
|
|
15
|
-
room: Room;
|
|
16
|
-
remote: RemoteParticipant;
|
|
17
|
-
topic: string;
|
|
18
|
-
});
|
|
19
|
-
start(onDataReceived: (data: Uint8Array) => void, _opts?: StartOptions): void;
|
|
20
|
-
sendData(data: Uint8Array): Promise<void>;
|
|
21
|
-
dispose(): void;
|
|
22
|
-
}
|
package/dist/esm/lk-protocol.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LivekitProtocolChannel = void 0;
|
|
4
|
-
const livekit_client_1 = require("livekit-client");
|
|
5
|
-
class LivekitProtocolChannel {
|
|
6
|
-
constructor({ room, remote, topic }) {
|
|
7
|
-
this.room = room;
|
|
8
|
-
this.remote = remote;
|
|
9
|
-
this.topic = topic;
|
|
10
|
-
}
|
|
11
|
-
start(onDataReceived, _opts) {
|
|
12
|
-
this.onDataReceived = onDataReceived;
|
|
13
|
-
this.boundOnData = (payload, participant, ...rest) => {
|
|
14
|
-
const identityMatches = participant?.identity === this.remote.identity;
|
|
15
|
-
const topicArg = rest?.[rest.length - 1] ?? undefined;
|
|
16
|
-
if (topicArg === this.topic && identityMatches) {
|
|
17
|
-
this.onDataReceived?.(payload);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
this.room.on(livekit_client_1.RoomEvent.DataReceived, this.boundOnData);
|
|
21
|
-
}
|
|
22
|
-
async sendData(data) {
|
|
23
|
-
await this.room.localParticipant.publishData(data, {
|
|
24
|
-
reliable: true,
|
|
25
|
-
topic: this.topic,
|
|
26
|
-
destinationIdentities: [this.remote.identity],
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
dispose() {
|
|
30
|
-
if (this.boundOnData) {
|
|
31
|
-
this.room.off(livekit_client_1.RoomEvent.DataReceived, this.boundOnData);
|
|
32
|
-
}
|
|
33
|
-
this.boundOnData = undefined;
|
|
34
|
-
this.onDataReceived = undefined;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.LivekitProtocolChannel = LivekitProtocolChannel;
|
package/dist/node/lk-client.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { RoomClient } from './room-client';
|
|
2
|
-
export declare class LivekitConnectionInfo {
|
|
3
|
-
url: string;
|
|
4
|
-
token: string;
|
|
5
|
-
constructor({ url, token }: {
|
|
6
|
-
url: string;
|
|
7
|
-
token: string;
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
export declare class LivekitClient {
|
|
11
|
-
room: RoomClient;
|
|
12
|
-
constructor({ room }: {
|
|
13
|
-
room: RoomClient;
|
|
14
|
-
});
|
|
15
|
-
getConnectionInfo({ breakoutRoom }: {
|
|
16
|
-
breakoutRoom?: string;
|
|
17
|
-
}): Promise<LivekitConnectionInfo>;
|
|
18
|
-
}
|
package/dist/node/lk-client.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LivekitClient = exports.LivekitConnectionInfo = void 0;
|
|
4
|
-
const response_1 = require("./response");
|
|
5
|
-
const room_server_client_1 = require("./room-server-client");
|
|
6
|
-
class LivekitConnectionInfo {
|
|
7
|
-
constructor({ url, token }) {
|
|
8
|
-
this.url = url;
|
|
9
|
-
this.token = token;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.LivekitConnectionInfo = LivekitConnectionInfo;
|
|
13
|
-
class LivekitClient {
|
|
14
|
-
constructor({ room }) {
|
|
15
|
-
this.room = room;
|
|
16
|
-
}
|
|
17
|
-
async getConnectionInfo({ breakoutRoom }) {
|
|
18
|
-
const response = await this.room.invoke({
|
|
19
|
-
toolkit: 'livekit',
|
|
20
|
-
tool: 'connect',
|
|
21
|
-
input: { breakout_room: breakoutRoom ?? null },
|
|
22
|
-
});
|
|
23
|
-
if (!(response instanceof response_1.JsonContent)) {
|
|
24
|
-
throw new room_server_client_1.RoomServerException('unexpected return type from livekit.connect');
|
|
25
|
-
}
|
|
26
|
-
const { url, token } = response.json;
|
|
27
|
-
if (typeof url !== 'string' || typeof token !== 'string') {
|
|
28
|
-
throw new room_server_client_1.RoomServerException('unexpected return type from livekit.connect');
|
|
29
|
-
}
|
|
30
|
-
return new LivekitConnectionInfo({ url, token });
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.LivekitClient = LivekitClient;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ProtocolChannel } from './protocol';
|
|
2
|
-
import type { Room, RemoteParticipant } from 'livekit-client';
|
|
3
|
-
export type DataHandler = (data: Uint8Array) => void;
|
|
4
|
-
export type StartOptions = {
|
|
5
|
-
onDone?: () => void;
|
|
6
|
-
onError?: (error: unknown) => void;
|
|
7
|
-
};
|
|
8
|
-
export declare class LivekitProtocolChannel implements ProtocolChannel {
|
|
9
|
-
private room;
|
|
10
|
-
private remote;
|
|
11
|
-
private topic;
|
|
12
|
-
private onDataReceived?;
|
|
13
|
-
private boundOnData?;
|
|
14
|
-
constructor({ room, remote, topic }: {
|
|
15
|
-
room: Room;
|
|
16
|
-
remote: RemoteParticipant;
|
|
17
|
-
topic: string;
|
|
18
|
-
});
|
|
19
|
-
start(onDataReceived: (data: Uint8Array) => void, _opts?: StartOptions): void;
|
|
20
|
-
sendData(data: Uint8Array): Promise<void>;
|
|
21
|
-
dispose(): void;
|
|
22
|
-
}
|
package/dist/node/lk-protocol.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LivekitProtocolChannel = void 0;
|
|
4
|
-
const livekit_client_1 = require("livekit-client");
|
|
5
|
-
class LivekitProtocolChannel {
|
|
6
|
-
constructor({ room, remote, topic }) {
|
|
7
|
-
this.room = room;
|
|
8
|
-
this.remote = remote;
|
|
9
|
-
this.topic = topic;
|
|
10
|
-
}
|
|
11
|
-
start(onDataReceived, _opts) {
|
|
12
|
-
this.onDataReceived = onDataReceived;
|
|
13
|
-
this.boundOnData = (payload, participant, ...rest) => {
|
|
14
|
-
const identityMatches = participant?.identity === this.remote.identity;
|
|
15
|
-
const topicArg = rest?.[rest.length - 1] ?? undefined;
|
|
16
|
-
if (topicArg === this.topic && identityMatches) {
|
|
17
|
-
this.onDataReceived?.(payload);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
this.room.on(livekit_client_1.RoomEvent.DataReceived, this.boundOnData);
|
|
21
|
-
}
|
|
22
|
-
async sendData(data) {
|
|
23
|
-
await this.room.localParticipant.publishData(data, {
|
|
24
|
-
reliable: true,
|
|
25
|
-
topic: this.topic,
|
|
26
|
-
destinationIdentities: [this.remote.identity],
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
dispose() {
|
|
30
|
-
if (this.boundOnData) {
|
|
31
|
-
this.room.off(livekit_client_1.RoomEvent.DataReceived, this.boundOnData);
|
|
32
|
-
}
|
|
33
|
-
this.boundOnData = undefined;
|
|
34
|
-
this.onDataReceived = undefined;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.LivekitProtocolChannel = LivekitProtocolChannel;
|