@tangle-network/agent-runtime 0.188.1 → 0.189.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.
Files changed (60) hide show
  1. package/dist/{activation-C39nGToq.js → activation-DuYIFVQm.js} +3 -3
  2. package/dist/{activation-C39nGToq.js.map → activation-DuYIFVQm.js.map} +1 -1
  3. package/dist/agent.d.ts +1 -1
  4. package/dist/agent.js +1 -1
  5. package/dist/{authoring-fsUwd9hg.js → authoring-CIE6rF8N.js} +2 -2
  6. package/dist/{authoring-fsUwd9hg.js.map → authoring-CIE6rF8N.js.map} +1 -1
  7. package/dist/candidate-execution/index.d.ts +4 -4
  8. package/dist/candidate-execution/index.js +4 -4
  9. package/dist/{candidate-execution-CehLeZmx.js → candidate-execution-CQYU8E5a.js} +4 -4
  10. package/dist/{candidate-execution-CehLeZmx.js.map → candidate-execution-CQYU8E5a.js.map} +1 -1
  11. package/dist/coordination-driver-CtbyZv5d.js.map +1 -1
  12. package/dist/durable.d.ts +1 -1
  13. package/dist/durable.js +1 -1
  14. package/dist/{graph-Cox_7pht.js → graph-DzkWh1BI.js} +2 -2
  15. package/dist/{graph-Cox_7pht.js.map → graph-DzkWh1BI.js.map} +1 -1
  16. package/dist/graph.d.ts +1 -1
  17. package/dist/graph.js +2 -2
  18. package/dist/{improvement-cycle-CnHGNT5r.js → improvement-cycle-DP9zf-IL.js} +2 -2
  19. package/dist/{improvement-cycle-CnHGNT5r.js.map → improvement-cycle-DP9zf-IL.js.map} +1 -1
  20. package/dist/{index-DQv7iCeE.d.ts → index-DCqHTdmp.d.ts} +3 -3
  21. package/dist/{index-DVob1IA1.d.ts → index-k5bcID4t.d.ts} +18 -7
  22. package/dist/{index-DdmozvB8.d.ts → index-tf6g2B27.d.ts} +3 -3
  23. package/dist/index.d.ts +7 -7
  24. package/dist/index.js +9 -9
  25. package/dist/intelligence.d.ts +2 -2
  26. package/dist/intelligence.js +4 -4
  27. package/dist/kernel.d.ts +1 -1
  28. package/dist/kernel.js +4 -4
  29. package/dist/{knowledge-BZDVXRCl.js → knowledge-C5lODZQC.js} +5 -5
  30. package/dist/{knowledge-BZDVXRCl.js.map → knowledge-C5lODZQC.js.map} +1 -1
  31. package/dist/knowledge.d.ts +1 -1
  32. package/dist/knowledge.js +1 -1
  33. package/dist/{loop-runner-bin-hXqgNrPN.js → loop-runner-bin-BKsjoaVu.js} +2 -2
  34. package/dist/{loop-runner-bin-hXqgNrPN.js.map → loop-runner-bin-BKsjoaVu.js.map} +1 -1
  35. package/dist/{loop-runner-bin-g9fWDuOh.d.ts → loop-runner-bin-ncN_8Msd.d.ts} +2 -2
  36. package/dist/loop-runner-bin.d.ts +1 -1
  37. package/dist/loop-runner-bin.js +1 -1
  38. package/dist/mcp/bin.js +2 -2
  39. package/dist/mcp/index.d.ts +1 -1
  40. package/dist/mcp/index.js +3 -3
  41. package/dist/{openai-tools-Cz04RKfD.js → openai-tools-x83CTnJM.js} +2 -2
  42. package/dist/{openai-tools-Cz04RKfD.js.map → openai-tools-x83CTnJM.js.map} +1 -1
  43. package/dist/{prepare-BpIGs5Tc.js → prepare-BtXhV0qj.js} +107 -29
  44. package/dist/prepare-BtXhV0qj.js.map +1 -0
  45. package/dist/{protected-model-port-B8ssMyUg.d.ts → protected-model-port-BtXp2dUY.d.ts} +2 -2
  46. package/dist/{protected-model-port-YclORl0x.js → protected-model-port-DHrayPt4.js} +19 -7
  47. package/dist/protected-model-port-DHrayPt4.js.map +1 -0
  48. package/dist/{runtime-CFltmoiL.js → runtime-C98JsP83.js} +4 -4
  49. package/dist/{runtime-CFltmoiL.js.map → runtime-C98JsP83.js.map} +1 -1
  50. package/dist/{supervise-BUy1cr2L.js → supervise-DSu4d0b6.js} +104 -7
  51. package/dist/{supervise-BUy1cr2L.js.map → supervise-DSu4d0b6.js.map} +1 -1
  52. package/dist/testing.d.ts +1 -1
  53. package/dist/testing.js +12 -12
  54. package/dist/tui/index.d.ts +1 -1
  55. package/dist/{types-19ZOddS3.d.ts → types-1s_29INY.d.ts} +15 -10
  56. package/dist/{workspace-archive-5K72EnlT.js → workspace-archive-SVeiWLNE.js} +2 -2
  57. package/dist/{workspace-archive-5K72EnlT.js.map → workspace-archive-SVeiWLNE.js.map} +1 -1
  58. package/package.json +2 -2
  59. package/dist/prepare-BpIGs5Tc.js.map +0 -1
  60. package/dist/protected-model-port-YclORl0x.js.map +0 -1
