@tangle-network/agent-runtime 0.239.0 → 0.246.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 (78) hide show
  1. package/dist/{activation-CUhkPtm0.js → activation-C6d-NTWk.js} +3 -3
  2. package/dist/{activation-CUhkPtm0.js.map → activation-C6d-NTWk.js.map} +1 -1
  3. package/dist/{activation-CRDZUoUE.d.ts → activation-Df-ae5Uq.d.ts} +115 -5
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/candidate-execution/index.js +7 -7
  7. package/dist/candidate-execution/index.js.map +1 -1
  8. package/dist/{coordination-driver-m-2dzvu6.js → coordination-driver-De8pyM57.js} +25 -12
  9. package/dist/coordination-driver-De8pyM57.js.map +1 -0
  10. package/dist/{delegate-DRQtaWF1.js → delegate-DE6hNhbD.js} +2 -2
  11. package/dist/{delegate-DRQtaWF1.js.map → delegate-DE6hNhbD.js.map} +1 -1
  12. package/dist/{durable-file-D24y9zg7.js → durable-file-DWQA4ooo.js} +2 -2
  13. package/dist/{durable-file-D24y9zg7.js.map → durable-file-DWQA4ooo.js.map} +1 -1
  14. package/dist/durable.d.ts +2 -2
  15. package/dist/durable.js +3 -3
  16. package/dist/{graph-B17RjVhE.js → graph-s57f-VCR.js} +3 -3
  17. package/dist/{graph-B17RjVhE.js.map → graph-s57f-VCR.js.map} +1 -1
  18. package/dist/{improvement-cycle-BP4rDivU.js → improvement-cycle-BE3gIJwL.js} +458 -60
  19. package/dist/improvement-cycle-BE3gIJwL.js.map +1 -0
  20. package/dist/{index-DTGWDyrF.d.ts → index-CAG31NtK.d.ts} +7 -7
  21. package/dist/index.d.ts +11 -8
  22. package/dist/index.js +27 -17
  23. package/dist/index.js.map +1 -1
  24. package/dist/intelligence.d.ts +3 -3
  25. package/dist/intelligence.js +9 -6
  26. package/dist/intelligence.js.map +1 -1
  27. package/dist/kernel.d.ts +3 -3
  28. package/dist/kernel.js +9 -9
  29. package/dist/{loop-runner-bin-BGi5UT85.d.ts → loop-runner-bin-B_oSVrE7.d.ts} +3 -3
  30. package/dist/{loop-runner-bin-mrOuv9SU.js → loop-runner-bin-Bp8Mih20.js} +3 -3
  31. package/dist/{loop-runner-bin-mrOuv9SU.js.map → loop-runner-bin-Bp8Mih20.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-BPPAXxP2.d.ts → openai-tools-B1GMKDjW.d.ts} +2 -2
  38. package/dist/{prepare-Dc30WRB0.js → prepare-CibQrhfi.js} +28 -28
  39. package/dist/prepare-CibQrhfi.js.map +1 -0
  40. package/dist/profiles.d.ts +2 -2
  41. package/dist/{protected-model-port-D5gDcnrH.js → protected-model-port-Dhdi5mDl.js} +3 -3
  42. package/dist/{protected-model-port-D5gDcnrH.js.map → protected-model-port-Dhdi5mDl.js.map} +1 -1
  43. package/dist/{protected-redaction-wGo44k2K.js → protected-redaction-Fn1ETfJ-.js} +6 -6
  44. package/dist/protected-redaction-Fn1ETfJ-.js.map +1 -0
  45. package/dist/{provision-supervisor-CNdrsjvc.js → provision-supervisor-D0X9KUv-.js} +5 -5
  46. package/dist/{provision-supervisor-CNdrsjvc.js.map → provision-supervisor-D0X9KUv-.js.map} +1 -1
  47. package/dist/{run-layout-hZREkcfu.js → run-layout-B8-Gqhpg.js} +2 -2
  48. package/dist/{run-layout-hZREkcfu.js.map → run-layout-B8-Gqhpg.js.map} +1 -1
  49. package/dist/{runtime-BsPY_v8H.js → runtime-CHbVv5UI.js} +16 -13
  50. package/dist/{runtime-BsPY_v8H.js.map → runtime-CHbVv5UI.js.map} +1 -1
  51. package/dist/{server-b8uEBoK0.js → server-DwsC_FyV.js} +3 -3
  52. package/dist/{server-b8uEBoK0.js.map → server-DwsC_FyV.js.map} +1 -1
  53. package/dist/{stream-agent-turn-xgmm-M55.d.ts → stream-agent-turn-DQ-W8mHf.d.ts} +2 -2
  54. package/dist/{structural-rollout-sy2sH_7-.js → structural-rollout-DasmuuUp.js} +2 -2
  55. package/dist/{structural-rollout-sy2sH_7-.js.map → structural-rollout-DasmuuUp.js.map} +1 -1
  56. package/dist/{substrate-B_9stFWH.d.ts → substrate-DJOnuoa_.d.ts} +2 -2
  57. package/dist/{supervise-CBd3FyCS.js → supervise-o6CzD2Rt.js} +142 -35
  58. package/dist/supervise-o6CzD2Rt.js.map +1 -0
  59. package/dist/{supervisor-De0lytFU.js → supervisor-tGq-TPIv.js} +162 -103
  60. package/dist/supervisor-tGq-TPIv.js.map +1 -0
  61. package/dist/testing.d.ts +2 -2
  62. package/dist/testing.js +398 -398
  63. package/dist/{top-app-CMMd8DgR.js → top-app-DL-sjv7K.js} +2 -2
  64. package/dist/{top-app-CMMd8DgR.js.map → top-app-DL-sjv7K.js.map} +1 -1
  65. package/dist/tui/bin.js +1 -1
  66. package/dist/tui/index.d.ts +1 -1
  67. package/dist/tui/index.js +2 -2
  68. package/dist/{types-CE7ES_TD.d.ts → types-BoEzH8V6.d.ts} +18 -2
  69. package/dist/{workspace-archive-CBX0hwL_.js → workspace-archive-DSRT4Tro.js} +8 -8
  70. package/dist/workspace-archive-DSRT4Tro.js.map +1 -0
  71. package/package.json +6 -6
  72. package/dist/coordination-driver-m-2dzvu6.js.map +0 -1
  73. package/dist/improvement-cycle-BP4rDivU.js.map +0 -1
  74. package/dist/prepare-Dc30WRB0.js.map +0 -1
  75. package/dist/protected-redaction-wGo44k2K.js.map +0 -1
  76. package/dist/supervise-CBd3FyCS.js.map +0 -1
  77. package/dist/supervisor-De0lytFU.js.map +0 -1
  78. package/dist/workspace-archive-CBX0hwL_.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { A as agentImprovementTargetInput, M as agentProfileImprovementStateDigest, c as requireSealedCandidateExperiment, d as verifyAgentImprovementActivation, f as verifyAgentImprovementProposal, k as agentImprovementTargetDigest } from "./improvement-cycle-BP4rDivU.js";
2
- import { o as canonicalCandidateDigest$1, p as verifyCanonicalCandidateDocument, s as canonicalCandidateDocument, u as immutableCandidateValue } from "./protected-redaction-wGo44k2K.js";
1
+ import { A as agentImprovementTargetInput, M as agentProfileImprovementStateDigest, c as requireSealedCandidateExperiment, d as verifyAgentImprovementActivation, f as verifyAgentImprovementProposal, k as agentImprovementTargetDigest } from "./improvement-cycle-BE3gIJwL.js";
2
+ import { o as canonicalCandidateDigest$1, p as verifyCanonicalCandidateDocument, s as canonicalCandidateDocument, u as immutableCandidateValue } from "./protected-redaction-Fn1ETfJ-.js";
3
3
  import { agentImprovementActivationResultSchema, agentImprovementActivationSchema, agentProfileImprovementExperimentSchema } from "@tangle-network/agent-interface";
4
4
  //#region src/intelligence/activation.ts
5
5
  /** Create the exact result a product stores in the same transaction as its target write. */
