@tangle-network/agent-runtime 0.115.0 → 0.116.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 (52) hide show
  1. package/dist/{activation-BNQQO-bc.js → activation-DuqQhee6.js} +2 -2
  2. package/dist/{activation-BNQQO-bc.js.map → activation-DuqQhee6.js.map} +1 -1
  3. package/dist/agent.d.ts +1 -1
  4. package/dist/agent.js +2 -2
  5. package/dist/{environment-provider-Cygthiy3.d.ts → environment-provider-CWsRh6Uz.d.ts} +365 -4
  6. package/dist/environment-provider.d.ts +1 -1
  7. package/dist/{improvement-cycle-CBLOgfsQ.js → improvement-cycle-C1cmjvPD.js} +3 -3
  8. package/dist/{improvement-cycle-CBLOgfsQ.js.map → improvement-cycle-C1cmjvPD.js.map} +1 -1
  9. package/dist/{index-BuzkRsOn.d.ts → index-COumPQka.d.ts} +49 -225
  10. package/dist/{index-I97xACXk.d.ts → index-CYkDeM5L.d.ts} +3 -3
  11. package/dist/{index-B_vcAAle.d.ts → index-DcLMNnG5.d.ts} +7 -6
  12. package/dist/index.d.ts +6 -7
  13. package/dist/index.js +7 -8
  14. package/dist/index.js.map +1 -1
  15. package/dist/intelligence.d.ts +3 -3
  16. package/dist/intelligence.js +3 -3
  17. package/dist/kernel.d.ts +4 -4
  18. package/dist/kernel.js +5 -5
  19. package/dist/{knowledge-DcIKJaPd.js → knowledge-DOzbywZT.js} +3 -3
  20. package/dist/{knowledge-DcIKJaPd.js.map → knowledge-DOzbywZT.js.map} +1 -1
  21. package/dist/knowledge.d.ts +1 -1
  22. package/dist/knowledge.js +1 -1
  23. package/dist/{local-harness-BnB1E9nM.d.ts → local-harness-t6cDWDQ2.d.ts} +3 -105
  24. package/dist/{loop-runner-bin-DgAXgQCI.d.ts → loop-runner-bin-BFrhPLKt.d.ts} +3 -3
  25. package/dist/{loop-runner-bin-C2GIqSUn.js → loop-runner-bin-BuQjc5DR.js} +3 -3
  26. package/dist/{loop-runner-bin-C2GIqSUn.js.map → loop-runner-bin-BuQjc5DR.js.map} +1 -1
  27. package/dist/loop-runner-bin.d.ts +1 -1
  28. package/dist/loop-runner-bin.js +1 -1
  29. package/dist/mcp/bin.js +2 -2
  30. package/dist/mcp/index.d.ts +3 -2
  31. package/dist/mcp/index.js +4 -5
  32. package/dist/mcp/index.js.map +1 -1
  33. package/dist/{openai-tools-BWAEIHkZ.js → openai-tools-_Wyp4udO.js} +2 -2
  34. package/dist/{openai-tools-BWAEIHkZ.js.map → openai-tools-_Wyp4udO.js.map} +1 -1
  35. package/dist/primeintellect/index.d.ts +1 -1
  36. package/dist/{redact-BRaHUFMf.d.ts → redact-BEtQtvd6.d.ts} +2 -2
  37. package/dist/{runtime-C_g_SsXg.js → runtime-Ut1pkd2n.js} +4 -4
  38. package/dist/{runtime-C_g_SsXg.js.map → runtime-Ut1pkd2n.js.map} +1 -1
  39. package/dist/{structural-rollout-Cqm1dKa7.js → structural-rollout-CVY_0hJp.js} +2 -2
  40. package/dist/{structural-rollout-Cqm1dKa7.js.map → structural-rollout-CVY_0hJp.js.map} +1 -1
  41. package/dist/{supervise-BcCHhLrz.js → supervise-BUR9ByF7.js} +61 -22
  42. package/dist/supervise-BUR9ByF7.js.map +1 -0
  43. package/dist/{supervisor-CspDspod.js → supervisor-BBbPBXpe.js} +1019 -10
  44. package/dist/supervisor-BBbPBXpe.js.map +1 -0
  45. package/dist/testing.js +8 -8
  46. package/package.json +1 -1
  47. package/dist/otel-export-CPZTSADj.js +0 -852
  48. package/dist/otel-export-CPZTSADj.js.map +0 -1
  49. package/dist/supervise-BcCHhLrz.js.map +0 -1
  50. package/dist/supervisor-CspDspod.js.map +0 -1
  51. package/dist/trace-propagation-B-pL7xn_.js +0 -57
  52. package/dist/trace-propagation-B-pL7xn_.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { it as canonicalCandidateDocument, rt as canonicalCandidateDigest$1, st as immutableCandidateValue, ut as verifyCanonicalCandidateDocument } from "./prepare-BHQBb02e.js";
2
- import { C as agentImprovementTargetInput, S as agentImprovementTargetDigest, T as agentProfileImprovementStateDigest, c as requireSealedCandidateExperiment, d as verifyAgentImprovementActivation, f as verifyAgentImprovementProposal } from "./improvement-cycle-CBLOgfsQ.js";
2
+ import { C as agentImprovementTargetInput, S as agentImprovementTargetDigest, T as agentProfileImprovementStateDigest, c as requireSealedCandidateExperiment, d as verifyAgentImprovementActivation, f as verifyAgentImprovementProposal } from "./improvement-cycle-C1cmjvPD.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-BNQQO-bc.js.map
204
+ //# sourceMappingURL=activation-DuqQhee6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"activation-BNQQO-bc.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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AkB,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-DuqQhee6.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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AY,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"}
package/dist/agent.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { x as RuntimeStreamEvent } from "./types-C9j4qg6l.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
3
  import { E as SandboxClient, t as AgentRunSpec, w as OutputAdapter } from "./types-DnNGJ5Gz.js";
