@meshagent/meshagent 0.47.1 → 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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
+ ## [0.48.0]
2
+ - Reworked the TS/JS agent chat stack to preserve ordered threaded messages and support injected-message threads across chat clients and process handling.
3
+ - Added chat feed widgets and virtual scrolling to the React/Tailwind UI, improving large-thread performance.
4
+ - Aligned `meshagent-agents-ts` with the Dart agents implementation and refreshed the shared chat/message contracts.
5
+ - Removed the LiveKit dependency from the React package and updated shared package dependencies for the new chat stack.
6
+
1
7
  ## [0.47.1]
8
+ - Changed room mount discovery to return typed room/container consumers without exposing internal source paths, and added typed container mount specs to listed containers.
2
9
  - Added duplex messaging stream subscriptions and replay-state alignment in the TypeScript chat clients, bringing the NodeJS SDK in line with the new streaming model.
3
10
  - Reworked messaging and room client flow control so dispatch ordering, close behavior, and presence updates stay consistent under streaming loads.
4
11
  - Expanded stream and presence test coverage for the new messaging behavior.
@@ -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
  }
@@ -9,6 +9,38 @@ const stream_controller_js_1 = require("./stream-controller.js");
9
9
  function isRecord(value) {
10
10
  return typeof value === "object" && value !== null && !Array.isArray(value);
11
11
  }
12
+ function parseContainerMountSpec(value) {
13
+ if (value === undefined || value === null) {
14
+ return undefined;
15
+ }
16
+ if (!isRecord(value)) {
17
+ throw new room_server_client_js_1.RoomServerException("unexpected return type from containers.list");
18
+ }
19
+ const readMounts = (field, validate) => {
20
+ const raw = value[field];
21
+ if (raw === undefined || raw === null) {
22
+ return undefined;
23
+ }
24
+ if (!Array.isArray(raw) || !raw.every((mount) => isRecord(mount) && validate(mount))) {
25
+ throw new room_server_client_js_1.RoomServerException("unexpected return type from containers.list");
26
+ }
27
+ return raw;
28
+ };
29
+ const optionalMountFieldsAreValid = (mount) => (mount["subpath"] === undefined || mount["subpath"] === null || typeof mount["subpath"] === "string")
30
+ && (mount["read_only"] === undefined || typeof mount["read_only"] === "boolean");
31
+ return {
32
+ room: readMounts("room", (mount) => typeof mount["path"] === "string" && optionalMountFieldsAreValid(mount)),
33
+ volumes: readMounts("volumes", (mount) => typeof mount["name"] === "string"
34
+ && typeof mount["path"] === "string"
35
+ && optionalMountFieldsAreValid(mount)),
36
+ empty_dirs: readMounts("empty_dirs", (mount) => typeof mount["path"] === "string"
37
+ && (mount["read_only"] === undefined || typeof mount["read_only"] === "boolean")),
38
+ configs: readMounts("configs", (mount) => mount["path"] === undefined || mount["path"] === null || typeof mount["path"] === "string"),
39
+ files: readMounts("files", (mount) => typeof mount["path"] === "string"
40
+ && (mount["read_only"] === undefined || typeof mount["read_only"] === "boolean")
41
+ && (mount["text"] === undefined || mount["text"] === null || typeof mount["text"] === "string")),
42
+ };
43
+ }
12
44
  function toStringMapList(values) {
13
45
  return Object.entries(values).map(([key, value]) => ({ key, value }));
14
46
  }
@@ -904,6 +936,7 @@ class ContainersClient {
904
936
  const imageIdRaw = entry["image_id"];
905
937
  const portsRaw = entry["ports"];
906
938
  const serviceIdRaw = entry["service_id"];
939
+ const mountsRaw = entry["mounts"];
907
940
  const statsRaw = entry["stats"];
908
941
  const exitStatusRaw = entry["exit_status"];
909
942
  if (!Array.isArray(portsRaw) ||
@@ -964,6 +997,7 @@ class ContainersClient {
964
997
  state,
965
998
  private: privateFlag,
966
999
  serviceId: typeof serviceIdRaw === "string" ? serviceIdRaw : undefined,
1000
+ mounts: parseContainerMountSpec(mountsRaw),
967
1001
  stats,
968
1002
  exitStatus,
969
1003
  });
@@ -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;
@@ -3994,10 +3994,9 @@ var UndoManager = class extends ObservableV2 {
3994
3994
  this.emit("stack-item-updated", changeEvent);
3995
3995
  }
3996
3996
  };
