@withgateway/sdk 0.2.3 → 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 (62) hide show
  1. package/dist/cli.js +13267 -5869
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +13272 -5874
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/files/index.js +83 -31
  6. package/dist/files/index.js.map +1 -1
  7. package/dist/files/index.mjs +79 -28
  8. package/dist/files/index.mjs.map +1 -1
  9. package/dist/hooks/index.d.mts +1 -0
  10. package/dist/hooks/index.d.ts +1 -0
  11. package/dist/hooks/index.js +4355 -0
  12. package/dist/hooks/index.js.map +1 -0
  13. package/dist/hooks/index.mjs +4243 -0
  14. package/dist/hooks/index.mjs.map +1 -0
  15. package/dist/{index-Dpo-t8iO.d.ts → index-1xnxt0Cc.d.ts} +58 -2
  16. package/dist/index-B0R3IgsV.d.mts +1279 -0
  17. package/dist/index-B0R3IgsV.d.ts +1279 -0
  18. package/dist/{index-B5HUQQDE.d.mts → index-C1wDEwH4.d.mts} +58 -2
  19. package/dist/index.d.mts +4 -3
  20. package/dist/index.d.ts +4 -3
  21. package/dist/index.js +6698 -1606
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +6793 -1713
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/traces/index.js +72 -20
  26. package/dist/traces/index.js.map +1 -1
  27. package/dist/traces/index.mjs +68 -17
  28. package/dist/traces/index.mjs.map +1 -1
  29. package/dist/tracing/index.d.mts +1 -1
  30. package/dist/tracing/index.d.ts +1 -1
  31. package/dist/tracing/index.js +47 -3
  32. package/dist/tracing/index.js.map +1 -1
  33. package/dist/tracing/index.mjs +42 -2
  34. package/dist/tracing/index.mjs.map +1 -1
  35. package/dist/worlds/index.d.mts +390 -27
  36. package/dist/worlds/index.d.ts +390 -27
  37. package/dist/worlds/index.js +2291 -366
  38. package/dist/worlds/index.js.map +1 -1
  39. package/dist/worlds/index.mjs +2281 -356
  40. package/dist/worlds/index.mjs.map +1 -1
  41. package/package.json +7 -1
  42. package/runtime/gatewaysdk/environment/_bundle.py +14 -24
  43. package/runtime/gatewaysdk/environment/_materialize.py +3 -3
  44. package/runtime/gatewaysdk/environment/schema/api.py +153 -20
  45. package/runtime/gatewaysdk/environment/schema/compiler.py +14 -0
  46. package/runtime/gatewaysdk/environment/schema/data.py +21 -19
  47. package/runtime/gatewaysdk/environment/schema/grading.py +225 -0
  48. package/runtime/gatewaysdk/environment/schema/host.py +171 -535
  49. package/runtime/gatewaysdk/environment/schema/ingest.py +3 -11
  50. package/runtime/gatewaysdk/environment/schema/local.py +32 -126
  51. package/runtime/gatewaysdk/environment/schema/platform.py +14 -22
  52. package/runtime/gatewaysdk/environment/schema/proof.py +237 -0
  53. package/runtime/gatewaysdk/environment/schema/runtime.py +686 -0
  54. package/runtime/gatewaysdk/environment/schema/skill.py +1 -0
  55. package/runtime/gatewaysdk/environment/schema/skills/hooks-getting-started/SKILL.md +156 -0
  56. package/runtime/gatewaysdk/environment/schema/snapshot.py +6 -5
  57. package/runtime/gatewaysdk/environment/schema/tasks.py +12 -2
  58. package/runtime/gatewaysdk/environment/schema/tools_world.py +75 -23
  59. package/runtime/gatewaysdk/environment/schema/verbs.py +136 -0
  60. package/runtime/gatewaysdk/environment/schema/workers.py +44 -13
  61. package/runtime/gatewaysdk/environment/world.py +391 -0
  62. package/skills/hooks-getting-started/SKILL.md +156 -0
@@ -60,17 +60,65 @@ var init_tasks = __esm({
60
60
  }
61
61
  });
62
62
 
63
+ // src/worlds/taskSessions.ts
64
+ var init_taskSessions = __esm({
65
+ "src/worlds/taskSessions.ts"() {
66
+ "use strict";
67
+ init_worlds();
68
+ init_browser();
69
+ init_session();
70
+ }
71
+ });
72
+
73
+ // src/worlds/evals.ts
74
+ var init_evals = __esm({
75
+ "src/worlds/evals.ts"() {
76
+ "use strict";
77
+ init_worlds();
78
+ }
79
+ });
80
+
81
+ // src/worlds/taskRun.ts
82
+ var import_node_crypto2, fs, path;
83
+ var init_taskRun = __esm({
84
+ "src/worlds/taskRun.ts"() {
85
+ "use strict";
86
+ import_node_crypto2 = require("crypto");
87
+ fs = __toESM(require("fs"));
88
+ path = __toESM(require("path"));
89
+ init_browser();
90
+ init_evals();
91
+ init_session();
92
+ init_taskSessions();
93
+ }
94
+ });
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
+
63
110
  // src/worlds/hub.ts