4
- import "./index-BuzkRsOn.js";
4
+ import "./index-COumPQka.js";
5
5
  import { TraceAnalystDefinition } from "@tangle-network/agent-eval";
6
6
  import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentProfile as AgentProfile$1, AgentProfileFileMount, AgentProfileMcpServer, CanonicalAgentProfileMaterializationAxis } from "@tangle-network/agent-interface";
7
7
  import { SandboxEvent } from "@tangle-network/sandbox";
package/dist/agent.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { u as ValidationError } from "./errors-DEAvWQPy.js";
2
- import "./runtime-C_g_SsXg.js";
2
+ import "./runtime-Ut1pkd2n.js";
3
3
  import { r as mapSandboxEvent } from "./sandbox-events-DeI5xX8P.js";
4
- import { Kt as createSandboxForSpec } from "./supervise-BcCHhLrz.js";
4
+ import { Kt as createSandboxForSpec } from "./supervise-BUR9ByF7.js";
5
5
  import { AGENT_PROFILE_MATERIALIZATION_AXES } from "@tangle-network/agent-interface";
6
6
  import { createHash } from "node:crypto";
7
7
  import { existsSync, readFileSync, statSync } from "node:fs";
@@ -1,6 +1,7 @@
1
+ import { d as AgentTaskStatus, o as AgentRuntimeEvent, x as RuntimeStreamEvent } from "./types-C9j4qg6l.js";
1
2
  import { l as RuntimeHooks } from "./runtime-hooks-sbRpjStq.js";
2
- import { E as SandboxClient, v as LoopTokenUsage } from "./types-DnNGJ5Gz.js";
3
- import { DefaultVerdict, ToolSpan } from "@tangle-network/agent-eval";
3
+ import { E as SandboxClient, v as LoopTokenUsage, y as LoopTraceEmitter } from "./types-DnNGJ5Gz.js";
4
+ import { ControlEvalResult, DefaultVerdict, KnowledgeReadinessReport, KnowledgeRequirement, ToolSpan } from "@tangle-network/agent-eval";
4
5
  import { AgentProfile as AgentProfile$1, AgentProfileValidationResult } from "@tangle-network/agent-interface";
5
6
  import { BackendType, CreateSandboxOptions, Sandbox } from "@tangle-network/sandbox";
6
7
  import { AgentEnvironment, AgentEnvironmentCapabilities, AgentEnvironmentCapabilities as AgentEnvironmentCapabilities$1, AgentEnvironmentEvent, AgentEnvironmentProvider, AgentEnvironmentProvider as AgentEnvironmentProvider$1, AgentEnvironmentQuery, AgentEnvironmentStatus, AgentEnvironmentSummary, AgentProfileRef, AgentProfileRef as AgentProfileRef$1, AgentSession, AgentSessionRef, AgentSessionStatus, AgentTurnInput, AgentTurnInput as AgentTurnInput$1, AgentTurnResult, CheckpointRef, CheckpointRequest, CreateAgentEnvironmentInput, CreateAgentEnvironmentInput as CreateAgentEnvironmentInput$1, ExecRequest, ExecResult, ForkRequest, PlacementInfo, ResourceRequest, WorkspaceRequest } from "@tangle-network/agent-interface/environment-provider";
@@ -303,6 +304,357 @@ declare function waitUntil(spec: WaitSpec): number | undefined;
303
304
  /** Structural validation, independent of the run. Returns null when the spec is usable. */
304
305
  declare function validateWaitSpec(spec: WaitSpec): string | null;
305
306
  //#endregion
