@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.
- package/dist/cli.js +1798 -1713
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2412 -2327
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.js +47 -31
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +43 -27
- package/dist/files/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +390 -287
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +375 -271
- package/dist/index.mjs.map +1 -1
- package/dist/traces/index.js +36 -20
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +32 -16
- package/dist/traces/index.mjs.map +1 -1
- package/dist/tracing/index.js +2 -1
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +2 -1
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +26 -22
- package/dist/worlds/index.d.ts +26 -22
- package/dist/worlds/index.js +307 -203
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +297 -193
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +2 -1
- package/runtime/gatewaysdk/environment/_bundle.py +14 -24
- package/runtime/gatewaysdk/environment/schema/api.py +37 -18
- 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 +156 -546
- 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 +6 -4
- 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 +14 -0
- package/runtime/gatewaysdk/environment/world.py +391 -0
- package/skills/hooks-getting-started/SKILL.md +6 -4
package/dist/files/index.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
115
|
+
import_node_crypto4 = require("crypto");
|
|
102
116
|
import_node_zlib = require("zlib");
|
|
103
|
-
|
|
104
|
-
|
|
117
|
+
fs3 = __toESM(require("fs"));
|
|
118
|
+
path3 = __toESM(require("path"));
|
|
105
119
|
init_worlds();
|
|
106
|
-
|
|
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
|
|
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
|
-
|
|
154
|
+
import_node_crypto5 = require("crypto");
|
|
140
155
|
init_json();
|
|
141
|
-
|
|
142
|
-
|
|
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,
|
|
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
|
|
190
|
+
var import_node_crypto6;
|
|
175
191
|
var init_redaction = __esm({
|
|
176
192
|
"src/worlds/redaction.ts"() {
|
|
177
193
|
"use strict";
|
|
178
|
-
|
|
194
|
+
import_node_crypto6 = require("crypto");
|
|
179
195
|
init_json();
|
|
180
196
|
init_transforms();
|
|
181
197
|
}
|
|
@@ -198,13 +214,13 @@ var init_migrate = __esm({
|
|
|
198
214
|
});
|
|
199
215
|
|
|
200
216
|
// src/worlds/ingest.ts
|
|
201
|
-
var
|
|
217
|
+
var fs4, os, path4;
|
|
202
218
|
var init_ingest = __esm({
|
|
203
219
|
"src/worlds/ingest.ts"() {
|
|
204
220
|
"use strict";
|
|
205
|
-
|
|
221
|
+
fs4 = __toESM(require("fs"));
|
|
206
222
|
os = __toESM(require("os"));
|
|
207
|
-
|
|
223
|
+
path4 = __toESM(require("path"));
|
|
208
224
|
init_worlds();
|
|
209
225
|
}
|
|
210
226
|
});
|
|
@@ -221,9 +237,9 @@ function resolveEnv(options) {
|
|
|
221
237
|
}
|
|
222
238
|
return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
|
|
223
239
|
}
|
|
224
|
-
async function apiRequest(options, method,
|
|
240
|
+
async function apiRequest(options, method, path6, body) {
|
|
225
241
|
const { host, publicKey, secretKey } = resolveEnv(options);
|
|
226
|
-
const res = await fetch(`${host}${
|
|
242
|
+
const res = await fetch(`${host}${path6}`, {
|
|
227
243
|
method,
|
|
228
244
|
headers: {
|
|
229
245
|
"content-type": "application/json",
|
|
@@ -232,7 +248,7 @@ async function apiRequest(options, method, path5, body) {
|
|
|
232
248
|
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
233
249
|
});
|
|
234
250
|
const text = await res.text();
|
|
235
|
-
if (!res.ok) throw new ApiError(res.status, method,
|
|
251
|
+
if (!res.ok) throw new ApiError(res.status, method, path6, text.slice(0, 400));
|
|
236
252
|
return JSON.parse(text);
|
|
237
253
|
}
|
|
238
254
|
var ApiError;
|
|
@@ -254,8 +270,8 @@ var init_worlds = __esm({
|
|
|
254
270
|
init_migrate();
|
|
255
271
|
init_ingest();
|
|
256
272
|
ApiError = class extends Error {
|
|
257
|
-
constructor(status, method,
|
|
258
|
-
super(`${method} ${
|
|
273
|
+
constructor(status, method, path6, body) {
|
|
274
|
+
super(`${method} ${path6} -> ${status}: ${body}`);
|
|
259
275
|
this.status = status;
|
|
260
276
|
this.name = "ApiError";
|
|
261
277
|
}
|
|
@@ -287,9 +303,9 @@ __export(files_exports, {
|
|
|
287
303
|
uploadFile: () => uploadFile
|
|
288
304
|
});
|
|
289
305
|
module.exports = __toCommonJS(files_exports);
|
|
290
|
-
var
|
|
291
|
-
var
|
|
292
|
-
var
|
|
306
|
+
var import_node_crypto7 = require("crypto");
|
|
307
|
+
var fs5 = __toESM(require("fs"));
|
|
308
|
+
var path5 = __toESM(require("path"));
|
|
293
309
|
var import_node_stream = require("stream");
|
|
294
310
|
var import_promises = require("stream/promises");
|
|
295
311
|
init_worlds();
|
|
@@ -338,9 +354,9 @@ async function readFile(options = {}, filePath) {
|
|
|
338
354
|
async function downloadFile(options = {}, filePath, outPath, onProgress) {
|
|
339
355
|
const file = await getFile(options, filePath);
|
|
340
356
|
const res = await openDownload(file.url);
|
|
341
|
-
|
|
357
|
+
fs5.mkdirSync(path5.dirname(path5.resolve(outPath)), { recursive: true });
|
|
342
358
|
const source = import_node_stream.Readable.fromWeb(res.body);
|
|
343
|
-
await (0, import_promises.pipeline)(source, counting((n) => onProgress?.(n, file.sizeBytes)),
|
|
359
|
+
await (0, import_promises.pipeline)(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs5.createWriteStream(outPath));
|
|
344
360
|
return { ...file, out: outPath };
|
|
345
361
|
}
|
|
346
362
|
async function requestUpload(options = {}, body) {
|
|
@@ -350,8 +366,8 @@ async function confirmUpload(options = {}, fileId, ok = true) {
|
|
|
350
366
|
return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
|
|
351
367
|
}
|
|
352
368
|
async function sha256Base64(localPath) {
|
|
353
|
-
const hash = (0,
|
|
354
|
-
for await (const chunk of
|
|
369
|
+
const hash = (0, import_node_crypto7.createHash)("sha256");
|
|
370
|
+
for await (const chunk of fs5.createReadStream(localPath)) hash.update(chunk);
|
|
355
371
|
return hash.digest("base64");
|
|
356
372
|
}
|
|
357
373
|
var CONTENT_TYPES = {
|
|
@@ -387,7 +403,7 @@ var CONTENT_TYPES = {
|
|
|
387
403
|
".mp4": "video/mp4"
|
|
388
404
|
};
|
|
389
405
|
function contentTypeFor(name) {
|
|
390
|
-
return CONTENT_TYPES[
|
|
406
|
+
return CONTENT_TYPES[path5.extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
391
407
|
}
|
|
392
408
|
function counting(report) {
|
|
393
409
|
let seen = 0;
|
|
@@ -414,7 +430,7 @@ async function putPresigned(uploadUrl, body, headers) {
|
|
|
414
430
|
if (!res.ok) throw new Error(`upload failed: storage answered HTTP ${res.status}: ${(await res.text()).slice(0, 300)}`);
|
|
415
431
|
}
|
|
416
432
|
async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
|
|
417
|
-
const stat =
|
|
433
|
+
const stat = fs5.statSync(localPath);
|
|
418
434
|
if (!stat.isFile()) throw new Error(`${localPath} is not a file`);
|
|
419
435
|
if (stat.size === 0) throw new Error(`${localPath} is empty; the drive refuses zero-byte uploads`);
|
|
420
436
|
const contentType = upload.contentType ?? contentTypeFor(localPath);
|
|
@@ -422,7 +438,7 @@ async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
|
|
|
422
438
|
const target = drivePath(targetPath);
|
|
423
439
|
const granted = await requestUpload(options, { path: target, contentLength: stat.size, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
|
|
424
440
|
try {
|
|
425
|
-
const stream =
|
|
441
|
+
const stream = fs5.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
|
|
426
442
|
await putPresigned(granted.uploadUrl, import_node_stream.Readable.toWeb(stream), { contentType, contentLength: stat.size, sha256 });
|
|
427
443
|
} catch (error) {
|
|
428
444
|
await confirmUpload(options, granted.fileId, false).catch(() => void 0);
|
|
@@ -435,7 +451,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
|
|
|
435
451
|
if (!bytes.length) throw new Error("nothing to upload: the content is empty");
|
|
436
452
|
const target = drivePath(targetPath);
|
|
437
453
|
const contentType = upload.contentType ?? contentTypeFor(target);
|
|
438
|
-
const sha256 = (0,
|
|
454
|
+
const sha256 = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("base64");
|
|
439
455
|
const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
|
|
440
456
|
try {
|
|
441
457
|
await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256 });
|