@tangle-network/agent-runtime 0.259.0 → 0.261.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 (73) hide show
  1. package/dist/{activation-Cus2oZaT.d.ts → activation-BpJ2CmXx.d.ts} +2 -2
  2. package/dist/{activation-Btw2npV2.js → activation-BwrMmguq.js} +3 -3
  3. package/dist/{activation-Btw2npV2.js.map → activation-BwrMmguq.js.map} +1 -1
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/{bundle-DXrBPEFw.js → bundle-CvLGRVO-.js} +2 -2
  7. package/dist/{bundle-DXrBPEFw.js.map → bundle-CvLGRVO-.js.map} +1 -1
  8. package/dist/candidate-execution/index.js +5 -4
  9. package/dist/candidate-execution/index.js.map +1 -1
  10. package/dist/{coordination-driver-BmtrkNPu.js → coordination-driver-LmDxHvAO.js} +77 -11
  11. package/dist/coordination-driver-LmDxHvAO.js.map +1 -0
  12. package/dist/{delegate-DJgmZZKH.js → delegate-rkhJf5w7.js} +2 -2
  13. package/dist/{delegate-DJgmZZKH.js.map → delegate-rkhJf5w7.js.map} +1 -1
  14. package/dist/durable.d.ts +285 -57
  15. package/dist/durable.js +637 -108
  16. package/dist/durable.js.map +1 -1
  17. package/dist/{graph-BKRvWzHx.js → graph-Bn3wSH8-.js} +4 -3
  18. package/dist/graph-Bn3wSH8-.js.map +1 -0
  19. package/dist/{improvement-cycle-D0Os0Hg_.js → improvement-cycle-DYiwfjWY.js} +8 -7
  20. package/dist/improvement-cycle-DYiwfjWY.js.map +1 -0
  21. package/dist/{index-sGOO254Q.d.ts → index-tubViIQJ.d.ts} +122 -12
  22. package/dist/index.d.ts +6 -6
  23. package/dist/index.js +9 -9
  24. package/dist/intelligence.d.ts +3 -3
  25. package/dist/intelligence.js +7 -6
  26. package/dist/intelligence.js.map +1 -1
  27. package/dist/kernel.d.ts +4 -4
  28. package/dist/kernel.js +8 -8
  29. package/dist/{loop-runner-bin-DAU4rNIL.d.ts → loop-runner-bin-CL4W2pu1.d.ts} +3 -3
  30. package/dist/{loop-runner-bin-pRlDgm1i.js → loop-runner-bin-Dxqxf91b.js} +3 -3
  31. package/dist/{loop-runner-bin-pRlDgm1i.js.map → loop-runner-bin-Dxqxf91b.js.map} +1 -1
  32. package/dist/loop-runner-bin.d.ts +1 -1
  33. package/dist/loop-runner-bin.js +1 -1
  34. package/dist/mcp/bin.js +3 -3
  35. package/dist/mcp/index.d.ts +5 -5
  36. package/dist/mcp/index.js +4 -4
  37. package/dist/{openai-tools-BsqD1_Zr.d.ts → openai-tools-BlZHd0Nz.d.ts} +2 -2
  38. package/dist/{prepare-RuaAclli.js → prepare-oHUQdC5-.js} +22 -452
  39. package/dist/prepare-oHUQdC5-.js.map +1 -0
  40. package/dist/profile-D3eXNBQV.js +438 -0
  41. package/dist/profile-D3eXNBQV.js.map +1 -0
  42. package/dist/profiles.d.ts +2 -2
  43. package/dist/{protected-model-port-BFhSgMAy.js → protected-model-port-DqF0qDU6.js} +4 -3
  44. package/dist/{protected-model-port-BFhSgMAy.js.map → protected-model-port-DqF0qDU6.js.map} +1 -1
  45. package/dist/{provision-supervisor-B9tf4soF.js → provision-supervisor-By5oGk3t.js} +3 -3
  46. package/dist/{provision-supervisor-B9tf4soF.js.map → provision-supervisor-By5oGk3t.js.map} +1 -1
  47. package/dist/{runtime-DKiucqGX.js → runtime-BbQmK7qe.js} +218 -20
  48. package/dist/runtime-BbQmK7qe.js.map +1 -0
  49. package/dist/{server-DIsiQ6mu.js → server-CHlpLE22.js} +3 -3
  50. package/dist/{server-DIsiQ6mu.js.map → server-CHlpLE22.js.map} +1 -1
  51. package/dist/{stream-agent-turn-DRTFLphI.d.ts → stream-agent-turn-DTgxWXbR.d.ts} +2 -2
  52. package/dist/{structural-rollout-BIBxgW64.js → structural-rollout-Dby60zHe.js} +2 -2
  53. package/dist/{structural-rollout-BIBxgW64.js.map → structural-rollout-Dby60zHe.js.map} +1 -1
  54. package/dist/{substrate-BToFBpfh.d.ts → substrate-CxwdhZri.d.ts} +2 -2
  55. package/dist/{supervise-DsQjhLN-.js → supervise-1QzYAyS2.js} +78 -7
  56. package/dist/supervise-1QzYAyS2.js.map +1 -0
  57. package/dist/{supervisor-CJyzUjc7.js → supervisor-yavsoQQo.js} +84 -9
  58. package/dist/{supervisor-CJyzUjc7.js.map → supervisor-yavsoQQo.js.map} +1 -1
  59. package/dist/testing.d.ts +2 -2
  60. package/dist/testing.js +14 -14
  61. package/dist/tui/index.d.ts +1 -1
  62. package/dist/tui/index.js +1 -1
  63. package/dist/{types-ChewVlpE.d.ts → types-DNCNRu0E.d.ts} +24 -2
  64. package/dist/{workspace-archive-DQGFwvM6.js → workspace-archive-C9lgf77y.js} +11 -11
  65. package/dist/workspace-archive-C9lgf77y.js.map +1 -0
  66. package/package.json +5 -5
  67. package/dist/coordination-driver-BmtrkNPu.js.map +0 -1
  68. package/dist/graph-BKRvWzHx.js.map +0 -1
  69. package/dist/improvement-cycle-D0Os0Hg_.js.map +0 -1
  70. package/dist/prepare-RuaAclli.js.map +0 -1
  71. package/dist/runtime-DKiucqGX.js.map +0 -1
  72. package/dist/supervise-DsQjhLN-.js.map +0 -1
  73. package/dist/workspace-archive-DQGFwvM6.js.map +0 -1