64
- var import_node_crypto2, import_node_zlib, fs, path, META_RELPATH;
111
+ var import_node_crypto4, import_node_zlib, fs3, path3, META_RELPATH;
65
112
  var init_hub = __esm({
66
113
  "src/worlds/hub.ts"() {
67
114
  "use strict";
68
- import_node_crypto2 = require("crypto");
115
+ import_node_crypto4 = require("crypto");
69
116
  import_node_zlib = require("zlib");
70
- fs = __toESM(require("fs"));
71
- path = __toESM(require("path"));
117
+ fs3 = __toESM(require("fs"));
118
+ path3 = __toESM(require("path"));
72
119
  init_worlds();
73
- META_RELPATH = path.join(".gateway", ".env-metadata.json");
120
+ init_worldDir();
121
+ META_RELPATH = path3.join(".gateway", ".env-metadata.json");
74
122
  }
75
123
  });
76
124
 
@@ -99,14 +147,15 @@ var init_json = __esm({
99
147
  });
100
148
 
101
149
  // src/worlds/transforms.ts
102
- var import_node_crypto3, 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;
103
151
  var init_transforms = __esm({
104
152
  "src/worlds/transforms.ts"() {
105
153
  "use strict";
106
- import_node_crypto3 = require("crypto");
154
+ import_node_crypto5 = require("crypto");
107
155
  init_json();
108
- WHITESPACE_EDGES = /^[ \t\n\r\f\v]+|[ \t\n\r\f\v]+$/g;
109
- 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");
110
159
  NOT_DIGIT = /[^0-9]/g;
111
160
  STRIP_PREFIX = "strip_prefix";
112
161
  trim = (value) => value.replace(WHITESPACE_EDGES, "");
@@ -118,7 +167,7 @@ var init_transforms = __esm({
118
167
  const at = value.lastIndexOf("@");
119
168
  return at === -1 ? "" : value.slice(at + 1).toLowerCase();
120
169
  };
121
- hex = (algorithm, value) => (0, import_node_crypto3.createHash)(algorithm).update(value, "utf8").digest("hex");
170
+ hex = (algorithm, value) => (0, import_node_crypto5.createHash)(algorithm).update(value, "utf8").digest("hex");
122
171
  SIMPLE = {
123
172
  lower: (value) => value.toLowerCase(),
124
173
  upper: (value) => value.toUpperCase(),
@@ -138,11 +187,11 @@ var init_transforms = __esm({
138
187
  });
139
188
 
140
189
  // src/worlds/redaction.ts
141
- var import_node_crypto4;
190
+ var import_node_crypto6;
142
191
  var init_redaction = __esm({
143
192
  "src/worlds/redaction.ts"() {
144
193
  "use strict";
145
- import_node_crypto4 = require("crypto");
194
+ import_node_crypto6 = require("crypto");
146
195
  init_json();
147
196
  init_transforms();
148
197
  }
@@ -165,13 +214,13 @@ var init_migrate = __esm({
165
214
  });
166
215
 
167
216
  // src/worlds/ingest.ts
168
- var fs2, os, path2;
217
+ var fs4, os, path4;
169
218
  var init_ingest = __esm({
170
219
  "src/worlds/ingest.ts"() {
171
220
  "use strict";
172
- fs2 = __toESM(require("fs"));
221
+ fs4 = __toESM(require("fs"));
173
222
  os = __toESM(require("os"));
174
- path2 = __toESM(require("path"));
223
+ path4 = __toESM(require("path"));
175
224
  init_worlds();
176
225
  }
177
226
  });
@@ -188,9 +237,9 @@ function resolveEnv(options) {
188
237
  }
189
238
  return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
190
239
  }
191
- async function apiRequest(options, method, path4, body) {
240
+ async function apiRequest(options, method, path6, body) {
192
241
  const { host, publicKey, secretKey } = resolveEnv(options);
193
- const res = await fetch(`${host}${path4}`, {
242
+ const res = await fetch(`${host}${path6}`, {
194
243
  method,
195
244
  headers: {
196
245
  "content-type": "application/json",
@@ -199,7 +248,7 @@ async function apiRequest(options, method, path4, body) {
199
248
  ...body === void 0 ? {} : { body: JSON.stringify(body) }
200
249
  });
201
250
  const text = await res.text();
202
- if (!res.ok) throw new ApiError(res.status, method, path4, text.slice(0, 400));
251
+ if (!res.ok) throw new ApiError(res.status, method, path6, text.slice(0, 400));
203
252
  return JSON.parse(text);
204
253
  }
205
254
  var ApiError;
@@ -208,6 +257,9 @@ var init_worlds = __esm({
208
257
  "use strict";
209
258
  init_session();
210
259
  init_tasks();
260
+ init_taskSessions();
261
+ init_taskRun();
262
+ init_evals();
211
263
  init_browser();
212
264
  init_hub();
213
265
  init_validate();
@@ -218,8 +270,8 @@ var init_worlds = __esm({
218
270
  init_migrate();
219
271
  init_ingest();
220
272
  ApiError = class extends Error {
221
- constructor(status, method, path4, body) {
222
- super(`${method} ${path4} -> ${status}: ${body}`);
273
+ constructor(status, method, path6, body) {
274
+ super(`${method} ${path6} -> ${status}: ${body}`);
223
275
  this.status = status;
224
276
  this.name = "ApiError";
225
277
  }
@@ -251,9 +303,9 @@ __export(files_exports, {
251
303
  uploadFile: () => uploadFile
252
304
  });
253
305
  module.exports = __toCommonJS(files_exports);
254
- var import_node_crypto5 = require("crypto");
255
- var fs3 = __toESM(require("fs"));
256
- var path3 = __toESM(require("path"));
306
+ var import_node_crypto7 = require("crypto");
307
+ var fs5 = __toESM(require("fs"));
308
+ var path5 = __toESM(require("path"));
257
309
  var import_node_stream = require("stream");
258
310
  var import_promises = require("stream/promises");
259
311
  init_worlds();
@@ -302,9 +354,9 @@ async function readFile(options = {}, filePath) {
302
354
  async function downloadFile(options = {}, filePath, outPath, onProgress) {
303
355
  const file = await getFile(options, filePath);
304
356
  const res = await openDownload(file.url);
305
- fs3.mkdirSync(path3.dirname(path3.resolve(outPath)), { recursive: true });
357
+ fs5.mkdirSync(path5.dirname(path5.resolve(outPath)), { recursive: true });
306
358
  const source = import_node_stream.Readable.fromWeb(res.body);
307
- await (0, import_promises.pipeline)(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs3.createWriteStream(outPath));
359
+ await (0, import_promises.pipeline)(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs5.createWriteStream(outPath));
308
360
  return { ...file, out: outPath };
309
361
  }
310
362
  async function requestUpload(options = {}, body) {
@@ -314,8 +366,8 @@ async function confirmUpload(options = {}, fileId, ok = true) {
314
366
  return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
315
367
  }
316
368
  async function sha256Base64(localPath) {
317
- const hash = (0, import_node_crypto5.createHash)("sha256");
318
- for await (const chunk of fs3.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);
319
371
  return hash.digest("base64");
320
372
  }
321
373
  var CONTENT_TYPES = {
@@ -351,7 +403,7 @@ var CONTENT_TYPES = {
351
403
  ".mp4": "video/mp4"
352
404
  };
353
405
  function contentTypeFor(name) {
354
- return CONTENT_TYPES[path3.extname(name).toLowerCase()] ?? "application/octet-stream";
406
+ return CONTENT_TYPES[path5.extname(name).toLowerCase()] ?? "application/octet-stream";
355
407
  }
356
408
  function counting(report) {
357
409
  let seen = 0;
@@ -378,7 +430,7 @@ async function putPresigned(uploadUrl, body, headers) {
378
430
  if (!res.ok) throw new Error(`upload failed: storage answered HTTP ${res.status}: ${(await res.text()).slice(0, 300)}`);
379
431
  }
380
432
  async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
381
- const stat = fs3.statSync(localPath);
433
+ const stat = fs5.statSync(localPath);
382
434
  if (!stat.isFile()) throw new Error(`${localPath} is not a file`);
383
435
  if (stat.size === 0) throw new Error(`${localPath} is empty; the drive refuses zero-byte uploads`);
384
436
  const contentType = upload.contentType ?? contentTypeFor(localPath);
@@ -386,7 +438,7 @@ async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
386
438
  const target = drivePath(targetPath);
387
439
  const granted = await requestUpload(options, { path: target, contentLength: stat.size, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
388
440
  try {
389
- const stream = fs3.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
441
+ const stream = fs5.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
390
442
  await putPresigned(granted.uploadUrl, import_node_stream.Readable.toWeb(stream), { contentType, contentLength: stat.size, sha256 });
391
443
  } catch (error) {
392
444
  await confirmUpload(options, granted.fileId, false).catch(() => void 0);
@@ -399,7 +451,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
399
451
  if (!bytes.length) throw new Error("nothing to upload: the content is empty");
400
452
  const target = drivePath(targetPath);
401
453
  const contentType = upload.contentType ?? contentTypeFor(target);
402
- const sha256 = (0, import_node_crypto5.createHash)("sha256").update(bytes).digest("base64");
454
+ const sha256 = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("base64");
403
455
  const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
404
456
  try {
405
457
  await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256 });