307
+ //#region src/sanitize.d.ts
308
+ /** @stable */
309
+ interface RuntimeTelemetryOptions {
310
+ /**
311
+ * Include raw task inputs. Off by default because task inputs often contain
312
+ * customer facts, credentials, source text, or internal IDs.
313
+ */
314
+ includeInputs?: boolean;
315
+ /** Include requirement descriptions. Secret requirements are always redacted. */
316
+ includeRequirementDescriptions?: boolean;
317
+ /** Include evidence IDs. Off by default; counts are safer for shared reports. */
318
+ includeEvidenceIds?: boolean;
319
+ /** Include user answers from question preflight. Off by default. */
320
+ includeUserAnswers?: boolean;
321
+ /** Include action payloads and action results for control steps. Off by default. */
322
+ includeControlPayloads?: boolean;
323
+ /** Include task metadata. Off by default because metadata may carry IDs or policy internals. */
324
+ includeMetadata?: boolean;
325
+ /** Include eval detail/evidence strings. Off by default because validators may echo private input. */
326
+ includeEvalDetails?: boolean;
327
+ }
328
+ /** @stable */
329
+ interface SanitizedKnowledgeRequirement {
330
+ id: string;
331
+ description?: string;
332
+ requiredFor: string[];
333
+ category: KnowledgeRequirement['category'];
334
+ acquisitionMode: KnowledgeRequirement['acquisitionMode'];
335
+ importance: KnowledgeRequirement['importance'];
336
+ freshness: KnowledgeRequirement['freshness'];
337
+ sensitivity: KnowledgeRequirement['sensitivity'];
338
+ confidenceNeeded: number;
339
+ currentConfidence: number;
340
+ evidenceCount: number;
341
+ evidenceIds?: string[];
342
+ fallbackPolicy: KnowledgeRequirement['fallbackPolicy'];
343
+ }
344
+ /** @stable */
345
+ interface SanitizedKnowledgeReadinessReport {
346
+ taskId: string;
347
+ readinessScore: number;
348
+ recommendedAction: KnowledgeReadinessReport['recommendedAction'];
349
+ severity: KnowledgeReadinessReport['severity'];
350
+ reason: string;
351
+ blockingMissingRequirements: SanitizedKnowledgeRequirement[];
352
+ nonBlockingGaps: SanitizedKnowledgeRequirement[];
353
+ evidenceCount: number;
354
+ evidenceIds?: string[];
355
+ missingRequirementIds: string[];
356
+ }
357
+ /** Strip PII and large blobs from a `KnowledgeReadinessReport` for safe telemetry emission. @stable */
358
+ declare function sanitizeKnowledgeReadinessReport(report: KnowledgeReadinessReport, options?: RuntimeTelemetryOptions): SanitizedKnowledgeReadinessReport;
359
+ /** Reduce an `AgentRuntimeEvent` to a PII-safe, serializable plain object for telemetry. @stable */
360
+ declare function sanitizeAgentRuntimeEvent<TState, TAction, TActionResult, TEval extends ControlEvalResult>(event: AgentRuntimeEvent<TState, TAction, TActionResult, TEval>, options?: RuntimeTelemetryOptions): Record<string, unknown>;
361
+ /** Reduce a `RuntimeStreamEvent` to a PII-safe, serializable plain object for telemetry. @stable */
362
+ declare function sanitizeRuntimeStreamEvent(event: RuntimeStreamEvent, options?: RuntimeTelemetryOptions): Record<string, unknown>;
363
+ /** @stable */
364
+ interface RuntimeEventCollector<TState = unknown, TAction = unknown, TActionResult = unknown, TEval extends ControlEvalResult = ControlEvalResult> {
365
+ onEvent: (event: AgentRuntimeEvent<TState, TAction, TActionResult, TEval>) => void;
366
+ events: Array<Record<string, unknown>>;
367
+ }
368
+ /** @stable */
369
+ type RuntimeStreamEventSink = (event: RuntimeStreamEvent) => void;
370
+ /** @stable */
371
+ interface RuntimeStreamEventSummary {
372
+ /** Total count of sanitized events collected. */
373
+ eventCount: number;
374
+ /** Count of events per `type`. Useful for log-line summaries. */
375
+ eventCountsByType: Record<string, number>;
376
+ /** First session id observed in a `session_created` / `session_resumed` event, if any. */
377
+ firstSessionId?: string;
378
+ /** Last `final` event's status, if a final event was observed. */
379
+ finalStatus?: AgentTaskStatus;
380
+ /** Last `final` event's reason, if a final event was observed. */
381
+ finalReason?: string;
382
+ /** Concatenated `text_delta.text` across the stream, even when payloads are redacted. */
383
+ finalText: string;
384
+ }
385
+ /** @stable */
386
+ interface RuntimeStreamEventCollector {
387
+ onEvent: RuntimeStreamEventSink;
388
+ events: Array<Record<string, unknown>>;
389
+ /** Snapshot of a small streaming-flavored summary derived from collected events. */
390
+ summary(): RuntimeStreamEventSummary;
391
+ }
392
+ /** Build an in-memory collector that sanitizes and accumulates `AgentRuntimeEvent`s for inspection. @stable */
393
+ declare function createRuntimeEventCollector<TState = unknown, TAction = unknown, TActionResult = unknown, TEval extends ControlEvalResult = ControlEvalResult>(options?: RuntimeTelemetryOptions): RuntimeEventCollector<TState, TAction, TActionResult, TEval>;
394
+ /**
395
+ *
396
+ * Streaming-event counterpart of `createRuntimeEventCollector`. Pass each
397
+ * event yielded by `runAgentTaskStream` through `onEvent` and read the
398
+ * sanitized copies off `events`; the same `RuntimeTelemetryOptions` redaction
399
+ * flags apply. Kept distinct from `createRuntimeEventCollector` because the
400
+ * stream and non-stream event shapes overlap on `type` literals — dispatching
401
+ * on `type` alone would misroute events.
402
+ *
403
+ * @stable
404
+ */
405
+ declare function createRuntimeStreamEventCollector(options?: RuntimeTelemetryOptions): RuntimeStreamEventCollector;
406
+ //#endregion
407
+ //#region src/otel-export.d.ts
408
+ interface OtelExportConfig {
409
+ /** OTLP endpoint. Reads OTEL_EXPORTER_OTLP_ENDPOINT env by default. */
410
+ endpoint?: string;
411
+ /** OTLP headers. Reads OTEL_EXPORTER_OTLP_HEADERS env by default. */
412
+ headers?: Record<string, string>;
413
+ /** Batch size before flush. Default 64. */
414
+ batchSize?: number;
415
+ /** Flush interval ms. Default 5000. */
416
+ flushIntervalMs?: number;
417
+ /** Resource attributes stamped on every export. */
418
+ resourceAttributes?: Record<string, string | number | boolean>;
419
+ /** Service name. Default 'agent-runtime'. */
420
+ serviceName?: string;
421
+ }
422
+ interface OtelExporter {
423
+ /** Export a span. */
424
+ exportSpan(span: OtelSpan): void;
425
+ /** Force flush pending spans. */
426
+ flush(): Promise<void>;
427
+ /** Shutdown cleanly. */
428
+ shutdown(): Promise<void>;
429
+ }
430
+ interface OtelSpan {
431
+ traceId: string;
432
+ spanId: string;
433
+ parentSpanId?: string;
434
+ name: string;
435
+ kind?: number;
436
+ startTimeUnixNano: string;
437
+ endTimeUnixNano: string;
438
+ attributes?: OtelAttribute[];
439
+ status?: {
440
+ code: number;
441
+ message?: string;
442
+ };
443
+ }
444
+ interface OtelAttribute {
445
+ key: string;
446
+ value: {
447
+ stringValue?: string;
448
+ intValue?: string;
449
+ doubleValue?: number;
450
+ boolValue?: boolean;
451
+ };
452
+ }
453
+ /**
454
+ * Create an OTEL exporter. Returns undefined when no endpoint is configured.
455
+ */
456
+ declare function createOtelExporter(config?: OtelExportConfig): OtelExporter | undefined;
457
+ /**
458
+ * Convert a LoopTraceEvent into an OtelSpan for export.
459
+ */
460
+ declare function loopEventToOtelSpan(event: {
461
+ kind: string;
462
+ runId: string;
463
+ timestamp: number;
464
+ payload: object;
465
+ }, traceId: string, parentSpanId?: string): OtelSpan;
466
+ interface RuntimeEventOtelOptions extends RuntimeTelemetryOptions {
467
+ /** Final customer redactor applied after the schema-aware runtime sanitizer. */
468
+ redact?: (value: unknown) => unknown;
469
+ }
470
+ /** Convert normalized runtime events into lossless, redacted child spans. */
471
+ declare function buildRuntimeEventOtelSpans(events: ReadonlyArray<RuntimeStreamEvent>, traceId: string, parentSpanId?: string, options?: RuntimeEventOtelOptions): OtelSpan[];
472
+ /**
473
+ * Sink-neutral node in a reconstructed loop span tree. The root node's
474
+ * `parentSpanId` is `undefined` — sinks decide how to parent it (the OTEL
475
+ * mapper attaches the inherited delegation span; the delegation journal
476
+ * leaves it as the tree root).
477
+ */
478
+ interface LoopSpanNode {
479
+ spanId: string;
480
+ parentSpanId?: string;
481
+ /** `'loop'` | `'loop.round'` | `'loop.iteration'`. */
482
+ name: string;
483
+ /** Topology level: loop root, plan round, or iteration branch. */
484
+ kind: 'loop' | 'round' | 'branch';
485
+ startMs: number;
486
+ endMs: number;
487
+ attrs: Record<string, string | number | boolean>;
488
+ /** True when the iteration carried an error — maps to OTEL status code 2. */
489
+ error: boolean;
490
+ }
491
+ /**
492
+ * Build a nested, real-duration OTLP span tree for ONE loop run from its full
493
+ * ordered `LoopTraceEvent` stream. Unlike `loopEventToOtelSpan` (one flat,
494
+ * zero-duration span per event), this reconstructs the topology hierarchy a
495
+ * GenAI trace viewer renders natively:
496
+ *
497
+ * loop (invoke_workflow)
498
+ * └─ loop.round[k] (invoke_workflow) ← tangle.loop.move.{kind,width,rationale}
499
+ * ├─ loop.iteration[i] (invoke_agent) ← gen_ai.agent.name + usage + verdict + placement
500
+ * └─ …
501
+ *
502
+ * Attributes follow the current GenAI semconv (`gen_ai.*`) where they apply and
503
+ * a namespaced `tangle.loop.*` / `tangle.cost.usd` extension for topology /
504
+ * verdict / placement / cost (not yet standardized). Pure: feed it a buffered
505
+ * per-runId event array (e.g. flushed on `loop.ended`) and export the result.
506
+ */
507
+ declare function buildLoopOtelSpans(events: ReadonlyArray<{
508
+ kind: string;
509
+ runId: string;
510
+ timestamp: number;
511
+ payload: object;
512
+ }>, traceId: string, rootParentSpanId?: string): OtelSpan[];
513
+ /**
514
+ * Sink-neutral core behind {@link buildLoopOtelSpans}: reconstruct the
515
+ * loop → round → branch span tree from one run's ordered `LoopTraceEvent`
516
+ * stream. Consumed by the OTEL mapper above and by the MCP delegation
517
+ * journal's compact trace tee — one topology reconstruction, two sinks.
518
+ * Tolerates partial streams (a run that never reached `loop.ended` closes
519
+ * at the last observed event's timestamp).
520
+ */
521
+ declare function buildLoopSpanNodes(events: ReadonlyArray<{
522
+ kind: string;
523
+ runId: string;
524
+ timestamp: number;
525
+ payload: object;
526
+ }>): LoopSpanNode[];
527
+ /**
528
+ * Convert a flat record into the OTLP attribute list. Non-finite numbers are DROPPED (an OTLP
529
+ * `doubleValue` of `NaN`/`Infinity` is not representable), integers ride as `intValue`. Exported so
530
+ * a producer that mints its own `OtelSpan` (the supervisor span recorder) builds attributes exactly
531
+ * the way every span in this file does, rather than re-deriving the encoding.
532
+ */
533
+ declare function toOtelAttributes(record: Record<string, string | number | boolean>): OtelAttribute[];
534
+ /** Mint a fresh 16-hex-character OTLP span id. Exported so a producer that must know a span's id
535
+ * BEFORE the span closes (a node opened at spawn and parented by its children) uses this one
536
+ * generator instead of a second copy of it. */
537
+ declare function generateSpanId(): string;
538
+ /** Wire version the eval-runs ingest enforces (X-Tangle-Wire-Version + body). */
539
+ declare const INTELLIGENCE_WIRE_VERSION = "2026-05-26.v1";
540
+ interface EvalRunGeneration {
541
+ /** 0-based ordinal of this generation within the run (required by ingest). */
542
+ index: number;
543
+ /** Identity of the proposed surface change (content-addressed hash). */
544
+ surfaceHash: string;
545
+ /** Arbitrary provenance for this generation (rationale, evidence, source). */
546
+ surface?: unknown;
547
+ /** Per-scenario results; empty until the generation is measured. */
548
+ cells?: unknown[];
549
+ /** Mean composite score (0 when unmeasured — pair with labels.measured). */
550
+ compositeMean: number;
551
+ costUsd: number;
552
+ durationMs: number;
553
+ }
554
+ interface EvalRunEvent {
555
+ runId: string;
556
+ runDir: string;
557
+ /** ISO timestamp. */
558
+ timestamp: string;
559
+ status: 'started' | 'baseline-complete' | 'generation-complete' | 'gate-decided' | 'finished' | 'errored';
560
+ labels?: Record<string, string>;
561
+ baseline?: EvalRunGeneration;
562
+ generations?: EvalRunGeneration[];
563
+ gateDecision?: 'ship' | 'hold' | 'need_more_work' | 'model_ceiling' | 'arch_ceiling';
564
+ holdoutLift?: number;
565
+ totalCostUsd: number;
566
+ totalDurationMs: number;
567
+ errorMessage?: string;
568
+ }
569
+ interface EvalRunsExportConfig {
570
+ /** Bearer key — tenant is resolved server-side from it. Reads TANGLE_API_KEY. */
571
+ apiKey?: string;
572
+ /** Intelligence base. Reads TANGLE_INTELLIGENCE_URL env, else prod. */
573
+ base?: string;
574
+ /** Idempotency-Key header (e.g. the runId) — safe retries + upsert. */
575
+ idempotencyKey?: string;
576
+ }
577
+ interface EvalRunsExportResult {
578
+ ok: boolean;
579
+ status: number;
580
+ accepted: number;
581
+ rejected: Array<{
582
+ index: number;
583
+ reason: string;
584
+ }>;
585
+ }
586
+ /**
587
+ * Ship self-improvement eval-run events to Tangle Intelligence. Unlike the
588
+ * best-effort span exporter, this RESOLVES with the ingest verdict (accepted /
589
+ * rejected per event) so a consumer's loop can assert its provenance landed.
590
+ * Throws only on a missing key or network failure.
591
+ */
592
+ declare function exportEvalRuns(events: EvalRunEvent[], config?: EvalRunsExportConfig): Promise<EvalRunsExportResult>;
593
+ //#endregion
594
+ //#region src/mcp/trace-propagation.d.ts
595
+ interface TraceContext {
596
+ /** Trace id inherited from the parent process, or a fresh one. */
597
+ traceId: string;
598
+ /** Parent span id from the delegation that launched this MCP server. */
599
+ parentSpanId?: string;
600
+ }
601
+ /**
602
+ * Read trace context from the process environment.
603
+ * Returns a context with inherited ids or a freshly generated root.
604
+ */
605
+ declare function readTraceContextFromEnv(): TraceContext;
606
+ /**
607
+ * Create a LoopTraceEmitter that:
608
+ * 1. Parents all spans under the inherited PARENT_SPAN_ID.
609
+ * 2. Exports spans to OTEL when OTEL_EXPORTER_OTLP_ENDPOINT is set.
610
+ *
611
+ * Returns both the emitter and the optional exporter handle for shutdown.
612
+ */
613
+ declare function createPropagatingTraceEmitter(ctx: TraceContext): {
614
+ emitter: LoopTraceEmitter;
615
+ exporter: OtelExporter | undefined;
616
+ context: TraceContext;
617
+ };
618
+ /**
619
+ * Build env vars to pass to a child MCP subprocess so it inherits the
620
+ * current trace context.
621
+ */
622
+ declare function traceContextToEnv(ctx: TraceContext): Record<string, string>;
623
+ //#endregion
624
+ //#region src/runtime/supervise/worker-trace.d.ts
625
+ /**
626
+ * Seam key the `Scope` seeds a {@link TraceContext} under on each child's `ExecutorContext.seams`.
627
+ * Single-sourced here so the scope and every backend agree on it without a circular import — the
628
+ * same arrangement `nestedScopeSeamKey` uses.
629
+ */
630
+ declare const workerTraceSeamKey = "worker-trace";
631
+ /**
632
+ * Resolve the trace context a worker spawned BY `spawningNodeId` should inherit. `undefined` means
633
+ * this run records no spans, so nothing is stamped. Supplied by
634
+ * `SupervisorSpanRecorder.workerTrace` and threaded to the scope as `SupervisorOpts.workerTrace`.
635
+ */
636
+ type WorkerTraceResolver = (spawningNodeId: string) => TraceContext | undefined;
637
+ /**
638
+ * What the two readers below need off an `ExecutorContext` — its seam bag, and nothing else.
639
+ * Structural (not an `ExecutorContext` import) so this module stays free of the keystone type
640
+ * surface, and exported because it is part of a public signature.
641
+ */
642
+ interface WorkerTraceSeamCarrier {
643
+ readonly seams: Readonly<Record<string, unknown>>;
644
+ }
645
+ /**
646
+ * Read the inherited trace context off an `ExecutorContext`, or `undefined` when the run records no
647
+ * spans. Fails CLOSED on a malformed seam value (returns `undefined`) rather than stamping a
648
+ * half-formed id that would produce an unjoinable orphan span downstream.
649
+ */
650
+ declare function readWorkerTraceContext(ctx: WorkerTraceSeamCarrier): TraceContext | undefined;
651
+ /**
652
+ * The `TRACE_ID` / `PARENT_SPAN_ID` pair to merge into a worker's environment — EMPTY when the run
653
+ * records no spans, which is what keeps the untraced path byte-identical. Merge it BELOW the
654
+ * caller's own seam env so a deliberately-set id wins (see the precedence note above).
655
+ */
656
+ declare function workerTraceEnv(ctx: WorkerTraceSeamCarrier): Record<string, string>;
657
+ //#endregion
306
658
  //#region src/runtime/supervise/types.d.ts