@@ -1,11 +1,12 @@
1
- import { C as canonicalCandidateDocument, D as omitTopLevelDigest, E as immutableCandidateValue, O as sha256Bytes, S as canonicalCandidateDigest$1, T as embeddedCandidateArtifact, _ as verifyBytes, a as persistCandidateOutputArtifact, b as verifyWorkspaceSnapshotArtifacts, c as verifyTaskCheckout, d as isWellFormedUnicode, f as artifactCacheKey, h as readVerifiedArtifact, l as verifyTaskOutcomePatch, m as readMaterializedWorkspaceFiles, o as readCandidateGitHubResource, s as verifyCandidateCode, u as assertExactObjectKeys, v as verifyMaterializedProfileWorkspace, w as deepFreezeCandidate, x as canonicalCandidateBytes$1, y as verifyMaterializedWorkspace } from "./workspace-archive-DQGFwvM6.js";
1
+ import { C as canonicalCandidateDigest$1, D as immutableCandidateValue, E as embeddedCandidateArtifact, O as omitTopLevelDigest, S as canonicalCandidateBytes$1, T as deepFreezeCandidate, a as persistCandidateOutputArtifact, b as verifyMaterializedWorkspace, c as verifyTaskCheckout, d as isWellFormedUnicode, f as artifactCacheKey, g as readVerifiedArtifact, h as readMaterializedWorkspaceFiles, k as sha256Bytes$1, l as verifyTaskOutcomePatch, o as readCandidateGitHubResource, s as verifyCandidateCode, u as assertExactObjectKeys, v as verifyBytes, w as canonicalCandidateDocument, x as verifyWorkspaceSnapshotArtifacts, y as verifyMaterializedProfileWorkspace } from "./workspace-archive-C9lgf77y.js";
2
2
  import { i as redactProtectedValue, n as createProtectedRecordRedactor, r as redactProtectedReason, t as assertNoProtectedBytes } from "./protected-redaction--F3v1oo8.js";
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";
3
+ import { f as parseAgentCandidateProfileActivation, n as PI_CANDIDATE_SESSION_DIR_ENV, o as assertCandidateProfileExecutionSupport, s as candidateProfileAgentPaths, t as PI_CANDIDATE_AGENT_DIR_ENV, u as materializeAgentCandidateProfilePlan } from "./profile-D3eXNBQV.js";
4
+ import { agentCandidateArtifactRefSchema, agentCandidateBenchmarkResultEvidenceSchema, agentCandidateBenchmarkSuiteSchema, agentCandidateBenchmarkTaskSchema, agentCandidateBundleSchema, agentCandidateContainerSchema, agentCandidateExecutionLimitsSchema, agentCandidateExecutionPlanEvidenceSchema, agentCandidateExecutionPlanMaterialSchema, agentCandidateMaterializationReceiptSchema, agentCandidateModelAccessNetworkSchema, agentCandidateModelSettlementEvidenceSchema, agentCandidateProfilePlanEvidenceSchema, agentCandidateResolvedModelSchema, agentCandidateRunCellSchema, agentCandidateRunReceiptSchema, agentCandidateTaskOutcomeEvidenceSchema, agentCandidateTaskOutcomeSpecSchema, agentCandidateTerminationSchema, agentCandidateWorkspaceManifestMaterialSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, sha256DigestSchema } from "@tangle-network/agent-interface";
4
5
  import { REDACTION_VERSION, isLlmSpan } from "@tangle-network/agent-eval";
5
6
  import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
6
7
  import { isAbsolute, join, posix, relative, resolve } from "node:path";
7
8
  import { lstat, mkdtemp, readFile, readdir, rm } from "node:fs/promises";
8
- import { applyAgentCandidateWorkspacePlan, isMaterializerHarness, materializeCandidateProfile, resolvePiRuntimePaths } from "@tangle-network/agent-profile-materialize";
9
+ import { applyAgentCandidateWorkspacePlan } from "@tangle-network/agent-profile-materialize";
9
10
  import { tmpdir } from "node:os";
10
11
  import { hashKnowledgeBase } from "@tangle-network/agent-knowledge";
11
12
  //#region src/candidate-execution/claim-file-formats.ts
@@ -871,437 +872,6 @@ function executionPathsOverlap(left, right) {
871
872
  return a === b || b.startsWith(a === "/" ? "/" : `${a}/`) || a.startsWith(b === "/" ? "/" : `${b}/`);
872
873
  }
873
874
  //#endregion
