@meshagent/meshagent 0.42.0 → 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.
Files changed (161) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/browser/agent-client.d.ts +4 -4
  3. package/dist/browser/agent-client.js +16 -16
  4. package/dist/browser/agent.d.ts +6 -6
  5. package/dist/browser/agent.js +57 -57
  6. package/dist/browser/api_keys.js +7 -3
  7. package/dist/browser/containers-client.d.ts +21 -3
  8. package/dist/browser/containers-client.js +126 -78
  9. package/dist/browser/datasets-client.d.ts +1 -1
  10. package/dist/browser/datasets-client.js +83 -83
  11. package/dist/browser/developer-client.d.ts +3 -3
  12. package/dist/browser/developer-client.js +11 -11
  13. package/dist/browser/document.d.ts +2 -2
  14. package/dist/browser/document.js +3 -3
  15. package/dist/browser/helpers.d.ts +4 -4
  16. package/dist/browser/helpers.js +9 -9
  17. package/dist/browser/index.d.ts +35 -35
  18. package/dist/browser/index.js +35 -35
  19. package/dist/browser/memory-client.d.ts +1 -1
  20. package/dist/browser/memory-client.js +6 -6
  21. package/dist/browser/meshagent-client.d.ts +1 -1
  22. package/dist/browser/meshagent-client.js +78 -78
  23. package/dist/browser/messaging-client.d.ts +4 -4
  24. package/dist/browser/messaging-client.js +33 -33
  25. package/dist/browser/participant-token.d.ts +1 -1
  26. package/dist/browser/participant-token.js +5 -5
  27. package/dist/browser/participant.d.ts +1 -1
  28. package/dist/browser/protocol.d.ts +7 -4
  29. package/dist/browser/protocol.js +36 -20
  30. package/dist/browser/queues-client.d.ts +1 -1
  31. package/dist/browser/queues-client.js +10 -10
  32. package/dist/browser/response.js +11 -11
  33. package/dist/browser/room-client.d.ts +23 -17
  34. package/dist/browser/room-client.js +138 -130
  35. package/dist/browser/room-server-client.d.ts +2 -2
  36. package/dist/browser/room-server-client.js +10 -10
  37. package/dist/browser/secrets-client.d.ts +3 -3
  38. package/dist/browser/secrets-client.js +30 -30
  39. package/dist/browser/services-client.d.ts +2 -2
  40. package/dist/browser/services-client.js +8 -8
  41. package/dist/browser/storage-client.d.ts +5 -5
  42. package/dist/browser/storage-client.js +30 -30
  43. package/dist/browser/sync-client.d.ts +4 -4
  44. package/dist/browser/sync-client.js +38 -38
  45. package/dist/browser/toolkit-config.d.ts +3 -3
  46. package/dist/esm/agent-client.d.ts +4 -4
  47. package/dist/esm/agent-client.js +19 -25
  48. package/dist/esm/agent.d.ts +6 -6
  49. package/dist/esm/agent.js +73 -93
  50. package/dist/esm/api_keys.js +12 -21
  51. package/dist/esm/client.js +7 -13
  52. package/dist/esm/completer.js +1 -5
  53. package/dist/esm/containers-client.d.ts +21 -3
  54. package/dist/esm/containers-client.js +132 -89
  55. package/dist/esm/datasets-client.d.ts +1 -1
  56. package/dist/esm/datasets-client.js +101 -111
  57. package/dist/esm/developer-client.d.ts +3 -3
  58. package/dist/esm/developer-client.js +11 -15
  59. package/dist/esm/document.d.ts +2 -2
  60. package/dist/esm/document.js +11 -20
  61. package/dist/esm/entrypoint.js +1 -12
  62. package/dist/esm/event-emitter.js +1 -5
  63. package/dist/esm/helpers.d.ts +4 -4
  64. package/dist/esm/helpers.js +15 -23
  65. package/dist/esm/index.d.ts +35 -35
  66. package/dist/esm/index.js +35 -51
  67. package/dist/esm/memory-client.d.ts +1 -1
  68. package/dist/esm/memory-client.js +7 -11
  69. package/dist/esm/meshagent-client.d.ts +1 -1
  70. package/dist/esm/meshagent-client.js +79 -83
  71. package/dist/esm/messaging-client.d.ts +4 -4
  72. package/dist/esm/messaging-client.js +33 -37
  73. package/dist/esm/oauth-scopes.js +2 -5
  74. package/dist/esm/participant-token.d.ts +1 -1
  75. package/dist/esm/participant-token.js +34 -62
  76. package/dist/esm/participant.d.ts +1 -1
  77. package/dist/esm/participant.js +3 -9
  78. package/dist/esm/protocol.d.ts +7 -4
  79. package/dist/esm/protocol.js +48 -46
  80. package/dist/esm/queues-client.d.ts +1 -1
  81. package/dist/esm/queues-client.js +12 -17
  82. package/dist/esm/requirement.js +4 -11
  83. package/dist/esm/response.js +22 -34
  84. package/dist/esm/room-client.d.ts +23 -17
  85. package/dist/esm/room-client.js +140 -137
  86. package/dist/esm/room-event.js +9 -21
  87. package/dist/esm/room-server-client.d.ts +2 -2
  88. package/dist/esm/room-server-client.js +13 -18
  89. package/dist/esm/runtime.js +1 -10
  90. package/dist/esm/schema.js +9 -18
  91. package/dist/esm/secrets-client.d.ts +3 -3
  92. package/dist/esm/secrets-client.js +31 -35
  93. package/dist/esm/services-client.d.ts +2 -2
  94. package/dist/esm/services-client.js +9 -13
  95. package/dist/esm/storage-client.d.ts +5 -5
  96. package/dist/esm/storage-client.js +32 -38
  97. package/dist/esm/stream-controller.js +1 -5
  98. package/dist/esm/sync-client.d.ts +4 -4
  99. package/dist/esm/sync-client.js +38 -42
  100. package/dist/esm/tool-content-type.js +1 -5
  101. package/dist/esm/toolkit-config.d.ts +3 -3
  102. package/dist/esm/toolkit-config.js +5 -13
  103. package/dist/esm/utils.js +10 -20
  104. package/dist/esm/version.js +1 -4
  105. package/dist/node/agent-client.d.ts +4 -4
  106. package/dist/node/agent-client.js +16 -16
  107. package/dist/node/agent.d.ts +6 -6
  108. package/dist/node/agent.js +57 -57
  109. package/dist/node/api_keys.js +7 -3
  110. package/dist/node/containers-client.d.ts +21 -3
  111. package/dist/node/containers-client.js +126 -78
  112. package/dist/node/datasets-client.d.ts +1 -1
  113. package/dist/node/datasets-client.js +83 -83
  114. package/dist/node/developer-client.d.ts +3 -3
  115. package/dist/node/developer-client.js +11 -11
  116. package/dist/node/document.d.ts +2 -2
  117. package/dist/node/document.js +3 -3
  118. package/dist/node/helpers.d.ts +4 -4
  119. package/dist/node/helpers.js +9 -9
  120. package/dist/node/index.d.ts +35 -35
  121. package/dist/node/index.js +35 -35
  122. package/dist/node/memory-client.d.ts +1 -1
  123. package/dist/node/memory-client.js +6 -6
  124. package/dist/node/meshagent-client.d.ts +1 -1
  125. package/dist/node/meshagent-client.js +78 -78
  126. package/dist/node/messaging-client.d.ts +4 -4
  127. package/dist/node/messaging-client.js +33 -33
  128. package/dist/node/participant-token.d.ts +1 -1
  129. package/dist/node/participant-token.js +5 -5
  130. package/dist/node/participant.d.ts +1 -1
  131. package/dist/node/protocol.d.ts +7 -4
  132. package/dist/node/protocol.js +36 -20
  133. package/dist/node/queues-client.d.ts +1 -1
  134. package/dist/node/queues-client.js +10 -10
  135. package/dist/node/response.js +11 -11
  136. package/dist/node/room-client.d.ts +23 -17
  137. package/dist/node/room-client.js +138 -130
  138. package/dist/node/room-server-client.d.ts +2 -2
  139. package/dist/node/room-server-client.js +10 -10
  140. package/dist/node/secrets-client.d.ts +3 -3
  141. package/dist/node/secrets-client.js +30 -30
  142. package/dist/node/services-client.d.ts +2 -2
  143. package/dist/node/services-client.js +8 -8
  144. package/dist/node/storage-client.d.ts +5 -5
  145. package/dist/node/storage-client.js +30 -30
  146. package/dist/node/sync-client.d.ts +4 -4
  147. package/dist/node/sync-client.js +38 -38
  148. package/dist/node/toolkit-config.d.ts +3 -3
  149. package/package.json +11 -5
  150. package/dist/browser/lk-client.d.ts +0 -18
  151. package/dist/browser/lk-client.js +0 -33
  152. package/dist/browser/lk-protocol.d.ts +0 -22
  153. package/dist/browser/lk-protocol.js +0 -37
  154. package/dist/esm/lk-client.d.ts +0 -18
  155. package/dist/esm/lk-client.js +0 -33
  156. package/dist/esm/lk-protocol.d.ts +0 -22
  157. package/dist/esm/lk-protocol.js +0 -37
  158. package/dist/node/lk-client.d.ts +0 -18
  159. package/dist/node/lk-client.js +0 -33
  160. package/dist/node/lk-protocol.d.ts +0 -22
  161. package/dist/node/lk-protocol.js +0 -37
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ContainersClient = exports.ExecSession = void 0;
4
- const uuid_1 = require("uuid");
5
- const completer_1 = require("./completer");
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`containers.${operation} returned invalid UTF-8 data`);
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 room_server_client_1.RoomServerException(`containers.${operation} returned an invalid status payload`);
91
+ throw new RoomServerException(`containers.${operation} returned an invalid status payload`);
95
92
  }
