@meshagent/meshagent 0.42.2 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/browser/agent-client.d.ts +4 -4
- package/dist/browser/agent-client.js +16 -16
- package/dist/browser/agent.d.ts +6 -6
- package/dist/browser/agent.js +57 -57
- package/dist/browser/api_keys.js +7 -3
- package/dist/browser/containers-client.d.ts +3 -3
- package/dist/browser/containers-client.js +76 -76
- package/dist/browser/datasets-client.d.ts +1 -1
- package/dist/browser/datasets-client.js +83 -83
- package/dist/browser/developer-client.d.ts +3 -3
- package/dist/browser/developer-client.js +11 -11
- package/dist/browser/document.d.ts +2 -2
- package/dist/browser/document.js +3 -3
- package/dist/browser/helpers.d.ts +4 -4
- package/dist/browser/helpers.js +9 -9
- package/dist/browser/index.d.ts +35 -35
- package/dist/browser/index.js +35 -35
- package/dist/browser/memory-client.d.ts +1 -1
- package/dist/browser/memory-client.js +6 -6
- package/dist/browser/meshagent-client.d.ts +1 -1
- package/dist/browser/meshagent-client.js +78 -78
- package/dist/browser/messaging-client.d.ts +4 -4
- package/dist/browser/messaging-client.js +33 -33
- package/dist/browser/participant-token.d.ts +1 -1
- package/dist/browser/participant-token.js +5 -5
- package/dist/browser/participant.d.ts +1 -1
- package/dist/browser/protocol.d.ts +7 -4
- package/dist/browser/protocol.js +36 -20
- package/dist/browser/queues-client.d.ts +1 -1
- package/dist/browser/queues-client.js +10 -10
- package/dist/browser/response.js +11 -11
- package/dist/browser/room-client.d.ts +23 -17
- package/dist/browser/room-client.js +138 -130
- package/dist/browser/room-server-client.d.ts +2 -2
- package/dist/browser/room-server-client.js +10 -10
- package/dist/browser/secrets-client.d.ts +3 -3
- package/dist/browser/secrets-client.js +30 -30
- package/dist/browser/services-client.d.ts +2 -2
- package/dist/browser/services-client.js +8 -8
- package/dist/browser/storage-client.d.ts +5 -5
- package/dist/browser/storage-client.js +30 -30
- package/dist/browser/sync-client.d.ts +4 -4
- package/dist/browser/sync-client.js +38 -38
- package/dist/browser/toolkit-config.d.ts +3 -3
- package/dist/esm/agent-client.d.ts +4 -4
- package/dist/esm/agent-client.js +19 -25
- package/dist/esm/agent.d.ts +6 -6
- package/dist/esm/agent.js +73 -93
- package/dist/esm/api_keys.js +12 -21
- package/dist/esm/client.js +7 -13
- package/dist/esm/completer.js +1 -5
- package/dist/esm/containers-client.d.ts +3 -3
- package/dist/esm/containers-client.js +82 -87
- package/dist/esm/datasets-client.d.ts +1 -1
- package/dist/esm/datasets-client.js +101 -111
- package/dist/esm/developer-client.d.ts +3 -3
- package/dist/esm/developer-client.js +11 -15
- package/dist/esm/document.d.ts +2 -2
- package/dist/esm/document.js +11 -20
- package/dist/esm/entrypoint.js +1 -12
- package/dist/esm/event-emitter.js +1 -5
- package/dist/esm/helpers.d.ts +4 -4
- package/dist/esm/helpers.js +15 -23
- package/dist/esm/index.d.ts +35 -35
- package/dist/esm/index.js +35 -51
- package/dist/esm/memory-client.d.ts +1 -1
- package/dist/esm/memory-client.js +7 -11
- package/dist/esm/meshagent-client.d.ts +1 -1
- package/dist/esm/meshagent-client.js +79 -83
- package/dist/esm/messaging-client.d.ts +4 -4
- package/dist/esm/messaging-client.js +33 -37
- package/dist/esm/oauth-scopes.js +2 -5
- package/dist/esm/participant-token.d.ts +1 -1
- package/dist/esm/participant-token.js +34 -62
- package/dist/esm/participant.d.ts +1 -1
- package/dist/esm/participant.js +3 -9
- package/dist/esm/protocol.d.ts +7 -4
- package/dist/esm/protocol.js +48 -46
- package/dist/esm/queues-client.d.ts +1 -1
- package/dist/esm/queues-client.js +12 -17
- package/dist/esm/requirement.js +4 -11
- package/dist/esm/response.js +22 -34
- package/dist/esm/room-client.d.ts +23 -17
- package/dist/esm/room-client.js +140 -137
- package/dist/esm/room-event.js +9 -21
- package/dist/esm/room-server-client.d.ts +2 -2
- package/dist/esm/room-server-client.js +13 -18
- package/dist/esm/runtime.js +1 -10
- package/dist/esm/schema.js +9 -18
- package/dist/esm/secrets-client.d.ts +3 -3
- package/dist/esm/secrets-client.js +31 -35
- package/dist/esm/services-client.d.ts +2 -2
- package/dist/esm/services-client.js +9 -13
- package/dist/esm/storage-client.d.ts +5 -5
- package/dist/esm/storage-client.js +32 -38
- package/dist/esm/stream-controller.js +1 -5
- package/dist/esm/sync-client.d.ts +4 -4
- package/dist/esm/sync-client.js +38 -42
- package/dist/esm/tool-content-type.js +1 -5
- package/dist/esm/toolkit-config.d.ts +3 -3
- package/dist/esm/toolkit-config.js +5 -13
- package/dist/esm/utils.js +10 -20
- package/dist/esm/version.js +1 -4
- package/dist/node/agent-client.d.ts +4 -4
- package/dist/node/agent-client.js +16 -16
- package/dist/node/agent.d.ts +6 -6
- package/dist/node/agent.js +57 -57
- package/dist/node/api_keys.js +7 -3
- package/dist/node/containers-client.d.ts +3 -3
- package/dist/node/containers-client.js +76 -76
- package/dist/node/datasets-client.d.ts +1 -1
- package/dist/node/datasets-client.js +83 -83
- package/dist/node/developer-client.d.ts +3 -3
- package/dist/node/developer-client.js +11 -11
- package/dist/node/document.d.ts +2 -2
- package/dist/node/document.js +3 -3
- package/dist/node/helpers.d.ts +4 -4
- package/dist/node/helpers.js +9 -9
- package/dist/node/index.d.ts +35 -35
- package/dist/node/index.js +35 -35
- package/dist/node/memory-client.d.ts +1 -1
- package/dist/node/memory-client.js +6 -6
- package/dist/node/meshagent-client.d.ts +1 -1
- package/dist/node/meshagent-client.js +78 -78
- package/dist/node/messaging-client.d.ts +4 -4
- package/dist/node/messaging-client.js +33 -33
- package/dist/node/participant-token.d.ts +1 -1
- package/dist/node/participant-token.js +5 -5
- package/dist/node/participant.d.ts +1 -1
- package/dist/node/protocol.d.ts +7 -4
- package/dist/node/protocol.js +36 -20
- package/dist/node/queues-client.d.ts +1 -1
- package/dist/node/queues-client.js +10 -10
- package/dist/node/response.js +11 -11
- package/dist/node/room-client.d.ts +23 -17
- package/dist/node/room-client.js +138 -130
- package/dist/node/room-server-client.d.ts +2 -2
- package/dist/node/room-server-client.js +10 -10
- package/dist/node/secrets-client.d.ts +3 -3
- package/dist/node/secrets-client.js +30 -30
- package/dist/node/services-client.d.ts +2 -2
- package/dist/node/services-client.js +8 -8
- package/dist/node/storage-client.d.ts +5 -5
- package/dist/node/storage-client.js +30 -30
- package/dist/node/sync-client.d.ts +4 -4
- package/dist/node/sync-client.js +38 -38
- package/dist/node/toolkit-config.d.ts +3 -3
- package/package.json +11 -5
- package/dist/browser/lk-client.d.ts +0 -18
- package/dist/browser/lk-client.js +0 -33
- package/dist/browser/lk-protocol.d.ts +0 -22
- package/dist/browser/lk-protocol.js +0 -37
- package/dist/esm/lk-client.d.ts +0 -18
- package/dist/esm/lk-client.js +0 -33
- package/dist/esm/lk-protocol.d.ts +0 -22
- package/dist/esm/lk-protocol.js +0 -37
- package/dist/node/lk-client.d.ts +0 -18
- package/dist/node/lk-client.js +0 -33
- package/dist/node/lk-protocol.d.ts +0 -22
- package/dist/node/lk-protocol.js +0 -37
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const response_1 = require("./response");
|
|
7
|
-
const room_server_client_1 = require("./room-server-client");
|
|
8
|
-
const stream_controller_1 = require("./stream-controller");
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
import { Completer } from "./completer.js";
|
|
3
|
+
import { BinaryContent, ControlContent, ErrorContent, JsonContent } from "./response.js";
|
|
4
|
+
import { RoomServerException } from "./room-server-client.js";
|
|
5
|
+
import { StreamController } from "./stream-controller.js";
|
|
9
6
|
function isRecord(value) {
|
|
10
7
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
8
|
}
|
|
@@ -31,14 +28,14 @@ function toMountList(values) {
|
|
|
31
28
|
function readStringField(data, field, operation) {
|
|
32
29
|
const value = data[field];
|
|
33
30
|
if (typeof value !== "string") {
|
|
34
|
-
throw new
|
|
31
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
35
32
|
}
|
|
36
33
|
return value;
|
|
37
34
|
}
|
|
38
35
|
function readIntegerField(data, field, operation) {
|
|
39
36
|
const value = data[field];
|
|
40
37
|
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
41
|
-
throw new
|
|
38
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
42
39
|
}
|
|
43
40
|
return value;
|
|
44
41
|
}
|
|
@@ -48,7 +45,7 @@ function readOptionalIntegerField(data, field, operation) {
|
|
|
48
45
|
return undefined;
|
|
49
46
|
}
|
|
50
47
|
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
51
|
-
throw new
|
|
48
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
52
49
|
}
|
|
53
50
|
return value;
|
|
54
51
|
}
|
|
@@ -58,7 +55,7 @@ function readOptionalStringField(data, field, operation) {
|
|
|
58
55
|
return undefined;
|
|
59
56
|
}
|
|
60
57
|
if (typeof value !== "string") {
|
|
61
|
-
throw new
|
|
58
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
62
59
|
}
|
|
63
60
|
return value;
|
|
64
61
|
}
|
|
@@ -68,11 +65,11 @@ function parseTimestampField(data, field, operation) {
|
|
|
68
65
|
return undefined;
|
|
69
66
|
}
|
|
70
67
|
if (typeof value !== "string") {
|
|
71
|
-
throw new
|
|
68
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
72
69
|
}
|
|
73
70
|
const timestamp = new Date(value);
|
|
74
71
|
if (Number.isNaN(timestamp.getTime())) {
|
|
75
|
-
throw new
|
|
72
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
76
73
|
}
|
|
77
74
|
return timestamp;
|
|
78
75
|
}
|
|
@@ -81,7 +78,7 @@ function decodeUtf8(data, operation) {
|
|
|
81
78
|
return new TextDecoder("utf-8", { fatal: true }).decode(data);
|
|
82
79
|
}
|
|
83
80
|
catch {
|
|
84
|
-
throw new
|
|
81
|
+
throw new RoomServerException(`containers.${operation} returned invalid UTF-8 data`);
|
|
85
82
|
}
|
|
86
83
|
}
|
|
87
84
|
function decodeJsonStatus(data, operation) {
|
|
@@ -91,14 +88,14 @@ function decodeJsonStatus(data, operation) {
|
|
|
91
88
|
parsed = JSON.parse(text);
|
|
92
89
|
}
|
|
93
90
|
catch {
|
|
94
|
-
throw new
|
|
91
|
+
throw new RoomServerException(`containers.${operation} returned an invalid status payload`);
|
|
95
92
|
}
|
|
96
93
|
if (!isRecord(parsed)) {
|
|
97
|
-
throw new
|
|
94
|
+
throw new RoomServerException(`containers.${operation} returned an invalid status payload`);
|
|
98
95
|
}
|
|
99
96
|
const status = parsed["status"];
|
|
100
97
|
if (typeof status !== "number" || !Number.isInteger(status)) {
|
|
101
|
-
throw new
|
|
98
|
+
throw new RoomServerException(`containers.${operation} returned an invalid status payload`);
|
|
102
99
|
}
|
|
103
100
|
return status;
|
|
104
101
|
}
|
|
@@ -107,12 +104,12 @@ function normalizeImageLabels(labelsRaw, operation) {
|
|
|
107
104
|
const labels = {};
|
|
108
105
|
for (const entry of labelsRaw) {
|
|
109
106
|
if (!isRecord(entry)) {
|
|
110
|
-
throw new
|
|
107
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
111
108
|
}
|
|
112
109
|
const key = entry["key"];
|
|
113
110
|
const value = entry["value"];
|
|
114
111
|
if (typeof key !== "string" || typeof value !== "string") {
|
|
115
|
-
throw new
|
|
112
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
116
113
|
}
|
|
117
114
|
labels[key] = value;
|
|
118
115
|
}
|
|
@@ -122,7 +119,7 @@ function normalizeImageLabels(labelsRaw, operation) {
|
|
|
122
119
|
const labels = {};
|
|
123
120
|
for (const [key, value] of Object.entries(labelsRaw)) {
|
|
124
121
|
if (typeof value !== "string") {
|
|
125
|
-
throw new
|
|
122
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
126
123
|
}
|
|
127
124
|
labels[key] = value;
|
|
128
125
|
}
|
|
@@ -131,14 +128,14 @@ function normalizeImageLabels(labelsRaw, operation) {
|
|
|
131
128
|
if (labelsRaw === undefined || labelsRaw === null) {
|
|
132
129
|
return {};
|
|
133
130
|
}
|
|
134
|
-
throw new
|
|
131
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
135
132
|
}
|
|
136
133
|
function normalizeImageReferences(entry, operation) {
|
|
137
134
|
const referencesRaw = entry["references"];
|
|
138
135
|
if (Array.isArray(referencesRaw)) {
|
|
139
136
|
const references = referencesRaw.filter((item) => typeof item === "string");
|
|
140
137
|
if (references.length !== referencesRaw.length) {
|
|
141
|
-
throw new
|
|
138
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
142
139
|
}
|
|
143
140
|
return references;
|
|
144
141
|
}
|
|
@@ -146,14 +143,14 @@ function normalizeImageReferences(entry, operation) {
|
|
|
146
143
|
if (Array.isArray(tagsRaw)) {
|
|
147
144
|
const references = tagsRaw.filter((item) => typeof item === "string");
|
|
148
145
|
if (references.length !== tagsRaw.length) {
|
|
149
|
-
throw new
|
|
146
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
150
147
|
}
|
|
151
148
|
return references;
|
|
152
149
|
}
|
|
153
150
|
if (referencesRaw === undefined || referencesRaw === null) {
|
|
154
151
|
return [];
|
|
155
152
|
}
|
|
156
|
-
throw new
|
|
153
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
157
154
|
}
|
|
158
155
|
function parseContainerImage(entry, operation) {
|
|
159
156
|
const references = normalizeImageReferences(entry, operation);
|
|
@@ -181,14 +178,14 @@ function parseOptionalContainerImageDescriptor(value, operation) {
|
|
|
181
178
|
return undefined;
|
|
182
179
|
}
|
|
183
180
|
if (!isRecord(value)) {
|
|
184
|
-
throw new
|
|
181
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
185
182
|
}
|
|
186
183
|
return parseContainerImageDescriptor(value, operation);
|
|
187
184
|
}
|
|
188
185
|
function parseContainerImageManifest(entry, operation) {
|
|
189
186
|
const descriptorRaw = entry["descriptor"];
|
|
190
187
|
if (!isRecord(descriptorRaw)) {
|
|
191
|
-
throw new
|
|
188
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
192
189
|
}
|
|
193
190
|
return {
|
|
194
191
|
descriptor: parseContainerImageDescriptor(descriptorRaw, operation),
|
|
@@ -203,7 +200,7 @@ function parseContainerImageInspection(entry, operation) {
|
|
|
203
200
|
const manifestsRaw = entry["manifests"];
|
|
204
201
|
const layersRaw = entry["layers"];
|
|
205
202
|
if (!isRecord(imageRaw) || !isRecord(targetRaw) || !Array.isArray(manifestsRaw) || !Array.isArray(layersRaw)) {
|
|
206
|
-
throw new
|
|
203
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
207
204
|
}
|
|
208
205
|
return {
|
|
209
206
|
image: parseContainerImage(imageRaw, operation),
|
|
@@ -211,14 +208,14 @@ function parseContainerImageInspection(entry, operation) {
|
|
|
211
208
|
selectedManifest: parseOptionalContainerImageDescriptor(entry["selected_manifest"], operation),
|
|
212
209
|
manifests: manifestsRaw.map((manifest) => {
|
|
213
210
|
if (!isRecord(manifest)) {
|
|
214
|
-
throw new
|
|
211
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
215
212
|
}
|
|
216
213
|
return parseContainerImageManifest(manifest, operation);
|
|
217
214
|
}),
|
|
218
215
|
config: parseOptionalContainerImageDescriptor(entry["config"], operation),
|
|
219
216
|
layers: layersRaw.map((layer) => {
|
|
220
217
|
if (!isRecord(layer)) {
|
|
221
|
-
throw new
|
|
218
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
222
219
|
}
|
|
223
220
|
return parseContainerImageDescriptor(layer, operation);
|
|
224
221
|
}),
|
|
@@ -229,7 +226,7 @@ function parseImportedImage(data, operation) {
|
|
|
229
226
|
const resolvedRef = data["resolved_ref"];
|
|
230
227
|
const refsRaw = data["refs"];
|
|
231
228
|
if (typeof resolvedRef !== "string" || !Array.isArray(refsRaw) || refsRaw.some((entry) => typeof entry !== "string")) {
|
|
232
|
-
throw new
|
|
229
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
233
230
|
}
|
|
234
231
|
return {
|
|
235
232
|
resolvedRef,
|
|
@@ -241,7 +238,7 @@ function parseBuildJob(data, operation) {
|
|
|
241
238
|
const tag = readStringField(data, "tag", operation);
|
|
242
239
|
const status = readStringField(data, "status", operation);
|
|
243
240
|
if (!["queued", "running", "failed", "cancelled", "succeeded"].includes(status)) {
|
|
244
|
-
throw new
|
|
241
|
+
throw new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
245
242
|
}
|
|
246
243
|
return {
|
|
247
244
|
id,
|
|
@@ -253,9 +250,9 @@ function parseBuildJob(data, operation) {
|
|
|
253
250
|
async function* buildInputStream(params) {
|
|
254
251
|
const tags = params.tags ?? (params.tag === undefined ? [] : [params.tag]);
|
|
255
252
|
if (tags.length === 0) {
|
|
256
|
-
throw new
|
|
253
|
+
throw new RoomServerException("containers.build requires at least one tag");
|
|
257
254
|
}
|
|
258
|
-
yield new
|
|
255
|
+
yield new BinaryContent({
|
|
259
256
|
data: new Uint8Array(0),
|
|
260
257
|
headers: {
|
|
261
258
|
kind: "start",
|
|
@@ -271,19 +268,19 @@ async function* buildInputStream(params) {
|
|
|
271
268
|
},
|
|
272
269
|
});
|
|
273
270
|
for await (const chunk of params.chunks) {
|
|
274
|
-
yield new
|
|
271
|
+
yield new BinaryContent({
|
|
275
272
|
data: new Uint8Array(chunk),
|
|
276
273
|
headers: { kind: "data" },
|
|
277
274
|
});
|
|
278
275
|
}
|
|
279
276
|
}
|
|
280
|
-
class ExecSession {
|
|
277
|
+
export class ExecSession {
|
|
281
278
|
constructor(params) {
|
|
282
279
|
this.previousOutput = [];
|
|
283
280
|
this.previousError = [];
|
|
284
|
-
this.resultCompleter = new
|
|
285
|
-
this.outputController = new
|
|
286
|
-
this.errorController = new
|
|
281
|
+
this.resultCompleter = new Completer();
|
|
282
|
+
this.outputController = new StreamController();
|
|
283
|
+
this.errorController = new StreamController();
|
|
287
284
|
this.queuedInput = [];
|
|
288
285
|
this.inputClosed = false;
|
|
289
286
|
this.closed = false;
|
|
@@ -297,7 +294,7 @@ class ExecSession {
|
|
|
297
294
|
this.stderr = this.errorController.stream;
|
|
298
295
|
}
|
|
299
296
|
async *inputStream() {
|
|
300
|
-
yield new
|
|
297
|
+
yield new BinaryContent({
|
|
301
298
|
data: new Uint8Array(0),
|
|
302
299
|
headers: {
|
|
303
300
|
kind: "start",
|
|
@@ -317,7 +314,7 @@ class ExecSession {
|
|
|
317
314
|
if (this.inputClosed) {
|
|
318
315
|
return;
|
|
319
316
|
}
|
|
320
|
-
this.inputWaiter = new
|
|
317
|
+
this.inputWaiter = new Completer();
|
|
321
318
|
await this.inputWaiter.fut;
|
|
322
319
|
this.inputWaiter = null;
|
|
323
320
|
}
|
|
@@ -373,9 +370,9 @@ class ExecSession {
|
|
|
373
370
|
}
|
|
374
371
|
queueInput(params) {
|
|
375
372
|
if (this.inputClosed) {
|
|
376
|
-
throw new
|
|
373
|
+
throw new RoomServerException("container exec session is already closed");
|
|
377
374
|
}
|
|
378
|
-
this.queuedInput.push(new
|
|
375
|
+
this.queuedInput.push(new BinaryContent({
|
|
379
376
|
data: params.data ?? new Uint8Array(0),
|
|
380
377
|
headers: {
|
|
381
378
|
kind: "input",
|
|
@@ -394,13 +391,12 @@ class ExecSession {
|
|
|
394
391
|
this.inputWaiter?.complete();
|
|
395
392
|
}
|
|
396
393
|
}
|
|
397
|
-
|
|
398
|
-
class ContainersClient {
|
|
394
|
+
export class ContainersClient {
|
|
399
395
|
constructor({ room }) {
|
|
400
396
|
this.room = room;
|
|
401
397
|
}
|
|
402
398
|
unexpectedResponseError(operation) {
|
|
403
|
-
return new
|
|
399
|
+
return new RoomServerException(`unexpected return type from containers.${operation}`);
|
|
404
400
|
}
|
|
405
401
|
async invoke(operation, input) {
|
|
406
402
|
return await this.room.invoke({
|
|
@@ -411,7 +407,7 @@ class ContainersClient {
|
|
|
411
407
|
}
|
|
412
408
|
async listImages() {
|
|
413
409
|
const output = await this.invoke("list_images", {});
|
|
414
|
-
if (!(output instanceof
|
|
410
|
+
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
415
411
|
throw this.unexpectedResponseError("list_images");
|
|
416
412
|
}
|
|
417
413
|
const imagesRaw = output.json["images"];
|
|
@@ -431,7 +427,7 @@ class ContainersClient {
|
|
|
431
427
|
const output = await this.invoke("inspect_image", {
|
|
432
428
|
image_id: params.imageId,
|
|
433
429
|
});
|
|
434
|
-
if (!(output instanceof
|
|
430
|
+
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
435
431
|
throw this.unexpectedResponseError("inspect_image");
|
|
436
432
|
}
|
|
437
433
|
return parseContainerImageInspection(output.json, "inspect_image");
|
|
@@ -453,7 +449,7 @@ class ContainersClient {
|
|
|
453
449
|
credentials: toCredentials(params.credentials ?? []),
|
|
454
450
|
private: params.private ?? false,
|
|
455
451
|
});
|
|
456
|
-
if (!(output instanceof
|
|
452
|
+
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
457
453
|
throw this.unexpectedResponseError("push_image");
|
|
458
454
|
}
|
|
459
455
|
return readStringField(output.json, "container_id", "push_image");
|
|
@@ -462,7 +458,7 @@ class ContainersClient {
|
|
|
462
458
|
const output = await this.invoke("load", {
|
|
463
459
|
archive_path: params.archivePath,
|
|
464
460
|
});
|
|
465
|
-
if (!(output instanceof
|
|
461
|
+
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
466
462
|
throw this.unexpectedResponseError("load");
|
|
467
463
|
}
|
|
468
464
|
return parseImportedImage(output.json, "load");
|
|
@@ -473,7 +469,7 @@ class ContainersClient {
|
|
|
473
469
|
archive_path: params.archivePath,
|
|
474
470
|
private: params.private ?? false,
|
|
475
471
|
});
|
|
476
|
-
if (!(output instanceof
|
|
472
|
+
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
477
473
|
throw this.unexpectedResponseError("load_image");
|
|
478
474
|
}
|
|
479
475
|
return readStringField(output.json, "container_id", "load_image");
|
|
@@ -485,7 +481,7 @@ class ContainersClient {
|
|
|
485
481
|
archive_path: params.archivePath,
|
|
486
482
|
private: params.private ?? false,
|
|
487
483
|
});
|
|
488
|
-
if (!(output instanceof
|
|
484
|
+
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
489
485
|
throw this.unexpectedResponseError("save_image");
|
|
490
486
|
}
|
|
491
487
|
return readStringField(output.json, "container_id", "save_image");
|
|
@@ -508,7 +504,7 @@ class ContainersClient {
|
|
|
508
504
|
writable_root_fs: params.writableRootFs,
|
|
509
505
|
private: params.private,
|
|
510
506
|
});
|
|
511
|
-
if (!(output instanceof
|
|
507
|
+
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
512
508
|
throw this.unexpectedResponseError("run");
|
|
513
509
|
}
|
|
514
510
|
return readStringField(output.json, "container_id", "run");
|
|
@@ -519,14 +515,14 @@ class ContainersClient {
|
|
|
519
515
|
tool: "build",
|
|
520
516
|
input: buildInputStream(params),
|
|
521
517
|
});
|
|
522
|
-
if (!(output instanceof
|
|
518
|
+
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
523
519
|
throw this.unexpectedResponseError("build");
|
|
524
520
|
}
|
|
525
521
|
return readStringField(output.json, "build_id", "build");
|
|
526
522
|
}
|
|
527
523
|
async listBuilds() {
|
|
528
524
|
const output = await this.invoke("list_builds", {});
|
|
529
|
-
if (!(output instanceof
|
|
525
|
+
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
530
526
|
throw this.unexpectedResponseError("list_builds");
|
|
531
527
|
}
|
|
532
528
|
const buildsRaw = output.json["builds"];
|
|
@@ -555,13 +551,13 @@ class ContainersClient {
|
|
|
555
551
|
service_id: params.serviceId,
|
|
556
552
|
env: toStringMapList(params.env ?? {}),
|
|
557
553
|
});
|
|
558
|
-
if (!(output instanceof
|
|
554
|
+
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
559
555
|
throw this.unexpectedResponseError("run_service");
|
|
560
556
|
}
|
|
561
557
|
return readStringField(output.json, "container_id", "run_service");
|
|
562
558
|
}
|
|
563
559
|
exec(params) {
|
|
564
|
-
const requestId = (
|
|
560
|
+
const requestId = uuidv4();
|
|
565
561
|
const session = new ExecSession({
|
|
566
562
|
requestId,
|
|
567
563
|
command: params.command,
|
|
@@ -576,21 +572,21 @@ class ContainersClient {
|
|
|
576
572
|
})
|
|
577
573
|
.then(async (stream) => {
|
|
578
574
|
for await (const chunk of stream) {
|
|
579
|
-
if (chunk instanceof
|
|
580
|
-
throw new
|
|
575
|
+
if (chunk instanceof ErrorContent) {
|
|
576
|
+
throw new RoomServerException(chunk.text, chunk.code);
|
|
581
577
|
}
|
|
582
|
-
if (chunk instanceof
|
|
578
|
+
if (chunk instanceof ControlContent) {
|
|
583
579
|
if (chunk.method === "close") {
|
|
584
580
|
break;
|
|
585
581
|
}
|
|
586
582
|
throw this.unexpectedResponseError("exec");
|
|
587
583
|
}
|
|
588
|
-
if (!(chunk instanceof
|
|
584
|
+
if (!(chunk instanceof BinaryContent)) {
|
|
589
585
|
throw this.unexpectedResponseError("exec");
|
|
590
586
|
}
|
|
591
587
|
const channel = chunk.headers["channel"];
|
|
592
588
|
if (typeof channel !== "number") {
|
|
593
|
-
throw new
|
|
589
|
+
throw new RoomServerException("containers.exec returned a chunk without a valid channel");
|
|
594
590
|
}
|
|
595
591
|
if (channel === 1) {
|
|
596
592
|
session.addOutput(chunk.data);
|
|
@@ -605,7 +601,7 @@ class ContainersClient {
|
|
|
605
601
|
return;
|
|
606
602
|
}
|
|
607
603
|
}
|
|
608
|
-
throw new
|
|
604
|
+
throw new RoomServerException("containers.exec stream closed before a status was returned");
|
|
609
605
|
})
|
|
610
606
|
.catch((error) => {
|
|
611
607
|
session.closeError(error);
|
|
@@ -622,7 +618,7 @@ class ContainersClient {
|
|
|
622
618
|
const output = await this.invoke("wait_for_exit", {
|
|
623
619
|
container_id: params.containerId,
|
|
624
620
|
});
|
|
625
|
-
if (!(output instanceof
|
|
621
|
+
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
626
622
|
throw this.unexpectedResponseError("wait_for_exit");
|
|
627
623
|
}
|
|
628
624
|
const exitCode = readIntegerField(output.json, "exit_code", "wait_for_exit");
|
|
@@ -646,11 +642,11 @@ class ContainersClient {
|
|
|
646
642
|
});
|
|
647
643
|
}
|
|
648
644
|
logs(params) {
|
|
649
|
-
const requestId = (
|
|
650
|
-
const closeInput = new
|
|
651
|
-
const progressController = new
|
|
652
|
-
const streamController = new
|
|
653
|
-
const result = new
|
|
645
|
+
const requestId = uuidv4();
|
|
646
|
+
const closeInput = new Completer();
|
|
647
|
+
const progressController = new StreamController();
|
|
648
|
+
const streamController = new StreamController();
|
|
649
|
+
const result = new Completer();
|
|
654
650
|
let inputClosed = false;
|
|
655
651
|
const closeInputStream = () => {
|
|
656
652
|
if (inputClosed) {
|
|
@@ -662,7 +658,7 @@ class ContainersClient {
|
|
|
662
658
|
}
|
|
663
659
|
};
|
|
664
660
|
const inputStream = async function* () {
|
|
665
|
-
yield new
|
|
661
|
+
yield new BinaryContent({
|
|
666
662
|
data: new Uint8Array(0),
|
|
667
663
|
headers: {
|
|
668
664
|
kind: "start",
|
|
@@ -681,10 +677,10 @@ class ContainersClient {
|
|
|
681
677
|
})
|
|
682
678
|
.then(async (stream) => {
|
|
683
679
|
for await (const chunk of stream) {
|
|
684
|
-
if (chunk instanceof
|
|
685
|
-
throw new
|
|
680
|
+
if (chunk instanceof ErrorContent) {
|
|
681
|
+
throw new RoomServerException(chunk.text, chunk.code);
|
|
686
682
|
}
|
|
687
|
-
if (chunk instanceof
|
|
683
|
+
if (chunk instanceof ControlContent) {
|
|
688
684
|
if (chunk.method === "close") {
|
|
689
685
|
closeInputStream();
|
|
690
686
|
progressController.close();
|
|
@@ -696,12 +692,12 @@ class ContainersClient {
|
|
|
696
692
|
}
|
|
697
693
|
throw this.unexpectedResponseError("logs");
|
|
698
694
|
}
|
|
699
|
-
if (!(chunk instanceof
|
|
695
|
+
if (!(chunk instanceof BinaryContent)) {
|
|
700
696
|
throw this.unexpectedResponseError("logs");
|
|
701
697
|
}
|
|
702
698
|
const channel = chunk.headers["channel"];
|
|
703
699
|
if (typeof channel !== "number") {
|
|
704
|
-
throw new
|
|
700
|
+
throw new RoomServerException("containers.logs returned a chunk without a valid channel");
|
|
705
701
|
}
|
|
706
702
|
if (channel !== 1) {
|
|
707
703
|
continue;
|
|
@@ -755,10 +751,10 @@ class ContainersClient {
|
|
|
755
751
|
};
|
|
756
752
|
}
|
|
757
753
|
getBuildLogs(params) {
|
|
758
|
-
const requestId = (
|
|
759
|
-
const closeInput = new
|
|
760
|
-
const streamController = new
|
|
761
|
-
const result = new
|
|
754
|
+
const requestId = uuidv4();
|
|
755
|
+
const closeInput = new Completer();
|
|
756
|
+
const streamController = new StreamController();
|
|
757
|
+
const result = new Completer();
|
|
762
758
|
let inputClosed = false;
|
|
763
759
|
const closeInputStream = () => {
|
|
764
760
|
if (inputClosed) {
|
|
@@ -770,7 +766,7 @@ class ContainersClient {
|
|
|
770
766
|
}
|
|
771
767
|
};
|
|
772
768
|
const inputStream = async function* () {
|
|
773
|
-
yield new
|
|
769
|
+
yield new BinaryContent({
|
|
774
770
|
data: new Uint8Array(0),
|
|
775
771
|
headers: {
|
|
776
772
|
kind: "start",
|
|
@@ -789,10 +785,10 @@ class ContainersClient {
|
|
|
789
785
|
})
|
|
790
786
|
.then(async (stream) => {
|
|
791
787
|
for await (const chunk of stream) {
|
|
792
|
-
if (chunk instanceof
|
|
793
|
-
throw new
|
|
788
|
+
if (chunk instanceof ErrorContent) {
|
|
789
|
+
throw new RoomServerException(chunk.text, chunk.code);
|
|
794
790
|
}
|
|
795
|
-
if (chunk instanceof
|
|
791
|
+
if (chunk instanceof ControlContent) {
|
|
796
792
|
if (chunk.method === "close") {
|
|
797
793
|
closeInputStream();
|
|
798
794
|
streamController.close();
|
|
@@ -803,12 +799,12 @@ class ContainersClient {
|
|
|
803
799
|
}
|
|
804
800
|
throw this.unexpectedResponseError("get_build_logs");
|
|
805
801
|
}
|
|
806
|
-
if (!(chunk instanceof
|
|
802
|
+
if (!(chunk instanceof BinaryContent)) {
|
|
807
803
|
throw this.unexpectedResponseError("get_build_logs");
|
|
808
804
|
}
|
|
809
805
|
const channel = chunk.headers["channel"];
|
|
810
806
|
if (typeof channel !== "number") {
|
|
811
|
-
throw new
|
|
807
|
+
throw new RoomServerException("containers.get_build_logs returned a chunk without a valid channel");
|
|
812
808
|
}
|
|
813
809
|
if (channel === 1) {
|
|
814
810
|
streamController.add(decodeUtf8(chunk.data, "get_build_logs"));
|
|
@@ -870,7 +866,7 @@ class ContainersClient {
|
|
|
870
866
|
const output = await this.invoke("list_containers", {
|
|
871
867
|
all: params?.all,
|
|
872
868
|
});
|
|
873
|
-
if (!(output instanceof
|
|
869
|
+
if (!(output instanceof JsonContent) || !isRecord(output.json)) {
|
|
874
870
|
throw this.unexpectedResponseError("list");
|
|
875
871
|
}
|
|
876
872
|
const containersRaw = output.json["containers"];
|
|
@@ -971,4 +967,3 @@ class ContainersClient {
|
|
|
971
967
|
return items;
|
|
972
968
|
}
|
|
973
969
|
}
|
|
974
|
-
exports.ContainersClient = ContainersClient;
|
|
@@ -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";
|