307
659
  /** Options for `Scope.wait`. `label` is the wait's identity within its parent scope — it is what
308
660
  * a resumed run matches to re-adopt a journaled, still-unfired wait, so it must be stable across
@@ -945,6 +1297,15 @@ interface SupervisorOpts {
945
1297
  /** Lifecycle stream sink, threaded into the root `Scope` so every `spawn`/settle emits on the
946
1298
  * same `agent.spawn`/`agent.child` stream `runAgentRounds` feeds — one observable recursive tree. */
947
1299
  readonly hooks?: RuntimeHooks;
1300
+ /**
1301
+ * Trace context to hand DOWN to each spawned worker, so a worker in another process or on another
1302
+ * machine emits spans that join THIS run's trace instead of opening its own root. Supply
1303
+ * `SupervisorSpanRecorder.workerTrace`; the `Scope` seeds the resolved context onto every child's
1304
+ * `ExecutorContext` and the backends with an environment channel stamp it as
1305
+ * `TRACE_ID` / `PARENT_SPAN_ID` (see `worker-trace.ts` for the precedence rule and for which
1306
+ * backends propagate). Omit and no worker environment is touched at all.
1307
+ */
1308
+ readonly workerTrace?: WorkerTraceResolver;
948
1309
  }
949
1310
  /**
950
1311
  * A driver's `act()` rejection, normalized to a serializable triple so it survives the typed
@@ -1123,5 +1484,5 @@ interface ProviderExecutorOptions {
1123
1484
  * @experimental */