@@ -4,7 +4,7 @@ import { agentCandidateArtifactRefSchema, agentCandidateBenchmarkResultEvidenceS
4
4
  import { REDACTION_VERSION, canonicalJson, isLlmSpan } from "@tangle-network/agent-eval";
5
5
  import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
6
6
  import { dirname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
7
- import { applyAgentCandidateWorkspacePlan, isMaterializerHarness, materializeCandidateProfile } from "@tangle-network/agent-profile-materialize";
7
+ import { applyAgentCandidateWorkspacePlan, isMaterializerHarness, materializeCandidateProfile, resolvePiRuntimePaths } from "@tangle-network/agent-profile-materialize";
8
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";
@@ -215,6 +215,8 @@ function candidateMaterializerHarness(harness) {
215
215
  }
216
216
  /** Runtime applies the materializer's launch flags to the candidate process. */
217
217
  const CANDIDATE_PROFILE_MATERIALIZER_BINDS = ["systemPrompt"];
218
+ const PI_CANDIDATE_AGENT_DIR_ENV = "PI_CODING_AGENT_DIR";
219
+ const PI_CANDIDATE_SESSION_DIR_ENV = "PI_CODING_AGENT_SESSION_DIR";
218
220
  /** Derive the exact native profile plan used by preparation and later evidence checks. */
219
221
  function materializeAgentCandidateProfilePlan(options) {
220
222
  const root = options.workspace === "task" ? options.workspaces.taskRoot : options.workspaces.candidateRoot;
@@ -224,15 +226,22 @@ function materializeAgentCandidateProfilePlan(options) {
224
226
  resolvedResources: options.resolvedResources
225
227
  }), options.launch, posix.join(root, ".tangle/system-prompt.md"), options.profile.prompt?.systemPrompt, options.profile.prompt?.appendSystemPrompt);
226
228
  }
229
+ /** Resolve the private Pi roots needed by an agent-root profile plan. */
230
+ function candidateProfileAgentPaths(plan, runtimeHome) {
231
+ if (!plan.files.some((file) => file.root === "agent")) return void 0;
232
+ if (plan.harness !== "pi") throw new Error(`candidate profile agent-root files are unsupported for ${plan.harness}`);
233
+ if (runtimeHome === void 0) throw new Error("candidate profile agent-root files require executionRoots.profileRoot");
234
+ return resolvePiRuntimePaths(runtimeHome);
235
+ }
227
236
  /** Bind exact native profile text to the canonical plan captured during preparation. */