@@ -201,4 +201,4 @@ function targetIdentity(target) {
201
201
  //#endregion
202
202
  export { executeAgentImprovementActivation as n, verifyAgentImprovementActivationResult as r, createAgentImprovementActivationResult as t };
203
203
 
204
- //# sourceMappingURL=activation-CUhkPtm0.js.map
204
+ //# sourceMappingURL=activation-C6d-NTWk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"activation-CUhkPtm0.js","names":["canonicalCandidateDigest"],"sources":["../src/intelligence/activation.ts"],"sourcesContent":["import type {\n AgentCandidateBundle,\n AgentCandidateExperiment,\n AgentImprovementActivation,\n AgentImprovementActivationOutcome,\n AgentImprovementActivationResult,\n AgentImprovementActivationTarget,\n AgentImprovementProposal,\n AgentImprovementReview,\n AgentImprovementSurface,\n AgentProfileImprovementChange,\n AgentProfileImprovementExperiment,\n Sha256Digest,\n} from '@tangle-network/agent-interface'\nimport {\n agentImprovementActivationResultSchema,\n agentImprovementActivationSchema,\n agentProfileImprovementExperimentSchema,\n} from '@tangle-network/agent-interface'\n\nimport {\n canonicalCandidateDigest,\n canonicalCandidateDocument,\n immutableCandidateValue,\n verifyCanonicalCandidateDocument,\n} from '../candidate-execution/digest'\nimport {\n requireSealedCandidateExperiment,\n verifyAgentImprovementActivation,\n verifyAgentImprovementProposal,\n} from './improvement-cycle'\nimport {\n agentImprovementTargetDigest,\n agentImprovementTargetInput,\n agentProfileImprovementStateDigest,\n} from './improvement-surfaces'\n\nexport interface CreateAgentImprovementActivationResultOptions {\n completedAt: string\n outcome: AgentImprovementActivationOutcome\n}\n\nexport interface AgentImprovementActivationTargetPlan extends AgentImprovementActivationTarget {\n desiredDigest: Sha256Digest\n /**\n * Exact measured input the product must apply to reach `desiredDigest`.\n * Transition surfaces such as code and knowledge are applied operations, so\n * their resulting state digest is not the digest of this input document.\n */\n desiredInput: unknown\n}\n\nexport type AgentProfileImprovementActivationOperation =\n | {\n kind: 'apply-change'\n changes: AgentProfileImprovementChange\n }\n | {\n /** The product must load its own saved state at `desiredStateDigest`. */\n kind: 'restore-state'\n }\n\nexport interface AgentProfileImprovementActivationTargetPlan\n extends AgentImprovementActivationTarget {\n desiredDigest: Sha256Digest\n desiredInput: AgentProfileImprovementActivationOperation\n}\n\nexport interface SealedCandidateActivationTransitionInput {\n kind: 'sealed-candidate'\n activation: AgentImprovementActivation\n candidateBundle: AgentCandidateBundle\n bundle: AgentCandidateBundle\n targets: [AgentImprovementActivationTargetPlan, ...AgentImprovementActivationTargetPlan[]]\n attemptedAt: string\n expired: boolean\n}\n\n/**\n * A measured profile change without raw profile bytes.\n * The product owns the private state lookup and atomic write.\n */\nexport interface ProfileImprovementActivationTransitionInput {\n kind: 'profile-improvement'\n activation: AgentImprovementActivation\n experiment: AgentProfileImprovementExperiment\n sourceStateDigest: Sha256Digest\n desiredStateDigest: Sha256Digest\n operation: AgentProfileImprovementActivationOperation\n targets: [\n AgentProfileImprovementActivationTargetPlan,\n ...AgentProfileImprovementActivationTargetPlan[],\n ]\n attemptedAt: string\n expired: boolean\n}\n\nexport type AgentImprovementActivationTransitionInput =\n | SealedCandidateActivationTransitionInput\n | ProfileImprovementActivationTransitionInput\n\nexport interface AgentImprovementActivationResultStore {\n load(idempotencyKey: Sha256Digest): Promise<unknown | undefined>\n putIfAbsent(result: AgentImprovementActivationResult): Promise<unknown>\n}\n\n/**\n * Product-owned or Runtime-composed transition.\n *\n * Implementations resolve a stored result for `activation.digest`, compare\n * every target, and make the write durably idempotent. Co-located targets store\n * the all-or-none write with its result. Other targets throw when result\n * storage fails so a retry can reconcile it. Runtime never invokes this write\n * function after authorization expires.\n */\nexport type AgentImprovementActivationTransition = (\n input: AgentImprovementActivationTransitionInput,\n) => Promise<unknown>\n\n/**\n * Target-read-only check for a prior exact write.\n * It may persist recovered result metadata, but must not change an activation target.\n * Return undefined only when no target write can have committed.\n */\nexport type AgentImprovementActivationReconciliation = (\n input: AgentImprovementActivationTransitionInput,\n) => Promise<unknown | undefined>\n\nexport interface ExecuteAgentImprovementActivationInput {\n proposal: AgentImprovementProposal\n review: AgentImprovementReview\n activation: AgentImprovementActivation\n}\n\nexport interface ExecuteAgentImprovementActivationOptions {\n transition: AgentImprovementActivationTransition\n reconcile?: AgentImprovementActivationReconciliation\n now?: () => Date\n}\n\n/** Create the exact result a product stores in the same transaction as its target write. */\nexport function createAgentImprovementActivationResult(\n transition: AgentImprovementActivationTransitionInput,\n options: CreateAgentImprovementActivationResultOptions,\n): AgentImprovementActivationResult {\n const activation = verifyCanonicalCandidateDocument(\n agentImprovementActivationSchema.parse(transition.activation),\n 'agent improvement activation',\n )\n assertTransitionInput(activation, transition)\n const result = agentImprovementActivationResultSchema.parse(\n canonicalCandidateDocument<AgentImprovementActivationResult>({\n kind: 'agent-improvement-activation-result',\n idempotencyKey: activation.digest,\n attemptedAt: transition.attemptedAt,\n completedAt: options.completedAt,\n outcome: options.outcome,\n }).value,\n )\n assertResultAgainstActivation(activation, result)\n assertOutcomeDesiredState(\n activation,\n result,\n new Map(transition.targets.map((target) => [targetIdentity(target), target.desiredDigest])),\n )\n return immutableCandidateValue(result)\n}\n\n/**\n * Recompute one historical activation result against the exact measured proposal and authority.\n * The result records that attempt; it is not a query of the target's current state.\n */\nexport function verifyAgentImprovementActivationResult(input: {\n proposal: unknown\n review: unknown\n activation: unknown\n result: unknown\n}): AgentImprovementActivationResult {\n const proposal = verifyAgentImprovementProposal(input.proposal)\n const activation = verifyAgentImprovementActivation(input)\n const result = verifyCanonicalCandidateDocument(\n agentImprovementActivationResultSchema.parse(input.result),\n 'agent improvement activation result',\n )\n assertResultAgainstActivation(activation, result)\n assertResultDesiredState(proposal, activation, result)\n return result\n}\n\n/** Validate and execute one product-owned activation transition. */\nexport async function executeAgentImprovementActivation(\n input: ExecuteAgentImprovementActivationInput,\n options: ExecuteAgentImprovementActivationOptions,\n): Promise<AgentImprovementActivationResult> {\n const proposal = verifyAgentImprovementProposal(input.proposal)\n const activation = verifyAgentImprovementActivation(input)\n const observedAt = (options.now ?? (() => new Date()))().toISOString()\n const attemptedAt =\n Date.parse(observedAt) < Date.parse(activation.authorizedAt)\n ? activation.authorizedAt\n : observedAt\n const expired = Date.parse(attemptedAt) >= Date.parse(activation.expiresAt)\n const transition = immutableCandidateValue<AgentImprovementActivationTransitionInput>(\n proposal.evaluation.kind === 'agent-improvement-measured-comparison'\n ? sealedCandidateTransition(proposal.evaluation.experiment, activation, attemptedAt, expired)\n : profileImprovementTransition(\n proposal.evaluation.experiment,\n activation,\n attemptedAt,\n expired,\n ),\n )\n\n if (transition.expired) {\n if (!options.reconcile) {\n return uncertainActivationResult(transition, 'RECONCILIATION_UNAVAILABLE')\n }\n let reconciled: unknown\n try {\n reconciled = await options.reconcile(transition)\n } catch {\n return uncertainActivationResult(transition, 'RECONCILIATION_THROW')\n }\n if (reconciled === undefined) {\n return createAgentImprovementActivationResult(transition, {\n completedAt: transition.attemptedAt,\n outcome: { status: 'expired' },\n })\n }\n try {\n return verifyAgentImprovementActivationResult({ ...input, result: reconciled })\n } catch {\n return uncertainActivationResult(transition, 'INVALID_RECONCILIATION')\n }\n }\n\n let rawResult: unknown\n try {\n rawResult = await options.transition(transition)\n } catch {\n return uncertainActivationResult(transition, 'TRANSITION_THROW')\n }\n try {\n return verifyAgentImprovementActivationResult({ ...input, result: rawResult })\n } catch {\n return uncertainActivationResult(transition, 'INVALID_RESULT')\n }\n}\n\nfunction sealedCandidateTransition(\n experiment: AgentCandidateExperiment,\n activation: AgentImprovementActivation,\n attemptedAt: string,\n expired: boolean,\n): SealedCandidateActivationTransitionInput {\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n return {\n kind: 'sealed-candidate',\n activation,\n candidateBundle: experiment.candidate,\n bundle: experiment[targetArm],\n targets: activation.targets.map((target) => ({\n ...target,\n desiredDigest: agentImprovementTargetDigest(experiment, targetArm, target.surface),\n desiredInput: agentImprovementTargetInput(experiment[targetArm], target.surface),\n })) as SealedCandidateActivationTransitionInput['targets'],\n attemptedAt,\n expired,\n }\n}\n\nfunction profileImprovementTransition(\n experiment: AgentProfileImprovementExperiment,\n activation: AgentImprovementActivation,\n attemptedAt: string,\n expired: boolean,\n): ProfileImprovementActivationTransitionInput {\n const sourceArm = activation.intent === 'activate-candidate' ? 'baseline' : 'candidate'\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n const operation = profileImprovementOperation(experiment, activation.intent)\n return {\n kind: 'profile-improvement',\n activation,\n experiment,\n sourceStateDigest: agentProfileImprovementStateDigest(experiment, sourceArm),\n desiredStateDigest: agentProfileImprovementStateDigest(experiment, targetArm),\n operation,\n targets: activation.targets.map((target) => ({\n ...target,\n desiredDigest: agentProfileImprovementStateDigest(experiment, targetArm),\n desiredInput: operation,\n })) as ProfileImprovementActivationTransitionInput['targets'],\n attemptedAt,\n expired,\n }\n}\n\nfunction profileImprovementOperation(\n experiment: AgentProfileImprovementExperiment,\n intent: AgentImprovementActivation['intent'],\n): AgentProfileImprovementActivationOperation {\n return intent === 'activate-candidate'\n ? { kind: 'apply-change', changes: experiment.change }\n : { kind: 'restore-state' }\n}\n\nfunction uncertainActivationResult(\n transition: AgentImprovementActivationTransitionInput,\n code: string,\n): AgentImprovementActivationResult {\n return createAgentImprovementActivationResult(transition, {\n completedAt: transition.attemptedAt,\n outcome: {\n status: 'indeterminate',\n code,\n message: 'The product transition did not return a trustworthy commit result.',\n },\n })\n}\n\nfunction assertTransitionInput(\n activation: AgentImprovementActivation,\n transition: AgentImprovementActivationTransitionInput,\n): void {\n if (transition.kind === 'sealed-candidate') {\n assertSealedCandidateTransitionInput(activation, transition)\n return\n }\n assertProfileImprovementTransitionInput(activation, transition)\n}\n\nfunction assertSealedCandidateTransitionInput(\n activation: AgentImprovementActivation,\n transition: SealedCandidateActivationTransitionInput,\n): void {\n assertAuthorizedTransitionTargets(activation, transition.targets)\n const desiredInputsMatch = transition.targets.every(\n (target) =>\n canonicalCandidateDigest(target.desiredInput) ===\n canonicalCandidateDigest(agentImprovementTargetInput(transition.bundle, target.surface)),\n )\n if (\n transition.expired !== Date.parse(transition.attemptedAt) >= Date.parse(activation.expiresAt) ||\n transition.candidateBundle.digest !== activation.candidateDigest ||\n !desiredInputsMatch ||\n (activation.intent === 'activate-candidate' &&\n transition.bundle.digest !== transition.candidateBundle.digest)\n ) {\n throw new Error('activation transition does not match its authorization')\n }\n}\n\nfunction assertProfileImprovementTransitionInput(\n activation: AgentImprovementActivation,\n transition: ProfileImprovementActivationTransitionInput,\n): void {\n assertAuthorizedTransitionTargets(activation, transition.targets)\n const targetsAgentProfile = activation.targets.some(\n (target) => target.surface === 'agent-profile',\n )\n const experiment = agentProfileImprovementExperimentSchema.parse(transition.experiment)\n const sourceArm = activation.intent === 'activate-candidate' ? 'baseline' : 'candidate'\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n const sourceStateDigest = agentProfileImprovementStateDigest(experiment, sourceArm)\n const desiredStateDigest = agentProfileImprovementStateDigest(experiment, targetArm)\n const operation = profileImprovementOperation(experiment, activation.intent)\n const targetsMatch = transition.targets.every(\n (target) =>\n target.expectedBaseDigest === sourceStateDigest &&\n target.desiredDigest === desiredStateDigest &&\n canonicalCandidateDigest(target.desiredInput) === canonicalCandidateDigest(operation),\n )\n if (\n transition.expired !== Date.parse(transition.attemptedAt) >= Date.parse(activation.expiresAt) ||\n experiment.digest !== activation.experimentDigest ||\n experiment.candidate.stateDigest !== activation.candidateDigest ||\n (targetsAgentProfile &&\n (activation.executionRef === undefined ||\n canonicalCandidateDigest(activation.executionRef) !==\n canonicalCandidateDigest(experiment.executionRef))) ||\n transition.sourceStateDigest !== sourceStateDigest ||\n transition.desiredStateDigest !== desiredStateDigest ||\n canonicalCandidateDigest(transition.operation) !== canonicalCandidateDigest(operation) ||\n !targetsMatch\n ) {\n throw new Error('activation transition does not match its authorization')\n }\n}\n\nfunction assertAuthorizedTransitionTargets(\n activation: AgentImprovementActivation,\n targets: readonly AgentImprovementActivationTargetPlan[],\n): void {\n const authorized = targetMap(activation.targets)\n const planned = targetMap(targets)\n if (\n authorized.size !== planned.size ||\n [...authorized.entries()].some(\n ([identity, target]) =>\n planned.get(identity)?.expectedBaseDigest !== target.expectedBaseDigest,\n )\n ) {\n throw new Error('activation transition does not match its authorization')\n }\n}\n\nfunction assertResultAgainstActivation(\n activation: AgentImprovementActivation,\n result: AgentImprovementActivationResult,\n): void {\n const attemptedAt = Date.parse(result.attemptedAt)\n const completedAt = Date.parse(result.completedAt)\n const expiresAt = Date.parse(activation.expiresAt)\n if (\n result.idempotencyKey !== activation.digest ||\n attemptedAt < Date.parse(activation.authorizedAt) ||\n completedAt < attemptedAt\n ) {\n throw new Error('activation result does not bind its authorization')\n }\n const expired = attemptedAt >= expiresAt\n if (\n (result.outcome.status === 'expired' && !expired) ||\n (expired && !['expired', 'indeterminate', 'already-applied'].includes(result.outcome.status))\n ) {\n throw new Error('activation result does not honor its authorization expiry')\n }\n if (!('targets' in result.outcome)) return\n const authorized = targetMap(activation.targets)\n const observed = new Set(result.outcome.targets.map(targetIdentity))\n if (\n authorized.size !== observed.size ||\n [...authorized.keys()].some((identity) => !observed.has(identity))\n ) {\n throw new Error('activation result must cover every authorized target exactly once')\n }\n if (\n result.outcome.status === 'applied' &&\n result.outcome.targets.some(\n (target) =>\n target.beforeDigest !== authorized.get(targetIdentity(target))?.expectedBaseDigest,\n )\n ) {\n throw new Error('applied activation did not start from its authorized base state')\n }\n}\n\nfunction assertResultDesiredState(\n proposal: AgentImprovementProposal,\n activation: AgentImprovementActivation,\n result: AgentImprovementActivationResult,\n): void {\n if (!('targets' in result.outcome)) return\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n const desiredStateDigest =\n proposal.evaluation.kind === 'agent-profile-improvement-measured-comparison'\n ? agentProfileImprovementStateDigest(proposal.evaluation.experiment, targetArm)\n : undefined\n const desired = new Map(\n activation.targets.map((target) => [\n targetIdentity(target),\n desiredStateDigest ??\n agentImprovementTargetDigest(\n requireSealedCandidateExperiment(proposal),\n targetArm,\n target.surface,\n ),\n ]),\n )\n assertOutcomeDesiredState(activation, result, desired)\n}\n\nfunction assertOutcomeDesiredState(\n activation: AgentImprovementActivation,\n result: AgentImprovementActivationResult,\n desired: ReadonlyMap<string, Sha256Digest>,\n): void {\n if (!('targets' in result.outcome)) return\n if (result.outcome.status === 'applied') {\n if (\n result.outcome.targets.some(\n (target) => target.afterDigest !== desired.get(targetIdentity(target)),\n )\n ) {\n throw new Error('applied activation does not match the requested bundle')\n }\n return\n }\n const allDesired = result.outcome.targets.every(\n (target) => target.currentDigest === desired.get(targetIdentity(target)),\n )\n if (result.outcome.status === 'already-applied') {\n if (!allDesired) throw new Error('already-applied activation is not at the requested state')\n return\n }\n const authorized = targetMap(activation.targets)\n const hasStaleTarget = result.outcome.targets.some(\n (target) => target.currentDigest !== authorized.get(targetIdentity(target))?.expectedBaseDigest,\n )\n if (allDesired || !hasStaleTarget) {\n throw new Error('activation conflict does not identify stale target state')\n }\n}\n\nfunction targetMap<T extends { surface: AgentImprovementSurface; identity: string }>(\n targets: readonly T[],\n): Map<string, T> {\n return new Map(targets.map((target) => [targetIdentity(target), target]))\n}\n\nfunction targetIdentity(target: { surface: AgentImprovementSurface; identity: string }): string {\n return `${target.surface}\\u0000${target.identity}`\n}\n"],"mappings":";;;;;AA6IA,SAAgB,uCACd,YACA,SACkC;CAClC,MAAM,aAAa,iCACjB,iCAAiC,MAAM,WAAW,UAAU,GAC5D,8BACF;CACA,sBAAsB,YAAY,UAAU;CAC5C,MAAM,SAAS,uCAAuC,MACpD,2BAA6D;EAC3D,MAAM;EACN,gBAAgB,WAAW;EAC3B,aAAa,WAAW;EACxB,aAAa,QAAQ;EACrB,SAAS,QAAQ;CACnB,CAAC,CAAC,CAAC,KACL;CACA,8BAA8B,YAAY,MAAM;CAChD,0BACE,YACA,QACA,IAAI,IAAI,WAAW,QAAQ,KAAK,WAAW,CAAC,eAAe,MAAM,GAAG,OAAO,aAAa,CAAC,CAAC,CAC5F;CACA,OAAO,wBAAwB,MAAM;AACvC;;;;;AAMA,SAAgB,uCAAuC,OAKlB;CACnC,MAAM,WAAW,+BAA+B,MAAM,QAAQ;CAC9D,MAAM,aAAa,iCAAiC,KAAK;CACzD,MAAM,SAAS,iCACb,uCAAuC,MAAM,MAAM,MAAM,GACzD,qCACF;CACA,8BAA8B,YAAY,MAAM;CAChD,yBAAyB,UAAU,YAAY,MAAM;CACrD,OAAO;AACT;;AAGA,eAAsB,kCACpB,OACA,SAC2C;CAC3C,MAAM,WAAW,+BAA+B,MAAM,QAAQ;CAC9D,MAAM,aAAa,iCAAiC,KAAK;CACzD,MAAM,cAAc,QAAQ,8BAAc,IAAI,KAAK,GAAA,CAAI,CAAC,CAAC,YAAY;CACrE,MAAM,cACJ,KAAK,MAAM,UAAU,IAAI,KAAK,MAAM,WAAW,YAAY,IACvD,WAAW,eACX;CACN,MAAM,UAAU,KAAK,MAAM,WAAW,KAAK,KAAK,MAAM,WAAW,SAAS;CAC1E,MAAM,aAAa,wBACjB,SAAS,WAAW,SAAS,0CACzB,0BAA0B,SAAS,WAAW,YAAY,YAAY,aAAa,OAAO,IAC1F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vE,GAEA,MAAM,IAAI,MAAM,wDAAwD;EAE1E;CACF;CACA,MAAM,aAAa,OAAO,QAAQ,QAAQ,OACvC,WAAW,OAAO,kBAAkB,QAAQ,IAAI,eAAe,MAAM,CAAC,CACzE;CACA,IAAI,OAAO,QAAQ,WAAW,mBAAmB;EAC/C,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,0DAA0D;EAC3F;CACF;CACA,MAAM,aAAa,UAAU,WAAW,OAAO;CAC/C,MAAM,iBAAiB,OAAO,QAAQ,QAAQ,MAC3C,WAAW,OAAO,kBAAkB,WAAW,IAAI,eAAe,MAAM,CAAC,CAAC,EAAE,kBAC/E;CACA,IAAI,cAAc,CAAC,gBACjB,MAAM,IAAI,MAAM,0DAA0D;AAE9E;AAEA,SAAS,UACP,SACgB;CAChB,OAAO,IAAI,IAAI,QAAQ,KAAK,WAAW,CAAC,eAAe,MAAM,GAAG,MAAM,CAAC,CAAC;AAC1E;AAEA,SAAS,eAAe,QAAwE;CAC9F,OAAO,GAAG,OAAO,QAAQ,QAAQ,OAAO;AAC1C"}
1
+ {"version":3,"file":"activation-C6d-NTWk.js","names":["canonicalCandidateDigest"],"sources":["../src/intelligence/activation.ts"],"sourcesContent":["import type {\n AgentCandidateBundle,\n AgentCandidateExperiment,\n AgentImprovementActivation,\n AgentImprovementActivationOutcome,\n AgentImprovementActivationResult,\n AgentImprovementActivationTarget,\n AgentImprovementProposal,\n AgentImprovementReview,\n AgentImprovementSurface,\n AgentProfileImprovementChange,\n AgentProfileImprovementExperiment,\n Sha256Digest,\n} from '@tangle-network/agent-interface'\nimport {\n agentImprovementActivationResultSchema,\n agentImprovementActivationSchema,\n agentProfileImprovementExperimentSchema,\n} from '@tangle-network/agent-interface'\n\nimport {\n canonicalCandidateDigest,\n canonicalCandidateDocument,\n immutableCandidateValue,\n verifyCanonicalCandidateDocument,\n} from '../candidate-execution/digest'\nimport {\n requireSealedCandidateExperiment,\n verifyAgentImprovementActivation,\n verifyAgentImprovementProposal,\n} from './improvement-cycle'\nimport {\n agentImprovementTargetDigest,\n agentImprovementTargetInput,\n agentProfileImprovementStateDigest,\n} from './improvement-surfaces'\n\nexport interface CreateAgentImprovementActivationResultOptions {\n completedAt: string\n outcome: AgentImprovementActivationOutcome\n}\n\nexport interface AgentImprovementActivationTargetPlan extends AgentImprovementActivationTarget {\n desiredDigest: Sha256Digest\n /**\n * Exact measured input the product must apply to reach `desiredDigest`.\n * Transition surfaces such as code and knowledge are applied operations, so\n * their resulting state digest is not the digest of this input document.\n */\n desiredInput: unknown\n}\n\nexport type AgentProfileImprovementActivationOperation =\n | {\n kind: 'apply-change'\n changes: AgentProfileImprovementChange\n }\n | {\n /** The product must load its own saved state at `desiredStateDigest`. */\n kind: 'restore-state'\n }\n\nexport interface AgentProfileImprovementActivationTargetPlan\n extends AgentImprovementActivationTarget {\n desiredDigest: Sha256Digest\n desiredInput: AgentProfileImprovementActivationOperation\n}\n\nexport interface SealedCandidateActivationTransitionInput {\n kind: 'sealed-candidate'\n activation: AgentImprovementActivation\n candidateBundle: AgentCandidateBundle\n bundle: AgentCandidateBundle\n targets: [AgentImprovementActivationTargetPlan, ...AgentImprovementActivationTargetPlan[]]\n attemptedAt: string\n expired: boolean\n}\n\n/**\n * A measured profile change without raw profile bytes.\n * The product owns the private state lookup and atomic write.\n */\nexport interface ProfileImprovementActivationTransitionInput {\n kind: 'profile-improvement'\n activation: AgentImprovementActivation\n experiment: AgentProfileImprovementExperiment\n sourceStateDigest: Sha256Digest\n desiredStateDigest: Sha256Digest\n operation: AgentProfileImprovementActivationOperation\n targets: [\n AgentProfileImprovementActivationTargetPlan,\n ...AgentProfileImprovementActivationTargetPlan[],\n ]\n attemptedAt: string\n expired: boolean\n}\n\nexport type AgentImprovementActivationTransitionInput =\n | SealedCandidateActivationTransitionInput\n | ProfileImprovementActivationTransitionInput\n\nexport interface AgentImprovementActivationResultStore {\n load(idempotencyKey: Sha256Digest): Promise<unknown | undefined>\n putIfAbsent(result: AgentImprovementActivationResult): Promise<unknown>\n}\n\n/**\n * Product-owned or Runtime-composed transition.\n *\n * Implementations resolve a stored result for `activation.digest`, compare\n * every target, and make the write durably idempotent. Co-located targets store\n * the all-or-none write with its result. Other targets throw when result\n * storage fails so a retry can reconcile it. Runtime never invokes this write\n * function after authorization expires.\n */\nexport type AgentImprovementActivationTransition = (\n input: AgentImprovementActivationTransitionInput,\n) => Promise<unknown>\n\n/**\n * Target-read-only check for a prior exact write.\n * It may persist recovered result metadata, but must not change an activation target.\n * Return undefined only when no target write can have committed.\n */\nexport type AgentImprovementActivationReconciliation = (\n input: AgentImprovementActivationTransitionInput,\n) => Promise<unknown | undefined>\n\nexport interface ExecuteAgentImprovementActivationInput {\n proposal: AgentImprovementProposal\n review: AgentImprovementReview\n activation: AgentImprovementActivation\n}\n\nexport interface ExecuteAgentImprovementActivationOptions {\n transition: AgentImprovementActivationTransition\n reconcile?: AgentImprovementActivationReconciliation\n now?: () => Date\n}\n\n/** Create the exact result a product stores in the same transaction as its target write. */\nexport function createAgentImprovementActivationResult(\n transition: AgentImprovementActivationTransitionInput,\n options: CreateAgentImprovementActivationResultOptions,\n): AgentImprovementActivationResult {\n const activation = verifyCanonicalCandidateDocument(\n agentImprovementActivationSchema.parse(transition.activation),\n 'agent improvement activation',\n )\n assertTransitionInput(activation, transition)\n const result = agentImprovementActivationResultSchema.parse(\n canonicalCandidateDocument<AgentImprovementActivationResult>({\n kind: 'agent-improvement-activation-result',\n idempotencyKey: activation.digest,\n attemptedAt: transition.attemptedAt,\n completedAt: options.completedAt,\n outcome: options.outcome,\n }).value,\n )\n assertResultAgainstActivation(activation, result)\n assertOutcomeDesiredState(\n activation,\n result,\n new Map(transition.targets.map((target) => [targetIdentity(target), target.desiredDigest])),\n )\n return immutableCandidateValue(result)\n}\n\n/**\n * Recompute one historical activation result against the exact measured proposal and authority.\n * The result records that attempt; it is not a query of the target's current state.\n */\nexport function verifyAgentImprovementActivationResult(input: {\n proposal: unknown\n review: unknown\n activation: unknown\n result: unknown\n}): AgentImprovementActivationResult {\n const proposal = verifyAgentImprovementProposal(input.proposal)\n const activation = verifyAgentImprovementActivation(input)\n const result = verifyCanonicalCandidateDocument(\n agentImprovementActivationResultSchema.parse(input.result),\n 'agent improvement activation result',\n )\n assertResultAgainstActivation(activation, result)\n assertResultDesiredState(proposal, activation, result)\n return result\n}\n\n/** Validate and execute one product-owned activation transition. */\nexport async function executeAgentImprovementActivation(\n input: ExecuteAgentImprovementActivationInput,\n options: ExecuteAgentImprovementActivationOptions,\n): Promise<AgentImprovementActivationResult> {\n const proposal = verifyAgentImprovementProposal(input.proposal)\n const activation = verifyAgentImprovementActivation(input)\n const observedAt = (options.now ?? (() => new Date()))().toISOString()\n const attemptedAt =\n Date.parse(observedAt) < Date.parse(activation.authorizedAt)\n ? activation.authorizedAt\n : observedAt\n const expired = Date.parse(attemptedAt) >= Date.parse(activation.expiresAt)\n const transition = immutableCandidateValue<AgentImprovementActivationTransitionInput>(\n proposal.evaluation.kind === 'agent-improvement-measured-comparison'\n ? sealedCandidateTransition(proposal.evaluation.experiment, activation, attemptedAt, expired)\n : profileImprovementTransition(\n proposal.evaluation.experiment,\n activation,\n attemptedAt,\n expired,\n ),\n )\n\n if (transition.expired) {\n if (!options.reconcile) {\n return uncertainActivationResult(transition, 'RECONCILIATION_UNAVAILABLE')\n }\n let reconciled: unknown\n try {\n reconciled = await options.reconcile(transition)\n } catch {\n return uncertainActivationResult(transition, 'RECONCILIATION_THROW')\n }\n if (reconciled === undefined) {\n return createAgentImprovementActivationResult(transition, {\n completedAt: transition.attemptedAt,\n outcome: { status: 'expired' },\n })\n }\n try {\n return verifyAgentImprovementActivationResult({ ...input, result: reconciled })\n } catch {\n return uncertainActivationResult(transition, 'INVALID_RECONCILIATION')\n }\n }\n\n let rawResult: unknown\n try {\n rawResult = await options.transition(transition)\n } catch {\n return uncertainActivationResult(transition, 'TRANSITION_THROW')\n }\n try {\n return verifyAgentImprovementActivationResult({ ...input, result: rawResult })\n } catch {\n return uncertainActivationResult(transition, 'INVALID_RESULT')\n }\n}\n\nfunction sealedCandidateTransition(\n experiment: AgentCandidateExperiment,\n activation: AgentImprovementActivation,\n attemptedAt: string,\n expired: boolean,\n): SealedCandidateActivationTransitionInput {\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n return {\n kind: 'sealed-candidate',\n activation,\n candidateBundle: experiment.candidate,\n bundle: experiment[targetArm],\n targets: activation.targets.map((target) => ({\n ...target,\n desiredDigest: agentImprovementTargetDigest(experiment, targetArm, target.surface),\n desiredInput: agentImprovementTargetInput(experiment[targetArm], target.surface),\n })) as SealedCandidateActivationTransitionInput['targets'],\n attemptedAt,\n expired,\n }\n}\n\nfunction profileImprovementTransition(\n experiment: AgentProfileImprovementExperiment,\n activation: AgentImprovementActivation,\n attemptedAt: string,\n expired: boolean,\n): ProfileImprovementActivationTransitionInput {\n const sourceArm = activation.intent === 'activate-candidate' ? 'baseline' : 'candidate'\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n const operation = profileImprovementOperation(experiment, activation.intent)\n return {\n kind: 'profile-improvement',\n activation,\n experiment,\n sourceStateDigest: agentProfileImprovementStateDigest(experiment, sourceArm),\n desiredStateDigest: agentProfileImprovementStateDigest(experiment, targetArm),\n operation,\n targets: activation.targets.map((target) => ({\n ...target,\n desiredDigest: agentProfileImprovementStateDigest(experiment, targetArm),\n desiredInput: operation,\n })) as ProfileImprovementActivationTransitionInput['targets'],\n attemptedAt,\n expired,\n }\n}\n\nfunction profileImprovementOperation(\n experiment: AgentProfileImprovementExperiment,\n intent: AgentImprovementActivation['intent'],\n): AgentProfileImprovementActivationOperation {\n return intent === 'activate-candidate'\n ? { kind: 'apply-change', changes: experiment.change }\n : { kind: 'restore-state' }\n}\n\nfunction uncertainActivationResult(\n transition: AgentImprovementActivationTransitionInput,\n code: string,\n): AgentImprovementActivationResult {\n return createAgentImprovementActivationResult(transition, {\n completedAt: transition.attemptedAt,\n outcome: {\n status: 'indeterminate',\n code,\n message: 'The product transition did not return a trustworthy commit result.',\n },\n })\n}\n\nfunction assertTransitionInput(\n activation: AgentImprovementActivation,\n transition: AgentImprovementActivationTransitionInput,\n): void {\n if (transition.kind === 'sealed-candidate') {\n assertSealedCandidateTransitionInput(activation, transition)\n return\n }\n assertProfileImprovementTransitionInput(activation, transition)\n}\n\nfunction assertSealedCandidateTransitionInput(\n activation: AgentImprovementActivation,\n transition: SealedCandidateActivationTransitionInput,\n): void {\n assertAuthorizedTransitionTargets(activation, transition.targets)\n const desiredInputsMatch = transition.targets.every(\n (target) =>\n canonicalCandidateDigest(target.desiredInput) ===\n canonicalCandidateDigest(agentImprovementTargetInput(transition.bundle, target.surface)),\n )\n if (\n transition.expired !== Date.parse(transition.attemptedAt) >= Date.parse(activation.expiresAt) ||\n transition.candidateBundle.digest !== activation.candidateDigest ||\n !desiredInputsMatch ||\n (activation.intent === 'activate-candidate' &&\n transition.bundle.digest !== transition.candidateBundle.digest)\n ) {\n throw new Error('activation transition does not match its authorization')\n }\n}\n\nfunction assertProfileImprovementTransitionInput(\n activation: AgentImprovementActivation,\n transition: ProfileImprovementActivationTransitionInput,\n): void {\n assertAuthorizedTransitionTargets(activation, transition.targets)\n const targetsAgentProfile = activation.targets.some(\n (target) => target.surface === 'agent-profile',\n )\n const experiment = agentProfileImprovementExperimentSchema.parse(transition.experiment)\n const sourceArm = activation.intent === 'activate-candidate' ? 'baseline' : 'candidate'\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n const sourceStateDigest = agentProfileImprovementStateDigest(experiment, sourceArm)\n const desiredStateDigest = agentProfileImprovementStateDigest(experiment, targetArm)\n const operation = profileImprovementOperation(experiment, activation.intent)\n const targetsMatch = transition.targets.every(\n (target) =>\n target.expectedBaseDigest === sourceStateDigest &&\n target.desiredDigest === desiredStateDigest &&\n canonicalCandidateDigest(target.desiredInput) === canonicalCandidateDigest(operation),\n )\n if (\n transition.expired !== Date.parse(transition.attemptedAt) >= Date.parse(activation.expiresAt) ||\n experiment.digest !== activation.experimentDigest ||\n experiment.candidate.stateDigest !== activation.candidateDigest ||\n (targetsAgentProfile &&\n (activation.executionRef === undefined ||\n canonicalCandidateDigest(activation.executionRef) !==\n canonicalCandidateDigest(experiment.executionRef))) ||\n transition.sourceStateDigest !== sourceStateDigest ||\n transition.desiredStateDigest !== desiredStateDigest ||\n canonicalCandidateDigest(transition.operation) !== canonicalCandidateDigest(operation) ||\n !targetsMatch\n ) {\n throw new Error('activation transition does not match its authorization')\n }\n}\n\nfunction assertAuthorizedTransitionTargets(\n activation: AgentImprovementActivation,\n targets: readonly AgentImprovementActivationTargetPlan[],\n): void {\n const authorized = targetMap(activation.targets)\n const planned = targetMap(targets)\n if (\n authorized.size !== planned.size ||\n [...authorized.entries()].some(\n ([identity, target]) =>\n planned.get(identity)?.expectedBaseDigest !== target.expectedBaseDigest,\n )\n ) {\n throw new Error('activation transition does not match its authorization')\n }\n}\n\nfunction assertResultAgainstActivation(\n activation: AgentImprovementActivation,\n result: AgentImprovementActivationResult,\n): void {\n const attemptedAt = Date.parse(result.attemptedAt)\n const completedAt = Date.parse(result.completedAt)\n const expiresAt = Date.parse(activation.expiresAt)\n if (\n result.idempotencyKey !== activation.digest ||\n attemptedAt < Date.parse(activation.authorizedAt) ||\n completedAt < attemptedAt\n ) {\n throw new Error('activation result does not bind its authorization')\n }\n const expired = attemptedAt >= expiresAt\n if (\n (result.outcome.status === 'expired' && !expired) ||\n (expired && !['expired', 'indeterminate', 'already-applied'].includes(result.outcome.status))\n ) {\n throw new Error('activation result does not honor its authorization expiry')\n }\n if (!('targets' in result.outcome)) return\n const authorized = targetMap(activation.targets)\n const observed = new Set(result.outcome.targets.map(targetIdentity))\n if (\n authorized.size !== observed.size ||\n [...authorized.keys()].some((identity) => !observed.has(identity))\n ) {\n throw new Error('activation result must cover every authorized target exactly once')\n }\n if (\n result.outcome.status === 'applied' &&\n result.outcome.targets.some(\n (target) =>\n target.beforeDigest !== authorized.get(targetIdentity(target))?.expectedBaseDigest,\n )\n ) {\n throw new Error('applied activation did not start from its authorized base state')\n }\n}\n\nfunction assertResultDesiredState(\n proposal: AgentImprovementProposal,\n activation: AgentImprovementActivation,\n result: AgentImprovementActivationResult,\n): void {\n if (!('targets' in result.outcome)) return\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n const desiredStateDigest =\n proposal.evaluation.kind === 'agent-profile-improvement-measured-comparison'\n ? agentProfileImprovementStateDigest(proposal.evaluation.experiment, targetArm)\n : undefined\n const desired = new Map(\n activation.targets.map((target) => [\n targetIdentity(target),\n desiredStateDigest ??\n agentImprovementTargetDigest(\n requireSealedCandidateExperiment(proposal),\n targetArm,\n target.surface,\n ),\n ]),\n )\n assertOutcomeDesiredState(activation, result, desired)\n}\n\nfunction assertOutcomeDesiredState(\n activation: AgentImprovementActivation,\n result: AgentImprovementActivationResult,\n desired: ReadonlyMap<string, Sha256Digest>,\n): void {\n if (!('targets' in result.outcome)) return\n if (result.outcome.status === 'applied') {\n if (\n result.outcome.targets.some(\n (target) => target.afterDigest !== desired.get(targetIdentity(target)),\n )\n ) {\n throw new Error('applied activation does not match the requested bundle')\n }\n return\n }\n const allDesired = result.outcome.targets.every(\n (target) => target.currentDigest === desired.get(targetIdentity(target)),\n )\n if (result.outcome.status === 'already-applied') {\n if (!allDesired) throw new Error('already-applied activation is not at the requested state')\n return\n }\n const authorized = targetMap(activation.targets)\n const hasStaleTarget = result.outcome.targets.some(\n (target) => target.currentDigest !== authorized.get(targetIdentity(target))?.expectedBaseDigest,\n )\n if (allDesired || !hasStaleTarget) {\n throw new Error('activation conflict does not identify stale target state')\n }\n}\n\nfunction targetMap<T extends { surface: AgentImprovementSurface; identity: string }>(\n targets: readonly T[],\n): Map<string, T> {\n return new Map(targets.map((target) => [targetIdentity(target), target]))\n}\n\nfunction targetIdentity(target: { surface: AgentImprovementSurface; identity: string }): string {\n return `${target.surface}\\u0000${target.identity}`\n}\n"],"mappings":";;;;;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O,kBAAkB,QAAQ,IAAI,eAAe,MAAM,CAAC,CACzE;CACA,IAAI,OAAO,QAAQ,WAAW,mBAAmB;EAC/C,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,0DAA0D;EAC3F;CACF;CACA,MAAM,aAAa,UAAU,WAAW,OAAO;CAC/C,MAAM,iBAAiB,OAAO,QAAQ,QAAQ,MAC3C,WAAW,OAAO,kBAAkB,WAAW,IAAI,eAAe,MAAM,CAAC,CAAC,EAAE,kBAC/E;CACA,IAAI,cAAc,CAAC,gBACjB,MAAM,IAAI,MAAM,0DAA0D;AAE9E;AAEA,SAAS,UACP,SACgB;CAChB,OAAO,IAAI,IAAI,QAAQ,KAAK,WAAW,CAAC,eAAe,MAAM,GAAG,MAAM,CAAC,CAAC;AAC1E;AAEA,SAAS,eAAe,QAAwE;CAC9F,OAAO,GAAG,OAAO,QAAQ,QAAQ,OAAO;AAC1C"}
@@ -1,5 +1,5 @@
1
- import { f as ExecutorConfig, i as CollectedAgentTurn, r as AgentTurnUsage } from "./stream-agent-turn-xgmm-M55.js";
2
- import { AgentCandidateBundle, AgentImprovementActivation, AgentImprovementActivationOutcome, AgentImprovementActivationResult, AgentImprovementActivationTarget, AgentImprovementProposal, AgentImprovementReview, AgentImprovementSurface, AgentProfile, AgentProfileDiff, AgentProfileImprovementChange, AgentProfileImprovementExperiment, HarnessType, ReasoningEffort, Sha256Digest } from "@tangle-network/agent-interface";
1
+ import { f as ExecutorConfig, i as CollectedAgentTurn, r as AgentTurnUsage } from "./stream-agent-turn-DQ-W8mHf.js";
2
+ import { AgentCandidateBundle, AgentImprovementActivation, AgentImprovementActivationOutcome, AgentImprovementActivationResult, AgentImprovementActivationTarget, AgentImprovementProposal, AgentImprovementReview, AgentImprovementSurface, AgentProfile, AgentProfileDiff, AgentProfileImprovementChange, AgentProfileImprovementExperiment, AgentTrainingReceipt, AgentTrainingTask, HarnessType, ReasoningEffort, Sha256Digest } from "@tangle-network/agent-interface";
3
3
  import { CostLedgerHandle, MaximumCharge, ProposalFinding } from "@tangle-network/agent-eval";
4
4
  import { CampaignScenarioIdentity, CompareOptimizationMethodsOptions, OptimizationMethod, OptimizationMethodComparison, WorktreeAdapter } from "@tangle-network/agent-eval/campaign";
5
5
  import { MutableSurface, Scenario as Scenario$1, SelfImproveBudget, SelfImproveOptions, SelfImproveProposerResult } from "@tangle-network/agent-eval/contract";
@@ -251,6 +251,7 @@ interface ImproveCandidateValidationInput {
251
251
  value: unknown;
252
252
  isBaseline: boolean;
253
253
  }
254
+ /** Accept by returning void synchronously; reject by throwing. Async callbacks are refused. */
254
255
  type ImproveCandidateValidator = (input: ImproveCandidateValidationInput) => void;
255
256
  type ImproveOptimizationRunOptions<TScenario extends Scenario$1, TArtifact> = Omit<NonNullable<CompareOptimizationMethodsOptions<TScenario, TArtifact>['optimizationRunOptions']>, 'dispatchRef'>;
256
257
  /** Complete-method configuration for every non-code profile surface. */
@@ -552,11 +553,120 @@ interface ImproveCodeResult<TScenario extends Scenario$1, TArtifact> extends Imp
552
553
  }
