@withgateway/sdk 0.2.2 → 0.2.4

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 (52) hide show
  1. package/dist/cli.js +11992 -4572
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +11998 -4578
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/files/index.js +71 -31
  6. package/dist/files/index.js.map +1 -1
  7. package/dist/files/index.mjs +59 -20
  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 +6547 -1552
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +6636 -1655
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/traces/index.js +60 -20
  26. package/dist/traces/index.js.map +1 -1
  27. package/dist/traces/index.mjs +51 -12
  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 +46 -3
  32. package/dist/tracing/index.js.map +1 -1
  33. package/dist/tracing/index.mjs +41 -2
  34. package/dist/tracing/index.mjs.map +1 -1
  35. package/dist/worlds/index.d.mts +371 -6
  36. package/dist/worlds/index.d.ts +371 -6
  37. package/dist/worlds/index.js +2061 -235
  38. package/dist/worlds/index.js.map +1 -1
  39. package/dist/worlds/index.mjs +2050 -224
  40. package/dist/worlds/index.mjs.map +1 -1
  41. package/package.json +6 -1
  42. package/runtime/gatewaysdk/environment/_materialize.py +3 -3
  43. package/runtime/gatewaysdk/environment/schema/api.py +116 -2
  44. package/runtime/gatewaysdk/environment/schema/compiler.py +14 -0
  45. package/runtime/gatewaysdk/environment/schema/host.py +37 -11
  46. package/runtime/gatewaysdk/environment/schema/skills/hooks-getting-started/SKILL.md +154 -0
  47. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +5 -5
  48. package/runtime/gatewaysdk/environment/schema/snapshot.py +6 -5
  49. package/runtime/gatewaysdk/environment/schema/tasks.py +12 -2
  50. package/runtime/gatewaysdk/environment/schema/workers.py +30 -13
  51. package/skills/hooks-getting-started/SKILL.md +154 -0
  52. package/skills/worlds-getting-started/SKILL.md +5 -5
@@ -35,17 +35,49 @@ var init_tasks = __esm({
35
35
  }
36
36
  });
37
37
 
38
+ // src/worlds/taskSessions.ts
39
+ var init_taskSessions = __esm({
40
+ "src/worlds/taskSessions.ts"() {
41
+ "use strict";
42
+ init_worlds();
43
+ init_browser();
44
+ init_session();
45
+ }
46
+ });
47
+
48
+ // src/worlds/evals.ts
49
+ var init_evals = __esm({
50
+ "src/worlds/evals.ts"() {
51
+ "use strict";
52
+ init_worlds();
53
+ }
54
+ });
55
+
56
+ // src/worlds/taskRun.ts
57
+ import { randomBytes } from "crypto";
58
+ import * as fs from "fs";
59
+ import * as path from "path";
60
+ var init_taskRun = __esm({
61
+ "src/worlds/taskRun.ts"() {
62
+ "use strict";
63
+ init_browser();
64
+ init_evals();
65
+ init_session();
66
+ init_taskSessions();
67
+ }
68
+ });
69
+
38
70
  // src/worlds/hub.ts
39
71
  import { createHash } from "crypto";
40
72
  import { gzipSync, gunzipSync } from "zlib";
41
- import * as fs from "fs";
42
- import * as path from "path";
73
+ import * as fs2 from "fs";
74
+ import * as path2 from "path";
43
75
  var META_RELPATH;
44
76
  var init_hub = __esm({
45
77
  "src/worlds/hub.ts"() {
46
78
  "use strict";
47
79
  init_worlds();
48
- META_RELPATH = path.join(".gateway", ".env-metadata.json");
80
+ META_RELPATH = path2.join(".gateway", ".env-metadata.json");
49
81
  }
50
82
  });
51
83
 
@@ -139,9 +171,9 @@ var init_migrate = __esm({
139
171
  });
140
172
 
141
173
  // src/worlds/ingest.ts
142
- import * as fs2 from "fs";
174
+ import * as fs3 from "fs";
143
175
  import * as os from "os";