1124
1485
  declare function providerAsExecutor(provider: AgentEnvironmentProvider, options?: ProviderExecutorOptions): ExecutorFactory<unknown>;
1125
1486
  //#endregion
1126
- export { ResumedWork as $, providerAsSandboxClient as A, SessionMessageLike as At, Executor as B, ExecutorProgress as Bt, ProviderAsSandboxClientOptions as C, WaitSpec as Ct, WorkspaceRequest as D, timerAt as Dt, SandboxClientProviderOptions as E, pollFor as Et, createTangleSandboxExactProcessProvider as F, decodeToolPart as Ft, Handle as G, ExecutorFactory as H, WorkerProgress as Ht, Agent as I, sandboxSessionTraceSource as It, NodeSnapshot as J, NoWinnerError as K, AgentSpec as L, ActivityLog as Lt, sandboxClientAsProvider as M, ToolStepInput as Mt, CreateTangleSandboxExactProcessProviderOptions as N, TraceSource as Nt, createAgentEnvironmentProviderRegistry as O, validateWaitSpec as Ot, SandboxControlClient as P, createPushTraceSource as Pt, ResumedKeyState as Q, Budget as R, ActivityNote as Rt, PlacementInfo as S, WaitRejection as St, ResourceRequest as T, isWaitOutcome as Tt, ExecutorRegistry as U, createActivityLog as Ut, ExecutorContext as V, ScopeProgressInput as Vt, ExecutorResult as W, readWorkerProgress as Wt, Restart as X, NodeStatus as Y, ResultBlobStore as Z, CheckpointRequest as _, WidenGate as _t, AgentEnvironmentProviderRef as a, SpawnEvent as at, ExecResult as b, WaitProbe as bt, AgentEnvironmentStatus as c, SpawnPrior as ct, AgentSession as d, SupervisedResult as dt, RootHandle as et, AgentSessionRef as f, Supervisor as ft, CheckpointRef as g, WaitOpts as gt, AgentTurnResult as h, UsageEvent as ht, AgentEnvironmentProvider$1 as i, Settled as it, resolveAgentEnvironmentProvider as j, SessionTraceBox as jt, providerAsExecutor as k, waitUntil as kt, AgentEnvironmentSummary as l, SpawnRejection as lt, AgentTurnInput$1 as m, TreeView as mt, AgentEnvironmentCapabilities$1 as n, Runtime as nt, AgentEnvironmentProviderRegistry as o, SpawnJournal as ot, AgentSessionStatus as p, SupervisorOpts as pt, NodeId as q, AgentEnvironmentEvent as r, Scope as rt, AgentEnvironmentQuery as s, SpawnOpts as st, AgentEnvironment as t, RootSignal as tt, AgentProfileRef$1 as u, Spend as ut, CreateAgentEnvironmentInput$1 as v, PendingWait as vt, ProviderExecutorOptions as w, createWaitProbes as wt, ForkRequest as x, WaitProbeRegistry as xt, ExecRequest as y, WaitOutcome as yt, DefaultVerdict as z, DEFAULT_STALL_AFTER_MS as zt };
1127
- //# sourceMappingURL=environment-provider-Cygthiy3.d.ts.map
1487
+ export { ResumedWork as $, createRuntimeEventCollector as $t, providerAsSandboxClient as A, readWorkerProgress as An, EvalRunsExportResult as At, Executor as B, buildRuntimeEventOtelSpans as Bt, ProviderAsSandboxClientOptions as C, ActivityLog as Cn, TraceContext as Ct, WorkspaceRequest as D, ScopeProgressInput as Dn, EvalRunEvent as Dt, SandboxClientProviderOptions as E, ExecutorProgress as En, traceContextToEnv as Et, createTangleSandboxExactProcessProvider as F, OtelExporter as Ft, Handle as G, toOtelAttributes as Gt, ExecutorFactory as H, exportEvalRuns as Ht, Agent as I, OtelSpan as It, NodeSnapshot as J, RuntimeStreamEventSink as Jt, NoWinnerError as K, RuntimeEventCollector as Kt, AgentSpec as L, RuntimeEventOtelOptions as Lt, sandboxClientAsProvider as M, LoopSpanNode as Mt, CreateTangleSandboxExactProcessProviderOptions as N, OtelAttribute as Nt, createAgentEnvironmentProviderRegistry as O, WorkerProgress as On, EvalRunGeneration as Ot, SandboxControlClient as P, OtelExportConfig as Pt, ResumedKeyState as Q, SanitizedKnowledgeRequirement as Qt, Budget as R, buildLoopOtelSpans as Rt, PlacementInfo as S, sandboxSessionTraceSource as Sn, workerTraceSeamKey as St, ResourceRequest as T, DEFAULT_STALL_AFTER_MS as Tn, readTraceContextFromEnv as Tt, ExecutorRegistry as U, generateSpanId as Ut, ExecutorContext as V, createOtelExporter as Vt, ExecutorResult as W, loopEventToOtelSpan as Wt, Restart as X, RuntimeTelemetryOptions as Xt, NodeStatus as Y, RuntimeStreamEventSummary as Yt, ResultBlobStore as Z, SanitizedKnowledgeReadinessReport as Zt, CheckpointRequest as _, SessionTraceBox as _n, WidenGate as _t, AgentEnvironmentProviderRef as a, WaitOutcome as an, SpawnEvent as at, ExecResult as b, createPushTraceSource as bn, readWorkerTraceContext as bt, AgentEnvironmentStatus as c, WaitRejection as cn, SpawnPrior as ct, AgentSession as d, isWaitOutcome as dn, SupervisedResult as dt, createRuntimeStreamEventCollector as en, RootHandle as et, AgentSessionRef as f, pollFor as fn, Supervisor as ft, CheckpointRef as g, SessionMessageLike as gn, WaitOpts as gt, AgentTurnResult as h, waitUntil as hn, UsageEvent as ht, AgentEnvironmentProvider$1 as i, PendingWait as in, Settled as it, resolveAgentEnvironmentProvider as j, INTELLIGENCE_WIRE_VERSION as jt, providerAsExecutor as k, createActivityLog as kn, EvalRunsExportConfig as kt, AgentEnvironmentSummary as l, WaitSpec as ln, SpawnRejection as lt, AgentTurnInput$1 as m, validateWaitSpec as mn, TreeView as mt, AgentEnvironmentCapabilities$1 as n, sanitizeKnowledgeReadinessReport as nn, Runtime as nt, AgentEnvironmentProviderRegistry as o, WaitProbe as on, SpawnJournal as ot, AgentSessionStatus as p, timerAt as pn, SupervisorOpts as pt, NodeId as q, RuntimeStreamEventCollector as qt, AgentEnvironmentEvent as r, sanitizeRuntimeStreamEvent as rn, Scope as rt, AgentEnvironmentQuery as s, WaitProbeRegistry as sn, SpawnOpts as st, AgentEnvironment as t, sanitizeAgentRuntimeEvent as tn, RootSignal as tt, AgentProfileRef$1 as u, createWaitProbes as un, Spend as ut, CreateAgentEnvironmentInput$1 as v, ToolStepInput as vn, WorkerTraceResolver as vt, ProviderExecutorOptions as w, ActivityNote as wn, createPropagatingTraceEmitter as wt, ForkRequest as x, decodeToolPart as xn, workerTraceEnv as xt, ExecRequest as y, TraceSource as yn, WorkerTraceSeamCarrier as yt, DefaultVerdict as z, buildLoopSpanNodes as zt };
1488
+ //# sourceMappingURL=environment-provider-CWsRh6Uz.d.ts.map
@@ -1,2 +1,2 @@
1
- import { A as providerAsSandboxClient, C as ProviderAsSandboxClientOptions, D as WorkspaceRequest, E as SandboxClientProviderOptions, F as createTangleSandboxExactProcessProvider, M as sandboxClientAsProvider, N as CreateTangleSandboxExactProcessProviderOptions, O as createAgentEnvironmentProviderRegistry, S as PlacementInfo, T as ResourceRequest, _ as CheckpointRequest, a as AgentEnvironmentProviderRef, b as ExecResult, c as AgentEnvironmentStatus, d as AgentSession, f as AgentSessionRef, g as CheckpointRef, h as AgentTurnResult, i as AgentEnvironmentProvider, j as resolveAgentEnvironmentProvider, k as providerAsExecutor, l as AgentEnvironmentSummary, m as AgentTurnInput, n as AgentEnvironmentCapabilities, o as AgentEnvironmentProviderRegistry, p as AgentSessionStatus, r as AgentEnvironmentEvent, s as AgentEnvironmentQuery, t as AgentEnvironment, u as AgentProfileRef, v as CreateAgentEnvironmentInput, w as ProviderExecutorOptions, x as ForkRequest, y as ExecRequest } from "./environment-provider-Cygthiy3.js";
1
+ import { A as providerAsSandboxClient, C as ProviderAsSandboxClientOptions, D as WorkspaceRequest, E as SandboxClientProviderOptions, F as createTangleSandboxExactProcessProvider, M as sandboxClientAsProvider, N as CreateTangleSandboxExactProcessProviderOptions, O as createAgentEnvironmentProviderRegistry, S as PlacementInfo, T as ResourceRequest, _ as CheckpointRequest, a as AgentEnvironmentProviderRef, b as ExecResult, c as AgentEnvironmentStatus, d as AgentSession, f as AgentSessionRef, g as CheckpointRef, h as AgentTurnResult, i as AgentEnvironmentProvider, j as resolveAgentEnvironmentProvider, k as providerAsExecutor, l as AgentEnvironmentSummary, m as AgentTurnInput, n as AgentEnvironmentCapabilities, o as AgentEnvironmentProviderRegistry, p as AgentSessionStatus, r as AgentEnvironmentEvent, s as AgentEnvironmentQuery, t as AgentEnvironment, u as AgentProfileRef, v as CreateAgentEnvironmentInput, w as ProviderExecutorOptions, x as ForkRequest, y as ExecRequest } from "./environment-provider-CWsRh6Uz.js";
2
2
  export { type AgentEnvironment, type AgentEnvironmentCapabilities, type AgentEnvironmentEvent, type AgentEnvironmentProvider, AgentEnvironmentProviderRef, AgentEnvironmentProviderRegistry, type AgentEnvironmentQuery, type AgentEnvironmentStatus, type AgentEnvironmentSummary, type AgentProfileRef, type AgentSession, type AgentSessionRef, type AgentSessionStatus, type AgentTurnInput, type AgentTurnResult, type CheckpointRef, type CheckpointRequest, type CreateAgentEnvironmentInput, type CreateTangleSandboxExactProcessProviderOptions, type ExecRequest, type ExecResult, type ForkRequest, type PlacementInfo, ProviderAsSandboxClientOptions, ProviderExecutorOptions, type ResourceRequest, SandboxClientProviderOptions, type WorkspaceRequest, createAgentEnvironmentProviderRegistry, createTangleSandboxExactProcessProvider, providerAsExecutor, providerAsSandboxClient, resolveAgentEnvironmentProvider, sandboxClientAsProvider };
