@tangle-network/agent-runtime 9.0.15 → 10.0.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 (93) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/dist/{activation-y6NAn3sW.d.ts → activation-CDlOqX5a.d.ts} +7 -8
  3. package/dist/{activation-DTVc4eVS.js → activation-CEGkyzEG.js} +2 -2
  4. package/dist/{activation-DTVc4eVS.js.map → activation-CEGkyzEG.js.map} +1 -1
  5. package/dist/agent.d.ts +1 -1
  6. package/dist/agent.js +3 -3
  7. package/dist/candidate-execution/index.d.ts +3 -0
  8. package/dist/candidate-execution/index.js +10 -3
  9. package/dist/candidate-execution/index.js.map +1 -1
  10. package/dist/{delegate-DigGceAE.js → delegate-V2Nz8GgO.js} +2 -2
  11. package/dist/{delegate-DigGceAE.js.map → delegate-V2Nz8GgO.js.map} +1 -1
  12. package/dist/{coordination-manager-mGr9UHYk.js → driver-control-acknowledgers-CJDYLJmW.js} +1042 -1042
  13. package/dist/driver-control-acknowledgers-CJDYLJmW.js.map +1 -0
  14. package/dist/durable.d.ts +5 -5
  15. package/dist/durable.js +13 -13
  16. package/dist/durable.js.map +1 -1
  17. package/dist/{failure-cause-WifbY42M.js → failure-cause-BI7cfDWx.js} +14 -2
  18. package/dist/failure-cause-BI7cfDWx.js.map +1 -0
  19. package/dist/{graph-registry-B_1C7qye.js → graph-registry-DxhlgHdA.js} +1 -1
  20. package/dist/{graph-registry-BbZN5deo.js → graph-registry-j9t9J0KT.js} +11 -12
  21. package/dist/{graph-registry-BbZN5deo.js.map → graph-registry-j9t9J0KT.js.map} +1 -1
  22. package/dist/{graph-D2DFmNIP.js → graph-wJOMQ1kC.js} +8 -8
  23. package/dist/{graph-D2DFmNIP.js.map → graph-wJOMQ1kC.js.map} +1 -1
  24. package/dist/{improve-DoANtwjC.js → improve-DOjywiPq.js} +42 -26
  25. package/dist/{improve-DoANtwjC.js.map → improve-DOjywiPq.js.map} +1 -1
  26. package/dist/index.d.ts +38 -6
  27. package/dist/index.js +59 -20
  28. package/dist/index.js.map +1 -1
  29. package/dist/intelligence.d.ts +93 -63
  30. package/dist/intelligence.js +166 -73
  31. package/dist/intelligence.js.map +1 -1
  32. package/dist/kernel.d.ts +3 -3
  33. package/dist/kernel.js +16 -15
  34. package/dist/{loop-runner-CVI07sjG.js → loop-runner-CPTOzSol.js} +2 -2
  35. package/dist/{loop-runner-CVI07sjG.js.map → loop-runner-CPTOzSol.js.map} +1 -1
  36. package/dist/{loop-runner-CfMOsISJ.d.ts → loop-runner-DwxZbYW5.d.ts} +2 -2
  37. package/dist/loop-runner-bin.d.ts +1 -1
  38. package/dist/loop-runner-bin.js +1 -1
  39. package/dist/mcp/bin.js +3 -3
  40. package/dist/mcp/index.d.ts +1 -1
  41. package/dist/mcp/index.js +7 -7
  42. package/dist/mcp/memory-bin.js +1 -1
  43. package/dist/{model-policy-CZwhXp8O.js → model-policy-CqDuBTq-.js} +12 -2
  44. package/dist/model-policy-CqDuBTq-.js.map +1 -0
  45. package/dist/{prepare-Cw4ZaN01.js → prepare-DT-ibRsm.js} +2 -2
  46. package/dist/{prepare-Cw4ZaN01.js.map → prepare-DT-ibRsm.js.map} +1 -1
  47. package/dist/profiles.d.ts +1 -1
  48. package/dist/profiles.js +1 -1
  49. package/dist/{provision-supervisor-BH6Fxf7H.js → provision-supervisor-B1_Kow9m.js} +6 -6
  50. package/dist/{provision-supervisor-BH6Fxf7H.js.map → provision-supervisor-B1_Kow9m.js.map} +1 -1
  51. package/dist/{run-cancellation-DHuvsgzo.js → run-cancellation-D5m6JHPH.js} +2 -2
  52. package/dist/{run-cancellation-DHuvsgzo.js.map → run-cancellation-D5m6JHPH.js.map} +1 -1
  53. package/dist/{run-state-CE2rffEV.js → run-state-DKOXe08H.js} +5 -5
  54. package/dist/{run-state-CE2rffEV.js.map → run-state-DKOXe08H.js.map} +1 -1
  55. package/dist/{runtime-PNBuLZxE.js → runtime-C5cWSMqU.js} +191 -24
  56. package/dist/runtime-C5cWSMqU.js.map +1 -0
  57. package/dist/{search-executor-CNxDTuV3.js → search-executor-CA6fTYWz.js} +5 -5
  58. package/dist/{search-executor-CNxDTuV3.js.map → search-executor-CA6fTYWz.js.map} +1 -1
  59. package/dist/{server-CfJ_WYXR.js → server-C8Z3vYdI.js} +4 -4
  60. package/dist/{server-CfJ_WYXR.js.map → server-C8Z3vYdI.js.map} +1 -1
  61. package/dist/{settle-record-einetd2l.js → settle-record-BDxPAO4m.js} +2 -2
  62. package/dist/{settle-record-einetd2l.js.map → settle-record-BDxPAO4m.js.map} +1 -1
  63. package/dist/{structural-rollout-BH_MWOy0.js → structural-rollout-B0HPcP9G.js} +5 -5
  64. package/dist/{structural-rollout-BH_MWOy0.js.map → structural-rollout-B0HPcP9G.js.map} +1 -1
  65. package/dist/{supervise-CM5cXyuf.js → supervise-Dvj-8S6D.js} +2341 -2283
  66. package/dist/supervise-Dvj-8S6D.js.map +1 -0
  67. package/dist/{supervision-discovery-BZRsXavN.js → supervision-discovery-CbrwcgJy.js} +3 -3
  68. package/dist/{supervision-discovery-BZRsXavN.js.map → supervision-discovery-CbrwcgJy.js.map} +1 -1
  69. package/dist/{supervisor-C3Fv97vT.js → supervisor-DwdeUC2l.js} +218 -47
  70. package/dist/supervisor-DwdeUC2l.js.map +1 -0
  71. package/dist/{supervisor-accounting-6O0Hr0Fg.js → supervisor-accounting-C48Yo9QC.js} +526 -348
  72. package/dist/supervisor-accounting-C48Yo9QC.js.map +1 -0
  73. package/dist/testing.d.ts +1 -1
  74. package/dist/testing.js +11 -11
  75. package/dist/{tool-server-CirrqFlr.js → tool-server-DsCeBr-C.js} +2 -2
  76. package/dist/{tool-server-CirrqFlr.js.map → tool-server-DsCeBr-C.js.map} +1 -1
  77. package/dist/{top-web-CRe6c8wu.js → top-web-CTOq4psb.js} +6 -6
  78. package/dist/{top-web-CRe6c8wu.js.map → top-web-CTOq4psb.js.map} +1 -1
  79. package/dist/tui/bin.js +3 -3
  80. package/dist/tui/index.d.ts +1 -1
  81. package/dist/tui/index.js +2 -2
  82. package/dist/{types-_j53efrk.d.ts → types-lnF0wIJW.d.ts} +8245 -8153
  83. package/dist/{workspace-streams-BakRr-Pl.js → workspace-streams-C7PGLAUd.js} +3 -3
  84. package/dist/workspace-streams-C7PGLAUd.js.map +1 -0
  85. package/package.json +6 -5
  86. package/dist/coordination-manager-mGr9UHYk.js.map +0 -1
  87. package/dist/failure-cause-WifbY42M.js.map +0 -1
  88. package/dist/model-policy-CZwhXp8O.js.map +0 -1
  89. package/dist/runtime-PNBuLZxE.js.map +0 -1
  90. package/dist/supervise-CM5cXyuf.js.map +0 -1
  91. package/dist/supervisor-C3Fv97vT.js.map +0 -1
  92. package/dist/supervisor-accounting-6O0Hr0Fg.js.map +0 -1
  93. package/dist/workspace-streams-BakRr-Pl.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { $u as IsolatedCheckResult, $y as createRuntimeEventCollector, AC as AgentEvalError, By as OtelExportStats, C as RuntimeFailureCause, CC as RuntimeRunPersistenceAdapter, EC as startRuntimeRun, FC as NotFoundError, Gy as loopEventToOtelSpan, Hy as OtelSpan, IC as ValidationError, Ib as SupervisedResult, Jy as RuntimeStreamEventSink, Ky as RuntimeEventCollector, MC as BackendTransportError, NC as ConfigError, OC as Redactor, PC as JudgeError, Qy as SanitizedKnowledgeRequirement, Ry as OtelAttribute, S as RuntimeStreamEvent, SC as RuntimeRunOptions, Su as SuperviseOptions, T as RuntimeFailureOwner, TC as RuntimeRunStatus, Uy as buildLoopOtelSpans, Vy as OtelExporter, Wy as createOtelExporter, Xu as IsolatedCheckBoxEvidence, Xy as RuntimeTelemetryOptions, Yy as RuntimeStreamEventSummary, Zy as SanitizedKnowledgeReadinessReport, _ as RunAgentTaskOptions, a as AgentKnowledgeProvider, b as RuntimeSession, bC as RuntimeRunCost, bp as ExecutorConfig, c as AgentTaskContext, cf as SupervisorProfile, d as AgentTaskStatus, eb as createRuntimeStreamEventCollector, g as OpenAIChatToolChoice, h as OpenAIChatTool, hx as ExecutorFactory, i as AgentExecutionBackend, jC as AgentEvalErrorCode, l as AgentTaskRunResult, m as OpenAIChatResponseFormat, n as AgentBackendContext, o as AgentRuntimeEvent, p as KnowledgeReadinessDecision, qy as RuntimeStreamEventCollector, r as AgentBackendInput, s as AgentRuntimeEventSink, t as AgentAdapter, tb as sanitizeKnowledgeReadinessReport, u as AgentTaskSpec, ub as Budget, v as RunAgentTaskStreamOptions, w as RuntimeFailureCode, wC as RuntimeRunRow, x as RuntimeSessionStore, xC as RuntimeRunHandle, y as RuntimeCanonicalStreamEvent, yC as RuntimeRunCompleteInput, zy as OtelExportConfig } from "./types-_j53efrk.js";
