@meshagent/meshagent 0.47.1 → 0.49.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 +16 -0
- package/dist/browser/containers-client.d.ts +1 -0
- package/dist/browser/containers-client.js +34 -0
- package/dist/browser/entrypoint.d.ts +1 -0
- package/dist/browser/entrypoint.js +3 -3
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.js +1 -0
- package/dist/browser/meshagent-client.d.ts +37 -5
- package/dist/browser/meshagent-client.js +25 -7
- package/dist/browser/messaging-client.js +9 -2
- package/dist/browser/mounts-client.d.ts +21 -0
- package/dist/browser/mounts-client.js +82 -0
- package/dist/browser/room-client.d.ts +4 -0
- package/dist/browser/room-client.js +13 -3
- package/dist/esm/containers-client.d.ts +1 -0
- package/dist/esm/containers-client.js +34 -0
- package/dist/esm/entrypoint.d.ts +1 -0
- package/dist/esm/entrypoint.js +3 -3
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/meshagent-client.d.ts +37 -5
- package/dist/esm/meshagent-client.js +25 -7
- package/dist/esm/messaging-client.js +9 -2
- package/dist/esm/mounts-client.d.ts +21 -0
- package/dist/esm/mounts-client.js +78 -0
- package/dist/esm/room-client.d.ts +4 -0
- package/dist/esm/room-client.js +13 -3
- package/dist/node/containers-client.d.ts +1 -0
- package/dist/node/containers-client.js +34 -0
- package/dist/node/entrypoint.d.ts +1 -0
- package/dist/node/entrypoint.js +3 -3
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/meshagent-client.d.ts +37 -5
- package/dist/node/meshagent-client.js +25 -7
- package/dist/node/messaging-client.js +9 -2
- package/dist/node/mounts-client.d.ts +21 -0
- package/dist/node/mounts-client.js +82 -0
- package/dist/node/room-client.d.ts +4 -0
- package/dist/node/room-client.js +13 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
## [0.49.0]
|
|
2
|
+
- Breaking: `createProject` no longer accepts inline settings; project settings are now document-based with `room_roles` support.
|
|
3
|
+
- Route path models now use a service-port/content-target union and support CORS, compression, index, and IAP for room-content routes.
|
|
4
|
+
- `RoomRole` now includes `guest`, and missing project-settings documents return `undefined`.
|
|
5
|
+
|
|
6
|
+
## [0.48.1]
|
|
7
|
+
- Stability
|
|
8
|
+
- Added typed room-content route targets with subpath, CORS, index serving, IAP, and Brotli-by-default compression options.
|
|
9
|
+
|
|
10
|
+
## [0.48.0]
|
|
11
|
+
- Reworked the TS/JS agent chat stack to preserve ordered threaded messages and support injected-message threads across chat clients and process handling.
|
|
12
|
+
- Added chat feed widgets and virtual scrolling to the React/Tailwind UI, improving large-thread performance.
|
|
13
|
+
- Aligned `meshagent-agents-ts` with the Dart agents implementation and refreshed the shared chat/message contracts.
|
|
14
|
+
- Removed the LiveKit dependency from the React package and updated shared package dependencies for the new chat stack.
|
|
15
|
+
|
|
1
16
|
## [0.47.1]
|
|
17
|
+
- 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
18
|
- 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
19
|
- Reworked messaging and room client flow control so dispatch ordering, close behavior, and presence updates stay consistent under streaming loads.
|
|
4
20
|
- Expanded stream and presence test coverage for the new messaging behavior.
|
|
@@ -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
|
};
|
package/dist/browser/index.d.ts
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';
|
package/dist/browser/index.js
CHANGED
|
@@ -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);
|
|
@@ -1,7 +1,8 @@
|
|
|
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
|
+
export type RoomRole = "site_user" | "guest" | ResourceRole;
|
|
5
|
+
export type ProjectSettingsDocumentName = "openai" | "anthropic" | "otel" | "admission" | "room" | "room_roles";
|
|
5
6
|
export type FeedRole = "reader" | "subscriber" | "publisher" | "manager";
|
|
6
7
|
export type SecretRole = "use_proxy";
|
|
7
8
|
export type AccessRole = ProjectRole | RoomRole | FeedRole | SecretRole | "list";
|
|
@@ -235,6 +236,12 @@ export interface RoomStorageMountSpec {
|
|
|
235
236
|
subpath?: string | null;
|
|
236
237
|
read_only?: boolean;
|
|
237
238
|
}
|
|
239
|
+
export interface VolumeStorageMountSpec {
|
|
240
|
+
name: string;
|
|
241
|
+
path: string;
|
|
242
|
+
subpath?: string | null;
|
|
243
|
+
read_only?: boolean;
|
|
244
|
+
}
|
|
238
245
|
export interface EmptyDirMountSpec {
|
|
239
246
|
path: string;
|
|
240
247
|
read_only?: boolean;
|
|
@@ -249,6 +256,7 @@ export interface FileMountSpec {
|
|
|
249
256
|
}
|
|
250
257
|
export interface ContainerMountSpec {
|
|
251
258
|
room?: RoomStorageMountSpec[];
|
|
259
|
+
volumes?: VolumeStorageMountSpec[];
|
|
252
260
|
empty_dirs?: EmptyDirMountSpec[];
|
|
253
261
|
configs?: ConfigMountSpec[];
|
|
254
262
|
files?: FileMountSpec[];
|
|
@@ -418,12 +426,33 @@ export interface RouteBackend {
|
|
|
418
426
|
room?: RouteBackendTarget | null;
|
|
419
427
|
agent?: RouteBackendTarget | null;
|
|
420
428
|
}
|
|
421
|
-
export interface
|
|
429
|
+
export interface RouteCorsRule {
|
|
430
|
+
allowedOrigins: string[];
|
|
431
|
+
allowedMethods?: string[];
|
|
432
|
+
allowedHeaders?: string[];
|
|
433
|
+
exposeHeaders?: string[];
|
|
434
|
+
maxAgeSeconds?: number;
|
|
435
|
+
allowCredentials?: boolean;
|
|
436
|
+
}
|
|
437
|
+
export interface RouteContentSpec {
|
|
438
|
+
subpath?: string;
|
|
439
|
+
cors?: RouteCorsRule[];
|
|
440
|
+
index?: boolean;
|
|
441
|
+
iap?: boolean;
|
|
442
|
+
compression?: "brotli" | "gzip" | "none";
|
|
443
|
+
}
|
|
444
|
+
interface RoutePathBase {
|
|
422
445
|
path?: string;
|
|
423
446
|
pathType?: "prefix" | "exact";
|
|
424
447
|
stripPrefix?: boolean;
|
|
425
|
-
targetPort: string | number;
|
|
426
448
|
}
|
|
449
|
+
export type RoutePathSpec = RoutePathBase & ({
|
|
450
|
+
targetPort: string | number;
|
|
451
|
+
targetContent?: never;
|
|
452
|
+
} | {
|
|
453
|
+
targetContent: RouteContentSpec;
|
|
454
|
+
targetPort?: never;
|
|
455
|
+
});
|
|
427
456
|
export interface RouteSpec {
|
|
428
457
|
version: "v1";
|
|
429
458
|
kind: "Route";
|
|
@@ -577,14 +606,17 @@ export declare class Meshagent {
|
|
|
577
606
|
projectId: string;
|
|
578
607
|
path: string;
|
|
579
608
|
}): Promise<Uint8Array>;
|
|
580
|
-
createProject(name: string
|
|
609
|
+
createProject(name: string): Promise<Record<string, unknown>>;
|
|
581
610
|
addUserToProject(projectId: string, userId: string, options?: {
|
|
582
611
|
roles?: ProjectRole[];
|
|
583
612
|
email?: string;
|
|
584
613
|
inviteRedirectUrl?: string;
|
|
585
614
|
}): Promise<Record<string, unknown>>;
|
|
586
615
|
removeUserFromProject(projectId: string, userId: string): Promise<Record<string, unknown>>;
|
|
587
|
-
|
|
616
|
+
private projectSettingsDocumentPath;
|
|
617
|
+
getProjectSettingsDocument(projectId: string, name: ProjectSettingsDocumentName): Promise<Record<string, unknown> | undefined>;
|
|
618
|
+
setProjectSettingsDocument(projectId: string, name: ProjectSettingsDocumentName, document: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
619
|
+
deleteProjectSettingsDocument(projectId: string, name: ProjectSettingsDocumentName): Promise<Record<string, unknown>>;
|
|
588
620
|
updateUserInProject(projectId: string, userId: string, roles: ProjectRole[]): Promise<Record<string, unknown>>;
|
|
589
621
|
getUsersInProjectPage(projectId: string, options?: {
|
|
590
622
|
pageSize?: number;
|
|
@@ -250,7 +250,7 @@ class Meshagent {
|
|
|
250
250
|
return url.toString();
|
|
251
251
|
}
|
|
252
252
|
async request(path, options) {
|
|
253
|
-
const { method = "GET", query, json, body, headers, action, responseType = "json" } = options;
|
|
253
|
+
const { method = "GET", query, json, body, headers, action, responseType = "json", returnUndefinedOnNotFound = false } = options;
|
|
254
254
|
const url = this.buildUrl(path, query);
|
|
255
255
|
const finalHeaders = {};
|
|
256
256
|
if (this.token) {
|
|
@@ -279,6 +279,9 @@ class Meshagent {
|
|
|
279
279
|
headers: finalHeaders,
|
|
280
280
|
body: toFetchBody(requestBody),
|
|
281
281
|
});
|
|
282
|
+
if (response.status === 404 && returnUndefinedOnNotFound) {
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
282
285
|
if (!response.ok) {
|
|
283
286
|
let message;
|
|
284
287
|
try {
|
|
@@ -867,10 +870,10 @@ class Meshagent {
|
|
|
867
870
|
responseType: "arrayBuffer",
|
|
868
871
|
});
|
|
869
872
|
}
|
|
870
|
-
async createProject(name
|
|
873
|
+
async createProject(name) {
|
|
871
874
|
return await this.request(`/accounts/projects`, {
|
|
872
875
|
method: "POST",
|
|
873
|
-
json: { name
|
|
876
|
+
json: { name },
|
|
874
877
|
action: "create project",
|
|
875
878
|
});
|
|
876
879
|
}
|
|
@@ -894,11 +897,26 @@ class Meshagent {
|
|
|
894
897
|
action: "remove user from project",
|
|
895
898
|
});
|
|
896
899
|
}
|
|
897
|
-
|
|
898
|
-
return
|
|
900
|
+
projectSettingsDocumentPath(name) {
|
|
901
|
+
return name === "room_roles" ? "room-roles" : name;
|
|
902
|
+
}
|
|
903
|
+
async getProjectSettingsDocument(projectId, name) {
|
|
904
|
+
return await this.request(`/accounts/projects/${projectId}/settings/${this.projectSettingsDocumentPath(name)}`, {
|
|
905
|
+
action: `get ${name} project settings`,
|
|
906
|
+
returnUndefinedOnNotFound: true,
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
async setProjectSettingsDocument(projectId, name, document) {
|
|
910
|
+
return await this.request(`/accounts/projects/${projectId}/settings/${this.projectSettingsDocumentPath(name)}`, {
|
|
899
911
|
method: "PUT",
|
|
900
|
-
json:
|
|
901
|
-
action:
|
|
912
|
+
json: document,
|
|
913
|
+
action: `set ${name} project settings`,
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
async deleteProjectSettingsDocument(projectId, name) {
|
|
917
|
+
return await this.request(`/accounts/projects/${projectId}/settings/${this.projectSettingsDocumentPath(name)}`, {
|
|
918
|
+
method: "DELETE",
|
|
919
|
+
action: `delete ${name} project settings`,
|
|
902
920
|
});
|
|
903
921
|
}
|
|
904
922
|
async updateUserInProject(projectId, userId, roles) {
|
|
@@ -693,8 +693,15 @@ class MessagingClient extends event_emitter_js_1.EventEmitter {
|
|
|
693
693
|
break;
|
|
694
694
|
}
|
|
695
695
|
const event = new room_event_js_1.RoomMessageEvent({ message });
|
|
696
|
-
|
|
697
|
-
|
|
696
|
+
try {
|
|
697
|
+
this.client.emit(event);
|
|
698
|
+
this.emit("message", event);
|
|
699
|
+
}
|
|
700
|
+
finally {
|
|
701
|
+
if (message.type === "dismiss") {
|
|
702
|
+
this.client._dismiss();
|
|
703
|
+
}
|
|
704
|
+
}
|
|
698
705
|
}
|
|
699
706
|
_onParticipantEnabled(message) {
|
|
700
707
|
const data = message.message;
|
|
@@ -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;
|
|
@@ -76,6 +78,7 @@ export declare class RoomClient {
|
|
|
76
78
|
private _localParticipantReady;
|
|
77
79
|
private _connected;
|
|
78
80
|
private _closing;
|
|
81
|
+
private _dismissed;
|
|
79
82
|
private _localParticipant;
|
|
80
83
|
private _lifecycleTask;
|
|
81
84
|
private _terminalState;
|
|
@@ -167,6 +170,7 @@ export declare class RoomClient {
|
|
|
167
170
|
private _retryProtocolConnection;
|
|
168
171
|
private _reconnect;
|
|
169
172
|
private _connectionLifecycle;
|
|
173
|
+
_dismiss(): void;
|
|
170
174
|
dispose(): void;
|
|
171
175
|
_sendProtocolNowait({ type, data, label, messageId, expectResponse, }: {
|
|
172
176
|
type: string;
|
|
@@ -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");
|
|
@@ -224,6 +225,7 @@ class RoomClient {
|
|
|
224
225
|
this._localParticipantReady = new completer_js_1.Completer();
|
|
225
226
|
this._connected = false;
|
|
226
227
|
this._closing = false;
|
|
228
|
+
this._dismissed = false;
|
|
227
229
|
this._localParticipant = null;
|
|
228
230
|
this._lifecycleTask = null;
|
|
229
231
|
this._terminalState = null;
|
|
@@ -261,6 +263,7 @@ class RoomClient {
|
|
|
261
263
|
this.containers = new containers_client_js_1.ContainersClient({ room: this });
|
|
262
264
|
this.memory = new memory_client_js_1.MemoryClient({ room: this });
|
|
263
265
|
this.services = new services_client_js_1.ServicesClient({ room: this });
|
|
266
|
+
this.mounts = new mounts_client_js_1.MountsClient(this);
|
|
264
267
|
}
|
|
265
268
|
static withIAP({ url = "./.well-known/meshagent/room/connect", reconnectTimeout = null, } = {}) {
|
|
266
269
|
return new RoomClient({
|
|
@@ -880,7 +883,7 @@ class RoomClient {
|
|
|
880
883
|
const deadline = this._reconnectTimeout == null ? null : Date.now() + this._reconnectTimeout;
|
|
881
884
|
let firstAttempt = true;
|
|
882
885
|
let retryCount = 0;
|
|
883
|
-
while (!this._closing) {
|
|
886
|
+
while (!this._closing && !this._dismissed) {
|
|
884
887
|
if (firstAttempt) {
|
|
885
888
|
firstAttempt = false;
|
|
886
889
|
if (this._reconnectTimeout == null) {
|
|
@@ -1011,7 +1014,7 @@ class RoomClient {
|
|
|
1011
1014
|
this._completeRoomClosed();
|
|
1012
1015
|
return;
|
|
1013
1016
|
}
|
|
1014
|
-
if (closeKind !== protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
1017
|
+
if (closeKind !== protocol_js_1.ProtocolCloseKind.ERROR || this._dismissed) {
|
|
1015
1018
|
this._setTerminalState({ state });
|
|
1016
1019
|
}
|
|
1017
1020
|
this._markDisconnected({ reason: closeReason, kind: closeKind });
|
|
@@ -1023,7 +1026,7 @@ class RoomClient {
|
|
|
1023
1026
|
this.messaging._onRoomDisconnect({ reason: closeReason });
|
|
1024
1027
|
await this._failPendingWork({ state });
|
|
1025
1028
|
await this._closeProtocol(protocol);
|
|
1026
|
-
if (closeKind === protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
1029
|
+
if (closeKind === protocol_js_1.ProtocolCloseKind.ERROR && !this._dismissed) {
|
|
1027
1030
|
if (this._reconnectTimeout === 0) {
|
|
1028
1031
|
if (closeReason == null) {
|
|
1029
1032
|
console.warn("room connection lost; automatic reconnect disabled");
|
|
@@ -1052,6 +1055,13 @@ class RoomClient {
|
|
|
1052
1055
|
return;
|
|
1053
1056
|
}
|
|
1054
1057
|
}
|
|
1058
|
+
_dismiss() {
|
|
1059
|
+
if (this._closing || this._dismissed) {
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
this._dismissed = true;
|
|
1063
|
+
this._protocolInstance.dispose();
|
|
1064
|
+
}
|
|
1055
1065
|
dispose() {
|
|
1056
1066
|
this._closing = true;
|
|
1057
1067
|
this._markDisconnected({
|
|
@@ -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
|
});
|
package/dist/esm/entrypoint.d.ts
CHANGED
|
@@ -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;
|
package/dist/esm/entrypoint.js
CHANGED
|
@@ -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
|
};
|
package/dist/esm/index.d.ts
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';
|
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';
|