@withgateway/sdk 0.2.4 → 0.2.6

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 (85) hide show
  1. package/dist/cli.js +4304 -2381
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +4266 -2343
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/files/index.js +56 -31
  6. package/dist/files/index.js.map +1 -1
  7. package/dist/files/index.mjs +52 -27
  8. package/dist/files/index.mjs.map +1 -1
  9. package/dist/hooks/index.d.mts +1 -1
  10. package/dist/hooks/index.d.ts +1 -1
  11. package/dist/hooks/index.js +280 -8
  12. package/dist/hooks/index.js.map +1 -1
  13. package/dist/hooks/index.mjs +272 -8
  14. package/dist/hooks/index.mjs.map +1 -1
  15. package/dist/{index-1xnxt0Cc.d.ts → index-BO2SNSgy.d.ts} +12 -1
  16. package/dist/{index-B0R3IgsV.d.mts → index-BaKu5ZSU.d.mts} +124 -2
  17. package/dist/{index-B0R3IgsV.d.ts → index-BaKu5ZSU.d.ts} +124 -2
  18. package/dist/{index-C1wDEwH4.d.mts → index-Cz8Q6Keo.d.mts} +12 -1
  19. package/dist/index.d.mts +4 -4
  20. package/dist/index.d.ts +4 -4
  21. package/dist/index.js +1100 -438
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +1079 -424
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/traces/index.js +45 -20
  26. package/dist/traces/index.js.map +1 -1
  27. package/dist/traces/index.mjs +41 -16
  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 +98 -61
  32. package/dist/tracing/index.js.map +1 -1
  33. package/dist/tracing/index.mjs +98 -61
  34. package/dist/tracing/index.mjs.map +1 -1
  35. package/dist/worlds/index.d.mts +179 -25
  36. package/dist/worlds/index.d.ts +179 -25
  37. package/dist/worlds/index.js +639 -284
  38. package/dist/worlds/index.js.map +1 -1
  39. package/dist/worlds/index.mjs +631 -276
  40. package/dist/worlds/index.mjs.map +1 -1
  41. package/package.json +2 -1
  42. package/runtime/gatewaysdk/environment/_bundle.py +15 -25
  43. package/runtime/gatewaysdk/environment/_materialize.py +53 -9
  44. package/runtime/gatewaysdk/environment/_toml.py +13 -0
  45. package/runtime/gatewaysdk/environment/schema/api.py +40 -25
  46. package/runtime/gatewaysdk/environment/schema/batch.py +15 -11
  47. package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +24 -0
  48. package/runtime/gatewaysdk/environment/schema/compiler.py +60 -28
  49. package/runtime/gatewaysdk/environment/schema/conform.py +1 -1
  50. package/runtime/gatewaysdk/environment/schema/connector.py +1 -1
  51. package/runtime/gatewaysdk/environment/schema/connectors/google-drive/readers/merge.ingest.toml +25 -0
  52. package/runtime/gatewaysdk/environment/schema/connectors/google-drive/readers/merge.toml +17 -0
  53. package/runtime/gatewaysdk/environment/schema/data.py +21 -19
  54. package/runtime/gatewaysdk/environment/schema/extract.py +1 -5
  55. package/runtime/gatewaysdk/environment/schema/grading.py +225 -0
  56. package/runtime/gatewaysdk/environment/schema/host.py +156 -546
  57. package/runtime/gatewaysdk/environment/schema/host_surfaces.py +1 -5
  58. package/runtime/gatewaysdk/environment/schema/ingest.py +3 -11
  59. package/runtime/gatewaysdk/environment/schema/local.py +32 -126
  60. package/runtime/gatewaysdk/environment/schema/mapping.py +1 -1
  61. package/runtime/gatewaysdk/environment/schema/platform.py +30 -26
  62. package/runtime/gatewaysdk/environment/schema/proof.py +237 -0
  63. package/runtime/gatewaysdk/environment/schema/redaction.py +1 -1
  64. package/runtime/gatewaysdk/environment/schema/runtime.py +686 -0
  65. package/runtime/gatewaysdk/environment/schema/scaffold.py +9 -2
  66. package/runtime/gatewaysdk/environment/schema/skill.py +1 -0
  67. package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +67 -9
  68. package/runtime/gatewaysdk/environment/schema/skills/hooks-getting-started/SKILL.md +67 -6
  69. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +4 -1
  70. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +11 -11
  71. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +17 -1
  72. package/runtime/gatewaysdk/environment/schema/snapshot.py +1 -5
  73. package/runtime/gatewaysdk/environment/schema/tools_world.py +71 -23
  74. package/runtime/gatewaysdk/environment/schema/ui.py +1 -5
  75. package/runtime/gatewaysdk/environment/schema/verbs.py +136 -0
  76. package/runtime/gatewaysdk/environment/schema/workers.py +14 -0
  77. package/runtime/gatewaysdk/environment/schema/world_tests.py +1 -1
  78. package/runtime/gatewaysdk/environment/world.py +507 -0
  79. package/skills/benchmarks-getting-started/SKILL.md +67 -9
  80. package/skills/connector-schema-authoring/connector-worlds.md +8 -1
  81. package/skills/connector-schema-authoring/world-schema.md +1 -1
  82. package/skills/hooks-getting-started/SKILL.md +67 -6
  83. package/skills/world-data-ingestion/SKILL.md +4 -1
  84. package/skills/worlds-getting-started/SKILL.md +11 -11
  85. package/skills/worlds-getting-started/references/cli-mcp-map.md +17 -1