874
- //#region src/candidate-execution/system-prompt.ts
875
- const SYSTEM_PROMPT_FILE = ".tangle/system-prompt.md";
876
- const APPEND_SYSTEM_PROMPT_FILE = ".tangle/append-system-prompt.md";
877
- const SYSTEM_PROMPT_FLAGS = ["--system-prompt", "--system-prompt-file"];
878
- const APPEND_SYSTEM_PROMPT_FLAGS = ["--append-system-prompt", "--append-system-prompt-file"];
879
- function argsSetSystemPromptFlag(values) {
880
- return values.some((value) => SYSTEM_PROMPT_FLAGS.some((flag) => value === flag || value.startsWith(`${flag}=`)));
881
- }
882
- function argsSetAppendSystemPromptFlag(values) {
883
- return values.some((value) => APPEND_SYSTEM_PROMPT_FLAGS.some((flag) => value === flag || value.startsWith(`${flag}=`)));
884
- }
885
- /** Codex keys that can replace or contaminate the materializer's sealed instructions file. */
886
- const CODEX_INSTRUCTION_KEYS = ["model_instructions_file", "developer_instructions"];
887
- function argsSetCodexInstructionOverride(values) {
888
- for (let index = 0; index < values.length; index++) {
889
- const value = values[index];
890
- const config = value === "-c" || value === "--config" ? values[index + 1] : value.startsWith("--config=") ? value.slice(9) : void 0;
891
- if (config !== void 0 && CODEX_INSTRUCTION_KEYS.some((key) => config.trimStart().startsWith(`${key}=`))) return true;
892
- }
893
- return false;
894
- }
895
- const HARNESS_SYSTEM_PROMPTS = {
896
- "claude-code": {
897
- executable: "claude",
898
- project: (plan, systemPrompt, path) => appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), "--system-prompt-file", path),
899
- projectAppend: (plan, appendSystemPrompt, path) => appendFlags(addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt), "--append-system-prompt-file", path),
900
- conflictsWithArgs: argsSetSystemPromptFlag,
901
- conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
902
- },
903
- /** OpenCode's bound primary agent is already selected by the materializer's --agent flag. */
904
- opencode: {
905
- executable: "opencode",
906
- project: (plan) => plan,
907
- retainsProjectedSystemPrompt: true,
908
- conflictsWithArgs: (values) => values.some((value) => value === "--agent" || value.startsWith("--agent=")),
909
- conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
910
- },
911
- pi: {
912
- executable: "pi",
913
- project: (plan, systemPrompt, path) => appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), "--system-prompt", path),
914
- projectAppend: (plan, appendSystemPrompt, path) => appendFlags(addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt), "--append-system-prompt", path),
915
- conflictsWithArgs: argsSetSystemPromptFlag,
916
- conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
917
- },
918
- prime: {
919
- executable: "prime-agent",
920
- project: (plan, systemPrompt, path) => appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), "--system-prompt", path),
921
- projectAppend: (plan, appendSystemPrompt, path) => appendFlags(addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt), "--append-system-prompt", path),
922
- conflictsWithArgs: argsSetSystemPromptFlag,
923
- conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
924
- },
925
- /** Gemini's file and env lowering is materializer-owned; this row supplies the launch proof. */
926
- gemini: {
927
- executable: "gemini",
928
- project: (plan) => plan,
929
- conflictsWithArgs: argsSetSystemPromptFlag,
930
- conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
931
- }
932
- };
933
- /**
934
- * These controls are lowered by agent-profile-materialize into files plus launch inputs. The
935
- * candidate adapter does not own the spawn, so it must reject an arbitrary entrypoint even when
936
- * the plan has the right bytes: only the native binary can make those inputs effective.
937
- */
938
- const MATERIALIZED_PROMPT_DELIVERIES = {
939
- codex: {
940
- executable: "codex",
941
- delivered: (plan) => plan.files.some((file) => file.relPath === ".codex/system-prompt.md") && plan.flags.some((flag) => flag.value === "model_instructions_file=.codex/system-prompt.md"),
942
- conflictsWithArgs: argsSetCodexInstructionOverride
943
- },
944
- gemini: {
945
- executable: "gemini",
946
- delivered: (plan) => plan.files.some((file) => file.relPath === ".gemini/system.md") && plan.env.GEMINI_SYSTEM_MD?.value === "1",
947
- conflictsWithArgs: argsSetSystemPromptFlag
948
- }
949
- };
950
- /** Project both prompt intents onto their distinct native process controls. */
951
- function projectCandidatePromptIntents(plan, launch, systemPromptFilePath, requestedSystemPrompt = plan.systemPrompt?.value, requestedAppendSystemPrompt = plan.appendSystemPrompt?.value) {
952
- const systemPrompt = plan.systemPrompt;
953
- const appendSystemPrompt = plan.appendSystemPrompt;
954
- const delivery = MATERIALIZED_PROMPT_DELIVERIES[plan.harness];
955
- if (systemPrompt === void 0 && delivery?.delivered(plan)) {
956
- assertProvableNativeLaunch(plan.harness, delivery.executable, launch, "replacement");
957
- assertNoShadowingArgs(plan.harness, delivery.conflictsWithArgs, launch, "replacement");
958
- if (requestedSystemPrompt === void 0) return plan;
959
- return plan;
960
- }
961
- if (requestedSystemPrompt === void 0 && requestedAppendSystemPrompt === void 0) return plan;
962
- const projection = HARNESS_SYSTEM_PROMPTS[plan.harness];
963
- if (!projection) throw new Error(`candidate system prompt has no native launch projection for ${plan.harness}`);
964
- const requestedReplacement = requestedSystemPrompt !== void 0;
965
- if (requestedReplacement && systemPrompt === void 0) throw new Error(`profile materializer did not deliver the candidate system prompt for ${plan.harness}`);
966
- if (systemPrompt !== void 0 && requestedSystemPrompt === void 0) throw new Error(`profile materializer added an unexpected candidate system prompt for ${plan.harness}`);
967
- if (systemPrompt !== void 0 && systemPrompt.value !== requestedSystemPrompt) throw new Error("profile materializer changed the candidate system prompt");
968
- if (appendSystemPrompt !== void 0 && appendSystemPrompt.value !== requestedAppendSystemPrompt) throw new Error("profile materializer changed the candidate append system prompt");
969
- const intent = requestedReplacement ? "replacement" : "addition";
970
- assertProvableNativeLaunch(plan.harness, projection.executable, launch, intent);
971
- const launchArgs = (launch.args ?? []).map((value) => value.value);
972
- if (requestedReplacement && projection.conflictsWithArgs(launchArgs)) throw new Error(`${plan.harness} launch arguments conflict with the candidate profile system prompt`);
973
- if (requestedAppendSystemPrompt !== void 0 && projection.conflictsWithAppendArgs(launchArgs)) throw new Error(`${plan.harness} launch arguments conflict with the candidate profile append system prompt`);
974
- let projected = plan;
975
- if (systemPrompt !== void 0) projected = projection.project(projection.retainsProjectedSystemPrompt ? projected : omitPromptIntent(projected, "systemPrompt"), systemPrompt.value, systemPromptFilePath);
976
- if (appendSystemPrompt !== void 0) {
977
- if (!projection.projectAppend) throw new Error(`candidate append system prompt has no native launch projection for ${plan.harness}`);
978
- projected = projection.projectAppend(omitPromptIntent(projected, "appendSystemPrompt"), appendSystemPrompt.value, posix.join(posix.dirname(systemPromptFilePath), "append-system-prompt.md"));
979
- }
980
- return projected;
981
- }
982
- function assertProvableNativeLaunch(harness, expectedExecutable, launch, intent) {
983
- if (launch.kind !== "container-command") throw new Error(`candidate-entrypoint launch cannot prove ${harness} system-prompt ${intent}`);
984
- if (launch.executable !== expectedExecutable && !(posix.isAbsolute(launch.executable) && posix.basename(launch.executable) === expectedExecutable)) throw new Error(`${harness} system-prompt ${intent} requires the native ${expectedExecutable} executable`);
985
- }
986
- function assertNoShadowingArgs(harness, conflictsWithArgs, launch, intent) {
987
- if (conflictsWithArgs((launch.args ?? []).map((value) => value.value))) throw new Error(`${harness} launch arguments conflict with the candidate profile ${intent === "replacement" ? "system" : "append system"} prompt`);
988
- }
989
- function omitPromptIntent(plan, intent) {
990
- const projected = { ...plan };
991
- delete projected[intent];
992
- return projected;
993
- }
994
- function appendFlags(plan, ...values) {
995
- return {
996
- ...plan,
997
- flags: [...plan.flags, ...values.map(publicValue$1)]
998
- };
999
- }
1000
- function publicValue$1(value) {
1001
- return {
1002
- kind: "public",
1003
- value
1004
- };
1005
- }
1006
- function addPromptFile(plan, relPath, prompt) {
1007
- if (plan.files.some((file) => file.relPath === relPath)) throw new Error(`candidate profile conflicts with reserved ${relPath}`);
1008
- return {
1009
- ...plan,
1010
- files: [...plan.files, {
1011
- relPath,
1012
- content: prompt,
1013
- source: "generated"
1014
- }]
1015
- };
1016
- }
1017
- //#endregion
1018
- //#region src/candidate-execution/profile.ts
1019
- function candidateMaterializerHarness(harness) {
1020
- if (!isMaterializerHarness(harness)) throw new Error(`sealed candidate profile materialization is unsupported for harness ${harness}`);
1021
- return harness;
1022
- }
1023
- /** Runtime applies the materializer's launch flags to the candidate process. */
1024
- const CANDIDATE_PROFILE_MATERIALIZER_BINDS = ["systemPrompt"];
1025
- const PI_CANDIDATE_AGENT_DIR_ENV = "PI_CODING_AGENT_DIR";
1026
- const PI_CANDIDATE_SESSION_DIR_ENV = "PI_CODING_AGENT_SESSION_DIR";
1027
- /** Derive the exact native profile plan used by preparation and later evidence checks. */
1028
- function materializeAgentCandidateProfilePlan(options) {
1029
- const root = options.workspace === "task" ? options.workspaces.taskRoot : options.workspaces.candidateRoot;
1030
- if (!root) throw new Error("candidate profile target is missing its execution workspace root");
1031
- return projectCandidatePromptIntents(materializeCandidateProfile(options.profile, candidateMaterializerHarness(options.harness), {
1032
- binds: CANDIDATE_PROFILE_MATERIALIZER_BINDS,
1033
- resolvedResources: options.resolvedResources
1034
- }), options.launch, posix.join(root, ".tangle/system-prompt.md"), options.profile.prompt?.systemPrompt, options.profile.prompt?.appendSystemPrompt);
1035
- }
1036
- /** Resolve the private Pi roots needed by an agent-root profile plan. */
1037
- function candidateProfileAgentPaths(plan, runtimeHome) {
1038
- if (!plan.files.some((file) => file.root === "agent")) return void 0;
1039
- if (plan.harness !== "pi") throw new Error(`candidate profile agent-root files are unsupported for ${plan.harness}`);
1040
- if (runtimeHome === void 0) throw new Error("candidate profile agent-root files require executionRoots.profileRoot");
1041
- return resolvePiRuntimePaths(runtimeHome);
1042
- }
1043
- /** Bind exact native profile text to the canonical plan captured during preparation. */
1044
- function createAgentCandidateProfileActivation(plan, profilePlan) {
1045
- const sourceByIdentity = new Map(plan.files.map((file) => [profileFileIdentity$1(file.root, file.relPath), file]));
1046
- if (sourceByIdentity.size !== plan.files.length) throw new Error("candidate profile activation contains duplicate rooted native file paths");
1047
- const files = profilePlan.material.files.map((expected) => {
1048
- const source = sourceByIdentity.get(profileFileIdentity$1(expected.root, expected.relPath));
1049
- if (!source) throw new Error(`candidate profile activation is missing ${profileFileLabel(expected.root, expected.relPath)}`);
1050
- const mode = source.mode ?? 420;
1051
- if (!Number.isSafeInteger(mode) || mode < 0 || mode > 511) throw new Error(`candidate profile activation has invalid mode for ${profileFileLabel(expected.root, expected.relPath)}`);
1052
- return {
1053
- path: expected.relPath,
1054
- mode,
1055
- content: source.content
1056
- };
1057
- });
1058
- if (files.length !== plan.files.length) throw new Error("candidate profile activation contains unplanned native files");
1059
- return parseAgentCandidateProfileActivation(canonicalCandidateDocument({
1060
- kind: "agent-candidate-profile-activation",
1061
- profilePlan,
1062
- files
1063
- }).value, profilePlan.digest);
1064
- }
1065
- function profileFileIdentity$1(root, relPath) {
1066
- return `${root ?? "workspace"}\0${relPath}`;
1067
- }
1068
- function profileFileLabel(root, relPath) {
1069
- return root === "agent" ? `agent:${relPath}` : relPath;
1070
- }
1071
- /** Parse and check every native file hash plus both canonical document digests. */
1072
- function parseAgentCandidateProfileActivation(input, expectedProfilePlanDigest) {
1073
- const activation = agentCandidateProfileActivationSchema.parse(input);
1074
- const planBytes = canonicalCandidateBytes$1(activation.profilePlan.material);
1075
- const profilePlanArtifact = activation.profilePlan.artifact;
1076
- if (sha256Bytes(planBytes) !== activation.profilePlan.digest || profilePlanArtifact.sha256 !== activation.profilePlan.digest || profilePlanArtifact.byteLength !== planBytes.byteLength || "content" in profilePlanArtifact && !Buffer.from(profilePlanArtifact.content, "base64").equals(Buffer.from(planBytes)) || expectedProfilePlanDigest !== void 0 && activation.profilePlan.digest !== expectedProfilePlanDigest) throw new Error("candidate profile activation has an invalid canonical profile plan");
1077
- if (canonicalCandidateDigest$1(omitTopLevelDigest(activation)) !== activation.digest) throw new Error("candidate profile activation digest does not match");
1078
- return immutableCandidateValue(activation);
1079
- }
1080
- const CANDIDATE_PROFILE_DIRECT_FIELDS = [
1081
- "name",
1082
- "description",
1083
- "version",
1084
- "tags",
1085
- "prompt",
1086
- "harness",
1087
- "permissions",
1088
- "tools",
1089
- "confidential"
1090
- ];
1091
- /** Convert only behavior-preserving generic profile fields into the closed candidate contract. */
1092
- function freezeGenericAgentCandidateProfile(input) {
1093
- return candidateProfileFromGenericProfile(parseExactAgentProfile(input, "profile"));
1094
- }
1095
- /**
1096
- * Keep every generic-profile-to-candidate conversion in one place.
1097
- * Callers use this both when sealing a new bundle and when proving a measured
1098
- * profile is exactly the profile in an existing candidate.
1099
- */
1100
- function candidateProfileFromGenericProfile(profile) {
1101
- if (profile.connections !== void 0) unsupportedProfileField("connections");
1102
- if (profile.metadata !== void 0) unsupportedProfileField("metadata");
1103
- if (profile.extensions !== void 0) unsupportedProfileField("extensions");
1104
- if (profile.model?.metadata !== void 0) unsupportedProfileField("model.metadata");
1105
- const candidate = {};
1106
- copyDirectProfileFields(candidate, profile);
1107
- if (profile.model) {
1108
- const { metadata: _metadata, ...model } = profile.model;
1109
- candidate.model = model;
1110
- }
1111
- if (profile.mcp) candidate.mcp = freezeMcpServers(profile.mcp);
1112
- if (profile.subagents) candidate.subagents = Object.fromEntries(Object.entries(profile.subagents).map(([name, subagent]) => {
1113
- if (subagent.metadata !== void 0) unsupportedProfileField(`subagents.${name}.metadata`);
1114
- const { metadata: _metadata, ...value } = subagent;
1115
- return [name, value];
1116
- }));
1117
- if (profile.resources) candidate.resources = freezeResources(profile.resources);
1118
- if (profile.hooks && Object.values(profile.hooks).some((commands) => commands.length > 0)) throw new Error("generic AgentProfile hooks cannot be safely tokenized; use a candidate-profile source with executable/args");
1119
- if (profile.hooks) candidate.hooks = profile.hooks;
1120
- if (profile.modes) candidate.modes = Object.fromEntries(Object.entries(profile.modes).map(([name, mode]) => {
1121
- if (mode.metadata !== void 0) unsupportedProfileField(`modes.${name}.metadata`);
1122
- const { metadata: _metadata, ...value } = mode;
1123
- return [name, value];
1124
- }));
1125
- return parseExactCandidateProfile(candidate);
1126
- }
1127
- /** Prove the measured generic profile and sealed candidate profile describe the same behavior. */
1128
- function assertCandidateProfileBinding(measuredInput, bundled) {
1129
- if (canonicalCandidateDigest$1(candidateProfileFromGenericProfile(parseExactAgentProfile(measuredInput, "measured agent profile"))) !== canonicalCandidateDigest$1(bundled)) throw new Error("measured agent profile does not match sealed candidate profile");
1130
- }
1131
- /** Parse a complete profile without silently discarding unsupported fields. */
1132
- function parseExactAgentProfile(input, label) {
1133
- let parsed;
1134
- try {
1135
- parsed = agentProfileSchema.parse(input);
1136
- } catch (cause) {
1137
- throw new Error(`${label} contains unsupported or non-canonical fields`, { cause });
1138
- }
1139
- assertCanonicalParse(input, parsed, label);
1140
- return parsed;
1141
- }
1142
- /** Parse a profile diff without silently discarding unsupported fields. */
1143
- function parseExactAgentProfileDiff(input, label) {
1144
- let parsed;
1145
- try {
1146
- parsed = agentProfileDiffSchema.parse(input);
1147
- } catch (cause) {
1148
- throw new Error(`${label} contains unsupported or non-canonical fields`, { cause });
1149
- }
1150
- assertCanonicalParse(input, parsed, label);
1151
- return parsed;
1152
- }
1153
- /** Apply one exact diff and reject any value that cannot be preserved canonically. */
1154
- function applyExactAgentProfileDiff(baseInput, diffInput, label) {
1155
- return parseExactAgentProfile(omitUndefinedObjectFields(applyAgentProfileDiff(parseExactAgentProfile(baseInput, `${label} base profile`), parseExactAgentProfileDiff(diffInput, `${label} diff`)), label), `${label} result`);
1156
- }
1157
- /** Parse a candidate profile without silently discarding unsupported or non-canonical fields. */
1158
- function parseExactCandidateProfile(input) {
1159
- const parsed = agentCandidateProfileSchema.parse(input);
1160
- assertCanonicalParse(input, parsed, "candidate profile");
1161
- return parsed;
1162
- }
1163
- /** Reject profile fields whose behavioral effect is not yet proven by candidate executors. */
1164
- function assertCandidateProfileExecutionSupport(profile) {
1165
- const unsupported = [
1166
- "tools",
1167
- "permissions",
1168
- "modes",
1169
- "confidential"
1170
- ].filter((field) => hasEntries(profile[field]));
1171
- if (unsupported.length > 0) throw new Error(`candidate execution cannot prove in-session effects for non-empty AgentProfile fields: ${unsupported.join(", ")}`);
1172
- }
1173
- /** Convert the candidate profile contract into the portable interface profile it represents. */
1174
- function agentCandidateProfileAsAgentProfile(candidate) {
1175
- const output = {};
1176
- copyDirectProfileFields(output, candidate);
1177
- if (candidate.model) output.model = { ...candidate.model };
1178
- if (candidate.mcp) output.mcp = Object.fromEntries(Object.entries(candidate.mcp).map(([name, server]) => [name, {
1179
- ...server,
1180
- ...server.args ? { args: server.args.map((value) => ({ ...value })) } : {},
1181
- ...server.env ? { env: cloneRecord(server.env) } : {}
1182
- }]));
1183
- if (candidate.subagents) output.subagents = cloneRecord(candidate.subagents);
1184
- if (candidate.modes) output.modes = cloneRecord(candidate.modes);
1185
- if (candidate.hooks) output.hooks = Object.fromEntries(Object.entries(candidate.hooks).map(([event, hooks]) => [event, hooks.map(({ executable, args, env, ...hook }) => ({
1186
- ...hook,
1187
- command: [executable, ...(args ?? []).map(publicValue)].map(shellQuote).join(" "),
1188
- ...env ? { env: cloneRecord(env) } : {}
1189
- }))]));
1190
- if (candidate.resources) {
1191
- if (candidate.resources.failOnError !== true) throw new Error("sealed candidate profile contains fields unsupported by generic profiles");
1192
- output.resources = {
1193
- failOnError: true,
1194
- ...candidate.resources.files ? { files: candidate.resources.files.map((file) => ({
1195
- ...file,
1196
- resource: publicResource(file.resource)
1197
- })) } : {},
1198
- ...candidate.resources.tools ? { tools: candidate.resources.tools.map(publicResource) } : {},
1199
- ...candidate.resources.skills ? { skills: candidate.resources.skills.map(publicResource) } : {},
1200
- ...candidate.resources.agents ? { agents: candidate.resources.agents.map(publicResource) } : {},
1201
- ...candidate.resources.commands ? { commands: candidate.resources.commands.map(publicResource) } : {},
1202
- ...candidate.resources.instructions !== void 0 ? { instructions: typeof candidate.resources.instructions === "string" ? candidate.resources.instructions : publicResource(candidate.resources.instructions) } : {}
1203
- };
1204
- }
1205
- return output;
1206
- }
1207
- /** Recursively remove undefined object fields while refusing undefined array entries. */
1208
- function omitUndefinedObjectFields(value, path) {
1209
- if (Array.isArray(value)) return value.map((entry, index) => {
1210
- if (entry === void 0) throw new Error(`${path} produced an undefined array entry at ${index}`);
1211
- return omitUndefinedObjectFields(entry, `${path}[${index}]`);
1212
- });
1213
- if (value === null || typeof value !== "object") return value;
1214
- return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0).map(([key, entry]) => [key, omitUndefinedObjectFields(entry, `${path}.${key}`)]));
1215
- }
1216
- function freezeMcpServers(servers) {
1217
- return Object.fromEntries(Object.entries(servers).map(([name, server]) => {
1218
- if (server.transport !== void 0 && server.transport !== "stdio") unsupportedProfileField(`mcp.${name}.transport=${server.transport}`);
1219
- if (server.url !== void 0) unsupportedProfileField(`mcp.${name}.url`);
1220
- if (server.headers !== void 0) unsupportedProfileField(`mcp.${name}.headers`);
1221
- if (server.metadata !== void 0) unsupportedProfileField(`mcp.${name}.metadata`);
1222
- return [name, {
1223
- ...server.transport ? { transport: server.transport } : {},
1224
- ...server.command ? { command: server.command } : {},
1225
- ...server.args ? { args: server.args.map((value, index) => candidatePublicValue(value, `mcp.${name}.args[${index}]`)) } : {},
1226
- ...server.env ? { env: mapCandidatePublicValues(server.env, `mcp.${name}.env`) } : {},
1227
- ...server.cwd ? { cwd: server.cwd } : {},
1228
- ...server.enabled === void 0 ? {} : { enabled: server.enabled }
1229
- }];
1230
- }));
1231
- }
1232
- function freezeResources(resources) {
1233
- if (resources.failOnError !== true) throw new Error("candidate profile resources require failOnError: true");
1234
- return {
1235
- failOnError: true,
1236
- ...resources.files ? { files: resources.files.map((file) => ({
1237
- ...file,
1238
- resource: freezeResource(file.resource)
1239
- })) } : {},
1240
- ...resources.tools ? { tools: resources.tools.map(freezeResource) } : {},
1241
- ...resources.skills ? { skills: resources.skills.map(freezeResource) } : {},
1242
- ...resources.agents ? { agents: resources.agents.map(freezeResource) } : {},
1243
- ...resources.commands ? { commands: resources.commands.map(freezeResource) } : {},
1244
- ...resources.instructions === void 0 ? {} : { instructions: typeof resources.instructions === "string" ? resources.instructions : freezeResource(resources.instructions) }
1245
- };
1246
- }
1247
- function freezeResource(resource) {
1248
- if (resource.kind === "github") throw new Error("generic GitHub profile resources do not carry byte identity; use a candidate-profile source with a pinned commit, digest, and byte length");
1249
- const bytes = Buffer.from(resource.content, "utf8");
1250
- return {
1251
- ...resource,
1252
- sha256: embeddedCandidateArtifact(bytes).sha256,
1253
- byteLength: bytes.byteLength
1254
- };
1255
- }
1256
- function copyDirectProfileFields(target, source) {
1257
- for (const key of CANDIDATE_PROFILE_DIRECT_FIELDS) if (source[key] !== void 0) target[key] = source[key];
1258
- }
1259
- function assertCanonicalParse(input, parsed, label) {
1260
- if (!Buffer.from(canonicalCandidateBytes$1(input)).equals(canonicalCandidateBytes$1(parsed))) throw new Error(`${label} contains unsupported or non-canonical fields`);
1261
- }
1262
- function publicResource(resource) {
1263
- if (resource.kind === "inline") return {
1264
- kind: "inline",
1265
- name: resource.name,
1266
- content: resource.content
1267
- };
1268
- return {
1269
- kind: "github",
1270
- repository: `${resource.repository.owner}/${resource.repository.repo}`,
1271
- path: resource.path,
1272
- ref: resource.commit,
1273
- ...resource.name ? { name: resource.name } : {}
1274
- };
1275
- }
1276
- /** Freeze one profile config value into the candidate's PUBLIC-only config
1277
- * shape. A secret-ref has no candidate representation (AgentCandidateConfigValue
1278
- * is public-only), so it is rejected, never silently dropped or unwrapped. */
1279
- function candidatePublicValue(value, path) {
1280
- if (value.kind !== "public") unsupportedProfileField(`${path} (secret-ref '${value.key}')`);
1281
- return {
1282
- kind: "public",
1283
- value: value.value
1284
- };
1285
- }
1286
- function mapCandidatePublicValues(values, pathPrefix) {
1287
- return Object.fromEntries(Object.entries(values).map(([name, value]) => [name, candidatePublicValue(value, `${pathPrefix}.${name}`)]));
1288
- }
1289
- function publicValue(value) {
1290
- return value.value;
1291
- }
1292
- function cloneRecord(values) {
1293
- return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, { ...value }]));
1294
- }
1295
- function hasEntries(value) {
1296
- return value !== void 0 && value !== null && typeof value === "object" ? Object.keys(value).length > 0 : false;
1297
- }
1298
- function shellQuote(value) {
1299
- return /^[A-Za-z0-9_./:@%+=,-]+$/.test(value) ? value : `'${value.replaceAll("'", `'"'"'`)}'`;
1300
- }
1301
- function unsupportedProfileField(path) {
1302
- throw new Error(`generic AgentProfile field ${path} is not representable in a sealed candidate profile`);
1303
- }
1304
- //#endregion
1305
875
  //#region src/candidate-execution/types.ts