553
554
  type ImproveResult<TScenario extends Scenario$1, TArtifact> = ImproveMethodResult | ImproveCodeResult<TScenario, TArtifact>;
554
555
  //#endregion
556
+ //#region src/improvement/training.d.ts
557
+ interface TrainingDatasetDocument {
558
+ version: 1;
559
+ format: 'sft' | 'dpo' | 'grpo';
560
+ /** Existing Eval export rows, without rewriting their payloads. Include every exposed partition. */
561
+ rows: Array<{
562
+ task: AgentTrainingTask;
563
+ partition: 'train' | 'validation';
564
+ data: unknown;
565
+ }>;
566
+ }
567
+ interface ProfileTrainerRequest {
568
+ version: 1;
569
+ invocationId: string;
570
+ datasetPath: string;
571
+ checkpointPath: string;
572
+ parentProfilePath: string;
573
+ parentProfileDigest: Sha256Digest;
574
+ parameters: AgentTrainingReceipt['trainer']['parameters'];
575
+ executionRef: Sha256Digest;
576
+ }
577
+ type TrainingBoundaryResult<T> = {
578
+ succeeded: true;
579
+ value: T;
580
+ } | {
581
+ succeeded: false;
582
+ reason: string;
583
+ };
584
+ /** Managed adapters use this same port: cancel the job on abort and download one exact checkpoint file. */
585
+ interface ProfileTrainer {
586
+ identity: Omit<AgentTrainingReceipt['trainer'], 'parameters'>;
587
+ execute(request: Readonly<ProfileTrainerRequest>, signal: AbortSignal): Promise<TrainingBoundaryResult<void>>;
588
+ }
589
+ interface CheckpointServingPort {
590
+ /** Verify the immutable Router route independently of the trainer's output. */
591
+ serve(input: {
592
+ artifactPath: string;
593
+ artifactDigest: Sha256Digest;
594
+ artifactBytes: number;
595
+ routerModelId: string;
596
+ signal: AbortSignal;
597
+ }): Promise<TrainingBoundaryResult<{
598
+ routerModelId: string;
599
+ artifactDigest: Sha256Digest;
600
+ evidenceDigest: Sha256Digest;
601
+ }>>;
602
+ }
603
+ interface ImproveTrainingOptions {
604
+ mode: 'training';
605
+ trainer: ProfileTrainer;
606
+ dataset: {
607
+ path: string;
608
+ digest: Sha256Digest;
609
+ };
610
+ parameters: AgentTrainingReceipt['trainer']['parameters'];
611
+ /** Pins trainer, serving adapter and their private dependencies, just like the bound profile harness. */
612
+ executionRef: Sha256Digest;
613
+ serving: CheckpointServingPort;
614
+ outputDirectory: string;
615
+ /** Optional overall deadline. Omit to rely on caller cancellation; long durations are supported. */
616
+ timeoutMs?: number;
617
+ maxCheckpointBytes: number;
618
+ signal?: AbortSignal;
619
+ validateCandidate?: ImproveCandidateValidator;
620
+ }
621
+ type ImproveTrainingResult = {
622
+ mode: 'training';
623
+ succeeded: true;
624
+ profile: ReadonlyAgentProfile;
625
+ profileDigest: Sha256Digest;
626
+ receipt: AgentTrainingReceipt;
627
+ artifactPath: string;
628
+ receiptPath: string;
629
+ profilePath: string;
630
+ } | {
631
+ mode: 'training';
632
+ succeeded: false;
633
+ stage: 'admission' | 'dataset' | 'training' | 'checkpoint' | 'serving' | 'profile' | 'persistence';
634
+ reason: string;
635
+ /** Partial artifacts are retained for diagnosis; they are not a runnable profile. */
636
+ outputDirectory?: string;
637
+ /** A serving request began; an interrupted adapter may still own a deployment. */
638
+ servingMayExist: boolean;
639
+ /** A timed-out managed adapter may still own a remote training job. */
640
+ trainingMayExist: boolean;
641
+ cleanupError?: string;
642
+ };
643
+ interface ControlledTrainingCommand {
644
+ id: string;
645
+ executable: {
646
+ path: string;
647
+ digest: Sha256Digest;
648
+ };
649
+ args: string[];
650
+ /** Script/config files used by the command, verified before and after execution. */
651
+ inputs: Array<{
652
+ path: string;
653
+ digest: Sha256Digest;
654
+ }>;
655
+ /** Explicit public environment only. Ambient credentials are never inherited. */
656
+ environment: Record<string, string>;
657
+ /** Total stdout + stderr byte budget. Output is drained, not retained in memory. */
658
+ maxOutputBytes: number;
659
+ }
660
+ /** Execute one pinned command without a shell, in the runtime-owned job directory. POSIX only. */
661
+ declare function createCommandProfileTrainer(input: ControlledTrainingCommand): ProfileTrainer;
662
+ //#endregion
555
663
  //#region src/improvement/improve.d.ts
