@odla-ai/harness 0.5.0 → 0.5.1
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/{chunk-UVGZHNLW.js → chunk-L2T3LPEF.js} +16 -9
- package/dist/chunk-L2T3LPEF.js.map +1 -0
- package/dist/code-runtime-cli.cjs +15 -8
- package/dist/code-runtime-cli.cjs.map +1 -1
- package/dist/code-runtime-cli.js +1 -1
- package/dist/node.cjs +15 -8
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-UVGZHNLW.js.map +0 -1
package/dist/code-runtime-cli.js
CHANGED
package/dist/node.cjs
CHANGED
|
@@ -1055,6 +1055,7 @@ function parseSnapshot(value) {
|
|
|
1055
1055
|
return { host, bindings, commands };
|
|
1056
1056
|
}
|
|
1057
1057
|
async function parseSource(value) {
|
|
1058
|
+
const repositoryLimits = { maximumFiles: 1e5, maximumBytes: 80 * 1024 * 1024 };
|
|
1058
1059
|
const snapshot = record2(record2(value)?.snapshot);
|
|
1059
1060
|
if (!snapshot || typeof snapshot.repository !== "string" || typeof snapshot.commitSha !== "string" || typeof snapshot.treeDigest !== "string" || !Array.isArray(snapshot.files)) throw invalid("source");
|
|
1060
1061
|
const files = snapshot.files.map((value2) => {
|
|
@@ -1076,12 +1077,12 @@ async function parseSource(value) {
|
|
|
1076
1077
|
return { path: file.path, content: file.content };
|
|
1077
1078
|
});
|
|
1078
1079
|
const source2 = { repository: reference.repository, commitSha: reference.commitSha, files: referenceFiles };
|
|
1079
|
-
const referenceDigest = await (0, import_code.digestCodeRepositorySnapshot)(source2,
|
|
1080
|
+
const referenceDigest = await (0, import_code.digestCodeRepositorySnapshot)(source2, repositoryLimits);
|
|
1080
1081
|
if (referenceDigest !== reference.treeDigest) throw invalid("reference source digest");
|
|
1081
1082
|
references.push({ alias: reference.alias, ...source2, treeDigest: referenceDigest });
|
|
1082
1083
|
}
|
|
1083
1084
|
const source = { repository: snapshot.repository, commitSha: snapshot.commitSha, files };
|
|
1084
|
-
const digest = await (0, import_code.digestCodeRepositorySnapshot)(source,
|
|
1085
|
+
const digest = await (0, import_code.digestCodeRepositorySnapshot)(source, repositoryLimits);
|
|
1085
1086
|
if (digest !== snapshot.treeDigest) throw invalid("source digest");
|
|
1086
1087
|
return { ...source, treeDigest: digest, ...references.length ? { references } : {} };
|
|
1087
1088
|
}
|
|
@@ -1848,8 +1849,11 @@ var import_node_os3 = require("os");
|
|
|
1848
1849
|
var import_node_path8 = require("path");
|
|
1849
1850
|
var RESERVED2 = /* @__PURE__ */ new Set([".git", ".odla", ".wrangler", "node_modules", "dist", "coverage"]);
|
|
1850
1851
|
var SECRET2 = /^(?:\.env(?:\..+)?|\.dev\.vars|credentials(?:\..+)?\.json|dev-token(?:\..+)?\.json)$/i;
|
|
1852
|
+
var SOURCE_MAX_FILES = 1e5;
|
|
1853
|
+
var SOURCE_MAX_BYTES = 80 * 1024 * 1024;
|
|
1854
|
+
var SOURCE_SET_MAX_BYTES = 480 * 1024 * 1024;
|
|
1851
1855
|
async function materializeCodeRuntimeSource(snapshot, tempRoot = (0, import_node_os3.tmpdir)()) {
|
|
1852
|
-
if (!snapshot.files.length || snapshot.files.length >
|
|
1856
|
+
if (!snapshot.files.length || snapshot.files.length > SOURCE_MAX_FILES) throw new TypeError("Code source file count is invalid");
|
|
1853
1857
|
const root = await (0, import_promises8.mkdtemp)((0, import_node_path8.join)(tempRoot, "odla-code-source-"));
|
|
1854
1858
|
const sourceDir = (0, import_node_path8.join)(root, "source");
|
|
1855
1859
|
await (0, import_promises8.mkdir)(sourceDir);
|
|
@@ -1861,7 +1865,7 @@ async function materializeCodeRuntimeSource(snapshot, tempRoot = (0, import_node
|
|
|
1861
1865
|
if (seen.has(file.path)) throw new TypeError("Code source repeats a path");
|
|
1862
1866
|
seen.add(file.path);
|
|
1863
1867
|
bytes += Buffer.byteLength(file.path) + Buffer.byteLength(file.content);
|
|
1864
|
-
if (bytes >
|
|
1868
|
+
if (bytes > SOURCE_MAX_BYTES) throw new TypeError("Code source exceeds its byte bound");
|
|
1865
1869
|
const target = (0, import_node_path8.resolve)(sourceDir, file.path);
|
|
1866
1870
|
if (!target.startsWith(`${(0, import_node_path8.resolve)(sourceDir)}${import_node_path8.sep}`)) throw new TypeError("Code source path escapes its root");
|
|
1867
1871
|
await (0, import_promises8.mkdir)((0, import_node_path8.dirname)(target), { recursive: true });
|
|
@@ -1869,14 +1873,14 @@ async function materializeCodeRuntimeSource(snapshot, tempRoot = (0, import_node
|
|
|
1869
1873
|
}
|
|
1870
1874
|
for (const reference of snapshot.references ?? []) {
|
|
1871
1875
|
validateAlias(reference.alias);
|
|
1872
|
-
if (!reference.files.length || reference.files.length >
|
|
1876
|
+
if (!reference.files.length || reference.files.length > SOURCE_MAX_FILES) throw new TypeError("Code reference file count is invalid");
|
|
1873
1877
|
for (const file of reference.files) {
|
|
1874
1878
|
validatePath(file.path);
|
|
1875
1879
|
const path = `.odla-references/${reference.alias}/${file.path}`;
|
|
1876
1880
|
if (seen.has(path)) throw new TypeError("Code reference repeats a path");
|
|
1877
1881
|
seen.add(path);
|
|
1878
1882
|
bytes += Buffer.byteLength(path) + Buffer.byteLength(file.content);
|
|
1879
|
-
if (bytes >
|
|
1883
|
+
if (bytes > SOURCE_SET_MAX_BYTES) throw new TypeError("Code source set exceeds its byte bound");
|
|
1880
1884
|
const target = (0, import_node_path8.resolve)(sourceDir, path);
|
|
1881
1885
|
if (!target.startsWith(`${(0, import_node_path8.resolve)(sourceDir)}${import_node_path8.sep}`)) throw new TypeError("Code reference path escapes its root");
|
|
1882
1886
|
await (0, import_promises8.mkdir)((0, import_node_path8.dirname)(target), { recursive: true });
|
|
@@ -1902,7 +1906,7 @@ async function attachCodeRuntimeReferences(workspace, references) {
|
|
|
1902
1906
|
validatePath(file.path);
|
|
1903
1907
|
const path = `.odla-references/${reference.alias}/${file.path}`;
|
|
1904
1908
|
bytes += Buffer.byteLength(path) + Buffer.byteLength(file.content);
|
|
1905
|
-
if (bytes >
|
|
1909
|
+
if (bytes > SOURCE_SET_MAX_BYTES - SOURCE_MAX_BYTES) throw new TypeError("Code reference set exceeds its byte bound");
|
|
1906
1910
|
for (const root of [workspace.baselineDir, workspace.workspaceDir]) {
|
|
1907
1911
|
const target = (0, import_node_path8.resolve)(root, path);
|
|
1908
1912
|
if (!target.startsWith(`${(0, import_node_path8.resolve)(root)}${import_node_path8.sep}`)) throw new TypeError("Code reference path escapes its root");
|
|
@@ -1952,7 +1956,10 @@ async function materializeCommandWorkspace(input) {
|
|
|
1952
1956
|
trustedBaseDir: materialized.sourceDir,
|
|
1953
1957
|
trustedBaseCommitSha: source.commitSha,
|
|
1954
1958
|
checkpoint: codeCheckpointPayload(command.payload)
|
|
1955
|
-
})).workspace : await stageWorkspace(materialized.sourceDir
|
|
1959
|
+
})).workspace : await stageWorkspace(materialized.sourceDir, {
|
|
1960
|
+
maxFiles: SOURCE_MAX_FILES,
|
|
1961
|
+
maxBytes: SOURCE_SET_MAX_BYTES
|
|
1962
|
+
});
|
|
1956
1963
|
return { workspace, sourceDigest: source.treeDigest, requestedLocal: null };
|
|
1957
1964
|
} finally {
|
|
1958
1965
|
await materialized.cleanup();
|