@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
@@ -67,17 +67,32 @@ var init_taskRun = __esm({
67
67
  }
68
68
  });
69
69
 
70
- // src/worlds/hub.ts
70
+ // src/worlds/worldDir.ts
71
71
  import { createHash } from "crypto";
72
- import { gzipSync, gunzipSync } from "zlib";
73
72
  import * as fs2 from "fs";
74
73
  import * as path2 from "path";
74
+ var CONNECTOR_SPEC, WORLD_SCHEMA_MARKERS, WORLD_ROOT_MARKERS;
75
+ var init_worldDir = __esm({
76
+ "src/worlds/worldDir.ts"() {
77
+ "use strict";
78
+ CONNECTOR_SPEC = "connector.toml";
79
+ WORLD_SCHEMA_MARKERS = ["schema/world.json", "schema/runtime.json", "schema/lock.json"];
80
+ WORLD_ROOT_MARKERS = [CONNECTOR_SPEC, ...WORLD_SCHEMA_MARKERS];
81
+ }
82
+ });
83
+
84
+ // src/worlds/hub.ts
85
+ import { createHash as createHash2 } from "crypto";
86
+ import { gzipSync, gunzipSync } from "zlib";
87
+ import * as fs3 from "fs";
88
+ import * as path3 from "path";
75
89
  var META_RELPATH;
76
90
  var init_hub = __esm({
77
91
  "src/worlds/hub.ts"() {
78
92
  "use strict";
79
93
  init_worlds();
80
- META_RELPATH = path2.join(".gateway", ".env-metadata.json");
94
+ init_worldDir();
95
+ META_RELPATH = path3.join(".gateway", ".env-metadata.json");
81
96
  }
82
97
  });
83
98
 
@@ -106,14 +121,15 @@ var init_json = __esm({
106
121
  });
107
122
 
108
123
  // src/worlds/transforms.ts
