@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.
- package/dist/cli.js +13267 -5869
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +13272 -5874
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.js +83 -31
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +79 -28
- 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 +6698 -1606
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6793 -1713
- package/dist/index.mjs.map +1 -1
- package/dist/traces/index.js +72 -20
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +68 -17
- 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 +47 -3
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +42 -2
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +390 -27
- package/dist/worlds/index.d.ts +390 -27
- package/dist/worlds/index.js +2291 -366
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +2281 -356
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +7 -1
- package/runtime/gatewaysdk/environment/_bundle.py +14 -24
- package/runtime/gatewaysdk/environment/_materialize.py +3 -3
- package/runtime/gatewaysdk/environment/schema/api.py +153 -20
- package/runtime/gatewaysdk/environment/schema/compiler.py +14 -0
- package/runtime/gatewaysdk/environment/schema/data.py +21 -19
- package/runtime/gatewaysdk/environment/schema/grading.py +225 -0
- package/runtime/gatewaysdk/environment/schema/host.py +171 -535
- package/runtime/gatewaysdk/environment/schema/ingest.py +3 -11
- package/runtime/gatewaysdk/environment/schema/local.py +32 -126
- package/runtime/gatewaysdk/environment/schema/platform.py +14 -22
- package/runtime/gatewaysdk/environment/schema/proof.py +237 -0
- package/runtime/gatewaysdk/environment/schema/runtime.py +686 -0
- package/runtime/gatewaysdk/environment/schema/skill.py +1 -0
- package/runtime/gatewaysdk/environment/schema/skills/hooks-getting-started/SKILL.md +156 -0
- package/runtime/gatewaysdk/environment/schema/snapshot.py +6 -5
- package/runtime/gatewaysdk/environment/schema/tasks.py +12 -2
- package/runtime/gatewaysdk/environment/schema/tools_world.py +75 -23
- package/runtime/gatewaysdk/environment/schema/verbs.py +136 -0
- package/runtime/gatewaysdk/environment/schema/workers.py +44 -13
- package/runtime/gatewaysdk/environment/world.py +391 -0
- package/skills/hooks-getting-started/SKILL.md +156 -0
package/dist/files/index.mjs
CHANGED
|
@@ -35,17 +35,64 @@ var init_tasks = __esm({
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
// src/worlds/
|
|
39
|
-
|
|
40
|
-
|
|
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";
|
|
41
58
|
import * as fs from "fs";
|
|
42
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
|
+
|
|
70
|
+
// src/worlds/worldDir.ts
|
|
71
|
+
import { createHash } from "crypto";
|
|
72
|
+
import * as fs2 from "fs";
|
|
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";
|
|
43
89
|
var META_RELPATH;
|
|
44
90
|
var init_hub = __esm({
|
|
45
91
|
"src/worlds/hub.ts"() {
|
|
46
92
|
"use strict";
|
|
47
93
|
init_worlds();
|
|
48
|
-
|
|
94
|
+
init_worldDir();
|
|
95
|
+
META_RELPATH = path3.join(".gateway", ".env-metadata.json");
|
|
49
96
|
}
|
|
50
97
|
});
|
|
51
98
|
|
|
@@ -74,14 +121,15 @@ var init_json = __esm({
|
|
|
74
121
|
});
|
|
75
122
|
|
|
76
123
|
// src/worlds/transforms.ts
|
|
77
|
-
import { createHash as
|
|
78
|
-
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;
|
|
79
126
|
var init_transforms = __esm({
|
|
80
127
|
"src/worlds/transforms.ts"() {
|
|
81
128
|
"use strict";
|
|
82
129
|
init_json();
|
|
83
|
-
|
|
84
|
-
|
|
130
|
+
WHITESPACE = " \n\r\f\v";
|
|
131
|
+
WHITESPACE_EDGES = new RegExp(`^[${WHITESPACE}]+|[${WHITESPACE}]+$`, "g");
|
|
132
|
+
WHITESPACE_RUN = new RegExp(`[${WHITESPACE}]+`, "g");
|
|
85
133
|
NOT_DIGIT = /[^0-9]/g;
|
|
86
134
|
STRIP_PREFIX = "strip_prefix";
|
|
87
135
|
trim = (value) => value.replace(WHITESPACE_EDGES, "");
|
|
@@ -93,7 +141,7 @@ var init_transforms = __esm({
|
|
|
93
141
|
const at = value.lastIndexOf("@");
|
|
94
142
|
return at === -1 ? "" : value.slice(at + 1).toLowerCase();
|
|
95
143
|
};
|
|
96
|
-
hex = (algorithm, value) =>
|
|
144
|
+
hex = (algorithm, value) => createHash3(algorithm).update(value, "utf8").digest("hex");
|
|
97
145
|
SIMPLE = {
|
|
98
146
|
lower: (value) => value.toLowerCase(),
|
|
99
147
|
upper: (value) => value.toUpperCase(),
|
|
@@ -113,7 +161,7 @@ var init_transforms = __esm({
|
|
|
113
161
|
});
|
|
114
162
|
|
|
115
163
|
// src/worlds/redaction.ts
|
|
116
|
-
import { createHash as
|
|
164
|
+
import { createHash as createHash4 } from "crypto";
|
|
117
165
|
var init_redaction = __esm({
|
|
118
166
|
"src/worlds/redaction.ts"() {
|
|
119
167
|
"use strict";
|
|
@@ -139,9 +187,9 @@ var init_migrate = __esm({
|
|
|
139
187
|
});
|
|
140
188
|
|
|
141
189
|
// src/worlds/ingest.ts
|
|
142
|
-
import * as
|
|
190
|
+
import * as fs4 from "fs";
|
|
143
191
|
import * as os from "os";
|
|
144
|
-
import * as
|
|
192
|
+
import * as path4 from "path";
|
|
145
193
|
var init_ingest = __esm({
|
|
146
194
|
"src/worlds/ingest.ts"() {
|
|
147
195
|
"use strict";
|
|
@@ -161,9 +209,9 @@ function resolveEnv(options) {
|
|
|
161
209
|
}
|
|
162
210
|
return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
|
|
163
211
|
}
|
|
164
|
-
async function apiRequest(options, method,
|
|
212
|
+
async function apiRequest(options, method, path6, body) {
|
|
165
213
|
const { host, publicKey, secretKey } = resolveEnv(options);
|
|
166
|
-
const res = await fetch(`${host}${
|
|
214
|
+
const res = await fetch(`${host}${path6}`, {
|
|
167
215
|
method,
|
|
168
216
|
headers: {
|
|
169
217
|
"content-type": "application/json",
|
|
@@ -172,7 +220,7 @@ async function apiRequest(options, method, path4, body) {
|
|
|
172
220
|
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
173
221
|
});
|
|
174
222
|
const text = await res.text();
|
|
175
|
-
if (!res.ok) throw new ApiError(res.status, method,
|
|
223
|
+
if (!res.ok) throw new ApiError(res.status, method, path6, text.slice(0, 400));
|
|
176
224
|
return JSON.parse(text);
|
|
177
225
|
}
|
|
178
226
|
var ApiError;
|
|
@@ -181,6 +229,9 @@ var init_worlds = __esm({
|
|
|
181
229
|
"use strict";
|
|
182
230
|
init_session();
|
|
183
231
|
init_tasks();
|
|
232
|
+
init_taskSessions();
|
|
233
|
+
init_taskRun();
|
|
234
|
+
init_evals();
|
|
184
235
|
init_browser();
|
|
185
236
|
init_hub();
|
|
186
237
|
init_validate();
|
|
@@ -191,8 +242,8 @@ var init_worlds = __esm({
|
|
|
191
242
|
init_migrate();
|
|
192
243
|
init_ingest();
|
|
193
244
|
ApiError = class extends Error {
|
|
194
|
-
constructor(status, method,
|
|
195
|
-
super(`${method} ${
|
|
245
|
+
constructor(status, method, path6, body) {
|
|
246
|
+
super(`${method} ${path6} -> ${status}: ${body}`);
|
|
196
247
|
this.status = status;
|
|
197
248
|
this.name = "ApiError";
|
|
198
249
|
}
|
|
@@ -202,9 +253,9 @@ var init_worlds = __esm({
|
|
|
202
253
|
|
|
203
254
|
// src/files/index.ts
|
|
204
255
|
init_worlds();
|
|
205
|
-
import { createHash as
|
|
206
|
-
import * as
|
|
207
|
-
import * as
|
|
256
|
+
import { createHash as createHash5 } from "crypto";
|
|
257
|
+
import * as fs5 from "fs";
|
|
258
|
+
import * as path5 from "path";
|
|
208
259
|
import { Readable, Transform } from "stream";
|
|
209
260
|
import { pipeline } from "stream/promises";
|
|
210
261
|
var DRIVE_PREFIX = "drive:";
|
|
@@ -252,9 +303,9 @@ async function readFile(options = {}, filePath) {
|
|
|
252
303
|
async function downloadFile(options = {}, filePath, outPath, onProgress) {
|
|
253
304
|
const file = await getFile(options, filePath);
|
|
254
305
|
const res = await openDownload(file.url);
|
|
255
|
-
|
|
306
|
+
fs5.mkdirSync(path5.dirname(path5.resolve(outPath)), { recursive: true });
|
|
256
307
|
const source = Readable.fromWeb(res.body);
|
|
257
|
-
await pipeline(source, counting((n) => onProgress?.(n, file.sizeBytes)),
|
|
308
|
+
await pipeline(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs5.createWriteStream(outPath));
|
|
258
309
|
return { ...file, out: outPath };
|
|
259
310
|
}
|
|
260
311
|
async function requestUpload(options = {}, body) {
|
|
@@ -264,8 +315,8 @@ async function confirmUpload(options = {}, fileId, ok = true) {
|
|
|
264
315
|
return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
|
|
265
316
|
}
|
|
266
317
|
async function sha256Base64(localPath) {
|
|
267
|
-
const hash =
|
|
268
|
-
for await (const chunk of
|
|
318
|
+
const hash = createHash5("sha256");
|
|
319
|
+
for await (const chunk of fs5.createReadStream(localPath)) hash.update(chunk);
|
|
269
320
|
return hash.digest("base64");
|
|
270
321
|
}
|
|
271
322
|
var CONTENT_TYPES = {
|
|
@@ -301,7 +352,7 @@ var CONTENT_TYPES = {
|
|
|
301
352
|
".mp4": "video/mp4"
|
|
302
353
|
};
|
|
303
354
|
function contentTypeFor(name) {
|
|
304
|
-
return CONTENT_TYPES[
|
|
355
|
+
return CONTENT_TYPES[path5.extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
305
356
|
}
|
|
306
357
|
function counting(report) {
|
|
307
358
|
let seen = 0;
|
|
@@ -328,7 +379,7 @@ async function putPresigned(uploadUrl, body, headers) {
|
|
|
328
379
|
if (!res.ok) throw new Error(`upload failed: storage answered HTTP ${res.status}: ${(await res.text()).slice(0, 300)}`);
|
|
329
380
|
}
|
|
330
381
|
async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
|
|
331
|
-
const stat =
|
|
382
|
+
const stat = fs5.statSync(localPath);
|
|
332
383
|
if (!stat.isFile()) throw new Error(`${localPath} is not a file`);
|
|
333
384
|
if (stat.size === 0) throw new Error(`${localPath} is empty; the drive refuses zero-byte uploads`);
|
|
334
385
|
const contentType = upload.contentType ?? contentTypeFor(localPath);
|
|
@@ -336,7 +387,7 @@ async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
|
|
|
336
387
|
const target = drivePath(targetPath);
|
|
337
388
|
const granted = await requestUpload(options, { path: target, contentLength: stat.size, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
|
|
338
389
|
try {
|
|
339
|
-
const stream =
|
|
390
|
+
const stream = fs5.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
|
|
340
391
|
await putPresigned(granted.uploadUrl, Readable.toWeb(stream), { contentType, contentLength: stat.size, sha256 });
|
|
341
392
|
} catch (error) {
|
|
342
393
|
await confirmUpload(options, granted.fileId, false).catch(() => void 0);
|
|
@@ -349,7 +400,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
|
|
|
349
400
|
if (!bytes.length) throw new Error("nothing to upload: the content is empty");
|
|
350
401
|
const target = drivePath(targetPath);
|
|
351
402
|
const contentType = upload.contentType ?? contentTypeFor(target);
|
|
352
|
-
const sha256 =
|
|
403
|
+
const sha256 = createHash5("sha256").update(bytes).digest("base64");
|
|
353
404
|
const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
|
|
354
405
|
try {
|
|
355
406
|
await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256 });
|