1306
876
  const verifiedCandidateBrand = Symbol("verifiedAgentCandidate");
1307
877
  const preparedCandidateBrand = Symbol("preparedAgentCandidate");
@@ -1541,7 +1111,7 @@ function assertPrivateCandidateIntegrity(state) {
1541
1111
  }
1542
1112
  function assertPlanEvidence(evidence, bytes, label) {
1543
1113
  const expected = canonicalCandidateBytes$1(evidence.material);
1544
- if (sha256Bytes(expected) !== evidence.digest || !Buffer.from(expected).equals(Buffer.from(bytes)) || evidence.artifact.sha256 !== evidence.digest || evidence.artifact.byteLength !== bytes.byteLength || !("content" in evidence.artifact) || !Buffer.from(evidence.artifact.content, "base64").equals(Buffer.from(bytes))) throw new Error(`prepared ${label} no longer matches its canonical bytes`);
1114
+ if (sha256Bytes$1(expected) !== evidence.digest || !Buffer.from(expected).equals(Buffer.from(bytes)) || evidence.artifact.sha256 !== evidence.digest || evidence.artifact.byteLength !== bytes.byteLength || !("content" in evidence.artifact) || !Buffer.from(evidence.artifact.content, "base64").equals(Buffer.from(bytes))) throw new Error(`prepared ${label} no longer matches its canonical bytes`);
1545
1115
  }