@@ -1,7 +1,7 @@
1
1
  import { i as ConfigError } from "./errors-DEAvWQPy.js";
2
2
  import { $ as parseExactAgentProfile, G as agentCandidateProfileAsAgentProfile, J as candidateMaterializerHarness, K as applyExactAgentProfileDiff, Q as parseAgentCandidateProfileActivation, Y as createAgentCandidateProfileActivation, Z as omitUndefinedObjectFields, ct as omitTopLevelDigest, d as verifiedResourceTextByDigest, f as verifyAgentCandidateBundle, it as canonicalCandidateDocument, n as executePreparedAgentCandidate, nt as canonicalCandidateBytes, q as assertCandidateProfileBinding, rt as canonicalCandidateDigest$1, st as immutableCandidateValue, t as prepareAgentCandidateExecution, ut as verifyCanonicalCandidateDocument } from "./prepare-BHQBb02e.js";
3
- import { D as runSettledCommand, F as runLocalHarness, N as harnessInvocation } from "./supervisor-CspDspod.js";
4
- import { E as optimizerMethod, a as defaultStructuralRolloutPolicy } from "./structural-rollout-Cqm1dKa7.js";
3
+ import { J as runSettledCommand, et as harnessInvocation, nt as runLocalHarness } from "./supervisor-BBbPBXpe.js";
4
+ import { E as optimizerMethod, a as defaultStructuralRolloutPolicy } from "./structural-rollout-CVY_0hJp.js";
5
5
  import { t as runAnalystLoop } from "./analyst-loop-BoNIG2hA.js";
