@tangle-network/agent-runtime 0.185.1 → 0.187.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/{activation-h6zO-0Rd.js → activation-CpEoQaj5.js} +3 -3
- package/dist/{activation-h6zO-0Rd.js.map → activation-CpEoQaj5.js.map} +1 -1
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +3 -3
- package/dist/{analyst-loop-DCTra9Qy.js → analyst-loop-CSH7P-Bf.js} +2 -2
- package/dist/{analyst-loop-DCTra9Qy.js.map → analyst-loop-CSH7P-Bf.js.map} +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/analyst-loop.js +1 -1
- package/dist/{authoring-BNQKWhto.js → authoring-fsUwd9hg.js} +2 -2
- package/dist/{authoring-BNQKWhto.js.map → authoring-fsUwd9hg.js.map} +1 -1
- package/dist/candidate-execution/index.js +4 -4
- package/dist/{candidate-execution-7lVEly33.js → candidate-execution-CehLeZmx.js} +4 -4
- package/dist/{candidate-execution-7lVEly33.js.map → candidate-execution-CehLeZmx.js.map} +1 -1
- package/dist/{conversation-BSgEebIo.js → conversation-DILnmy84.js} +3 -3
- package/dist/{conversation-BSgEebIo.js.map → conversation-DILnmy84.js.map} +1 -1
- package/dist/conversation.d.ts +1 -1
- package/dist/conversation.js +1 -1
- package/dist/{coordination-driver-Dh_0SvXr.js → coordination-driver-CtbyZv5d.js} +4 -4
- package/dist/{coordination-driver-Dh_0SvXr.js.map → coordination-driver-CtbyZv5d.js.map} +1 -1
- package/dist/durable.d.ts +24 -3
- package/dist/durable.js +12 -2
- package/dist/durable.js.map +1 -1
- package/dist/environment-provider-C4AQiUxj.d.ts +143 -0
- package/dist/{environment-provider-6QtI-u5j.js → environment-provider-DZxuH3E4.js} +56 -9
- package/dist/environment-provider-DZxuH3E4.js.map +1 -0
- package/dist/environment-provider.d.ts +2 -2
- package/dist/environment-provider.js +1 -1
- package/dist/{executable-spec-CkGvdPds.js → executable-spec-DxuiDFAU.js} +2 -2
- package/dist/{executable-spec-CkGvdPds.js.map → executable-spec-DxuiDFAU.js.map} +1 -1
- package/dist/{graph-VTmSuXNo.js → graph-Cox_7pht.js} +93 -5
- package/dist/graph-Cox_7pht.js.map +1 -0
- package/dist/graph.d.ts +3 -3
- package/dist/graph.js +5 -5
- package/dist/{improvement-cycle-Cmpe5Uev.js → improvement-cycle-BYHefgVo.js} +7 -7
- package/dist/{improvement-cycle-Cmpe5Uev.js.map → improvement-cycle-BYHefgVo.js.map} +1 -1
- package/dist/{index-DHSZjuLC.d.ts → index-DA9jKuJc.d.ts} +3 -3
- package/dist/{index-BhtdFMnG.d.ts → index-DVob1IA1.d.ts} +117 -14
- package/dist/{index-Dg2UXocB.d.ts → index-DdmozvB8.d.ts} +4 -4
- package/dist/index.d.ts +9 -9
- package/dist/index.js +13 -13
- package/dist/intelligence.d.ts +5 -5
- package/dist/intelligence.js +6 -6
- package/dist/kernel.d.ts +7 -7
- package/dist/kernel.js +14 -14
- package/dist/{knowledge-SVRitzcp.js → knowledge-Bj1rDycX.js} +7 -7
- package/dist/{knowledge-SVRitzcp.js.map → knowledge-Bj1rDycX.js.map} +1 -1
- package/dist/knowledge.d.ts +1 -1
- package/dist/knowledge.js +1 -1
- package/dist/{loop-runner-bin-D2A4NfN7.js → loop-runner-bin-DgmtU0F0.js} +4 -4
- package/dist/{loop-runner-bin-D2A4NfN7.js.map → loop-runner-bin-DgmtU0F0.js.map} +1 -1
- package/dist/{loop-runner-bin-NanoP_bG.d.ts → loop-runner-bin-g9fWDuOh.d.ts} +3 -3
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +6 -6
- package/dist/mcp/index.js +7 -7
- package/dist/{model-policy-Sw4ywhtL.js → model-policy-Wf2MxXJ9.js} +12 -4
- package/dist/model-policy-Wf2MxXJ9.js.map +1 -0
- package/dist/{openai-tools-Cbk5uBUu.d.ts → openai-tools-BDwAdxk5.d.ts} +2 -2
- package/dist/{openai-tools-DCorsAv3.js → openai-tools-Cz04RKfD.js} +2 -2
- package/dist/{openai-tools-DCorsAv3.js.map → openai-tools-Cz04RKfD.js.map} +1 -1
- package/dist/{prepare-Tip-2ZoZ.js → prepare-BpIGs5Tc.js} +123 -40
- package/dist/prepare-BpIGs5Tc.js.map +1 -0
- package/dist/primeintellect/index.d.ts +1 -1
- package/dist/profiles.d.ts +2 -2
- package/dist/profiles.js +1 -1
- package/dist/{protected-model-port-Dd3a1SRm.js → protected-model-port-YclORl0x.js} +2 -2
- package/dist/{protected-model-port-Dd3a1SRm.js.map → protected-model-port-YclORl0x.js.map} +1 -1
- package/dist/{provision-supervisor-ey6o68i7.js → provision-supervisor-B-_4I1In.js} +7 -7
- package/dist/{provision-supervisor-ey6o68i7.js.map → provision-supervisor-B-_4I1In.js.map} +1 -1
- package/dist/{redact-BYcuQ6R_.d.ts → redact-C9EWk1FT.d.ts} +3 -3
- package/dist/{researcher-BMFFPwKb.js → researcher-hgPa5p9i.js} +2 -2
- package/dist/{researcher-BMFFPwKb.js.map → researcher-hgPa5p9i.js.map} +1 -1
- package/dist/{runtime-C90NMh9Y.js → runtime-DN0SxAaM.js} +15 -15
- package/dist/{runtime-C90NMh9Y.js.map → runtime-DN0SxAaM.js.map} +1 -1
- package/dist/{runtime-B-DLSfE5.d.ts → runtime-EQgE3942.d.ts} +23 -7
- package/dist/{sandbox-events-DGXLxiuX.js → sandbox-events-DWeQRWxg.js} +4 -2
- package/dist/sandbox-events-DWeQRWxg.js.map +1 -0
- package/dist/{spawn-journal--N8Ten1q.js → spawn-journal-CxRa-NJ2.js} +2 -2
- package/dist/{spawn-journal--N8Ten1q.js.map → spawn-journal-CxRa-NJ2.js.map} +1 -1
- package/dist/{stream-agent-turn-DY-y9yW1.d.ts → stream-agent-turn-BomJ21AK.d.ts} +3 -3
- package/dist/{stream-agent-turn-B5Cmq-u3.js → stream-agent-turn-DWWe_7bh.js} +4 -4
- package/dist/{stream-agent-turn-B5Cmq-u3.js.map → stream-agent-turn-DWWe_7bh.js.map} +1 -1
- package/dist/{structural-rollout-CsHxVoVH.js → structural-rollout-DPmVZaLI.js} +6 -6
- package/dist/{structural-rollout-CsHxVoVH.js.map → structural-rollout-DPmVZaLI.js.map} +1 -1
- package/dist/{substrate-RrmNZoL3.d.ts → substrate-qLePHqvH.d.ts} +2 -2
- package/dist/{supervise-rbZ-ppOC.js → supervise-BUy1cr2L.js} +246 -30
- package/dist/supervise-BUy1cr2L.js.map +1 -0
- package/dist/{supervisor-DBUmrQsF.js → supervisor-BSNkaM2a.js} +154 -23
- package/dist/supervisor-BSNkaM2a.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +13 -13
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-B-rWcun_.d.ts → types-BbkiJR1D.d.ts} +37 -4
- package/dist/{types-CrTTgig6.d.ts → types-BdolQ6Zi.d.ts} +20 -1
- package/dist/{util-D6ZEuBMi.js → util-BfoW6RU7.js} +53 -4
- package/dist/util-BfoW6RU7.js.map +1 -0
- package/dist/{workspace-archive-ByonPBl-.js → workspace-archive-5K72EnlT.js} +2 -2
- package/dist/{workspace-archive-ByonPBl-.js.map → workspace-archive-5K72EnlT.js.map} +1 -1
- package/package.json +8 -8
- package/dist/environment-provider-6QtI-u5j.js.map +0 -1
- package/dist/environment-provider-CzohJCuk.d.ts +0 -89
- package/dist/graph-VTmSuXNo.js.map +0 -1
- package/dist/model-policy-Sw4ywhtL.js.map +0 -1
- package/dist/prepare-Tip-2ZoZ.js.map +0 -1
- package/dist/sandbox-events-DGXLxiuX.js.map +0 -1
- package/dist/supervise-rbZ-ppOC.js.map +0 -1
- package/dist/supervisor-DBUmrQsF.js.map +0 -1
- package/dist/util-D6ZEuBMi.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { x as contentAddress } from "./spawn-journal
|
|
1
|
+
import { x as contentAddress } from "./spawn-journal-CxRa-NJ2.js";
|
|
2
2
|
import { i as redactProtectedValue, n as createProtectedRecordRedactor, r as redactProtectedReason, t as assertNoProtectedBytes } from "./protected-redaction--F3v1oo8.js";
|
|
3
3
|
import { agentCandidateArtifactRefSchema, agentCandidateBenchmarkResultEvidenceSchema, agentCandidateBenchmarkSuiteSchema, agentCandidateBenchmarkTaskSchema, agentCandidateBundleSchema, agentCandidateContainerSchema, agentCandidateExecutionLimitsSchema, agentCandidateExecutionPlanEvidenceSchema, agentCandidateExecutionPlanMaterialSchema, agentCandidateMaterializationReceiptSchema, agentCandidateModelAccessNetworkSchema, agentCandidateModelSettlementEvidenceSchema, agentCandidateProfileActivationSchema, agentCandidateProfilePlanEvidenceSchema, agentCandidateProfileSchema, agentCandidateResolvedModelSchema, agentCandidateRunCellSchema, agentCandidateRunReceiptSchema, agentCandidateTaskOutcomeEvidenceSchema, agentCandidateTaskOutcomeSpecSchema, agentCandidateTerminationSchema, agentCandidateWorkspaceManifestMaterialSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, agentProfileDiffSchema, agentProfileSchema, applyAgentProfileDiff, sha256DigestSchema } from "@tangle-network/agent-interface";
|
|
4
4
|
import { REDACTION_VERSION, canonicalJson, isLlmSpan } from "@tangle-network/agent-eval";
|
|
5
5
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
6
|
-
import { isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
6
|
+
import { dirname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
7
7
|
import { applyAgentCandidateWorkspacePlan, isMaterializerHarness, materializeCandidateProfile } from "@tangle-network/agent-profile-materialize";
|
|
8
|
-
import { lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rm, stat } from "node:fs/promises";
|
|
8
|
+
import { lstat, mkdir, mkdtemp, open, readFile, readdir, readlink, realpath, rm, stat } from "node:fs/promises";
|
|
9
9
|
import { constants } from "node:fs";
|
|
10
10
|
import { spawn } from "node:child_process";
|
|
11
11
|
import { tmpdir } from "node:os";
|
|
@@ -910,16 +910,28 @@ async function verifyWorkspaceSnapshotArtifacts(snapshot, port) {
|
|
|
910
910
|
};
|
|
911
911
|
}
|
|
912
912
|
async function verifyMaterializedWorkspace(root, expected, options = {}) {
|
|
913
|
-
assertWorkspaceManifest(
|
|
913
|
+
assertWorkspaceManifest(await scanMaterializedWorkspaceManifest(root, options), expected);
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* The canonical manifest of one materialized workspace, read without holding any file.
|
|
917
|
+
*
|
|
918
|
+
* Every file is digested by streaming, so the size of the largest file does not decide whether the
|
|
919
|
+
* workspace can be described. `FileHandle.readFile` refuses anything above 2 GiB with
|
|
920
|
+
* `ERR_FS_FILE_TOO_LARGE`, which made a workspace holding one such artifact impossible to verify
|
|
921
|
+
* against a manifest it already matched. The digest is sha-256 over the same bytes either way, so
|
|
922
|
+
* a manifest a buffered read produced is reproduced exactly.
|
|
923
|
+
*/
|
|
924
|
+
async function scanMaterializedWorkspaceManifest(root, options = {}) {
|
|
925
|
+
return workspaceManifestFromEntries(await walkWorkspace(root, options, false));
|
|
914
926
|
}
|
|
915
927
|
async function captureMaterializedWorkspace(root, options = {}) {
|
|
916
|
-
const
|
|
928
|
+
const entries = await walkWorkspace(root, options, true);
|
|
917
929
|
return {
|
|
918
|
-
manifest:
|
|
919
|
-
files:
|
|
920
|
-
path:
|
|
921
|
-
mode:
|
|
922
|
-
bytes: Uint8Array.from(
|
|
930
|
+
manifest: workspaceManifestFromEntries(entries),
|
|
931
|
+
files: entries.map((entry) => ({
|
|
932
|
+
path: entry.path,
|
|
933
|
+
mode: entry.mode,
|
|
934
|
+
bytes: Uint8Array.from(capturedBytes(entry))
|
|
923
935
|
}))
|
|
924
936
|
};
|
|
925
937
|
}
|
|
@@ -933,36 +945,65 @@ async function readMaterializedWorkspaceFiles(root, expected, options = {}) {
|
|
|
933
945
|
bytes: Uint8Array.from(file.bytes)
|
|
934
946
|
}));
|
|
935
947
|
}
|
|
936
|
-
function candidateWorkspaceManifest(files) {
|
|
948
|
+
function candidateWorkspaceManifest(files, options = {}) {
|
|
949
|
+
return workspaceManifestFromEntries(files.map((file) => ({
|
|
950
|
+
path: file.path,
|
|
951
|
+
mode: options.portableTree === true ? portableFileMode(file.mode) : file.mode,
|
|
952
|
+
sha256: sha256Bytes(file.bytes),
|
|
953
|
+
byteLength: file.bytes.byteLength
|
|
954
|
+
})));
|
|
955
|
+
}
|
|
956
|
+
function workspaceManifestFromEntries(entries) {
|
|
937
957
|
return {
|
|
938
958
|
kind: "agent-candidate-workspace-manifest",
|
|
939
|
-
files:
|
|
940
|
-
path:
|
|
941
|
-
mode:
|
|
942
|
-
sha256:
|
|
943
|
-
byteLength:
|
|
959
|
+
files: entries.map((entry) => ({
|
|
960
|
+
path: entry.path,
|
|
961
|
+
mode: entry.mode,
|
|
962
|
+
sha256: entry.sha256,
|
|
963
|
+
byteLength: entry.byteLength
|
|
944
964
|
})).sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0)
|
|
945
965
|
};
|
|
946
966
|
}
|
|
967
|
+
/** Git records exactly two file modes, and a portable-tree scan records the same two. */
|
|
968
|
+
function portableFileMode(mode) {
|
|
969
|
+
return (mode & 73) !== 0 ? 493 : 420;
|
|
970
|
+
}
|
|
971
|
+
function capturedBytes(entry) {
|
|
972
|
+
if (!entry.bytes) throw new Error(`workspace file was digested without its bytes: ${entry.path}`);
|
|
973
|
+
return entry.bytes;
|
|
974
|
+
}
|
|
947
975
|
function assertWorkspaceManifest(observed, expected) {
|
|
948
|
-
if (
|
|
976
|
+
if (Buffer.from(canonicalCandidateBytes(observed)).equals(canonicalCandidateBytes(expected))) return;
|
|
977
|
+
if (Buffer.from(canonicalCandidateBytes(withPortableModes(observed))).equals(canonicalCandidateBytes(withPortableModes(expected)))) throw new Error("materialized workspace files do not match the signed manifest: only the file modes differ, so the capture and this verify disagree about portableTree");
|
|
978
|
+
throw new Error("materialized workspace files, modes, or bytes do not match the signed manifest");
|
|
979
|
+
}
|
|
980
|
+
function withPortableModes(material) {
|
|
981
|
+
return {
|
|
982
|
+
...material,
|
|
983
|
+
files: material.files.map((file) => ({
|
|
984
|
+
...file,
|
|
985
|
+
mode: portableFileMode(file.mode)
|
|
986
|
+
}))
|
|
987
|
+
};
|
|
949
988
|
}
|
|
950
989
|
async function verifyMaterializedProfileWorkspace(root, expected) {
|
|
951
|
-
const observedProfile = (await
|
|
990
|
+
const observedProfile = (await scanMaterializedWorkspaceManifest(root)).files.map(({ path, mode, sha256 }) => ({
|
|
952
991
|
relPath: path,
|
|
953
992
|
mode,
|
|
954
993
|
contentSha256: sha256
|
|
955
994
|
}));
|
|
956
995
|
if (!Buffer.from(canonicalCandidateBytes(observedProfile)).equals(canonicalCandidateBytes(expected.files))) throw new Error("profile staging files, modes, or bytes do not match the signed profile plan");
|
|
957
996
|
}
|
|
958
|
-
async function
|
|
997
|
+
async function walkWorkspace(root, options, keepBytes) {
|
|
998
|
+
const ignoredProtectedRootEntries = new Set(options.ignoredProtectedRootEntries ?? []);
|
|
999
|
+
const limits = options.limits;
|
|
959
1000
|
const requestedRoot = resolve(root);
|
|
960
1001
|
const rootStats = await lstat(requestedRoot);
|
|
961
1002
|
if (!rootStats.isDirectory() || rootStats.isSymbolicLink()) throw new Error("workspace root must be a real directory");
|
|
962
1003
|
const absoluteRoot = await realpath(requestedRoot);
|
|
963
1004
|
const resolvedStats = await lstat(absoluteRoot);
|
|
964
1005
|
if (!resolvedStats.isDirectory() || resolvedStats.isSymbolicLink()) throw new Error("workspace root must resolve to a real directory");
|
|
965
|
-
const
|
|
1006
|
+
const scanned = [];
|
|
966
1007
|
let totalBytes = 0;
|
|
967
1008
|
async function visit(directory) {
|
|
968
1009
|
const entries = await readdir(directory, { withFileTypes: true });
|
|
@@ -973,28 +1014,30 @@ async function scanWorkspace(root, ignoredProtectedRootEntries, limits) {
|
|
|
973
1014
|
const relPath = relative(absoluteRoot, absolute).split(sep).join("/");
|
|
974
1015
|
if (!relPath || relPath.startsWith("../") || relPath.includes("/../")) throw new Error(`workspace entry escapes root: ${relPath}`);
|
|
975
1016
|
const stats = await lstat(absolute);
|
|
976
|
-
if (stats.isSymbolicLink()) throw new Error(
|
|
1017
|
+
if (stats.isSymbolicLink()) throw new Error(await symlinkRefusal(absolute, relPath, absoluteRoot));
|
|
977
1018
|
if (stats.isDirectory()) {
|
|
978
1019
|
await visit(absolute);
|
|
979
1020
|
continue;
|
|
980
1021
|
}
|
|
981
1022
|
if (!stats.isFile()) throw new Error(`workspace contains a non-regular entry: ${relPath}`);
|
|
982
|
-
if (limits &&
|
|
1023
|
+
if (limits && scanned.length >= limits.maxFiles) throw new Error("workspace exceeds maxFiles");
|
|
983
1024
|
const descriptor = await open(absolute, constants.O_RDONLY | (typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0));
|
|
984
1025
|
try {
|
|
985
1026
|
const openedStats = await descriptor.stat();
|
|
986
1027
|
if (!openedStats.isFile()) throw new Error(`workspace contains a non-regular entry: ${relPath}`);
|
|
987
1028
|
if (openedStats.nlink !== 1) throw new Error(`workspace contains a hard-linked file: ${relPath}`);
|
|
988
|
-
const mode = openedStats.mode & 511;
|
|
1029
|
+
const mode = options.portableTree === true ? portableFileMode(openedStats.mode) : openedStats.mode & 511;
|
|
989
1030
|
if (limits && openedStats.size > limits.maxFileBytes) throw new Error(`workspace file exceeds maxFileBytes: ${relPath}`);
|
|
990
1031
|
const remainingBytes = limits ? limits.maxTotalFileBytes - totalBytes : void 0;
|
|
991
1032
|
if (remainingBytes !== void 0 && openedStats.size > remainingBytes) throw new Error("workspace exceeds maxTotalFileBytes");
|
|
992
|
-
const
|
|
993
|
-
totalBytes +=
|
|
994
|
-
|
|
1033
|
+
const read = await readWorkspaceFile(descriptor, limits ? Math.min(limits.maxFileBytes, remainingBytes ?? limits.maxFileBytes) : void 0, keepBytes, relPath);
|
|
1034
|
+
totalBytes += read.byteLength;
|
|
1035
|
+
scanned.push({
|
|
995
1036
|
path: relPath,
|
|
996
1037
|
mode,
|
|
997
|
-
|
|
1038
|
+
sha256: read.sha256,
|
|
1039
|
+
byteLength: read.byteLength,
|
|
1040
|
+
...read.bytes === void 0 ? {} : { bytes: read.bytes }
|
|
998
1041
|
});
|
|
999
1042
|
} finally {
|
|
1000
1043
|
await descriptor.close();
|
|
@@ -1002,25 +1045,65 @@ async function scanWorkspace(root, ignoredProtectedRootEntries, limits) {
|
|
|
1002
1045
|
}
|
|
1003
1046
|
}
|
|
1004
1047
|
await visit(absoluteRoot);
|
|
1005
|
-
return
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1048
|
+
return scanned;
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Why one symbolic link is refused, in the terms that separate a portable link from a link that
|
|
1052
|
+
* reaches outside the tree.
|
|
1053
|
+
*
|
|
1054
|
+
* Every link is refused, in both mode policies. `AgentCandidateWorkspaceManifestMaterial` has no
|
|
1055
|
+
* representation for one — `mode`, `sha256` and `byteLength` describe a regular file — so a link
|
|
1056
|
+
* recorded as a file would let two different trees share one digest. The reason says which kind of
|
|
1057
|
+
* link it was, so a caller can tell a link it can rewrite from one it cannot.
|
|
1058
|
+
*/
|
|
1059
|
+
async function symlinkRefusal(absolute, relPath, absoluteRoot) {
|
|
1060
|
+
const target = await readlink(absolute);
|
|
1061
|
+
if (isAbsolute(target)) return `workspace contains an absolute symlink: ${relPath} -> ${target}`;
|
|
1062
|
+
if (!isWithin(absoluteRoot, resolve(dirname(absolute), target))) return `workspace contains a symlink that escapes its tree: ${relPath} -> ${target}`;
|
|
1063
|
+
let physical;
|
|
1064
|
+
try {
|
|
1065
|
+
physical = await realpath(absolute);
|
|
1066
|
+
} catch {
|
|
1067
|
+
return `workspace contains an unresolved symlink: ${relPath} -> ${target}`;
|
|
1068
|
+
}
|
|
1069
|
+
if (!isWithin(absoluteRoot, physical)) return `workspace contains a symlink that resolves outside its tree: ${relPath} -> ${target}`;
|
|
1070
|
+
return `workspace contains a symlink: ${relPath} -> ${target}`;
|
|
1009
1071
|
}
|
|
1010
|
-
|
|
1011
|
-
|
|
1072
|
+
function isWithin(root, path) {
|
|
1073
|
+
return path === root || path.startsWith(`${root}${sep}`);
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Read one open regular file into its digest, keeping the bytes only when the caller needs them.
|
|
1077
|
+
*
|
|
1078
|
+
* The content reaches the hash in 1 MiB chunks and is never held whole for a digest-only walk, so
|
|
1079
|
+
* the size of the largest file does not decide whether a workspace can be described.
|
|
1080
|
+
* `FileHandle.readFile` refuses anything above 2 GiB with `ERR_FS_FILE_TOO_LARGE`. Hashing the
|
|
1081
|
+
* chunks in order equals hashing the whole buffer, so a manifest a buffered read produced is
|
|
1082
|
+
* reproduced byte for byte.
|
|
1083
|
+
*/
|
|
1084
|
+
async function readWorkspaceFile(descriptor, maxBytes, keepBytes, path) {
|
|
1085
|
+
const hash = createHash("sha256");
|
|
1086
|
+
const buffer = Buffer.allocUnsafe(1024 * 1024);
|
|
1012
1087
|
const chunks = [];
|
|
1013
1088
|
let total = 0;
|
|
1014
1089
|
while (true) {
|
|
1015
|
-
const
|
|
1016
|
-
const chunk = Buffer.allocUnsafe(Math.min(64 * 1024, remaining + 1));
|
|
1017
|
-
const { bytesRead } = await descriptor.read(chunk, 0, chunk.byteLength, null);
|
|
1090
|
+
const { bytesRead } = await descriptor.read(buffer, 0, buffer.byteLength, null);
|
|
1018
1091
|
if (bytesRead === 0) break;
|
|
1019
1092
|
total += bytesRead;
|
|
1020
|
-
if (total > maxBytes) throw new Error(`workspace file exceeds its capture limit: ${path}`);
|
|
1021
|
-
|
|
1093
|
+
if (maxBytes !== void 0 && total > maxBytes) throw new Error(`workspace file exceeds its capture limit: ${path}`);
|
|
1094
|
+
const chunk = buffer.subarray(0, bytesRead);
|
|
1095
|
+
hash.update(chunk);
|
|
1096
|
+
if (keepBytes) chunks.push(Buffer.from(chunk));
|
|
1022
1097
|
}
|
|
1023
|
-
|
|
1098
|
+
const sha256 = `sha256:${hash.digest("hex")}`;
|
|
1099
|
+
return keepBytes ? {
|
|
1100
|
+
sha256,
|
|
1101
|
+
byteLength: total,
|
|
1102
|
+
bytes: Buffer.concat(chunks, total)
|
|
1103
|
+
} : {
|
|
1104
|
+
sha256,
|
|
1105
|
+
byteLength: total
|
|
1106
|
+
};
|
|
1024
1107
|
}
|
|
1025
1108
|
//#endregion
|
|
1026
1109
|
//#region src/candidate-execution/git-materialize.ts
|
|
@@ -4486,4 +4569,4 @@ function errorMessage(error) {
|
|
|
4486
4569
|
//#endregion
|
|
4487
4570
|
export { parseAgentCandidateProfileActivation as $, verifyMaterializedWorkspace as A, rejectedStage as B, assertNoGitIndirection as C, captureMaterializedWorkspace as D, candidateWorkspaceManifest as E, assertTerminalAllowedInPhase as F, isWellFormedUnicode as G, sealTerminalDigest as H, assertTerminalMatchesClaim as I, assertCandidateProfileBinding as J, agentCandidateProfileAsAgentProfile as K, assertTerminalMatchesStaged as L, candidateCleanupTimeout as M, withinCandidateCleanupDeadline as N, readVerifiedArtifact as O, assertRecoveryMatchesStaged as P, omitUndefinedObjectFields as Q, recoveredTerminalRecord as R, CANDIDATE_TRACE_TAGS as S, runCandidateGit as T, terminalRecord as U, requireStagedTerminal as V, assertExactObjectKeys as W, freezeGenericAgentCandidateProfile as X, createAgentCandidateProfileActivation as Y, materializeAgentCandidateProfilePlan as Z, candidateExecutionClaim as _, persistCandidateOutputArtifact as a, canonicalCandidateDocument as at, consumePreparedCandidateExecution as b, CANDIDATE_KNOWLEDGE_ROOT_ENV as c, immutableCandidateValue as ct, verifiedResourceTextByDigest as d, verifyCanonicalCandidateDocument as dt, parseExactAgentProfile as et, verifyAgentCandidateBundle as f, candidateClaimFileInternals as g, InMemoryAgentCandidateExecutionClaimStore as h, persistCandidateModelSettlementEvidence as i, canonicalCandidateDigest$1 as it, candidateCleanupDeadline as j, verifyBytes as k, candidateKnowledgeExecutionPaths as l, omitTopLevelDigest as lt, usdToNanos as m, executePreparedAgentCandidate as n, parseExactCandidateProfile as nt, sealAgentCandidateExecutorStopAcknowledgement as o, deepFreezeCandidate as ot, sealAgentCandidateModelSettlement as p, applyExactAgentProfileDiff as q, RecoveryAgentCandidateTraceStore as r, canonicalCandidateBytes as rt, CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV as s, embeddedCandidateArtifact as st, prepareAgentCandidateExecution as t, parseExactAgentProfileDiff as tt, AGENT_CANDIDATE_EXECUTION_SUPPORT as u, sha256Bytes as ut, assertPreparedCandidateIntegrity as v, readCandidateGitTreeFiles as w, CANDIDATE_TRACE_ENV as x, beginPreparedCandidateDisposal as y, rejectedFinish as z };
|
|
4488
4571
|
|
|
4489
|
-
//# sourceMappingURL=prepare-
|
|
4572
|
+
//# sourceMappingURL=prepare-BpIGs5Tc.js.map
|