2
- import { $ as ImproveCodeBaseOptions, $t as CandidateGenerator, At as SearchPromotion, B as DecideSearchImprovementOptions, Bt as sharedBoxLane, Ct as ImproveSearchOptions, Dt as ImprovementCodeCandidate, Et as ImproveSurface, Ft as SearchLaneOptions, G as ImproveTrainingOptions, Gt as AgenticGeneratorOptions, H as decideSearchImprovement, Ht as DeepReadonly, It as SearchTraceOptions, J as ProfileTrainerRequest, Jt as AgenticGeneratorShotReceipt, K as ImproveTrainingResult, Kt as AgenticGeneratorShotDisposition, L as improve, Lt as SharedBoxSearchLane, Mt as SearchEnvironmentFault, Nt as SearchLane, Ot as ImprovementProfileCandidate, Pt as SearchLaneKind, Q as ImproveCandidateValidator, Qt as commandVerifier, R as SearchMethodOptions, Rt as dedicatedLane, St as ImproveSearchMethod, Tt as ImproveSkillsOptions, U as CheckpointServingPort, Ut as ReadonlyAgentProfile, V as SearchImprovementDecision, Vt as subscriptionLane, W as ControlledTrainingCommand, Wt as AgenticGeneratorExecutorForWorktree, X as createCommandProfileTrainer, Xt as VerifyResult, Y as TrainingBoundaryResult, Yt as Verifier, Z as ImproveCandidateValidationInput, Zt as agenticGenerator, at as ImproveLineage, bt as ImproveSearchAgent, ct as ImproveMethodLineage, dt as ImproveMethodSource, et as ImproveCodeOptions, ft as ImproveOptimizationRunOptions, gt as ImproveProfileSurface, ht as ImproveProfileComponents, i as AgentImprovementActivationTransition, it as ImproveCustomCodeGeneratorOptions, jt as SearchCellContext, kt as SearchDispatchContext, lt as ImproveMethodOptions, mt as ImproveProfileAgent, n as AgentImprovementActivationResultStore, nt as ImproveCodeRunOptions, ot as ImproveMethodContext, q as ProfileTrainer, qt as AgenticGeneratorShotExecution, rt as ImproveCost, st as ImproveMethodFactory, t as AgentImprovementActivationReconciliation, tt as ImproveCodeResult, ut as ImproveMethodResult, vt as ImproveRuntimeCodeGeneratorOptions, wt as ImproveSearchResult, xt as ImproveSearchIdentity, yt as ImproveScenarioPartitions, z as searchMethod, zt as routerLane } from "./activation-y6NAn3sW.js";
1
+ import { Ay as SanitizedKnowledgeReadinessReport, Bi as DeepReadonly, C as RuntimeFailureCause, Cy as createOtelExporter, Dy as RuntimeStreamEventSink, Ey as RuntimeStreamEventCollector, Lf as IsolatedCheckResult, My as createRuntimeEventCollector, Ny as createRuntimeStreamEventCollector, Oy as RuntimeStreamEventSummary, Pf as IsolatedCheckBoxEvidence, Py as sanitizeKnowledgeReadinessReport, S as RuntimeStreamEvent, Sy as buildLoopOtelSpans, T as RuntimeFailureOwner, Ty as RuntimeEventCollector, Vi as ReadonlyAgentProfile, _ as RunAgentTaskOptions, _w as RuntimeRunPersistenceAdapter, _y as OtelAttribute, a as AgentKnowledgeProvider, aS as ConfigError, b as RuntimeSession, bw as startRuntimeRun, by as OtelExporter, c as AgentTaskContext, cS as ValidationError, d as AgentTaskStatus, dS as ExecutorFactory, eS as Redactor, fm as SupervisorProfile, g as OpenAIChatToolChoice, gw as RuntimeRunOptions, h as OpenAIChatTool, hw as RuntimeRunHandle, i as AgentExecutionBackend, iS as BackendTransportError, if as SuperviseOptions, jy as SanitizedKnowledgeRequirement, kt as SupervisedResult, ky as RuntimeTelemetryOptions, l as AgentTaskRunResult, m as OpenAIChatResponseFormat, mw as RuntimeRunCost, n as AgentBackendContext, nS as AgentEvalError, o as AgentRuntimeEvent, oS as JudgeError, p as KnowledgeReadinessDecision, pw as RuntimeRunCompleteInput, r as AgentBackendInput, rS as AgentEvalErrorCode, rt as Budget, s as AgentRuntimeEventSink, sS as NotFoundError, t as AgentAdapter, u as AgentTaskSpec, v as RunAgentTaskStreamOptions, vw as RuntimeRunRow, vy as OtelExportConfig, w as RuntimeFailureCode, wh as ExecutorConfig, wy as loopEventToOtelSpan, x as RuntimeSessionStore, xy as OtelSpan, y as RuntimeCanonicalStreamEvent, yw as RuntimeRunStatus, yy as OtelExportStats } from "./types-lnF0wIJW.js";
2
+ import { $ as ImproveCodeBaseOptions, At as SearchPromotion, B as DecideSearchImprovementOptions, Bt as sharedBoxLane, Ct as ImproveSearchOptions, Dt as ImprovementCodeCandidate, Et as ImproveSurface, Ft as SearchLaneOptions, G as ImproveTrainingOptions, Gt as AgenticGeneratorShotExecution, H as decideSearchImprovement, Ht as AgenticGeneratorExecutorForWorktree, It as SearchTraceOptions, J as ProfileTrainerRequest, Jt as VerifyResult, K as ImproveTrainingResult, Kt as AgenticGeneratorShotReceipt, L as improve, Lt as SharedBoxSearchLane, Mt as SearchEnvironmentFault, Nt as SearchLane, Ot as ImprovementProfileCandidate, Pt as SearchLaneKind, Q as ImproveCandidateValidator, R as SearchMethodOptions, Rt as dedicatedLane, St as ImproveSearchMethod, Tt as ImproveSkillsOptions, U as CheckpointServingPort, Ut as AgenticGeneratorOptions, V as SearchImprovementDecision, Vt as subscriptionLane, W as ControlledTrainingCommand, Wt as AgenticGeneratorShotDisposition, X as createCommandProfileTrainer, Xt as commandVerifier, Y as TrainingBoundaryResult, Yt as agenticGenerator, Z as ImproveCandidateValidationInput, Zt as CandidateGenerator, at as ImproveLineage, bt as ImproveSearchAgent, ct as ImproveMethodLineage, dt as ImproveMethodSource, et as ImproveCodeOptions, ft as ImproveOptimizationRunOptions, gt as ImproveProfileSurface, ht as ImproveProfileComponents, i as AgentImprovementActivationTransition, it as ImproveCustomCodeGeneratorOptions, jt as SearchCellContext, kt as SearchDispatchContext, lt as ImproveMethodOptions, mt as ImproveProfileAgent, n as AgentImprovementActivationResultStore, nt as ImproveCodeRunOptions, ot as ImproveMethodContext, q as ProfileTrainer, qt as Verifier, rt as ImproveCost, st as ImproveMethodFactory, t as AgentImprovementActivationReconciliation, tt as ImproveCodeResult, ut as ImproveMethodResult, vt as ImproveRuntimeCodeGeneratorOptions, wt as ImproveSearchResult, xt as ImproveSearchIdentity, yt as ImproveScenarioPartitions, z as searchMethod, zt as routerLane } from "./activation-CDlOqX5a.js";
3
3
  import { i as SurfaceImprovementEdit } from "./improvement-adapter-D5GRU1eY.js";