228
237
  function createAgentCandidateProfileActivation(plan, profilePlan) {
229
- const sourceByPath = new Map(plan.files.map((file) => [file.relPath, file]));
230
- if (sourceByPath.size !== plan.files.length) throw new Error("candidate profile activation contains duplicate native file paths");
238
+ const sourceByIdentity = new Map(plan.files.map((file) => [profileFileIdentity$1(file.root, file.relPath), file]));
239
+ if (sourceByIdentity.size !== plan.files.length) throw new Error("candidate profile activation contains duplicate rooted native file paths");
231
240
  const files = profilePlan.material.files.map((expected) => {
232
- const source = sourceByPath.get(expected.relPath);
233
- if (!source) throw new Error(`candidate profile activation is missing ${expected.relPath}`);
241
+ const source = sourceByIdentity.get(profileFileIdentity$1(expected.root, expected.relPath));
242
+ if (!source) throw new Error(`candidate profile activation is missing ${profileFileLabel(expected.root, expected.relPath)}`);
234
243
  const mode = source.mode ?? 420;
235
- if (!Number.isSafeInteger(mode) || mode < 0 || mode > 511) throw new Error(`candidate profile activation has invalid mode for ${expected.relPath}`);
244
+ if (!Number.isSafeInteger(mode) || mode < 0 || mode > 511) throw new Error(`candidate profile activation has invalid mode for ${profileFileLabel(expected.root, expected.relPath)}`);
236
245
  return {
237
246
  path: expected.relPath,
238
247
  mode,
@@ -246,6 +255,12 @@ function createAgentCandidateProfileActivation(plan, profilePlan) {
246
255
  files
247
256
  }).value, profilePlan.digest);
248
257
  }
258
+ function profileFileIdentity$1(root, relPath) {
259
+ return `${root ?? "workspace"}\0${relPath}`;
260
+ }
261
+ function profileFileLabel(root, relPath) {
262
+ return root === "agent" ? `agent:${relPath}` : relPath;
263
+ }
249
264
  /** Parse and check every native file hash plus both canonical document digests. */
250
265
  function parseAgentCandidateProfileActivation(input, expectedProfilePlanDigest) {
251
266
  const activation = agentCandidateProfileActivationSchema.parse(input);
@@ -986,13 +1001,14 @@ function withPortableModes(material) {
986
1001
  }))
987
1002
  };
988
1003
  }
989
- async function verifyMaterializedProfileWorkspace(root, expected) {
1004
+ async function verifyMaterializedProfileWorkspace(root, expected, fileRoot = "workspace") {
990
1005
  const observedProfile = (await scanMaterializedWorkspaceManifest(root)).files.map(({ path, mode, sha256 }) => ({
991
1006
  relPath: path,
992
1007
  mode,
993
1008
  contentSha256: sha256
994
1009
  }));
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");
1010
+ const expectedFiles = expected.files.filter((file) => (file.root ?? "workspace") === fileRoot).map(({ root: _root, ...file }) => file);
1011
+ if (!Buffer.from(canonicalCandidateBytes(observedProfile)).equals(canonicalCandidateBytes(expectedFiles))) throw new Error(`profile ${fileRoot} staging files, modes, or bytes do not match the signed profile plan`);
996
1012
  }
997
1013
  async function walkWorkspace(root, options, keepBytes) {
998
1014
  const ignoredProtectedRootEntries = new Set(options.ignoredProtectedRootEntries ?? []);
@@ -1106,6 +1122,37 @@ async function readWorkspaceFile(descriptor, maxBytes, keepBytes, path) {
1106
1122
  };
1107
1123
  }
1108
1124
  //#endregion
1125
+ //#region src/candidate-execution/execution-roots.ts
1126
+ /** Validate the canonical identity and isolation boundary for execution roots. */
1127
+ function assertAgentCandidateExecutionRoots(roots) {
1128
+ const entries = [
1129
+ ["task", roots.taskRoot],
1130
+ ["candidate", roots.candidateRoot],
1131
+ ["profile", roots.profileRoot]
1132
+ ];
1133
+ for (const [name, root] of entries) {
1134
+ if (root === void 0) continue;
1135
+ if (!posix.isAbsolute(root) || posix.normalize(root) !== root) throw new Error(`execution ${name} root must be a canonical absolute path`);
1136
+ }
1137
+ for (let left = 0; left < entries.length; left++) {
1138
+ const entry = entries[left];
1139
+ if (!entry) continue;
1140
+ const [leftName, leftRoot] = entry;
1141
+ if (leftRoot === void 0) continue;
1142
+ for (let right = left + 1; right < entries.length; right++) {
1143
+ const rightEntry = entries[right];
1144
+ if (!rightEntry) continue;
1145
+ const [rightName, rightRoot] = rightEntry;
1146
+ if (rightRoot !== void 0 && executionPathsOverlap(leftRoot, rightRoot)) throw new Error(`execution ${leftName} and ${rightName} roots must be distinct and non-overlapping`);
1147
+ }
1148
+ }
1149
+ }
1150
+ function executionPathsOverlap(left, right) {
1151
+ const a = posix.normalize(left);
1152
+ const b = posix.normalize(right);
1153
+ return a === b || b.startsWith(a === "/" ? "/" : `${a}/`) || a.startsWith(b === "/" ? "/" : `${b}/`);
1154
+ }
1155
+ //#endregion
1109
1156
  //#region src/candidate-execution/git-materialize.ts
1110
1157
  async function verifyCandidateCode(code, repositories, patchBytes) {
1111
1158
  if (code.kind === "disabled") return void 0;
@@ -1618,6 +1665,7 @@ function detachPreparedCandidateState(input) {
1618
1665
  });
1619
1666
  }