96
93
  if (!isRecord(parsed)) {
97
- throw new room_server_client_1.RoomServerException(`containers.${operation} returned an invalid status payload`);
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 room_server_client_1.RoomServerException(`containers.${operation} returned an invalid status payload`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException("containers.build requires at least one tag");
253
+ throw new RoomServerException("containers.build requires at least one tag");
257
254
  }
258
- yield new response_1.BinaryContent({
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 response_1.BinaryContent({
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 completer_1.Completer();
285
- this.outputController = new stream_controller_1.StreamController();
286
- this.errorController = new stream_controller_1.StreamController();
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 response_1.BinaryContent({
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 completer_1.Completer();
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 room_server_client_1.RoomServerException("container exec session is already closed");
373
+ throw new RoomServerException("container exec session is already closed");
377
374
  }
378
- this.queuedInput.push(new response_1.BinaryContent({
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
- exports.ExecSession = ExecSession;
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 = (0, uuid_1.v4)();
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 response_1.ErrorContent) {
580
- throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
575
+ if (chunk instanceof ErrorContent) {
576
+ throw new RoomServerException(chunk.text, chunk.code);
581
577
  }
582
- if (chunk instanceof response_1.ControlContent) {
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 response_1.BinaryContent)) {
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 room_server_client_1.RoomServerException("containers.exec returned a chunk without a valid channel");
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 room_server_client_1.RoomServerException("containers.exec stream closed before a status was returned");
604
+ throw new RoomServerException("containers.exec stream closed before a status was returned");
609
605
  })
610
606
  .catch((error) => {
611
607
  session.closeError(error);
@@ -618,14 +614,27 @@ class ContainersClient {
618
614
  force: params.force ?? false,
619
615
  });
620
616
  }
621
- async waitForExit(params) {
617
+ async waitForExitStatus(params) {
622
618
  const output = await this.invoke("wait_for_exit", {
623
619
  container_id: params.containerId,
624
620
  });
625
- if (!(output instanceof response_1.JsonContent) || !isRecord(output.json)) {
621
+ if (!(output instanceof JsonContent) || !isRecord(output.json)) {
626
622
  throw this.unexpectedResponseError("wait_for_exit");
627
623
  }
628
- return readIntegerField(output.json, "exit_code", "wait_for_exit");
624
+ const exitCode = readIntegerField(output.json, "exit_code", "wait_for_exit");
625
+ const reason = output.json["reason"];
626
+ const message = output.json["message"];
627
+ const oomKilled = output.json["oom_killed"];
628
+ return {
629
+ exitCode,
630
+ reason: typeof reason === "string" ? reason : undefined,
631
+ message: typeof message === "string" ? message : undefined,
632
+ oomKilled: typeof oomKilled === "boolean" ? oomKilled : undefined,
633
+ };
634
+ }
635
+ async waitForExit(params) {
636
+ const status = await this.waitForExitStatus(params);
637
+ return status.exitCode;
629
638
  }
630
639
  async deleteContainer(params) {
631
640
  await this.invoke("delete_container", {
@@ -633,11 +642,11 @@ class ContainersClient {
633
642
  });
634
643
  }
635
644
  logs(params) {
636
- const requestId = (0, uuid_1.v4)();
637
- const closeInput = new completer_1.Completer();
638
- const progressController = new stream_controller_1.StreamController();
639
- const streamController = new stream_controller_1.StreamController();
640
- const result = new completer_1.Completer();
645
+ const requestId = uuidv4();
646
+ const closeInput = new Completer();
647
+ const progressController = new StreamController();
648
+ const streamController = new StreamController();
649
+ const result = new Completer();
641
650
  let inputClosed = false;
642
651
  const closeInputStream = () => {
643
652
  if (inputClosed) {
@@ -649,7 +658,7 @@ class ContainersClient {
649
658
  }
650
659
  };
651
660
  const inputStream = async function* () {
652
- yield new response_1.BinaryContent({
661
+ yield new BinaryContent({
653
662
  data: new Uint8Array(0),
654
663
  headers: {
655
664
  kind: "start",
@@ -668,10 +677,10 @@ class ContainersClient {
668
677
  })
669
678
  .then(async (stream) => {
670
679
  for await (const chunk of stream) {
671
- if (chunk instanceof response_1.ErrorContent) {
672
- throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
680
+ if (chunk instanceof ErrorContent) {
681
+ throw new RoomServerException(chunk.text, chunk.code);
673
682
  }
674
- if (chunk instanceof response_1.ControlContent) {
683
+ if (chunk instanceof ControlContent) {
675
684
  if (chunk.method === "close") {
676
685
  closeInputStream();
677
686
  progressController.close();
@@ -683,12 +692,12 @@ class ContainersClient {
683
692
  }
684
693
  throw this.unexpectedResponseError("logs");
685
694
  }
686
- if (!(chunk instanceof response_1.BinaryContent)) {
695
+ if (!(chunk instanceof BinaryContent)) {
687
696
  throw this.unexpectedResponseError("logs");
688
697
  }
689
698
  const channel = chunk.headers["channel"];
690
699
  if (typeof channel !== "number") {
691
- throw new room_server_client_1.RoomServerException("containers.logs returned a chunk without a valid channel");
700
+ throw new RoomServerException("containers.logs returned a chunk without a valid channel");
692
701
  }
693
702
  if (channel !== 1) {
694
703
  continue;
@@ -742,10 +751,10 @@ class ContainersClient {
742
751
  };
743
752
  }
744
753
  getBuildLogs(params) {
745
- const requestId = (0, uuid_1.v4)();
746
- const closeInput = new completer_1.Completer();
747
- const streamController = new stream_controller_1.StreamController();
748
- const result = new completer_1.Completer();
754
+ const requestId = uuidv4();
755
+ const closeInput = new Completer();
756
+ const streamController = new StreamController();
757
+ const result = new Completer();
749
758
  let inputClosed = false;
750
759
  const closeInputStream = () => {
751
760
  if (inputClosed) {
@@ -757,7 +766,7 @@ class ContainersClient {
757
766
  }
758
767
  };
759
768
  const inputStream = async function* () {
760
- yield new response_1.BinaryContent({
769
+ yield new BinaryContent({
761
770
  data: new Uint8Array(0),
762
771
  headers: {
763
772
  kind: "start",
@@ -776,10 +785,10 @@ class ContainersClient {
776
785
  })
777
786
  .then(async (stream) => {
778
787
  for await (const chunk of stream) {
779
- if (chunk instanceof response_1.ErrorContent) {
780
- throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
788
+ if (chunk instanceof ErrorContent) {
789
+ throw new RoomServerException(chunk.text, chunk.code);
781
790
  }
782
- if (chunk instanceof response_1.ControlContent) {
791
+ if (chunk instanceof ControlContent) {
783
792
  if (chunk.method === "close") {
784
793
  closeInputStream();
785
794
  streamController.close();
@@ -790,12 +799,12 @@ class ContainersClient {
790
799
  }
791
800
  throw this.unexpectedResponseError("get_build_logs");
792
801
  }
793
- if (!(chunk instanceof response_1.BinaryContent)) {
802
+ if (!(chunk instanceof BinaryContent)) {
794
803
  throw this.unexpectedResponseError("get_build_logs");
795
804
  }
796
805
  const channel = chunk.headers["channel"];
797
806
  if (typeof channel !== "number") {
798
- throw new room_server_client_1.RoomServerException("containers.get_build_logs returned a chunk without a valid channel");
807
+ throw new RoomServerException("containers.get_build_logs returned a chunk without a valid channel");
799
808
  }
800
809
  if (channel === 1) {
801
810
  streamController.add(decodeUtf8(chunk.data, "get_build_logs"));
@@ -857,7 +866,7 @@ class ContainersClient {
857
866
  const output = await this.invoke("list_containers", {
858
867
  all: params?.all,
859
868
  });
860
- if (!(output instanceof response_1.JsonContent) || !isRecord(output.json)) {
869
+ if (!(output instanceof JsonContent) || !isRecord(output.json)) {
861
870
  throw this.unexpectedResponseError("list");
862
871
  }
863
872
  const containersRaw = output.json["containers"];
@@ -888,8 +897,11 @@ class ContainersClient {
888
897
  throw this.unexpectedResponseError("list");
889
898
  }
890
899
  const nameRaw = entry["name"];
900
+ const imageIdRaw = entry["image_id"];
891
901
  const portsRaw = entry["ports"];
892
902
  const serviceIdRaw = entry["service_id"];
903
+ const statsRaw = entry["stats"];
904
+ const exitStatusRaw = entry["exit_status"];
893
905
  if (!Array.isArray(portsRaw) ||
894
906
  !portsRaw.every((port) => {
895
907
  if (!isRecord(port)) {
@@ -906,9 +918,39 @@ class ContainersClient {
906
918
  containerPort: port["container_port"],
907
919
  hostPort: port["host_port"],
908
920
  }));
921
+ let stats;
922
+ if (isRecord(statsRaw)) {
923
+ const cpuUsageNanoCores = statsRaw["cpu_usage_nano_cores"];
924
+ const memoryUsageBytes = statsRaw["memory_usage_bytes"];
925
+ const memoryWorkingSetBytes = statsRaw["memory_working_set_bytes"];
926
+ const timestampNs = statsRaw["timestamp_ns"];
927
+ stats = {
928
+ cpuUsageNanoCores: typeof cpuUsageNanoCores === "number" ? cpuUsageNanoCores : undefined,
929
+ memoryUsageBytes: typeof memoryUsageBytes === "number" ? memoryUsageBytes : undefined,
930
+ memoryWorkingSetBytes: typeof memoryWorkingSetBytes === "number" ? memoryWorkingSetBytes : undefined,
931
+ timestampNs: typeof timestampNs === "number" ? timestampNs : undefined,
932
+ };
933
+ }
934
+ let exitStatus;
935
+ if (isRecord(exitStatusRaw)) {
936
+ const exitCode = exitStatusRaw["exit_code"];
937
+ if (typeof exitCode === "number" &&
938
+ Number.isInteger(exitCode)) {
939
+ const reason = exitStatusRaw["reason"];
940
+ const message = exitStatusRaw["message"];
941
+ const oomKilled = exitStatusRaw["oom_killed"];
942
+ exitStatus = {
943
+ exitCode,
944
+ reason: typeof reason === "string" ? reason : undefined,
945
+ message: typeof message === "string" ? message : undefined,
946
+ oomKilled: typeof oomKilled === "boolean" ? oomKilled : undefined,
947
+ };
948
+ }
949
+ }
909
950
  items.push({
910
951
  id,
911
952
  image,
953
+ imageId: typeof imageIdRaw === "string" ? imageIdRaw : undefined,
912
954
  name: typeof nameRaw === "string" ? nameRaw : undefined,
913
955
  ports,
914
956
  startedBy: {
@@ -918,9 +960,10 @@ class ContainersClient {
918
960
  state,
919
961
  private: privateFlag,
920
962
  serviceId: typeof serviceIdRaw === "string" ? serviceIdRaw : undefined,
963
+ stats,
964
+ exitStatus,
921
965
  });
922
966
  }
923
967
  return items;
924
968
  }
925
969
  }
926
- 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";