1546
1116
  function evidenceView(evidence) {
1547
1117
  const bytes = Uint8Array.from(evidence.bytes);
@@ -1612,7 +1182,7 @@ function assertExecutorInputs(state) {
1612
1182
  for (let index = 0; index < expectedFiles.length; index++) {
1613
1183
  const expected = expectedFiles[index];
1614
1184
  const actual = state.executorInputs.profileFiles[index];
1615
- 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");
1185
+ if (!expected || !actual || actual.path !== expected.relPath || (actual.root ?? "workspace") !== (expected.root ?? "workspace") || actual.mode !== expected.mode || sha256Bytes$1(actual.bytes) !== expected.contentSha256) throw new Error("prepared profile executor files do not match the signed profile plan");
1616
1186
  }
1617
1187
  }
1618
1188
  function assertPreparedKnowledge(state) {
@@ -1628,14 +1198,14 @@ function assertPreparedKnowledge(state) {
1628
1198
  if (expected.retrievalConfig || actual.retrievalConfig) throw new Error("prepared knowledge retrieval config does not match the candidate bundle");
1629
1199
  return;
1630
1200
  }
1631
- if (actual.retrievalConfig.byteLength !== expected.retrievalConfig.byteLength || sha256Bytes(actual.retrievalConfig) !== expected.retrievalConfig.sha256) throw new Error("prepared knowledge retrieval config does not match the candidate bundle");
1201
+ if (actual.retrievalConfig.byteLength !== expected.retrievalConfig.byteLength || sha256Bytes$1(actual.retrievalConfig) !== expected.retrievalConfig.sha256) throw new Error("prepared knowledge retrieval config does not match the candidate bundle");
1632
1202
  }
1633
1203
  function assertWorkspaceExecutorFiles(actualFiles, expected) {
1634
1204
  if (actualFiles.length !== expected.files.length) throw new Error("prepared workspace executor files do not match the signed manifest");
1635
1205
  for (let index = 0; index < expected.files.length; index++) {
1636
1206
  const actual = actualFiles[index];
1637
1207
  const planned = expected.files[index];
1638
- if (!actual || !planned || actual.path !== planned.path || actual.mode !== planned.mode || actual.bytes.byteLength !== planned.byteLength || sha256Bytes(actual.bytes) !== planned.sha256) throw new Error("prepared workspace executor files do not match the signed manifest");
1208
+ if (!actual || !planned || actual.path !== planned.path || actual.mode !== planned.mode || actual.bytes.byteLength !== planned.byteLength || sha256Bytes$1(actual.bytes) !== planned.sha256) throw new Error("prepared workspace executor files do not match the signed manifest");
1639
1209
  }
1640
1210
  }
1641
1211
  function assertSignedBenchmarkInput(state) {
@@ -1647,7 +1217,7 @@ function assertSignedBenchmarkInput(state) {
1647
1217
  if (canonicalCandidateDigest$1(omitTopLevelDigest(suite)) !== suite.digest || canonicalCandidateDigest$1(omitTopLevelDigest(task)) !== task.digest || canonicalCandidateDigest$1(omitTopLevelDigest(cell)) !== cell.digest || cell.bundleDigest !== state.bundle.digest || cell.suiteDigest !== suite.digest || cell.taskDigest !== task.digest || suite.taskDigests[cell.taskIndex] !== task.digest || suite.seeds[cellIndex] !== cell.seed || cell.repetition >= suite.reps || cell.attempt < 1 || cell.attempt > task.attempt.maxAttempts) throw new Error("prepared candidate no longer matches its signed experiment cell");
1648
1218
  const suiteBytes = canonicalCandidateBytes$1(omitTopLevelDigest(suite));
1649
1219
  const taskBytes = canonicalCandidateBytes$1(omitTopLevelDigest(task));
1650
- if (receipt.benchmark.suite.digest !== suite.digest || receipt.benchmark.suite.material.sha256 !== sha256Bytes(suiteBytes) || receipt.benchmark.suite.material.byteLength !== suiteBytes.byteLength || receipt.benchmark.task.digest !== task.digest || receipt.benchmark.task.material.sha256 !== sha256Bytes(taskBytes) || receipt.benchmark.task.material.byteLength !== taskBytes.byteLength) throw new Error("materialization receipt no longer matches its signed benchmark input");
1220
+ if (receipt.benchmark.suite.digest !== suite.digest || receipt.benchmark.suite.material.sha256 !== sha256Bytes$1(suiteBytes) || receipt.benchmark.suite.material.byteLength !== suiteBytes.byteLength || receipt.benchmark.task.digest !== task.digest || receipt.benchmark.task.material.sha256 !== sha256Bytes$1(taskBytes) || receipt.benchmark.task.material.byteLength !== taskBytes.byteLength) throw new Error("materialization receipt no longer matches its signed benchmark input");
1651
1221
  }
1652
1222
  function immutableExecutorFiles(files) {
1653
1223
  return Object.freeze(files.map((file) => Object.freeze({
@@ -2182,7 +1752,7 @@ async function memoryReceipt(state, capture, persisted, signal) {
2182
1752
  const manifestBytes = canonicalCandidateBytes$1(afterState);
2183
1753
  const snapshot = agentCandidateWorkspaceSnapshotEvidenceSchema.parse({
2184
1754
  kind: "agent-candidate-workspace-snapshot",
2185
- digest: sha256Bytes(manifestBytes),
1755
+ digest: sha256Bytes$1(manifestBytes),
2186
1756
  material: afterState,
2187
1757
  manifest: persisted.manifest,
2188
1758
  archive: persisted.archive
@@ -2224,7 +1794,7 @@ async function runBoundCandidateBenchmarkGrader(input) {
2224
1794
  const descriptor = snapshotGraderDescriptor(input.grader, input.expectedGrader);
2225
1795
  const implementationBytes = await readVerifiedArtifact(descriptor.artifact, input.artifacts);
2226
1796
  if (implementationBytes.byteLength === 0) throw new Error("candidate benchmark grader implementation cannot be empty");
2227
- const expectedImplementationDigest = sha256Bytes(implementationBytes);
1797
+ const expectedImplementationDigest = sha256Bytes$1(implementationBytes);
2228
1798
  const termination = immutableCandidateValue(input.termination);
2229
1799
  const run = input.grader.run;
2230
1800
  const startedAtMs = Date.now();
@@ -2239,7 +1809,7 @@ async function runBoundCandidateBenchmarkGrader(input) {
2239
1809
  input.signal?.throwIfAborted();
2240
1810
  assertExactRunnerResult(result);
2241
1811
  const evidence = Uint8Array.from(result.evidence);
2242
- const outputDigest = sha256Bytes(evidence);
1812
+ const outputDigest = sha256Bytes$1(evidence);
2243
1813
  if (result.binding.implementationDigest !== expectedImplementationDigest) throw new Error("candidate benchmark grader executed implementation digest does not match its verified artifact");
2244
1814
  if (result.binding.taskOutcomeDigest !== input.outcome.evidence.digest) throw new Error("candidate benchmark grader task outcome digest does not match verified outcome");
2245
1815
  if (result.binding.outputDigest !== outputDigest) throw new Error("candidate benchmark grader raw output digest does not match returned evidence");
@@ -2419,7 +1989,7 @@ async function persistCandidateModelSettlementEvidence(identity, settlement, out
2419
1989
  usage: settlement.usage
2420
1990
  };
2421
1991
  const bytes = canonicalCandidateBytes$1(material);
2422
- const digest = sha256Bytes(bytes);
1992
+ const digest = sha256Bytes$1(bytes);
2423
1993
  const artifact = await persistCandidateOutputArtifact(outputArtifacts, {
2424
1994
  executionId: identity.executionId,
2425
1995
  purpose: "model-settlement",
@@ -2478,7 +2048,7 @@ async function verifyWorkspaceTaskCapture(state, capture, protectedValues, signa
2478
2048
  assertNoProtectedBytes(manifestBytes, protectedValues);
2479
2049
  await verifyTaskOutcomeArchive(state, agentCandidateWorkspaceSnapshotEvidenceSchema.parse({
2480
2050
  kind: "agent-candidate-workspace-snapshot",
2481
- digest: sha256Bytes(manifestBytes),
2051
+ digest: sha256Bytes$1(manifestBytes),
2482
2052
  material: afterState,
2483
2053
  manifest: embeddedCandidateArtifact(manifestBytes),
2484
2054
  archive: embeddedCandidateArtifact(archive)
@@ -2499,7 +2069,7 @@ async function persistVerifiedWorkspaceTaskOutcome(state, verified, persisted, o
2499
2069
  const { afterState, manifestBytes, patch, repository } = verified;
2500
2070
  const snapshot = agentCandidateWorkspaceSnapshotEvidenceSchema.parse({
2501
2071
  kind: "agent-candidate-workspace-snapshot",
2502
- digest: sha256Bytes(manifestBytes),
2072
+ digest: sha256Bytes$1(manifestBytes),
2503
2073
  material: afterState,
2504
2074
  manifest: persisted.manifest,
2505
2075
  archive: persisted.archive
@@ -2576,7 +2146,7 @@ async function persistVerifiedOutputTaskOutcome(state, verified, persisted, outp
2576
2146
  }
2577
2147
  async function persistTaskOutcomeEvidence(state, material, outputArtifacts, signal) {
2578
2148
  const bytes = canonicalCandidateBytes$1(material);
2579
- const digest = sha256Bytes(bytes);
2149
+ const digest = sha256Bytes$1(bytes);
2580
2150
  const artifact = await persistCandidateOutputArtifact(outputArtifacts, {
2581
2151
  executionId: state.executionId,
2582
2152
  purpose: "task-outcome",
@@ -2626,7 +2196,7 @@ async function persistCandidateBenchmarkResult(state, termination, outcome, grad
2626
2196
  dimensions: evaluation.dimensions
2627
2197
  };
2628
2198
  const bytes = canonicalCandidateBytes$1(material);
2629
- const digest = sha256Bytes(bytes);
2199
+ const digest = sha256Bytes$1(bytes);
2630
2200
  const artifact = await persistCandidateOutputArtifact(outputArtifacts, {
2631
2201
  executionId: state.executionId,
2632
2202
  purpose: "benchmark-result",
@@ -2671,7 +2241,7 @@ async function verifyMemoryCapture(state, capture, protectedValues, signal) {
2671
2241
  assertNoProtectedBytes(memory.archive, protectedValues);
2672
2242
  const snapshot = agentCandidateWorkspaceSnapshotEvidenceSchema.parse({
2673
2243
  kind: "agent-candidate-workspace-snapshot",
2674
- digest: sha256Bytes(manifestBytes),
2244
+ digest: sha256Bytes$1(manifestBytes),
2675
2245
  material: memory.afterState,
2676
2246
  manifest: embeddedCandidateArtifact(manifestBytes),
2677
2247
  archive: embeddedCandidateArtifact(memory.archive)
@@ -3574,7 +3144,7 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
3574
3144
  agentCandidateExecutionPlanMaterialSchema.parse(executionMaterial);
3575
3145
  const executionBytes = canonicalCandidateBytes$1(executionMaterial);
3576
3146
  const executionDigest = canonicalCandidateDigest$1(executionMaterial);
3577
- if (sha256Bytes(executionBytes) !== executionDigest) throw new Error("execution plan canonical serializers disagree");
3147
+ if (sha256Bytes$1(executionBytes) !== executionDigest) throw new Error("execution plan canonical serializers disagree");
3578
3148
  const executionPlan = agentCandidateExecutionPlanEvidenceSchema.parse({
3579
3149
  kind: "agent-candidate-execution-plan",
3580
3150
  digest: executionDigest,
@@ -3999,7 +3569,7 @@ function exactProfileExecutorFiles(sourceFiles, expectedFiles) {
3999
3569
  const source = byIdentity.get(profileFileIdentity(expected.root, expected.relPath));
4000
3570
  const mode = source?.mode ?? 420;
4001
3571
  const bytes = Buffer.from(source?.content ?? "", "utf8");
4002
- 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");
3572
+ if (!source || !Number.isInteger(mode) || mode < 0 || mode > 511 || mode !== expected.mode || sha256Bytes$1(bytes) !== expected.contentSha256) throw new Error("profile source files do not match the signed profile plan");
4003
3573
  return {
4004
3574
  path: expected.relPath,
4005
3575
  mode,
@@ -4015,6 +3585,6 @@ function errorMessage(error) {
4015
3585
  return error instanceof Error ? error.message : String(error);
4016
3586
  }
4017
3587
  //#endregion
4018
- export { parseAgentCandidateProfileActivation as A, assertRecoveryMatchesStaged as B, applyExactAgentProfileDiff as C, freezeGenericAgentCandidateProfile as D, createAgentCandidateProfileActivation as E, InMemoryAgentCandidateExecutionClaimStore as F, rejectedFinish as G, assertTerminalMatchesClaim as H, candidateClaimFileInternals as I, sealTerminalDigest as J, rejectedStage as K, candidateCleanupDeadline as L, parseExactAgentProfileDiff as M, parseExactCandidateProfile as N, materializeAgentCandidateProfilePlan as O, assertAgentCandidateExecutionRoots as P, candidateCleanupTimeout as R, agentCandidateProfileAsAgentProfile as S, candidateProfileAgentPaths as T, assertTerminalMatchesStaged as U, assertTerminalAllowedInPhase as V, recoveredTerminalRecord as W, terminalRecord as Y, consumePreparedCandidateExecution as _, AGENT_CANDIDATE_EXECUTION_SUPPORT as a, PI_CANDIDATE_AGENT_DIR_ENV as b, executePreparedAgentCandidate as c, sealAgentCandidateModelSettlement as d, usdToNanos as f, beginPreparedCandidateDisposal as g, assertPreparedCandidateIntegrity as h, candidateKnowledgeExecutionPaths as i, parseExactAgentProfile as j, omitUndefinedObjectFields as k, RecoveryAgentCandidateTraceStore as l, candidateExecutionClaim as m, CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV as n, verifiedResourceTextByDigest as o, sealAgentCandidateExecutorStopAcknowledgement as p, requireStagedTerminal as q, CANDIDATE_KNOWLEDGE_ROOT_ENV as r, verifyAgentCandidateBundle as s, prepareAgentCandidateExecution as t, persistCandidateModelSettlementEvidence as u, CANDIDATE_TRACE_ENV as v, assertCandidateProfileBinding as w, PI_CANDIDATE_SESSION_DIR_ENV as x, CANDIDATE_TRACE_TAGS as y, withinCandidateCleanupDeadline as z };
3588
+ export { recoveredTerminalRecord as A, candidateCleanupDeadline as C, assertTerminalAllowedInPhase as D, assertRecoveryMatchesStaged as E, terminalRecord as F, rejectedStage as M, requireStagedTerminal as N, assertTerminalMatchesClaim as O, sealTerminalDigest as P, candidateClaimFileInternals as S, withinCandidateCleanupDeadline as T, consumePreparedCandidateExecution as _, AGENT_CANDIDATE_EXECUTION_SUPPORT as a, assertAgentCandidateExecutionRoots as b, executePreparedAgentCandidate as c, sealAgentCandidateModelSettlement as d, usdToNanos as f, beginPreparedCandidateDisposal as g, assertPreparedCandidateIntegrity as h, candidateKnowledgeExecutionPaths as i, rejectedFinish as j, assertTerminalMatchesStaged as k, RecoveryAgentCandidateTraceStore as l, candidateExecutionClaim as m, CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV as n, verifiedResourceTextByDigest as o, sealAgentCandidateExecutorStopAcknowledgement as p, CANDIDATE_KNOWLEDGE_ROOT_ENV as r, verifyAgentCandidateBundle as s, prepareAgentCandidateExecution as t, persistCandidateModelSettlementEvidence as u, CANDIDATE_TRACE_ENV as v, candidateCleanupTimeout as w, InMemoryAgentCandidateExecutionClaimStore as x, CANDIDATE_TRACE_TAGS as y };
4019
3589
 
4020
- //# sourceMappingURL=prepare-RuaAclli.js.map
3590
+ //# sourceMappingURL=prepare-oHUQdC5-.js.map