1620
1667
  function assertPrivateCandidateIntegrity(state) {
1668
+ assertAgentCandidateExecutionRoots(state.roots.execution);
1621
1669
  if (canonicalCandidateDigest$1(omitTopLevelDigest(state.bundle)) !== state.bundle.digest) throw new Error("prepared candidate bundle no longer matches its digest");
1622
1670
  assertPlanEvidence(state.profilePlan.value, state.profilePlan.bytes, "profile plan");
1623
1671
  parseAgentCandidateProfileActivation(state.profileActivation, state.profilePlan.value.digest);
@@ -1694,6 +1742,7 @@ function profileFileView(source) {
1694
1742
  return Object.freeze({
1695
1743
  path: source.path,
1696
1744
  mode: source.mode,
1745
+ ...source.root === "agent" ? { root: "agent" } : {},
1697
1746
  get bytes() {
1698
1747
  return Uint8Array.from(bytes);
1699
1748
  }
@@ -1721,7 +1770,7 @@ function assertExecutorInputs(state) {
1721
1770
  for (let index = 0; index < expectedFiles.length; index++) {
1722
1771
  const expected = expectedFiles[index];
1723
1772
  const actual = state.executorInputs.profileFiles[index];
1724
- if (!expected || !actual || actual.path !== expected.relPath || actual.mode !== expected.mode || sha256Bytes(actual.bytes) !== expected.contentSha256) throw new Error("prepared profile executor files do not match the signed profile plan");
1773
+ if (!expected || !actual || actual.path !== expected.relPath || (actual.root ?? "workspace") !== (expected.root ?? "workspace") || actual.mode !== expected.mode || sha256Bytes(actual.bytes) !== expected.contentSha256) throw new Error("prepared profile executor files do not match the signed profile plan");
1725
1774
  }
1726
1775
  }
1727
1776
  function assertPreparedKnowledge(state) {
@@ -4050,11 +4099,25 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
4050
4099
  harness: bundle.execution.harness,
4051
4100
  launch: bundle.execution.launch,
4052
4101
  workspace: bundle.execution.cwd.workspace,
4053
- workspaces: task.executionRoots,
4102
+ workspaces: {
4103
+ taskRoot: task.executionRoots.taskRoot,
4104
+ ...task.executionRoots.candidateRoot ? { candidateRoot: task.executionRoots.candidateRoot } : {}
4105
+ },
4054
4106
  resolvedResources: verifiedResourceTextByDigest(candidate)
4055
4107
  });
4056
- const profileApplication = applyAgentCandidateWorkspacePlan(profileWorkspacePlan, task.stagingRoots.profileRoot, bundle.execution.cwd.workspace);
4057
- await verifyMaterializedProfileWorkspace(task.stagingRoots.profileRoot, profileApplication.profileActivation.profilePlan.material);
4108
+ const profileAgentPaths = candidateProfileAgentPaths(profileWorkspacePlan, task.executionRoots.profileRoot);
4109
+ const profileAgentStagingRoot = profileWorkspacePlan.files.some((file) => file.root === "agent") ? await mkdtemp(join(tmpdir(), "tangle-candidate-profile-agent-")) : void 0;
4110
+ let profileApplication;
4111
+ try {
4112
+ profileApplication = applyAgentCandidateWorkspacePlan(profileWorkspacePlan, task.stagingRoots.profileRoot, bundle.execution.cwd.workspace, profileAgentStagingRoot ? { agentDir: profileAgentStagingRoot } : void 0);
4113
+ await verifyMaterializedProfileWorkspace(task.stagingRoots.profileRoot, profileApplication.profileActivation.profilePlan.material);
4114
+ if (profileAgentStagingRoot) await verifyMaterializedProfileWorkspace(profileAgentStagingRoot, profileApplication.profileActivation.profilePlan.material, "agent");
4115
+ } finally {
4116
+ if (profileAgentStagingRoot) await rm(profileAgentStagingRoot, {
4117
+ recursive: true,
4118
+ force: true
4119
+ });
4120
+ }
4058
4121
  const profilePlanBytes = await readVerifiedArtifact(profileApplication.profileActivation.profilePlan.artifact, ports.artifacts);
4059
4122
  if (!Buffer.from(profilePlanBytes).equals(Buffer.from(canonicalCandidateBytes(profileApplication.profileActivation.profilePlan.material)))) throw new Error("profile materializer did not capture exact canonical plan bytes");
4060
4123
  const profileActivation = profileApplication.profileActivation;
@@ -4079,7 +4142,16 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
4079
4142
  const knowledge = await prepareAgentCandidateKnowledge(candidate, ports, task.runCell.arm);
4080
4143
  const knowledgePaths = knowledge ? candidateKnowledgeExecutionPaths(task.executionRoots.taskRoot, knowledge.retrievalConfig !== void 0) : void 0;
4081
4144
  const baseLaunch = buildLaunch(candidate, task, profileApplication.flags);
4082
- const publicEnv = mergePublicEnvironment(bundle.execution.env ?? {}, profileApplication.env, bundle.execution.instructionDelivery.kind === "utf8-file" ? { [bundle.execution.instructionDelivery.env]: {
4145
+ const publicEnv = mergePublicEnvironment(bundle.execution.env ?? {}, profileApplication.env, profileAgentPaths ? {
4146
+ [PI_CANDIDATE_AGENT_DIR_ENV]: {
4147
+ kind: "public",
4148
+ value: profileAgentPaths.agentDir
4149
+ },
4150
+ [PI_CANDIDATE_SESSION_DIR_ENV]: {
4151
+ kind: "public",
4152
+ value: profileAgentPaths.sessionDir
4153
+ }
4154
+ } : {}, bundle.execution.instructionDelivery.kind === "utf8-file" ? { [bundle.execution.instructionDelivery.env]: {
4083
4155
  kind: "public",
4084
4156
  value: bundle.execution.instructionDelivery.path
4085
4157
  } } : {}, knowledgePaths ? {
@@ -4311,15 +4383,14 @@ function assertTaskInput(task, delivery) {
4311
4383
  if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(benchmarkTask.repository.baseTree)) throw new Error("task repository base tree is not a full Git object id");
4312
4384
  if (benchmarkTask.repository.baseCommit.length !== benchmarkTask.repository.baseTree.length) throw new Error("task repository Git object formats disagree");
4313
4385
  }
4386
+ assertAgentCandidateExecutionRoots(task.executionRoots);
4314
4387
  for (const [name, root] of [
4315
- ["execution task root", task.executionRoots.taskRoot],
4316
- ["execution candidate root", task.executionRoots.candidateRoot],
4317
4388
  ["staging task root", task.stagingRoots.taskRoot],
4318
4389
  ["staging candidate root", task.stagingRoots.candidateRoot],
4319
4390
  ["staging profile root", task.stagingRoots.profileRoot]
4320
4391
  ]) {
4321
4392
  if (root === void 0) continue;
4322
- if (!(name.startsWith("execution") ? posix.isAbsolute(root) && posix.normalize(root) === root : isAbsolute(root) && resolve(root) === root)) throw new Error(`${name} must be a canonical absolute path`);
4393
+ if (!(isAbsolute(root) && resolve(root) === root)) throw new Error(`${name} must be a canonical absolute path`);
4323
4394
  }
4324
4395
  if (!Number.isInteger(runCell.attempt) || !Number.isInteger(benchmarkTask.attempt.maxAttempts) || runCell.attempt < 1 || runCell.attempt > benchmarkTask.attempt.maxAttempts || benchmarkTask.attempt.retryPolicy === "none" && benchmarkTask.attempt.maxAttempts !== 1) throw new Error("task attempt policy is invalid");
4325
4396
  const limits = benchmarkTask.limits;
@@ -4339,14 +4410,13 @@ function assertTaskInput(task, delivery) {
4339
4410
  });
4340
4411
  }
4341
4412
  if (delivery.kind === "utf8-file") {
4342
- if (executionPathsOverlap(task.executionRoots.taskRoot, delivery.path) || task.executionRoots.candidateRoot !== void 0 && executionPathsOverlap(task.executionRoots.candidateRoot, delivery.path)) throw new Error("task instruction file must remain outside execution workspaces");
4413
+ if ([
4414
+ task.executionRoots.taskRoot,
4415
+ task.executionRoots.candidateRoot,
4416
+ task.executionRoots.profileRoot
4417
+ ].some((root) => root !== void 0 && executionPathsOverlap(root, delivery.path))) throw new Error("task instruction file must remain outside execution workspaces");
4343
4418
  }
4344
4419
  }
4345
- function executionPathsOverlap(left, right) {
4346
- const a = posix.normalize(left);
4347
- const b = posix.normalize(right);
4348
- return a === b || b.startsWith(a === "/" ? "/" : `${a}/`) || a.startsWith(b === "/" ? "/" : `${b}/`);
4349
- }
4350
4420
  function assertDisjointHostStagingRoots(task) {
4351
4421
  const roots = [
4352
4422
  task.stagingRoots.taskRoot,
@@ -4519,12 +4589,16 @@ function candidateEntrypointReceipt(candidate) {
4519
4589
  };
4520
4590
  }
4521
4591
  function absoluteExecutionCwd(cwd, roots) {
4522
- const root = cwd.workspace === "task" ? roots.taskRoot : roots.candidateRoot;
4523
- if (!root) throw new Error("candidate cwd is missing its execution workspace root");
4592
+ const root = workspaceExecutionRoot(cwd.workspace, roots);
4524
4593
  const absolute = cwd.path === "." ? root : posix.join(root, cwd.path);
4525
4594
  if (absolute !== root && !absolute.startsWith(`${root}/`)) throw new Error("candidate cwd escapes its execution workspace");
4526
4595
  return absolute;
4527
4596
  }
4597
+ function workspaceExecutionRoot(workspace, roots) {
4598
+ const root = workspace === "task" ? roots.taskRoot : roots.candidateRoot;
4599
+ if (!root) throw new Error(`candidate ${workspace} workspace root is missing`);
4600
+ return root;
4601
+ }
4528
4602
  function validateProtectedModelReservation(reservation, expectedLimits, preparationId, expiresAtMs) {
4529
4603
  if (!/^sha256:[a-f0-9]{64}$/.test(reservation.digest)) throw new Error("protected model reservation has an invalid identity digest");
4530
4604
  if (reservation.preparationId !== preparationId || reservation.expiresAtMs !== expiresAtMs) throw new Error("protected model reservation is not scoped to this preparation");
@@ -4549,24 +4623,28 @@ function modelLimits(limits) {
4549
4623
  };
4550
4624
  }
4551
4625
  function exactProfileExecutorFiles(sourceFiles, expectedFiles) {
4552
- const byPath = new Map(sourceFiles.map((file) => [file.relPath, file]));
4553
- if (byPath.size !== sourceFiles.length || sourceFiles.length !== expectedFiles.length) throw new Error("profile source files do not match the signed profile plan");
4626
+ const byIdentity = new Map(sourceFiles.map((file) => [profileFileIdentity(file.root, file.relPath), file]));
4627
+ if (byIdentity.size !== sourceFiles.length || sourceFiles.length !== expectedFiles.length) throw new Error("profile source files do not match the signed profile plan");
4554
4628
  return expectedFiles.map((expected) => {
4555
- const source = byPath.get(expected.relPath);
4629
+ const source = byIdentity.get(profileFileIdentity(expected.root, expected.relPath));
4556
4630
  const mode = source?.mode ?? 420;
4557
4631
  const bytes = Buffer.from(source?.content ?? "", "utf8");
4558
4632
  if (!source || !Number.isInteger(mode) || mode < 0 || mode > 511 || mode !== expected.mode || sha256Bytes(bytes) !== expected.contentSha256) throw new Error("profile source files do not match the signed profile plan");
4559
4633
  return {
4560
4634
  path: expected.relPath,
4561
4635
  mode,
4636
+ ...expected.root === "agent" ? { root: "agent" } : {},
4562
4637
  bytes: Uint8Array.from(bytes)
4563
4638
  };
4564
4639
  });
4565
4640
  }
4641
+ function profileFileIdentity(root, relPath) {
4642
+ return `${root ?? "workspace"}\0${relPath}`;
4643
+ }
4566
4644
  function errorMessage(error) {
4567
4645
  return error instanceof Error ? error.message : String(error);
4568
4646
  }
4569
4647
  //#endregion
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 };
4648
+ export { createAgentCandidateProfileActivation as $, verifyBytes as A, rejectedFinish as B, assertNoGitIndirection as C, candidateWorkspaceManifest as D, assertAgentCandidateExecutionRoots as E, assertRecoveryMatchesStaged as F, assertExactObjectKeys as G, requireStagedTerminal as H, assertTerminalAllowedInPhase as I, PI_CANDIDATE_SESSION_DIR_ENV as J, isWellFormedUnicode as K, assertTerminalMatchesClaim as L, candidateCleanupDeadline as M, candidateCleanupTimeout as N, captureMaterializedWorkspace as O, withinCandidateCleanupDeadline as P, candidateProfileAgentPaths as Q, assertTerminalMatchesStaged as R, CANDIDATE_TRACE_TAGS as S, runCandidateGit as T, sealTerminalDigest as U, rejectedStage as V, terminalRecord as W, applyExactAgentProfileDiff as X, agentCandidateProfileAsAgentProfile as Y, assertCandidateProfileBinding as Z, candidateExecutionClaim as _, persistCandidateOutputArtifact as a, parseExactAgentProfileDiff as at, consumePreparedCandidateExecution as b, CANDIDATE_KNOWLEDGE_ROOT_ENV as c, canonicalCandidateDigest$1 as ct, verifiedResourceTextByDigest as d, embeddedCandidateArtifact as dt, freezeGenericAgentCandidateProfile as et, verifyAgentCandidateBundle as f, immutableCandidateValue as ft, candidateClaimFileInternals as g, InMemoryAgentCandidateExecutionClaimStore as h, verifyCanonicalCandidateDocument as ht, persistCandidateModelSettlementEvidence as i, parseExactAgentProfile as it, verifyMaterializedWorkspace as j, readVerifiedArtifact as k, candidateKnowledgeExecutionPaths as l, canonicalCandidateDocument as lt, usdToNanos as m, sha256Bytes as mt, executePreparedAgentCandidate as n, omitUndefinedObjectFields as nt, sealAgentCandidateExecutorStopAcknowledgement as o, parseExactCandidateProfile as ot, sealAgentCandidateModelSettlement as p, omitTopLevelDigest as pt, PI_CANDIDATE_AGENT_DIR_ENV as q, RecoveryAgentCandidateTraceStore as r, parseAgentCandidateProfileActivation as rt, CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV as s, canonicalCandidateBytes as st, prepareAgentCandidateExecution as t, materializeAgentCandidateProfilePlan as tt, AGENT_CANDIDATE_EXECUTION_SUPPORT as u, deepFreezeCandidate as ut, assertPreparedCandidateIntegrity as v, readCandidateGitTreeFiles as w, CANDIDATE_TRACE_ENV as x, beginPreparedCandidateDisposal as y, recoveredTerminalRecord as z };
4571
4649
 
4572
- //# sourceMappingURL=prepare-BpIGs5Tc.js.map
4650
+ //# sourceMappingURL=prepare-BtXhV0qj.js.map