@withgateway/sdk 0.3.3 → 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 +4 -3
- package/dist/cli.js +2221 -962
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2212 -953
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.js +81 -19
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +79 -17
- 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.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +903 -221
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +868 -212
- package/dist/index.mjs.map +1 -1
- package/dist/traces/index.js +78 -16
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +76 -14
- package/dist/traces/index.mjs.map +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 +692 -410
- package/dist/worlds/index.d.ts +692 -410
- package/dist/worlds/index.js +740 -197
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +736 -193
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +1 -1
- package/runtime/gatewaysdk/environment/_materialize.py +5 -25
- package/runtime/gatewaysdk/environment/_world.py +58 -65
- 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/schema/admission.py +174 -0
- package/runtime/gatewaysdk/environment/schema/api.py +174 -471
- package/runtime/gatewaysdk/environment/schema/assertions.py +458 -0
- package/runtime/gatewaysdk/environment/schema/batch.py +3 -3
- 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 +230 -18
- package/runtime/gatewaysdk/environment/schema/call_redaction.py +201 -19
- package/runtime/gatewaysdk/environment/schema/cast.py +15 -35
- package/runtime/gatewaysdk/environment/schema/conform.py +6 -27
- package/runtime/gatewaysdk/environment/schema/connector.py +89 -152
- 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 +14 -13
- package/runtime/gatewaysdk/environment/schema/database/base.py +106 -165
- package/runtime/gatewaysdk/environment/schema/database/guard.py +43 -36
- 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 +25 -4
- 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 +437 -0
- package/runtime/gatewaysdk/environment/schema/ledger_spill.py +828 -0
- package/runtime/gatewaysdk/environment/schema/local.py +31 -116
- package/runtime/gatewaysdk/environment/schema/platform.py +15 -17
- 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 +129 -176
- 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/SKILL.md +31 -6
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +12 -8
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +13 -13
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +23 -23
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +11 -6
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +35 -2
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/journal-checks.md +182 -0
- package/runtime/gatewaysdk/environment/schema/snapshot.py +149 -29
- 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 +84 -203
- package/runtime/gatewaysdk/environment/schema/validation.py +69 -1
- 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 +203 -39
- package/runtime/gatewaysdk/environment/schema/world_host.py +953 -0
- package/runtime/gatewaysdk/environment/schema/world_tests.py +9 -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/SKILL.md +31 -6
- package/skills/connector-schema-authoring/connector-worlds.md +129 -7
- package/skills/world-data-ingestion/ROWS.md +12 -8
- package/skills/world-data-ingestion/SKILL.md +13 -13
- package/skills/worlds-getting-started/SKILL.md +23 -23
- package/skills/worlds-getting-started/references/cli-mcp-map.md +11 -6
- package/skills/worlds-getting-started/references/gotchas.md +35 -2
- package/skills/worlds-getting-started/references/journal-checks.md +182 -0
package/dist/files/index.js
CHANGED
|
@@ -65,7 +65,7 @@ function platformTimeoutMs(env = process.env) {
|
|
|
65
65
|
if (Number.isInteger(value) && value > 0) return value;
|
|
66
66
|
throw new Error(`${PLATFORM_TIMEOUT_ENV} must be a positive whole number of milliseconds, not \`${raw}\`.`);
|
|
67
67
|
}
|
|
68
|
-
var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, sleep, RetryPolicy, Attempt, PlatformTransport;
|
|
68
|
+
var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, FETCH_LIMIT, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, sleep, RetryPolicy, Attempt, PlatformTransport;
|
|
69
69
|
var init_transport = __esm({
|
|
70
70
|
"src/worlds/transport.ts"() {
|
|
71
71
|
"use strict";
|
|
@@ -73,7 +73,13 @@ var init_transport = __esm({
|
|
|
73
73
|
PLATFORM_TIMEOUT_DEFAULT_MS = 12e4;
|
|
74
74
|
CHECK_HOST = "Check GATEWAY_HOST (or --host) points at a running platform, then retry.";
|
|
75
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
|
+
};
|
|
76
80
|
CAUSES = {
|
|
81
|
+
UND_ERR_HEADERS_TIMEOUT: FETCH_LIMIT,
|
|
82
|
+
UND_ERR_BODY_TIMEOUT: FETCH_LIMIT,
|
|
77
83
|
ECONNREFUSED: { reason: "connection refused", next: CHECK_HOST },
|
|
78
84
|
ENOTFOUND: { reason: "DNS lookup failed", next: CHECK_HOST },
|
|
79
85
|
EAI_AGAIN: { reason: "DNS lookup failed", next: CHECK_HOST },
|
|
@@ -1519,17 +1525,34 @@ var init_nativeComputer = __esm({
|
|
|
1519
1525
|
});
|
|
1520
1526
|
|
|
1521
1527
|
// src/worlds/sessionContract.ts
|
|
1522
|
-
var CALL_BODY_LIMIT_BYTES, EXPLORATORY_TASK;
|
|
1528
|
+
var CALL_BODY_LIMIT_BYTES, REQUEST_BODY_CAPTURE_BYTES, EXPLORATORY_TASK;
|
|
1523
1529
|
var init_sessionContract = __esm({
|
|
1524
1530
|
"src/worlds/sessionContract.ts"() {
|
|
1525
1531
|
"use strict";
|
|
1526
1532
|
CALL_BODY_LIMIT_BYTES = 4 * 1024 * 1024;
|
|
1533
|
+
REQUEST_BODY_CAPTURE_BYTES = 64 * 1024;
|
|
1527
1534
|
EXPLORATORY_TASK = Object.freeze({
|
|
1528
1535
|
instruction: "exploratory session"
|
|
1529
1536
|
});
|
|
1530
1537
|
}
|
|
1531
1538
|
});
|
|
1532
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
|
+
|
|
1533
1556
|
// src/worlds/sessionReadiness.ts
|
|
1534
1557
|
var READY_TIMEOUT_MS;
|
|
1535
1558
|
var init_sessionReadiness = __esm({
|
|
@@ -1587,6 +1610,8 @@ var init_session2 = __esm({
|
|
|
1587
1610
|
init_browser();
|
|
1588
1611
|
init_nativeComputer();
|
|
1589
1612
|
init_sessionContract();
|
|
1613
|
+
init_toolSchema();
|
|
1614
|
+
init_requestLedger();
|
|
1590
1615
|
init_sessionReadiness();
|
|
1591
1616
|
init_session();
|
|
1592
1617
|
init_taskRef();
|
|
@@ -1615,6 +1640,14 @@ var init_tasks = __esm({
|
|
|
1615
1640
|
}
|
|
1616
1641
|
});
|
|
1617
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
|
+
|
|
1618
1651
|
// src/worlds/surfaceDescriptor.ts
|
|
1619
1652
|
var init_surfaceDescriptor = __esm({
|
|
1620
1653
|
"src/worlds/surfaceDescriptor.ts"() {
|
|
@@ -1741,6 +1774,7 @@ var init_setRun = __esm({
|
|
|
1741
1774
|
var init_requestLog = __esm({
|
|
1742
1775
|
"src/worlds/requestLog.ts"() {
|
|
1743
1776
|
"use strict";
|
|
1777
|
+
init_requestLedger();
|
|
1744
1778
|
}
|
|
1745
1779
|
});
|
|
1746
1780
|
|
|
@@ -1806,10 +1840,14 @@ var init_validate = __esm({
|
|
|
1806
1840
|
});
|
|
1807
1841
|
|
|
1808
1842
|
// src/worlds/sandbox.ts
|
|
1843
|
+
var import_node_crypto6, SANDBOX_WRITE_CHUNK_BYTES, SANDBOX_FILE_MAX_BYTES;
|
|
1809
1844
|
var init_sandbox = __esm({
|
|
1810
1845
|
"src/worlds/sandbox.ts"() {
|
|
1811
1846
|
"use strict";
|
|
1847
|
+
import_node_crypto6 = require("crypto");
|
|
1812
1848
|
init_worlds();
|
|
1849
|
+
SANDBOX_WRITE_CHUNK_BYTES = 4 * 1024 * 1024;
|
|
1850
|
+
SANDBOX_FILE_MAX_BYTES = 256 * 1024 * 1024;
|
|
1813
1851
|
}
|
|
1814
1852
|
});
|
|
1815
1853
|
|
|
@@ -1830,11 +1868,11 @@ var init_json = __esm({
|
|
|
1830
1868
|
});
|
|
1831
1869
|
|
|
1832
1870
|
// src/worlds/transforms.ts
|
|
1833
|
-
var
|
|
1871
|
+
var import_node_crypto7, WHITESPACE, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, hex, SIMPLE, TRANSFORMS;
|
|
1834
1872
|
var init_transforms = __esm({
|
|
1835
1873
|
"src/worlds/transforms.ts"() {
|
|
1836
1874
|
"use strict";
|
|
1837
|
-
|
|
1875
|
+
import_node_crypto7 = require("crypto");
|
|
1838
1876
|
init_json();
|
|
1839
1877
|
WHITESPACE = " \n\r\f\v";
|
|
1840
1878
|
WHITESPACE_EDGES = new RegExp(`^[${WHITESPACE}]+|[${WHITESPACE}]+$`, "g");
|
|
@@ -1850,7 +1888,7 @@ var init_transforms = __esm({
|
|
|
1850
1888
|
const at = value.lastIndexOf("@");
|
|
1851
1889
|
return at === -1 ? "" : value.slice(at + 1).toLowerCase();
|
|
1852
1890
|
};
|
|
1853
|
-
hex = (algorithm, value) => (0,
|
|
1891
|
+
hex = (algorithm, value) => (0, import_node_crypto7.createHash)(algorithm).update(value, "utf8").digest("hex");
|
|
1854
1892
|
SIMPLE = {
|
|
1855
1893
|
lower: (value) => value.toLowerCase(),
|
|
1856
1894
|
upper: (value) => value.toUpperCase(),
|
|
@@ -1870,11 +1908,11 @@ var init_transforms = __esm({
|
|
|
1870
1908
|
});
|
|
1871
1909
|
|
|
1872
1910
|
// src/worlds/redaction.ts
|
|
1873
|
-
var
|
|
1911
|
+
var import_node_crypto8;
|
|
1874
1912
|
var init_redaction = __esm({
|
|
1875
1913
|
"src/worlds/redaction.ts"() {
|
|
1876
1914
|
"use strict";
|
|
1877
|
-
|
|
1915
|
+
import_node_crypto8 = require("crypto");
|
|
1878
1916
|
init_json();
|
|
1879
1917
|
init_transforms();
|
|
1880
1918
|
}
|
|
@@ -1926,31 +1964,45 @@ var init_dryRun = __esm({
|
|
|
1926
1964
|
});
|
|
1927
1965
|
|
|
1928
1966
|
// src/worlds/index.ts
|
|
1929
|
-
function
|
|
1930
|
-
|
|
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;
|
|
1970
|
+
}
|
|
1971
|
+
function parseErrorBody(text, status) {
|
|
1972
|
+
const raw = { detail: text.slice(0, DETAIL_LIMIT), code: null };
|
|
1931
1973
|
let parsed;
|
|
1932
1974
|
try {
|
|
1933
1975
|
parsed = JSON.parse(text);
|
|
1934
1976
|
} catch {
|
|
1935
|
-
return
|
|
1977
|
+
return { detail: (edgeAnswer(text, status) ?? text).slice(0, DETAIL_LIMIT), code: null };
|
|
1936
1978
|
}
|
|
1937
1979
|
if (parsed === null || typeof parsed !== "object") return raw;
|
|
1938
|
-
const { message, code } = parsed;
|
|
1980
|
+
const { message, code, error } = parsed;
|
|
1939
1981
|
const stableCode = typeof code === "string" ? code : null;
|
|
1940
1982
|
if (typeof message !== "string") return { ...raw, code: stableCode };
|
|
1941
|
-
|
|
1942
|
-
|
|
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 };
|
|
1943
1986
|
return {
|
|
1944
|
-
detail: `${
|
|
1987
|
+
detail: `${said} (${stableCode})`.slice(0, DETAIL_LIMIT),
|
|
1945
1988
|
code: stableCode
|
|
1946
1989
|
};
|
|
1947
1990
|
}
|
|
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
|
+
}
|
|
1948
2000
|
async function apiRequest(options, method, path9, body, init = {}) {
|
|
1949
2001
|
const reply = await new PlatformTransport(requirePlatformEndpoint(options)).send(method, path9, body, init);
|
|
1950
2002
|
if (!reply.ok) throw new ApiError(reply.status, method, path9, reply.text);
|
|
1951
2003
|
return JSON.parse(reply.text);
|
|
1952
2004
|
}
|
|
1953
|
-
var ApiError;
|
|
2005
|
+
var ApiError, DETAIL_LIMIT, EDGE_ANSWERS, EDGE_FAILURE, EDGE_PAGE;
|
|
1954
2006
|
var init_worlds = __esm({
|
|
1955
2007
|
"src/worlds/index.ts"() {
|
|
1956
2008
|
"use strict";
|
|
@@ -1963,6 +2015,7 @@ var init_worlds = __esm({
|
|
|
1963
2015
|
init_sessionContract();
|
|
1964
2016
|
init_taskRef();
|
|
1965
2017
|
init_tasks();
|
|
2018
|
+
init_taskGrades();
|
|
1966
2019
|
init_taskSessions();
|
|
1967
2020
|
init_taskRun();
|
|
1968
2021
|
init_setRun();
|
|
@@ -1971,6 +2024,7 @@ var init_worlds = __esm({
|
|
|
1971
2024
|
init_browser();
|
|
1972
2025
|
init_surfaceDescriptor();
|
|
1973
2026
|
init_requestLog();
|
|
2027
|
+
init_requestLedger();
|
|
1974
2028
|
init_browserReconnect();
|
|
1975
2029
|
init_nativeComputer();
|
|
1976
2030
|
init_hub();
|
|
@@ -1987,7 +2041,7 @@ var init_worlds = __esm({
|
|
|
1987
2041
|
init_worldNotice();
|
|
1988
2042
|
ApiError = class extends Error {
|
|
1989
2043
|
constructor(status, method, path9, text) {
|
|
1990
|
-
const parsed = parseErrorBody(text);
|
|
2044
|
+
const parsed = parseErrorBody(text, status);
|
|
1991
2045
|
super(`${method} ${path9} -> ${status}: ${parsed.detail}`);
|
|
1992
2046
|
this.status = status;
|
|
1993
2047
|
this.text = text;
|
|
@@ -1998,6 +2052,14 @@ var init_worlds = __esm({
|
|
|
1998
2052
|
text;
|
|
1999
2053
|
code;
|
|
2000
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.";
|
|
2001
2063
|
}
|
|
2002
2064
|
});
|
|
2003
2065
|
|
|
@@ -2026,7 +2088,7 @@ __export(files_exports, {
|
|
|
2026
2088
|
uploadFile: () => uploadFile
|
|
2027
2089
|
});
|
|
2028
2090
|
module.exports = __toCommonJS(files_exports);
|
|
2029
|
-
var
|
|
2091
|
+
var import_node_crypto9 = require("crypto");
|
|
2030
2092
|
var fs7 = __toESM(require("fs"));
|
|
2031
2093
|
var path8 = __toESM(require("path"));
|
|
2032
2094
|
var import_node_stream = require("stream");
|
|
@@ -2092,7 +2154,7 @@ async function confirmUpload(options = {}, fileId, ok = true) {
|
|
|
2092
2154
|
return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
|
|
2093
2155
|
}
|
|
2094
2156
|
async function sha256Base64(localPath) {
|
|
2095
|
-
const hash = (0,
|
|
2157
|
+
const hash = (0, import_node_crypto9.createHash)("sha256");
|
|
2096
2158
|
for await (const chunk of fs7.createReadStream(localPath)) hash.update(chunk);
|
|
2097
2159
|
return hash.digest("base64");
|
|
2098
2160
|
}
|
|
@@ -2177,7 +2239,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
|
|
|
2177
2239
|
if (!bytes.length) throw new Error("nothing to upload: the content is empty");
|
|
2178
2240
|
const target = drivePath(targetPath);
|
|
2179
2241
|
const contentType = upload.contentType ?? contentTypeFor(target);
|
|
2180
|
-
const sha256 = (0,
|
|
2242
|
+
const sha256 = (0, import_node_crypto9.createHash)("sha256").update(bytes).digest("base64");
|
|
2181
2243
|
const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256, ...upload.overwrite ? { overwrite: true } : {} });
|
|
2182
2244
|
try {
|
|
2183
2245
|
await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256 });
|