@withgateway/sdk 0.2.4 → 0.2.5

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 (46) hide show
  1. package/dist/cli.js +1798 -1713
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +2412 -2327
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/files/index.js +47 -31
  6. package/dist/files/index.js.map +1 -1
  7. package/dist/files/index.mjs +43 -27
  8. package/dist/files/index.mjs.map +1 -1
  9. package/dist/index.d.mts +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +390 -287
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +375 -271
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/traces/index.js +36 -20
  16. package/dist/traces/index.js.map +1 -1
  17. package/dist/traces/index.mjs +32 -16
  18. package/dist/traces/index.mjs.map +1 -1
  19. package/dist/tracing/index.js +2 -1
  20. package/dist/tracing/index.js.map +1 -1
  21. package/dist/tracing/index.mjs +2 -1
  22. package/dist/tracing/index.mjs.map +1 -1
  23. package/dist/worlds/index.d.mts +26 -22
  24. package/dist/worlds/index.d.ts +26 -22
  25. package/dist/worlds/index.js +307 -203
  26. package/dist/worlds/index.js.map +1 -1
  27. package/dist/worlds/index.mjs +297 -193
  28. package/dist/worlds/index.mjs.map +1 -1
  29. package/package.json +2 -1
  30. package/runtime/gatewaysdk/environment/_bundle.py +14 -24
  31. package/runtime/gatewaysdk/environment/schema/api.py +37 -18
  32. package/runtime/gatewaysdk/environment/schema/data.py +21 -19
  33. package/runtime/gatewaysdk/environment/schema/grading.py +225 -0
  34. package/runtime/gatewaysdk/environment/schema/host.py +156 -546
  35. package/runtime/gatewaysdk/environment/schema/ingest.py +3 -11
  36. package/runtime/gatewaysdk/environment/schema/local.py +32 -126
  37. package/runtime/gatewaysdk/environment/schema/platform.py +14 -22
  38. package/runtime/gatewaysdk/environment/schema/proof.py +237 -0
  39. package/runtime/gatewaysdk/environment/schema/runtime.py +686 -0
  40. package/runtime/gatewaysdk/environment/schema/skill.py +1 -0
  41. package/runtime/gatewaysdk/environment/schema/skills/hooks-getting-started/SKILL.md +6 -4
  42. package/runtime/gatewaysdk/environment/schema/tools_world.py +75 -23
  43. package/runtime/gatewaysdk/environment/schema/verbs.py +136 -0
  44. package/runtime/gatewaysdk/environment/schema/workers.py +14 -0
  45. package/runtime/gatewaysdk/environment/world.py +391 -0
  46. package/skills/hooks-getting-started/SKILL.md +6 -4
@@ -93,17 +93,32 @@ var init_taskRun = __esm({
93
93
  }
94
94
  });
95
95
 
96
+ // src/worlds/worldDir.ts
97
+ var import_node_crypto3, fs2, path2, CONNECTOR_SPEC, WORLD_SCHEMA_MARKERS, WORLD_ROOT_MARKERS;
98
+ var init_worldDir = __esm({
99
+ "src/worlds/worldDir.ts"() {
100
+ "use strict";
101
+ import_node_crypto3 = require("crypto");
102
+ fs2 = __toESM(require("fs"));
103
+ path2 = __toESM(require("path"));
104
+ CONNECTOR_SPEC = "connector.toml";
105
+ WORLD_SCHEMA_MARKERS = ["schema/world.json", "schema/runtime.json", "schema/lock.json"];
106
+ WORLD_ROOT_MARKERS = [CONNECTOR_SPEC, ...WORLD_SCHEMA_MARKERS];
107
+ }
108
+ });
109
+
96
110
  // src/worlds/hub.ts
97
- var import_node_crypto3, import_node_zlib, fs2, path2, META_RELPATH;
111
+ var import_node_crypto4, import_node_zlib, fs3, path3, META_RELPATH;
98
112
  var init_hub = __esm({
99
113
  "src/worlds/hub.ts"() {
100
114
  "use strict";
101
- import_node_crypto3 = require("crypto");
115
+ import_node_crypto4 = require("crypto");
102
116
  import_node_zlib = require("zlib");
103
- fs2 = __toESM(require("fs"));
104
- path2 = __toESM(require("path"));
117
+ fs3 = __toESM(require("fs"));
118
+ path3 = __toESM(require("path"));
105
119
  init_worlds();
106
- META_RELPATH = path2.join(".gateway", ".env-metadata.json");
120
+ init_worldDir();
121
+ META_RELPATH = path3.join(".gateway", ".env-metadata.json");
107
122
  }
108
123
  });