@@ -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,21 @@ 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"));
224
+ init_worlds();
225
+ }
226
+ });
227
+
228
+ // src/worlds/sandbox.ts
229
+ var init_sandbox = __esm({
230
+ "src/worlds/sandbox.ts"() {
231
+ "use strict";
208
232
  init_worlds();
209
233
  }
210
234
  });
@@ -221,9 +245,9 @@ function resolveEnv(options) {
221
245
  }
222
246
  return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
223
247
  }
224
- async function apiRequest(options, method, path5, body) {
248
+ async function apiRequest(options, method, path6, body) {
225
249
  const { host, publicKey, secretKey } = resolveEnv(options);
226
- const res = await fetch(`${host}${path5}`, {
250
+ const res = await fetch(`${host}${path6}`, {
227
251
  method,
228
252
  headers: {
229
253
  "content-type": "application/json",
@@ -232,7 +256,7 @@ async function apiRequest(options, method, path5, body) {
232
256
  ...body === void 0 ? {} : { body: JSON.stringify(body) }
233
257
  });
234
258
  const text = await res.text();
235
- if (!res.ok) throw new ApiError(res.status, method, path5, text.slice(0, 400));
259
+ if (!res.ok) throw new ApiError(res.status, method, path6, text.slice(0, 400));
236
260
  return JSON.parse(text);
237
261
  }
238
262
  var ApiError;
@@ -253,9 +277,10 @@ var init_worlds = __esm({
253
277
  init_query();
254
278
  init_migrate();
255
279
  init_ingest();
280
+ init_sandbox();
256
281
  ApiError = class extends Error {
257
- constructor(status, method, path5, body) {
258
- super(`${method} ${path5} -> ${status}: ${body}`);
282
+ constructor(status, method, path6, body) {
283
+ super(`${method} ${path6} -> ${status}: ${body}`);
259
284
  this.status = status;
260
285
  this.name = "ApiError";
261
286
  }
@@ -287,9 +312,9 @@ __export(files_exports, {
287
312
  uploadFile: () => uploadFile
288
313
  });
289
314
  module.exports = __toCommonJS(files_exports);
290
- var import_node_crypto6 = require("crypto");
291
- var fs4 = __toESM(require("fs"));
292
- var path4 = __toESM(require("path"));
315
+ var import_node_crypto7 = require("crypto");
316
+ var fs5 = __toESM(require("fs"));
317
+ var path5 = __toESM(require("path"));
293
318
  var import_node_stream = require("stream");
294
319
  var import_promises = require("stream/promises");
295
320
  init_worlds();
@@ -338,9 +363,9 @@ async function readFile(options = {}, filePath) {
338
363
  async function downloadFile(options = {}, filePath, outPath, onProgress) {
339
364
  const file = await getFile(options, filePath);
340
365
  const res = await openDownload(file.url);
341
- fs4.mkdirSync(path4.dirname(path4.resolve(outPath)), { recursive: true });
366
+ fs5.mkdirSync(path5.dirname(path5.resolve(outPath)), { recursive: true });
342
367
  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));
368
+ await (0, import_promises.pipeline)(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs5.createWriteStream(outPath));
344
369
  return { ...file, out: outPath };
345
370
  }
346
371
  async function requestUpload(options = {}, body) {
@@ -350,8 +375,8 @@ async function confirmUpload(options = {}, fileId, ok = true) {
350
375
  return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
351
376
  }
352
377
  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);
378
+ const hash = (0, import_node_crypto7.createHash)("sha256");
379
+ for await (const chunk of fs5.createReadStream(localPath)) hash.update(chunk);
355
380
  return hash.digest("base64");
356
381
  }
357
382
  var CONTENT_TYPES = {
@@ -387,7 +412,7 @@ var CONTENT_TYPES = {
387
412
  ".mp4": "video/mp4"
388
413
  };
389
414
  function contentTypeFor(name) {
390
- return CONTENT_TYPES[path4.extname(name).toLowerCase()] ?? "application/octet-stream";
415
+ return CONTENT_TYPES[path5.extname(name).toLowerCase()] ?? "application/octet-stream";
391
416
  }
392
417
  function counting(report) {
393
418
  let seen = 0;
@@ -414,7 +439,7 @@ async function putPresigned(uploadUrl, body, headers) {
414
439
  if (!res.ok) throw new Error(`upload failed: storage answered HTTP ${res.status}: ${(await res.text()).slice(0, 300)}`);
415
440
  }
416
441
  async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
417
- const stat = fs4.statSync(localPath);
442
+ const stat = fs5.statSync(localPath);
418
443
  if (!stat.isFile()) throw new Error(`${localPath} is not a file`);
419
444
  if (stat.size === 0) throw new Error(`${localPath} is empty; the drive refuses zero-byte uploads`);
420
445
  const contentType = upload.contentType ?? contentTypeFor(localPath);
@@ -422,7 +447,7 @@ async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
422
447
  const target = drivePath(targetPath);
423
448
  const granted = await requestUpload(options, { path: target, contentLength: stat.size, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
424
449
  try {
425
- const stream = fs4.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
450
+ const stream = fs5.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
426
451
  await putPresigned(granted.uploadUrl, import_node_stream.Readable.toWeb(stream), { contentType, contentLength: stat.size, sha256 });
427
452
  } catch (error) {
428
453
  await confirmUpload(options, granted.fileId, false).catch(() => void 0);
@@ -435,7 +460,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
435
460
  if (!bytes.length) throw new Error("nothing to upload: the content is empty");
436
461
  const target = drivePath(targetPath);
437
462
  const contentType = upload.contentType ?? contentTypeFor(target);
438
- const sha256 = (0, import_node_crypto6.createHash)("sha256").update(bytes).digest("base64");
463
+ const sha256 = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("base64");
439
464
  const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
440
465
  try {
441
466
  await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256 });