@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.
- package/dist/cli.js +11992 -4572
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +11998 -4578
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.js +71 -31
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +59 -20
- package/dist/files/index.mjs.map +1 -1
- package/dist/hooks/index.d.mts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +4355 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +4243 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/{index-Dpo-t8iO.d.ts → index-1xnxt0Cc.d.ts} +58 -2
- package/dist/index-B0R3IgsV.d.mts +1279 -0
- package/dist/index-B0R3IgsV.d.ts +1279 -0
- package/dist/{index-B5HUQQDE.d.mts → index-C1wDEwH4.d.mts} +58 -2
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +6547 -1552
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6636 -1655
- package/dist/index.mjs.map +1 -1
- package/dist/traces/index.js +60 -20
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +51 -12
- package/dist/traces/index.mjs.map +1 -1
- package/dist/tracing/index.d.mts +1 -1
- package/dist/tracing/index.d.ts +1 -1
- package/dist/tracing/index.js +46 -3
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +41 -2
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +371 -6
- package/dist/worlds/index.d.ts +371 -6
- package/dist/worlds/index.js +2061 -235
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +2050 -224
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +6 -1
- package/runtime/gatewaysdk/environment/_materialize.py +3 -3
- package/runtime/gatewaysdk/environment/schema/api.py +116 -2
- package/runtime/gatewaysdk/environment/schema/compiler.py +14 -0
- package/runtime/gatewaysdk/environment/schema/host.py +37 -11
- package/runtime/gatewaysdk/environment/schema/skills/hooks-getting-started/SKILL.md +154 -0
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +5 -5
- package/runtime/gatewaysdk/environment/schema/snapshot.py +6 -5
- package/runtime/gatewaysdk/environment/schema/tasks.py +12 -2
- package/runtime/gatewaysdk/environment/schema/workers.py +30 -13
- package/skills/hooks-getting-started/SKILL.md +154 -0
- package/skills/worlds-getting-started/SKILL.md +5 -5
package/dist/files/index.js
CHANGED
|
@@ -60,17 +60,50 @@ 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
|
+
|
|
63
96
|
// src/worlds/hub.ts
|
|
64
|
-
var
|
|
97
|
+
var import_node_crypto3, import_node_zlib, fs2, path2, META_RELPATH;
|
|
65
98
|
var init_hub = __esm({
|
|
66
99
|
"src/worlds/hub.ts"() {
|
|
67
100
|
"use strict";
|
|
68
|
-
|
|
101
|
+
import_node_crypto3 = require("crypto");
|
|
69
102
|
import_node_zlib = require("zlib");
|
|
70
|
-
|
|
71
|
-
|
|
103
|
+
fs2 = __toESM(require("fs"));
|
|
104
|
+
path2 = __toESM(require("path"));
|
|
72
105
|
init_worlds();
|
|
73
|
-
META_RELPATH =
|
|
106
|
+
META_RELPATH = path2.join(".gateway", ".env-metadata.json");
|
|
74
107
|
}
|
|
75
108
|
});
|
|
76
109
|
|
|
@@ -99,11 +132,11 @@ var init_json = __esm({
|
|
|
99
132
|
});
|
|
100
133
|
|
|
101
134
|
// src/worlds/transforms.ts
|
|
102
|
-
var
|
|
135
|
+
var import_node_crypto4, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, hex, SIMPLE, TRANSFORMS;
|
|
103
136
|
var init_transforms = __esm({
|
|
104
137
|
"src/worlds/transforms.ts"() {
|
|
105
138
|
"use strict";
|
|
106
|
-
|
|
139
|
+
import_node_crypto4 = require("crypto");
|
|
107
140
|
init_json();
|
|
108
141
|
WHITESPACE_EDGES = /^[ \t\n\r\f\v]+|[ \t\n\r\f\v]+$/g;
|
|
109
142
|
WHITESPACE_RUN = /[ \t\n\r\f\v]+/g;
|
|
@@ -118,7 +151,7 @@ var init_transforms = __esm({
|
|
|
118
151
|
const at = value.lastIndexOf("@");
|
|
119
152
|
return at === -1 ? "" : value.slice(at + 1).toLowerCase();
|
|
120
153
|
};
|
|
121
|
-
hex = (algorithm, value) => (0,
|
|
154
|
+
hex = (algorithm, value) => (0, import_node_crypto4.createHash)(algorithm).update(value, "utf8").digest("hex");
|
|
122
155
|
SIMPLE = {
|
|
123
156
|
lower: (value) => value.toLowerCase(),
|
|
124
157
|
upper: (value) => value.toUpperCase(),
|
|
@@ -138,11 +171,11 @@ var init_transforms = __esm({
|
|
|
138
171
|
});
|
|
139
172
|
|
|
140
173
|
// src/worlds/redaction.ts
|
|
141
|
-
var
|
|
174
|
+
var import_node_crypto5;
|
|
142
175
|
var init_redaction = __esm({
|
|
143
176
|
"src/worlds/redaction.ts"() {
|
|
144
177
|
"use strict";
|
|
145
|
-
|
|
178
|
+
import_node_crypto5 = require("crypto");
|
|
146
179
|
init_json();
|
|
147
180
|
init_transforms();
|
|
148
181
|
}
|
|
@@ -165,13 +198,13 @@ var init_migrate = __esm({
|
|
|
165
198
|
});
|
|
166
199
|
|
|
167
200
|
// src/worlds/ingest.ts
|
|
168
|
-
var
|
|
201
|
+
var fs3, os, path3;
|
|
169
202
|
var init_ingest = __esm({
|
|
170
203
|
"src/worlds/ingest.ts"() {
|
|
171
204
|
"use strict";
|
|
172
|
-
|
|
205
|
+
fs3 = __toESM(require("fs"));
|
|
173
206
|
os = __toESM(require("os"));
|
|
174
|
-
|
|
207
|
+
path3 = __toESM(require("path"));
|
|
175
208
|
init_worlds();
|
|
176
209
|
}
|
|
177
210
|
});
|
|
@@ -188,9 +221,9 @@ function resolveEnv(options) {
|
|
|
188
221
|
}
|
|
189
222
|
return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
|
|
190
223
|
}
|
|
191
|
-
async function apiRequest(options, method,
|
|
224
|
+
async function apiRequest(options, method, path5, body) {
|
|
192
225
|
const { host, publicKey, secretKey } = resolveEnv(options);
|
|
193
|
-
const res = await fetch(`${host}${
|
|
226
|
+
const res = await fetch(`${host}${path5}`, {
|
|
194
227
|
method,
|
|
195
228
|
headers: {
|
|
196
229
|
"content-type": "application/json",
|
|
@@ -199,18 +232,18 @@ async function apiRequest(options, method, path4, body) {
|
|
|
199
232
|
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
200
233
|
});
|
|
201
234
|
const text = await res.text();
|
|
202
|
-
if (!res.ok)
|
|
203
|
-
throw new Error(
|
|
204
|
-
`${method} ${path4} -> ${res.status}: ${text.slice(0, 400)}`
|
|
205
|
-
);
|
|
206
|
-
}
|
|
235
|
+
if (!res.ok) throw new ApiError(res.status, method, path5, text.slice(0, 400));
|
|
207
236
|
return JSON.parse(text);
|
|
208
237
|
}
|
|
238
|
+
var ApiError;
|
|
209
239
|
var init_worlds = __esm({
|
|
210
240
|
"src/worlds/index.ts"() {
|
|
211
241
|
"use strict";
|
|
212
242
|
init_session();
|
|
213
243
|
init_tasks();
|
|
244
|
+
init_taskSessions();
|
|
245
|
+
init_taskRun();
|
|
246
|
+
init_evals();
|
|
214
247
|
init_browser();
|
|
215
248
|
init_hub();
|
|
216
249
|
init_validate();
|
|
@@ -220,6 +253,13 @@ var init_worlds = __esm({
|
|
|
220
253
|
init_query();
|
|
221
254
|
init_migrate();
|
|
222
255
|
init_ingest();
|
|
256
|
+
ApiError = class extends Error {
|
|
257
|
+
constructor(status, method, path5, body) {
|
|
258
|
+
super(`${method} ${path5} -> ${status}: ${body}`);
|
|
259
|
+
this.status = status;
|
|
260
|
+
this.name = "ApiError";
|
|
261
|
+
}
|
|
262
|
+
};
|
|
223
263
|
}
|
|
224
264
|
});
|
|
225
265
|
|
|
@@ -247,9 +287,9 @@ __export(files_exports, {
|
|
|
247
287
|
uploadFile: () => uploadFile
|
|
248
288
|
});
|
|
249
289
|
module.exports = __toCommonJS(files_exports);
|
|
250
|
-
var
|
|
251
|
-
var
|
|
252
|
-
var
|
|
290
|
+
var import_node_crypto6 = require("crypto");
|
|
291
|
+
var fs4 = __toESM(require("fs"));
|
|
292
|
+
var path4 = __toESM(require("path"));
|
|
253
293
|
var import_node_stream = require("stream");
|
|
254
294
|
var import_promises = require("stream/promises");
|
|
255
295
|
init_worlds();
|
|
@@ -298,9 +338,9 @@ async function readFile(options = {}, filePath) {
|
|
|
298
338
|
async function downloadFile(options = {}, filePath, outPath, onProgress) {
|
|
299
339
|
const file = await getFile(options, filePath);
|
|
300
340
|
const res = await openDownload(file.url);
|
|
301
|
-
|
|
341
|
+
fs4.mkdirSync(path4.dirname(path4.resolve(outPath)), { recursive: true });
|
|
302
342
|
const source = import_node_stream.Readable.fromWeb(res.body);
|
|
303
|
-
await (0, import_promises.pipeline)(source, counting((n) => onProgress?.(n, file.sizeBytes)),
|
|
343
|
+
await (0, import_promises.pipeline)(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs4.createWriteStream(outPath));
|
|
304
344
|
return { ...file, out: outPath };
|
|
305
345
|
}
|
|
306
346
|
async function requestUpload(options = {}, body) {
|
|
@@ -310,8 +350,8 @@ async function confirmUpload(options = {}, fileId, ok = true) {
|
|
|
310
350
|
return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
|
|
311
351
|
}
|
|
312
352
|
async function sha256Base64(localPath) {
|
|
313
|
-
const hash = (0,
|
|
314
|
-
for await (const chunk of
|
|
353
|
+
const hash = (0, import_node_crypto6.createHash)("sha256");
|
|
354
|
+
for await (const chunk of fs4.createReadStream(localPath)) hash.update(chunk);
|
|
315
355
|
return hash.digest("base64");
|
|
316
356
|
}
|
|
317
357
|
var CONTENT_TYPES = {
|
|
@@ -347,7 +387,7 @@ var CONTENT_TYPES = {
|
|
|
347
387
|
".mp4": "video/mp4"
|
|
348
388
|
};
|
|
349
389
|
function contentTypeFor(name) {
|
|
350
|
-
return CONTENT_TYPES[
|
|
390
|
+
return CONTENT_TYPES[path4.extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
351
391
|
}
|
|
352
392
|
function counting(report) {
|
|
353
393
|
let seen = 0;
|
|
@@ -374,7 +414,7 @@ async function putPresigned(uploadUrl, body, headers) {
|
|
|
374
414
|
if (!res.ok) throw new Error(`upload failed: storage answered HTTP ${res.status}: ${(await res.text()).slice(0, 300)}`);
|
|
375
415
|
}
|
|
376
416
|
async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
|
|
377
|
-
const stat =
|
|
417
|
+
const stat = fs4.statSync(localPath);
|
|
378
418
|
if (!stat.isFile()) throw new Error(`${localPath} is not a file`);
|
|
379
419
|
if (stat.size === 0) throw new Error(`${localPath} is empty; the drive refuses zero-byte uploads`);
|
|
380
420
|
const contentType = upload.contentType ?? contentTypeFor(localPath);
|
|
@@ -382,7 +422,7 @@ async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
|
|
|
382
422
|
const target = drivePath(targetPath);
|
|
383
423
|
const granted = await requestUpload(options, { path: target, contentLength: stat.size, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
|
|
384
424
|
try {
|
|
385
|
-
const stream =
|
|
425
|
+
const stream = fs4.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
|
|
386
426
|
await putPresigned(granted.uploadUrl, import_node_stream.Readable.toWeb(stream), { contentType, contentLength: stat.size, sha256 });
|
|
387
427
|
} catch (error) {
|
|
388
428
|
await confirmUpload(options, granted.fileId, false).catch(() => void 0);
|
|
@@ -395,7 +435,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
|
|
|
395
435
|
if (!bytes.length) throw new Error("nothing to upload: the content is empty");
|
|
396
436
|
const target = drivePath(targetPath);
|
|
397
437
|
const contentType = upload.contentType ?? contentTypeFor(target);
|
|
398
|
-
const sha256 = (0,
|
|
438
|
+
const sha256 = (0, import_node_crypto6.createHash)("sha256").update(bytes).digest("base64");
|
|
399
439
|
const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
|
|
400
440
|
try {
|
|
401
441
|
await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256 });
|