@meshagent/meshagent 0.42.2 → 0.43.1
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 +13 -0
- package/dist/browser/agent-client.d.ts +4 -4
- package/dist/browser/agent-client.js +16 -16
- package/dist/browser/agent.d.ts +6 -6
- package/dist/browser/agent.js +57 -57
- package/dist/browser/api_keys.js +7 -3
- package/dist/browser/containers-client.d.ts +3 -3
- package/dist/browser/containers-client.js +76 -76
- package/dist/browser/datasets-client.d.ts +1 -1
- package/dist/browser/datasets-client.js +83 -83
- package/dist/browser/developer-client.d.ts +3 -3
- package/dist/browser/developer-client.js +11 -11
- package/dist/browser/document.d.ts +2 -2
- package/dist/browser/document.js +3 -3
- package/dist/browser/helpers.d.ts +4 -4
- package/dist/browser/helpers.js +9 -9
- package/dist/browser/index.d.ts +35 -35
- package/dist/browser/index.js +35 -35
- package/dist/browser/memory-client.d.ts +1 -1
- package/dist/browser/memory-client.js +6 -6
- package/dist/browser/meshagent-client.d.ts +1 -1
- package/dist/browser/meshagent-client.js +78 -78
- package/dist/browser/messaging-client.d.ts +4 -4
- package/dist/browser/messaging-client.js +33 -33
- package/dist/browser/participant-token.d.ts +1 -1
- package/dist/browser/participant-token.js +5 -5
- package/dist/browser/participant.d.ts +1 -1
- package/dist/browser/protocol.d.ts +7 -4
- package/dist/browser/protocol.js +36 -20
- package/dist/browser/queues-client.d.ts +1 -1
- package/dist/browser/queues-client.js +10 -10
- package/dist/browser/response.js +11 -11
- package/dist/browser/room-client.d.ts +23 -17
- package/dist/browser/room-client.js +138 -130
- package/dist/browser/room-server-client.d.ts +2 -2
- package/dist/browser/room-server-client.js +10 -10
- package/dist/browser/secrets-client.d.ts +3 -3
- package/dist/browser/secrets-client.js +30 -30
- package/dist/browser/services-client.d.ts +2 -2
- package/dist/browser/services-client.js +8 -8
- package/dist/browser/storage-client.d.ts +5 -5
- package/dist/browser/storage-client.js +30 -30
- package/dist/browser/sync-client.d.ts +4 -4
- package/dist/browser/sync-client.js +38 -38
- package/dist/browser/toolkit-config.d.ts +3 -3
- package/dist/esm/agent-client.d.ts +4 -4
- package/dist/esm/agent-client.js +19 -25
- package/dist/esm/agent.d.ts +6 -6
- package/dist/esm/agent.js +73 -93
- package/dist/esm/api_keys.js +12 -21
- package/dist/esm/client.js +7 -13
- package/dist/esm/completer.js +1 -5
- package/dist/esm/containers-client.d.ts +3 -3
- package/dist/esm/containers-client.js +82 -87
- package/dist/esm/datasets-client.d.ts +1 -1
- package/dist/esm/datasets-client.js +101 -111
- package/dist/esm/developer-client.d.ts +3 -3
- package/dist/esm/developer-client.js +11 -15
- package/dist/esm/document.d.ts +2 -2
- package/dist/esm/document.js +11 -20
- package/dist/esm/entrypoint.js +1 -12
- package/dist/esm/event-emitter.js +1 -5
- package/dist/esm/helpers.d.ts +4 -4
- package/dist/esm/helpers.js +15 -23
- package/dist/esm/index.d.ts +35 -35
- package/dist/esm/index.js +35 -51
- package/dist/esm/memory-client.d.ts +1 -1
- package/dist/esm/memory-client.js +7 -11
- package/dist/esm/meshagent-client.d.ts +1 -1
- package/dist/esm/meshagent-client.js +79 -83
- package/dist/esm/messaging-client.d.ts +4 -4
- package/dist/esm/messaging-client.js +33 -37
- package/dist/esm/oauth-scopes.js +2 -5
- package/dist/esm/participant-token.d.ts +1 -1
- package/dist/esm/participant-token.js +34 -62
- package/dist/esm/participant.d.ts +1 -1
- package/dist/esm/participant.js +3 -9
- package/dist/esm/protocol.d.ts +7 -4
- package/dist/esm/protocol.js +48 -46
- package/dist/esm/queues-client.d.ts +1 -1
- package/dist/esm/queues-client.js +12 -17
- package/dist/esm/requirement.js +4 -11
- package/dist/esm/response.js +22 -34
- package/dist/esm/room-client.d.ts +23 -17
- package/dist/esm/room-client.js +140 -137
- package/dist/esm/room-event.js +9 -21
- package/dist/esm/room-server-client.d.ts +2 -2
- package/dist/esm/room-server-client.js +13 -18
- package/dist/esm/runtime.js +1 -10
- package/dist/esm/schema.js +9 -18
- package/dist/esm/secrets-client.d.ts +3 -3
- package/dist/esm/secrets-client.js +31 -35
- package/dist/esm/services-client.d.ts +2 -2
- package/dist/esm/services-client.js +9 -13
- package/dist/esm/storage-client.d.ts +5 -5
- package/dist/esm/storage-client.js +32 -38
- package/dist/esm/stream-controller.js +1 -5
- package/dist/esm/sync-client.d.ts +4 -4
- package/dist/esm/sync-client.js +38 -42
- package/dist/esm/tool-content-type.js +1 -5
- package/dist/esm/toolkit-config.d.ts +3 -3
- package/dist/esm/toolkit-config.js +5 -13
- package/dist/esm/utils.js +10 -20
- package/dist/esm/version.js +1 -4
- package/dist/node/agent-client.d.ts +4 -4
- package/dist/node/agent-client.js +16 -16
- package/dist/node/agent.d.ts +6 -6
- package/dist/node/agent.js +57 -57
- package/dist/node/api_keys.js +7 -3
- package/dist/node/containers-client.d.ts +3 -3
- package/dist/node/containers-client.js +76 -76
- package/dist/node/datasets-client.d.ts +1 -1
- package/dist/node/datasets-client.js +83 -83
- package/dist/node/developer-client.d.ts +3 -3
- package/dist/node/developer-client.js +11 -11
- package/dist/node/document.d.ts +2 -2
- package/dist/node/document.js +3 -3
- package/dist/node/helpers.d.ts +4 -4
- package/dist/node/helpers.js +9 -9
- package/dist/node/index.d.ts +35 -35
- package/dist/node/index.js +35 -35
- package/dist/node/memory-client.d.ts +1 -1
- package/dist/node/memory-client.js +6 -6
- package/dist/node/meshagent-client.d.ts +1 -1
- package/dist/node/meshagent-client.js +78 -78
- package/dist/node/messaging-client.d.ts +4 -4
- package/dist/node/messaging-client.js +33 -33
- package/dist/node/participant-token.d.ts +1 -1
- package/dist/node/participant-token.js +5 -5
- package/dist/node/participant.d.ts +1 -1
- package/dist/node/protocol.d.ts +7 -4
- package/dist/node/protocol.js +36 -20
- package/dist/node/queues-client.d.ts +1 -1
- package/dist/node/queues-client.js +10 -10
- package/dist/node/response.js +11 -11
- package/dist/node/room-client.d.ts +23 -17
- package/dist/node/room-client.js +138 -130
- package/dist/node/room-server-client.d.ts +2 -2
- package/dist/node/room-server-client.js +10 -10
- package/dist/node/secrets-client.d.ts +3 -3
- package/dist/node/secrets-client.js +30 -30
- package/dist/node/services-client.d.ts +2 -2
- package/dist/node/services-client.js +8 -8
- package/dist/node/storage-client.d.ts +5 -5
- package/dist/node/storage-client.js +30 -30
- package/dist/node/sync-client.d.ts +4 -4
- package/dist/node/sync-client.js +38 -38
- package/dist/node/toolkit-config.d.ts +3 -3
- package/package.json +11 -5
- package/dist/browser/lk-client.d.ts +0 -18
- package/dist/browser/lk-client.js +0 -33
- package/dist/browser/lk-protocol.d.ts +0 -22
- package/dist/browser/lk-protocol.js +0 -37
- package/dist/esm/lk-client.d.ts +0 -18
- package/dist/esm/lk-client.js +0 -33
- package/dist/esm/lk-protocol.d.ts +0 -22
- package/dist/esm/lk-protocol.js +0 -37
- package/dist/node/lk-client.d.ts +0 -18
- package/dist/node/lk-client.js +0 -33
- package/dist/node/lk-protocol.d.ts +0 -22
- package/dist/node/lk-protocol.js +0 -37
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContainersClient = exports.ExecSession = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
5
|
+
const completer_js_1 = require("./completer.js");
|
|
6
|
+
const response_js_1 = require("./response.js");
|
|
7
|
+
const room_server_client_js_1 = require("./room-server-client.js");
|
|
8
|
+
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
|
}
|
|
@@ -31,14 +31,14 @@ function toMountList(values) {
|
|
|
31
31
|
function readStringField(data, field, operation) {
|
|
32
32
|
const value = data[field];
|
|
33
33
|
if (typeof value !== "string") {
|
|
34
|
-
throw new
|
|
34
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
35
35
|
}
|
|
36
36
|
return value;
|
|
37
37
|
}
|
|
38
38
|
function readIntegerField(data, field, operation) {
|
|
39
39
|
const value = data[field];
|
|
40
40
|
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
41
|
-
throw new
|
|
41
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
42
42
|
}
|
|
43
43
|
return value;
|
|
44
44
|
}
|
|
@@ -48,7 +48,7 @@ function readOptionalIntegerField(data, field, operation) {
|
|
|
48
48
|
return undefined;
|
|
49
49
|
}
|
|
50
50
|
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
51
|
-
throw new
|
|
51
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
52
52
|
}
|
|
53
53
|
return value;
|
|
54
54
|
}
|
|
@@ -58,7 +58,7 @@ function readOptionalStringField(data, field, operation) {
|
|
|
58
58
|
return undefined;
|
|
59
59
|
}
|
|
60
60
|
if (typeof value !== "string") {
|
|
61
|
-
throw new
|
|
61
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
62
62
|
}
|
|
63
63
|
return value;
|
|
64
64
|
}
|
|
@@ -68,11 +68,11 @@ function parseTimestampField(data, field, operation) {
|
|
|
68
68
|
return undefined;
|
|
69
69
|
}
|
|
70
70
|
if (typeof value !== "string") {
|
|
71
|
-
throw new
|
|
71
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
72
72
|
}
|
|
73
73
|
const timestamp = new Date(value);
|
|
74
74
|
if (Number.isNaN(timestamp.getTime())) {
|
|
75
|
-
throw new
|
|
75
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
76
76
|
}
|
|
77
77
|
return timestamp;
|
|
78
78
|
}
|
|
@@ -81,7 +81,7 @@ function decodeUtf8(data, operation) {
|
|
|
81
81
|
return new TextDecoder("utf-8", { fatal: true }).decode(data);
|
|
82
82
|
}
|
|
83
83
|
catch {
|
|
84
|
-
throw new
|
|
84
|
+
throw new room_server_client_js_1.RoomServerException(`containers.${operation} returned invalid UTF-8 data`);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
function decodeJsonStatus(data, operation) {
|
|
@@ -91,14 +91,14 @@ function decodeJsonStatus(data, operation) {
|
|
|
91
91
|
parsed = JSON.parse(text);
|
|
92
92
|
}
|
|
93
93
|
catch {
|
|
94
|
-
throw new
|
|
94
|
+
throw new room_server_client_js_1.RoomServerException(`containers.${operation} returned an invalid status payload`);
|
|
95
95
|
}
|
|
96
96
|
if (!isRecord(parsed)) {
|
|
97
|
-
throw new
|
|
97
|
+
throw new room_server_client_js_1.RoomServerException(`containers.${operation} returned an invalid status payload`);
|
|
98
98
|
}
|
|
99
99
|
const status = parsed["status"];
|
|
100
100
|
if (typeof status !== "number" || !Number.isInteger(status)) {
|
|
101
|
-
throw new
|
|
101
|
+
throw new room_server_client_js_1.RoomServerException(`containers.${operation} returned an invalid status payload`);
|
|
102
102
|
}
|
|
103
103
|
return status;
|
|
104
104
|
}
|
|
@@ -107,12 +107,12 @@ function normalizeImageLabels(labelsRaw, operation) {
|
|
|
107
107
|
const labels = {};
|
|
108
108
|
for (const entry of labelsRaw) {
|
|
109
109
|
if (!isRecord(entry)) {
|
|
110
|
-
throw new
|
|
110
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
111
111
|
}
|
|
112
112
|
const key = entry["key"];
|
|
113
113
|
const value = entry["value"];
|
|
114
114
|
if (typeof key !== "string" || typeof value !== "string") {
|
|
115
|
-
throw new
|
|
115
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
116
116
|
}
|
|
117
117
|
labels[key] = value;
|
|
118
118
|
}
|
|
@@ -122,7 +122,7 @@ function normalizeImageLabels(labelsRaw, operation) {
|
|
|
122
122
|
const labels = {};
|
|
123
123
|
for (const [key, value] of Object.entries(labelsRaw)) {
|
|
124
124
|
if (typeof value !== "string") {
|
|
125
|
-
throw new
|
|
125
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
126
126
|
}
|
|
127
127
|
labels[key] = value;
|
|
128
128
|
}
|
|
@@ -131,14 +131,14 @@ function normalizeImageLabels(labelsRaw, operation) {
|
|
|
131
131
|
if (labelsRaw === undefined || labelsRaw === null) {
|
|
132
132
|
return {};
|
|
133
133
|
}
|
|
134
|
-
throw new
|
|
134
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
135
135
|
}
|
|
136
136
|
function normalizeImageReferences(entry, operation) {
|
|
137
137
|
const referencesRaw = entry["references"];
|
|
138
138
|
if (Array.isArray(referencesRaw)) {
|
|
139
139
|
const references = referencesRaw.filter((item) => typeof item === "string");
|
|
140
140
|
if (references.length !== referencesRaw.length) {
|
|
141
|
-
throw new
|
|
141
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
142
142
|
}
|
|
143
143
|
return references;
|
|
144
144
|
}
|
|
@@ -146,14 +146,14 @@ function normalizeImageReferences(entry, operation) {
|
|
|
146
146
|
if (Array.isArray(tagsRaw)) {
|
|
147
147
|
const references = tagsRaw.filter((item) => typeof item === "string");
|
|
148
148
|
if (references.length !== tagsRaw.length) {
|
|
149
|
-
throw new
|
|
149
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
150
150
|
}
|
|
151
151
|
return references;
|
|
152
152
|
}
|
|
153
153
|
if (referencesRaw === undefined || referencesRaw === null) {
|
|
154
154
|
return [];
|
|
155
155
|
}
|
|
156
|
-
throw new
|
|
156
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
157
157
|
}
|
|
158
158
|
function parseContainerImage(entry, operation) {
|
|
159
159
|
const references = normalizeImageReferences(entry, operation);
|
|
@@ -181,14 +181,14 @@ function parseOptionalContainerImageDescriptor(value, operation) {
|
|
|
181
181
|
return undefined;
|
|
182
182
|
}
|
|
183
183
|
if (!isRecord(value)) {
|
|
184
|
-
throw new
|
|
184
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
185
185
|
}
|
|
186
186
|
return parseContainerImageDescriptor(value, operation);
|
|
187
187
|
}
|
|
188
188
|
function parseContainerImageManifest(entry, operation) {
|
|
189
189
|
const descriptorRaw = entry["descriptor"];
|
|
190
190
|
if (!isRecord(descriptorRaw)) {
|
|
191
|
-
throw new
|
|
191
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
192
192
|
}
|
|
193
193
|
return {
|
|
194
194
|
descriptor: parseContainerImageDescriptor(descriptorRaw, operation),
|
|
@@ -203,7 +203,7 @@ function parseContainerImageInspection(entry, operation) {
|
|
|
203
203
|
const manifestsRaw = entry["manifests"];
|
|
204
204
|
const layersRaw = entry["layers"];
|
|
205
205
|
if (!isRecord(imageRaw) || !isRecord(targetRaw) || !Array.isArray(manifestsRaw) || !Array.isArray(layersRaw)) {
|
|
206
|
-
throw new
|
|
206
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
207
207
|
}
|
|
208
208
|
return {
|
|
209
209
|
image: parseContainerImage(imageRaw, operation),
|
|
@@ -211,14 +211,14 @@ function parseContainerImageInspection(entry, operation) {
|
|
|
211
211
|
selectedManifest: parseOptionalContainerImageDescriptor(entry["selected_manifest"], operation),
|
|
212
212
|
manifests: manifestsRaw.map((manifest) => {
|
|
213
213
|
if (!isRecord(manifest)) {
|
|
214
|
-
throw new
|
|
214
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
215
215
|
}
|
|
216
216
|
return parseContainerImageManifest(manifest, operation);
|
|
217
217
|
}),
|
|
218
218
|
config: parseOptionalContainerImageDescriptor(entry["config"], operation),
|
|
219
219
|
layers: layersRaw.map((layer) => {
|
|
220
220
|
if (!isRecord(layer)) {
|
|
221
|
-
throw new
|
|
221
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
222
222
|
}
|
|
223
223
|
return parseContainerImageDescriptor(layer, operation);
|
|
224
224
|
}),
|
|
@@ -229,7 +229,7 @@ function parseImportedImage(data, operation) {
|
|
|
229
229
|
const resolvedRef = data["resolved_ref"];
|
|
230
230
|
const refsRaw = data["refs"];
|
|
231
231
|
if (typeof resolvedRef !== "string" || !Array.isArray(refsRaw) || refsRaw.some((entry) => typeof entry !== "string")) {
|
|
232
|
-
throw new
|
|
232
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
233
233
|
}
|
|
234
234
|
return {
|
|
235
235
|
resolvedRef,
|
|
@@ -241,7 +241,7 @@ function parseBuildJob(data, operation) {
|
|
|
241
241
|
const tag = readStringField(data, "tag", operation);
|
|
242
242
|
const status = readStringField(data, "status", operation);
|
|
243
243
|
if (!["queued", "running", "failed", "cancelled", "succeeded"].includes(status)) {
|
|
244
|
-
throw new
|
|
244
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
245
245
|
}
|
|
246
246
|
return {
|
|
247
247
|
id,
|
|
@@ -253,9 +253,9 @@ function parseBuildJob(data, operation) {
|
|
|
253
253
|
async function* buildInputStream(params) {
|
|
254
254
|
const tags = params.tags ?? (params.tag === undefined ? [] : [params.tag]);
|
|
255
255
|
if (tags.length === 0) {
|
|
256
|
-
throw new
|
|
256
|
+
throw new room_server_client_js_1.RoomServerException("containers.build requires at least one tag");
|
|
257
257
|
}
|
|
258
|
-
yield new
|
|
258
|
+
yield new response_js_1.BinaryContent({
|
|
259
259
|
data: new Uint8Array(0),
|
|
260
260
|
headers: {
|
|
261
261
|
kind: "start",
|
|
@@ -271,7 +271,7 @@ async function* buildInputStream(params) {
|
|
|
271
271
|
},
|
|
272
272
|
});
|
|
273
273
|
for await (const chunk of params.chunks) {
|
|
274
|
-
yield new
|
|
274
|
+
yield new response_js_1.BinaryContent({
|
|
275
275
|
data: new Uint8Array(chunk),
|
|
276
276
|
headers: { kind: "data" },
|
|
277
277
|
});
|
|
@@ -281,9 +281,9 @@ class ExecSession {
|
|
|
281
281
|
constructor(params) {
|
|
282
282
|
this.previousOutput = [];
|
|
283
283
|
this.previousError = [];
|
|
284
|
-
this.resultCompleter = new
|
|
285
|
-
this.outputController = new
|
|
286
|
-
this.errorController = new
|
|
284
|
+
this.resultCompleter = new completer_js_1.Completer();
|
|
285
|
+
this.outputController = new stream_controller_js_1.StreamController();
|
|
286
|
+
this.errorController = new stream_controller_js_1.StreamController();
|
|
287
287
|
this.queuedInput = [];
|
|
288
288
|
this.inputClosed = false;
|
|
289
289
|
this.closed = false;
|
|
@@ -297,7 +297,7 @@ class ExecSession {
|
|
|
297
297
|
this.stderr = this.errorController.stream;
|
|
298
298
|
}
|
|
299
299
|
async *inputStream() {
|
|
300
|
-
yield new
|
|
300
|
+
yield new response_js_1.BinaryContent({
|
|
301
301
|
data: new Uint8Array(0),
|
|
302
302
|
headers: {
|
|
303
303
|
kind: "start",
|
|
@@ -317,7 +317,7 @@ class ExecSession {
|
|
|
317
317
|
if (this.inputClosed) {
|
|
318
318
|
return;
|
|
319
319
|
}
|
|
320
|
-
this.inputWaiter = new
|
|
320
|
+
this.inputWaiter = new completer_js_1.Completer();
|
|
321
321
|
await this.inputWaiter.fut;
|
|
322
322
|
this.inputWaiter = null;
|
|
323
323
|
}
|
|
@@ -373,9 +373,9 @@ class ExecSession {
|
|
|
373
373
|
}
|
|
374
374
|
queueInput(params) {
|
|
375
375
|
if (this.inputClosed) {
|
|
376
|
-
throw new
|
|
376
|
+
throw new room_server_client_js_1.RoomServerException("container exec session is already closed");
|
|
377
377
|
}
|
|
378
|
-
this.queuedInput.push(new
|
|
378
|
+
this.queuedInput.push(new response_js_1.BinaryContent({
|
|
379
379
|
data: params.data ?? new Uint8Array(0),
|
|
380
380
|
headers: {
|
|
381
381
|
kind: "input",
|
|
@@ -400,7 +400,7 @@ class ContainersClient {
|
|
|
400
400
|
this.room = room;
|
|
401
401
|
}
|
|
402
402
|
unexpectedResponseError(operation) {
|
|
403
|
-
return new
|
|
403
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
404
404
|
}
|
|
405
405
|
async invoke(operation, input) {
|
|
406
406
|
return await this.room.invoke({
|
|
@@ -411,7 +411,7 @@ class ContainersClient {
|
|
|
411
411
|
}
|
|
412
412
|
async listImages() {
|
|
413
413
|
const output = await this.invoke("list_images", {});
|
|
414
|
-
if (!(output instanceof
|
|
414
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
415
415
|
throw this.unexpectedResponseError("list_images");
|
|
416
416
|
}
|
|
417
417
|
const imagesRaw = output.json["images"];
|
|
@@ -431,7 +431,7 @@ class ContainersClient {
|
|
|
431
431
|
const output = await this.invoke("inspect_image", {
|
|
432
432
|
image_id: params.imageId,
|
|
433
433
|
});
|
|
434
|
-
if (!(output instanceof
|
|
434
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
435
435
|
throw this.unexpectedResponseError("inspect_image");
|
|
436
436
|
}
|
|
437
437
|
return parseContainerImageInspection(output.json, "inspect_image");
|
|
@@ -453,7 +453,7 @@ class ContainersClient {
|
|
|
453
453
|
credentials: toCredentials(params.credentials ?? []),
|
|
454
454
|
private: params.private ?? false,
|
|
455
455
|
});
|
|
456
|
-
if (!(output instanceof
|
|
456
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
457
457
|
throw this.unexpectedResponseError("push_image");
|
|
458
458
|
}
|
|
459
459
|
return readStringField(output.json, "container_id", "push_image");
|
|
@@ -462,7 +462,7 @@ class ContainersClient {
|
|
|
462
462
|
const output = await this.invoke("load", {
|
|
463
463
|
archive_path: params.archivePath,
|
|
464
464
|
});
|
|
465
|
-
if (!(output instanceof
|
|
465
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
466
466
|
throw this.unexpectedResponseError("load");
|
|
467
467
|
}
|
|
468
468
|
return parseImportedImage(output.json, "load");
|
|
@@ -473,7 +473,7 @@ class ContainersClient {
|
|
|
473
473
|
archive_path: params.archivePath,
|
|
474
474
|
private: params.private ?? false,
|
|
475
475
|
});
|
|
476
|
-
if (!(output instanceof
|
|
476
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
477
477
|
throw this.unexpectedResponseError("load_image");
|
|
478
478
|
}
|
|
479
479
|
return readStringField(output.json, "container_id", "load_image");
|
|
@@ -485,7 +485,7 @@ class ContainersClient {
|
|
|
485
485
|
archive_path: params.archivePath,
|
|
486
486
|
private: params.private ?? false,
|
|
487
487
|
});
|
|
488
|
-
if (!(output instanceof
|
|
488
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
489
489
|
throw this.unexpectedResponseError("save_image");
|
|
490
490
|
}
|
|
491
491
|
return readStringField(output.json, "container_id", "save_image");
|
|
@@ -508,7 +508,7 @@ class ContainersClient {
|
|
|
508
508
|
writable_root_fs: params.writableRootFs,
|
|
509
509
|
private: params.private,
|
|
510
510
|
});
|
|
511
|
-
if (!(output instanceof
|
|
511
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
512
512
|
throw this.unexpectedResponseError("run");
|
|
513
513
|
}
|
|
514
514
|
return readStringField(output.json, "container_id", "run");
|
|
@@ -519,14 +519,14 @@ class ContainersClient {
|
|
|
519
519
|
tool: "build",
|
|
520
520
|
input: buildInputStream(params),
|
|
521
521
|
});
|
|
522
|
-
if (!(output instanceof
|
|
522
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
523
523
|
throw this.unexpectedResponseError("build");
|
|
524
524
|
}
|
|
525
525
|
return readStringField(output.json, "build_id", "build");
|
|
526
526
|
}
|
|
527
527
|
async listBuilds() {
|
|
528
528
|
const output = await this.invoke("list_builds", {});
|
|
529
|
-
if (!(output instanceof
|
|
529
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
530
530
|
throw this.unexpectedResponseError("list_builds");
|
|
531
531
|
}
|
|
532
532
|
const buildsRaw = output.json["builds"];
|
|
@@ -555,7 +555,7 @@ class ContainersClient {
|
|
|
555
555
|
service_id: params.serviceId,
|
|
556
556
|
env: toStringMapList(params.env ?? {}),
|
|
557
557
|
});
|
|
558
|
-
if (!(output instanceof
|
|
558
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
559
559
|
throw this.unexpectedResponseError("run_service");
|
|
560
560
|
}
|
|
561
561
|
return readStringField(output.json, "container_id", "run_service");
|
|
@@ -576,21 +576,21 @@ class ContainersClient {
|
|
|
576
576
|
})
|
|
577
577
|
.then(async (stream) => {
|
|
578
578
|
for await (const chunk of stream) {
|
|
579
|
-
if (chunk instanceof
|
|
580
|
-
throw new
|
|
579
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
580
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
581
581
|
}
|
|
582
|
-
if (chunk instanceof
|
|
582
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
583
583
|
if (chunk.method === "close") {
|
|
584
584
|
break;
|
|
585
585
|
}
|
|
586
586
|
throw this.unexpectedResponseError("exec");
|
|
587
587
|
}
|
|
588
|
-
if (!(chunk instanceof
|
|
588
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
589
589
|
throw this.unexpectedResponseError("exec");
|
|
590
590
|
}
|
|
591
591
|
const channel = chunk.headers["channel"];
|
|
592
592
|
if (typeof channel !== "number") {
|
|
593
|
-
throw new
|
|
593
|
+
throw new room_server_client_js_1.RoomServerException("containers.exec returned a chunk without a valid channel");
|
|
594
594
|
}
|
|
595
595
|
if (channel === 1) {
|
|
596
596
|
session.addOutput(chunk.data);
|
|
@@ -605,7 +605,7 @@ class ContainersClient {
|
|
|
605
605
|
return;
|
|
606
606
|
}
|
|
607
607
|
}
|
|
608
|
-
throw new
|
|
608
|
+
throw new room_server_client_js_1.RoomServerException("containers.exec stream closed before a status was returned");
|
|
609
609
|
})
|
|
610
610
|
.catch((error) => {
|
|
611
611
|
session.closeError(error);
|
|
@@ -622,7 +622,7 @@ class ContainersClient {
|
|
|
622
622
|
const output = await this.invoke("wait_for_exit", {
|
|
623
623
|
container_id: params.containerId,
|
|
624
624
|
});
|
|
625
|
-
if (!(output instanceof
|
|
625
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
626
626
|
throw this.unexpectedResponseError("wait_for_exit");
|
|
627
627
|
}
|
|
628
628
|
const exitCode = readIntegerField(output.json, "exit_code", "wait_for_exit");
|
|
@@ -647,10 +647,10 @@ class ContainersClient {
|
|
|
647
647
|
}
|
|
648
648
|
logs(params) {
|
|
649
649
|
const requestId = (0, uuid_1.v4)();
|
|
650
|
-
const closeInput = new
|
|
651
|
-
const progressController = new
|
|
652
|
-
const streamController = new
|
|
653
|
-
const result = new
|
|
650
|
+
const closeInput = new completer_js_1.Completer();
|
|
651
|
+
const progressController = new stream_controller_js_1.StreamController();
|
|
652
|
+
const streamController = new stream_controller_js_1.StreamController();
|
|
653
|
+
const result = new completer_js_1.Completer();
|
|
654
654
|
let inputClosed = false;
|
|
655
655
|
const closeInputStream = () => {
|
|
656
656
|
if (inputClosed) {
|
|
@@ -662,7 +662,7 @@ class ContainersClient {
|
|
|
662
662
|
}
|
|
663
663
|
};
|
|
664
664
|
const inputStream = async function* () {
|
|
665
|
-
yield new
|
|
665
|
+
yield new response_js_1.BinaryContent({
|
|
666
666
|
data: new Uint8Array(0),
|
|
667
667
|
headers: {
|
|
668
668
|
kind: "start",
|
|
@@ -681,10 +681,10 @@ class ContainersClient {
|
|
|
681
681
|
})
|
|
682
682
|
.then(async (stream) => {
|
|
683
683
|
for await (const chunk of stream) {
|
|
684
|
-
if (chunk instanceof
|
|
685
|
-
throw new
|
|
684
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
685
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
686
686
|
}
|
|
687
|
-
if (chunk instanceof
|
|
687
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
688
688
|
if (chunk.method === "close") {
|
|
689
689
|
closeInputStream();
|
|
690
690
|
progressController.close();
|
|
@@ -696,12 +696,12 @@ class ContainersClient {
|
|
|
696
696
|
}
|
|
697
697
|
throw this.unexpectedResponseError("logs");
|
|
698
698
|
}
|
|
699
|
-
if (!(chunk instanceof
|
|
699
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
700
700
|
throw this.unexpectedResponseError("logs");
|
|
701
701
|
}
|
|
702
702
|
const channel = chunk.headers["channel"];
|
|
703
703
|
if (typeof channel !== "number") {
|
|
704
|
-
throw new
|
|
704
|
+
throw new room_server_client_js_1.RoomServerException("containers.logs returned a chunk without a valid channel");
|
|
705
705
|
}
|
|
706
706
|
if (channel !== 1) {
|
|
707
707
|
continue;
|
|
@@ -756,9 +756,9 @@ class ContainersClient {
|
|
|
756
756
|
}
|
|
757
757
|
getBuildLogs(params) {
|
|
758
758
|
const requestId = (0, uuid_1.v4)();
|
|
759
|
-
const closeInput = new
|
|
760
|
-
const streamController = new
|
|
761
|
-
const result = new
|
|
759
|
+
const closeInput = new completer_js_1.Completer();
|
|
760
|
+
const streamController = new stream_controller_js_1.StreamController();
|
|
761
|
+
const result = new completer_js_1.Completer();
|
|
762
762
|
let inputClosed = false;
|
|
763
763
|
const closeInputStream = () => {
|
|
764
764
|
if (inputClosed) {
|
|
@@ -770,7 +770,7 @@ class ContainersClient {
|
|
|
770
770
|
}
|
|
771
771
|
};
|
|
772
772
|
const inputStream = async function* () {
|
|
773
|
-
yield new
|
|
773
|
+
yield new response_js_1.BinaryContent({
|
|
774
774
|
data: new Uint8Array(0),
|
|
775
775
|
headers: {
|
|
776
776
|
kind: "start",
|
|
@@ -789,10 +789,10 @@ class ContainersClient {
|
|
|
789
789
|
})
|
|
790
790
|
.then(async (stream) => {
|
|
791
791
|
for await (const chunk of stream) {
|
|
792
|
-
if (chunk instanceof
|
|
793
|
-
throw new
|
|
792
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
793
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
794
794
|
}
|
|
795
|
-
if (chunk instanceof
|
|
795
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
796
796
|
if (chunk.method === "close") {
|
|
797
797
|
closeInputStream();
|
|
798
798
|
streamController.close();
|
|
@@ -803,12 +803,12 @@ class ContainersClient {
|
|
|
803
803
|
}
|
|
804
804
|
throw this.unexpectedResponseError("get_build_logs");
|
|
805
805
|
}
|
|
806
|
-
if (!(chunk instanceof
|
|
806
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
807
807
|
throw this.unexpectedResponseError("get_build_logs");
|
|
808
808
|
}
|
|
809
809
|
const channel = chunk.headers["channel"];
|
|
810
810
|
if (typeof channel !== "number") {
|
|
811
|
-
throw new
|
|
811
|
+
throw new room_server_client_js_1.RoomServerException("containers.get_build_logs returned a chunk without a valid channel");
|
|
812
812
|
}
|
|
813
813
|
if (channel === 1) {
|
|
814
814
|
streamController.add(decodeUtf8(chunk.data, "get_build_logs"));
|
|
@@ -870,7 +870,7 @@ class ContainersClient {
|
|
|
870
870
|
const output = await this.invoke("list_containers", {
|
|
871
871
|
all: params?.all,
|
|
872
872
|
});
|
|
873
|
-
if (!(output instanceof
|
|
873
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
874
874
|
throw this.unexpectedResponseError("list");
|
|
875
875
|
}
|
|
876
876
|
const containersRaw = output.json["containers"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema, Table } from "apache-arrow";
|
|
2
|
-
import { RoomClient } from "./room-client";
|
|
2
|
+
import { RoomClient } from "./room-client.js";
|
|
3
3
|
export type CreateMode = "create" | "overwrite" | "create_if_not_exists";
|
|
4
4
|
export type DatasetStorageFormat = "auto" | "json" | "arrow" | "csv" | "tsv" | "parquet" | "excel";
|
|
5
5
|
export type DatasetImportMode = "create" | "replace" | "merge";
|