@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
@@ -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 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");
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`containers.${operation} returned invalid UTF-8 data`);
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 room_server_client_1.RoomServerException(`containers.${operation} returned an invalid status payload`);
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 room_server_client_1.RoomServerException(`containers.${operation} returned an invalid status payload`);
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 room_server_client_1.RoomServerException(`containers.${operation} returned an invalid status payload`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 room_server_client_1.RoomServerException("containers.build requires at least one tag");
256
+ throw new room_server_client_js_1.RoomServerException("containers.build requires at least one tag");
257
257
  }
258
- yield new response_1.BinaryContent({
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 response_1.BinaryContent({
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 completer_1.Completer();
285
- this.outputController = new stream_controller_1.StreamController();
286
- this.errorController = new stream_controller_1.StreamController();
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 response_1.BinaryContent({
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 completer_1.Completer();
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 room_server_client_1.RoomServerException("container exec session is already closed");
376
+ throw new room_server_client_js_1.RoomServerException("container exec session is already closed");
377
377
  }
378
- this.queuedInput.push(new response_1.BinaryContent({
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 room_server_client_1.RoomServerException(`unexpected return type from containers.${operation}`);
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.JsonContent) || !isRecord(output.json)) {
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 response_1.ErrorContent) {
580
- throw new room_server_client_1.RoomServerException(chunk.text, chunk.code);
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 response_1.ControlContent) {
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 response_1.BinaryContent)) {
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 room_server_client_1.RoomServerException("containers.exec returned a chunk without a valid channel");
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 room_server_client_1.RoomServerException("containers.exec stream closed before a status was returned");
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);
@@ -618,14 +618,27 @@ class ContainersClient {
618
618
  force: params.force ?? false,
619
619
  });
620
620
  }
621
- async waitForExit(params) {
621
+ async waitForExitStatus(params) {
622
622
  const output = await this.invoke("wait_for_exit", {
623
623
  container_id: params.containerId,
624
624
  });
625
- if (!(output instanceof response_1.JsonContent) || !isRecord(output.json)) {
625
+ if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
626
626
  throw this.unexpectedResponseError("wait_for_exit");
627
627
  }
628
- return readIntegerField(output.json, "exit_code", "wait_for_exit");
628
+ const exitCode = readIntegerField(output.json, "exit_code", "wait_for_exit");
629
+ const reason = output.json["reason"];
630
+ const message = output.json["message"];
631
+ const oomKilled = output.json["oom_killed"];
632
+ return {
633
+ exitCode,
634
+ reason: typeof reason === "string" ? reason : undefined,
635
+ message: typeof message === "string" ? message : undefined,
636
+ oomKilled: typeof oomKilled === "boolean" ? oomKilled : undefined,
637
+ };
638
+ }
639
+ async waitForExit(params) {
640
+ const status = await this.waitForExitStatus(params);
641
+ return status.exitCode;
629
642
  }
630
643
  async deleteContainer(params) {
631
644
  await this.invoke("delete_container", {
@@ -634,10 +647,10 @@ class ContainersClient {
634
647
  }
635
648
  logs(params) {
636
649
  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();
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();
641
654
  let inputClosed = false;
642
655
  const closeInputStream = () => {
643
656
  if (inputClosed) {
@@ -649,7 +662,7 @@ class ContainersClient {
649
662
  }
650
663
  };
651
664
  const inputStream = async function* () {
652
- yield new response_1.BinaryContent({
665
+ yield new response_js_1.BinaryContent({
653
666
  data: new Uint8Array(0),
654
667
  headers: {
655
668
  kind: "start",
@@ -668,10 +681,10 @@ class ContainersClient {
668
681
  })
669
682
  .then(async (stream) => {
670
683
  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);
684
+ if (chunk instanceof response_js_1.ErrorContent) {
685
+ throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
673
686
  }
674
- if (chunk instanceof response_1.ControlContent) {
687
+ if (chunk instanceof response_js_1.ControlContent) {
675
688
  if (chunk.method === "close") {
676
689
  closeInputStream();
677
690
  progressController.close();
@@ -683,12 +696,12 @@ class ContainersClient {
683
696
  }
684
697
  throw this.unexpectedResponseError("logs");
685
698
  }
686
- if (!(chunk instanceof response_1.BinaryContent)) {
699
+ if (!(chunk instanceof response_js_1.BinaryContent)) {
687
700
  throw this.unexpectedResponseError("logs");
688
701
  }
689
702
  const channel = chunk.headers["channel"];
690
703
  if (typeof channel !== "number") {
691
- throw new room_server_client_1.RoomServerException("containers.logs returned a chunk without a valid channel");
704
+ throw new room_server_client_js_1.RoomServerException("containers.logs returned a chunk without a valid channel");
692
705
  }
693
706
  if (channel !== 1) {
694
707
  continue;
@@ -743,9 +756,9 @@ class ContainersClient {
743
756
  }
744
757
  getBuildLogs(params) {
745
758
  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();
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();
749
762
  let inputClosed = false;
750
763
  const closeInputStream = () => {
751
764
  if (inputClosed) {
@@ -757,7 +770,7 @@ class ContainersClient {
757
770
  }
758
771
  };
759
772
  const inputStream = async function* () {
760
- yield new response_1.BinaryContent({
773
+ yield new response_js_1.BinaryContent({
761
774
  data: new Uint8Array(0),
762
775
  headers: {
763
776
  kind: "start",
@@ -776,10 +789,10 @@ class ContainersClient {
776
789
  })
777
790
  .then(async (stream) => {
778
791
  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);
792
+ if (chunk instanceof response_js_1.ErrorContent) {
793
+ throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
781
794
  }
782
- if (chunk instanceof response_1.ControlContent) {
795
+ if (chunk instanceof response_js_1.ControlContent) {
783
796
  if (chunk.method === "close") {
784
797
  closeInputStream();
785
798
  streamController.close();
@@ -790,12 +803,12 @@ class ContainersClient {
790
803
  }
791
804
  throw this.unexpectedResponseError("get_build_logs");
792
805
  }
793
- if (!(chunk instanceof response_1.BinaryContent)) {
806
+ if (!(chunk instanceof response_js_1.BinaryContent)) {
794
807
  throw this.unexpectedResponseError("get_build_logs");
795
808
  }
796
809
  const channel = chunk.headers["channel"];
797
810
  if (typeof channel !== "number") {
798
- throw new room_server_client_1.RoomServerException("containers.get_build_logs returned a chunk without a valid channel");
811
+ throw new room_server_client_js_1.RoomServerException("containers.get_build_logs returned a chunk without a valid channel");
799
812
  }
800
813
  if (channel === 1) {
801
814
  streamController.add(decodeUtf8(chunk.data, "get_build_logs"));
@@ -857,7 +870,7 @@ class ContainersClient {
857
870
  const output = await this.invoke("list_containers", {
858
871
  all: params?.all,
859
872
  });
860
- if (!(output instanceof response_1.JsonContent) || !isRecord(output.json)) {
873
+ if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
861
874
  throw this.unexpectedResponseError("list");
862
875
  }
863
876
  const containersRaw = output.json["containers"];
@@ -888,8 +901,11 @@ class ContainersClient {
888
901
  throw this.unexpectedResponseError("list");
889
902
  }
890
903
  const nameRaw = entry["name"];
904
+ const imageIdRaw = entry["image_id"];
891
905
  const portsRaw = entry["ports"];
892
906
  const serviceIdRaw = entry["service_id"];
907
+ const statsRaw = entry["stats"];
908
+ const exitStatusRaw = entry["exit_status"];
893
909
  if (!Array.isArray(portsRaw) ||
894
910
  !portsRaw.every((port) => {
895
911
  if (!isRecord(port)) {
@@ -906,9 +922,39 @@ class ContainersClient {
906
922
  containerPort: port["container_port"],
907
923
  hostPort: port["host_port"],
908
924
  }));
925
+ let stats;
926
+ if (isRecord(statsRaw)) {
927
+ const cpuUsageNanoCores = statsRaw["cpu_usage_nano_cores"];
928
+ const memoryUsageBytes = statsRaw["memory_usage_bytes"];
929
+ const memoryWorkingSetBytes = statsRaw["memory_working_set_bytes"];
930
+ const timestampNs = statsRaw["timestamp_ns"];
931
+ stats = {
932
+ cpuUsageNanoCores: typeof cpuUsageNanoCores === "number" ? cpuUsageNanoCores : undefined,
933
+ memoryUsageBytes: typeof memoryUsageBytes === "number" ? memoryUsageBytes : undefined,
934
+ memoryWorkingSetBytes: typeof memoryWorkingSetBytes === "number" ? memoryWorkingSetBytes : undefined,
935
+ timestampNs: typeof timestampNs === "number" ? timestampNs : undefined,
936
+ };
937
+ }
938
+ let exitStatus;
939
+ if (isRecord(exitStatusRaw)) {
940
+ const exitCode = exitStatusRaw["exit_code"];
941
+ if (typeof exitCode === "number" &&
942
+ Number.isInteger(exitCode)) {
943
+ const reason = exitStatusRaw["reason"];
944
+ const message = exitStatusRaw["message"];
945
+ const oomKilled = exitStatusRaw["oom_killed"];
946
+ exitStatus = {
947
+ exitCode,
948
+ reason: typeof reason === "string" ? reason : undefined,
949
+ message: typeof message === "string" ? message : undefined,
950
+ oomKilled: typeof oomKilled === "boolean" ? oomKilled : undefined,
951
+ };
952
+ }
953
+ }
909
954
  items.push({
910
955
  id,
911
956
  image,
957
+ imageId: typeof imageIdRaw === "string" ? imageIdRaw : undefined,
912
958
  name: typeof nameRaw === "string" ? nameRaw : undefined,
913
959
  ports,
914
960
  startedBy: {
@@ -918,6 +964,8 @@ class ContainersClient {
918
964
  state,
919
965
  private: privateFlag,
920
966
  serviceId: typeof serviceIdRaw === "string" ? serviceIdRaw : undefined,
967
+ stats,
968
+ exitStatus,
921
969
  });
922
970
  }
923
971
  return items;
@@ -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";