144
- import * as path2 from "path";
176
+ import * as path3 from "path";
145
177
  var init_ingest = __esm({
146
178
  "src/worlds/ingest.ts"() {
147
179
  "use strict";
@@ -161,9 +193,9 @@ function resolveEnv(options) {
161
193
  }
162
194
  return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
163
195
  }
164
- async function apiRequest(options, method, path4, body) {
196
+ async function apiRequest(options, method, path5, body) {
165
197
  const { host, publicKey, secretKey } = resolveEnv(options);
166
- const res = await fetch(`${host}${path4}`, {
198
+ const res = await fetch(`${host}${path5}`, {
167
199
  method,
168
200
  headers: {
169
201
  "content-type": "application/json",
@@ -172,18 +204,18 @@ async function apiRequest(options, method, path4, body) {
172
204
  ...body === void 0 ? {} : { body: JSON.stringify(body) }
173
205
  });
174
206
  const text = await res.text();
175
- if (!res.ok) {
176
- throw new Error(
177
- `${method} ${path4} -> ${res.status}: ${text.slice(0, 400)}`
178
- );
179
- }
207
+ if (!res.ok) throw new ApiError(res.status, method, path5, text.slice(0, 400));
180
208
  return JSON.parse(text);
181
209
  }
210
+ var ApiError;
182
211
  var init_worlds = __esm({
183
212
  "src/worlds/index.ts"() {
184
213
  "use strict";
185
214
  init_session();
186
215
  init_tasks();
216
+ init_taskSessions();
217
+ init_taskRun();
218
+ init_evals();
187
219
  init_browser();
188
220
  init_hub();
189
221
  init_validate();
@@ -193,14 +225,21 @@ var init_worlds = __esm({
193
225
  init_query();
194
226
  init_migrate();
195
227
  init_ingest();
228
+ ApiError = class extends Error {
229
+ constructor(status, method, path5, body) {
230
+ super(`${method} ${path5} -> ${status}: ${body}`);
231
+ this.status = status;
232
+ this.name = "ApiError";
233
+ }
234
+ };
196
235
  }
197
236
  });
198
237
 
199
238
  // src/files/index.ts
200
239
  init_worlds();
201
240
  import { createHash as createHash4 } from "crypto";
202
- import * as fs3 from "fs";
203
- import * as path3 from "path";
241
+ import * as fs4 from "fs";
242
+ import * as path4 from "path";
204
243
  import { Readable, Transform } from "stream";
205
244
  import { pipeline } from "stream/promises";
206
245
  var DRIVE_PREFIX = "drive:";
@@ -248,9 +287,9 @@ async function readFile(options = {}, filePath) {
248
287
  async function downloadFile(options = {}, filePath, outPath, onProgress) {
249
288
  const file = await getFile(options, filePath);
250
289
  const res = await openDownload(file.url);
251
- fs3.mkdirSync(path3.dirname(path3.resolve(outPath)), { recursive: true });
290
+ fs4.mkdirSync(path4.dirname(path4.resolve(outPath)), { recursive: true });
252
291
  const source = Readable.fromWeb(res.body);
253
- await pipeline(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs3.createWriteStream(outPath));
292
+ await pipeline(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs4.createWriteStream(outPath));
254
293
  return { ...file, out: outPath };
255
294
  }
256
295
  async function requestUpload(options = {}, body) {
@@ -261,7 +300,7 @@ async function confirmUpload(options = {}, fileId, ok = true) {
261
300
  }
262
301
  async function sha256Base64(localPath) {
263
302
  const hash = createHash4("sha256");
264
- for await (const chunk of fs3.createReadStream(localPath)) hash.update(chunk);
303
+ for await (const chunk of fs4.createReadStream(localPath)) hash.update(chunk);
265
304
  return hash.digest("base64");
266
305
  }
267
306
  var CONTENT_TYPES = {
@@ -297,7 +336,7 @@ var CONTENT_TYPES = {
297
336
  ".mp4": "video/mp4"
298
337
  };
299
338
  function contentTypeFor(name) {
300
- return CONTENT_TYPES[path3.extname(name).toLowerCase()] ?? "application/octet-stream";
339
+ return CONTENT_TYPES[path4.extname(name).toLowerCase()] ?? "application/octet-stream";
301
340
  }
302
341
  function counting(report) {
303
342
  let seen = 0;
@@ -324,7 +363,7 @@ async function putPresigned(uploadUrl, body, headers) {
324
363
  if (!res.ok) throw new Error(`upload failed: storage answered HTTP ${res.status}: ${(await res.text()).slice(0, 300)}`);
325
364
  }
326
365
  async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
327
- const stat = fs3.statSync(localPath);
366
+ const stat = fs4.statSync(localPath);
328
367
  if (!stat.isFile()) throw new Error(`${localPath} is not a file`);
329
368
  if (stat.size === 0) throw new Error(`${localPath} is empty; the drive refuses zero-byte uploads`);
330
369
  const contentType = upload.contentType ?? contentTypeFor(localPath);
@@ -332,7 +371,7 @@ async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
332
371
  const target = drivePath(targetPath);
333
372
  const granted = await requestUpload(options, { path: target, contentLength: stat.size, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
334
373
  try {
335
- const stream = fs3.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
374
+ const stream = fs4.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
336
375
  await putPresigned(granted.uploadUrl, Readable.toWeb(stream), { contentType, contentLength: stat.size, sha256 });
337
376
  } catch (error) {
338
377
  await confirmUpload(options, granted.fileId, false).catch(() => void 0);