109
124
 
@@ -132,14 +147,15 @@ var init_json = __esm({
132
147
  });
133
148
 
134
149
  // src/worlds/transforms.ts
135
- var import_node_crypto4, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, hex, SIMPLE, TRANSFORMS;
150
+ var import_node_crypto5, WHITESPACE, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, hex, SIMPLE, TRANSFORMS;
136
151
  var init_transforms = __esm({
137
152
  "src/worlds/transforms.ts"() {
138
153
  "use strict";
139
- import_node_crypto4 = require("crypto");
154
+ import_node_crypto5 = require("crypto");
140
155
  init_json();
141
- WHITESPACE_EDGES = /^[ \t\n\r\f\v]+|[ \t\n\r\f\v]+$/g;
142
- WHITESPACE_RUN = /[ \t\n\r\f\v]+/g;
156
+ WHITESPACE = " \n\r\f\v";
157
+ WHITESPACE_EDGES = new RegExp(`^[${WHITESPACE}]+|[${WHITESPACE}]+$`, "g");
158
+ WHITESPACE_RUN = new RegExp(`[${WHITESPACE}]+`, "g");
143
159
  NOT_DIGIT = /[^0-9]/g;
144
160
  STRIP_PREFIX = "strip_prefix";
145
161
  trim = (value) => value.replace(WHITESPACE_EDGES, "");
@@ -151,7 +167,7 @@ var init_transforms = __esm({
151
167
  const at = value.lastIndexOf("@");
152
168
  return at === -1 ? "" : value.slice(at + 1).toLowerCase();
153
169
  };
154
- hex = (algorithm, value) => (0, import_node_crypto4.createHash)(algorithm).update(value, "utf8").digest("hex");
170
+ hex = (algorithm, value) => (0, import_node_crypto5.createHash)(algorithm).update(value, "utf8").digest("hex");
155
171
  SIMPLE = {
156
172
  lower: (value) => value.toLowerCase(),
157
173
  upper: (value) => value.toUpperCase(),
@@ -171,11 +187,11 @@ var init_transforms = __esm({
171
187
  });
172
188
 
173
189
  // src/worlds/redaction.ts
174
- var import_node_crypto5;
190
+ var import_node_crypto6;
175
191
  var init_redaction = __esm({
176
192
  "src/worlds/redaction.ts"() {
177
193
  "use strict";
178
- import_node_crypto5 = require("crypto");
194
+ import_node_crypto6 = require("crypto");
179
195
  init_json();
180
196
  init_transforms();
181
197
  }
@@ -198,13 +214,13 @@ var init_migrate = __esm({
198
214
  });
199
215
 
200
216
  // src/worlds/ingest.ts
201
- var fs3, os, path3;
217
+ var fs4, os, path4;
202
218
  var init_ingest = __esm({
203
219
  "src/worlds/ingest.ts"() {
204
220
  "use strict";
205
- fs3 = __toESM(require("fs"));
221
+ fs4 = __toESM(require("fs"));
206
222
  os = __toESM(require("os"));
207
- path3 = __toESM(require("path"));
223
+ path4 = __toESM(require("path"));
208
224
  init_worlds();
209
225
  }
210
226
  });
@@ -221,9 +237,9 @@ function resolveEnv(options) {
221
237
  }
222
238
  return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
223
239
  }
224
- async function apiRequest(options, method, path5, body) {
240
+ async function apiRequest(options, method, path6, body) {
225
241
  const { host, publicKey, secretKey } = resolveEnv(options);
226
- const res = await fetch(`${host}${path5}`, {
242
+ const res = await fetch(`${host}${path6}`, {
227
243
  method,
228
244
  headers: {
229
245
  "content-type": "application/json",
@@ -232,7 +248,7 @@ async function apiRequest(options, method, path5, body) {
232
248
  ...body === void 0 ? {} : { body: JSON.stringify(body) }
233
249
  });
234
250
  const text = await res.text();
235
- if (!res.ok) throw new ApiError(res.status, method, path5, text.slice(0, 400));
251
+ if (!res.ok) throw new ApiError(res.status, method, path6, text.slice(0, 400));
236
252
  return JSON.parse(text);
237
253
  }
238
254
  var ApiError;
@@ -254,8 +270,8 @@ var init_worlds = __esm({
254
270
  init_migrate();
255
271
  init_ingest();
256
272
  ApiError = class extends Error {
257
- constructor(status, method, path5, body) {
258
- super(`${method} ${path5} -> ${status}: ${body}`);
273
+ constructor(status, method, path6, body) {
274
+ super(`${method} ${path6} -> ${status}: ${body}`);
259
275
  this.status = status;
260
276
  this.name = "ApiError";
261
277
  }
@@ -287,9 +303,9 @@ __export(files_exports, {
287
303
  uploadFile: () => uploadFile
288
304
  });
289
305
  module.exports = __toCommonJS(files_exports);
290
- var import_node_crypto6 = require("crypto");
291
- var fs4 = __toESM(require("fs"));
292
- var path4 = __toESM(require("path"));
306
+ var import_node_crypto7 = require("crypto");
307
+ var fs5 = __toESM(require("fs"));
308
+ var path5 = __toESM(require("path"));
293
309
  var import_node_stream = require("stream");
294
310
  var import_promises = require("stream/promises");
295
311
  init_worlds();
@@ -338,9 +354,9 @@ async function readFile(options = {}, filePath) {
338
354
  async function downloadFile(options = {}, filePath, outPath, onProgress) {
339
355
  const file = await getFile(options, filePath);
340
356
  const res = await openDownload(file.url);
341
- fs4.mkdirSync(path4.dirname(path4.resolve(outPath)), { recursive: true });
357
+ fs5.mkdirSync(path5.dirname(path5.resolve(outPath)), { recursive: true });
342
358
  const source = import_node_stream.Readable.fromWeb(res.body);
343
- await (0, import_promises.pipeline)(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs4.createWriteStream(outPath));
359
+ await (0, import_promises.pipeline)(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs5.createWriteStream(outPath));
344
360
  return { ...file, out: outPath };
345
361
  }
346
362
  async function requestUpload(options = {}, body) {
@@ -350,8 +366,8 @@ async function confirmUpload(options = {}, fileId, ok = true) {
350
366
  return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
351
367
  }
352
368
  async function sha256Base64(localPath) {
353
- const hash = (0, import_node_crypto6.createHash)("sha256");
354
- for await (const chunk of fs4.createReadStream(localPath)) hash.update(chunk);
369
+ const hash = (0, import_node_crypto7.createHash)("sha256");
370
+ for await (const chunk of fs5.createReadStream(localPath)) hash.update(chunk);
355
371
  return hash.digest("base64");
356
372
  }
357
373
  var CONTENT_TYPES = {
@@ -387,7 +403,7 @@ var CONTENT_TYPES = {
387
403
  ".mp4": "video/mp4"
388
404
  };
389
405
  function contentTypeFor(name) {
390
- return CONTENT_TYPES[path4.extname(name).toLowerCase()] ?? "application/octet-stream";
406
+ return CONTENT_TYPES[path5.extname(name).toLowerCase()] ?? "application/octet-stream";
391
407
  }
392
408
  function counting(report) {
393
409
  let seen = 0;
@@ -414,7 +430,7 @@ async function putPresigned(uploadUrl, body, headers) {
414
430
  if (!res.ok) throw new Error(`upload failed: storage answered HTTP ${res.status}: ${(await res.text()).slice(0, 300)}`);
415
431
  }
416
432
  async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
417
- const stat = fs4.statSync(localPath);
433
+ const stat = fs5.statSync(localPath);
418
434
  if (!stat.isFile()) throw new Error(`${localPath} is not a file`);
419
435
  if (stat.size === 0) throw new Error(`${localPath} is empty; the drive refuses zero-byte uploads`);
420
436
  const contentType = upload.contentType ?? contentTypeFor(localPath);
@@ -422,7 +438,7 @@ async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
422
438
  const target = drivePath(targetPath);
423
439
  const granted = await requestUpload(options, { path: target, contentLength: stat.size, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
424
440
  try {
425
- const stream = fs4.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
441
+ const stream = fs5.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
426
442
  await putPresigned(granted.uploadUrl, import_node_stream.Readable.toWeb(stream), { contentType, contentLength: stat.size, sha256 });
427
443
  } catch (error) {
428
444
  await confirmUpload(options, granted.fileId, false).catch(() => void 0);
@@ -435,7 +451,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
435
451
  if (!bytes.length) throw new Error("nothing to upload: the content is empty");
436
452
  const target = drivePath(targetPath);
437
453
  const contentType = upload.contentType ?? contentTypeFor(target);
438
- const sha256 = (0, import_node_crypto6.createHash)("sha256").update(bytes).digest("base64");
454
+ const sha256 = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("base64");
439
455
  const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
440
456
  try {
441
457
  await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256 });