109
- import { createHash as createHash2 } from "crypto";
110
- var WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, hex, SIMPLE, TRANSFORMS;
124
+ import { createHash as createHash3 } from "crypto";
125
+ var WHITESPACE, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, hex, SIMPLE, TRANSFORMS;
111
126
  var init_transforms = __esm({
112
127
  "src/worlds/transforms.ts"() {
113
128
  "use strict";
114
129
  init_json();
115
- WHITESPACE_EDGES = /^[ \t\n\r\f\v]+|[ \t\n\r\f\v]+$/g;
116
- WHITESPACE_RUN = /[ \t\n\r\f\v]+/g;
130
+ WHITESPACE = " \n\r\f\v";
131
+ WHITESPACE_EDGES = new RegExp(`^[${WHITESPACE}]+|[${WHITESPACE}]+$`, "g");
132
+ WHITESPACE_RUN = new RegExp(`[${WHITESPACE}]+`, "g");
117
133
  NOT_DIGIT = /[^0-9]/g;
118
134
  STRIP_PREFIX = "strip_prefix";
119
135
  trim = (value) => value.replace(WHITESPACE_EDGES, "");
@@ -125,7 +141,7 @@ var init_transforms = __esm({
125
141
  const at = value.lastIndexOf("@");
126
142
  return at === -1 ? "" : value.slice(at + 1).toLowerCase();
127
143
  };
128
- hex = (algorithm, value) => createHash2(algorithm).update(value, "utf8").digest("hex");
144
+ hex = (algorithm, value) => createHash3(algorithm).update(value, "utf8").digest("hex");
129
145
  SIMPLE = {
130
146
  lower: (value) => value.toLowerCase(),
131
147
  upper: (value) => value.toUpperCase(),
@@ -145,7 +161,7 @@ var init_transforms = __esm({
145
161
  });
146
162
 
147
163
  // src/worlds/redaction.ts
148
- import { createHash as createHash3 } from "crypto";
164
+ import { createHash as createHash4 } from "crypto";
149
165
  var init_redaction = __esm({
150
166
  "src/worlds/redaction.ts"() {
151
167
  "use strict";
@@ -171,9 +187,9 @@ var init_migrate = __esm({
171
187
  });
172
188
 
173
189
  // src/worlds/ingest.ts
174
- import * as fs3 from "fs";
190
+ import * as fs4 from "fs";
175
191
  import * as os from "os";
176
- import * as path3 from "path";
192
+ import * as path4 from "path";
177
193
  var init_ingest = __esm({
178
194
  "src/worlds/ingest.ts"() {
179
195
  "use strict";
@@ -193,9 +209,9 @@ function resolveEnv(options) {
193
209
  }
194
210
  return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
195
211
  }
196
- async function apiRequest(options, method, path5, body) {
212
+ async function apiRequest(options, method, path6, body) {
197
213
  const { host, publicKey, secretKey } = resolveEnv(options);
198
- const res = await fetch(`${host}${path5}`, {
214
+ const res = await fetch(`${host}${path6}`, {
199
215
  method,
200
216
  headers: {
201
217
  "content-type": "application/json",
@@ -204,7 +220,7 @@ async function apiRequest(options, method, path5, body) {
204
220
  ...body === void 0 ? {} : { body: JSON.stringify(body) }
205
221
  });
206
222
  const text = await res.text();
207
- if (!res.ok) throw new ApiError(res.status, method, path5, text.slice(0, 400));
223
+ if (!res.ok) throw new ApiError(res.status, method, path6, text.slice(0, 400));
208
224
  return JSON.parse(text);
209
225
  }
210
226
  var ApiError;
@@ -226,8 +242,8 @@ var init_worlds = __esm({
226
242
  init_migrate();
227
243
  init_ingest();
228
244
  ApiError = class extends Error {
229
- constructor(status, method, path5, body) {
230
- super(`${method} ${path5} -> ${status}: ${body}`);
245
+ constructor(status, method, path6, body) {
246
+ super(`${method} ${path6} -> ${status}: ${body}`);
231
247
  this.status = status;
232
248
  this.name = "ApiError";
233
249
  }
@@ -237,9 +253,9 @@ var init_worlds = __esm({
237
253
 
238
254
  // src/files/index.ts
239
255
  init_worlds();
240
- import { createHash as createHash4 } from "crypto";
241
- import * as fs4 from "fs";
242
- import * as path4 from "path";
256
+ import { createHash as createHash5 } from "crypto";
257
+ import * as fs5 from "fs";
258
+ import * as path5 from "path";
243
259
  import { Readable, Transform } from "stream";
244
260
  import { pipeline } from "stream/promises";
245
261
  var DRIVE_PREFIX = "drive:";
@@ -287,9 +303,9 @@ async function readFile(options = {}, filePath) {
287
303
  async function downloadFile(options = {}, filePath, outPath, onProgress) {
288
304
  const file = await getFile(options, filePath);
289
305
  const res = await openDownload(file.url);
290
- fs4.mkdirSync(path4.dirname(path4.resolve(outPath)), { recursive: true });
306
+ fs5.mkdirSync(path5.dirname(path5.resolve(outPath)), { recursive: true });
291
307
  const source = Readable.fromWeb(res.body);
292
- await pipeline(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs4.createWriteStream(outPath));
308
+ await pipeline(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs5.createWriteStream(outPath));
293
309
  return { ...file, out: outPath };
294
310
  }
295
311
  async function requestUpload(options = {}, body) {
@@ -299,8 +315,8 @@ async function confirmUpload(options = {}, fileId, ok = true) {
299
315
  return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
300
316
  }
301
317
  async function sha256Base64(localPath) {
302
- const hash = createHash4("sha256");
303
- for await (const chunk of fs4.createReadStream(localPath)) hash.update(chunk);
318
+ const hash = createHash5("sha256");
319
+ for await (const chunk of fs5.createReadStream(localPath)) hash.update(chunk);
304
320
  return hash.digest("base64");
305
321
  }
306
322
  var CONTENT_TYPES = {
@@ -336,7 +352,7 @@ var CONTENT_TYPES = {
336
352
  ".mp4": "video/mp4"
337
353
  };
338
354
  function contentTypeFor(name) {
339
- return CONTENT_TYPES[path4.extname(name).toLowerCase()] ?? "application/octet-stream";
355
+ return CONTENT_TYPES[path5.extname(name).toLowerCase()] ?? "application/octet-stream";
340
356
  }
341
357
  function counting(report) {
342
358
  let seen = 0;
@@ -363,7 +379,7 @@ async function putPresigned(uploadUrl, body, headers) {
363
379
  if (!res.ok) throw new Error(`upload failed: storage answered HTTP ${res.status}: ${(await res.text()).slice(0, 300)}`);
364
380
  }
365
381
  async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
366
- const stat = fs4.statSync(localPath);
382
+ const stat = fs5.statSync(localPath);
367
383
  if (!stat.isFile()) throw new Error(`${localPath} is not a file`);
368
384
  if (stat.size === 0) throw new Error(`${localPath} is empty; the drive refuses zero-byte uploads`);
369
385
  const contentType = upload.contentType ?? contentTypeFor(localPath);
@@ -371,7 +387,7 @@ async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
371
387
  const target = drivePath(targetPath);
372
388
  const granted = await requestUpload(options, { path: target, contentLength: stat.size, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
373
389
  try {
374
- const stream = fs4.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
390
+ const stream = fs5.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
375
391
  await putPresigned(granted.uploadUrl, Readable.toWeb(stream), { contentType, contentLength: stat.size, sha256 });
376
392
  } catch (error) {
377
393
  await confirmUpload(options, granted.fileId, false).catch(() => void 0);
@@ -384,7 +400,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
384
400
  if (!bytes.length) throw new Error("nothing to upload: the content is empty");
385
401
  const target = drivePath(targetPath);
386
402
  const contentType = upload.contentType ?? contentTypeFor(target);
387
- const sha256 = createHash4("sha256").update(bytes).digest("base64");
403
+ const sha256 = createHash5("sha256").update(bytes).digest("base64");
388
404
  const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
389
405
  try {
390
406
  await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256 });