6
6
  import { CostLedger, canonicalJson, makeProposalFinding } from "@tangle-network/agent-eval";
7
7
  import { campaignScenarioIdentity, campaignSplitDigestFromIdentities, compareOptimizationMethods, gitWorktreeAdapter, verifyCodeSurface } from "@tangle-network/agent-eval/campaign";
@@ -2848,4 +2848,4 @@ function sameOrderedValues(left, right) {
2848
2848
  //#endregion
2849
2849
  export { improve as A, agenticGenerator as B, agentImprovementTargetInput as C, buildAgentImprovementActivationTargets as D, assertProfileImprovementTargetsShareIdentity as E, normalizeRolloutPolicy as F, summarizeFindings as G, defaultBuildPrompt as H, parseRolloutPolicy as I, worktreeChangedPaths as K, serializeRolloutPolicy as L, rawTraceDistiller as M, ROLLOUT_POLICY_EXTENSION as N, isAgentImprovementProfileSurface as O, applyRolloutPolicyToProfile as P, structuralRolloutPolicyFromProfile as R, agentImprovementTargetDigest as S, agentProfileImprovementStateDigest as T, rawTraceEvidenceProblem as U, commandVerifier as V, requiresRawTraceEvidence as W, AGENT_IMPROVEMENT_PROFILE_SURFACES as _, executeAgentCandidateExperimentCell as a, agentImprovementProfileSurfaceDigest as b, requireSealedCandidateExperiment as c, verifyAgentImprovementActivation as d, verifyAgentImprovementProposal as f, optimizationActivationReceiptFromMetadata as g, createOptimizationActivationReceipt as h, createAgentImprovementProposal as i, withMethodRuntimeControls as j, isAgentProfileMeasuredSurface as k, reviewAgentImprovementProposal as l, verifyCandidateExecutionEvidence as m, createAgentImprovementActivation as n, proposeAgentImprovement as o, verifyAgentImprovementReview as p, createAgentImprovementMeasuredComparison as r, proposeAgentProfileImprovement as s, AgentCandidateExperimentCellExecutionError as t, runAgentCandidateExperiment as u, AGENT_PROFILE_MEASURED_SURFACES as v, agentImprovementTargetProfileDiffs as w, agentImprovementProfileSurfaceInput as x, agentImprovementProfileDiffs as y, AGENTIC_PROFILE_RESOURCE_ROOT as z };
2850
2850
 
2851
- //# sourceMappingURL=improvement-cycle-CBLOgfsQ.js.map
2851
+ //# sourceMappingURL=improvement-cycle-C1cmjvPD.js.map