664
+ /** Train and serve a checkpoint without implying that it improved held-out quality. */
665
+ declare function improve(profile: ReadonlyAgentProfile, opts: ImproveTrainingOptions): Promise<ImproveTrainingResult>;
556
666
  /**
557
667
  * Optimize one exact profile surface with a complete method.
558
668
  */
559
- declare function improve<TScenario extends Scenario$1, TArtifact>(profile: AgentProfile, opts: ImproveMethodOptions<TScenario, TArtifact>): Promise<ImproveMethodResult>;
669
+ declare function improve<TScenario extends Scenario$1, TArtifact>(profile: ReadonlyAgentProfile, opts: ImproveMethodOptions<TScenario, TArtifact>): Promise<ImproveMethodResult>;
560
670
  /**
561
671
  * Optimize repository code through Runtime's isolated worktree path.
562
672
  */
@@ -657,5 +767,5 @@ declare function verifyAgentImprovementActivationResult(input: {
657
767
  /** Validate and execute one product-owned activation transition. */
658
768
  declare function executeAgentImprovementActivation(input: ExecuteAgentImprovementActivationInput, options: ExecuteAgentImprovementActivationOptions): Promise<AgentImprovementActivationResult>;
659
769
  //#endregion
660
- export { ImprovementProfilePopulationLineageNode as $, ImproveMethodResult as A, ImproveSkillsOptions as B, ImproveCost as C, ImproveMethodFactory as D, ImproveMethodContext as E, ImproveProfileComponents as F, ImprovementProfileCandidate as G, ImprovementCandidate as H, ImproveProfileSurface as I, ImprovementProfileCandidatePopulationUnavailable as J, ImprovementProfileCandidatePopulation as K, ImproveResult as L, ImproveOptimizationRunOptions as M, ImproveOptions as N, ImproveMethodLineage as O, ImproveProfileAgent as P, ImprovementProfilePopulationLineage as Q, ImproveRuntimeCodeGeneratorOptions as R, ImproveCodeRunOptions as S, ImproveLineage as T, ImprovementCodeCandidate as U, ImproveSurface as V, ImprovementMaterializedProfilePopulationCandidate as W, ImprovementProfilePopulationCandidate as X, ImprovementProfilePopulationArtifactSource as Y, ImprovementProfilePopulationCandidateSource as Z, ImproveCandidateValidationInput as _, AgentImprovementActivationTransitionInput as a, AgenticGeneratorOptions as at, ImproveCodeOptions as b, CreateAgentImprovementActivationResultOptions as c, AgenticGeneratorShotReceipt as ct, ProfileImprovementActivationTransitionInput as d, agenticGenerator as dt, ImprovementProfilePopulationObservationSource as et, SealedCandidateActivationTransitionInput as f, commandVerifier as ft, improve as g, verifyAgentImprovementActivationResult as h, AgentImprovementActivationTransition as i, AgenticGeneratorExecutorForWorktree as it, ImproveMethodSource as j, ImproveMethodOptions as k, ExecuteAgentImprovementActivationInput as l, Verifier as lt, executeAgentImprovementActivation as m, CandidateGenerator as mt, AgentImprovementActivationResultStore as n, DeepReadonly as nt, AgentProfileImprovementActivationOperation as o, AgenticGeneratorShotDisposition as ot, createAgentImprovementActivationResult as p, defaultBuildPrompt as pt, ImprovementProfileCandidatePopulationAvailable as q, AgentImprovementActivationTargetPlan as r, ReadonlyAgentProfile as rt, AgentProfileImprovementActivationTargetPlan as s, AgenticGeneratorShotExecution as st, AgentImprovementActivationReconciliation as t, ImprovementRefusedProfilePopulationCandidate as tt, ExecuteAgentImprovementActivationOptions as u, VerifyResult as ut, ImproveCandidateValidator as v, ImproveCustomCodeGeneratorOptions as w, ImproveCodeResult as x, ImproveCodeBaseOptions as y, ImproveScenarioPartitions as z };
661
- //# sourceMappingURL=activation-CRDZUoUE.d.ts.map
770
+ export { ImprovementMaterializedProfilePopulationCandidate as $, ImproveCodeResult as A, ImproveMethodSource as B, TrainingBoundaryResult as C, CandidateGenerator as Ct, ImproveCandidateValidator as D, ImproveCandidateValidationInput as E, ImproveMethodContext as F, ImproveProfileSurface as G, ImproveOptions as H, ImproveMethodFactory as I, ImproveScenarioPartitions as J, ImproveResult as K, ImproveMethodLineage as L, ImproveCost as M, ImproveCustomCodeGeneratorOptions as N, ImproveCodeBaseOptions as O, ImproveLineage as P, ImprovementCodeCandidate as Q, ImproveMethodOptions as R, ProfileTrainerRequest as S, defaultBuildPrompt as St, createCommandProfileTrainer as T, ImproveProfileAgent as U, ImproveOptimizationRunOptions as V, ImproveProfileComponents as W, ImproveSurface as X, ImproveSkillsOptions as Y, ImprovementCandidate as Z, CheckpointServingPort as _, AgenticGeneratorShotReceipt as _t, AgentImprovementActivationTransitionInput as a, ImprovementProfilePopulationCandidate as at, ImproveTrainingResult as b, agenticGenerator as bt, CreateAgentImprovementActivationResultOptions as c, ImprovementProfilePopulationLineageNode as ct, ProfileImprovementActivationTransitionInput as d, DeepReadonly as dt, ImprovementProfileCandidate as et, SealedCandidateActivationTransitionInput as f, ReadonlyAgentProfile as ft, improve as g, AgenticGeneratorShotExecution as gt, verifyAgentImprovementActivationResult as h, AgenticGeneratorShotDisposition as ht, AgentImprovementActivationTransition as i, ImprovementProfilePopulationArtifactSource as it, ImproveCodeRunOptions as j, ImproveCodeOptions as k, ExecuteAgentImprovementActivationInput as l, ImprovementProfilePopulationObservationSource as lt, executeAgentImprovementActivation as m, AgenticGeneratorOptions as mt, AgentImprovementActivationResultStore as n, ImprovementProfileCandidatePopulationAvailable as nt, AgentProfileImprovementActivationOperation as o, ImprovementProfilePopulationCandidateSource as ot, createAgentImprovementActivationResult as p, AgenticGeneratorExecutorForWorktree as pt, ImproveRuntimeCodeGeneratorOptions as q, AgentImprovementActivationTargetPlan as r, ImprovementProfileCandidatePopulationUnavailable as rt, AgentProfileImprovementActivationTargetPlan as s, ImprovementProfilePopulationLineage as st, AgentImprovementActivationReconciliation as t, ImprovementProfileCandidatePopulation as tt, ExecuteAgentImprovementActivationOptions as u, ImprovementRefusedProfilePopulationCandidate as ut, ControlledTrainingCommand as v, Verifier as vt, TrainingDatasetDocument as w, ProfileTrainer as x, commandVerifier as xt, ImproveTrainingOptions as y, VerifyResult as yt, ImproveMethodResult as z };
771
+ //# sourceMappingURL=activation-Df-ae5Uq.d.ts.map
package/dist/agent.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Gi as RuntimeStreamEvent, Vr as AgentRunSpec, fi as SandboxClient, ui as OutputAdapter } from "./types-CE7ES_TD.js";
1
+ import { Gi as RuntimeStreamEvent, Vr as AgentRunSpec, fi as SandboxClient, ui as OutputAdapter } from "./types-BoEzH8V6.js";
2
2
  import { a as createSurfaceImprovementProposer, c as SurfaceValidationIssue, d as validateSurfaces, i as SurfaceImprovementEdit, l as renderSurfaceIssues, n as DraftPatchInput, o as AgentSurfaces, r as DraftPatchOutput, s as ResolvedSurface, t as CreateSurfaceImprovementProposerOptions, u as resolveSubjectPath } from "./improvement-adapter-D5gwwoXQ.js";
3
- import { Am as DefineProfileMaterializationContractOptions, Bm as promptControlProfileMaterialization, Dm as AgentProfileMaterializationAxis, Em as AGENT_PROFILE_MATERIALIZATION_AXES, Fm as assertProfileMaterialization, Gm as sandboxActProfileMaterialization, Hm as promptOnlyProfileMaterialization, Im as controlProfileMaterialization, Km as validateProfileMaterialization, Lm as defineProfileMaterializationContract, Mm as ProfileMaterializationContract, Nm as ProfileMaterializationIssue, Om as AssertProfileMaterializationOptions, Pm as ValidateProfileMaterializationOptions, Rm as fullProfileMaterialization, Um as promptResourceProfileMaterialization, Vm as promptModelProfileMaterialization, Wm as renderProfileMaterializationIssues, jm as KnownAgentProfileMaterializationAxis, km as CanonicalAgentProfileMaterializationAxis, qm as worktreeCliProfileMaterialization, zm as profileMaterializationAxes } from "./index-DTGWDyrF.js";
3
+ import { Am as DefineProfileMaterializationContractOptions, Bm as promptControlProfileMaterialization, Dm as AgentProfileMaterializationAxis, Em as AGENT_PROFILE_MATERIALIZATION_AXES, Fm as assertProfileMaterialization, Gm as sandboxActProfileMaterialization, Hm as promptOnlyProfileMaterialization, Im as controlProfileMaterialization, Km as validateProfileMaterialization, Lm as defineProfileMaterializationContract, Mm as ProfileMaterializationContract, Nm as ProfileMaterializationIssue, Om as AssertProfileMaterializationOptions, Pm as ValidateProfileMaterializationOptions, Rm as fullProfileMaterialization, Um as promptResourceProfileMaterialization, Vm as promptModelProfileMaterialization, Wm as renderProfileMaterializationIssues, jm as KnownAgentProfileMaterializationAxis, km as CanonicalAgentProfileMaterializationAxis, qm as worktreeCliProfileMaterialization, zm as profileMaterializationAxes } from "./index-CAG31NtK.js";
4
4
  import { AgentProfile, AgentProfileFileMount, AgentProfileMcpServer } from "@tangle-network/agent-interface";
5
5
  import { TraceAnalystDefinition } from "@tangle-network/agent-eval";
6
6
  import { SandboxEvent } from "@tangle-network/sandbox";
package/dist/agent.js CHANGED
@@ -1,5 +1,5 @@
1
- import { Br as promptModelProfileMaterialization, Fr as controlProfileMaterialization, Gr as sandboxActProfileMaterialization, Hr as promptResourceProfileMaterialization, Ir as defineProfileMaterializationContract, Jr as worktreeCliProfileMaterialization, Lr as fullProfileMaterialization, Nr as AGENT_PROFILE_MATERIALIZATION_AXES, Pr as assertProfileMaterialization, Rr as profileMaterializationAxes, Ur as renderProfileMaterializationIssues, Vr as promptOnlyProfileMaterialization, ki as mapSandboxEvent, mn as createSandboxForSpec, qr as validateProfileMaterialization, zr as promptControlProfileMaterialization } from "./supervisor-De0lytFU.js";
2
- import "./runtime-BsPY_v8H.js";
1
+ import { Ai as mapSandboxEvent, Br as promptControlProfileMaterialization, Fr as assertProfileMaterialization, Hr as promptOnlyProfileMaterialization, Ir as controlProfileMaterialization, Jr as validateProfileMaterialization, Kr as sandboxActProfileMaterialization, Lr as defineProfileMaterializationContract, Pr as AGENT_PROFILE_MATERIALIZATION_AXES, Rr as fullProfileMaterialization, Ur as promptResourceProfileMaterialization, Vr as promptModelProfileMaterialization, Wr as renderProfileMaterializationIssues, Yr as worktreeCliProfileMaterialization, mn as createSandboxForSpec, zr as profileMaterializationAxes } from "./supervisor-tGq-TPIv.js";
2
+ import "./runtime-CHbVv5UI.js";
3
3
  import { createHash } from "node:crypto";
4
4
  import { existsSync, readFileSync, statSync } from "node:fs";
5
5
  import { isAbsolute, join, relative, resolve, sep } from "node:path";
@@ -1,7 +1,7 @@
1
- import { a as canonicalCandidateBytes, l as embeddedCandidateArtifact } from "../protected-redaction-wGo44k2K.js";
2
- import { $ as assertTerminalMatchesStaged, A as omitUndefinedObjectFields, C as agentCandidateProfileAsAgentProfile, G as InMemoryAgentCandidateExecutionClaimStore, H as scanMaterializedWorkspaceManifest, J as candidateCleanupTimeout, K as candidateClaimFileInternals, M as parseExactAgentProfile, N as parseExactAgentProfileDiff, O as freezeGenericAgentCandidateProfile, P as parseExactCandidateProfile, Q as assertTerminalMatchesClaim, T as assertCandidateProfileBinding, V as readVerifiedArtifact, W as verifyMaterializedWorkspace, X as assertRecoveryMatchesStaged, Y as withinCandidateCleanupDeadline, Z as assertTerminalAllowedInPhase, _ as beginPreparedCandidateDisposal, a as AGENT_CANDIDATE_EXECUTION_SUPPORT, at as terminalRecord, b as CANDIDATE_TRACE_TAGS, c as executePreparedAgentCandidate, d as persistCandidateOutputArtifact, et as recoveredTerminalRecord, f as sealAgentCandidateModelSettlement, g as assertPreparedCandidateIntegrity, h as candidateExecutionClaim, i as candidateKnowledgeExecutionPaths, it as sealTerminalDigest, l as RecoveryAgentCandidateTraceStore, m as sealAgentCandidateExecutorStopAcknowledgement, n as CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV, nt as rejectedStage, q as candidateCleanupDeadline, r as CANDIDATE_KNOWLEDGE_ROOT_ENV, rt as requireStagedTerminal, s as verifyAgentCandidateBundle, t as prepareAgentCandidateExecution, tt as rejectedFinish, u as persistCandidateModelSettlementEvidence, v as consumePreparedCandidateExecution, w as applyExactAgentProfileDiff, y as CANDIDATE_TRACE_ENV, z as candidateWorkspaceManifest } from "../prepare-Dc30WRB0.js";
3
- import { i as sealAgentCandidateBundle, n as captureAgentCandidateWorkspaceFiles, r as createAgentCandidateWorkspacePort, t as captureAgentCandidateWorkspace } from "../workspace-archive-CBX0hwL_.js";
4
- import { n as exactProcessProviderAsCandidateExecutor, t as createProtectedAgentCandidateModelPort } from "../protected-model-port-D5gDcnrH.js";
1
+ import { a as canonicalCandidateBytes$1, l as embeddedCandidateArtifact } from "../protected-redaction-Fn1ETfJ-.js";
2
+ import { $ as assertTerminalMatchesStaged, A as omitUndefinedObjectFields, C as agentCandidateProfileAsAgentProfile, G as InMemoryAgentCandidateExecutionClaimStore, H as scanMaterializedWorkspaceManifest, J as candidateCleanupTimeout, K as candidateClaimFileInternals, M as parseExactAgentProfile, N as parseExactAgentProfileDiff, O as freezeGenericAgentCandidateProfile, P as parseExactCandidateProfile, Q as assertTerminalMatchesClaim, T as assertCandidateProfileBinding, V as readVerifiedArtifact, W as verifyMaterializedWorkspace, X as assertRecoveryMatchesStaged, Y as withinCandidateCleanupDeadline, Z as assertTerminalAllowedInPhase, _ as beginPreparedCandidateDisposal, a as AGENT_CANDIDATE_EXECUTION_SUPPORT, at as terminalRecord, b as CANDIDATE_TRACE_TAGS, c as executePreparedAgentCandidate, d as persistCandidateOutputArtifact, et as recoveredTerminalRecord, f as sealAgentCandidateModelSettlement, g as assertPreparedCandidateIntegrity, h as candidateExecutionClaim, i as candidateKnowledgeExecutionPaths, it as sealTerminalDigest, l as RecoveryAgentCandidateTraceStore, m as sealAgentCandidateExecutorStopAcknowledgement, n as CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV, nt as rejectedStage, q as candidateCleanupDeadline, r as CANDIDATE_KNOWLEDGE_ROOT_ENV, rt as requireStagedTerminal, s as verifyAgentCandidateBundle, t as prepareAgentCandidateExecution, tt as rejectedFinish, u as persistCandidateModelSettlementEvidence, v as consumePreparedCandidateExecution, w as applyExactAgentProfileDiff, y as CANDIDATE_TRACE_ENV, z as candidateWorkspaceManifest } from "../prepare-CibQrhfi.js";
3
+ import { i as sealAgentCandidateBundle, n as captureAgentCandidateWorkspaceFiles, r as createAgentCandidateWorkspacePort, t as captureAgentCandidateWorkspace } from "../workspace-archive-DSRT4Tro.js";
4
+ import { n as exactProcessProviderAsCandidateExecutor, t as createProtectedAgentCandidateModelPort } from "../protected-model-port-Dhdi5mDl.js";
5
5
  import { agentCandidateExecutionPlanMaterialSchema, agentCandidateMaterializationReceiptSchema } from "@tangle-network/agent-interface";
6
6
  import { createHash, randomUUID } from "node:crypto";
7
7
  import { constants, linkSync } from "node:fs";
@@ -274,7 +274,7 @@ async function writeRecordIfAbsent(directory, destination, record, options = {})
274
274
  const temporaryPath = join(directory, `.candidate-execution-${process.pid}-${randomUUID()}.tmp`);
275
275
  const handle = await open(temporaryPath, "wx", 384);
276
276
  try {
277
- await handle.writeFile(Buffer.concat([Buffer.from(canonicalCandidateBytes(record)), Buffer.from("\n")]));
277
+ await handle.writeFile(Buffer.concat([Buffer.from(canonicalCandidateBytes$1(record)), Buffer.from("\n")]));
278
278
  await handle.sync();
279
279
  } finally {
280
280
  await handle.close();
@@ -515,7 +515,7 @@ async function recoverExpiredAgentCandidateExecution(options) {
515
515
  const failureEvidence = await withinCandidateCleanupDeadline(() => persistCandidateOutputArtifact(options.outputArtifacts, {
516
516
  executionId: record.claim.executionId,
517
517
  purpose: "failure-evidence",
518
- bytes: canonicalCandidateBytes({
518
+ bytes: canonicalCandidateBytes$1({
519
519
  kind: "agent-candidate-recovery-failure",
520
520
  executionId: record.claim.executionId,
521
521
  attempt: record.claim.attempt,
@@ -574,7 +574,7 @@ function parseCanonicalBytes(bytes, label) {
574
574
  throw new Error(`candidate recovery ${label} is not JSON`, { cause: error });
575
575
  }
576
576
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`candidate recovery ${label} must be an object`);
577
- if (!Buffer.from(canonicalCandidateBytes(parsed)).equals(Buffer.from(bytes))) throw new Error(`candidate recovery ${label} bytes are not canonical`);
577
+ if (!Buffer.from(canonicalCandidateBytes$1(parsed)).equals(Buffer.from(bytes))) throw new Error(`candidate recovery ${label} bytes are not canonical`);
578
578
  return parsed;
579
579
  }
580
580
  //#endregion