@withgateway/sdk 0.2.4 → 0.2.6
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 +4304 -2381
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +4266 -2343
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.js +56 -31
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +52 -27
- package/dist/files/index.mjs.map +1 -1
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +280 -8
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +272 -8
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/{index-1xnxt0Cc.d.ts → index-BO2SNSgy.d.ts} +12 -1
- package/dist/{index-B0R3IgsV.d.mts → index-BaKu5ZSU.d.mts} +124 -2
- package/dist/{index-B0R3IgsV.d.ts → index-BaKu5ZSU.d.ts} +124 -2
- package/dist/{index-C1wDEwH4.d.mts → index-Cz8Q6Keo.d.mts} +12 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1100 -438
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1079 -424
- package/dist/index.mjs.map +1 -1
- package/dist/traces/index.js +45 -20
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +41 -16
- 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 +98 -61
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +98 -61
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +179 -25
- package/dist/worlds/index.d.ts +179 -25
- package/dist/worlds/index.js +639 -284
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +631 -276
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +2 -1
- package/runtime/gatewaysdk/environment/_bundle.py +15 -25
- package/runtime/gatewaysdk/environment/_materialize.py +53 -9
- package/runtime/gatewaysdk/environment/_toml.py +13 -0
- package/runtime/gatewaysdk/environment/schema/api.py +40 -25
- package/runtime/gatewaysdk/environment/schema/batch.py +15 -11
- package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +24 -0
- package/runtime/gatewaysdk/environment/schema/compiler.py +60 -28
- package/runtime/gatewaysdk/environment/schema/conform.py +1 -1
- package/runtime/gatewaysdk/environment/schema/connector.py +1 -1
- package/runtime/gatewaysdk/environment/schema/connectors/google-drive/readers/merge.ingest.toml +25 -0
- package/runtime/gatewaysdk/environment/schema/connectors/google-drive/readers/merge.toml +17 -0
- package/runtime/gatewaysdk/environment/schema/data.py +21 -19
- package/runtime/gatewaysdk/environment/schema/extract.py +1 -5
- package/runtime/gatewaysdk/environment/schema/grading.py +225 -0
- package/runtime/gatewaysdk/environment/schema/host.py +156 -546
- package/runtime/gatewaysdk/environment/schema/host_surfaces.py +1 -5
- package/runtime/gatewaysdk/environment/schema/ingest.py +3 -11
- package/runtime/gatewaysdk/environment/schema/local.py +32 -126
- package/runtime/gatewaysdk/environment/schema/mapping.py +1 -1
- package/runtime/gatewaysdk/environment/schema/platform.py +30 -26
- package/runtime/gatewaysdk/environment/schema/proof.py +237 -0
- package/runtime/gatewaysdk/environment/schema/redaction.py +1 -1
- package/runtime/gatewaysdk/environment/schema/runtime.py +686 -0
- package/runtime/gatewaysdk/environment/schema/scaffold.py +9 -2
- package/runtime/gatewaysdk/environment/schema/skill.py +1 -0
- package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +67 -9
- package/runtime/gatewaysdk/environment/schema/skills/hooks-getting-started/SKILL.md +67 -6
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +4 -1
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +11 -11
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +17 -1
- package/runtime/gatewaysdk/environment/schema/snapshot.py +1 -5
- package/runtime/gatewaysdk/environment/schema/tools_world.py +71 -23
- package/runtime/gatewaysdk/environment/schema/ui.py +1 -5
- package/runtime/gatewaysdk/environment/schema/verbs.py +136 -0
- package/runtime/gatewaysdk/environment/schema/workers.py +14 -0
- package/runtime/gatewaysdk/environment/schema/world_tests.py +1 -1
- package/runtime/gatewaysdk/environment/world.py +507 -0
- package/skills/benchmarks-getting-started/SKILL.md +67 -9
- package/skills/connector-schema-authoring/connector-worlds.md +8 -1
- package/skills/connector-schema-authoring/world-schema.md +1 -1
- package/skills/hooks-getting-started/SKILL.md +67 -6
- package/skills/world-data-ingestion/SKILL.md +4 -1
- package/skills/worlds-getting-started/SKILL.md +11 -11
- package/skills/worlds-getting-started/references/cli-mcp-map.md +17 -1
package/dist/files/index.mjs
CHANGED
|
@@ -67,17 +67,32 @@ var init_taskRun = __esm({
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
// src/worlds/
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
116
|
-
|
|
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) =>
|
|
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
|
|
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
|
|
190
|
+
import * as fs4 from "fs";
|
|
175
191
|
import * as os from "os";
|
|
176
|
-
import * as
|
|
192
|
+
import * as path4 from "path";
|
|
177
193
|
var init_ingest = __esm({
|
|
178
194
|
"src/worlds/ingest.ts"() {
|
|
179
195
|
"use strict";
|
|
@@ -181,6 +197,14 @@ var init_ingest = __esm({
|
|
|
181
197
|
}
|
|
182
198
|
});
|
|
183
199
|
|
|
200
|
+
// src/worlds/sandbox.ts
|
|
201
|
+
var init_sandbox = __esm({
|
|
202
|
+
"src/worlds/sandbox.ts"() {
|
|
203
|
+
"use strict";
|
|
204
|
+
init_worlds();
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
184
208
|
// src/worlds/index.ts
|
|
185
209
|
function resolveEnv(options) {
|
|
186
210
|
const host = options.host ?? process.env.GATEWAY_HOST ?? "https://withgateway.ai";
|
|
@@ -193,9 +217,9 @@ function resolveEnv(options) {
|
|
|
193
217
|
}
|
|
194
218
|
return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
|
|
195
219
|
}
|
|
196
|
-
async function apiRequest(options, method,
|
|
220
|
+
async function apiRequest(options, method, path6, body) {
|
|
197
221
|
const { host, publicKey, secretKey } = resolveEnv(options);
|
|
198
|
-
const res = await fetch(`${host}${
|
|
222
|
+
const res = await fetch(`${host}${path6}`, {
|
|
199
223
|
method,
|
|
200
224
|
headers: {
|
|
201
225
|
"content-type": "application/json",
|
|
@@ -204,7 +228,7 @@ async function apiRequest(options, method, path5, body) {
|
|
|
204
228
|
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
205
229
|
});
|
|
206
230
|
const text = await res.text();
|
|
207
|
-
if (!res.ok) throw new ApiError(res.status, method,
|
|
231
|
+
if (!res.ok) throw new ApiError(res.status, method, path6, text.slice(0, 400));
|
|
208
232
|
return JSON.parse(text);
|
|
209
233
|
}
|
|
210
234
|
var ApiError;
|
|
@@ -225,9 +249,10 @@ var init_worlds = __esm({
|
|
|
225
249
|
init_query();
|
|
226
250
|
init_migrate();
|
|
227
251
|
init_ingest();
|
|
252
|
+
init_sandbox();
|
|
228
253
|
ApiError = class extends Error {
|
|
229
|
-
constructor(status, method,
|
|
230
|
-
super(`${method} ${
|
|
254
|
+
constructor(status, method, path6, body) {
|
|
255
|
+
super(`${method} ${path6} -> ${status}: ${body}`);
|
|
231
256
|
this.status = status;
|
|
232
257
|
this.name = "ApiError";
|
|
233
258
|
}
|
|
@@ -237,9 +262,9 @@ var init_worlds = __esm({
|
|
|
237
262
|
|
|
238
263
|
// src/files/index.ts
|
|
239
264
|
init_worlds();
|
|
240
|
-
import { createHash as
|
|
241
|
-
import * as
|
|
242
|
-
import * as
|
|
265
|
+
import { createHash as createHash5 } from "crypto";
|
|
266
|
+
import * as fs5 from "fs";
|
|
267
|
+
import * as path5 from "path";
|
|
243
268
|
import { Readable, Transform } from "stream";
|
|
244
269
|
import { pipeline } from "stream/promises";
|
|
245
270
|
var DRIVE_PREFIX = "drive:";
|
|
@@ -287,9 +312,9 @@ async function readFile(options = {}, filePath) {
|
|
|
287
312
|
async function downloadFile(options = {}, filePath, outPath, onProgress) {
|
|
288
313
|
const file = await getFile(options, filePath);
|
|
289
314
|
const res = await openDownload(file.url);
|
|
290
|
-
|
|
315
|
+
fs5.mkdirSync(path5.dirname(path5.resolve(outPath)), { recursive: true });
|
|
291
316
|
const source = Readable.fromWeb(res.body);
|
|
292
|
-
await pipeline(source, counting((n) => onProgress?.(n, file.sizeBytes)),
|
|
317
|
+
await pipeline(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs5.createWriteStream(outPath));
|
|
293
318
|
return { ...file, out: outPath };
|
|
294
319
|
}
|
|
295
320
|
async function requestUpload(options = {}, body) {
|
|
@@ -299,8 +324,8 @@ async function confirmUpload(options = {}, fileId, ok = true) {
|
|
|
299
324
|
return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
|
|
300
325
|
}
|
|
301
326
|
async function sha256Base64(localPath) {
|
|
302
|
-
const hash =
|
|
303
|
-
for await (const chunk of
|
|
327
|
+
const hash = createHash5("sha256");
|
|
328
|
+
for await (const chunk of fs5.createReadStream(localPath)) hash.update(chunk);
|
|
304
329
|
return hash.digest("base64");
|
|
305
330
|
}
|
|
306
331
|
var CONTENT_TYPES = {
|
|
@@ -336,7 +361,7 @@ var CONTENT_TYPES = {
|
|
|
336
361
|
".mp4": "video/mp4"
|
|
337
362
|
};
|
|
338
363
|
function contentTypeFor(name) {
|
|
339
|
-
return CONTENT_TYPES[
|
|
364
|
+
return CONTENT_TYPES[path5.extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
340
365
|
}
|
|
341
366
|
function counting(report) {
|
|
342
367
|
let seen = 0;
|
|
@@ -363,7 +388,7 @@ async function putPresigned(uploadUrl, body, headers) {
|
|
|
363
388
|
if (!res.ok) throw new Error(`upload failed: storage answered HTTP ${res.status}: ${(await res.text()).slice(0, 300)}`);
|
|
364
389
|
}
|
|
365
390
|
async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
|
|
366
|
-
const stat =
|
|
391
|
+
const stat = fs5.statSync(localPath);
|
|
367
392
|
if (!stat.isFile()) throw new Error(`${localPath} is not a file`);
|
|
368
393
|
if (stat.size === 0) throw new Error(`${localPath} is empty; the drive refuses zero-byte uploads`);
|
|
369
394
|
const contentType = upload.contentType ?? contentTypeFor(localPath);
|
|
@@ -371,7 +396,7 @@ async function uploadFile(options = {}, localPath, targetPath, upload = {}) {
|
|
|
371
396
|
const target = drivePath(targetPath);
|
|
372
397
|
const granted = await requestUpload(options, { path: target, contentLength: stat.size, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
|
|
373
398
|
try {
|
|
374
|
-
const stream =
|
|
399
|
+
const stream = fs5.createReadStream(localPath).pipe(counting((n) => upload.onProgress?.(n, stat.size)));
|
|
375
400
|
await putPresigned(granted.uploadUrl, Readable.toWeb(stream), { contentType, contentLength: stat.size, sha256 });
|
|
376
401
|
} catch (error) {
|
|
377
402
|
await confirmUpload(options, granted.fileId, false).catch(() => void 0);
|
|
@@ -384,7 +409,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
|
|
|
384
409
|
if (!bytes.length) throw new Error("nothing to upload: the content is empty");
|
|
385
410
|
const target = drivePath(targetPath);
|
|
386
411
|
const contentType = upload.contentType ?? contentTypeFor(target);
|
|
387
|
-
const sha256 =
|
|
412
|
+
const sha256 = createHash5("sha256").update(bytes).digest("base64");
|
|
388
413
|
const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
|
|
389
414
|
try {
|
|
390
415
|
await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256 });
|