@withgateway/sdk 0.3.1 → 0.4.0
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/README.md +8 -6
- package/dist/cli.js +4372 -2265
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +4362 -2256
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.d.mts +1 -1
- package/dist/files/index.d.ts +1 -1
- package/dist/files/index.js +259 -58
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +249 -50
- 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 +124 -11
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +124 -11
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/{index-C3UzD0G3.d.mts → index-CDPQBsU5.d.mts} +19 -3
- package/dist/{index-C3UzD0G3.d.ts → index-CDPQBsU5.d.ts} +19 -3
- package/dist/{index-CBqbB_0J.d.ts → index-DUHmS74p.d.ts} +1 -1
- package/dist/{index-D-AMnAMa.d.mts → index-mJhG3vZU.d.mts} +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2240 -789
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2150 -739
- package/dist/index.mjs.map +1 -1
- package/dist/{media-CbcAfQvd.d.mts → media-BIApiPzS.d.mts} +21 -2
- package/dist/{media-CbcAfQvd.d.ts → media-BIApiPzS.d.ts} +21 -2
- package/dist/traces/index.d.mts +1 -1
- package/dist/traces/index.d.ts +1 -1
- package/dist/traces/index.js +253 -52
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +243 -44
- package/dist/traces/index.mjs.map +1 -1
- package/dist/tracing/index.d.mts +2 -2
- package/dist/tracing/index.d.ts +2 -2
- package/dist/tracing/index.js +75 -13
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +75 -13
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +893 -482
- package/dist/worlds/index.d.ts +893 -482
- package/dist/worlds/index.js +1968 -669
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +1960 -662
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +1 -1
- package/runtime/gatewaysdk/environment/_bundle.py +2 -27
- package/runtime/gatewaysdk/environment/_materialize.py +48 -88
- package/runtime/gatewaysdk/environment/_world.py +155 -237
- package/runtime/gatewaysdk/environment/backing.py +133 -0
- package/runtime/gatewaysdk/environment/core.py +2 -17
- package/runtime/gatewaysdk/environment/legacy_sqlite.py +288 -0
- package/runtime/gatewaysdk/environment/reward_keys.py +25 -0
- package/runtime/gatewaysdk/environment/runtime.py +8 -13
- package/runtime/gatewaysdk/environment/schema/__init__.py +4 -4
- package/runtime/gatewaysdk/environment/schema/admin_routes.py +86 -0
- package/runtime/gatewaysdk/environment/schema/admission.py +174 -0
- package/runtime/gatewaysdk/environment/schema/api.py +347 -892
- package/runtime/gatewaysdk/environment/schema/assertions.py +458 -0
- package/runtime/gatewaysdk/environment/schema/batch.py +44 -39
- package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +17 -5
- package/runtime/gatewaysdk/environment/schema/cache_layout.py +5 -0
- package/runtime/gatewaysdk/environment/schema/call_capture.py +309 -0
- package/runtime/gatewaysdk/environment/schema/call_log.py +503 -0
- package/runtime/gatewaysdk/environment/schema/call_redaction.py +526 -0
- package/runtime/gatewaysdk/environment/schema/cast.py +15 -35
- package/runtime/gatewaysdk/environment/schema/compiler.py +334 -158
- package/runtime/gatewaysdk/environment/schema/conform.py +14 -39
- package/runtime/gatewaysdk/environment/schema/connector.py +113 -211
- package/runtime/gatewaysdk/environment/schema/connectors/confluence/connector.toml +1 -12
- package/runtime/gatewaysdk/environment/schema/connectors/github/connector.toml +1 -0
- package/runtime/gatewaysdk/environment/schema/connectors/servicenow/connector.toml +2 -5
- package/runtime/gatewaysdk/environment/schema/cors.py +54 -0
- package/runtime/gatewaysdk/environment/schema/credentials.py +313 -8
- package/runtime/gatewaysdk/environment/schema/data.py +60 -216
- package/runtime/gatewaysdk/environment/schema/database/__init__.py +24 -0
- package/runtime/gatewaysdk/environment/schema/database/audit.py +121 -0
- package/runtime/gatewaysdk/environment/schema/database/base.py +936 -0
- package/runtime/gatewaysdk/environment/schema/database/budget.py +33 -0
- package/runtime/gatewaysdk/environment/schema/database/connections.py +101 -0
- package/runtime/gatewaysdk/environment/schema/database/engines.py +8 -0
- package/runtime/gatewaysdk/environment/schema/database/guard.py +215 -0
- package/runtime/gatewaysdk/environment/schema/database/ingest.py +154 -0
- package/runtime/gatewaysdk/environment/schema/database/matching.py +58 -0
- package/runtime/gatewaysdk/environment/schema/database/provenance.py +30 -0
- package/runtime/gatewaysdk/environment/schema/database/reads.py +169 -0
- package/runtime/gatewaysdk/environment/schema/database/rows.py +53 -0
- package/runtime/gatewaysdk/environment/schema/database/runtime_rows.py +39 -0
- package/runtime/gatewaysdk/environment/schema/database/sqlite.py +393 -0
- package/runtime/gatewaysdk/environment/schema/declared_routes.py +210 -0
- package/runtime/gatewaysdk/environment/schema/domain_migration.py +236 -0
- package/runtime/gatewaysdk/environment/schema/door.py +899 -0
- package/runtime/gatewaysdk/environment/schema/envelope.py +227 -0
- package/runtime/gatewaysdk/environment/schema/extract.py +6 -13
- package/runtime/gatewaysdk/environment/schema/grading.py +90 -103
- package/runtime/gatewaysdk/environment/schema/handler_errors.py +163 -12
- package/runtime/gatewaysdk/environment/schema/host.py +237 -1795
- package/runtime/gatewaysdk/environment/schema/host_control.py +144 -0
- package/runtime/gatewaysdk/environment/schema/host_handoff.py +370 -0
- package/runtime/gatewaysdk/environment/schema/host_loops.py +97 -0
- package/runtime/gatewaysdk/environment/schema/host_owners.py +121 -0
- package/runtime/gatewaysdk/environment/schema/host_proxy.py +111 -0
- package/runtime/gatewaysdk/environment/schema/host_requests.py +6 -0
- package/runtime/gatewaysdk/environment/schema/host_session.py +126 -0
- package/runtime/gatewaysdk/environment/schema/host_surfaces.py +79 -21
- package/runtime/gatewaysdk/environment/schema/host_transfers.py +127 -0
- package/runtime/gatewaysdk/environment/schema/host_versions.py +242 -0
- package/runtime/gatewaysdk/environment/schema/host_workers.py +577 -0
- package/runtime/gatewaysdk/environment/schema/journal.py +437 -0
- package/runtime/gatewaysdk/environment/schema/lanes.py +53 -0
- package/runtime/gatewaysdk/environment/schema/ledger_spill.py +828 -0
- package/runtime/gatewaysdk/environment/schema/local.py +58 -170
- package/runtime/gatewaysdk/environment/schema/mapping.py +5 -25
- package/runtime/gatewaysdk/environment/schema/openapi_import.py +112 -73
- package/runtime/gatewaysdk/environment/schema/openapi_paging.py +147 -0
- package/runtime/gatewaysdk/environment/schema/openapi_payloads.py +288 -0
- package/runtime/gatewaysdk/environment/schema/openapi_routes.py +97 -102
- package/runtime/gatewaysdk/environment/schema/openapi_schemas.py +113 -30
- package/runtime/gatewaysdk/environment/schema/platform.py +137 -187
- package/runtime/gatewaysdk/environment/schema/platform_import.py +2 -3
- package/runtime/gatewaysdk/environment/schema/platform_query.py +61 -5
- package/runtime/gatewaysdk/environment/schema/primary_key.py +61 -0
- package/runtime/gatewaysdk/environment/schema/proof.py +19 -12
- package/runtime/gatewaysdk/environment/schema/request_body.py +238 -0
- package/runtime/gatewaysdk/environment/schema/request_ledger.py +958 -0
- package/runtime/gatewaysdk/environment/schema/route_bindings.py +25 -3
- package/runtime/gatewaysdk/environment/schema/route_miss.py +54 -0
- package/runtime/gatewaysdk/environment/schema/runtime.py +178 -308
- package/runtime/gatewaysdk/environment/schema/served_names.py +58 -0
- package/runtime/gatewaysdk/environment/schema/session_files.py +275 -0
- package/runtime/gatewaysdk/environment/schema/session_move.py +275 -0
- package/runtime/gatewaysdk/environment/schema/skills/agents/connector-template-author.md +5 -1
- package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +10 -11
- package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +49 -16
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +39 -9
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +27 -27
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +33 -33
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +13 -7
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +49 -1
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/journal-checks.md +182 -0
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/openapi-import.md +50 -21
- package/runtime/gatewaysdk/environment/schema/slack.py +4 -8
- package/runtime/gatewaysdk/environment/schema/snapshot.py +516 -140
- package/runtime/gatewaysdk/environment/schema/spill_files.py +228 -0
- package/runtime/gatewaysdk/environment/schema/store_contract.py +8 -14
- package/runtime/gatewaysdk/environment/schema/tasks.py +267 -276
- package/runtime/gatewaysdk/environment/schema/tools_world.py +146 -242
- package/runtime/gatewaysdk/environment/schema/ui.py +24 -5
- package/runtime/gatewaysdk/environment/schema/ui_static/app.js +100 -130
- package/runtime/gatewaysdk/environment/schema/ui_static/index.html +1 -8
- package/runtime/gatewaysdk/environment/schema/validation.py +235 -41
- package/runtime/gatewaysdk/environment/schema/verbs.py +32 -36
- package/runtime/gatewaysdk/environment/schema/worker.py +6 -4
- package/runtime/gatewaysdk/environment/schema/workers.py +345 -96
- package/runtime/gatewaysdk/environment/schema/world_host.py +953 -0
- package/runtime/gatewaysdk/environment/schema/world_sql.py +81 -0
- package/runtime/gatewaysdk/environment/schema/world_tests.py +80 -50
- package/runtime/gatewaysdk/environment/score.py +57 -0
- package/runtime/gatewaysdk/environment/secret_values.py +36 -0
- package/runtime/gatewaysdk/environment/world.py +43 -4
- package/runtime/gatewaysdk/environment/world_session_contract.py +46 -5
- package/skills/agents/connector-template-author.md +5 -1
- package/skills/benchmarks-getting-started/SKILL.md +10 -11
- package/skills/connector-schema-authoring/SKILL.md +49 -16
- package/skills/connector-schema-authoring/connector-worlds.md +142 -11
- package/skills/connector-schema-authoring/world-schema.md +103 -51
- package/skills/world-data-ingestion/ROWS.md +39 -9
- package/skills/world-data-ingestion/SKILL.md +27 -27
- package/skills/worlds-getting-started/SKILL.md +33 -33
- package/skills/worlds-getting-started/references/cli-mcp-map.md +13 -7
- package/skills/worlds-getting-started/references/gotchas.md +49 -1
- package/skills/worlds-getting-started/references/journal-checks.md +182 -0
- package/skills/worlds-getting-started/references/openapi-import.md +50 -21
- package/runtime/gatewaysdk/environment/schema/store.py +0 -1013
package/dist/files/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '../worlds/index.mjs';
|
|
2
2
|
export { D as DRIVE_PREFIX, a as DriveDownload, b as DriveFile, c as DriveFolder, d as DriveListing, F as FetchHeader, e as FetchToDriveOptions, f as FetchToDriveResult, g as FileConnector, U as UploadOptions, h as UploadResult, j as confirmUpload, k as contentTypeFor, l as createFolder, m as deleteFile, n as downloadFile, o as drivePath, p as fetchToDrive, q as getFile, r as isDriveRef, s as iterateFiles, t as listFileConnectors, u as listFiles, v as moveFile, w as readFile, x as requestUpload, y as sha256Base64, z as syncFileConnector, A as uploadBytes, B as uploadFile } from '../index-FfK4Nump.mjs';
|
|
3
|
-
import '../media-
|
|
3
|
+
import '../media-BIApiPzS.mjs';
|
package/dist/files/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '../worlds/index.js';
|
|
2
2
|
export { D as DRIVE_PREFIX, a as DriveDownload, b as DriveFile, c as DriveFolder, d as DriveListing, F as FetchHeader, e as FetchToDriveOptions, f as FetchToDriveResult, g as FileConnector, U as UploadOptions, h as UploadResult, j as confirmUpload, k as contentTypeFor, l as createFolder, m as deleteFile, n as downloadFile, o as drivePath, p as fetchToDrive, q as getFile, r as isDriveRef, s as iterateFiles, t as listFileConnectors, u as listFiles, v as moveFile, w as readFile, x as requestUpload, y as sha256Base64, z as syncFileConnector, A as uploadBytes, B as uploadFile } from '../index-D-_4Ibcn.js';
|
|
3
|
-
import '../media-
|
|
3
|
+
import '../media-BIApiPzS.js';
|
package/dist/files/index.js
CHANGED
|
@@ -35,6 +35,28 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
35
35
|
));
|
|
36
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
37
|
|
|
38
|
+
// src/worlds/platformEndpoint.ts
|
|
39
|
+
function platformEndpoint(options) {
|
|
40
|
+
const publicKey = options.publicKey ?? process.env.GATEWAY_PUBLIC_KEY;
|
|
41
|
+
const secretKey = options.secretKey ?? process.env.GATEWAY_SECRET_KEY;
|
|
42
|
+
if (!publicKey || !secretKey) return null;
|
|
43
|
+
const host = options.host ?? process.env.GATEWAY_HOST ?? DEFAULT_HOST;
|
|
44
|
+
return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
|
|
45
|
+
}
|
|
46
|
+
function requirePlatformEndpoint(options) {
|
|
47
|
+
const endpoint = platformEndpoint(options);
|
|
48
|
+
if (!endpoint) throw new Error(GATEWAY_KEYS_MISSING);
|
|
49
|
+
return endpoint;
|
|
50
|
+
}
|
|
51
|
+
var DEFAULT_HOST, GATEWAY_KEYS_MISSING;
|
|
52
|
+
var init_platformEndpoint = __esm({
|
|
53
|
+
"src/worlds/platformEndpoint.ts"() {
|
|
54
|
+
"use strict";
|
|
55
|
+
DEFAULT_HOST = "https://withgateway.ai";
|
|
56
|
+
GATEWAY_KEYS_MISSING = "Gateway keys missing: set GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY (or pass publicKey/secretKey).";
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
38
60
|
// src/worlds/transport.ts
|
|
39
61
|
function platformTimeoutMs(env = process.env) {
|
|
40
62
|
const raw = env[PLATFORM_TIMEOUT_ENV];
|
|
@@ -43,7 +65,7 @@ function platformTimeoutMs(env = process.env) {
|
|
|
43
65
|
if (Number.isInteger(value) && value > 0) return value;
|
|
44
66
|
throw new Error(`${PLATFORM_TIMEOUT_ENV} must be a positive whole number of milliseconds, not \`${raw}\`.`);
|
|
45
67
|
}
|
|
46
|
-
var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, PlatformTransport;
|
|
68
|
+
var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, FETCH_LIMIT, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, sleep, RetryPolicy, Attempt, PlatformTransport;
|
|
47
69
|
var init_transport = __esm({
|
|
48
70
|
"src/worlds/transport.ts"() {
|
|
49
71
|
"use strict";
|
|
@@ -51,7 +73,13 @@ var init_transport = __esm({
|
|
|
51
73
|
PLATFORM_TIMEOUT_DEFAULT_MS = 12e4;
|
|
52
74
|
CHECK_HOST = "Check GATEWAY_HOST (or --host) points at a running platform, then retry.";
|
|
53
75
|
RETRY = "Retry; if it repeats, check the network between here and the platform.";
|
|
76
|
+
FETCH_LIMIT = {
|
|
77
|
+
reason: "Node's fetch stopped waiting after 300 s",
|
|
78
|
+
next: "The platform may still be running it: check what it changed before you retry."
|
|
79
|
+
};
|
|
54
80
|
CAUSES = {
|
|
81
|
+
UND_ERR_HEADERS_TIMEOUT: FETCH_LIMIT,
|
|
82
|
+
UND_ERR_BODY_TIMEOUT: FETCH_LIMIT,
|
|
55
83
|
ECONNREFUSED: { reason: "connection refused", next: CHECK_HOST },
|
|
56
84
|
ENOTFOUND: { reason: "DNS lookup failed", next: CHECK_HOST },
|
|
57
85
|
EAI_AGAIN: { reason: "DNS lookup failed", next: CHECK_HOST },
|
|
@@ -105,6 +133,56 @@ var init_transport = __esm({
|
|
|
105
133
|
route;
|
|
106
134
|
failure;
|
|
107
135
|
};
|
|
136
|
+
sleep = (ms) => new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
137
|
+
RetryPolicy = class _RetryPolicy {
|
|
138
|
+
constructor(delaysMs, wait = sleep, budgetMs = Number.POSITIVE_INFINITY, now = Date.now) {
|
|
139
|
+
this.delaysMs = delaysMs;
|
|
140
|
+
this.wait = wait;
|
|
141
|
+
this.budgetMs = budgetMs;
|
|
142
|
+
this.now = now;
|
|
143
|
+
}
|
|
144
|
+
delaysMs;
|
|
145
|
+
wait;
|
|
146
|
+
budgetMs;
|
|
147
|
+
now;
|
|
148
|
+
static NONE = new _RetryPolicy([]);
|
|
149
|
+
/** A platform restart or a short edge outage: no wait starts that would end past five minutes, so a step ends
|
|
150
|
+
* within the budget plus one request timeout. */
|
|
151
|
+
static FILING = new _RetryPolicy([250, 500, 1e3, 2e3, 4e3, 8e3, 16e3, 3e4], sleep, 3e5);
|
|
152
|
+
static TRANSIENT_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
|
|
153
|
+
async run(attempt) {
|
|
154
|
+
const started = this.now();
|
|
155
|
+
for (let tries = 0; ; tries += 1) {
|
|
156
|
+
const outcome = await Attempt.of(attempt);
|
|
157
|
+
const delayMs = this.delaysMs[tries];
|
|
158
|
+
const spent = delayMs === void 0 || this.now() - started + delayMs >= this.budgetMs;
|
|
159
|
+
if (!outcome.transient || spent) return outcome.settle();
|
|
160
|
+
await this.wait(delayMs);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
Attempt = class _Attempt {
|
|
165
|
+
constructor(reply, error, transient) {
|
|
166
|
+
this.reply = reply;
|
|
167
|
+
this.error = error;
|
|
168
|
+
this.transient = transient;
|
|
169
|
+
}
|
|
170
|
+
reply;
|
|
171
|
+
error;
|
|
172
|
+
transient;
|
|
173
|
+
static async of(attempt) {
|
|
174
|
+
try {
|
|
175
|
+
const reply = await attempt();
|
|
176
|
+
return new _Attempt(reply, null, RetryPolicy.TRANSIENT_STATUSES.has(reply.status));
|
|
177
|
+
} catch (error) {
|
|
178
|
+
return new _Attempt(null, error, error instanceof UnreachableError);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
settle() {
|
|
182
|
+
if (this.reply) return this.reply;
|
|
183
|
+
throw this.error;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
108
186
|
PlatformTransport = class {
|
|
109
187
|
constructor(endpoint, timeoutMs = platformTimeoutMs()) {
|
|
110
188
|
this.endpoint = endpoint;
|
|
@@ -118,6 +196,9 @@ var init_transport = __esm({
|
|
|
118
196
|
}
|
|
119
197
|
async send(method, route, body, opts = {}) {
|
|
120
198
|
const timeoutMs = this.budget(opts.timeoutMs);
|
|
199
|
+
return (opts.retry ?? RetryPolicy.NONE).run(() => this.once(method, route, body, timeoutMs));
|
|
200
|
+
}
|
|
201
|
+
async once(method, route, body, timeoutMs) {
|
|
121
202
|
const payload = body === void 0 ? {} : { body: JSON.stringify(body) };
|
|
122
203
|
const controller = new AbortController();
|
|
123
204
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -490,13 +571,13 @@ var init_screen = __esm({
|
|
|
490
571
|
});
|
|
491
572
|
}
|
|
492
573
|
async drag(action) {
|
|
493
|
-
const
|
|
494
|
-
if (
|
|
574
|
+
const path9 = action.args.path ?? [];
|
|
575
|
+
if (path9.length < 2) throw new Error("a drag needs at least two points");
|
|
495
576
|
return this.held(action.args.modifiers ?? [], async () => {
|
|
496
|
-
await this.moveTo(
|
|
577
|
+
await this.moveTo(path9[0]);
|
|
497
578
|
await this.page.mouse.down({ button: "left" });
|
|
498
579
|
try {
|
|
499
|
-
for (const point2 of
|
|
580
|
+
for (const point2 of path9.slice(1)) await this.moveTo(point2, DRAG_STEPS);
|
|
500
581
|
} finally {
|
|
501
582
|
await this.page.mouse.up({ button: "left" });
|
|
502
583
|
}
|
|
@@ -587,7 +668,7 @@ var init_media = __esm({
|
|
|
587
668
|
put;
|
|
588
669
|
maxBytes;
|
|
589
670
|
/** The uploader for `GATEWAY_HOST` / `GATEWAY_PUBLIC_KEY` /
|
|
590
|
-
* `GATEWAY_SECRET_KEY`
|
|
671
|
+
* `GATEWAY_SECRET_KEY` only; null when any is unset, so a run traced with a saved login uploads none. */
|
|
591
672
|
static fromEnv(env = process.env) {
|
|
592
673
|
const host = env.GATEWAY_HOST;
|
|
593
674
|
const publicKey = env.GATEWAY_PUBLIC_KEY;
|
|
@@ -1444,17 +1525,43 @@ var init_nativeComputer = __esm({
|
|
|
1444
1525
|
});
|
|
1445
1526
|
|
|
1446
1527
|
// src/worlds/sessionContract.ts
|
|
1447
|
-
var CALL_BODY_LIMIT_BYTES, EXPLORATORY_TASK;
|
|
1528
|
+
var CALL_BODY_LIMIT_BYTES, REQUEST_BODY_CAPTURE_BYTES, EXPLORATORY_TASK;
|
|
1448
1529
|
var init_sessionContract = __esm({
|
|
1449
1530
|
"src/worlds/sessionContract.ts"() {
|
|
1450
1531
|
"use strict";
|
|
1451
1532
|
CALL_BODY_LIMIT_BYTES = 4 * 1024 * 1024;
|
|
1533
|
+
REQUEST_BODY_CAPTURE_BYTES = 64 * 1024;
|
|
1452
1534
|
EXPLORATORY_TASK = Object.freeze({
|
|
1453
1535
|
instruction: "exploratory session"
|
|
1454
1536
|
});
|
|
1455
1537
|
}
|
|
1456
1538
|
});
|
|
1457
1539
|
|
|
1540
|
+
// src/worlds/toolSchema.ts
|
|
1541
|
+
var init_toolSchema = __esm({
|
|
1542
|
+
"src/worlds/toolSchema.ts"() {
|
|
1543
|
+
"use strict";
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
|
|
1547
|
+
// src/worlds/requestLedger.ts
|
|
1548
|
+
var init_requestLedger = __esm({
|
|
1549
|
+
"src/worlds/requestLedger.ts"() {
|
|
1550
|
+
"use strict";
|
|
1551
|
+
init_worlds();
|
|
1552
|
+
init_sessionContract();
|
|
1553
|
+
}
|
|
1554
|
+
});
|
|
1555
|
+
|
|
1556
|
+
// src/worlds/sessionReadiness.ts
|
|
1557
|
+
var READY_TIMEOUT_MS;
|
|
1558
|
+
var init_sessionReadiness = __esm({
|
|
1559
|
+
"src/worlds/sessionReadiness.ts"() {
|
|
1560
|
+
"use strict";
|
|
1561
|
+
READY_TIMEOUT_MS = 10 * 6e4;
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
|
|
1458
1565
|
// src/tracing/session.ts
|
|
1459
1566
|
var import_async_hooks, processStorage, currentSessionStorage, currentWorldSessionStorage;
|
|
1460
1567
|
var init_session = __esm({
|
|
@@ -1479,8 +1586,22 @@ var init_taskRef = __esm({
|
|
|
1479
1586
|
}
|
|
1480
1587
|
});
|
|
1481
1588
|
|
|
1589
|
+
// src/worlds/worldNotice.ts
|
|
1590
|
+
var init_worldNotice = __esm({
|
|
1591
|
+
"src/worlds/worldNotice.ts"() {
|
|
1592
|
+
"use strict";
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1595
|
+
|
|
1596
|
+
// src/worlds/grade.ts
|
|
1597
|
+
var init_grade = __esm({
|
|
1598
|
+
"src/worlds/grade.ts"() {
|
|
1599
|
+
"use strict";
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
|
|
1482
1603
|
// src/worlds/session.ts
|
|
1483
|
-
var import_node_crypto2,
|
|
1604
|
+
var import_node_crypto2, CALL_TIMEOUT_MS, JUDGED_GRADE_TIMEOUT_MS;
|
|
1484
1605
|
var init_session2 = __esm({
|
|
1485
1606
|
"src/worlds/session.ts"() {
|
|
1486
1607
|
"use strict";
|
|
@@ -1489,10 +1610,15 @@ var init_session2 = __esm({
|
|
|
1489
1610
|
init_browser();
|
|
1490
1611
|
init_nativeComputer();
|
|
1491
1612
|
init_sessionContract();
|
|
1613
|
+
init_toolSchema();
|
|
1614
|
+
init_requestLedger();
|
|
1615
|
+
init_sessionReadiness();
|
|
1492
1616
|
init_session();
|
|
1493
1617
|
init_taskRef();
|
|
1618
|
+
init_worldNotice();
|
|
1619
|
+
init_grade();
|
|
1494
1620
|
init_taskRef();
|
|
1495
|
-
|
|
1621
|
+
init_sessionReadiness();
|
|
1496
1622
|
CALL_TIMEOUT_MS = 3 * 6e4;
|
|
1497
1623
|
JUDGED_GRADE_TIMEOUT_MS = 15 * 6e4;
|
|
1498
1624
|
}
|
|
@@ -1514,6 +1640,14 @@ var init_tasks = __esm({
|
|
|
1514
1640
|
}
|
|
1515
1641
|
});
|
|
1516
1642
|
|
|
1643
|
+
// src/worlds/taskGrades.ts
|
|
1644
|
+
var init_taskGrades = __esm({
|
|
1645
|
+
"src/worlds/taskGrades.ts"() {
|
|
1646
|
+
"use strict";
|
|
1647
|
+
init_worlds();
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
|
|
1517
1651
|
// src/worlds/surfaceDescriptor.ts
|
|
1518
1652
|
var init_surfaceDescriptor = __esm({
|
|
1519
1653
|
"src/worlds/surfaceDescriptor.ts"() {
|
|
@@ -1528,6 +1662,7 @@ var init_taskSessions = __esm({
|
|
|
1528
1662
|
"use strict";
|
|
1529
1663
|
init_worlds();
|
|
1530
1664
|
init_browser();
|
|
1665
|
+
init_grade();
|
|
1531
1666
|
init_surfaceDescriptor();
|
|
1532
1667
|
init_session2();
|
|
1533
1668
|
}
|
|
@@ -1538,13 +1673,52 @@ var init_evals = __esm({
|
|
|
1538
1673
|
"src/worlds/evals.ts"() {
|
|
1539
1674
|
"use strict";
|
|
1540
1675
|
init_worlds();
|
|
1676
|
+
init_transport();
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
|
|
1680
|
+
// src/worlds/runSignals.ts
|
|
1681
|
+
var import_node_os;
|
|
1682
|
+
var init_runSignals = __esm({
|
|
1683
|
+
"src/worlds/runSignals.ts"() {
|
|
1684
|
+
"use strict";
|
|
1685
|
+
import_node_os = require("os");
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
|
|
1689
|
+
// src/worlds/taskRunDir.ts
|
|
1690
|
+
var fs, path;
|
|
1691
|
+
var init_taskRunDir = __esm({
|
|
1692
|
+
"src/worlds/taskRunDir.ts"() {
|
|
1693
|
+
"use strict";
|
|
1694
|
+
fs = __toESM(require("fs"));
|
|
1695
|
+
path = __toESM(require("path"));
|
|
1696
|
+
init_browser();
|
|
1697
|
+
}
|
|
1698
|
+
});
|
|
1699
|
+
|
|
1700
|
+
// src/worlds/taskRunOutcome.ts
|
|
1701
|
+
var init_taskRunOutcome = __esm({
|
|
1702
|
+
"src/worlds/taskRunOutcome.ts"() {
|
|
1703
|
+
"use strict";
|
|
1704
|
+
init_grade();
|
|
1705
|
+
init_taskSessions();
|
|
1541
1706
|
}
|
|
1542
1707
|
});
|
|
1543
1708
|
|
|
1544
1709
|
// src/tracing/prerequisites.ts
|
|
1710
|
+
var OPENTELEMETRY_PEERS, PINNED_PEERS;
|
|
1545
1711
|
var init_prerequisites = __esm({
|
|
1546
1712
|
"src/tracing/prerequisites.ts"() {
|
|
1547
1713
|
"use strict";
|
|
1714
|
+
OPENTELEMETRY_PEERS = {
|
|
1715
|
+
"@opentelemetry/api": "1.9.0",
|
|
1716
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.222.0",
|
|
1717
|
+
"@opentelemetry/resources": "2.11.0",
|
|
1718
|
+
"@opentelemetry/sdk-trace-base": "2.11.0",
|
|
1719
|
+
"@opentelemetry/sdk-trace-node": "2.11.0"
|
|
1720
|
+
};
|
|
1721
|
+
PINNED_PEERS = Object.entries(OPENTELEMETRY_PEERS).map(([name, version]) => `${name}@${version}`).join(" ");
|
|
1548
1722
|
}
|
|
1549
1723
|
});
|
|
1550
1724
|
|
|
@@ -1553,22 +1727,26 @@ var init_taskTracing = __esm({
|
|
|
1553
1727
|
"src/worlds/taskTracing.ts"() {
|
|
1554
1728
|
"use strict";
|
|
1555
1729
|
init_prerequisites();
|
|
1730
|
+
init_platformEndpoint();
|
|
1556
1731
|
}
|
|
1557
1732
|
});
|
|
1558
1733
|
|
|
1559
1734
|
// src/worlds/taskRun.ts
|
|
1560
|
-
var import_node_crypto3,
|
|
1735
|
+
var import_node_crypto3, path2;
|
|
1561
1736
|
var init_taskRun = __esm({
|
|
1562
1737
|
"src/worlds/taskRun.ts"() {
|
|
1563
1738
|
"use strict";
|
|
1564
1739
|
import_node_crypto3 = require("crypto");
|
|
1565
|
-
|
|
1566
|
-
path = __toESM(require("path"));
|
|
1740
|
+
path2 = __toESM(require("path"));
|
|
1567
1741
|
init_browser();
|
|
1568
1742
|
init_evals();
|
|
1743
|
+
init_runSignals();
|
|
1569
1744
|
init_session2();
|
|
1570
1745
|
init_taskSessions();
|
|
1746
|
+
init_taskRunDir();
|
|
1747
|
+
init_taskRunOutcome();
|
|
1571
1748
|
init_taskTracing();
|
|
1749
|
+
init_worldNotice();
|
|
1572
1750
|
}
|
|
1573
1751
|
});
|
|
1574
1752
|
|
|
@@ -1587,6 +1765,7 @@ var init_setRun = __esm({
|
|
|
1587
1765
|
"use strict";
|
|
1588
1766
|
init_worlds();
|
|
1589
1767
|
init_checkoutProvenance();
|
|
1768
|
+
init_runSignals();
|
|
1590
1769
|
init_taskRun();
|
|
1591
1770
|
}
|
|
1592
1771
|
});
|
|
@@ -1595,27 +1774,28 @@ var init_setRun = __esm({
|
|
|
1595
1774
|
var init_requestLog = __esm({
|
|
1596
1775
|
"src/worlds/requestLog.ts"() {
|
|
1597
1776
|
"use strict";
|
|
1777
|
+
init_requestLedger();
|
|
1598
1778
|
}
|
|
1599
1779
|
});
|
|
1600
1780
|
|
|
1601
1781
|
// src/worlds/checkoutTarget.ts
|
|
1602
|
-
var fs2,
|
|
1782
|
+
var fs2, path3;
|
|
1603
1783
|
var init_checkoutTarget = __esm({
|
|
1604
1784
|
"src/worlds/checkoutTarget.ts"() {
|
|
1605
1785
|
"use strict";
|
|
1606
1786
|
fs2 = __toESM(require("fs"));
|
|
1607
|
-
|
|
1787
|
+
path3 = __toESM(require("path"));
|
|
1608
1788
|
}
|
|
1609
1789
|
});
|
|
1610
1790
|
|
|
1611
1791
|
// src/worlds/worldDir.ts
|
|
1612
|
-
var import_node_crypto4, fs3,
|
|
1792
|
+
var import_node_crypto4, fs3, path4, CONNECTOR_SPEC, WORLD_SCHEMA_MARKERS, WORLD_ROOT_MARKERS;
|
|
1613
1793
|
var init_worldDir = __esm({
|
|
1614
1794
|
"src/worlds/worldDir.ts"() {
|
|
1615
1795
|
"use strict";
|
|
1616
1796
|
import_node_crypto4 = require("crypto");
|
|
1617
1797
|
fs3 = __toESM(require("fs"));
|
|
1618
|
-
|
|
1798
|
+
path4 = __toESM(require("path"));
|
|
1619
1799
|
CONNECTOR_SPEC = "connector.toml";
|
|
1620
1800
|
WORLD_SCHEMA_MARKERS = ["schema/world.json", "schema/runtime.json", "schema/lock.json"];
|
|
1621
1801
|
WORLD_ROOT_MARKERS = [CONNECTOR_SPEC, ...WORLD_SCHEMA_MARKERS];
|
|
@@ -1623,30 +1803,30 @@ var init_worldDir = __esm({
|
|
|
1623
1803
|
});
|
|
1624
1804
|
|
|
1625
1805
|
// src/worlds/tar.ts
|
|
1626
|
-
var fs4,
|
|
1806
|
+
var fs4, path5, import_node_zlib;
|
|
1627
1807
|
var init_tar = __esm({
|
|
1628
1808
|
"src/worlds/tar.ts"() {
|
|
1629
1809
|
"use strict";
|
|
1630
1810
|
fs4 = __toESM(require("fs"));
|
|
1631
|
-
|
|
1811
|
+
path5 = __toESM(require("path"));
|
|
1632
1812
|
import_node_zlib = require("zlib");
|
|
1633
1813
|
}
|
|
1634
1814
|
});
|
|
1635
1815
|
|
|
1636
1816
|
// src/worlds/hub.ts
|
|
1637
|
-
var import_node_crypto5, import_node_zlib2, fs5,
|
|
1817
|
+
var import_node_crypto5, import_node_zlib2, fs5, path6, META_RELPATH;
|
|
1638
1818
|
var init_hub = __esm({
|
|
1639
1819
|
"src/worlds/hub.ts"() {
|
|
1640
1820
|
"use strict";
|
|
1641
1821
|
import_node_crypto5 = require("crypto");
|
|
1642
1822
|
import_node_zlib2 = require("zlib");
|
|
1643
1823
|
fs5 = __toESM(require("fs"));
|
|
1644
|
-
|
|
1824
|
+
path6 = __toESM(require("path"));
|
|
1645
1825
|
init_worlds();
|
|
1646
1826
|
init_checkoutTarget();
|
|
1647
1827
|
init_worldDir();
|
|
1648
1828
|
init_tar();
|
|
1649
|
-
META_RELPATH =
|
|
1829
|
+
META_RELPATH = path6.join(".gateway", ".env-metadata.json");
|
|
1650
1830
|
}
|
|
1651
1831
|
});
|
|
1652
1832
|
|
|
@@ -1660,10 +1840,14 @@ var init_validate = __esm({
|
|
|
1660
1840
|
});
|
|
1661
1841
|
|
|
1662
1842
|
// src/worlds/sandbox.ts
|
|
1843
|
+
var import_node_crypto6, SANDBOX_WRITE_CHUNK_BYTES, SANDBOX_FILE_MAX_BYTES;
|
|
1663
1844
|
var init_sandbox = __esm({
|
|
1664
1845
|
"src/worlds/sandbox.ts"() {
|
|
1665
1846
|
"use strict";
|
|
1847
|
+
import_node_crypto6 = require("crypto");
|
|
1666
1848
|
init_worlds();
|
|
1849
|
+
SANDBOX_WRITE_CHUNK_BYTES = 4 * 1024 * 1024;
|
|
1850
|
+
SANDBOX_FILE_MAX_BYTES = 256 * 1024 * 1024;
|
|
1667
1851
|
}
|
|
1668
1852
|
});
|
|
1669
1853
|
|
|
@@ -1684,11 +1868,11 @@ var init_json = __esm({
|
|
|
1684
1868
|
});
|
|
1685
1869
|
|
|
1686
1870
|
// src/worlds/transforms.ts
|
|
1687
|
-
var
|
|
1871
|
+
var import_node_crypto7, WHITESPACE, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, hex, SIMPLE, TRANSFORMS;
|
|
1688
1872
|
var init_transforms = __esm({
|
|
1689
1873
|
"src/worlds/transforms.ts"() {
|
|
1690
1874
|
"use strict";
|
|
1691
|
-
|
|
1875
|
+
import_node_crypto7 = require("crypto");
|
|
1692
1876
|
init_json();
|
|
1693
1877
|
WHITESPACE = " \n\r\f\v";
|
|
1694
1878
|
WHITESPACE_EDGES = new RegExp(`^[${WHITESPACE}]+|[${WHITESPACE}]+$`, "g");
|
|
@@ -1704,7 +1888,7 @@ var init_transforms = __esm({
|
|
|
1704
1888
|
const at = value.lastIndexOf("@");
|
|
1705
1889
|
return at === -1 ? "" : value.slice(at + 1).toLowerCase();
|
|
1706
1890
|
};
|
|
1707
|
-
hex = (algorithm, value) => (0,
|
|
1891
|
+
hex = (algorithm, value) => (0, import_node_crypto7.createHash)(algorithm).update(value, "utf8").digest("hex");
|
|
1708
1892
|
SIMPLE = {
|
|
1709
1893
|
lower: (value) => value.toLowerCase(),
|
|
1710
1894
|
upper: (value) => value.toUpperCase(),
|
|
@@ -1724,11 +1908,11 @@ var init_transforms = __esm({
|
|
|
1724
1908
|
});
|
|
1725
1909
|
|
|
1726
1910
|
// src/worlds/redaction.ts
|
|
1727
|
-
var
|
|
1911
|
+
var import_node_crypto8;
|
|
1728
1912
|
var init_redaction = __esm({
|
|
1729
1913
|
"src/worlds/redaction.ts"() {
|
|
1730
1914
|
"use strict";
|
|
1731
|
-
|
|
1915
|
+
import_node_crypto8 = require("crypto");
|
|
1732
1916
|
init_json();
|
|
1733
1917
|
init_transforms();
|
|
1734
1918
|
}
|
|
@@ -1751,14 +1935,15 @@ var init_migrate = __esm({
|
|
|
1751
1935
|
});
|
|
1752
1936
|
|
|
1753
1937
|
// src/worlds/ingest.ts
|
|
1754
|
-
var fs6, os,
|
|
1938
|
+
var fs6, os, path7;
|
|
1755
1939
|
var init_ingest = __esm({
|
|
1756
1940
|
"src/worlds/ingest.ts"() {
|
|
1757
1941
|
"use strict";
|
|
1758
1942
|
fs6 = __toESM(require("fs"));
|
|
1759
1943
|
os = __toESM(require("os"));
|
|
1760
|
-
|
|
1944
|
+
path7 = __toESM(require("path"));
|
|
1761
1945
|
init_worlds();
|
|
1946
|
+
init_platformEndpoint();
|
|
1762
1947
|
}
|
|
1763
1948
|
});
|
|
1764
1949
|
|
|
@@ -1779,52 +1964,58 @@ var init_dryRun = __esm({
|
|
|
1779
1964
|
});
|
|
1780
1965
|
|
|
1781
1966
|
// src/worlds/index.ts
|
|
1782
|
-
function
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
const secretKey = options.secretKey ?? process.env.GATEWAY_SECRET_KEY;
|
|
1786
|
-
if (!publicKey || !secretKey) {
|
|
1787
|
-
throw new Error(
|
|
1788
|
-
"Gateway keys missing: set GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY (or pass publicKey/secretKey)."
|
|
1789
|
-
);
|
|
1790
|
-
}
|
|
1791
|
-
return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
|
|
1967
|
+
function edgeAnswer(text, status) {
|
|
1968
|
+
if (status !== void 0 && status >= 500) return EDGE_ANSWERS[status] ?? EDGE_FAILURE;
|
|
1969
|
+
return /^\s*</.test(text) ? EDGE_PAGE : null;
|
|
1792
1970
|
}
|
|
1793
|
-
function parseErrorBody(text,
|
|
1794
|
-
const raw = { detail: text.slice(0,
|
|
1971
|
+
function parseErrorBody(text, status) {
|
|
1972
|
+
const raw = { detail: text.slice(0, DETAIL_LIMIT), code: null };
|
|
1795
1973
|
let parsed;
|
|
1796
1974
|
try {
|
|
1797
1975
|
parsed = JSON.parse(text);
|
|
1798
1976
|
} catch {
|
|
1799
|
-
return
|
|
1977
|
+
return { detail: (edgeAnswer(text, status) ?? text).slice(0, DETAIL_LIMIT), code: null };
|
|
1800
1978
|
}
|
|
1801
1979
|
if (parsed === null || typeof parsed !== "object") return raw;
|
|
1802
|
-
const { message, code } = parsed;
|
|
1980
|
+
const { message, code, error } = parsed;
|
|
1803
1981
|
const stableCode = typeof code === "string" ? code : null;
|
|
1804
1982
|
if (typeof message !== "string") return { ...raw, code: stableCode };
|
|
1805
|
-
|
|
1806
|
-
|
|
1983
|
+
const fields = invalidFields(error);
|
|
1984
|
+
const said = fields ? `${message}: ${fields}` : message;
|
|
1985
|
+
if (stableCode === null) return { detail: said.slice(0, DETAIL_LIMIT), code: null };
|
|
1807
1986
|
return {
|
|
1808
|
-
detail: `${
|
|
1987
|
+
detail: `${said} (${stableCode})`.slice(0, DETAIL_LIMIT),
|
|
1809
1988
|
code: stableCode
|
|
1810
1989
|
};
|
|
1811
1990
|
}
|
|
1812
|
-
|
|
1813
|
-
const
|
|
1814
|
-
|
|
1991
|
+
function invalidFields(error) {
|
|
1992
|
+
const issues = Array.isArray(error) ? error : [];
|
|
1993
|
+
return issues.filter(
|
|
1994
|
+
(issue) => issue !== null && typeof issue === "object" && typeof issue.message === "string"
|
|
1995
|
+
).map((issue) => {
|
|
1996
|
+
const path9 = Array.isArray(issue.path) ? issue.path.map(String).join(".") : "";
|
|
1997
|
+
return path9 ? `${path9}: ${issue.message}` : issue.message;
|
|
1998
|
+
}).join("; ");
|
|
1999
|
+
}
|
|
2000
|
+
async function apiRequest(options, method, path9, body, init = {}) {
|
|
2001
|
+
const reply = await new PlatformTransport(requirePlatformEndpoint(options)).send(method, path9, body, init);
|
|
2002
|
+
if (!reply.ok) throw new ApiError(reply.status, method, path9, reply.text);
|
|
1815
2003
|
return JSON.parse(reply.text);
|
|
1816
2004
|
}
|
|
1817
|
-
var ApiError;
|
|
2005
|
+
var ApiError, DETAIL_LIMIT, EDGE_ANSWERS, EDGE_FAILURE, EDGE_PAGE;
|
|
1818
2006
|
var init_worlds = __esm({
|
|
1819
2007
|
"src/worlds/index.ts"() {
|
|
1820
2008
|
"use strict";
|
|
2009
|
+
init_platformEndpoint();
|
|
1821
2010
|
init_transport();
|
|
1822
2011
|
init_transport();
|
|
1823
2012
|
init_session2();
|
|
2013
|
+
init_grade();
|
|
1824
2014
|
init_sessionList();
|
|
1825
2015
|
init_sessionContract();
|
|
1826
2016
|
init_taskRef();
|
|
1827
2017
|
init_tasks();
|
|
2018
|
+
init_taskGrades();
|
|
1828
2019
|
init_taskSessions();
|
|
1829
2020
|
init_taskRun();
|
|
1830
2021
|
init_setRun();
|
|
@@ -1833,6 +2024,7 @@ var init_worlds = __esm({
|
|
|
1833
2024
|
init_browser();
|
|
1834
2025
|
init_surfaceDescriptor();
|
|
1835
2026
|
init_requestLog();
|
|
2027
|
+
init_requestLedger();
|
|
1836
2028
|
init_browserReconnect();
|
|
1837
2029
|
init_nativeComputer();
|
|
1838
2030
|
init_hub();
|
|
@@ -1846,10 +2038,11 @@ var init_worlds = __esm({
|
|
|
1846
2038
|
init_sandbox();
|
|
1847
2039
|
init_editSessions();
|
|
1848
2040
|
init_dryRun();
|
|
2041
|
+
init_worldNotice();
|
|
1849
2042
|
ApiError = class extends Error {
|
|
1850
|
-
constructor(status, method,
|
|
1851
|
-
const parsed = parseErrorBody(text);
|
|
1852
|
-
super(`${method} ${
|
|
2043
|
+
constructor(status, method, path9, text) {
|
|
2044
|
+
const parsed = parseErrorBody(text, status);
|
|
2045
|
+
super(`${method} ${path9} -> ${status}: ${parsed.detail}`);
|
|
1853
2046
|
this.status = status;
|
|
1854
2047
|
this.text = text;
|
|
1855
2048
|
this.name = "ApiError";
|
|
@@ -1859,6 +2052,14 @@ var init_worlds = __esm({
|
|
|
1859
2052
|
text;
|
|
1860
2053
|
code;
|
|
1861
2054
|
};
|
|
2055
|
+
DETAIL_LIMIT = 600;
|
|
2056
|
+
EDGE_ANSWERS = {
|
|
2057
|
+
502: "Bad Gateway from the load balancer in front of the platform, not the platform's answer: the web server dropped the connection or restarted mid-request. Retry; if it repeats, the platform is restarting or overloaded.",
|
|
2058
|
+
503: "Service Unavailable from the load balancer in front of the platform, not the platform's answer: no web server was ready to take the request (a deploy or a restart). Retry in a minute.",
|
|
2059
|
+
504: "Gateway Time-out from the load balancer in front of the platform, not the platform's answer: the request sent nothing back within the load balancer's idle timeout (60 s unless the deployment raises it: Helm ingress.idleTimeoutSeconds) and was cut there, though the platform may still be running it. Check what it changed before you retry."
|
|
2060
|
+
};
|
|
2061
|
+
EDGE_FAILURE = "The platform failed without its JSON error body: a proxy in front of it answered, or the server stopped before its error handler ran. Retry; if it repeats, report the request and the time.";
|
|
2062
|
+
EDGE_PAGE = "An HTML page answered instead of the platform's JSON: a proxy in front of the platform, or the configured host is not the platform.";
|
|
1862
2063
|
}
|
|
1863
2064
|
});
|
|
1864
2065
|
|
|
@@ -1887,9 +2088,9 @@ __export(files_exports, {
|
|
|
1887
2088
|
uploadFile: () => uploadFile
|
|
1888
2089
|
});
|
|
1889
2090
|
module.exports = __toCommonJS(files_exports);
|
|
1890
|
-
var
|
|
2091
|
+
var import_node_crypto9 = require("crypto");
|
|
1891
2092
|
var fs7 = __toESM(require("fs"));
|
|
1892
|
-
var
|
|
2093
|
+
var path8 = __toESM(require("path"));
|
|
1893
2094
|
var import_node_stream = require("stream");
|
|
1894
2095
|
var import_promises = require("stream/promises");
|
|
1895
2096
|
init_worlds();
|
|
@@ -1941,7 +2142,7 @@ async function readFile(options = {}, filePath, limits = {}) {
|
|
|
1941
2142
|
async function downloadFile(options = {}, filePath, outPath, onProgress) {
|
|
1942
2143
|
const file = await getFile(options, filePath);
|
|
1943
2144
|
const res = await openDownload(file.url);
|
|
1944
|
-
fs7.mkdirSync(
|
|
2145
|
+
fs7.mkdirSync(path8.dirname(path8.resolve(outPath)), { recursive: true });
|
|
1945
2146
|
const source = import_node_stream.Readable.fromWeb(res.body);
|
|
1946
2147
|
await (0, import_promises.pipeline)(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs7.createWriteStream(outPath));
|
|
1947
2148
|
return { ...file, out: outPath };
|
|
@@ -1953,7 +2154,7 @@ async function confirmUpload(options = {}, fileId, ok = true) {
|
|
|
1953
2154
|
return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
|
|
1954
2155
|
}
|
|
1955
2156
|
async function sha256Base64(localPath) {
|
|
1956
|
-
const hash = (0,
|
|
2157
|
+
const hash = (0, import_node_crypto9.createHash)("sha256");
|
|
1957
2158
|
for await (const chunk of fs7.createReadStream(localPath)) hash.update(chunk);
|
|
1958
2159
|
return hash.digest("base64");
|
|
1959
2160
|
}
|
|
@@ -1990,7 +2191,7 @@ var CONTENT_TYPES = {
|
|
|
1990
2191
|
".mp4": "video/mp4"
|
|
1991
2192
|
};
|
|
1992
2193
|
function contentTypeFor(name) {
|
|
1993
|
-
return CONTENT_TYPES[
|
|
2194
|
+
return CONTENT_TYPES[path8.extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
1994
2195
|
}
|
|
1995
2196
|
function counting(report) {
|
|
1996
2197
|
let seen = 0;
|
|
@@ -2038,7 +2239,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
|
|
|
2038
2239
|
if (!bytes.length) throw new Error("nothing to upload: the content is empty");
|
|
2039
2240
|
const target = drivePath(targetPath);
|
|
2040
2241
|
const contentType = upload.contentType ?? contentTypeFor(target);
|
|
2041
|
-
const sha256 = (0,
|
|
2242
|
+
const sha256 = (0, import_node_crypto9.createHash)("sha256").update(bytes).digest("base64");
|
|
2042
2243
|
const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
|
|
2043
2244
|
try {
|
|
2044
2245
|
await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256 });
|