@withgateway/sdk 0.3.3 → 0.6.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 +4 -3
- package/dist/cli.js +3005 -1401
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2996 -1392
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.js +128 -37
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +126 -35
- 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-mJhG3vZU.d.mts → index-Di9nNqOY.d.mts} +26 -3
- package/dist/{index-DUHmS74p.d.ts → index-LA-PMRJT.d.ts} +26 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1078 -260
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1040 -251
- package/dist/index.mjs.map +1 -1
- package/dist/replay/index.d.mts +1 -1
- package/dist/replay/index.d.ts +1 -1
- package/dist/replay/index.js.map +1 -1
- package/dist/replay/index.mjs.map +1 -1
- package/dist/traces/index.js +125 -34
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +123 -32
- 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 +7 -1
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +7 -1
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +819 -438
- package/dist/worlds/index.d.ts +819 -438
- package/dist/worlds/index.js +912 -236
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +908 -232
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +1 -1
- package/runtime/gatewaysdk/environment/_bundle.py +4 -6
- package/runtime/gatewaysdk/environment/_materialize.py +5 -25
- package/runtime/gatewaysdk/environment/_world.py +82 -66
- package/runtime/gatewaysdk/environment/backing.py +20 -24
- package/runtime/gatewaysdk/environment/core.py +1 -16
- package/runtime/gatewaysdk/environment/legacy_sqlite.py +14 -27
- package/runtime/gatewaysdk/environment/runtime.py +45 -2
- package/runtime/gatewaysdk/environment/schema/admission.py +174 -0
- package/runtime/gatewaysdk/environment/schema/api.py +198 -474
- package/runtime/gatewaysdk/environment/schema/assertions.py +458 -0
- package/runtime/gatewaysdk/environment/schema/batch.py +3 -3
- package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +1 -0
- package/runtime/gatewaysdk/environment/schema/cache_layout.py +5 -0
- package/runtime/gatewaysdk/environment/schema/call_capture.py +321 -0
- package/runtime/gatewaysdk/environment/schema/call_log.py +276 -18
- package/runtime/gatewaysdk/environment/schema/call_redaction.py +207 -19
- package/runtime/gatewaysdk/environment/schema/cast.py +15 -35
- package/runtime/gatewaysdk/environment/schema/compiler.py +4 -1
- package/runtime/gatewaysdk/environment/schema/conform.py +38 -35
- package/runtime/gatewaysdk/environment/schema/connector.py +94 -152
- package/runtime/gatewaysdk/environment/schema/connectors/confluence/connector.toml +1 -12
- package/runtime/gatewaysdk/environment/schema/connectors/custom/handlers.py +2 -1
- package/runtime/gatewaysdk/environment/schema/connectors/github/api/handlers.py +217 -58
- package/runtime/gatewaysdk/environment/schema/connectors/github/connector.toml +10 -19
- package/runtime/gatewaysdk/environment/schema/connectors/github/scenarios/default/seed/github_webhooks.json +10 -2
- package/runtime/gatewaysdk/environment/schema/connectors/github/tests/webhooks.json +47 -0
- package/runtime/gatewaysdk/environment/schema/connectors/github/world.json +21 -0
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/api/handlers.py +185 -18
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/connector.toml +29 -14
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/provenance.json +43 -12
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/scenarios/default/seed/jamf_webhooks.json +2 -2
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/scope.toml +4 -17
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/tests/webhooks.json +107 -0
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/vendor-openapi.json +1 -1
- package/runtime/gatewaysdk/environment/schema/connectors/linear/api/handlers.py +85 -1
- package/runtime/gatewaysdk/environment/schema/connectors/linear/connector.toml +19 -31
- package/runtime/gatewaysdk/environment/schema/connectors/linear/provenance.json +18 -8
- package/runtime/gatewaysdk/environment/schema/connectors/linear/scenarios/default/seed/webhooks.json +19 -3
- package/runtime/gatewaysdk/environment/schema/connectors/linear/tests/test_webhooks.py +71 -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 +14 -13
- package/runtime/gatewaysdk/environment/schema/database/base.py +106 -165
- package/runtime/gatewaysdk/environment/schema/database/guard.py +45 -37
- package/runtime/gatewaysdk/environment/schema/database/reads.py +169 -0
- package/runtime/gatewaysdk/environment/schema/database/sqlite.py +57 -31
- package/runtime/gatewaysdk/environment/schema/declared_routes.py +210 -0
- package/runtime/gatewaysdk/environment/schema/door.py +899 -0
- package/runtime/gatewaysdk/environment/schema/envelope.py +86 -28
- package/runtime/gatewaysdk/environment/schema/grading.py +58 -86
- package/runtime/gatewaysdk/environment/schema/handler_errors.py +52 -5
- package/runtime/gatewaysdk/environment/schema/host.py +229 -1695
- 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 +438 -0
- package/runtime/gatewaysdk/environment/schema/ledger_spill.py +828 -0
- package/runtime/gatewaysdk/environment/schema/local.py +32 -116
- package/runtime/gatewaysdk/environment/schema/openapi_schemas.py +20 -5
- package/runtime/gatewaysdk/environment/schema/platform.py +29 -234
- 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 +136 -176
- package/runtime/gatewaysdk/environment/schema/scaffold.py +2 -1
- package/runtime/gatewaysdk/environment/schema/session_files.py +133 -24
- 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 +8 -9
- package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/CONNECTORS.md +3 -3
- package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +50 -28
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +12 -8
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +20 -22
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +25 -25
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +24 -16
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +71 -7
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/journal-checks.md +182 -0
- package/runtime/gatewaysdk/environment/schema/snapshot.py +150 -30
- package/runtime/gatewaysdk/environment/schema/spill_files.py +228 -0
- package/runtime/gatewaysdk/environment/schema/tasks.py +229 -323
- package/runtime/gatewaysdk/environment/schema/tools_world.py +103 -203
- package/runtime/gatewaysdk/environment/schema/validation.py +69 -1
- package/runtime/gatewaysdk/environment/schema/verbs.py +38 -36
- package/runtime/gatewaysdk/environment/schema/webhooks.py +687 -0
- package/runtime/gatewaysdk/environment/schema/worker.py +6 -4
- package/runtime/gatewaysdk/environment/schema/workers.py +203 -39
- package/runtime/gatewaysdk/environment/schema/world_host.py +970 -0
- package/runtime/gatewaysdk/environment/schema/world_tests.py +83 -11
- package/runtime/gatewaysdk/environment/world.py +1 -1
- package/runtime/gatewaysdk/environment/world_session_contract.py +14 -0
- package/skills/agents/connector-template-author.md +5 -1
- package/skills/benchmarks-getting-started/SKILL.md +8 -9
- package/skills/connector-schema-authoring/CONNECTORS.md +3 -3
- package/skills/connector-schema-authoring/SKILL.md +50 -28
- package/skills/connector-schema-authoring/connector-worlds.md +282 -18
- package/skills/connector-schema-authoring/world-schema.md +7 -6
- package/skills/world-data-ingestion/ROWS.md +12 -8
- package/skills/world-data-ingestion/SKILL.md +20 -22
- package/skills/worlds-getting-started/SKILL.md +25 -25
- package/skills/worlds-getting-started/references/cli-mcp-map.md +24 -16
- package/skills/worlds-getting-started/references/gotchas.md +71 -7
- package/skills/worlds-getting-started/references/journal-checks.md +182 -0
package/dist/files/index.mjs
CHANGED
|
@@ -46,7 +46,7 @@ function platformTimeoutMs(env = process.env) {
|
|
|
46
46
|
if (Number.isInteger(value) && value > 0) return value;
|
|
47
47
|
throw new Error(`${PLATFORM_TIMEOUT_ENV} must be a positive whole number of milliseconds, not \`${raw}\`.`);
|
|
48
48
|
}
|
|
49
|
-
var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, sleep, RetryPolicy, Attempt, PlatformTransport;
|
|
49
|
+
var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, FETCH_LIMIT, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, sleep, RetryPolicy, Attempt, PlatformTransport;
|
|
50
50
|
var init_transport = __esm({
|
|
51
51
|
"src/worlds/transport.ts"() {
|
|
52
52
|
"use strict";
|
|
@@ -54,7 +54,13 @@ var init_transport = __esm({
|
|
|
54
54
|
PLATFORM_TIMEOUT_DEFAULT_MS = 12e4;
|
|
55
55
|
CHECK_HOST = "Check GATEWAY_HOST (or --host) points at a running platform, then retry.";
|
|
56
56
|
RETRY = "Retry; if it repeats, check the network between here and the platform.";
|
|
57
|
+
FETCH_LIMIT = {
|
|
58
|
+
reason: "Node's fetch stopped waiting after 300 s",
|
|
59
|
+
next: "The platform may still be running it: check what it changed before you retry."
|
|
60
|
+
};
|
|
57
61
|
CAUSES = {
|
|
62
|
+
UND_ERR_HEADERS_TIMEOUT: FETCH_LIMIT,
|
|
63
|
+
UND_ERR_BODY_TIMEOUT: FETCH_LIMIT,
|
|
58
64
|
ECONNREFUSED: { reason: "connection refused", next: CHECK_HOST },
|
|
59
65
|
ENOTFOUND: { reason: "DNS lookup failed", next: CHECK_HOST },
|
|
60
66
|
EAI_AGAIN: { reason: "DNS lookup failed", next: CHECK_HOST },
|
|
@@ -1061,7 +1067,7 @@ function click(button, count) {
|
|
|
1061
1067
|
modifiers: modifierChord(raw.text)
|
|
1062
1068
|
});
|
|
1063
1069
|
}
|
|
1064
|
-
var SCROLL_STEP_PX, NOT_EXECUTED, MAX_ERROR2, SCROLL_DIRECTIONS, MEMBERS, AnthropicComputer, AnthropicComputer20251124;
|
|
1070
|
+
var SCROLL_STEP_PX, NOT_EXECUTED, MAX_ERROR2, SCROLL_DIRECTIONS, IMAGE_PARTS, MEMBERS, AnthropicComputer, AnthropicComputer20251124;
|
|
1065
1071
|
var init_anthropic = __esm({
|
|
1066
1072
|
"src/worlds/nativeComputer/anthropic.ts"() {
|
|
1067
1073
|
"use strict";
|
|
@@ -1077,6 +1083,14 @@ var init_anthropic = __esm({
|
|
|
1077
1083
|
left: [-1, 0],
|
|
1078
1084
|
right: [1, 0]
|
|
1079
1085
|
};
|
|
1086
|
+
IMAGE_PARTS = {
|
|
1087
|
+
6: (data) => ({ type: "image-data", data, mediaType: "image/png" }),
|
|
1088
|
+
7: (data) => ({
|
|
1089
|
+
type: "file",
|
|
1090
|
+
mediaType: "image/png",
|
|
1091
|
+
data: { type: "data", data }
|
|
1092
|
+
})
|
|
1093
|
+
};
|
|
1080
1094
|
MEMBERS = {
|
|
1081
1095
|
screenshot: () => new ComputerAction("screenshot"),
|
|
1082
1096
|
zoom: (raw) => new ComputerAction("zoom", {
|
|
@@ -1186,15 +1200,17 @@ var init_anthropic = __esm({
|
|
|
1186
1200
|
];
|
|
1187
1201
|
return [{ type: "text", text: result.text ?? "OK" }];
|
|
1188
1202
|
}
|
|
1189
|
-
/** For `anthropic.tools.computerToolset_20260801(
|
|
1190
|
-
* (or `computer_20251124` with the legacy kind
|
|
1191
|
-
* and returns `{ type: "image", data }` or
|
|
1192
|
-
* into the tool result
|
|
1203
|
+
/** For `anthropic.tools.computerToolset_20260801(computer.aiSdk({ version: 7 }))`
|
|
1204
|
+
* (AI SDK 7 only), or `computer_20251124` with the legacy kind (AI SDK 6
|
|
1205
|
+
* and 7): `execute` runs one action and returns `{ type: "image", data }` or
|
|
1206
|
+
* text; `toModelOutput` turns that into the tool result in the part shape
|
|
1207
|
+
* of `options.version`. Calls run one at a time, and once a call fails the
|
|
1193
1208
|
* rest of that step's calls answer as not executed. */
|
|
1194
|
-
aiSdk() {
|
|
1209
|
+
aiSdk(options = {}) {
|
|
1210
|
+
const imagePart = _AnthropicComputer.imagePart(options);
|
|
1195
1211
|
let failedStep;
|
|
1196
|
-
const execute = (input,
|
|
1197
|
-
const step =
|
|
1212
|
+
const execute = (input, options2) => this.serial(async () => {
|
|
1213
|
+
const step = options2?.messages?.length;
|
|
1198
1214
|
if (step !== void 0 && step === failedStep)
|
|
1199
1215
|
throw new Error(NOT_EXECUTED);
|
|
1200
1216
|
try {
|
|
@@ -1206,7 +1222,7 @@ var init_anthropic = __esm({
|
|
|
1206
1222
|
});
|
|
1207
1223
|
return {
|
|
1208
1224
|
execute,
|
|
1209
|
-
toModelOutput: ({ output }) => _AnthropicComputer.
|
|
1225
|
+
toModelOutput: ({ output }) => _AnthropicComputer.modelOutput(output, imagePart)
|
|
1210
1226
|
};
|
|
1211
1227
|
}
|
|
1212
1228
|
static aiSdkOutput(result) {
|
|
@@ -1214,16 +1230,26 @@ var init_anthropic = __esm({
|
|
|
1214
1230
|
return { type: "image", data: result.image.toString("base64") };
|
|
1215
1231
|
return result.text ?? "OK";
|
|
1216
1232
|
}
|
|
1217
|
-
/**
|
|
1218
|
-
*
|
|
1219
|
-
|
|
1233
|
+
/** A screenshot as the image part of AI SDK `options.version`:
|
|
1234
|
+
* `image-data` for 6 (the default), `file` with `{ type: "data", data }`
|
|
1235
|
+
* for 7. */
|
|
1236
|
+
static aiSdkModelOutput(output, options = {}) {
|
|
1237
|
+
return _AnthropicComputer.modelOutput(
|
|
1238
|
+
output,
|
|
1239
|
+
_AnthropicComputer.imagePart(options)
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1242
|
+
static imagePart({
|
|
1243
|
+
version = 6
|
|
1244
|
+
}) {
|
|
1245
|
+
if (Object.hasOwn(IMAGE_PARTS, version)) return IMAGE_PARTS[version];
|
|
1246
|
+
throw new Error(
|
|
1247
|
+
`unsupported AI SDK version ${version}; choose ${Object.keys(IMAGE_PARTS).join(" or ")}`
|
|
1248
|
+
);
|
|
1249
|
+
}
|
|
1250
|
+
static modelOutput(output, imagePart) {
|
|
1220
1251
|
if (typeof output === "string") return { type: "text", value: output };
|
|
1221
|
-
return {
|
|
1222
|
-
type: "content",
|
|
1223
|
-
value: [
|
|
1224
|
-
{ type: "image-data", data: output.data, mediaType: "image/png" }
|
|
1225
|
-
]
|
|
1226
|
-
};
|
|
1252
|
+
return { type: "content", value: [imagePart(output.data)] };
|
|
1227
1253
|
}
|
|
1228
1254
|
envelope(block, content, isError = false) {
|
|
1229
1255
|
return {
|
|
@@ -1500,17 +1526,34 @@ var init_nativeComputer = __esm({
|
|
|
1500
1526
|
});
|
|
1501
1527
|
|
|
1502
1528
|
// src/worlds/sessionContract.ts
|
|
1503
|
-
var CALL_BODY_LIMIT_BYTES, EXPLORATORY_TASK;
|
|
1529
|
+
var CALL_BODY_LIMIT_BYTES, REQUEST_BODY_CAPTURE_BYTES, EXPLORATORY_TASK;
|
|
1504
1530
|
var init_sessionContract = __esm({
|
|
1505
1531
|
"src/worlds/sessionContract.ts"() {
|
|
1506
1532
|
"use strict";
|
|
1507
1533
|
CALL_BODY_LIMIT_BYTES = 4 * 1024 * 1024;
|
|
1534
|
+
REQUEST_BODY_CAPTURE_BYTES = 64 * 1024;
|
|
1508
1535
|
EXPLORATORY_TASK = Object.freeze({
|
|
1509
1536
|
instruction: "exploratory session"
|
|
1510
1537
|
});
|
|
1511
1538
|
}
|
|
1512
1539
|
});
|
|
1513
1540
|
|
|
1541
|
+
// src/worlds/toolSchema.ts
|
|
1542
|
+
var init_toolSchema = __esm({
|
|
1543
|
+
"src/worlds/toolSchema.ts"() {
|
|
1544
|
+
"use strict";
|
|
1545
|
+
}
|
|
1546
|
+
});
|
|
1547
|
+
|
|
1548
|
+
// src/worlds/requestLedger.ts
|
|
1549
|
+
var init_requestLedger = __esm({
|
|
1550
|
+
"src/worlds/requestLedger.ts"() {
|
|
1551
|
+
"use strict";
|
|
1552
|
+
init_worlds();
|
|
1553
|
+
init_sessionContract();
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
|
|
1514
1557
|
// src/worlds/sessionReadiness.ts
|
|
1515
1558
|
var READY_TIMEOUT_MS;
|
|
1516
1559
|
var init_sessionReadiness = __esm({
|
|
@@ -1568,6 +1611,8 @@ var init_session2 = __esm({
|
|
|
1568
1611
|
init_browser();
|
|
1569
1612
|
init_nativeComputer();
|
|
1570
1613
|
init_sessionContract();
|
|
1614
|
+
init_toolSchema();
|
|
1615
|
+
init_requestLedger();
|
|
1571
1616
|
init_sessionReadiness();
|
|
1572
1617
|
init_session();
|
|
1573
1618
|
init_taskRef();
|
|
@@ -1596,6 +1641,14 @@ var init_tasks = __esm({
|
|
|
1596
1641
|
}
|
|
1597
1642
|
});
|
|
1598
1643
|
|
|
1644
|
+
// src/worlds/taskGrades.ts
|
|
1645
|
+
var init_taskGrades = __esm({
|
|
1646
|
+
"src/worlds/taskGrades.ts"() {
|
|
1647
|
+
"use strict";
|
|
1648
|
+
init_worlds();
|
|
1649
|
+
}
|
|
1650
|
+
});
|
|
1651
|
+
|
|
1599
1652
|
// src/worlds/surfaceDescriptor.ts
|
|
1600
1653
|
var init_surfaceDescriptor = __esm({
|
|
1601
1654
|
"src/worlds/surfaceDescriptor.ts"() {
|
|
@@ -1718,6 +1771,15 @@ var init_setRun = __esm({
|
|
|
1718
1771
|
var init_requestLog = __esm({
|
|
1719
1772
|
"src/worlds/requestLog.ts"() {
|
|
1720
1773
|
"use strict";
|
|
1774
|
+
init_requestLedger();
|
|
1775
|
+
}
|
|
1776
|
+
});
|
|
1777
|
+
|
|
1778
|
+
// src/worlds/webhooks.ts
|
|
1779
|
+
var init_webhooks = __esm({
|
|
1780
|
+
"src/worlds/webhooks.ts"() {
|
|
1781
|
+
"use strict";
|
|
1782
|
+
init_worlds();
|
|
1721
1783
|
}
|
|
1722
1784
|
});
|
|
1723
1785
|
|
|
@@ -1781,10 +1843,14 @@ var init_validate = __esm({
|
|
|
1781
1843
|
});
|
|
1782
1844
|
|
|
1783
1845
|
// src/worlds/sandbox.ts
|
|
1846
|
+
import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
|
|
1847
|
+
var SANDBOX_WRITE_CHUNK_BYTES, SANDBOX_FILE_MAX_BYTES;
|
|
1784
1848
|
var init_sandbox = __esm({
|
|
1785
1849
|
"src/worlds/sandbox.ts"() {
|
|
1786
1850
|
"use strict";
|
|
1787
1851
|
init_worlds();
|
|
1852
|
+
SANDBOX_WRITE_CHUNK_BYTES = 4 * 1024 * 1024;
|
|
1853
|
+
SANDBOX_FILE_MAX_BYTES = 256 * 1024 * 1024;
|
|
1788
1854
|
}
|
|
1789
1855
|
});
|
|
1790
1856
|
|
|
@@ -1805,7 +1871,7 @@ var init_json = __esm({
|
|
|
1805
1871
|
});
|
|
1806
1872
|
|
|
1807
1873
|
// src/worlds/transforms.ts
|
|
1808
|
-
import { createHash as
|
|
1874
|
+
import { createHash as createHash5 } from "crypto";
|
|
1809
1875
|
var WHITESPACE, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, hex, SIMPLE, TRANSFORMS;
|
|
1810
1876
|
var init_transforms = __esm({
|
|
1811
1877
|
"src/worlds/transforms.ts"() {
|
|
@@ -1825,7 +1891,7 @@ var init_transforms = __esm({
|
|
|
1825
1891
|
const at = value.lastIndexOf("@");
|
|
1826
1892
|
return at === -1 ? "" : value.slice(at + 1).toLowerCase();
|
|
1827
1893
|
};
|
|
1828
|
-
hex = (algorithm, value) =>
|
|
1894
|
+
hex = (algorithm, value) => createHash5(algorithm).update(value, "utf8").digest("hex");
|
|
1829
1895
|
SIMPLE = {
|
|
1830
1896
|
lower: (value) => value.toLowerCase(),
|
|
1831
1897
|
upper: (value) => value.toUpperCase(),
|
|
@@ -1845,7 +1911,7 @@ var init_transforms = __esm({
|
|
|
1845
1911
|
});
|
|
1846
1912
|
|
|
1847
1913
|
// src/worlds/redaction.ts
|
|
1848
|
-
import { createHash as
|
|
1914
|
+
import { createHash as createHash6 } from "crypto";
|
|
1849
1915
|
var init_redaction = __esm({
|
|
1850
1916
|
"src/worlds/redaction.ts"() {
|
|
1851
1917
|
"use strict";
|
|
@@ -1899,31 +1965,45 @@ var init_dryRun = __esm({
|
|
|
1899
1965
|
});
|
|
1900
1966
|
|
|
1901
1967
|
// src/worlds/index.ts
|
|
1902
|
-
function
|
|
1903
|
-
|
|
1968
|
+
function edgeAnswer(text, status) {
|
|
1969
|
+
if (status !== void 0 && status >= 500) return EDGE_ANSWERS[status] ?? EDGE_FAILURE;
|
|
1970
|
+
return /^\s*</.test(text) ? EDGE_PAGE : null;
|
|
1971
|
+
}
|
|
1972
|
+
function parseErrorBody(text, status) {
|
|
1973
|
+
const raw = { detail: text.slice(0, DETAIL_LIMIT), code: null };
|
|
1904
1974
|
let parsed;
|
|
1905
1975
|
try {
|
|
1906
1976
|
parsed = JSON.parse(text);
|
|
1907
1977
|
} catch {
|
|
1908
|
-
return
|
|
1978
|
+
return { detail: (edgeAnswer(text, status) ?? text).slice(0, DETAIL_LIMIT), code: null };
|
|
1909
1979
|
}
|
|
1910
1980
|
if (parsed === null || typeof parsed !== "object") return raw;
|
|
1911
|
-
const { message, code } = parsed;
|
|
1981
|
+
const { message, code, error } = parsed;
|
|
1912
1982
|
const stableCode = typeof code === "string" ? code : null;
|
|
1913
1983
|
if (typeof message !== "string") return { ...raw, code: stableCode };
|
|
1914
|
-
|
|
1915
|
-
|
|
1984
|
+
const fields = invalidFields(error);
|
|
1985
|
+
const said = fields ? `${message}: ${fields}` : message;
|
|
1986
|
+
if (stableCode === null) return { detail: said.slice(0, DETAIL_LIMIT), code: null };
|
|
1916
1987
|
return {
|
|
1917
|
-
detail: `${
|
|
1988
|
+
detail: `${said} (${stableCode})`.slice(0, DETAIL_LIMIT),
|
|
1918
1989
|
code: stableCode
|
|
1919
1990
|
};
|
|
1920
1991
|
}
|
|
1992
|
+
function invalidFields(error) {
|
|
1993
|
+
const issues = Array.isArray(error) ? error : [];
|
|
1994
|
+
return issues.filter(
|
|
1995
|
+
(issue) => issue !== null && typeof issue === "object" && typeof issue.message === "string"
|
|
1996
|
+
).map((issue) => {
|
|
1997
|
+
const path9 = Array.isArray(issue.path) ? issue.path.map(String).join(".") : "";
|
|
1998
|
+
return path9 ? `${path9}: ${issue.message}` : issue.message;
|
|
1999
|
+
}).join("; ");
|
|
2000
|
+
}
|
|
1921
2001
|
async function apiRequest(options, method, path9, body, init = {}) {
|
|
1922
2002
|
const reply = await new PlatformTransport(requirePlatformEndpoint(options)).send(method, path9, body, init);
|
|
1923
2003
|
if (!reply.ok) throw new ApiError(reply.status, method, path9, reply.text);
|
|
1924
2004
|
return JSON.parse(reply.text);
|
|
1925
2005
|
}
|
|
1926
|
-
var ApiError;
|
|
2006
|
+
var ApiError, DETAIL_LIMIT, EDGE_ANSWERS, EDGE_FAILURE, EDGE_PAGE;
|
|
1927
2007
|
var init_worlds = __esm({
|
|
1928
2008
|
"src/worlds/index.ts"() {
|
|
1929
2009
|
"use strict";
|
|
@@ -1936,6 +2016,7 @@ var init_worlds = __esm({
|
|
|
1936
2016
|
init_sessionContract();
|
|
1937
2017
|
init_taskRef();
|
|
1938
2018
|
init_tasks();
|
|
2019
|
+
init_taskGrades();
|
|
1939
2020
|
init_taskSessions();
|
|
1940
2021
|
init_taskRun();
|
|
1941
2022
|
init_setRun();
|
|
@@ -1944,6 +2025,8 @@ var init_worlds = __esm({
|
|
|
1944
2025
|
init_browser();
|
|
1945
2026
|
init_surfaceDescriptor();
|
|
1946
2027
|
init_requestLog();
|
|
2028
|
+
init_requestLedger();
|
|
2029
|
+
init_webhooks();
|
|
1947
2030
|
init_browserReconnect();
|
|
1948
2031
|
init_nativeComputer();
|
|
1949
2032
|
init_hub();
|
|
@@ -1960,7 +2043,7 @@ var init_worlds = __esm({
|
|
|
1960
2043
|
init_worldNotice();
|
|
1961
2044
|
ApiError = class extends Error {
|
|
1962
2045
|
constructor(status, method, path9, text) {
|
|
1963
|
-
const parsed = parseErrorBody(text);
|
|
2046
|
+
const parsed = parseErrorBody(text, status);
|
|
1964
2047
|
super(`${method} ${path9} -> ${status}: ${parsed.detail}`);
|
|
1965
2048
|
this.status = status;
|
|
1966
2049
|
this.text = text;
|
|
@@ -1971,12 +2054,20 @@ var init_worlds = __esm({
|
|
|
1971
2054
|
text;
|
|
1972
2055
|
code;
|
|
1973
2056
|
};
|
|
2057
|
+
DETAIL_LIMIT = 600;
|
|
2058
|
+
EDGE_ANSWERS = {
|
|
2059
|
+
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.",
|
|
2060
|
+
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.",
|
|
2061
|
+
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."
|
|
2062
|
+
};
|
|
2063
|
+
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.";
|
|
2064
|
+
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.";
|
|
1974
2065
|
}
|
|
1975
2066
|
});
|
|
1976
2067
|
|
|
1977
2068
|
// src/files/index.ts
|
|
1978
2069
|
init_worlds();
|
|
1979
|
-
import { createHash as
|
|
2070
|
+
import { createHash as createHash7 } from "crypto";
|
|
1980
2071
|
import * as fs7 from "fs";
|
|
1981
2072
|
import * as path8 from "path";
|
|
1982
2073
|
import { Readable, Transform } from "stream";
|
|
@@ -2041,7 +2132,7 @@ async function confirmUpload(options = {}, fileId, ok = true) {
|
|
|
2041
2132
|
return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
|
|
2042
2133
|
}
|
|
2043
2134
|
async function sha256Base64(localPath) {
|
|
2044
|
-
const hash =
|
|
2135
|
+
const hash = createHash7("sha256");
|
|
2045
2136
|
for await (const chunk of fs7.createReadStream(localPath)) hash.update(chunk);
|
|
2046
2137
|
return hash.digest("base64");
|
|
2047
2138
|
}
|
|
@@ -2126,7 +2217,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
|
|
|
2126
2217
|
if (!bytes.length) throw new Error("nothing to upload: the content is empty");
|
|
2127
2218
|
const target = drivePath(targetPath);
|
|
2128
2219
|
const contentType = upload.contentType ?? contentTypeFor(target);
|
|
2129
|
-
const sha256 =
|
|
2220
|
+
const sha256 = createHash7("sha256").update(bytes).digest("base64");
|
|
2130
2221
|
const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
|
|
2131
2222
|
try {
|
|
2132
2223
|
await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256 });
|