3997
+ this.destroy = this.destroy.bind(this);
3997
3998
  this.doc.on("afterTransaction", this.afterTransactionHandler);
3998
- this.doc.on("destroy", () => {
3999
- this.destroy();
4000
- });
3999
+ this.doc.on("destroy", this.destroy);
4001
4000
  }
4002
4001
  /**
4003
4002
  * Extend the scope.
@@ -4114,6 +4113,7 @@ var UndoManager = class extends ObservableV2 {
4114
4113
  destroy() {
4115
4114
  this.trackedOrigins.delete(this);
4116
4115
  this.doc.off("afterTransaction", this.afterTransactionHandler);
4116
+ this.doc.off("destroy", this.destroy);
4117
4117
  super.destroy();
4118
4118
  }
4119
4119
  };
@@ -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';
@@ -26,6 +26,7 @@ __exportStar(require("./document.js"), exports);
26
26
  __exportStar(require("./meshagent-client.js"), exports);
27
27
  __exportStar(require("./messaging-client.js"), exports);
28
28
  __exportStar(require("./memory-client.js"), exports);
29
+ __exportStar(require("./mounts-client.js"), exports);
29
30
  __exportStar(require("./oauth-scopes.js"), exports);
30
31
  __exportStar(require("./participant-token.js"), exports);
31
32
  __exportStar(require("./participant.js"), exports);
@@ -235,6 +235,12 @@ export interface RoomStorageMountSpec {
235
235
  subpath?: string | null;
236
236
  read_only?: boolean;
237
237
  }
238
+ export interface VolumeStorageMountSpec {
239
+ name: string;
240
+ path: string;
241
+ subpath?: string | null;
242
+ read_only?: boolean;
243
+ }
238
244
  export interface EmptyDirMountSpec {
239
245
  path: string;
240
246
  read_only?: boolean;
@@ -249,6 +255,7 @@ export interface FileMountSpec {
249
255
  }
250
256
  export interface ContainerMountSpec {
251
257
  room?: RoomStorageMountSpec[];
258
+ volumes?: VolumeStorageMountSpec[];
252
259
  empty_dirs?: EmptyDirMountSpec[];
253
260
  configs?: ConfigMountSpec[];
254
261
  files?: FileMountSpec[];
@@ -0,0 +1,21 @@
1
+ import type { RoomClient } from "./room-client.js";
2
+ export interface MountedVolumeConsumer {
3
+ kind: "room" | "container";
4
+ containerId?: string;
5
+ }
6
+ export interface MountedVolume {
7
+ id: string;
8
+ name: string;
9
+ required: boolean;
10
+ description: string;
11
+ metadata: Record<string, unknown>;
12
+ annotations: Record<string, string>;
13
+ storageClass: "standard" | "juice" | "zerofs";
14
+ maxSizeMb?: number;
15
+ consumers: MountedVolumeConsumer[];
16
+ }
17
+ export declare class MountsClient {
18
+ private readonly room;
19
+ constructor(room: RoomClient);
20
+ list(): Promise<MountedVolume[]>;
21
+ }
@@ -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;
@@ -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;
@@ -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({
@@ -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';
@@ -235,6 +235,12 @@ export interface RoomStorageMountSpec {
235
235
  subpath?: string | null;
236
236
  read_only?: boolean;
237
237
  }
238
+ export interface VolumeStorageMountSpec {
239
+ name: string;
240
+ path: string;
241
+ subpath?: string | null;
242
+ read_only?: boolean;
243
+ }
238
244
  export interface EmptyDirMountSpec {
239
245
  path: string;
240
246
  read_only?: boolean;
@@ -249,6 +255,7 @@ export interface FileMountSpec {
249
255
  }
250
256
  export interface ContainerMountSpec {
251
257
  room?: RoomStorageMountSpec[];
258
+ volumes?: VolumeStorageMountSpec[];
252
259
  empty_dirs?: EmptyDirMountSpec[];
253
260
  configs?: ConfigMountSpec[];
254
261
  files?: FileMountSpec[];
@@ -0,0 +1,21 @@
1
+ import type { RoomClient } from "./room-client.js";
2
+ export interface MountedVolumeConsumer {
3
+ kind: "room" | "container";
4
+ containerId?: string;
5
+ }
6
+ export interface MountedVolume {
7
+ id: string;
8
+ name: string;
9
+ required: boolean;
10
+ description: string;
11
+ metadata: Record<string, unknown>;
12
+ annotations: Record<string, string>;
13
+ storageClass: "standard" | "juice" | "zerofs";
14
+ maxSizeMb?: number;
15
+ consumers: MountedVolumeConsumer[];
16
+ }
17
+ export declare class MountsClient {
18
+ private readonly room;
19
+ constructor(room: RoomClient);
20
+ list(): Promise<MountedVolume[]>;
21
+ }
@@ -0,0 +1,78 @@
1
+ import { JsonContent } from "./response.js";
2
+ import { RoomServerException } from "./room-server-client.js";
3
+ function isRecord(value) {
4
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5
+ }
6
+ function parseMountedVolume(value) {
7
+ if (!isRecord(value)
8
+ || typeof value["id"] !== "string"
9
+ || typeof value["name"] !== "string"
10
+ || typeof value["required"] !== "boolean") {
11
+ throw new RoomServerException("unexpected return type from mounts.list");
12
+ }
13
+ const metadata = isRecord(value["metadata"]) ? value["metadata"] : {};
14
+ const rawAnnotations = isRecord(value["annotations"]) ? value["annotations"] : {};
15
+ const annotations = {};
16
+ for (const [key, item] of Object.entries(rawAnnotations)) {
17
+ if (typeof item === "string") {
18
+ annotations[key] = item;
19
+ }
20
+ }
21
+ const rawConsumers = value["consumers"] ?? [];
22
+ if (!Array.isArray(rawConsumers)) {
23
+ throw new RoomServerException("unexpected return type from mounts.list");
24
+ }
25
+ const consumers = rawConsumers.map((consumer) => {
26
+ if (!isRecord(consumer)
27
+ || (consumer["kind"] !== "room" && consumer["kind"] !== "container")
28
+ || (consumer["kind"] === "container" && typeof consumer["container_id"] !== "string")
29
+ || (consumer["kind"] === "room" && consumer["container_id"] !== undefined)) {
30
+ throw new RoomServerException("unexpected return type from mounts.list");
31
+ }
32
+ return {
33
+ kind: consumer["kind"],
34
+ containerId: typeof consumer["container_id"] === "string"
35
+ ? consumer["container_id"]
36
+ : undefined,
37
+ };
38
+ });
39
+ const storageClass = value["storage_class"] ?? "standard";
40
+ if (storageClass !== "standard" && storageClass !== "juice" && storageClass !== "zerofs") {
41
+ throw new RoomServerException("unexpected return type from mounts.list");
42
+ }
43
+ const maxSizeMb = value["max_size_mb"];
44
+ if (maxSizeMb !== undefined && (typeof maxSizeMb !== "number" || !Number.isInteger(maxSizeMb) || maxSizeMb <= 0)) {
45
+ throw new RoomServerException("unexpected return type from mounts.list");
46
+ }
47
+ return {
48
+ id: value["id"],
49
+ name: value["name"],
50
+ required: value["required"],
51
+ description: typeof value["description"] === "string" ? value["description"] : "",
52
+ metadata,
53
+ annotations,
54
+ storageClass,
55
+ maxSizeMb,
56
+ consumers,
57
+ };
58
+ }
59
+ export class MountsClient {
60
+ constructor(room) {
61
+ this.room = room;
62
+ }
63
+ async list() {
64
+ const response = await this.room.invokeContent({
65
+ toolkit: "mounts",
66
+ tool: "list",
67
+ input: {},
68
+ });
69
+ if (!(response instanceof JsonContent)) {
70
+ throw new RoomServerException("unexpected return type from mounts.list");
71
+ }
72
+ const volumes = response.json["volumes"];
73
+ if (!Array.isArray(volumes)) {
74
+ throw new RoomServerException("unexpected return type from mounts.list");
75
+ }
76
+ return volumes.map(parseMountedVolume);
77
+ }
78
+ }
@@ -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;
@@ -5,6 +5,7 @@ import { DeveloperClient } from "./developer-client.js";
5
5
  import { EventEmitter } from "./event-emitter.js";
6
6
  import { MessagingClient } from "./messaging-client.js";
7
7
  import { MemoryClient } from "./memory-client.js";
8
+ import { MountsClient } from "./mounts-client.js";
8
9
  import { LocalParticipant } from "./participant.js";
9
10
  import { ProtocolCloseException, ProtocolCloseKind, ProtocolHandshakeException, ProtocolReconnectUnsupportedException, WebSocketClientProtocol, } from "./protocol.js";
10
11
  import { QueuesClient } from "./queues-client.js";
@@ -257,6 +258,7 @@ export class RoomClient {
257
258
  this.containers = new ContainersClient({ room: this });
258
259
  this.memory = new MemoryClient({ room: this });
259
260
  this.services = new ServicesClient({ room: this });
261
+ this.mounts = new MountsClient(this);
260
262
  }
261
263
  static withIAP({ url = "./.well-known/meshagent/room/connect", reconnectTimeout = null, } = {}) {
262
264
  return new RoomClient({
@@ -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
  }
@@ -9,6 +9,38 @@ const stream_controller_js_1 = require("./stream-controller.js");
9
9
  function isRecord(value) {
10
10
  return typeof value === "object" && value !== null && !Array.isArray(value);
11
11
  }
12
+ function parseContainerMountSpec(value) {
13
+ if (value === undefined || value === null) {
14
+ return undefined;
15
+ }
16
+ if (!isRecord(value)) {
17
+ throw new room_server_client_js_1.RoomServerException("unexpected return type from containers.list");
18
+ }
19
+ const readMounts = (field, validate) => {
20
+ const raw = value[field];
21
+ if (raw === undefined || raw === null) {
22
+ return undefined;
23
+ }
24
+ if (!Array.isArray(raw) || !raw.every((mount) => isRecord(mount) && validate(mount))) {
25
+ throw new room_server_client_js_1.RoomServerException("unexpected return type from containers.list");
26
+ }
27
+ return raw;
28
+ };
29
+ const optionalMountFieldsAreValid = (mount) => (mount["subpath"] === undefined || mount["subpath"] === null || typeof mount["subpath"] === "string")
30
+ && (mount["read_only"] === undefined || typeof mount["read_only"] === "boolean");
31
+ return {
32
+ room: readMounts("room", (mount) => typeof mount["path"] === "string" && optionalMountFieldsAreValid(mount)),
33
+ volumes: readMounts("volumes", (mount) => typeof mount["name"] === "string"
34
+ && typeof mount["path"] === "string"
35
+ && optionalMountFieldsAreValid(mount)),
36
+ empty_dirs: readMounts("empty_dirs", (mount) => typeof mount["path"] === "string"
37
+ && (mount["read_only"] === undefined || typeof mount["read_only"] === "boolean")),
38
+ configs: readMounts("configs", (mount) => mount["path"] === undefined || mount["path"] === null || typeof mount["path"] === "string"),
39
+ files: readMounts("files", (mount) => typeof mount["path"] === "string"
40
+ && (mount["read_only"] === undefined || typeof mount["read_only"] === "boolean")
41
+ && (mount["text"] === undefined || mount["text"] === null || typeof mount["text"] === "string")),
42
+ };
43
+ }
12
44
  function toStringMapList(values) {
13
45
  return Object.entries(values).map(([key, value]) => ({ key, value }));
14
46
  }
@@ -904,6 +936,7 @@ class ContainersClient {
904
936
  const imageIdRaw = entry["image_id"];
905
937
  const portsRaw = entry["ports"];
906
938
  const serviceIdRaw = entry["service_id"];
939
+ const mountsRaw = entry["mounts"];
907
940
  const statsRaw = entry["stats"];
908
941
  const exitStatusRaw = entry["exit_status"];
909
942
  if (!Array.isArray(portsRaw) ||
@@ -964,6 +997,7 @@ class ContainersClient {
964
997
  state,
965
998
  private: privateFlag,
966
999
  serviceId: typeof serviceIdRaw === "string" ? serviceIdRaw : undefined,
1000
+ mounts: parseContainerMountSpec(mountsRaw),
967
1001
  stats,
968
1002
  exitStatus,
969
1003
  });
@@ -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;
@@ -3038,10 +3038,9 @@ var UndoManager = class extends ObservableV2 {
3038
3038
  this.emit("stack-item-updated", changeEvent);
3039
3039
  }
3040
3040
  };
3041
+ this.destroy = this.destroy.bind(this);
3041
3042
  this.doc.on("afterTransaction", this.afterTransactionHandler);
3042
- this.doc.on("destroy", () => {
3043
- this.destroy();
3044
- });
3043
+ this.doc.on("destroy", this.destroy);
3045
3044
  }
3046
3045
  addToScope(ytypes) {
3047
3046
  const tmpSet = new Set(this.scope);
@@ -3110,6 +3109,7 @@ var UndoManager = class extends ObservableV2 {
3110
3109
  destroy() {
3111
3110
  this.trackedOrigins.delete(this);
3112
3111
  this.doc.off("afterTransaction", this.afterTransactionHandler);
3112
+ this.doc.off("destroy", this.destroy);
3113
3113
  super.destroy();
3114
3114
  }
3115
3115
  };
@@ -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';
@@ -26,6 +26,7 @@ __exportStar(require("./document.js"), exports);
26
26
  __exportStar(require("./meshagent-client.js"), exports);
27
27
  __exportStar(require("./messaging-client.js"), exports);
28
28
  __exportStar(require("./memory-client.js"), exports);
29
+ __exportStar(require("./mounts-client.js"), exports);
29
30
  __exportStar(require("./oauth-scopes.js"), exports);
30
31
  __exportStar(require("./participant-token.js"), exports);
31
32
  __exportStar(require("./participant.js"), exports);
@@ -235,6 +235,12 @@ export interface RoomStorageMountSpec {
235
235
  subpath?: string | null;
236
236
  read_only?: boolean;
237
237
  }
238
+ export interface VolumeStorageMountSpec {
239
+ name: string;
240
+ path: string;
241
+ subpath?: string | null;
242
+ read_only?: boolean;
243
+ }
238
244
  export interface EmptyDirMountSpec {
239
245
  path: string;
240
246
  read_only?: boolean;
@@ -249,6 +255,7 @@ export interface FileMountSpec {
249
255
  }
250
256
  export interface ContainerMountSpec {
251
257
  room?: RoomStorageMountSpec[];
258
+ volumes?: VolumeStorageMountSpec[];
252
259
  empty_dirs?: EmptyDirMountSpec[];
253
260
  configs?: ConfigMountSpec[];
254
261
  files?: FileMountSpec[];
@@ -0,0 +1,21 @@
1
+ import type { RoomClient } from "./room-client.js";
2
+ export interface MountedVolumeConsumer {
3
+ kind: "room" | "container";
4
+ containerId?: string;
5
+ }
6
+ export interface MountedVolume {
7
+ id: string;
8
+ name: string;
9
+ required: boolean;
10
+ description: string;
11
+ metadata: Record<string, unknown>;
12
+ annotations: Record<string, string>;
13
+ storageClass: "standard" | "juice" | "zerofs";
14
+ maxSizeMb?: number;
15
+ consumers: MountedVolumeConsumer[];
16
+ }
17
+ export declare class MountsClient {
18
+ private readonly room;
19
+ constructor(room: RoomClient);
20
+ list(): Promise<MountedVolume[]>;
21
+ }
@@ -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;
@@ -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;
@@ -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({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshagent/meshagent",
3
- "version": "0.47.1",
3
+ "version": "0.48.0",
4
4
  "description": "Meshagent Client",
5
5
  "homepage": "https://github.com/meshagent/meshagent-ts",
6
6
  "scripts": {