@meshagent/meshagent 0.47.0 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/browser/agent.js +6 -6
  3. package/dist/browser/containers-client.d.ts +1 -0
  4. package/dist/browser/containers-client.js +34 -0
  5. package/dist/browser/entrypoint.d.ts +1 -0
  6. package/dist/browser/entrypoint.js +3 -3
  7. package/dist/browser/index.d.ts +1 -0
  8. package/dist/browser/index.js +1 -0
  9. package/dist/browser/meshagent-client.d.ts +9 -1
  10. package/dist/browser/meshagent-client.js +1 -0
  11. package/dist/browser/messaging-client.d.ts +72 -1
  12. package/dist/browser/messaging-client.js +302 -1
  13. package/dist/browser/mounts-client.d.ts +21 -0
  14. package/dist/browser/mounts-client.js +82 -0
  15. package/dist/browser/participant-token.d.ts +1 -0
  16. package/dist/browser/participant-token.js +3 -0
  17. package/dist/browser/room-client.d.ts +4 -1
  18. package/dist/browser/room-client.js +27 -12
  19. package/dist/esm/agent.js +6 -6
  20. package/dist/esm/containers-client.d.ts +1 -0
  21. package/dist/esm/containers-client.js +34 -0
  22. package/dist/esm/entrypoint.d.ts +1 -0
  23. package/dist/esm/entrypoint.js +3 -3
  24. package/dist/esm/index.d.ts +1 -0
  25. package/dist/esm/index.js +1 -0
  26. package/dist/esm/meshagent-client.d.ts +9 -1
  27. package/dist/esm/meshagent-client.js +1 -0
  28. package/dist/esm/messaging-client.d.ts +72 -1
  29. package/dist/esm/messaging-client.js +301 -1
  30. package/dist/esm/mounts-client.d.ts +21 -0
  31. package/dist/esm/mounts-client.js +78 -0
  32. package/dist/esm/participant-token.d.ts +1 -0
  33. package/dist/esm/participant-token.js +3 -0
  34. package/dist/esm/room-client.d.ts +4 -1
  35. package/dist/esm/room-client.js +27 -12
  36. package/dist/node/agent.js +6 -6
  37. package/dist/node/containers-client.d.ts +1 -0
  38. package/dist/node/containers-client.js +34 -0
  39. package/dist/node/entrypoint.d.ts +1 -0
  40. package/dist/node/entrypoint.js +3 -3
  41. package/dist/node/index.d.ts +1 -0
  42. package/dist/node/index.js +1 -0
  43. package/dist/node/meshagent-client.d.ts +9 -1
  44. package/dist/node/meshagent-client.js +1 -0
  45. package/dist/node/messaging-client.d.ts +72 -1
  46. package/dist/node/messaging-client.js +302 -1
  47. package/dist/node/mounts-client.d.ts +21 -0
  48. package/dist/node/mounts-client.js +82 -0
  49. package/dist/node/participant-token.d.ts +1 -0
  50. package/dist/node/participant-token.js +3 -0
  51. package/dist/node/room-client.d.ts +4 -1
  52. package/dist/node/room-client.js +27 -12
  53. package/package.json +1 -1
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MountsClient = void 0;
4
+ const response_js_1 = require("./response.js");
5
+ const room_server_client_js_1 = require("./room-server-client.js");
6
+ function isRecord(value) {
7
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8
+ }
9
+ function parseMountedVolume(value) {
10
+ if (!isRecord(value)
11
+ || typeof value["id"] !== "string"
12
+ || typeof value["name"] !== "string"
13
+ || typeof value["required"] !== "boolean") {
14
+ throw new room_server_client_js_1.RoomServerException("unexpected return type from mounts.list");
15
+ }
16
+ const metadata = isRecord(value["metadata"]) ? value["metadata"] : {};
17
+ const rawAnnotations = isRecord(value["annotations"]) ? value["annotations"] : {};
18
+ const annotations = {};
19
+ for (const [key, item] of Object.entries(rawAnnotations)) {
20
+ if (typeof item === "string") {
21
+ annotations[key] = item;
22
+ }
23
+ }
24
+ const rawConsumers = value["consumers"] ?? [];
25
+ if (!Array.isArray(rawConsumers)) {
26
+ throw new room_server_client_js_1.RoomServerException("unexpected return type from mounts.list");
27
+ }
28
+ const consumers = rawConsumers.map((consumer) => {
29
+ if (!isRecord(consumer)
30
+ || (consumer["kind"] !== "room" && consumer["kind"] !== "container")
31
+ || (consumer["kind"] === "container" && typeof consumer["container_id"] !== "string")
32
+ || (consumer["kind"] === "room" && consumer["container_id"] !== undefined)) {
33
+ throw new room_server_client_js_1.RoomServerException("unexpected return type from mounts.list");
34
+ }
35
+ return {
36
+ kind: consumer["kind"],
37
+ containerId: typeof consumer["container_id"] === "string"
38
+ ? consumer["container_id"]
39
+ : undefined,
40
+ };
41
+ });
42
+ const storageClass = value["storage_class"] ?? "standard";
43
+ if (storageClass !== "standard" && storageClass !== "juice" && storageClass !== "zerofs") {
44
+ throw new room_server_client_js_1.RoomServerException("unexpected return type from mounts.list");
45
+ }
46
+ const maxSizeMb = value["max_size_mb"];
47
+ if (maxSizeMb !== undefined && (typeof maxSizeMb !== "number" || !Number.isInteger(maxSizeMb) || maxSizeMb <= 0)) {
48
+ throw new room_server_client_js_1.RoomServerException("unexpected return type from mounts.list");
49
+ }
50
+ return {
51
+ id: value["id"],
52
+ name: value["name"],
53
+ required: value["required"],
54
+ description: typeof value["description"] === "string" ? value["description"] : "",
55
+ metadata,
56
+ annotations,
57
+ storageClass,
58
+ maxSizeMb,
59
+ consumers,
60
+ };
61
+ }
62
+ class MountsClient {
63
+ constructor(room) {
64
+ this.room = room;
65
+ }
66
+ async list() {
67
+ const response = await this.room.invokeContent({
68
+ toolkit: "mounts",
69
+ tool: "list",
70
+ input: {},
71
+ });
72
+ if (!(response instanceof response_js_1.JsonContent)) {
73
+ throw new room_server_client_js_1.RoomServerException("unexpected return type from mounts.list");
74
+ }
75
+ const volumes = response.json["volumes"];
76
+ if (!Array.isArray(volumes)) {
77
+ throw new room_server_client_js_1.RoomServerException("unexpected return type from mounts.list");
78
+ }
79
+ return volumes.map(parseMountedVolume);
80
+ }
81
+ }
82
+ exports.MountsClient = MountsClient;
@@ -404,6 +404,7 @@ export declare class ParticipantToken {
404
404
  addTunnelGrant(ports: number[]): void;
405
405
  addRoleGrant(role: string): void;
406
406
  addRoomGrant(roomName: string): void;
407
+ addSiteGrant(roomName: string): void;
407
408
  addApiGrant(grant: ApiScope): void;
408
409
  grantScope(name: string): string | ApiScope | undefined;
409
410
  getApiGrant(): ApiScope | undefined;
@@ -1323,6 +1323,9 @@ class ParticipantToken {
1323
1323
  addRoomGrant(roomName) {
1324
1324
  this.grants.push(new ParticipantGrant({ name: "room", scope: roomName }));
1325
1325
  }
1326
+ addSiteGrant(roomName) {
1327
+ this.grants.push(new ParticipantGrant({ name: "site", scope: roomName }));
1328
+ }
1326
1329
  addApiGrant(grant) {
1327
1330
  for (const existingGrant of this.grants) {
1328
1331
  if (existingGrant.name === "api") {
@@ -4,6 +4,7 @@ import { DeveloperClient } from "./developer-client.js";
4
4
  import { type EventHandler, type EventName } from "./event-emitter.js";
5
5
  import { MessagingClient } from "./messaging-client.js";
6
6
  import { MemoryClient } from "./memory-client.js";
7
+ import { MountsClient } from "./mounts-client.js";
7
8
  import { LocalParticipant } from "./participant.js";
8
9
  import { Protocol, ProtocolCloseKind, type MessageHandler, type ProtocolFactory } from "./protocol.js";
9
10
  import { QueuesClient } from "./queues-client.js";
@@ -59,6 +60,7 @@ export declare class RoomClient {
59
60
  readonly containers: ContainersClient;
60
61
  readonly memory: MemoryClient;
61
62
  readonly services: ServicesClient;
63
+ readonly mounts: MountsClient;
62
64
  _protocolInstance: Protocol;
63
65
  _entered: boolean;
64
66
  _allowDisconnectedRequests: boolean;
@@ -190,6 +192,7 @@ export declare class RoomClient {
190
192
  _sendLocalAttributesNowait(attributes: Record<string, unknown>): void;
191
193
  _resendLocalAttributesNowait(): void;
192
194
  sendRequest(type: string, request: RequestHeader, data?: Uint8Array, afterSend?: () => void): Promise<Content>;
195
+ private _dispatchRequest;
193
196
  call(params: {
194
197
  name: string;
195
198
  url: string;
@@ -249,7 +252,7 @@ export declare class RoomClient {
249
252
  participantId?: string;
250
253
  onBehalfOfId?: string;
251
254
  }): Promise<AsyncIterable<Content>>;
252
- private _sendToolCallRequestChunk;
255
+ private _dispatchToolCallRequestChunk;
253
256
  private _streamInvokeToolRequestChunks;
254
257
  private _decodeToolCallContent;
255
258
  private _handleToolCallResponseChunk;
@@ -8,6 +8,7 @@ const developer_client_js_1 = require("./developer-client.js");
8
8
  const event_emitter_js_1 = require("./event-emitter.js");
9
9
  const messaging_client_js_1 = require("./messaging-client.js");
10
10
  const memory_client_js_1 = require("./memory-client.js");
11
+ const mounts_client_js_1 = require("./mounts-client.js");
11
12
  const participant_js_1 = require("./participant.js");
12
13
  const protocol_js_1 = require("./protocol.js");
13
14
  const queues_client_js_1 = require("./queues-client.js");
@@ -261,6 +262,7 @@ class RoomClient {
261
262
  this.containers = new containers_client_js_1.ContainersClient({ room: this });
262
263
  this.memory = new memory_client_js_1.MemoryClient({ room: this });
263
264
  this.services = new services_client_js_1.ServicesClient({ room: this });
265
+ this.mounts = new mounts_client_js_1.MountsClient(this);
264
266
  }
265
267
  static withIAP({ url = "./.well-known/meshagent/room/connect", reconnectTimeout = null, } = {}) {
266
268
  return new RoomClient({
@@ -1147,6 +1149,11 @@ class RoomClient {
1147
1149
  this._sendLocalAttributesNowait(attributes);
1148
1150
  }
1149
1151
  async sendRequest(type, request, data, afterSend) {
1152
+ const response = this._dispatchRequest(type, request, data);
1153
+ afterSend?.();
1154
+ return await response;
1155
+ }
1156
+ _dispatchRequest(type, request, data) {
1150
1157
  this._raiseIfTerminal();
1151
1158
  if (this._entered && !this._connected && !this._allowDisconnectedRequests) {
1152
1159
  throw this._disconnectedError({ baseMessage: "room connection is disconnected" });
@@ -1155,9 +1162,8 @@ class RoomClient {
1155
1162
  const completer = new completer_js_1.Completer();
1156
1163
  this._pendingRequests.set(requestId, completer);
1157
1164
  try {
1158
- await this._protocolInstance.send(type, (0, utils_js_1.packMessage)(request, data), requestId);
1159
- afterSend?.();
1160
- return await completer.fut;
1165
+ this._protocolInstance.sendNowait(type, (0, utils_js_1.packMessage)(request, data), { id: requestId });
1166
+ return completer.fut;
1161
1167
  }
1162
1168
  catch (error) {
1163
1169
  this._pendingRequests.delete(requestId);
@@ -1263,7 +1269,6 @@ class RoomClient {
1263
1269
  let requestTask;
1264
1270
  if (params.streamInput === true) {
1265
1271
  request["arguments"] = { type: "control", method: "open" };
1266
- requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
1267
1272
  }
1268
1273
  else {
1269
1274
  const input = params.input;
@@ -1280,9 +1285,14 @@ class RoomClient {
1280
1285
  if (params.onBehalfOfId != null) {
1281
1286
  request["on_behalf_of_id"] = params.onBehalfOfId;
1282
1287
  }
1288
+ const responseRequest = this._dispatchRequest("room.invoke_tool", request, requestData);
1289
+ params.afterSend?.();
1290
+ if (params.streamInput === true) {
1291
+ requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
1292
+ }
1283
1293
  try {
1284
1294
  const response = await Promise.race([
1285
- this.sendRequest("room.invoke_tool", request, requestData, params.afterSend),
1295
+ responseRequest,
1286
1296
  preOpenError.fut,
1287
1297
  ]);
1288
1298
  this._toolCallPreOpenErrors.delete(toolCallId);
@@ -1337,9 +1347,10 @@ class RoomClient {
1337
1347
  if (params.onBehalfOfId != null) {
1338
1348
  request["on_behalf_of_id"] = params.onBehalfOfId;
1339
1349
  }
1350
+ const responseRequest = this._dispatchRequest("room.invoke_tool", request);
1340
1351
  const requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
1341
1352
  try {
1342
- const response = await this.sendRequest("room.invoke_tool", request);
1353
+ const response = await responseRequest;
1343
1354
  await requestTask;
1344
1355
  if (response instanceof response_js_1.ControlContent && response.method === "open") {
1345
1356
  throw new room_server_client_js_1.RoomServerException(`unexpected return type from ${params.toolkit}.${params.tool}`);
@@ -1370,6 +1381,7 @@ class RoomClient {
1370
1381
  if (params.onBehalfOfId != null) {
1371
1382
  request["on_behalf_of_id"] = params.onBehalfOfId;
1372
1383
  }
1384
+ const responseRequest = this._dispatchRequest("room.invoke_tool", request);
1373
1385
  const requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
1374
1386
  void requestTask.catch((error) => {
1375
1387
  const stream = this._toolCallStreams.get(toolCallId);
@@ -1383,7 +1395,7 @@ class RoomClient {
1383
1395
  let response;
1384
1396
  try {
1385
1397
  response = await Promise.race([
1386
- this.sendRequest("room.invoke_tool", request),
1398
+ responseRequest,
1387
1399
  preOpenError.fut,
1388
1400
  ]);
1389
1401
  }
@@ -1405,24 +1417,27 @@ class RoomClient {
1405
1417
  },
1406
1418
  };
1407
1419
  }
1408
- async _sendToolCallRequestChunk(toolCallId, chunk) {
1420
+ _dispatchToolCallRequestChunk(toolCallId, chunk) {
1421
+ this._raiseIfTerminal();
1422
+ if (this._entered && !this._connected && !this._allowDisconnectedRequests) {
1423
+ throw this._disconnectedError({ baseMessage: "room connection is disconnected" });
1424
+ }
1409
1425
  const packed = chunk.pack();
1410
1426
  const request = {
1411
1427
  tool_call_id: toolCallId,
1412
1428
  chunk: JSON.parse((0, utils_js_1.splitMessageHeader)(packed)),
1413
1429
  };
1414
1430
  const payload = (0, utils_js_1.splitMessagePayload)(packed);
1415
- await this.sendRequest("room.tool_call_request_chunk", request, payload.length > 0 ? payload : undefined);
1431
+ this._protocolInstance.sendNowait("room.tool_call_request_chunk", (0, utils_js_1.packMessage)(request, payload.length > 0 ? payload : undefined));
1416
1432
  }
1417
1433
  async _streamInvokeToolRequestChunks(toolCallId, input) {
1418
- await Promise.resolve();
1419
1434
  try {
1420
1435
  for await (const item of input) {
1421
- await this._sendToolCallRequestChunk(toolCallId, item);
1436
+ this._dispatchToolCallRequestChunk(toolCallId, item);
1422
1437
  }
1423
1438
  }
1424
1439
  finally {
1425
- await this._sendToolCallRequestChunk(toolCallId, new response_js_1.ControlContent({ method: "close" }));
1440
+ this._dispatchToolCallRequestChunk(toolCallId, new response_js_1.ControlContent({ method: "close" }));
1426
1441
  }
1427
1442
  }
1428
1443
  _decodeToolCallContent(params) {
package/dist/esm/agent.js CHANGED
@@ -511,10 +511,10 @@ class _RemoteToolkitWrapper {
511
511
  return false;
512
512
  }
513
513
  }
514
- async _sendToolCallResponseChunk(messageId, toolCallId, chunk) {
514
+ _sendToolCallResponseChunk(messageId, toolCallId, chunk) {
515
515
  const [header, payload] = unpackMessage(chunk.pack());
516
516
  try {
517
- await this.client.protocol.send("room.tool_call_response_chunk", packMessage({ tool_call_id: toolCallId, chunk: header }, payload.length > 0 ? payload : undefined), { id: messageId });
517
+ this.client.protocol.sendNowait("room.tool_call_response_chunk", packMessage({ tool_call_id: toolCallId, chunk: header }, payload.length > 0 ? payload : undefined), { id: messageId });
518
518
  return true;
519
519
  }
520
520
  catch (error) {
@@ -615,10 +615,10 @@ class _RemoteToolkitWrapper {
615
615
  return;
616
616
  for await (const chunk of output.stream) {
617
617
  this.toolkit.validateOutputContent(tool, chunk);
618
- if (!await this._sendToolCallResponseChunk(messageId, toolCallId, chunk))
618
+ if (!this._sendToolCallResponseChunk(messageId, toolCallId, chunk))
619
619
  return;
620
620
  }
621
- await this._sendToolCallResponseChunk(messageId, toolCallId, new ControlContent({ method: "close" }));
621
+ this._sendToolCallResponseChunk(messageId, toolCallId, new ControlContent({ method: "close" }));
622
622
  return;
623
623
  }
624
624
  throw new Error(`tool ${toolName} returned unsupported output`);
@@ -629,9 +629,9 @@ class _RemoteToolkitWrapper {
629
629
  return;
630
630
  }
631
631
  if (!(error instanceof InvalidToolDataException)) {
632
- await this._sendToolCallResponseChunk(messageId, toolCallId, new ErrorContent({ text: String(error) }));
632
+ this._sendToolCallResponseChunk(messageId, toolCallId, new ErrorContent({ text: String(error) }));
633
633
  }
634
- await this._sendToolCallResponseChunk(messageId, toolCallId, new ControlContent({
634
+ this._sendToolCallResponseChunk(messageId, toolCallId, new ControlContent({
635
635
  method: "close",
636
636
  statusCode: error instanceof InvalidToolDataException ? ControlCloseStatus.INVALID_DATA : undefined,
637
637
  message: error instanceof InvalidToolDataException ? error.message : undefined,
@@ -72,6 +72,7 @@ export interface RoomContainer {
72
72
  state: string;
73
73
  private: boolean;
74
74
  serviceId?: string;
75
+ mounts?: ContainerMountSpec;
75
76
  stats?: RoomContainerStats;
76
77
  exitStatus?: ContainerExitStatus;
77
78
  }
@@ -6,6 +6,38 @@ import { StreamController } from "./stream-controller.js";
6
6
  function isRecord(value) {
7
7
  return typeof value === "object" && value !== null && !Array.isArray(value);
8
8
  }
9
+ function parseContainerMountSpec(value) {
10
+ if (value === undefined || value === null) {
11
+ return undefined;
12
+ }
13
+ if (!isRecord(value)) {
14
+ throw new RoomServerException("unexpected return type from containers.list");
15
+ }
16
+ const readMounts = (field, validate) => {
17
+ const raw = value[field];
18
+ if (raw === undefined || raw === null) {
19
+ return undefined;
20
+ }
21
+ if (!Array.isArray(raw) || !raw.every((mount) => isRecord(mount) && validate(mount))) {
22
+ throw new RoomServerException("unexpected return type from containers.list");
23
+ }
24
+ return raw;
25
+ };
26
+ const optionalMountFieldsAreValid = (mount) => (mount["subpath"] === undefined || mount["subpath"] === null || typeof mount["subpath"] === "string")
27
+ && (mount["read_only"] === undefined || typeof mount["read_only"] === "boolean");
28
+ return {
29
+ room: readMounts("room", (mount) => typeof mount["path"] === "string" && optionalMountFieldsAreValid(mount)),
30
+ volumes: readMounts("volumes", (mount) => typeof mount["name"] === "string"
31
+ && typeof mount["path"] === "string"
32
+ && optionalMountFieldsAreValid(mount)),
33
+ empty_dirs: readMounts("empty_dirs", (mount) => typeof mount["path"] === "string"
34
+ && (mount["read_only"] === undefined || typeof mount["read_only"] === "boolean")),
35
+ configs: readMounts("configs", (mount) => mount["path"] === undefined || mount["path"] === null || typeof mount["path"] === "string"),
36
+ files: readMounts("files", (mount) => typeof mount["path"] === "string"
37
+ && (mount["read_only"] === undefined || typeof mount["read_only"] === "boolean")
38
+ && (mount["text"] === undefined || mount["text"] === null || typeof mount["text"] === "string")),
39
+ };
40
+ }
9
41
  function toStringMapList(values) {
10
42
  return Object.entries(values).map(([key, value]) => ({ key, value }));
11
43
  }
@@ -900,6 +932,7 @@ export class ContainersClient {
900
932
  const imageIdRaw = entry["image_id"];
901
933
  const portsRaw = entry["ports"];
902
934
  const serviceIdRaw = entry["service_id"];
935
+ const mountsRaw = entry["mounts"];
903
936
  const statsRaw = entry["stats"];
904
937
  const exitStatusRaw = entry["exit_status"];
905
938
  if (!Array.isArray(portsRaw) ||
@@ -960,6 +993,7 @@ export class ContainersClient {
960
993
  state,
961
994
  private: privateFlag,
962
995
  serviceId: typeof serviceIdRaw === "string" ? serviceIdRaw : undefined,
996
+ mounts: parseContainerMountSpec(mountsRaw),
963
997
  stats,
964
998
  exitStatus,
965
999
  });
@@ -16,6 +16,7 @@ export var ServerXmlDocument: {
16
16
  ignoreRemoteMapChanges: UndoManagerOptions;
17
17
  captureTimeout: UndoManagerOptions;
18
18
  afterTransactionHandler: (transaction: any) => void;
19
+ destroy(): void;
19
20
  addToScope(ytypes: Array<any | {
20
21
  gc: DocOpts;
21
22
  gcFilter: DocOpts;
@@ -3027,10 +3027,9 @@ var UndoManager = class extends ObservableV2 {
3027
3027
  this.emit("stack-item-updated", changeEvent);
3028
3028
  }
3029
3029
  };
3030
+ this.destroy = this.destroy.bind(this);
3030
3031
  this.doc.on("afterTransaction", this.afterTransactionHandler);
3031
- this.doc.on("destroy", () => {
3032
- this.destroy();
3033
- });
3032
+ this.doc.on("destroy", this.destroy);
3034
3033
  }
3035
3034
  addToScope(ytypes) {
3036
3035
  const tmpSet = new Set(this.scope);
@@ -3099,6 +3098,7 @@ var UndoManager = class extends ObservableV2 {
3099
3098
  destroy() {
3100
3099
  this.trackedOrigins.delete(this);
3101
3100
  this.doc.off("afterTransaction", this.afterTransactionHandler);
3101
+ this.doc.off("destroy", this.destroy);
3102
3102
  super.destroy();
3103
3103
  }
3104
3104
  };
@@ -10,6 +10,7 @@ export * from './document.js';
10
10
  export * from './meshagent-client.js';
11
11
  export * from './messaging-client.js';
12
12
  export * from './memory-client.js';
13
+ export * from './mounts-client.js';
13
14
  export * from './oauth-scopes.js';
14
15
  export * from './participant-token.js';
15
16
  export * from './participant.js';
package/dist/esm/index.js CHANGED
@@ -10,6 +10,7 @@ export * from './document.js';
10
10
  export * from './meshagent-client.js';
11
11
  export * from './messaging-client.js';
12
12
  export * from './memory-client.js';
13
+ export * from './mounts-client.js';
13
14
  export * from './oauth-scopes.js';
14
15
  export * from './participant-token.js';
15
16
  export * from './participant.js';
@@ -1,9 +1,10 @@
1
1
  import { ApiScope } from "./participant-token.js";
2
2
  export type ProjectRole = "member" | "admin" | "developer" | "room_creator" | "room_inventory" | "room_manager" | "session_inventory" | "agent_creator" | "agent_inventory" | "agent_manager" | "repository_creator" | "repository_inventory" | "repository_manager" | "feed_creator" | "feed_inventory" | "feed_manager" | "oauth_client_creator" | "oauth_client_inventory" | "oauth_client_manager" | "api_key_creator" | "api_key_inventory" | "api_key_manager" | "service_creator" | "service_inventory" | "service_manager" | "service_account_creator" | "service_account_inventory" | "service_account_manager" | "participant_token_creator" | "mailbox_creator" | "mailbox_inventory" | "mailbox_manager" | "route_creator" | "route_inventory" | "route_manager" | "scheduled_task_creator" | "scheduled_task_inventory" | "scheduled_task_manager" | "feed_subscription_creator" | "feed_subscription_inventory" | "feed_subscription_manager" | "llm_logger_creator" | "llm_logger_inventory" | "llm_logger_manager" | "llm_proxy_user" | "usage_reporter" | "billing_manager" | "group_manager";
3
3
  export type ResourceRole = "viewer" | "operator" | "developer" | "admin";
4
+ export type RoomRole = "site_user" | ResourceRole;
4
5
  export type FeedRole = "reader" | "subscriber" | "publisher" | "manager";
5
6
  export type SecretRole = "use_proxy";
6
- export type AccessRole = ProjectRole | ResourceRole | FeedRole | SecretRole | "list";
7
+ export type AccessRole = ProjectRole | RoomRole | FeedRole | SecretRole | "list";
7
8
  export type AccessSubjectType = "user" | "group" | "agent" | "service_account" | "userset";
8
9
  export type AccessResourceType = "project" | "room" | "agent" | "group" | "repository" | "feed" | "secret";
9
10
  export interface AccessSubject {
@@ -234,6 +235,12 @@ export interface RoomStorageMountSpec {
234
235
  subpath?: string | null;
235
236
  read_only?: boolean;
236
237
  }
238
+ export interface VolumeStorageMountSpec {
239
+ name: string;
240
+ path: string;
241
+ subpath?: string | null;
242
+ read_only?: boolean;
243
+ }
237
244
  export interface EmptyDirMountSpec {
238
245
  path: string;
239
246
  read_only?: boolean;
@@ -248,6 +255,7 @@ export interface FileMountSpec {
248
255
  }
249
256
  export interface ContainerMountSpec {
250
257
  room?: RoomStorageMountSpec[];
258
+ volumes?: VolumeStorageMountSpec[];
251
259
  empty_dirs?: EmptyDirMountSpec[];
252
260
  configs?: ConfigMountSpec[];
253
261
  files?: FileMountSpec[];
@@ -654,6 +654,7 @@ export class Meshagent {
654
654
  const parsedSubject = this.parseAccessSubject(data.subject);
655
655
  const parsedDirectRoles = Array.isArray(data.direct_roles)
656
656
  ? data.direct_roles.filter((item) => item === "member" ||
657
+ item === "site_user" ||
657
658
  item === "viewer" ||
658
659
  item === "operator" ||
659
660
  item === "developer" ||
@@ -1,8 +1,72 @@
1
1
  import { EventEmitter } from "./event-emitter.js";
2
2
  import { Participant, RemoteParticipant } from "./participant.js";
3
+ import { Content } from "./response.js";
3
4
  import { RoomClient } from "./room-client.js";
4
- import { RoomMessageEvent } from "./room-event.js";
5
+ import { RoomMessage, RoomMessageEvent } from "./room-event.js";
5
6
  type MessagePayload = Record<string, unknown>;
7
+ export type MessagingStreamEvent = {
8
+ kind: "message";
9
+ message: RoomMessage;
10
+ } | {
11
+ kind: "client_disconnected";
12
+ streamId: string;
13
+ participantId: string;
14
+ } | {
15
+ kind: "closed";
16
+ streamId: string;
17
+ reason: string;
18
+ message?: string;
19
+ };
20
+ declare class MessagingStreamInput {
21
+ private readonly items;
22
+ private signal;
23
+ private active;
24
+ private closed;
25
+ private error;
26
+ enqueue(content: Content, { wait }?: {
27
+ wait?: boolean;
28
+ }): Promise<void>;
29
+ close(error?: unknown): void;
30
+ fail(error: unknown): void;
31
+ stream(): AsyncIterable<Content>;
32
+ }
33
+ export declare class MessagingStream implements AsyncIterable<MessagingStreamEvent> {
34
+ readonly streamId: string;
35
+ readonly remoteParticipantId: string;
36
+ private readonly input;
37
+ private readonly output;
38
+ private readonly inputDone;
39
+ private readonly onClosed;
40
+ private readonly events;
41
+ private eventSignal;
42
+ private state;
43
+ constructor({ streamId, remoteParticipantId, input, output, inputClosed, onClosed, }: {
44
+ streamId: string;
45
+ remoteParticipantId: string;
46
+ input: MessagingStreamInput;
47
+ output: AsyncIterator<Content>;
48
+ inputClosed?: Promise<void>;
49
+ onClosed: () => void;
50
+ });
51
+ get closed(): boolean;
52
+ private push;
53
+ private finish;
54
+ private consumeOutput;
55
+ private content;
56
+ sendMessageNowait(params: {
57
+ type: string;
58
+ message: MessagePayload;
59
+ attachment?: Uint8Array;
60
+ }): void;
61
+ sendMessage(params: {
62
+ type: string;
63
+ message: MessagePayload;
64
+ attachment?: Uint8Array;
65
+ }): Promise<void>;
66
+ close(): Promise<void>;
67
+ clientDisconnected(participantId: string): void;
68
+ [Symbol.asyncIterator](): AsyncIterator<MessagingStreamEvent>;
69
+ }
6
70
  export declare class MessagingClient extends EventEmitter<RoomMessageEvent> {
7
71
  private readonly client;
8
72
  private readonly _messageHandler;
@@ -11,6 +75,7 @@ export declare class MessagingClient extends EventEmitter<RoomMessageEvent> {
11
75
  private _messageQueued;
12
76
  private _sendTask;
13
77
  private readonly _sendOperations;
78
+ private readonly _streams;
14
79
  private _messageQueueClosed;
15
80
  private _desiredEnabled;
16
81
  private _online;
@@ -64,6 +129,12 @@ export declare class MessagingClient extends EventEmitter<RoomMessageEvent> {
64
129
  message: MessagePayload;
65
130
  attachment?: Uint8Array;
66
131
  }): Promise<void>;
132
+ stream({ to, type, message, attachment, }: {
133
+ to: Participant;
134
+ type: string;
135
+ message: MessagePayload;
136
+ attachment?: Uint8Array;
137
+ }): Promise<MessagingStream>;
67
138
  getParticipants(): RemoteParticipant[];
68
139
  getParticipant(id: string): RemoteParticipant | null;
69
140
  getParticipantByName(name: string): RemoteParticipant | null;