4
4
  import { a as ImprovementProposalSource } from "./types-qsqfyQoY.js";
5
5
  import { T as AgentCandidateOutputArtifactPort } from "./workspace-archive-DS9E9tUr.js";
6
- import { i as auditLoopRunner, r as DelegatedLoopRunner } from "./loop-runner-CfMOsISJ.js";
6
+ import { i as auditLoopRunner, r as DelegatedLoopRunner } from "./loop-runner-DwxZbYW5.js";
7
7
  import { a as RuntimeHookContext, c as RuntimeHookPhase, d as composeRuntimeHooks, f as defineRuntimeHooks, i as RuntimeExecutionAdmittedPayload, l as RuntimeHookTarget, o as RuntimeHookErrorContext, s as RuntimeHookEvent, u as RuntimeHooks } from "./runtime-hooks-DPghSHV7.js";
8
8
  import { toW3CSpanId as padSpanId, toW3CTraceId as padTraceId } from "@tangle-network/agent-trace-contract";
9
9
  import { AgentCandidateBundle, AgentCandidateCapturedArtifact, AgentCandidateKnowledge, AgentProfile, Sha256Digest } from "@tangle-network/agent-interface";
@@ -11,7 +11,7 @@ import { AgentProfile as AgentProfile$1, ControlBudget, ControlDecision, Control
11
11
  import { ZodType } from "zod";
12
12
  import { GepaOptimizationMethodConfig, MutableSurface, ProfileDispatchFn, Scenario, SearchScoredCell, SkillOptOptimizationMethodConfig, SurfaceProposer } from "@tangle-network/agent-eval/campaign";
13
13
  import { Scenario as Scenario$1 } from "@tangle-network/agent-eval/contract";
14
- import { KnowledgeImprovementOptions, KnowledgeImprovementResult, PromoteKnowledgeCandidateOptions } from "@tangle-network/agent-knowledge";
14
+ import { KnowledgeImprovementCandidateRef, KnowledgeImprovementOptions, KnowledgeImprovementResult, PromoteKnowledgeCandidateOptions } from "@tangle-network/agent-knowledge";
15
15
  /** Wrap any custom async-iterable stream into a typed `AgentExecutionBackend`. @stable */
16
16
  export declare function createIterableBackend<TInput extends AgentBackendInput>(options: {
17
17
  kind: string;
@@ -623,6 +623,26 @@ type KnowledgeReadinessCheckResult = boolean | {
623
623
  metadata?: Record<string, unknown>;
624
624
  };
625
625
  type KnowledgeReadinessCheck = (input: KnowledgeReadinessCheckInput) => Promise<KnowledgeReadinessCheckResult> | KnowledgeReadinessCheckResult;
626
+ interface SupervisedKnowledgeUpdateOptions {
627
+ root: string;
628
+ goal: string;
629
+ readiness: KnowledgeReadinessCheck;
630
+ readinessSpecs?: readonly unknown[];
631
+ readinessTaskId?: string;
632
+ readinessOptions?: unknown;
633
+ findings?: readonly unknown[];
634
+ metadata?: Record<string, unknown>;
635
+ budget: Budget;
636
+ backend?: ExecutorConfig;
637
+ makeWorkerAgent?: SuperviseOptions['makeWorkerAgent'];
638
+ /** Caller-owned exact supervisor harness/provider/model identity. */
639
+ supervisorProfile: SupervisorProfile;
640
+ superviseOptions?: Partial<Omit<SuperviseOptions, 'budget' | 'backend' | 'deliverable' | 'makeWorkerAgent' | 'allowedModels'>>;
641
+ allowedModels?: readonly string[];
642
+ runSupervised?: (profile: SupervisorProfile, task: unknown, opts: SuperviseOptions,
643
+ /** Exact isolated update workspace; never infer this authority from task text. */
644
+ context?: Readonly<Pick<SupervisedKnowledgeUpdateOptions, 'root' | 'goal'>>) => Promise<SupervisedResult<unknown>>;
645
+ }
626
646
  interface RunKnowledgeImprovementJobOptions extends Omit<KnowledgeImprovementOptions, 'updateKnowledge'> {
627
647
  budget: Budget;
628
648
  readinessCheck?: KnowledgeReadinessCheck;
@@ -631,7 +651,7 @@ interface RunKnowledgeImprovementJobOptions extends Omit<KnowledgeImprovementOpt
631
651
  supervisorProfile: SupervisorProfile;
632
652
  superviseOptions?: Partial<Omit<SuperviseOptions, 'budget' | 'backend' | 'deliverable' | 'makeWorkerAgent' | 'allowedModels'>>;
633
653
  allowedModels?: readonly string[];
634
- runSupervised?: (profile: SupervisorProfile, task: unknown, opts: SuperviseOptions) => Promise<SupervisedResult<unknown>>;
654
+ runSupervised?: SupervisedKnowledgeUpdateOptions['runSupervised'];
635
655
  candidateArtifacts?: AgentCandidateOutputArtifactPort;
636
656
  onMeasurement?: (measurement: KnowledgeImprovementJobMeasurement) => Promise<void> | void;
637
657
  }
@@ -645,6 +665,8 @@ interface KnowledgeImprovementJobMeasurement {
645
665
  iterations: number;
646
666
  inputTokens: number;
647
667
  outputTokens: number;
668
+ /** Missing on older owners means unavailable completeness, not proven-known usage. */
669
+ tokensKnown?: boolean;
648
670
  usdKnown: boolean;
649
671
  usd: number;
650
672
  ms: number;
@@ -671,6 +693,16 @@ interface KnowledgeImprovementExperimentBundles {
671
693
  export declare function runKnowledgeImprovementJob(options: RunKnowledgeImprovementJobOptions): Promise<KnowledgeImprovementJobResult>;
672
694
  /** Attach both frozen knowledge inputs to one otherwise-identical bundle pair. */
673
695
  export declare function buildKnowledgeImprovementExperimentBundles(bundle: AgentCandidateBundle, knowledge: KnowledgeImprovementCandidatePair): KnowledgeImprovementExperimentBundles;
696
+ /** Capture an already measured Knowledge candidate and its original baseline.
697
+ * The Knowledge owner revalidates the exact reference, evidence and isolated
698
+ * bytes before Runtime freezes the existing execution snapshot contracts.
699
+ * This does not update, evaluate or promote the curated Knowledge store. */
700
+ export declare function captureKnowledgeImprovementCandidatePair(options: {
701
+ root: string;
702
+ candidate: KnowledgeImprovementCandidateRef;
703
+ artifacts?: AgentCandidateOutputArtifactPort;
704
+ signal?: AbortSignal;
705
+ }): Promise<KnowledgeImprovementCandidatePair>;
674
706
  /**
675
707
  *
676
708
  * Chat-model resolution + catalog validation — the shared primitive every
@@ -825,5 +857,5 @@ interface ServerSentEventOptions {
825
857
  export declare function readinessServerSentEvent(report: KnowledgeReadinessReport$1, options?: RuntimeTelemetryOptions & ServerSentEventOptions): string;
826
858
  /** Serialize a `RuntimeStreamEvent` as a Server-Sent Event string. @stable */
827
859
  export declare function runtimeStreamServerSentEvent(event: RuntimeStreamEvent, options?: RuntimeTelemetryOptions & ServerSentEventOptions): string;
828
- export { type AgentAdapter, type AgentBackendContext, type AgentBackendInput, AgentEvalError, type AgentEvalErrorCode, type AgentExecutionBackend, type AgentImprovementActivationReconciliation, type AgentImprovementActivationResultStore, type AgentImprovementActivationTransition, type AgentKnowledgeProvider, type AgentRuntimeEvent, type AgentRuntimeEventSink, type AgentTaskContext, type AgentTaskRunResult, type AgentTaskSpec, type AgentTaskStatus, type AgenticGeneratorExecutorForWorktree, type AgenticGeneratorOptions, type AgenticGeneratorShotDisposition, type AgenticGeneratorShotExecution, type AgenticGeneratorShotReceipt, type AuthSource, type BackendCallPolicy, BackendTransportError, type CandidateGenerator, type ChatModelCandidate, type ChatModelValidation, type CheckpointServingPort, type CircuitBreakerConfig, ConfigError, type ControlBudget, type ControlDecision, type ControlEvalResult, type ControlRunResult, type ControlStep, type ControlledTrainingCommand, type Conversation, type ConversationDriveState, type ConversationParticipant, type ConversationPolicy, type ConversationResult, type ConversationStreamEvent, type ConversationTurn, type CreateKnowledgeImprovementActivationExecutorOptions, type CreateProfileImprovementHarnessOptions, type DataAcquisitionPlan, type DecideSearchImprovementOptions, type DeepReadonly, type DelegatedLoopRunner, type HaltContext, type HaltPredicate, type HaltReason, type HaltSignal, type ImproveCandidateValidationInput, type ImproveCandidateValidator, type ImproveCodeBaseOptions, type ImproveCodeOptions, type ImproveCodeResult, type ImproveCodeRunOptions, type ImproveCost, type ImproveCustomCodeGeneratorOptions, type ImproveLineage, type ImproveMethodContext, type ImproveMethodFactory, type ImproveMethodLineage, type ImproveMethodOptions, type ImproveMethodResult, type ImproveMethodSource, type ImproveOptimizationRunOptions, type ImproveProfileAgent, type ImproveProfileComponents, type ImproveProfileSurface, type ImproveRuntimeCodeGeneratorOptions, type ImproveScenarioPartitions, type ImproveSearchAgent, type ImproveSearchIdentity, type ImproveSearchMethod, type ImproveSearchOptions, type ImproveSearchResult, type ImproveSkillsOptions, type ImproveSurface, type ImproveTrainingOptions, type ImproveTrainingResult, type ImprovementCodeCandidate, type ImprovementProfileCandidate, JudgeError, type KnowledgeImprovementActivationExecutor, type KnowledgeImprovementCandidatePair, type KnowledgeImprovementExperimentBundles, type KnowledgeImprovementJobMeasurement, type KnowledgeImprovementJobResult, type KnowledgeReadinessCheck, type KnowledgeReadinessCheckInput, type KnowledgeReadinessCheckResult, type KnowledgeReadinessDecision, type KnowledgeReadinessReport, type KnowledgeRequirement, type ModelInfo, NotFoundError, type OfficialGepaOptions, type OfficialOptimizerContextOptions, type OfficialSensitiveCandidateInput, type OfficialSkillOptOptions, type OpenAIChatResponseFormat, type OpenAIChatTool, type OpenAIChatToolChoice, type OtelAttribute, type OtelExportConfig, type OtelExportStats, type OtelExporter, type OtelSpan, type PersonaConversationResult, type PersonaDriver, type ProfileImprovementHarness, type ProfileImprovementHarnessRunOptions, type ProfileImprovementHarnessTrainOptions, type ProfileTrainer, type ProfileTrainerRequest, type ReadonlyAgentProfile, type ReflectiveGeneratorOptions, type ReflectiveProfileProposerOptions, type ReflectiveProposerChat, type ReflectiveProposerParent, type ReflectiveProposerReply, type ResolvedChatModel, type RetryBackoff, type RetryableErrorPredicate, type RouterEnv, type RunAgentTaskOptions, type RunAgentTaskStreamOptions, type RunConversationOptions, type RunKnowledgeImprovementJobOptions, type RunPersonaConfig, type RunPersonaConversationOptions, type RunRecord, type RuntimeCanonicalStreamEvent, type RuntimeEventCollector, type RuntimeExecutionAdmittedPayload, type RuntimeFailureCause, type RuntimeFailureCode, type RuntimeFailureOwner, type RuntimeHookContext, type RuntimeHookErrorContext, type RuntimeHookEvent, type RuntimeHookPhase, type RuntimeHookTarget, type RuntimeHooks, type RuntimeRunCompleteInput, type RuntimeRunCost, type RuntimeRunHandle, type RuntimeRunOptions, type RuntimeRunPersistenceAdapter, type RuntimeRunRow, type RuntimeRunStatus, type RuntimeSession, type RuntimeSessionStore, type RuntimeStreamEvent, type RuntimeStreamEventCollector, type RuntimeStreamEventSink, type RuntimeStreamEventSummary, type RuntimeTelemetryOptions, type SanitizedKnowledgeReadinessReport, type SanitizedKnowledgeRequirement, type SearchCellContext, type SearchDispatchContext, SearchEnvironmentFault, type SearchImprovementDecision, type SearchLane, type SearchLaneKind, type SearchLaneOptions, type SearchMethodOptions, type SearchPromotion, type SearchTraceOptions, type ServerSentEventOptions, type SharedBoxSearchLane, type TokenWork, type TrainingBoundaryResult, type TurnOrder, ValidationError, type Verifier, type VerifyResult, agenticGenerator, auditLoopRunner, buildLoopOtelSpans, commandVerifier, composeRuntimeHooks, createCommandProfileTrainer, createOtelExporter, createRuntimeEventCollector, createRuntimeStreamEventCollector, decideSearchImprovement, dedicatedLane, defineRuntimeHooks, improve, loopEventToOtelSpan, padSpanId, padTraceId, routerLane, sanitizeKnowledgeReadinessReport, searchMethod, sharedBoxLane, startRuntimeRun, subscriptionLane };
860
+ export { type AgentAdapter, type AgentBackendContext, type AgentBackendInput, AgentEvalError, type AgentEvalErrorCode, type AgentExecutionBackend, type AgentImprovementActivationReconciliation, type AgentImprovementActivationResultStore, type AgentImprovementActivationTransition, type AgentKnowledgeProvider, type AgentRuntimeEvent, type AgentRuntimeEventSink, type AgentTaskContext, type AgentTaskRunResult, type AgentTaskSpec, type AgentTaskStatus, type AgenticGeneratorExecutorForWorktree, type AgenticGeneratorOptions, type AgenticGeneratorShotDisposition, type AgenticGeneratorShotExecution, type AgenticGeneratorShotReceipt, type AuthSource, type BackendCallPolicy, BackendTransportError, type CandidateGenerator, type ChatModelCandidate, type ChatModelValidation, type CheckpointServingPort, type CircuitBreakerConfig, ConfigError, type ControlBudget, type ControlDecision, type ControlEvalResult, type ControlRunResult, type ControlStep, type ControlledTrainingCommand, type Conversation, type ConversationDriveState, type ConversationParticipant, type ConversationPolicy, type ConversationResult, type ConversationStreamEvent, type ConversationTurn, type CreateKnowledgeImprovementActivationExecutorOptions, type CreateProfileImprovementHarnessOptions, type DataAcquisitionPlan, type DecideSearchImprovementOptions, type DeepReadonly, type DelegatedLoopRunner, type HaltContext, type HaltPredicate, type HaltReason, type HaltSignal, type ImproveCandidateValidationInput, type ImproveCandidateValidator, type ImproveCodeBaseOptions, type ImproveCodeOptions, type ImproveCodeResult, type ImproveCodeRunOptions, type ImproveCost, type ImproveCustomCodeGeneratorOptions, type ImproveLineage, type ImproveMethodContext, type ImproveMethodFactory, type ImproveMethodLineage, type ImproveMethodOptions, type ImproveMethodResult, type ImproveMethodSource, type ImproveOptimizationRunOptions, type ImproveProfileAgent, type ImproveProfileComponents, type ImproveProfileSurface, type ImproveRuntimeCodeGeneratorOptions, type ImproveScenarioPartitions, type ImproveSearchAgent, type ImproveSearchIdentity, type ImproveSearchMethod, type ImproveSearchOptions, type ImproveSearchResult, type ImproveSkillsOptions, type ImproveSurface, type ImproveTrainingOptions, type ImproveTrainingResult, type ImprovementCodeCandidate, type ImprovementProfileCandidate, JudgeError, type KnowledgeImprovementActivationExecutor, type KnowledgeImprovementCandidatePair, type KnowledgeImprovementExperimentBundles, type KnowledgeImprovementJobMeasurement, type KnowledgeImprovementJobResult, type KnowledgeReadinessCheck, type KnowledgeReadinessCheckInput, type KnowledgeReadinessCheckResult, type KnowledgeReadinessDecision, type KnowledgeReadinessReport, type KnowledgeRequirement, type ModelInfo, NotFoundError, type OfficialGepaOptions, type OfficialOptimizerContextOptions, type OfficialSensitiveCandidateInput, type OfficialSkillOptOptions, type OpenAIChatResponseFormat, type OpenAIChatTool, type OpenAIChatToolChoice, type OtelAttribute, type OtelExportConfig, type OtelExportStats, type OtelExporter, type OtelSpan, type PersonaConversationResult, type PersonaDriver, type ProfileImprovementHarness, type ProfileImprovementHarnessRunOptions, type ProfileImprovementHarnessTrainOptions, type ProfileTrainer, type ProfileTrainerRequest, type ReadonlyAgentProfile, type ReflectiveGeneratorOptions, type ReflectiveProfileProposerOptions, type ReflectiveProposerChat, type ReflectiveProposerParent, type ReflectiveProposerReply, type ResolvedChatModel, type RetryBackoff, type RetryableErrorPredicate, type RouterEnv, type RunAgentTaskOptions, type RunAgentTaskStreamOptions, type RunConversationOptions, type RunKnowledgeImprovementJobOptions, type RunPersonaConfig, type RunPersonaConversationOptions, type RunRecord, type RuntimeCanonicalStreamEvent, type RuntimeEventCollector, type RuntimeExecutionAdmittedPayload, type RuntimeFailureCause, type RuntimeFailureCode, type RuntimeFailureOwner, type RuntimeHookContext, type RuntimeHookErrorContext, type RuntimeHookEvent, type RuntimeHookPhase, type RuntimeHookTarget, type RuntimeHooks, type RuntimeRunCompleteInput, type RuntimeRunCost, type RuntimeRunHandle, type RuntimeRunOptions, type RuntimeRunPersistenceAdapter, type RuntimeRunRow, type RuntimeRunStatus, type RuntimeSession, type RuntimeSessionStore, type RuntimeStreamEvent, type RuntimeStreamEventCollector, type RuntimeStreamEventSink, type RuntimeStreamEventSummary, type RuntimeTelemetryOptions, type SanitizedKnowledgeReadinessReport, type SanitizedKnowledgeRequirement, type SearchCellContext, type SearchDispatchContext, SearchEnvironmentFault, type SearchImprovementDecision, type SearchLane, type SearchLaneKind, type SearchLaneOptions, type SearchMethodOptions, type SearchPromotion, type SearchTraceOptions, type ServerSentEventOptions, type SharedBoxSearchLane, type SupervisedKnowledgeUpdateOptions, type TokenWork, type TrainingBoundaryResult, type TurnOrder, ValidationError, type Verifier, type VerifyResult, agenticGenerator, auditLoopRunner, buildLoopOtelSpans, commandVerifier, composeRuntimeHooks, createCommandProfileTrainer, createOtelExporter, createRuntimeEventCollector, createRuntimeStreamEventCollector, decideSearchImprovement, dedicatedLane, defineRuntimeHooks, improve, loopEventToOtelSpan, padSpanId, padTraceId, routerLane, sanitizeKnowledgeReadinessReport, searchMethod, sharedBoxLane, startRuntimeRun, subscriptionLane };
829
861
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
- import { B as InMemoryRuntimeSessionStore, C as optimizerMethod, H as nowIso, I as streamAgentTurn, L as createIterableBackend, R as createSandboxPromptBackend, U as startOrResumeRuntimeSession, V as newRuntimeSession, W as touchSession, z as normalizeBackendStreamEvent } from "./structural-rollout-BH_MWOy0.js";
1
+ import { B as InMemoryRuntimeSessionStore, C as optimizerMethod, H as nowIso, I as streamAgentTurn, L as createIterableBackend, R as createSandboxPromptBackend, U as startOrResumeRuntimeSession, V as newRuntimeSession, W as touchSession, z as normalizeBackendStreamEvent } from "./structural-rollout-B0HPcP9G.js";
2
2
  import { a as JudgeError, f as RuntimeRunStateError, i as ConfigError, m as ValidationError, o as NotFoundError, r as BackendTransportError, t as AgentEvalError } from "./errors-DG8yufqX.js";
3
- import { Jn as createRuntimeStreamEventCollector, Kn as loopEventToOtelSpan, Un as createOtelExporter, Xn as sanitizeRuntimeStreamEvent, Yn as sanitizeKnowledgeReadinessReport, ci as providerMessageText, qn as createRuntimeEventCollector, qr as executableAgentProfileSnapshot, zn as buildLoopOtelSpans } from "./supervisor-accounting-6O0Hr0Fg.js";
3
+ import { $n as sanitizeKnowledgeReadinessReport, Qn as createRuntimeStreamEventCollector, Qr as executableAgentProfileSnapshot, Un as buildLoopOtelSpans, Xn as loopEventToOtelSpan, Zn as createRuntimeEventCollector, er as sanitizeRuntimeStreamEvent, pi as providerMessageText, qn as createOtelExporter } from "./supervisor-accounting-C48Yo9QC.js";
4
4
  import { v as sleep } from "./util-qsH5cC9S.js";
5
- import { c as withMethodRuntimeControls, d as commandVerifier, f as addRuntimeUsage, i as assertCandidateValidator, m as isUsageAmount, n as createCommandProfileTrainer, o as parseExecutionRef, p as createRuntimeUsageTotals, r as searchMethod, s as privateValuePaths, t as improve, u as agenticGenerator } from "./improve-DoANtwjC.js";
6
- import { _ as embeddedCandidateArtifact, m as canonicalCandidateDigest$1, p as canonicalCandidateBytes$1, t as persistCandidateOutputArtifact, v as immutableCandidateValue, y as omitTopLevelDigest } from "./output-artifacts-AqkZ8lO2.js";
5
+ import { c as withMethodRuntimeControls, d as commandVerifier, f as addRuntimeUsage, i as assertCandidateValidator, m as isUsageAmount, n as createCommandProfileTrainer, o as parseExecutionRef, p as createRuntimeUsageTotals, r as searchMethod, s as privateValuePaths, t as improve, u as agenticGenerator } from "./improve-DOjywiPq.js";
6
+ import { _ as embeddedCandidateArtifact, a as captureMaterializedWorkspace, m as canonicalCandidateDigest$1, p as canonicalCandidateBytes$1, t as persistCandidateOutputArtifact, v as immutableCandidateValue, y as omitTopLevelDigest } from "./output-artifacts-AqkZ8lO2.js";
7
7
  import { d as defaultRedactorIdentityMaterial, f as resolveRedactor } from "./snapshot-BKI_w3JD.js";
8
- import { n as createAgentImprovementActivationResult } from "./activation-DTVc4eVS.js";
8
+ import { n as createAgentImprovementActivationResult } from "./activation-CEGkyzEG.js";
9
9
  import { t as sealAgentCandidateBundle } from "./bundle-9NLb1WO3.js";
10
- import { s as captureAgentCandidateWorkspace } from "./workspace-streams-BakRr-Pl.js";
11
- import { t as assertExecutableAgentProfile } from "./model-policy-CZwhXp8O.js";
12
- import { t as supervise } from "./supervise-CM5cXyuf.js";
13
- import { n as auditLoopRunner } from "./loop-runner-CVI07sjG.js";
14
- import { l as sharedBoxLane, o as routerLane, r as dedicatedLane, t as SearchEnvironmentFault, u as subscriptionLane, y as decideSearchImprovement } from "./search-executor-CNxDTuV3.js";
15
- import { Tt as ROUTER_PRICE_SOURCE, wt as priceTokens } from "./supervisor-C3Fv97vT.js";
16
- import { n as runtimeFailureCause } from "./failure-cause-WifbY42M.js";
17
- import { a as isolatedCheckBoxEvidenceSchema, o as isolatedCheckResultSchema } from "./graph-D2DFmNIP.js";
10
+ import { m as captureAgentCandidateWorkspaceFiles } from "./workspace-streams-C7PGLAUd.js";
11
+ import { t as assertExecutableAgentProfile } from "./model-policy-CqDuBTq-.js";
12
+ import { t as supervise } from "./supervise-Dvj-8S6D.js";
13
+ import { n as auditLoopRunner } from "./loop-runner-CPTOzSol.js";
14
+ import { l as sharedBoxLane, o as routerLane, r as dedicatedLane, t as SearchEnvironmentFault, u as subscriptionLane, y as decideSearchImprovement } from "./search-executor-CA6fTYWz.js";
15
+ import { Tt as ROUTER_PRICE_SOURCE, wt as priceTokens } from "./supervisor-DwdeUC2l.js";
16
+ import { n as runtimeFailureCause } from "./failure-cause-BI7cfDWx.js";
17
+ import { a as isolatedCheckBoxEvidenceSchema, o as isolatedCheckResultSchema } from "./graph-wJOMQ1kC.js";
18
18
  import { n as defineRuntimeHooks, t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
19
19
  import { toW3CSpanId as padSpanId, toW3CTraceId as padTraceId } from "@tangle-network/agent-trace-contract";
20
20
  import { agentCandidateKnowledgeSchema, agentProfileSchema, canonicalAgentProfileDigest, sha256DigestSchema } from "@tangle-network/agent-interface";
@@ -25,7 +25,7 @@ import { isAbsolute, relative, resolve, sep } from "node:path";
25
25
  import { spawnSync } from "node:child_process";
26
26
  import { realpath } from "node:fs/promises";
27
27
  import { gepaOptimizationMethod, skillOptOptimizationMethod } from "@tangle-network/agent-eval/campaign";
28
- import { evaluateKnowledgeBaseReadiness, fromAgentCandidateKnowledgeRef, improveKnowledgeBase, knowledgeImprovementCandidateRef, loadKnowledgeImprovementActivationResult, normalizeKnowledgeStateScope, promoteKnowledgeCandidate, restoreKnowledgeCandidateBaseline, toAgentCandidateKnowledgeRef, withKnowledgeImprovementComparison } from "@tangle-network/agent-knowledge";
28
+ import { KB_CLAIM_LEDGER_DIR, KB_EVENTS_PATH, KB_STORE_DIR, evaluateKnowledgeBaseReadiness, fromAgentCandidateKnowledgeRef, hashKnowledgeBase, improveKnowledgeBase, knowledgeImprovementCandidateRef, loadKnowledgeImprovementActivationResult, loadKnowledgeImprovementState, normalizeKnowledgeStateScope, promoteKnowledgeCandidate, restoreKnowledgeCandidateBaseline, toAgentCandidateKnowledgeRef, withKnowledgeImprovementComparison } from "@tangle-network/agent-knowledge";
29
29
  // src/runtime/profile-execution-backend.ts
30
30
  /**
31
31
  * Bind one exact profile and Runtime executor to the stable `AgentExecutionBackend` contract used
@@ -1858,7 +1858,10 @@ async function runSupervisedKnowledgeUpdate(options) {
1858
1858
  deliverable: knowledgeReadinessDeliverable(options),
1859
1859
  makeWorkerAgent: options.makeWorkerAgent,
1860
1860
  allowedModels: options.allowedModels
1861
- });
1861
+ }, Object.freeze({
1862
+ root: options.root,
1863
+ goal: options.goal
1864
+ }));
1862
1865
  return {
1863
1866
  applied: supervised.kind === "winner",
1864
1867
  summary: supervised.kind === "winner" ? "research supervisor completed and the knowledge base passed readiness" : `research supervisor stopped without a ready knowledge base: ${supervised.reason}`,
@@ -1944,7 +1947,12 @@ async function runKnowledgeImprovementJob(options) {
1944
1947
  updateKnowledge: instrumentedUpdateKnowledge
1945
1948
  });
1946
1949
  let knowledge;
1947
- if (resolvedImprovement.candidate?.status === "candidate-ready" || resolvedImprovement.candidate?.status === "promoted") knowledge = await freezeKnowledgeCandidatePair(options.root, resolvedImprovement, candidateArtifacts, knowledgeOptions.signal);
1950
+ if (resolvedImprovement.candidate?.status === "candidate-ready" || resolvedImprovement.candidate?.status === "promoted") knowledge = await captureKnowledgeImprovementCandidatePair({
1951
+ root: options.root,
1952
+ candidate: knowledgeImprovementCandidateRef(resolvedImprovement),
1953
+ artifacts: candidateArtifacts,
1954
+ signal: knowledgeOptions.signal
1955
+ });
1948
1956
  const finishedAtMs = Date.now();
1949
1957
  const measurement = {
1950
1958
  startedAt,
@@ -1982,16 +1990,31 @@ function buildKnowledgeImprovementExperimentBundles(bundle, knowledge) {
1982
1990
  })
1983
1991
  });
1984
1992
  }
1985
- async function freezeKnowledgeCandidatePair(root, improvement, artifacts, signal) {
1986
- const candidate = knowledgeImprovementCandidateRef(improvement);
1993
+ /** Capture an already measured Knowledge candidate and its original baseline.
1994
+ * The Knowledge owner revalidates the exact reference, evidence and isolated
1995
+ * bytes before Runtime freezes the existing execution snapshot contracts.
1996
+ * This does not update, evaluate or promote the curated Knowledge store. */
1997
+ async function captureKnowledgeImprovementCandidatePair(options) {
1998
+ const { root, candidate, artifacts, signal } = options;
1999
+ signal?.throwIfAborted();
2000
+ const state = await loadKnowledgeImprovementState(root, candidate.runId);
2001
+ if (!state) throw new Error("Knowledge candidate has no persisted owner state");
2002
+ const expectedHash = state.status === "promoted" && state.promotedCandidateId === candidate.candidateId ? candidate.candidateHash : candidate.baseHash;
2003
+ const assertCurrent = async () => {
2004
+ signal?.throwIfAborted();
2005
+ if (await hashKnowledgeBase(root, state.stateScope) !== expectedHash) throw new Error("Knowledge candidate no longer matches the current curated state");
2006
+ };
2007
+ await assertCurrent();
1987
2008
  const candidateRef = toAgentCandidateKnowledgeRef(candidate);
1988
2009
  return withKnowledgeImprovementComparison({
1989
2010
  root,
1990
2011
  candidate
1991
2012
  }, async (comparison) => {
2013
+ if (!comparison.evaluation.passed) throw new Error("Knowledge candidate has no passing measured evaluation");
1992
2014
  const freeze = async (target) => {
1993
2015
  const executionId = `knowledge-${candidate.candidateId}-${target}`;
1994
- return (await captureAgentCandidateWorkspace(await realpath(comparison[target].root), { ...artifacts ? { artifactPersistence: {
2016
+ const { files } = await captureMaterializedWorkspace(await realpath(comparison[target].root));
2017
+ return (await captureAgentCandidateWorkspaceFiles(files.filter((file) => isMeasuredKnowledgePath(file.path, comparison.stateScope)), { ...artifacts ? { artifactPersistence: {
1995
2018
  executionId,
1996
2019
  outputArtifacts: artifacts,
1997
2020
  ...signal ? { signal } : {}
@@ -2007,6 +2030,7 @@ async function freezeKnowledgeCandidatePair(root, improvement, artifacts, signal
2007
2030
  const stateScope = normalizedScope.pagesDirectory === defaultScope.pagesDirectory && normalizedScope.researchState === defaultScope.researchState ? void 0 : Object.freeze(normalizedScope);
2008
2031
  const baseline = await freeze("baseline");
2009
2032
  const proposed = await freeze("candidate");
2033
+ await assertCurrent();
2010
2034
  return Object.freeze({
2011
2035
  reference: candidateRef,
2012
2036
  ...stateScope ? { stateScope } : {},
@@ -2016,6 +2040,19 @@ async function freezeKnowledgeCandidatePair(root, improvement, artifacts, signal
2016
2040
  });
2017
2041
  });
2018
2042
  }
2043
+ /**
2044
+ * The Knowledge state a candidate hash measures: pages, raw sources and the source registry, plus
2045
+ * claim ledgers and the event log for a research scope. Each comparison view also rewrites
2046
+ * agent-knowledge's own index, mutation epoch and lock owner with its root, clock and holder, so
2047
+ * freezing those would make two captures of one measured candidate differ.
2048
+ */
2049
+ function isMeasuredKnowledgePath(path, scope) {
2050
+ const normalized = normalizeKnowledgeStateScope(scope);
2051
+ const within = (prefix) => path === prefix || path.startsWith(`${prefix}/`);
2052
+ if (within(normalized.pagesDirectory) || within("raw")) return true;
2053
+ if (path === `${KB_STORE_DIR}/sources.json`) return true;
2054
+ return normalized.researchState === true && (within(KB_CLAIM_LEDGER_DIR) || path === KB_EVENTS_PATH || within(`${KB_STORE_DIR}/event-log`));
2055
+ }
2019
2056
  async function captureKnowledgeEvidence(bytes, purpose, executionId, artifacts, signal) {
2020
2057
  if (!artifacts) return embeddedCandidateArtifact(bytes);
2021
2058
  return persistCandidateOutputArtifact(artifacts, {
@@ -2033,6 +2070,7 @@ function emptySpent() {
2033
2070
  iterations: 0,
2034
2071
  inputTokens: 0,
2035
2072
  outputTokens: 0,
2073
+ tokensKnown: true,
2036
2074
  usdKnown: true,
2037
2075
  usd: 0,
2038
2076
  ms: 0
@@ -2043,6 +2081,7 @@ function addSpent(target, result) {
2043
2081
  target.iterations += spent.iterations;
2044
2082
  target.inputTokens += spent.tokens.input;
2045
2083
  target.outputTokens += spent.tokens.output;
2084
+ target.tokensKnown = target.tokensKnown === true && spent.tokensKnown !== false;
2046
2085
  target.usdKnown = target.usdKnown && spent.usdKnown !== false;
2047
2086
  target.usd += spent.usd;
2048
2087
  target.ms += spent.ms;
@@ -2823,6 +2862,6 @@ function runtimeStreamServerSentEvent(event, options = {}) {
2823
2862
  function stripNewlines(value) {
2824
2863
  return value.replace(/[\r\n]/g, " ");
2825
2864
  }
2826
- export { AgentEvalError, BackendTransportError, ConfigError, DEFAULT_ROUTER_BASE_URL, InMemoryRuntimeSessionStore, JudgeError, NotFoundError, ROUTER_PRICE_SOURCE, SearchEnvironmentFault, ValidationError, agenticGenerator, auditLoopRunner, buildKnowledgeImprovementExperimentBundles, buildLoopOtelSpans, cleanModelId, commandVerifier, composeRuntimeHooks, createCommandProfileTrainer, createConversationBackend, createIterableBackend, createKnowledgeImprovementActivationExecutor, createOtelExporter, createProfileExecutionBackend, createProfileImprovementHarness, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, decideKnowledgeReadiness, decideSearchImprovement, dedicatedLane, defineRuntimeHooks, getModels, improve, isolatedCheckBoxEvidenceSchema, isolatedCheckResultSchema, loopEventToOtelSpan, officialGepa, officialSkillOpt, optimizerMethod, padSpanId, padTraceId, priceTokens, readinessServerSentEvent, reflectiveGenerator, reflectiveProfileProposer, resolveChatModel, resolveRouterBaseUrl, routerLane, runAgentTask, runAgentTaskStream, runConversation, runConversationStream, runKnowledgeImprovementJob, runPersonaConversation, runPersonaDispatch, runtimeStreamServerSentEvent, sanitizeKnowledgeReadinessReport, searchMethod, sharedBoxLane, startRuntimeRun, subscriptionLane, validateChatModelId };
2865
+ export { AgentEvalError, BackendTransportError, ConfigError, DEFAULT_ROUTER_BASE_URL, InMemoryRuntimeSessionStore, JudgeError, NotFoundError, ROUTER_PRICE_SOURCE, SearchEnvironmentFault, ValidationError, agenticGenerator, auditLoopRunner, buildKnowledgeImprovementExperimentBundles, buildLoopOtelSpans, captureKnowledgeImprovementCandidatePair, cleanModelId, commandVerifier, composeRuntimeHooks, createCommandProfileTrainer, createConversationBackend, createIterableBackend, createKnowledgeImprovementActivationExecutor, createOtelExporter, createProfileExecutionBackend, createProfileImprovementHarness, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, decideKnowledgeReadiness, decideSearchImprovement, dedicatedLane, defineRuntimeHooks, getModels, improve, isolatedCheckBoxEvidenceSchema, isolatedCheckResultSchema, loopEventToOtelSpan, officialGepa, officialSkillOpt, optimizerMethod, padSpanId, padTraceId, priceTokens, readinessServerSentEvent, reflectiveGenerator, reflectiveProfileProposer, resolveChatModel, resolveRouterBaseUrl, routerLane, runAgentTask, runAgentTaskStream, runConversation, runConversationStream, runKnowledgeImprovementJob, runPersonaConversation, runPersonaDispatch, runtimeStreamServerSentEvent, sanitizeKnowledgeReadinessReport, searchMethod, sharedBoxLane, startRuntimeRun, subscriptionLane, validateChatModelId };
2827
2866
 
2828
2867
  //# sourceMappingURL=index.js.map