@tangle-network/agent-knowledge 6.0.0 → 6.1.1

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 (57) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -1
  3. package/dist/benchmarks/index.d.ts +2 -53
  4. package/dist/benchmarks/index.js +2 -49
  5. package/dist/benchmarks-CmW6iORW.js +2718 -0
  6. package/dist/benchmarks-CmW6iORW.js.map +1 -0
  7. package/dist/cli.d.ts +1 -1
  8. package/dist/cli.js +180 -274
  9. package/dist/cli.js.map +1 -1
  10. package/dist/ids-DRqPZ42_.js +15 -0
  11. package/dist/ids-DRqPZ42_.js.map +1 -0
  12. package/dist/index-CGBctbit.d.ts +857 -0
  13. package/dist/index-CGBctbit.d.ts.map +1 -0
  14. package/dist/index-CIW3G4s_.d.ts +680 -0
  15. package/dist/index-CIW3G4s_.d.ts.map +1 -0
  16. package/dist/index.d.ts +1671 -1868
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +5836 -6528
  19. package/dist/index.js.map +1 -1
  20. package/dist/inspect-D5iarJc2.js +1864 -0
  21. package/dist/inspect-D5iarJc2.js.map +1 -0
  22. package/dist/memory/index.d.ts +3 -8
  23. package/dist/memory/index.js +3 -81
  24. package/dist/memory-C6KPRhoU.js +4494 -0
  25. package/dist/memory-C6KPRhoU.js.map +1 -0
  26. package/dist/search-CP0QtBJZ.js +113 -0
  27. package/dist/search-CP0QtBJZ.js.map +1 -0
  28. package/dist/sources/index.d.ts +212 -205
  29. package/dist/sources/index.d.ts.map +1 -0
  30. package/dist/sources/index.js +614 -33
  31. package/dist/sources/index.js.map +1 -1
  32. package/dist/types-DcCCzreS.d.ts +175 -0
  33. package/dist/types-DcCCzreS.d.ts.map +1 -0
  34. package/dist/viz/index.d.ts +23 -22
  35. package/dist/viz/index.d.ts.map +1 -0
  36. package/dist/viz/index.js +134 -10
  37. package/dist/viz/index.js.map +1 -1
  38. package/package.json +22 -11
  39. package/dist/benchmarks/index.js.map +0 -1
  40. package/dist/chunk-46YPZHAX.js +0 -5443
  41. package/dist/chunk-46YPZHAX.js.map +0 -1
  42. package/dist/chunk-4PNXQ2NT.js +0 -147
  43. package/dist/chunk-4PNXQ2NT.js.map +0 -1
  44. package/dist/chunk-AKYJG2MR.js +0 -2183
  45. package/dist/chunk-AKYJG2MR.js.map +0 -1
  46. package/dist/chunk-DQ3PDMDP.js +0 -115
  47. package/dist/chunk-DQ3PDMDP.js.map +0 -1
  48. package/dist/chunk-MYFM6LKH.js +0 -551
  49. package/dist/chunk-MYFM6LKH.js.map +0 -1
  50. package/dist/chunk-PVCSESAF.js +0 -3153
  51. package/dist/chunk-PVCSESAF.js.map +0 -1
  52. package/dist/chunk-YMKHCTS2.js +0 -19
  53. package/dist/chunk-YMKHCTS2.js.map +0 -1
  54. package/dist/index-C--N5wQV.d.ts +0 -796
  55. package/dist/memory/index.js.map +0 -1
  56. package/dist/types-6x0OpfW6.d.ts +0 -173
  57. package/dist/types-BY-xLVw-.d.ts +0 -622
package/dist/index.d.ts CHANGED
@@ -1,54 +1,50 @@
1
- import { S as SourceRecord, c as KnowledgeIndex, d as KnowledgeSearchResult, e as SourceRegistry, f as KnowledgeEvent, g as KnowledgeLintFinding, h as KnowledgeEventType, i as KnowledgePage, b as KnowledgeGraph, j as KnowledgeWriteBlock, k as KnowledgeClaim, l as KnowledgeRelease, m as KnowledgeWriteParseResult } from './types-6x0OpfW6.js';
2
- export { C as ClaimRef, n as KnowledgeBaseCandidate, K as KnowledgeGraphEdge, a as KnowledgeGraphNode, o as KnowledgeId, p as KnowledgePolicy, q as KnowledgeRelation, r as KnowledgeUnit, s as SourceAnchor } from './types-6x0OpfW6.js';
3
- import { KnowledgeRequirementCategory, KnowledgeAcquisitionMode, KnowledgeImportance, KnowledgeFreshness, KnowledgeSensitivity, KnowledgeRequirement, KnowledgeBundle, KnowledgeReadinessReport, UserQuestion, DataAcquisitionPlan, ControlRuntimeConfig, ControlEvalResult, RunRecord, AnalystSeverity, AnalystFinding, ReleaseTraceEvidence, GateDecision, DatasetScenario, ReleaseConfidenceScorecard } from '@tangle-network/agent-eval';
4
- import { AgentCandidateJsonValue, AgentImprovementActivation, AgentImprovementActivationResult, AgentCandidateKnowledgeRef } from '@tangle-network/agent-interface';
5
- import { z } from 'zod';
6
- import { OptimizationMethod, DispatchContext, JudgeConfig, ComparisonCost, Scenario } from '@tangle-network/agent-eval/campaign';
7
- import { R as RunSerializedKnowledgeOptimizationResult, a as RunSerializedKnowledgeOptimizationOptions } from './index-C--N5wQV.js';
8
- export { A as AgentMemoryActivation, b as AgentMemoryActivationDriver, c as AgentMemoryAttemptEvent, d as AgentMemoryBranch, e as AgentMemoryBranchLifetime, f as AgentMemoryBranchSnapshot, g as AgentMemoryDimensionComparison, h as AgentMemoryExecutionContext, i as AgentMemoryExecutionCostMeter, j as AgentMemoryExecutionCostReceipt, k as AgentMemoryExecutionPaidCallInput, l as AgentMemoryExecutionPaidCallResult, m as AgentMemoryExecutionStep, n as AgentMemoryExperimentCandidate, o as AgentMemoryExperimentRankingRow, p as AgentMemoryExperimentRunLease, q as AgentMemoryFinalEvaluation, r as AgentMemoryFinalPair, s as AgentMemoryHitSchema, t as AgentMemoryImprovementRunLease, u as AgentMemoryJournalEntry, v as AgentMemoryKindSchema, w as AgentMemoryLifecycleTimeoutError, x as AgentMemoryLifecycleUnsafeError, y as AgentMemoryPromotionDecision, z as AgentMemoryScopeSchema, B as AgentMemorySequence, C as AgentMemorySequenceArtifact, D as AgentMemorySequenceProbe, E as AgentMemorySequenceProbeResult, F as AgentMemorySequenceScenario, G as AgentMemorySequenceStep, H as AgentMemorySharingPolicy, I as AgentMemoryVisibility, J as AgentMemoryWriteInputSchema, K as BuildAgentMemorySequencesFromBenchmarkCasesOptions, L as CreateAgentMemoryBranchOptions, M as DEFAULT_MEMORY_CLEANUP_TIMEOUT_MS, N as ForkAgentMemoryBranchSnapshotOptions, O as GraphitiMcpClientLike, P as GraphitiMemoryAdapterOptions, Q as GraphitiToolNames, S as Mem0ClientLike, T as Mem0ClientMode, U as Mem0MemoryAdapterOptions, V as MemoryConfigScenario, W as Neo4jAgentMemoryAdapterOptions, X as RetrievalHoldoutOffPolicyOptions, Y as RetrievalHoldoutOffPolicyResult, Z as RetrievalHoldoutSessionSummary, _ as RunAgentMemoryExperimentOptions, $ as RunAgentMemoryExperimentResult, a0 as RunAgentMemoryImprovementOptions, a1 as RunAgentMemoryImprovementResult, a2 as SerializedCandidate, a3 as SerializedCandidateCodec, a4 as agentMemorySequenceJudge, a5 as applyRetrievalHoldout, a6 as applySessionStickyRetrievalHoldout, a7 as buildAgentMemorySequenceScenarios, a8 as buildAgentMemorySequencesFromBenchmarkCases, a9 as createAgentMemoryBranch, aa as createGraphitiMemoryAdapter, ab as createMem0MemoryAdapter, ac as createMemoryExecutionPool, ad as createNeo4jAgentMemoryAdapter, ae as defaultGetMemoryContext, af as deterministicRng, ag as emitRetrievalHoldoutBypass, ah as forkAgentMemoryBranchSnapshot, ai as graphitiMemoryAdapterIdentity, aj as jsonCandidateCodec, ak as jsonObjectCandidateCodec, al as mem0MemoryAdapterIdentity, am as memoryHitToSourceRecord, an as memoryRecoveryDelayMs, ao as memoryWriteResultToSourceRecord, ap as renderMemoryContext, aq as resetRetrievalHoldoutRegistry, ar as resolveMemoryCleanupTimeoutMs, as as retrievalHoldoutConfigHash, at as runAgentMemoryExperiment, au as runAgentMemoryImprovement, av as runBoundedMemoryLifecycle, aw as runSerializedKnowledgeOptimization, ax as scenarioContentFingerprint, ay as sleepForMemoryRecovery, az as toOffPolicyTrajectory } from './index-C--N5wQV.js';
9
- import { R as RetrievalConfig, a as RetrievalEvalScenario, b as RetrievalEvalArtifact, c as RetrievalEvalRetriever, d as RetrievalMetricWeights, e as RetrievedKnowledgeHit } from './types-BY-xLVw-.js';
10
- export { A as AgentMemoryAcquireRunLease, f as AgentMemoryAdapter, g as AgentMemoryBranchIsolation, h as AgentMemoryContext, i as AgentMemoryControllerMode, j as AgentMemoryHit, k as AgentMemoryKind, l as AgentMemoryRunLease, m as AgentMemoryScope, n as AgentMemorySearchOptions, o as AgentMemoryWriteInput, p as AgentMemoryWriteResult, B as BuildRetrievalBenchmarkCasesFromQrelsOptions, q as BuildRetrievalEvalDispatchOptions, K as KnowledgeAnswerBenchmarkCase, r as KnowledgeAnswerBenchmarkTaskKind, s as KnowledgeBenchmarkArtifact, t as KnowledgeBenchmarkCase, u as KnowledgeBenchmarkCaseBase, v as KnowledgeBenchmarkDistribution, w as KnowledgeBenchmarkEvaluation, x as KnowledgeBenchmarkFamily, y as KnowledgeBenchmarkReport, z as KnowledgeBenchmarkResponder, C as KnowledgeBenchmarkScenario, D as KnowledgeBenchmarkSliceSummary, E as KnowledgeBenchmarkSource, F as KnowledgeBenchmarkSpec, G as KnowledgeBenchmarkSplit, H as KnowledgeBenchmarkTaskKind, I as KnowledgeClaimMatcher, J as KnowledgeMemoryBenchmarkCase, L as KnowledgeMemoryBenchmarkTaskKind, M as KnowledgeMemoryEvent, N as KnowledgeMemoryFactMatcher, O as KnowledgeRetrievalBenchmarkCase, P as KnowledgeRetrievalBenchmarkQrel, Q as KnowledgeRetrievalBenchmarkQuery, S as MemoryAdapterBenchmarkCandidate, T as MemoryAdapterBenchmarkRankingRow, U as OwnedAgentMemoryRunLease, V as PartitionRetrievalScenariosOptions, W as RetrievalEvalRetrieverInput, X as RetrievalEvalRetrieverResult, Y as RetrievalGoldTarget, Z as RetrievalHoldoutBypassReason, _ as RetrievalHoldoutCallContext, $ as RetrievalHoldoutConfig, a0 as RetrievalHoldoutEligibleItem, a1 as RetrievalHoldoutEvent, a2 as RetrievalHoldoutResult, a3 as RetrievalHoldoutSessionState, a4 as RetrievalMetricSummary, a5 as RetrievalRecallJudgeOptions, a6 as RetrievalScenarioPartitions, a7 as RetrievedSourceSpan, a8 as RunKnowledgeBenchmarkSuiteOptions, a9 as RunKnowledgeBenchmarkSuiteResult, aa as RunMemoryAdapterBenchmarkOptions, ab as RunMemoryAdapterBenchmarkResult, ac as acquireAgentMemoryRunLease, ad as buildRetrievalEvalDispatch, ae as partitionRetrievalScenarios, af as retrievalConfigFromSurface, ag as retrievalConfigSurface, ah as retrievalRecallJudge, ai as scoreRetrievalArtifact } from './types-BY-xLVw-.js';
11
- export { INDUSTRY_MEMORY_BENCHMARKS, INDUSTRY_RAG_BENCHMARKS, buildFirstPartyMemoryLifecycleBenchmarkCases, buildIndustryMemoryBenchmarkSmokeCases, buildIndustryRagBenchmarkSmokeCases, buildKnowledgeBenchmarkScenarios, buildRetrievalBenchmarkCasesFromQrels, createInMemoryBenchmarkAdapter, createNoopMemoryBenchmarkAdapter, isKnowledgeMemoryBenchmarkCase, knowledgeBenchmarkJudge, parseKnowledgeBenchmarkJsonl, parseKnowledgeBenchmarkQrels, renderKnowledgeBenchmarkReportMarkdown, respondToIndustryMemoryBenchmarkSmokeCase, respondToIndustryRagBenchmarkSmokeCase, runKnowledgeBenchmarkSuite, runMemoryAdapterBenchmark, scoreKnowledgeBenchmarkArtifact, scoreMemoryBenchmarkArtifact, summarizeKnowledgeBenchmarkCampaign } from './benchmarks/index.js';
12
- import { KnowledgeFragment } from './sources/index.js';
13
- export { CornellLiiSelector, CornellLiiSourceOptions, FetchOpts, FragmentProvenance, IRS_DIMENSION_HINTS, IrsPublicationsSourceOptions, KnowledgeSource, MAX_RESPONSE_BYTES, MIN_REQUEST_GAP_MS, POLITE_USER_AGENT, PoliteFetchOptions, PoliteFetchResult, StateSosEntity, StateSosSourceConfig, __resetHttpThrottle, createCornellLiiSource, createIrsPublicationsSource, createStateSosSource, extractLinks, firstMatch, htmlToText, innerHtmlById, looksLikeBlockPage, politeFetch } from './sources/index.js';
14
- import '@tangle-network/agent-eval/rl';
15
-
1
+ import { S as SourceRegistry, _ as KnowledgeUnit, a as KnowledgeEventType, b as SourceAnchor, c as KnowledgeGraphNode, d as KnowledgeLintFinding, f as KnowledgePage, g as KnowledgeSearchResult, h as KnowledgeRelease, i as KnowledgeEvent, l as KnowledgeId, m as KnowledgeRelation, n as KnowledgeBaseCandidate, o as KnowledgeGraph, p as KnowledgePolicy, r as KnowledgeClaim, s as KnowledgeGraphEdge, t as ClaimRef, u as KnowledgeIndex, v as KnowledgeWriteBlock, x as SourceRecord, y as KnowledgeWriteParseResult } from "./types-DcCCzreS.js";
2
+ import { $ as RetrievalConfig, A as KnowledgeBenchmarkResponder, At as AgentMemoryScope, B as KnowledgeMemoryEvent, Bt as RetrievalHoldoutSessionState, C as KnowledgeBenchmarkArtifact, Ct as createInMemoryBenchmarkAdapter, D as KnowledgeBenchmarkEvaluation, Dt as AgentMemoryContext, E as KnowledgeBenchmarkDistribution, Et as AgentMemoryBranchIsolation, F as KnowledgeBenchmarkSplit, Ft as RetrievalHoldoutCallContext, G as MemoryAdapterBenchmarkCandidate, H as KnowledgeRetrievalBenchmarkCase, I as KnowledgeBenchmarkTaskKind, It as RetrievalHoldoutConfig, J as RunKnowledgeBenchmarkSuiteResult, K as MemoryAdapterBenchmarkRankingRow, L as KnowledgeClaimMatcher, Lt as RetrievalHoldoutEligibleItem, M as KnowledgeBenchmarkSliceSummary, Mt as AgentMemoryWriteInput, N as KnowledgeBenchmarkSource, Nt as AgentMemoryWriteResult, O as KnowledgeBenchmarkFamily, Ot as AgentMemoryHit, P as KnowledgeBenchmarkSpec, Pt as RetrievalHoldoutBypassReason, Q as PartitionRetrievalScenariosOptions, R as KnowledgeMemoryBenchmarkCase, Rt as RetrievalHoldoutEvent, S as KnowledgeAnswerBenchmarkTaskKind, St as acquireAgentMemoryRunLease, T as KnowledgeBenchmarkCaseBase, Tt as AgentMemoryAdapter, U as KnowledgeRetrievalBenchmarkQrel, V as KnowledgeMemoryFactMatcher, W as KnowledgeRetrievalBenchmarkQuery, X as RunMemoryAdapterBenchmarkResult, Y as RunMemoryAdapterBenchmarkOptions, Z as BuildRetrievalEvalDispatchOptions, _ as buildIndustryRagBenchmarkSmokeCases, _t as scoreRetrievalArtifact, a as runKnowledgeBenchmarkSuite, at as RetrievalGoldTarget, b as BuildRetrievalBenchmarkCasesFromQrelsOptions, bt as AgentMemoryRunLease, c as buildRetrievalBenchmarkCasesFromQrels, ct as RetrievalRecallJudgeOptions, d as summarizeKnowledgeBenchmarkCampaign, dt as RetrievedSourceSpan, et as RetrievalEvalArtifact, f as runMemoryAdapterBenchmark, ft as buildRetrievalEvalDispatch, g as buildIndustryMemoryBenchmarkSmokeCases, gt as retrievalRecallJudge, h as buildFirstPartyMemoryLifecycleBenchmarkCases, ht as retrievalConfigSurface, i as renderKnowledgeBenchmarkReportMarkdown, it as RetrievalEvalScenario, j as KnowledgeBenchmarkScenario, jt as AgentMemorySearchOptions, k as KnowledgeBenchmarkReport, kt as AgentMemoryKind, l as parseKnowledgeBenchmarkJsonl, lt as RetrievalScenarioPartitions, m as INDUSTRY_RAG_BENCHMARKS, mt as retrievalConfigFromSurface, n as buildKnowledgeBenchmarkScenarios, nt as RetrievalEvalRetrieverInput, o as scoreKnowledgeBenchmarkArtifact, ot as RetrievalMetricSummary, p as INDUSTRY_MEMORY_BENCHMARKS, pt as partitionRetrievalScenarios, q as RunKnowledgeBenchmarkSuiteOptions, r as knowledgeBenchmarkJudge, rt as RetrievalEvalRetrieverResult, s as scoreMemoryBenchmarkArtifact, st as RetrievalMetricWeights, t as isKnowledgeMemoryBenchmarkCase, tt as RetrievalEvalRetriever, u as parseKnowledgeBenchmarkQrels, ut as RetrievedKnowledgeHit, v as respondToIndustryMemoryBenchmarkSmokeCase, vt as AgentMemoryAcquireRunLease, w as KnowledgeBenchmarkCase, wt as createNoopMemoryBenchmarkAdapter, x as KnowledgeAnswerBenchmarkCase, xt as OwnedAgentMemoryRunLease, y as respondToIndustryRagBenchmarkSmokeCase, yt as AgentMemoryControllerMode, z as KnowledgeMemoryBenchmarkTaskKind, zt as RetrievalHoldoutResult } from "./index-CIW3G4s_.js";
3
+ import { $ as buildAgentMemorySequenceScenarios, A as AgentMemoryFinalPair, At as defaultGetMemoryContext, B as applySessionStickyRetrievalHoldout, C as runBoundedMemoryLifecycle, Ct as AgentMemoryJournalEntry, D as AgentMemoryActivationDriver, Dt as ForkAgentMemoryBranchSnapshotOptions, E as AgentMemoryActivation, Et as CreateAgentMemoryBranchOptions, F as RunAgentMemoryImprovementResult, Ft as SerializedCandidateCodec, G as toOffPolicyTrajectory, H as emitRetrievalHoldoutBypass, I as RetrievalHoldoutOffPolicyOptions, It as jsonCandidateCodec, J as GraphitiToolNames, K as GraphitiMcpClientLike, L as RetrievalHoldoutOffPolicyResult, Lt as jsonObjectCandidateCodec, M as AgentMemoryPromotionDecision, Mt as RunSerializedKnowledgeOptimizationOptions, N as MemoryConfigScenario, Nt as RunSerializedKnowledgeOptimizationResult, O as AgentMemoryDimensionComparison, Ot as createAgentMemoryBranch, P as RunAgentMemoryImprovementOptions, Pt as SerializedCandidate, Q as agentMemorySequenceJudge, R as RetrievalHoldoutSessionSummary, Rt as runSerializedKnowledgeOptimization, S as resolveMemoryCleanupTimeoutMs, St as AgentMemoryBranchSnapshot, T as runAgentMemoryImprovement, Tt as AgentMemoryVisibility, U as resetRetrievalHoldoutRegistry, V as deterministicRng, W as retrievalHoldoutConfigHash, X as graphitiMemoryAdapterIdentity, Y as createGraphitiMemoryAdapter, Z as runAgentMemoryExperiment, _ as AgentMemoryLifecycleTimeoutError, _t as BuildAgentMemorySequencesFromBenchmarkCasesOptions, a as AgentMemoryScopeSchema, at as AgentMemoryExecutionPaidCallInput, b as createMemoryExecutionPool, bt as AgentMemoryBranch, c as createNeo4jAgentMemoryAdapter, ct as AgentMemoryExperimentCandidate, d as Mem0HostedMemoryAdapterOptions, dt as AgentMemorySequence, et as buildAgentMemorySequencesFromBenchmarkCases, f as Mem0MemoryAdapterOptions, ft as AgentMemorySequenceArtifact, g as mem0MemoryAdapterIdentity, gt as AgentMemorySequenceStep, h as createMem0MemoryAdapter, ht as AgentMemorySequenceScenario, i as AgentMemoryKindSchema, it as AgentMemoryExecutionCostReceipt, j as AgentMemoryImprovementRunLease, jt as renderMemoryContext, k as AgentMemoryFinalEvaluation, kt as forkAgentMemoryBranchSnapshot, l as Mem0ClientMode, lt as AgentMemoryExperimentRankingRow, m as Mem0OssMemoryAdapterOptions, mt as AgentMemorySequenceProbeResult, n as memoryWriteResultToSourceRecord, nt as AgentMemoryExecutionContext, o as AgentMemoryWriteInputSchema, ot as AgentMemoryExecutionPaidCallResult, p as Mem0OssClient, pt as AgentMemorySequenceProbe, q as GraphitiMemoryAdapterOptions, r as AgentMemoryHitSchema, rt as AgentMemoryExecutionCostMeter, s as Neo4jAgentMemoryAdapterOptions, st as AgentMemoryExecutionStep, t as memoryHitToSourceRecord, tt as AgentMemoryAttemptEvent, u as Mem0HostedClient, ut as AgentMemoryExperimentRunLease, v as AgentMemoryLifecycleUnsafeError, vt as RunAgentMemoryExperimentOptions, w as sleepForMemoryRecovery, wt as AgentMemorySharingPolicy, x as memoryRecoveryDelayMs, xt as AgentMemoryBranchLifetime, y as DEFAULT_MEMORY_CLEANUP_TIMEOUT_MS, yt as RunAgentMemoryExperimentResult, z as applyRetrievalHoldout, zt as scenarioContentFingerprint } from "./index-CGBctbit.js";
4
+ import { CornellLiiSelector, CornellLiiSourceOptions, FetchOpts, FragmentProvenance, IRS_DIMENSION_HINTS, IrsPublicationsSourceOptions, KnowledgeFragment, KnowledgeSource, MAX_RESPONSE_BYTES, MIN_REQUEST_GAP_MS, POLITE_USER_AGENT, PoliteFetchOptions, PoliteFetchResult, StateSosEntity, StateSosSourceConfig, __resetHttpThrottle, createCornellLiiSource, createIrsPublicationsSource, createStateSosSource, extractLinks, firstMatch, htmlToText, innerHtmlById, looksLikeBlockPage, politeFetch } from "./sources/index.js";
5
+ import { AgentCandidateJsonValue, AgentCandidateKnowledgeRef, AgentImprovementActivation, AgentImprovementActivationResult } from "@tangle-network/agent-interface";
6
+ import { AnalystFinding, AnalystSeverity, ControlEvalResult, ControlRuntimeConfig, DataAcquisitionPlan, DatasetScenario, GateDecision, KnowledgeAcquisitionMode, KnowledgeBundle, KnowledgeFreshness, KnowledgeImportance, KnowledgeReadinessReport, KnowledgeRequirement, KnowledgeRequirementCategory, KnowledgeSensitivity, ReleaseConfidenceScorecard, ReleaseTraceEvidence, RunRecord, UserQuestion } from "@tangle-network/agent-eval";
7
+ import { z } from "zod";
8
+ import "proper-lockfile";
9
+ import { ComparisonCost, DispatchContext, JudgeConfig, OptimizationMethod, Scenario } from "@tangle-network/agent-eval/campaign";
10
+ //#region src/adapters.d.ts
16
11
  interface SourceAdapterInput {
17
- uri: string;
18
- bytes?: Uint8Array;
19
- text?: string;
20
- metadata?: Record<string, unknown>;
12
+ uri: string;
13
+ bytes?: Uint8Array;
14
+ text?: string;
15
+ metadata?: Record<string, unknown>;
21
16
  }
22
17
  interface SourceAdapterOutput {
23
- title?: string;
24
- mediaType?: string;
25
- text?: string;
26
- anchors?: SourceRecord['anchors'];
27
- metadata?: Record<string, unknown>;
18
+ title?: string;
19
+ mediaType?: string;
20
+ text?: string;
21
+ anchors?: SourceRecord['anchors'];
22
+ metadata?: Record<string, unknown>;
28
23
  }
29
24
  interface SourceAdapter {
30
- id: string;
31
- canLoad(input: SourceAdapterInput): boolean;
32
- load(input: SourceAdapterInput): Promise<SourceAdapterOutput> | SourceAdapterOutput;
25
+ id: string;
26
+ canLoad(input: SourceAdapterInput): boolean;
27
+ load(input: SourceAdapterInput): Promise<SourceAdapterOutput> | SourceAdapterOutput;
33
28
  }
34
29
  declare const textSourceAdapter: SourceAdapter;
35
30
  declare function mediaTypeFor(uri: string): string;
36
-
31
+ //#endregion
32
+ //#region src/eval-readiness.d.ts
37
33
  interface KnowledgeReadinessSpec {
38
- id: string;
39
- description: string;
40
- query: string;
41
- requiredFor: string[];
42
- category: KnowledgeRequirementCategory;
43
- acquisitionMode: KnowledgeAcquisitionMode;
44
- importance: KnowledgeImportance;
45
- freshness: KnowledgeFreshness;
46
- sensitivity: KnowledgeSensitivity;
47
- confidenceNeeded: number;
48
- fallbackPolicy?: KnowledgeRequirement['fallbackPolicy'];
49
- minSources?: number;
50
- minHits?: number;
51
- metadata?: Record<string, unknown>;
34
+ id: string;
35
+ description: string;
36
+ query: string;
37
+ requiredFor: string[];
38
+ category: KnowledgeRequirementCategory;
39
+ acquisitionMode: KnowledgeAcquisitionMode;
40
+ importance: KnowledgeImportance;
41
+ freshness: KnowledgeFreshness;
42
+ sensitivity: KnowledgeSensitivity;
43
+ confidenceNeeded: number;
44
+ fallbackPolicy?: KnowledgeRequirement['fallbackPolicy'];
45
+ minSources?: number;
46
+ minHits?: number;
47
+ metadata?: Record<string, unknown>;
52
48
  }
53
49
  /**
54
50
  * Defaults applied by `defineReadinessSpec` when the caller omits the field.
@@ -59,14 +55,14 @@ interface KnowledgeReadinessSpec {
59
55
  * topic that must reflect today's regulatory state).
60
56
  */
61
57
  declare const READINESS_SPEC_DEFAULTS: {
62
- readonly category: "domain_specific";
63
- readonly acquisitionMode: "search_web";
64
- readonly importance: "high";
65
- readonly freshness: "monthly";
66
- readonly sensitivity: "public";
67
- readonly confidenceNeeded: 0.7;
68
- readonly minSources: 1;
69
- readonly minHits: 2;
58
+ readonly category: 'domain_specific';
59
+ readonly acquisitionMode: 'search_web';
60
+ readonly importance: 'high';
61
+ readonly freshness: 'monthly';
62
+ readonly sensitivity: 'public';
63
+ readonly confidenceNeeded: 0.7;
64
+ readonly minSources: 1;
65
+ readonly minHits: 2;
70
66
  };
71
67
  /**
72
68
  * Inputs accepted by `defineReadinessSpec`. The four fields the caller cannot
@@ -106,58 +102,60 @@ type DefineReadinessSpecInput = Pick<KnowledgeReadinessSpec, 'id' | 'description
106
102
  */
107
103
  declare function defineReadinessSpec(input: DefineReadinessSpecInput): KnowledgeReadinessSpec;
108
104
  interface BuildEvalKnowledgeBundleOptions {
109
- taskId: string;
110
- index: KnowledgeIndex;
111
- specs: KnowledgeReadinessSpec[];
112
- userAnswers?: Record<string, string>;
113
- searchLimit?: number;
114
- metadata?: Record<string, unknown>;
115
- now?: Date;
105
+ taskId: string;
106
+ index: KnowledgeIndex;
107
+ specs: KnowledgeReadinessSpec[];
108
+ userAnswers?: Record<string, string>;
109
+ searchLimit?: number;
110
+ metadata?: Record<string, unknown>;
111
+ now?: Date;
116
112
  }
117
113
  interface EvalKnowledgeBundleBuildResult {
118
- bundle: KnowledgeBundle;
119
- report: KnowledgeReadinessReport;
120
- requirements: KnowledgeRequirement[];
121
- searchResultsByRequirement: Record<string, KnowledgeSearchResult[]>;
122
- questions: UserQuestion[];
123
- acquisitionPlans: DataAcquisitionPlan[];
114
+ bundle: KnowledgeBundle;
115
+ report: KnowledgeReadinessReport;
116
+ requirements: KnowledgeRequirement[];
117
+ searchResultsByRequirement: Record<string, KnowledgeSearchResult[]>;
118
+ questions: UserQuestion[];
119
+ acquisitionPlans: DataAcquisitionPlan[];
124
120
  }
125
121
  declare function buildEvalKnowledgeBundle(options: BuildEvalKnowledgeBundleOptions): EvalKnowledgeBundleBuildResult;
126
-
122
+ //#endregion
123
+ //#region src/sources.d.ts
127
124
  interface AddSourceOptions {
128
- copyIntoRaw?: boolean;
129
- adapters?: SourceAdapter[];
130
- now?: () => Date;
125
+ copyIntoRaw?: boolean;
126
+ adapters?: SourceAdapter[];
127
+ now?: () => Date;
131
128
  }
132
129
  interface AddSourceTextInput {
133
- uri: string;
134
- text: string;
135
- title?: string;
136
- mediaType?: string;
137
- validUntil?: string;
138
- lastVerifiedAt?: string;
139
- metadata?: Record<string, unknown>;
130
+ uri: string;
131
+ text: string;
132
+ title?: string;
133
+ mediaType?: string;
134
+ validUntil?: string;
135
+ lastVerifiedAt?: string;
136
+ metadata?: Record<string, unknown>;
140
137
  }
141
138
  declare function loadSourceRegistry(root: string): Promise<SourceRegistry>;
142
139
  declare function writeSourceRegistry(root: string, registry: SourceRegistry): Promise<void>;
143
140
  declare function addSourcePath(root: string, sourcePath: string, options?: AddSourceOptions): Promise<SourceRecord[]>;
144
141
  declare function addSourceText(root: string, input: AddSourceTextInput, options?: Pick<AddSourceOptions, 'adapters' | 'now'>): Promise<SourceRecord>;
145
142
  declare function sourceRegistryPath(root: string): string;
146
-
143
+ //#endregion
144
+ //#region src/verified-research-loop.d.ts
147
145
  /**
148
146
  * A knowledge gap the loop surfaces from `scoreKnowledgeReadiness`. The worker
149
147
  * targets these; the driver folds the unfilled remainder into the worker's next
150
148
  * prompt and runs its own gap-fill pass over them.
151
149
  */
152
150
  interface KnowledgeGap {
153
- /** Readiness-spec id this gap belongs to. */
154
- id: string;
155
- /** Human-readable description of what's missing. */
156
- description: string;
157
- /** The search query the readiness check ran for this requirement. */
158
- query: string;
159
- /** True when the gap blocks readiness (vs. a soft, non-blocking gap). */
160
- blocking: boolean;
151
+ /** Readiness-spec id this gap belongs to. */
152
+ id: string;
153
+ /** Human-readable description of what's missing. */
154
+ description: string;
155
+ /** The search query the readiness check ran for this requirement. */
156
+ query: string;
157
+ /** True when the gap blocks readiness (vs. a soft, non-blocking gap). */
158
+ blocking: boolean;
161
159
  }
162
160
  /** A new source the worker (or driver) discovered and wants to add to the KB. */
163
161
  type ResearchSourceProposal = AddSourceTextInput;
@@ -171,62 +169,62 @@ type ResearchSourceProposal = AddSourceTextInput;
171
169
  * sources, so a rejected source never reaches the curated pages.
172
170
  */
173
171
  interface ResearchContribution {
174
- /** Immutable sources to register (the raw evidence). */
175
- sources?: ResearchSourceProposal[];
176
- /** Safe write-protocol text producing curated `knowledge/*.md` pages. */
177
- proposalText?: string;
178
- /**
179
- * Build the page write-protocol text FROM the sources the driver accepted —
180
- * the curated, citing pages the readiness gate searches. Receives the
181
- * registered `SourceRecord`s (with their assigned ids, so a page's frontmatter
182
- * `sources:` can cite them). Returns `---FILE: knowledge/...---` block text or
183
- * `undefined`. Runs after verification, so a page never cites a rejected
184
- * source. Concatenated after any static `proposalText`.
185
- */
186
- buildPages?: (acceptedSources: SourceRecord[]) => string | undefined;
187
- /** Free-form research transcript — products can persist this. */
188
- notes?: string;
189
- metadata?: Record<string, unknown>;
172
+ /** Immutable sources to register (the raw evidence). */
173
+ sources?: ResearchSourceProposal[];
174
+ /** Safe write-protocol text producing curated `knowledge/*.md` pages. */
175
+ proposalText?: string;
176
+ /**
177
+ * Build the page write-protocol text FROM the sources the driver accepted —
178
+ * the curated, citing pages the readiness gate searches. Receives the
179
+ * registered `SourceRecord`s (with their assigned ids, so a page's frontmatter
180
+ * `sources:` can cite them). Returns `---FILE: knowledge/...---` block text or
181
+ * `undefined`. Runs after verification, so a page never cites a rejected
182
+ * source. Concatenated after any static `proposalText`.
183
+ */
184
+ buildPages?: (acceptedSources: SourceRecord[]) => string | undefined;
185
+ /** Free-form research transcript — products can persist this. */
186
+ notes?: string;
187
+ metadata?: Record<string, unknown>;
190
188
  }
191
189
  /** Context handed to the worker each round. */
192
190
  interface WorkerResearchContext {
193
- root: string;
194
- goal: string;
195
- round: number;
196
- index: KnowledgeIndex;
197
- /** Gaps the readiness gate currently reports — what the worker should close. */
198
- gaps: KnowledgeGap[];
199
- /** Steer text the driver folded in from the previous round's remaining gaps. */
200
- steer?: string;
201
- readiness: EvalKnowledgeBundleBuildResult;
202
- signal?: AbortSignal;
191
+ root: string;
192
+ goal: string;
193
+ round: number;
194
+ index: KnowledgeIndex;
195
+ /** Gaps the readiness gate currently reports — what the worker should close. */
196
+ gaps: KnowledgeGap[];
197
+ /** Steer text the driver folded in from the previous round's remaining gaps. */
198
+ steer?: string;
199
+ readiness: EvalKnowledgeBundleBuildResult;
200
+ signal?: AbortSignal;
203
201
  }
204
202
  /** Context handed to the driver's verifier for one candidate source. */
205
203
  interface SourceVerificationContext {
206
- root: string;
207
- goal: string;
208
- round: number;
209
- index: KnowledgeIndex;
210
- gaps: KnowledgeGap[];
211
- /** Sources already accepted earlier THIS round (in-round dedup). */
212
- acceptedThisRound: ResearchSourceProposal[];
213
- signal?: AbortSignal;
204
+ root: string;
205
+ goal: string;
206
+ round: number;
207
+ index: KnowledgeIndex;
208
+ gaps: KnowledgeGap[];
209
+ /** Sources already accepted earlier THIS round (in-round dedup). */
210
+ acceptedThisRound: ResearchSourceProposal[];
211
+ signal?: AbortSignal;
214
212
  }
215
213
  /** A single rejected source plus the reason the driver gave. */
216
214
  interface RejectedSource {
217
- source: ResearchSourceProposal;
218
- reason: string;
215
+ source: ResearchSourceProposal;
216
+ reason: string;
219
217
  }
220
218
  /** Context handed to the driver's gap-fill pass (only when `driverResearches`). */
221
219
  interface DriverResearchContext {
222
- root: string;
223
- goal: string;
224
- round: number;
225
- index: KnowledgeIndex;
226
- /** Gaps STILL open after the worker's accepted contribution applied. */
227
- remainingGaps: KnowledgeGap[];
228
- readiness: EvalKnowledgeBundleBuildResult;
229
- signal?: AbortSignal;
220
+ root: string;
221
+ goal: string;
222
+ round: number;
223
+ index: KnowledgeIndex;
224
+ /** Gaps STILL open after the worker's accepted contribution applied. */
225
+ remainingGaps: KnowledgeGap[];
226
+ readiness: EvalKnowledgeBundleBuildResult;
227
+ signal?: AbortSignal;
230
228
  }
231
229
  /**
232
230
  * The differentiated driver role.
@@ -242,69 +240,69 @@ interface DriverResearchContext {
242
240
  * next prompt. Defaults to a compact bulleted list when omitted.
243
241
  */
244
242
  interface ResearchDriver {
245
- verifySource(source: ResearchSourceProposal, ctx: SourceVerificationContext): Promise<SourceVerdict> | SourceVerdict;
246
- research?(ctx: DriverResearchContext): Promise<ResearchContribution> | ResearchContribution;
247
- foldGaps?(gaps: KnowledgeGap[]): string;
243
+ verifySource(source: ResearchSourceProposal, ctx: SourceVerificationContext): Promise<SourceVerdict> | SourceVerdict;
244
+ research?(ctx: DriverResearchContext): Promise<ResearchContribution> | ResearchContribution;
245
+ foldGaps?(gaps: KnowledgeGap[]): string;
248
246
  }
249
247
  type SourceVerdict = {
250
- accept: true;
248
+ accept: true;
251
249
  } | {
252
- accept: false;
253
- reason: string;
250
+ accept: false;
251
+ reason: string;
254
252
  };
255
253
  /** The worker: primary research targeting the round's gaps. */
256
254
  type ResearchWorker = (ctx: WorkerResearchContext) => Promise<ResearchContribution> | ResearchContribution;
257
255
  interface VerifiedResearchLoopOptions {
258
- root: string;
259
- goal: string;
260
- worker: ResearchWorker;
261
- driver: ResearchDriver;
262
- /**
263
- * When false (default), the driver ONLY verifies + gates — a pure coordinator
264
- * that contributes no research of its own (the "doesn't participate in the
265
- * work" mode). When true, the driver also runs its `research` gap-fill pass
266
- * each round over the gaps the worker left open.
267
- */
268
- driverResearches?: boolean;
269
- maxRounds?: number;
270
- actor?: string;
271
- /** Readiness specs define the gate; an empty list means the loop never gates. */
272
- readinessSpecs?: KnowledgeReadinessSpec[];
273
- readinessTaskId?: string;
274
- readiness?: Omit<BuildEvalKnowledgeBundleOptions, 'taskId' | 'index' | 'specs'>;
275
- sourceOptions?: Pick<AddSourceOptions, 'adapters' | 'now'>;
276
- signal?: AbortSignal;
277
- onRound?: (round: VerifiedResearchRound) => Promise<void> | void;
256
+ root: string;
257
+ goal: string;
258
+ worker: ResearchWorker;
259
+ driver: ResearchDriver;
260
+ /**
261
+ * When false (default), the driver ONLY verifies + gates — a pure coordinator
262
+ * that contributes no research of its own (the "doesn't participate in the
263
+ * work" mode). When true, the driver also runs its `research` gap-fill pass
264
+ * each round over the gaps the worker left open.
265
+ */
266
+ driverResearches?: boolean;
267
+ maxRounds?: number;
268
+ actor?: string;
269
+ /** Readiness specs define the gate; an empty list means the loop never gates. */
270
+ readinessSpecs?: KnowledgeReadinessSpec[];
271
+ readinessTaskId?: string;
272
+ readiness?: Omit<BuildEvalKnowledgeBundleOptions, 'taskId' | 'index' | 'specs'>;
273
+ sourceOptions?: Pick<AddSourceOptions, 'adapters' | 'now'>;
274
+ signal?: AbortSignal;
275
+ onRound?: (round: VerifiedResearchRound) => Promise<void> | void;
278
276
  }
279
277
  interface VerifiedResearchRound {
280
- round: number;
281
- /** Gaps reported at the START of the round (what the worker targeted). */
282
- gaps: KnowledgeGap[];
283
- /** Worker sources accepted by the driver and written to the KB. */
284
- acceptedWorkerSources: SourceRecord[];
285
- /** Worker sources the driver rejected (with reasons) — never written. */
286
- rejectedWorkerSources: RejectedSource[];
287
- /** Sources the driver itself added in its gap-fill pass. */
288
- driverSources: SourceRecord[];
289
- /** Curated pages written this round (worker proposal + driver proposal). */
290
- writtenPages: string[];
291
- readiness?: EvalKnowledgeBundleBuildResult;
292
- /** True once the readiness gate reports no blocking gaps. */
293
- ready: boolean;
294
- event: KnowledgeEvent;
295
- notes: {
296
- worker?: string;
297
- driver?: string;
298
- };
278
+ round: number;
279
+ /** Gaps reported at the START of the round (what the worker targeted). */
280
+ gaps: KnowledgeGap[];
281
+ /** Worker sources accepted by the driver and written to the KB. */
282
+ acceptedWorkerSources: SourceRecord[];
283
+ /** Worker sources the driver rejected (with reasons) — never written. */
284
+ rejectedWorkerSources: RejectedSource[];
285
+ /** Sources the driver itself added in its gap-fill pass. */
286
+ driverSources: SourceRecord[];
287
+ /** Curated pages written this round (worker proposal + driver proposal). */
288
+ writtenPages: string[];
289
+ readiness?: EvalKnowledgeBundleBuildResult;
290
+ /** True once the readiness gate reports no blocking gaps. */
291
+ ready: boolean;
292
+ event: KnowledgeEvent;
293
+ notes: {
294
+ worker?: string;
295
+ driver?: string;
296
+ };
299
297
  }
300
298
  interface VerifiedResearchLoopResult {
301
- root: string;
302
- goal: string;
303
- rounds: number;
304
- ready: boolean;
305
- index: KnowledgeIndex;
306
- readiness?: EvalKnowledgeBundleBuildResult;
307
- steps: VerifiedResearchRound[];
299
+ root: string;
300
+ goal: string;
301
+ rounds: number;
302
+ ready: boolean;
303
+ index: KnowledgeIndex;
304
+ readiness?: EvalKnowledgeBundleBuildResult;
305
+ steps: VerifiedResearchRound[];
308
306
  }
309
307
  /**
310
308
  * Two-agent (driver + worker) sibling of `runKnowledgeResearchLoop`.
@@ -335,59 +333,30 @@ declare function runVerifiedResearchLoop(options: VerifiedResearchLoopOptions):
335
333
  * driver can compose into `verifySource` (real verifiers can do more).
336
334
  */
337
335
  declare function sourceMatchesGaps(source: ResearchSourceProposal, index: KnowledgeIndex, gaps: KnowledgeGap[]): KnowledgeSearchResult[];
338
-
339
- /**
340
- * Real web-research worker + verifying driver for `runVerifiedResearchLoop`.
341
- *
342
- * This is the GENERAL, any-topic implementation behind the two-agent research
343
- * loop's live arm. Given the open knowledge gaps the readiness gate surfaces,
344
- * the worker:
345
- *
346
- * 1. asks an LLM (glm-5.2 by default) to turn each gap into focused web
347
- * search queries,
348
- * 2. runs a REAL web search over the Tangle router (`POST /v1/search` — the
349
- * same endpoint `tcloud mcp`'s `web_search` tool forwards to), so there is
350
- * no hardcoded corpus,
351
- * 3. fetches the top results with the repo's polite, cached `politeFetch` and
352
- * reduces each page to text with `htmlToText`,
353
- * 4. proposes the readable, verifiable pages as `ResearchSourceProposal`s plus
354
- * a `buildPages` that writes citing `knowledge/*.md` pages from the sources
355
- * the driver accepts.
356
- *
357
- * The verifying DRIVER is the differentiated role from the two-agent loop: a
358
- * second LLM pass that judges each fetched source's on-topic relevance to the
359
- * goal + open gaps and rejects off-topic / spam / already-covered material. The
360
- * worker ADDS; the driver GATES. Together they build a cleaner knowledge base
361
- * than a single agent at the same compute budget.
362
- *
363
- * Dependency-free on purpose: it talks to the router over `fetch` directly with
364
- * the published OpenAI-compatible chat shape and the `/v1/search` shape, so it
365
- * works whether or not the `tcloud` CLI is installed. Point it at any router by
366
- * passing `baseUrl`; supply the key via `apiKey` or `TANGLE_API_KEY`.
367
- */
368
-
336
+ //#endregion
337
+ //#region src/web-research-worker.d.ts
369
338
  /** One live web result, as the router's `/v1/search` returns it. */
370
339
  interface WebSearchHit {
371
- title: string;
372
- url: string;
373
- snippet?: string;
340
+ title: string;
341
+ url: string;
342
+ snippet?: string;
374
343
  }
375
344
  /**
376
345
  * The two router capabilities the worker/driver need. Injectable so tests can
377
346
  * stub the network; the default talks to the live Tangle router over `fetch`.
378
347
  */
379
348
  interface RouterClient {
380
- /** Live web search — returns title/url/snippet hits. */
381
- search(query: string, opts?: {
382
- maxResults?: number;
383
- }): Promise<WebSearchHit[]>;
384
- /** Chat completion — returns the assistant message's visible text. */
385
- chat(messages: {
386
- role: 'system' | 'user';
387
- content: string;
388
- }[], maxTokens?: number): Promise<string>;
389
- /** Cumulative cost (chat + search) since this client was created. */
390
- usage(): RouterUsage;
349
+ /** Live web search — returns title/url/snippet hits. */
350
+ search(query: string, opts?: {
351
+ maxResults?: number;
352
+ }): Promise<WebSearchHit[]>;
353
+ /** Chat completion — returns the assistant message's visible text. */
354
+ chat(messages: {
355
+ role: 'system' | 'user';
356
+ content: string;
357
+ }[], maxTokens?: number): Promise<string>;
358
+ /** Cumulative cost (chat + search) since this client was created. */
359
+ usage(): RouterUsage;
391
360
  }
392
361
  /**
393
362
  * Cumulative router cost — the per-arm signal the A/B reports ALONGSIDE quality,
@@ -397,38 +366,38 @@ interface RouterClient {
397
366
  * than its "equal passes" budget implies.
398
367
  */
399
368
  interface RouterUsage {
400
- chatCalls: number;
401
- searchCalls: number;
402
- promptTokens: number;
403
- completionTokens: number;
404
- usd: number;
405
- wallMs: number;
369
+ chatCalls: number;
370
+ searchCalls: number;
371
+ promptTokens: number;
372
+ completionTokens: number;
373
+ usd: number;
374
+ wallMs: number;
406
375
  }
407
376
  interface TangleRouterOptions {
408
- /** Router base URL. Defaults to `https://router.tangle.tools/v1`. */
409
- baseUrl?: string;
410
- /** Bearer key. Defaults to `process.env.TANGLE_API_KEY`. */
411
- apiKey?: string;
412
- /** Chat model id. Defaults to `glm-5.2`. */
413
- model?: string;
414
- /** Optional preferred search provider (exa | you | perplexity | …). */
415
- searchProvider?: string;
416
- /**
417
- * Retries on a TRANSIENT upstream status (502/503/504/429) with exponential
418
- * backoff. Default 4. A 4xx that isn't 429, and a 401, are NOT retried — those
419
- * are not transient. After the budget is exhausted the call still fails loud
420
- * with the original `RouterError`, so the fail-closed contract holds; this only
421
- * stops a single upstream-capacity blip from voiding a whole multi-topic run.
422
- */
423
- maxRetries?: number;
424
- /** Base backoff in ms (doubled each retry, ±25% jitter). Default 1500. */
425
- retryBaseMs?: number;
426
- signal?: AbortSignal;
377
+ /** Router base URL. Defaults to `https://router.tangle.tools/v1`. */
378
+ baseUrl?: string;
379
+ /** Bearer key. Defaults to `process.env.TANGLE_API_KEY`. */
380
+ apiKey?: string;
381
+ /** Chat model id. Defaults to `glm-5.2`. */
382
+ model?: string;
383
+ /** Optional preferred search provider (exa | you | perplexity | …). */
384
+ searchProvider?: string;
385
+ /**
386
+ * Retries on a TRANSIENT upstream status (502/503/504/429) with exponential
387
+ * backoff. Default 4. A 4xx that isn't 429, and a 401, are NOT retried — those
388
+ * are not transient. After the budget is exhausted the call still fails loud
389
+ * with the original `RouterError`, so the fail-closed contract holds; this only
390
+ * stops a single upstream-capacity blip from voiding a whole multi-topic run.
391
+ */
392
+ maxRetries?: number;
393
+ /** Base backoff in ms (doubled each retry, ±25% jitter). Default 1500. */
394
+ retryBaseMs?: number;
395
+ signal?: AbortSignal;
427
396
  }
428
397
  /** A small error so a failed router call fails loud rather than returning junk. */
429
398
  declare class RouterError extends Error {
430
- readonly status: number;
431
- constructor(status: number, message: string);
399
+ readonly status: number;
400
+ constructor(status: number, message: string);
432
401
  }
433
402
  /**
434
403
  * Build a dependency-free Tangle router client over `fetch`. This is the same
@@ -437,21 +406,21 @@ declare class RouterError extends Error {
437
406
  */
438
407
  declare function createTangleRouterClient(options?: TangleRouterOptions): RouterClient;
439
408
  interface WebResearchWorkerOptions {
440
- /** Router client. Defaults to a live Tangle router client from env creds. */
441
- router?: RouterClient;
442
- router_options?: TangleRouterOptions;
443
- /** Max search queries the LLM may form per gap. Default 2. */
444
- queriesPerGap?: number;
445
- /** Max web results fetched per query. Default 3. */
446
- resultsPerQuery?: number;
447
- /** Hard cap on sources proposed per round (across all gaps). Default 6. */
448
- maxSourcesPerRound?: number;
449
- /** Disk cache dir for `politeFetch`. Optional; speeds repeat runs. */
450
- cacheDir?: string;
451
- /** Minimum readable text length to keep a fetched page. Default 200. */
452
- minTextChars?: number;
453
- /** Max chars of page text stored per source (keeps pages bounded). Default 4000. */
454
- maxTextChars?: number;
409
+ /** Router client. Defaults to a live Tangle router client from env creds. */
410
+ router?: RouterClient;
411
+ router_options?: TangleRouterOptions;
412
+ /** Max search queries the LLM may form per gap. Default 2. */
413
+ queriesPerGap?: number;
414
+ /** Max web results fetched per query. Default 3. */
415
+ resultsPerQuery?: number;
416
+ /** Hard cap on sources proposed per round (across all gaps). Default 6. */
417
+ maxSourcesPerRound?: number;
418
+ /** Disk cache dir for `politeFetch`. Optional; speeds repeat runs. */
419
+ cacheDir?: string;
420
+ /** Minimum readable text length to keep a fetched page. Default 200. */
421
+ minTextChars?: number;
422
+ /** Max chars of page text stored per source (keeps pages bounded). Default 4000. */
423
+ maxTextChars?: number;
455
424
  }
456
425
  /**
457
426
  * The real web-research worker. Conforms to the loop's `ResearchWorker`
@@ -460,14 +429,14 @@ interface WebResearchWorkerOptions {
460
429
  */
461
430
  declare function createWebResearchWorker(options?: WebResearchWorkerOptions): ResearchWorker;
462
431
  interface VerifyingDriverOptions {
463
- router?: RouterClient;
464
- router_options?: TangleRouterOptions;
465
- /**
466
- * When the LLM verdict can't be parsed, default to REJECT (fail-closed) so a
467
- * model hiccup never poisons the KB with an unverified source. Set `true` to
468
- * accept-on-parse-failure only if you have a reason to. Default false.
469
- */
470
- acceptOnParseFailure?: boolean;
432
+ router?: RouterClient;
433
+ router_options?: TangleRouterOptions;
434
+ /**
435
+ * When the LLM verdict can't be parsed, default to REJECT (fail-closed) so a
436
+ * model hiccup never poisons the KB with an unverified source. Set `true` to
437
+ * accept-on-parse-failure only if you have a reason to. Default false.
438
+ */
439
+ acceptOnParseFailure?: boolean;
471
440
  }
472
441
  /**
473
442
  * The verifying driver: a real LLM pass that judges each candidate source's
@@ -480,44 +449,8 @@ interface VerifyingDriverOptions {
480
449
  * judgement, not bookkeeping.
481
450
  */
482
451
  declare function createVerifyingResearchDriver(options?: VerifyingDriverOptions): ResearchDriver;
483
-
484
- /**
485
- * Adaptive verifier mode for `runVerifiedResearchLoop`.
486
- *
487
- * The cost/quality A/B (`docs/results/cost-quality.md`) found the LLM relevance
488
- * verifier's cleanliness win is dominated by DE-DUPLICATION — which a
489
- * deterministic content-hash / canonical-URL check captures at ~none of the LLM
490
- * premium — and that an LLM check only earns its dollar on the off-scope tail.
491
- * The honest production move it names is: do the cheap deterministic work first,
492
- * spend the LLM only where it pays. This module is that driver.
493
- *
494
- * Per candidate source the adaptive driver runs THREE stages, cheapest first,
495
- * and stops at the first that decides:
496
- *
497
- * 1. DEDUP ($0, no LLM). Reject a source whose CONTENT (normalized-text hash)
498
- * or whose CANONICAL URL matches one already accepted this round or already
499
- * in the knowledge base. This is the de-dup the relevance judge was being
500
- * paid to do; doing it deterministically is free and exact.
501
- *
502
- * 2. HEURISTIC TRIAGE ($0, no LLM). For a unique survivor, a cheap host /
503
- * title / length signal classifies it as clearly-keep, clearly-drop, or
504
- * AMBIGUOUS. Clear cases are resolved without a model: an authoritative host
505
- * (arxiv, *.edu, *.gov, official docs) with a substantial readable body is
506
- * kept; an obvious spam/listicle/marketing title or a too-thin body is
507
- * dropped. Only genuinely ambiguous survivors fall through.
508
- *
509
- * 3. LLM ESCALATION ($, one call). ONLY the ambiguous survivors reach the LLM
510
- * `verifySource` — the shipped `createVerifyingResearchDriver` relevance
511
- * judge. This is where the verifier earns its premium: the off-scope tail a
512
- * cheap rule can't adjudicate.
513
- *
514
- * The result is the cost/quality frontier point the doc predicted: most of the
515
- * cleanliness (dedup + clear drops) at a fraction of the LLM $/calls (only the
516
- * ambiguous tail pays). It is a real `ResearchDriver` — same contract the
517
- * two-agent loop already gates on — and reuses `sha256`, the relevance verifier,
518
- * and the index; it reinvents none of them.
519
- */
520
-
452
+ //#endregion
453
+ //#region src/adaptive-driver.d.ts
521
454
  /**
522
455
  * Canonicalize a URL for duplicate detection: lowercase host, strip a leading
523
456
  * `www.`, drop the scheme, the fragment, a trailing slash, and tracking query
@@ -540,59 +473,59 @@ type DedupReason = 'duplicate-url' | 'duplicate-content';
540
473
  type TriageClass = 'keep' | 'drop' | 'ambiguous';
541
474
  /** One source's adaptive routing decision, for instrumentation and the doc. */
542
475
  interface AdaptiveDecision {
543
- uri: string;
544
- /** The stage that decided this source: dedup | heuristic | llm. */
545
- stage: 'dedup' | 'heuristic' | 'llm';
546
- accepted: boolean;
547
- /** The triage class assigned (set once past dedup). */
548
- triage?: TriageClass;
549
- reason?: string;
476
+ uri: string;
477
+ /** The stage that decided this source: dedup | heuristic | llm. */
478
+ stage: 'dedup' | 'heuristic' | 'llm';
479
+ accepted: boolean;
480
+ /** The triage class assigned (set once past dedup). */
481
+ triage?: TriageClass;
482
+ reason?: string;
550
483
  }
551
484
  /** Running tally of where the adaptive driver spent its decisions. */
552
485
  interface AdaptiveStats {
553
- total: number;
554
- /** Rejected by deterministic dedup (URL or content). $0. */
555
- dedupRejected: number;
556
- /** Kept by the cheap heuristic without an LLM call. $0. */
557
- heuristicKept: number;
558
- /** Dropped by the cheap heuristic without an LLM call. $0. */
559
- heuristicDropped: number;
560
- /** Escalated to the LLM relevance verifier ($ — the only paid stage). */
561
- llmCalls: number;
562
- /** Of the escalations, how many the LLM accepted. */
563
- llmAccepted: number;
564
- decisions: AdaptiveDecision[];
486
+ total: number;
487
+ /** Rejected by deterministic dedup (URL or content). $0. */
488
+ dedupRejected: number;
489
+ /** Kept by the cheap heuristic without an LLM call. $0. */
490
+ heuristicKept: number;
491
+ /** Dropped by the cheap heuristic without an LLM call. $0. */
492
+ heuristicDropped: number;
493
+ /** Escalated to the LLM relevance verifier ($ — the only paid stage). */
494
+ llmCalls: number;
495
+ /** Of the escalations, how many the LLM accepted. */
496
+ llmAccepted: number;
497
+ decisions: AdaptiveDecision[];
565
498
  }
566
499
  interface AdaptiveDriverOptions {
567
- /** Router client for the LLM escalation. Defaults to a live client from env. */
568
- router?: RouterClient;
569
- router_options?: TangleRouterOptions;
570
- /** Passed through to the escalation relevance verifier. */
571
- verifying?: Pick<VerifyingDriverOptions, 'acceptOnParseFailure'>;
572
- /**
573
- * Hosts an authoritative source lives on. A unique survivor on one of these,
574
- * with a substantial body, is KEPT deterministically (no LLM). Suffix-matched
575
- * against the canonical host, so `arxiv.org` matches `export.arxiv.org`. The
576
- * defaults cover papers, official docs, and standards bodies.
577
- */
578
- authoritativeHosts?: string[];
579
- /**
580
- * Title/snippet patterns that mark obvious spam / listicle / marketing — a
581
- * unique survivor matching one is DROPPED deterministically (no LLM).
582
- */
583
- spamPatterns?: RegExp[];
584
- /**
585
- * Below this many readable chars a survivor is too thin to be a real reference
586
- * and is dropped deterministically. Default 400.
587
- */
588
- minBodyChars?: number;
589
- /**
590
- * A survivor whose body is at or above this many chars AND on an authoritative
591
- * host is kept without an LLM call. Default 600.
592
- */
593
- substantialBodyChars?: number;
594
- /** Receives each routing decision as it is made (for live instrumentation). */
595
- onDecision?: (decision: AdaptiveDecision) => void;
500
+ /** Router client for the LLM escalation. Defaults to a live client from env. */
501
+ router?: RouterClient;
502
+ router_options?: TangleRouterOptions;
503
+ /** Passed through to the escalation relevance verifier. */
504
+ verifying?: Pick<VerifyingDriverOptions, 'acceptOnParseFailure'>;
505
+ /**
506
+ * Hosts an authoritative source lives on. A unique survivor on one of these,
507
+ * with a substantial body, is KEPT deterministically (no LLM). Suffix-matched
508
+ * against the canonical host, so `arxiv.org` matches `export.arxiv.org`. The
509
+ * defaults cover papers, official docs, and standards bodies.
510
+ */
511
+ authoritativeHosts?: string[];
512
+ /**
513
+ * Title/snippet patterns that mark obvious spam / listicle / marketing — a
514
+ * unique survivor matching one is DROPPED deterministically (no LLM).
515
+ */
516
+ spamPatterns?: RegExp[];
517
+ /**
518
+ * Below this many readable chars a survivor is too thin to be a real reference
519
+ * and is dropped deterministically. Default 400.
520
+ */
521
+ minBodyChars?: number;
522
+ /**
523
+ * A survivor whose body is at or above this many chars AND on an authoritative
524
+ * host is kept without an LLM call. Default 600.
525
+ */
526
+ substantialBodyChars?: number;
527
+ /** Receives each routing decision as it is made (for live instrumentation). */
528
+ onDecision?: (decision: AdaptiveDecision) => void;
596
529
  }
597
530
  /**
598
531
  * Classify a UNIQUE survivor (already past dedup) with cheap host/title/length
@@ -601,18 +534,18 @@ interface AdaptiveDriverOptions {
601
534
  * with a plausible body, which a host/title rule cannot adjudicate.
602
535
  */
603
536
  declare function triageSource(source: ResearchSourceProposal, options: {
604
- authoritativeHosts: string[];
605
- spamPatterns: RegExp[];
606
- minBodyChars: number;
607
- substantialBodyChars: number;
537
+ authoritativeHosts: string[];
538
+ spamPatterns: RegExp[];
539
+ minBodyChars: number;
540
+ substantialBodyChars: number;
608
541
  }): {
609
- triage: TriageClass;
610
- reason: string;
542
+ triage: TriageClass;
543
+ reason: string;
611
544
  };
612
545
  interface AdaptiveResearchDriver {
613
- verifySource(source: ResearchSourceProposal, ctx: SourceVerificationContext): Promise<SourceVerdict>;
614
- /** Live tally of where decisions were spent — the cost/quality instrumentation. */
615
- stats(): AdaptiveStats;
546
+ verifySource(source: ResearchSourceProposal, ctx: SourceVerificationContext): Promise<SourceVerdict>;
547
+ /** Live tally of where decisions were spent — the cost/quality instrumentation. */
548
+ stats(): AdaptiveStats;
616
549
  }
617
550
  /**
618
551
  * Build the adaptive verifier. The deterministic stages (dedup + heuristic
@@ -625,137 +558,141 @@ interface AdaptiveResearchDriver {
625
558
  * context's `acceptedThisRound` and the KB index. Use one driver per loop run.
626
559
  */
627
560
  declare function createAdaptiveResearchDriver(options?: AdaptiveDriverOptions): AdaptiveResearchDriver;
628
-
561
+ //#endregion
562
+ //#region src/rag-optimization.d.ts
629
563
  type RagOptimizationConfig = Record<string, AgentCandidateJsonValue>;
630
564
  type RagOptimizationBaseOptions = Omit<RunSerializedKnowledgeOptimizationOptions<RagOptimizationConfig, RagAnswerEvalScenario, RagAnswerEvalArtifact>, 'baseline' | 'method' | 'trainScenarios' | 'selectionScenarios' | 'finalScenarios' | 'dispatchCandidate' | 'judges' | 'codec' | 'scenarioFingerprint'>;
631
565
  interface RunRagOptimizationOptions extends RagOptimizationBaseOptions {
632
- baseline: RagOptimizationConfig;
633
- method: OptimizationMethod<RagAnswerEvalScenario, RagAnswerEvalArtifact>;
634
- trainScenarios: readonly RagAnswerEvalScenario[];
635
- selectionScenarios: readonly RagAnswerEvalScenario[];
636
- finalScenarios: readonly RagAnswerEvalScenario[];
637
- run(input: {
638
- config: RagOptimizationConfig;
639
- configSurface: string;
640
- configSurfaceHash: string;
641
- scenario: RagAnswerEvalScenario;
642
- context: DispatchContext;
643
- }): Promise<RagAnswerEvalArtifact>;
644
- judges?: readonly JudgeConfig<RagAnswerEvalArtifact, RagAnswerEvalScenario>[];
566
+ baseline: RagOptimizationConfig;
567
+ method: OptimizationMethod<RagAnswerEvalScenario, RagAnswerEvalArtifact>;
568
+ trainScenarios: readonly RagAnswerEvalScenario[];
569
+ selectionScenarios: readonly RagAnswerEvalScenario[];
570
+ finalScenarios: readonly RagAnswerEvalScenario[];
571
+ run(input: {
572
+ config: RagOptimizationConfig;
573
+ configSurface: string;
574
+ configSurfaceHash: string;
575
+ scenario: RagAnswerEvalScenario;
576
+ context: DispatchContext;
577
+ }): Promise<RagAnswerEvalArtifact>;
578
+ judges?: readonly JudgeConfig<RagAnswerEvalArtifact, RagAnswerEvalScenario>[];
645
579
  }
646
580
  interface RunRagOptimizationResult extends RunSerializedKnowledgeOptimizationResult<RagOptimizationConfig> {
647
- baselineConfig: RagOptimizationConfig;
648
- winnerConfig: RagOptimizationConfig;
649
- trainScenarios: readonly RagAnswerEvalScenario[];
650
- selectionScenarios: readonly RagAnswerEvalScenario[];
651
- finalScenarios: readonly RagAnswerEvalScenario[];
581
+ baselineConfig: RagOptimizationConfig;
582
+ winnerConfig: RagOptimizationConfig;
583
+ trainScenarios: readonly RagAnswerEvalScenario[];
584
+ selectionScenarios: readonly RagAnswerEvalScenario[];
585
+ finalScenarios: readonly RagAnswerEvalScenario[];
652
586
  }
653
587
  /** Optimizes retrieval and answer behavior together as one serialized RAG configuration. */
654
588
  declare function runRagOptimization(options: RunRagOptimizationOptions): Promise<RunRagOptimizationResult>;
655
-
589
+ //#endregion
590
+ //#region src/proposals.d.ts
656
591
  interface ApplyWriteBlocksResult {
657
- written: string[];
658
- warnings: string[];
592
+ written: string[];
593
+ warnings: string[];
659
594
  }
660
595
  declare function applyKnowledgeWriteBlocks(root: string, proposalText: string): Promise<ApplyWriteBlocksResult>;
661
596
  declare function applyKnowledgeWriteBlocksFile(root: string, proposalPath: string): Promise<ApplyWriteBlocksResult>;
662
-
597
+ //#endregion
598
+ //#region src/validate.d.ts
663
599
  interface ValidateKnowledgeOptions {
664
- strict?: boolean;
600
+ strict?: boolean;
665
601
  }
666
602
  interface ValidateKnowledgeResult {
667
- ok: boolean;
668
- findings: KnowledgeLintFinding[];
603
+ ok: boolean;
604
+ findings: KnowledgeLintFinding[];
669
605
  }
670
606
  declare function validateKnowledgeIndex(index: KnowledgeIndex, options?: ValidateKnowledgeOptions): ValidateKnowledgeResult;
671
-
607
+ //#endregion
608
+ //#region src/research-loop.d.ts
672
609
  interface KnowledgeResearchLoopContext {
673
- root: string;
674
- goal: string;
675
- iteration: number;
676
- index: KnowledgeIndex;
677
- lintFindings: KnowledgeLintFinding[];
678
- validation: ValidateKnowledgeResult;
679
- readiness?: EvalKnowledgeBundleBuildResult;
680
- previousSteps: KnowledgeResearchLoopStep[];
681
- signal?: AbortSignal;
610
+ root: string;
611
+ goal: string;
612
+ iteration: number;
613
+ index: KnowledgeIndex;
614
+ lintFindings: KnowledgeLintFinding[];
615
+ validation: ValidateKnowledgeResult;
616
+ readiness?: EvalKnowledgeBundleBuildResult;
617
+ previousSteps: KnowledgeResearchLoopStep[];
618
+ signal?: AbortSignal;
682
619
  }
683
620
  interface KnowledgeResearchLoopDecision {
684
- /**
685
- * Free-form notes from the researcher. Keep this human-readable; products can
686
- * store it as the research transcript.
687
- */
688
- notes?: string;
689
- /**
690
- * Local files to register as immutable sources before applying proposals.
691
- */
692
- sourcePaths?: string[];
693
- /**
694
- * Textual source artifacts discovered by an agent, browser worker, connector,
695
- * or deep-research process.
696
- */
697
- sourceTexts?: AddSourceTextInput[];
698
- /**
699
- * Safe write protocol text. The loop parses and applies only accepted
700
- * `---FILE: knowledge/...---` blocks.
701
- */
702
- proposalText?: string;
703
- /**
704
- * The researcher decides when the wiki is good enough. The loop deliberately
705
- * does not encode a domain-specific definition of "done".
706
- */
707
- done?: boolean;
708
- metadata?: Record<string, unknown>;
621
+ /**
622
+ * Free-form notes from the researcher. Keep this human-readable; products can
623
+ * store it as the research transcript.
624
+ */
625
+ notes?: string;
626
+ /**
627
+ * Local files to register as immutable sources before applying proposals.
628
+ */
629
+ sourcePaths?: string[];
630
+ /**
631
+ * Textual source artifacts discovered by an agent, browser worker, connector,
632
+ * or deep-research process.
633
+ */
634
+ sourceTexts?: AddSourceTextInput[];
635
+ /**
636
+ * Safe write protocol text. The loop parses and applies only accepted
637
+ * `---FILE: knowledge/...---` blocks.
638
+ */
639
+ proposalText?: string;
640
+ /**
641
+ * The researcher decides when the wiki is good enough. The loop deliberately
642
+ * does not encode a domain-specific definition of "done".
643
+ */
644
+ done?: boolean;
645
+ metadata?: Record<string, unknown>;
709
646
  }
710
647
  interface KnowledgeResearchLoopStep {
711
- iteration: number;
712
- notes?: string;
713
- addedSources: SourceRecord[];
714
- applied?: ApplyWriteBlocksResult;
715
- lintFindings: KnowledgeLintFinding[];
716
- validation: ValidateKnowledgeResult;
717
- readiness?: EvalKnowledgeBundleBuildResult;
718
- event: KnowledgeEvent;
719
- done: boolean;
720
- metadata?: Record<string, unknown>;
648
+ iteration: number;
649
+ notes?: string;
650
+ addedSources: SourceRecord[];
651
+ applied?: ApplyWriteBlocksResult;
652
+ lintFindings: KnowledgeLintFinding[];
653
+ validation: ValidateKnowledgeResult;
654
+ readiness?: EvalKnowledgeBundleBuildResult;
655
+ event: KnowledgeEvent;
656
+ done: boolean;
657
+ metadata?: Record<string, unknown>;
721
658
  }
722
659
  interface RunKnowledgeResearchLoopOptions {
723
- root: string;
724
- goal: string;
725
- maxIterations?: number;
726
- actor?: string;
727
- strict?: ValidateKnowledgeOptions['strict'];
728
- readinessSpecs?: KnowledgeReadinessSpec[];
729
- readinessTaskId?: string;
730
- readiness?: Omit<BuildEvalKnowledgeBundleOptions, 'taskId' | 'index' | 'specs'>;
731
- sourceOptions?: Pick<AddSourceOptions, 'adapters' | 'now'>;
732
- signal?: AbortSignal;
733
- step(context: KnowledgeResearchLoopContext): Promise<KnowledgeResearchLoopDecision> | KnowledgeResearchLoopDecision;
734
- onStep?: (step: KnowledgeResearchLoopStep) => Promise<void> | void;
660
+ root: string;
661
+ goal: string;
662
+ maxIterations?: number;
663
+ actor?: string;
664
+ strict?: ValidateKnowledgeOptions['strict'];
665
+ readinessSpecs?: KnowledgeReadinessSpec[];
666
+ readinessTaskId?: string;
667
+ readiness?: Omit<BuildEvalKnowledgeBundleOptions, 'taskId' | 'index' | 'specs'>;
668
+ sourceOptions?: Pick<AddSourceOptions, 'adapters' | 'now'>;
669
+ signal?: AbortSignal;
670
+ step(context: KnowledgeResearchLoopContext): Promise<KnowledgeResearchLoopDecision> | KnowledgeResearchLoopDecision;
671
+ onStep?: (step: KnowledgeResearchLoopStep) => Promise<void> | void;
735
672
  }
736
673
  interface KnowledgeResearchLoopResult {
737
- root: string;
738
- goal: string;
739
- iterations: number;
740
- done: boolean;
741
- index: KnowledgeIndex;
742
- lintFindings: KnowledgeLintFinding[];
743
- validation: ValidateKnowledgeResult;
744
- readiness?: EvalKnowledgeBundleBuildResult;
745
- steps: KnowledgeResearchLoopStep[];
674
+ root: string;
675
+ goal: string;
676
+ iterations: number;
677
+ done: boolean;
678
+ index: KnowledgeIndex;
679
+ lintFindings: KnowledgeLintFinding[];
680
+ validation: ValidateKnowledgeResult;
681
+ readiness?: EvalKnowledgeBundleBuildResult;
682
+ steps: KnowledgeResearchLoopStep[];
746
683
  }
747
684
  type KnowledgeControlLoopState = KnowledgeResearchLoopContext;
748
685
  type KnowledgeControlLoopAction = KnowledgeResearchLoopDecision;
749
686
  type KnowledgeControlLoopActionResult = KnowledgeResearchLoopStep;
750
687
  interface KnowledgeControlLoopAdapterOptions {
751
- root: string;
752
- goal: string;
753
- actor?: string;
754
- strict?: ValidateKnowledgeOptions['strict'];
755
- readinessSpecs?: KnowledgeReadinessSpec[];
756
- readinessTaskId?: string;
757
- readiness?: Omit<BuildEvalKnowledgeBundleOptions, 'taskId' | 'index' | 'specs'>;
758
- sourceOptions?: Pick<AddSourceOptions, 'adapters' | 'now'>;
688
+ root: string;
689
+ goal: string;
690
+ actor?: string;
691
+ strict?: ValidateKnowledgeOptions['strict'];
692
+ readinessSpecs?: KnowledgeReadinessSpec[];
693
+ readinessTaskId?: string;
694
+ readiness?: Omit<BuildEvalKnowledgeBundleOptions, 'taskId' | 'index' | 'specs'>;
695
+ sourceOptions?: Pick<AddSourceOptions, 'adapters' | 'now'>;
759
696
  }
760
697
  type KnowledgeControlLoopAdapter = Pick<ControlRuntimeConfig<KnowledgeControlLoopState, KnowledgeControlLoopAction, KnowledgeControlLoopActionResult, ControlEvalResult>, 'intent' | 'observe' | 'validate' | 'act' | 'shouldStop'>;
761
698
  /**
@@ -765,650 +702,660 @@ type KnowledgeControlLoopAdapter = Pick<ControlRuntimeConfig<KnowledgeControlLoo
765
702
  */
766
703
  declare function createKnowledgeControlLoopAdapter(options: KnowledgeControlLoopAdapterOptions): KnowledgeControlLoopAdapter;
767
704
  declare function runKnowledgeResearchLoop(options: RunKnowledgeResearchLoopOptions): Promise<KnowledgeResearchLoopResult>;
768
-
705
+ //#endregion
706
+ //#region src/retrieval-optimization.d.ts
769
707
  type RetrievalOptimizationBaseOptions = Omit<RunSerializedKnowledgeOptimizationOptions<RetrievalConfig, RetrievalEvalScenario, RetrievalEvalArtifact>, 'baseline' | 'method' | 'trainScenarios' | 'selectionScenarios' | 'finalScenarios' | 'dispatchCandidate' | 'judges' | 'codec' | 'scenarioFingerprint'>;
770
708
  interface RunRetrievalImprovementLoopOptions extends RetrievalOptimizationBaseOptions {
771
- baseline: RetrievalConfig;
772
- trainScenarios: readonly RetrievalEvalScenario[];
773
- selectionScenarios: readonly RetrievalEvalScenario[];
774
- finalScenarios: readonly RetrievalEvalScenario[];
775
- method: OptimizationMethod<RetrievalEvalScenario, RetrievalEvalArtifact>;
776
- index?: KnowledgeIndex;
777
- defaultK?: number;
778
- retrieve?: RetrievalEvalRetriever;
779
- judges?: readonly JudgeConfig<RetrievalEvalArtifact, RetrievalEvalScenario>[];
780
- metricWeights?: RetrievalMetricWeights;
709
+ baseline: RetrievalConfig;
710
+ trainScenarios: readonly RetrievalEvalScenario[];
711
+ selectionScenarios: readonly RetrievalEvalScenario[];
712
+ finalScenarios: readonly RetrievalEvalScenario[];
713
+ method: OptimizationMethod<RetrievalEvalScenario, RetrievalEvalArtifact>;
714
+ index?: KnowledgeIndex;
715
+ defaultK?: number;
716
+ retrieve?: RetrievalEvalRetriever;
717
+ judges?: readonly JudgeConfig<RetrievalEvalArtifact, RetrievalEvalScenario>[];
718
+ metricWeights?: RetrievalMetricWeights;
781
719
  }
782
720
  interface RunRetrievalImprovementLoopResult extends RunSerializedKnowledgeOptimizationResult<RetrievalConfig> {
783
- baselineConfig: RetrievalConfig;
784
- winnerConfig: RetrievalConfig;
785
- trainScenarios: readonly RetrievalEvalScenario[];
786
- selectionScenarios: readonly RetrievalEvalScenario[];
787
- finalScenarios: readonly RetrievalEvalScenario[];
721
+ baselineConfig: RetrievalConfig;
722
+ winnerConfig: RetrievalConfig;
723
+ trainScenarios: readonly RetrievalEvalScenario[];
724
+ selectionScenarios: readonly RetrievalEvalScenario[];
725
+ finalScenarios: readonly RetrievalEvalScenario[];
788
726
  }
789
727
  declare function runRetrievalImprovementLoop(options: RunRetrievalImprovementLoopOptions): Promise<RunRetrievalImprovementLoopResult>;
790
-
728
+ //#endregion
729
+ //#region src/rag-improvement-loop.d.ts
791
730
  type RagKnowledgeImprovementPhase = 'rag-optimization' | 'retrieval-tuning' | 'gap-diagnosis' | 'knowledge-acquisition' | 'knowledge-update' | 'answer-quality' | 'promotion';
792
731
  type RagKnowledgeImprovementPhaseStatus = 'completed' | 'skipped' | 'failed';
793
732
  type RagGapKind = 'missing-source' | 'stale-source' | 'retrieval-miss' | 'retrieval-noise' | 'chunking-mismatch' | 'missing-multihop-evidence' | 'generator-unsupported-claim' | 'citation-mismatch' | 'incorrect-abstention' | 'unknown';
794
733
  type RagGapSeverity = 'info' | 'warning' | 'error' | 'critical';
795
734
  interface RagGapFinding {
796
- id: string;
797
- kind: RagGapKind;
798
- severity: RagGapSeverity;
799
- message: string;
800
- scenarioId?: string;
801
- evidence?: Record<string, AgentCandidateJsonValue>;
735
+ id: string;
736
+ kind: RagGapKind;
737
+ severity: RagGapSeverity;
738
+ message: string;
739
+ scenarioId?: string;
740
+ evidence?: Record<string, AgentCandidateJsonValue>;
802
741
  }
803
742
  interface RagKnowledgeImprovementPhaseResult {
804
- phase: RagKnowledgeImprovementPhase;
805
- status: RagKnowledgeImprovementPhaseStatus;
806
- summary: string;
807
- startedAt: string;
808
- finishedAt: string;
809
- metadata?: Record<string, AgentCandidateJsonValue>;
743
+ phase: RagKnowledgeImprovementPhase;
744
+ status: RagKnowledgeImprovementPhaseStatus;
745
+ summary: string;
746
+ startedAt: string;
747
+ finishedAt: string;
748
+ metadata?: Record<string, AgentCandidateJsonValue>;
810
749
  }
811
750
  type RagOptimizationSelection = Pick<RunRagOptimizationResult, 'methodName' | 'baseline' | 'winner' | 'baselineConfig' | 'winnerConfig'>;
812
751
  type RetrievalOptimizationSelection = Pick<RunRetrievalImprovementLoopResult, 'methodName' | 'baseline' | 'winner' | 'baselineConfig' | 'winnerConfig'>;
813
752
  interface RagPhaseInputBase {
814
- goal: string;
815
- phases: readonly RagKnowledgeImprovementPhaseResult[];
816
- /** Selected candidate only. Adaptive update callbacks run before final scoring starts. */
817
- optimization?: RagOptimizationSelection;
818
- signal?: AbortSignal;
753
+ goal: string;
754
+ phases: readonly RagKnowledgeImprovementPhaseResult[];
755
+ /** Selected candidate only. Adaptive update callbacks run before final scoring starts. */
756
+ optimization?: RagOptimizationSelection;
757
+ signal?: AbortSignal;
819
758
  }
820
759
  interface RagDiagnosisInput extends RagPhaseInputBase {
821
- retrieval?: RetrievalOptimizationSelection;
760
+ retrieval?: RetrievalOptimizationSelection;
822
761
  }
823
762
  interface RagKnowledgeAcquisitionInput extends RagPhaseInputBase {
824
- retrieval?: RetrievalOptimizationSelection;
825
- findings: readonly RagGapFinding[];
763
+ retrieval?: RetrievalOptimizationSelection;
764
+ findings: readonly RagGapFinding[];
826
765
  }
827
766
  interface RagKnowledgeUpdateInput extends RagPhaseInputBase {
828
- retrieval?: RetrievalOptimizationSelection;
829
- findings: readonly RagGapFinding[];
830
- acquisition?: KnowledgeResearchLoopDecision;
767
+ retrieval?: RetrievalOptimizationSelection;
768
+ findings: readonly RagGapFinding[];
769
+ acquisition?: KnowledgeResearchLoopDecision;
831
770
  }
832
771
  interface RagKnowledgeUpdateResult {
833
- applied: boolean;
834
- summary: string;
835
- research?: KnowledgeResearchLoopResult;
836
- metadata?: Record<string, AgentCandidateJsonValue>;
772
+ applied: boolean;
773
+ summary: string;
774
+ research?: KnowledgeResearchLoopResult;
775
+ metadata?: Record<string, AgentCandidateJsonValue>;
837
776
  }
838
777
  interface RagAnswerQualityInput extends RagPhaseInputBase {
839
- retrieval?: RetrievalOptimizationSelection;
840
- findings: readonly RagGapFinding[];
841
- acquisition?: KnowledgeResearchLoopDecision;
842
- knowledgeUpdate?: RagKnowledgeUpdateResult;
778
+ retrieval?: RetrievalOptimizationSelection;
779
+ findings: readonly RagGapFinding[];
780
+ acquisition?: KnowledgeResearchLoopDecision;
781
+ knowledgeUpdate?: RagKnowledgeUpdateResult;
843
782
  }
844
783
  interface RagAnswerQualityResult {
845
- passed: boolean;
846
- metrics: Record<string, number>;
847
- finalScenarioIds: readonly string[];
848
- datasetRef: string;
849
- evaluatorRef: string;
850
- cost: ComparisonCost;
851
- findings?: readonly RagGapFinding[];
852
- metadata?: Record<string, AgentCandidateJsonValue>;
784
+ passed: boolean;
785
+ metrics: Record<string, number>;
786
+ finalScenarioIds: readonly string[];
787
+ datasetRef: string;
788
+ evaluatorRef: string;
789
+ cost: ComparisonCost;
790
+ findings?: readonly RagGapFinding[];
791
+ metadata?: Record<string, AgentCandidateJsonValue>;
853
792
  }
854
793
  interface RagPromotionInput extends RagPhaseInputBase {
855
- retrieval?: RetrievalOptimizationSelection;
856
- /** Full final-case result available only to the terminal promotion decision. */
857
- optimizationComparison?: RunRagOptimizationResult['comparison'];
858
- /** Full final-case result available only to the terminal promotion decision. */
859
- retrievalComparison?: RunRetrievalImprovementLoopResult['comparison'];
860
- findings: readonly RagGapFinding[];
861
- acquisition?: KnowledgeResearchLoopDecision;
862
- knowledgeUpdate?: RagKnowledgeUpdateResult;
863
- answerQuality?: RagAnswerQualityResult;
794
+ retrieval?: RetrievalOptimizationSelection;
795
+ /** Full final-case result available only to the terminal promotion decision. */
796
+ optimizationComparison?: RunRagOptimizationResult['comparison'];
797
+ /** Full final-case result available only to the terminal promotion decision. */
798
+ retrievalComparison?: RunRetrievalImprovementLoopResult['comparison'];
799
+ findings: readonly RagGapFinding[];
800
+ acquisition?: KnowledgeResearchLoopDecision;
801
+ knowledgeUpdate?: RagKnowledgeUpdateResult;
802
+ answerQuality?: RagAnswerQualityResult;
864
803
  }
865
804
  interface RagPromotionResult {
866
- promoted: boolean;
867
- reason: string;
868
- metadata?: Record<string, AgentCandidateJsonValue>;
805
+ promoted: boolean;
806
+ reason: string;
807
+ metadata?: Record<string, AgentCandidateJsonValue>;
869
808
  }
870
809
  interface RagKnowledgeResearchOptions extends Omit<RunKnowledgeResearchLoopOptions, 'goal' | 'signal' | 'step'> {
871
- goal?: string;
872
- step?: RunKnowledgeResearchLoopOptions['step'];
810
+ goal?: string;
811
+ step?: RunKnowledgeResearchLoopOptions['step'];
873
812
  }
874
813
  interface RunRagKnowledgeImprovementLoopOptions {
875
- goal: string;
876
- optimization?: RunRagOptimizationOptions;
877
- retrieval?: RunRetrievalImprovementLoopOptions;
878
- diagnose?: (input: RagDiagnosisInput) => MaybePromise$1<readonly RagGapFinding[]>;
879
- acquireKnowledge?: (input: RagKnowledgeAcquisitionInput) => MaybePromise$1<KnowledgeResearchLoopDecision>;
880
- knowledgeResearch?: RagKnowledgeResearchOptions;
881
- updateKnowledge?: (input: RagKnowledgeUpdateInput) => MaybePromise$1<RagKnowledgeUpdateResult>;
882
- evaluateAnswers?: (input: RagAnswerQualityInput) => MaybePromise$1<RagAnswerQualityResult>;
883
- /** Maximum total answer-evaluation spend accepted for promotion. */
884
- answerQualityCostCeiling?: number;
885
- /**
886
- * Makes a side-effect-free promotion decision after the library has rejected
887
- * missing, regressing, unaccounted, or over-budget final evidence.
888
- */
889
- decidePromotion?: (input: RagPromotionInput) => MaybePromise$1<RagPromotionResult>;
890
- enabledPhases?: readonly RagKnowledgeImprovementPhase[];
891
- requiredPhases?: readonly RagKnowledgeImprovementPhase[];
892
- signal?: AbortSignal;
893
- now?: () => Date;
814
+ goal: string;
815
+ optimization?: RunRagOptimizationOptions;
816
+ retrieval?: RunRetrievalImprovementLoopOptions;
817
+ diagnose?: (input: RagDiagnosisInput) => MaybePromise$1<readonly RagGapFinding[]>;
818
+ acquireKnowledge?: (input: RagKnowledgeAcquisitionInput) => MaybePromise$1<KnowledgeResearchLoopDecision>;
819
+ knowledgeResearch?: RagKnowledgeResearchOptions;
820
+ updateKnowledge?: (input: RagKnowledgeUpdateInput) => MaybePromise$1<RagKnowledgeUpdateResult>;
821
+ evaluateAnswers?: (input: RagAnswerQualityInput) => MaybePromise$1<RagAnswerQualityResult>;
822
+ /** Maximum total answer-evaluation spend accepted for promotion. */
823
+ answerQualityCostCeiling?: number;
824
+ /**
825
+ * Makes a side-effect-free promotion decision after the library has rejected
826
+ * missing, regressing, unaccounted, or over-budget final evidence.
827
+ */
828
+ decidePromotion?: (input: RagPromotionInput) => MaybePromise$1<RagPromotionResult>;
829
+ enabledPhases?: readonly RagKnowledgeImprovementPhase[];
830
+ requiredPhases?: readonly RagKnowledgeImprovementPhase[];
831
+ signal?: AbortSignal;
832
+ now?: () => Date;
894
833
  }
895
834
  interface RunRagKnowledgeImprovementLoopResult {
896
- goal: string;
897
- phases: readonly RagKnowledgeImprovementPhaseResult[];
898
- optimization?: RunRagOptimizationResult;
899
- retrieval?: RunRetrievalImprovementLoopResult;
900
- findings: readonly RagGapFinding[];
901
- acquisition?: KnowledgeResearchLoopDecision;
902
- knowledgeUpdate?: RagKnowledgeUpdateResult;
903
- answerQuality?: RagAnswerQualityResult;
904
- promotion?: RagPromotionResult;
835
+ goal: string;
836
+ phases: readonly RagKnowledgeImprovementPhaseResult[];
837
+ optimization?: RunRagOptimizationResult;
838
+ retrieval?: RunRetrievalImprovementLoopResult;
839
+ findings: readonly RagGapFinding[];
840
+ acquisition?: KnowledgeResearchLoopDecision;
841
+ knowledgeUpdate?: RagKnowledgeUpdateResult;
842
+ answerQuality?: RagAnswerQualityResult;
843
+ promotion?: RagPromotionResult;
905
844
  }
906
845
  type MaybePromise$1<T> = T | Promise<T>;
907
846
  declare function runRagKnowledgeImprovementLoop(options: RunRagKnowledgeImprovementLoopOptions): Promise<RunRagKnowledgeImprovementLoopResult>;
908
-
847
+ //#endregion
848
+ //#region src/rag-eval/contracts.d.ts
909
849
  type RagEvalProvider = 'agent-knowledge' | 'ragas' | 'deepeval' | 'trulens' | 'ragchecker' | 'custom';
910
850
  type RagEvalMetricKey = 'context_precision' | 'context_recall' | 'context_relevance' | 'context_sufficiency' | 'faithfulness' | 'groundedness' | 'answer_relevance' | 'answer_correctness' | 'citation_support' | 'abstention' | 'unsupported_answer_rate';
911
851
  type RagEvalSlice = 'known-answer' | 'paraphrase' | 'distractor' | 'freshness' | 'multi-source' | 'unanswerable' | 'long-tail' | 'custom';
912
852
  interface RagEvalContext {
913
- id: string;
914
- text: string;
915
- rank?: number;
916
- pageId?: string;
917
- sourceId?: string;
918
- anchorId?: string;
919
- stale?: boolean;
920
- metadata?: Record<string, AgentCandidateJsonValue>;
853
+ id: string;
854
+ text: string;
855
+ rank?: number;
856
+ pageId?: string;
857
+ sourceId?: string;
858
+ anchorId?: string;
859
+ stale?: boolean;
860
+ metadata?: Record<string, AgentCandidateJsonValue>;
921
861
  }
922
862
  interface RagEvalCitation {
923
- id: string;
924
- claimId?: string;
925
- contextId?: string;
926
- pageId?: string;
927
- sourceId?: string;
928
- anchorId?: string;
929
- quote?: string;
930
- metadata?: Record<string, AgentCandidateJsonValue>;
863
+ id: string;
864
+ claimId?: string;
865
+ contextId?: string;
866
+ pageId?: string;
867
+ sourceId?: string;
868
+ anchorId?: string;
869
+ quote?: string;
870
+ metadata?: Record<string, AgentCandidateJsonValue>;
931
871
  }
932
872
  interface RagEvalClaim {
933
- id: string;
934
- text: string;
935
- citationIds?: readonly string[];
936
- metadata?: Record<string, AgentCandidateJsonValue>;
873
+ id: string;
874
+ text: string;
875
+ citationIds?: readonly string[];
876
+ metadata?: Record<string, AgentCandidateJsonValue>;
937
877
  }
938
878
  interface RagRequiredContext {
939
- id?: string;
940
- text?: string;
941
- pageId?: string;
942
- sourceId?: string;
943
- anchorId?: string;
879
+ id?: string;
880
+ text?: string;
881
+ pageId?: string;
882
+ sourceId?: string;
883
+ anchorId?: string;
944
884
  }
945
885
  interface RagAnswerEvalScenario extends Scenario {
946
- kind: 'rag-answer-eval';
947
- query: string;
948
- referenceAnswer?: string;
949
- expectedClaims?: readonly string[];
950
- forbiddenClaims?: readonly string[];
951
- requiredContext?: readonly RagRequiredContext[];
952
- unanswerable?: boolean;
953
- requireCitations?: boolean;
954
- slices?: readonly RagEvalSlice[];
955
- thresholds?: Partial<Record<RagEvalMetricKey, number>>;
886
+ kind: 'rag-answer-eval';
887
+ query: string;
888
+ referenceAnswer?: string;
889
+ expectedClaims?: readonly string[];
890
+ forbiddenClaims?: readonly string[];
891
+ requiredContext?: readonly RagRequiredContext[];
892
+ unanswerable?: boolean;
893
+ requireCitations?: boolean;
894
+ slices?: readonly RagEvalSlice[];
895
+ thresholds?: Partial<Record<RagEvalMetricKey, number>>;
956
896
  }
957
897
  interface ExternalRagEvalScore {
958
- provider: RagEvalProvider | string;
959
- scores: Record<string, number>;
960
- reasons?: Record<string, string>;
961
- metadata?: Record<string, AgentCandidateJsonValue>;
898
+ provider: RagEvalProvider | string;
899
+ scores: Record<string, number>;
900
+ reasons?: Record<string, string>;
901
+ metadata?: Record<string, AgentCandidateJsonValue>;
962
902
  }
963
903
  interface RagAnswerEvalArtifact {
964
- query: string;
965
- answer: string;
966
- contexts: readonly RagEvalContext[];
967
- claims?: readonly RagEvalClaim[];
968
- citations?: readonly RagEvalCitation[];
969
- abstained?: boolean;
970
- durationMs?: number;
971
- costUsd?: number;
972
- externalScores?: readonly ExternalRagEvalScore[];
973
- metadata?: Record<string, AgentCandidateJsonValue>;
904
+ query: string;
905
+ answer: string;
906
+ contexts: readonly RagEvalContext[];
907
+ claims?: readonly RagEvalClaim[];
908
+ citations?: readonly RagEvalCitation[];
909
+ abstained?: boolean;
910
+ durationMs?: number;
911
+ costUsd?: number;
912
+ externalScores?: readonly ExternalRagEvalScore[];
913
+ metadata?: Record<string, AgentCandidateJsonValue>;
974
914
  }
975
915
  interface RagAnswerMetricSummary {
976
- metrics: Record<RagEvalMetricKey, number>;
977
- composite: number;
978
- passed: boolean;
979
- findings: readonly RagGapFinding[];
980
- claimCount: number;
981
- supportedClaimCount: number;
982
- citedClaimCount: number;
983
- supportedCitationCount: number;
984
- matchedRequiredContextCount: number;
985
- requiredContextCount: number;
986
- providerScores: Record<string, Record<RagEvalMetricKey, number>>;
916
+ metrics: Record<RagEvalMetricKey, number>;
917
+ composite: number;
918
+ passed: boolean;
919
+ findings: readonly RagGapFinding[];
920
+ claimCount: number;
921
+ supportedClaimCount: number;
922
+ citedClaimCount: number;
923
+ supportedCitationCount: number;
924
+ matchedRequiredContextCount: number;
925
+ requiredContextCount: number;
926
+ providerScores: Record<string, Record<RagEvalMetricKey, number>>;
987
927
  }
988
928
  interface RagAnswerQualityJudgeOptions {
989
- name?: string;
990
- thresholds?: Partial<Record<RagEvalMetricKey, number>>;
991
- weights?: Partial<Record<RagEvalMetricKey, number>>;
992
- externalScorePolicy?: 'prefer-external' | 'deterministic-first';
993
- minClaimSupport?: number;
929
+ name?: string;
930
+ thresholds?: Partial<Record<RagEvalMetricKey, number>>;
931
+ weights?: Partial<Record<RagEvalMetricKey, number>>;
932
+ externalScorePolicy?: 'prefer-external' | 'deterministic-first';
933
+ minClaimSupport?: number;
994
934
  }
995
935
  interface RagAnswerEvalCase {
996
- scenario: RagAnswerEvalScenario;
997
- artifact: RagAnswerEvalArtifact;
936
+ scenario: RagAnswerEvalScenario;
937
+ artifact: RagAnswerEvalArtifact;
998
938
  }
999
939
  interface RagAnswerQualityHookOptions {
1000
- scenarios: readonly RagAnswerEvalScenario[];
1001
- /** Immutable identity of generation, scoring, models, and external evaluator behavior. */
1002
- evaluatorRef: string;
1003
- /** Return observed spend after all generation and evaluation calls finish. */
1004
- cost: ComparisonCost | (() => MaybePromise<ComparisonCost>);
1005
- run: (scenario: RagAnswerEvalScenario) => MaybePromise<RagAnswerEvalArtifact>;
1006
- externalEvaluator?: (item: RagAnswerEvalCase) => MaybePromise<ExternalRagEvalScore | readonly ExternalRagEvalScore[] | undefined>;
1007
- thresholds?: Partial<Record<RagEvalMetricKey, number>>;
1008
- weights?: Partial<Record<RagEvalMetricKey, number>>;
940
+ scenarios: readonly RagAnswerEvalScenario[];
941
+ /** Immutable identity of generation, scoring, models, and external evaluator behavior. */
942
+ evaluatorRef: string;
943
+ /** Return observed spend after all generation and evaluation calls finish. */
944
+ cost: ComparisonCost | (() => MaybePromise<ComparisonCost>);
945
+ run: (scenario: RagAnswerEvalScenario) => MaybePromise<RagAnswerEvalArtifact>;
946
+ externalEvaluator?: (item: RagAnswerEvalCase) => MaybePromise<ExternalRagEvalScore | readonly ExternalRagEvalScore[] | undefined>;
947
+ thresholds?: Partial<Record<RagEvalMetricKey, number>>;
948
+ weights?: Partial<Record<RagEvalMetricKey, number>>;
1009
949
  }
1010
950
  interface RagCalibrationOptions {
1011
- scenario: RagAnswerEvalScenario;
1012
- strong: RagAnswerEvalArtifact;
1013
- weak: RagAnswerEvalArtifact;
1014
- judge?: JudgeConfig<RagAnswerEvalArtifact, RagAnswerEvalScenario>;
1015
- minStrongScore?: number;
1016
- maxWeakScore?: number;
1017
- signal?: AbortSignal;
951
+ scenario: RagAnswerEvalScenario;
952
+ strong: RagAnswerEvalArtifact;
953
+ weak: RagAnswerEvalArtifact;
954
+ judge?: JudgeConfig<RagAnswerEvalArtifact, RagAnswerEvalScenario>;
955
+ minStrongScore?: number;
956
+ maxWeakScore?: number;
957
+ signal?: AbortSignal;
1018
958
  }
1019
959
  interface RagCalibrationResult {
1020
- passed: boolean;
1021
- strongScore: number;
1022
- weakScore: number;
1023
- gap: number;
960
+ passed: boolean;
961
+ strongScore: number;
962
+ weakScore: number;
963
+ gap: number;
1024
964
  }
1025
965
  interface KnowledgeBaseQualityOptions {
1026
- now?: Date;
1027
- strict?: boolean;
1028
- minCitationRate?: number;
1029
- maxStaleSourceRate?: number;
966
+ now?: Date;
967
+ strict?: boolean;
968
+ minCitationRate?: number;
969
+ maxStaleSourceRate?: number;
1030
970
  }
1031
971
  interface KnowledgeBaseQualityReport {
1032
- ok: boolean;
1033
- metrics: {
1034
- page_count: number;
1035
- source_count: number;
1036
- citation_rate: number;
1037
- source_backed_page_rate: number;
1038
- stale_source_rate: number;
1039
- duplicate_source_hash_rate: number;
1040
- lint_error_count: number;
1041
- lint_warning_count: number;
1042
- };
1043
- findings: readonly RagGapFinding[];
972
+ ok: boolean;
973
+ metrics: {
974
+ page_count: number;
975
+ source_count: number;
976
+ citation_rate: number;
977
+ source_backed_page_rate: number;
978
+ stale_source_rate: number;
979
+ duplicate_source_hash_rate: number;
980
+ lint_error_count: number;
981
+ lint_warning_count: number;
982
+ };
983
+ findings: readonly RagGapFinding[];
1044
984
  }
1045
985
  type MaybePromise<T> = T | Promise<T>;
1046
-
986
+ //#endregion
987
+ //#region src/rag-eval/calibration.d.ts
1047
988
  declare function createRagAnswerQualityHook(options: RagAnswerQualityHookOptions): () => Promise<RagAnswerQualityResult>;
1048
989
  declare function calibrateRagAnswerJudge(options: RagCalibrationOptions): Promise<RagCalibrationResult>;
1049
-
990
+ //#endregion
991
+ //#region src/rag-eval/knowledge-base.d.ts
1050
992
  declare function scoreKnowledgeBaseIndex(index: KnowledgeIndex, options?: KnowledgeBaseQualityOptions): KnowledgeBaseQualityReport;
1051
-
993
+ //#endregion
994
+ //#region src/rag-eval/providers.d.ts
1052
995
  declare function normalizeExternalRagScores(scores: readonly ExternalRagEvalScore[]): Record<string, Record<RagEvalMetricKey, number>>;
1053
996
  declare function toRagasEvaluationRows(cases: readonly RagAnswerEvalCase[]): {
1054
- user_input: string;
1055
- response: string;
1056
- retrieved_contexts: string[];
1057
- reference: string | undefined;
1058
- reference_contexts: string[];
997
+ user_input: string;
998
+ response: string;
999
+ retrieved_contexts: string[];
1000
+ reference: string | undefined;
1001
+ reference_contexts: string[];
1059
1002
  }[];
1060
1003
  declare function toDeepEvalTestCases(cases: readonly RagAnswerEvalCase[]): {
1061
- input: string;
1062
- actual_output: string;
1063
- expected_output: string | undefined;
1064
- retrieval_context: string[];
1065
- context: string[];
1004
+ input: string;
1005
+ actual_output: string;
1006
+ expected_output: string | undefined;
1007
+ retrieval_context: string[];
1008
+ context: string[];
1066
1009
  }[];
1067
1010
  declare function toTruLensRecords(cases: readonly RagAnswerEvalCase[]): {
1068
- input: string;
1069
- output: string;
1070
- context: string;
1011
+ input: string;
1012
+ output: string;
1013
+ context: string;
1071
1014
  }[];
1072
1015
  declare function toRagCheckerRecords(cases: readonly RagAnswerEvalCase[]): {
1073
- query_id: string;
1074
- query: string;
1075
- gt_answer: string | undefined;
1076
- response: string;
1077
- retrieved_context: {
1078
- doc_id: string;
1079
- text: string;
1080
- }[];
1081
- claims: string[];
1016
+ query_id: string;
1017
+ query: string;
1018
+ gt_answer: string | undefined;
1019
+ response: string;
1020
+ retrieved_context: {
1021
+ doc_id: string;
1022
+ text: string;
1023
+ }[];
1024
+ claims: string[];
1082
1025
  }[];
1083
-
1026
+ //#endregion
1027
+ //#region src/rag-eval/scoring.d.ts
1084
1028
  declare function ragAnswerQualityJudge(options?: RagAnswerQualityJudgeOptions): JudgeConfig<RagAnswerEvalArtifact, RagAnswerEvalScenario>;
1085
1029
  declare function scoreRagAnswerArtifact(artifact: RagAnswerEvalArtifact, scenario: RagAnswerEvalScenario, options?: RagAnswerQualityJudgeOptions): RagAnswerMetricSummary;
1086
1030
  declare function diagnoseRagAnswerFailure(metrics: Record<RagEvalMetricKey, number>, scenario: RagAnswerEvalScenario, thresholds?: Partial<Record<RagEvalMetricKey, number>>): RagGapFinding[];
1087
-
1031
+ //#endregion
1032
+ //#region src/kb-improvement/contracts.d.ts
1088
1033
  type KnowledgeImprovementStatus = 'running' | 'candidate-ready' | 'promoted' | 'rejected' | 'blocked';
1089
1034
  interface KnowledgeImprovementMetricProvenanceBase {
1090
- evaluator: string;
1091
- version: string;
1035
+ evaluator: string;
1036
+ version: string;
1092
1037
  }
1093
1038
  type KnowledgeImprovementMetricProvenance = (KnowledgeImprovementMetricProvenanceBase & {
1094
- method: 'deterministic';
1039
+ method: 'deterministic';
1095
1040
  }) | (KnowledgeImprovementMetricProvenanceBase & {
1096
- method: 'sampled' | 'composite';
1097
- corpusHash: string;
1098
- runRecords: RunRecord[];
1041
+ method: 'sampled' | 'composite';
1042
+ corpusHash: string;
1043
+ runRecords: RunRecord[];
1099
1044
  }) | (KnowledgeImprovementMetricProvenanceBase & {
1100
- method: 'model';
1101
- model: string;
1102
- corpusHash: string;
1103
- runRecords: RunRecord[];
1045
+ method: 'model';
1046
+ model: string;
1047
+ corpusHash: string;
1048
+ runRecords: RunRecord[];
1104
1049
  });
1105
1050
  interface KnowledgeImprovementMetric {
1106
- score: number;
1107
- passed: boolean;
1108
- dimensions?: Record<string, number>;
1109
- notes?: string;
1110
- provenance: KnowledgeImprovementMetricProvenance;
1051
+ score: number;
1052
+ passed: boolean;
1053
+ dimensions?: Record<string, number>;
1054
+ notes?: string;
1055
+ provenance: KnowledgeImprovementMetricProvenance;
1111
1056
  }
1112
1057
  interface KnowledgeImprovementEvaluationInput {
1113
- runId: string;
1114
- iteration: number;
1115
- root: string;
1116
- baselineRoot: string;
1117
- candidateRoot: string;
1118
- baselineIndex: KnowledgeIndex;
1119
- candidateIndex: KnowledgeIndex;
1120
- baseHash: string;
1121
- candidateHash: string;
1122
- validation: ValidateKnowledgeResult;
1123
- readiness?: EvalKnowledgeBundleBuildResult;
1124
- kbQuality: KnowledgeBaseQualityReport;
1125
- lifecycle?: RunRagKnowledgeImprovementLoopResult;
1126
- signal?: AbortSignal;
1058
+ runId: string;
1059
+ iteration: number;
1060
+ root: string;
1061
+ baselineRoot: string;
1062
+ candidateRoot: string;
1063
+ baselineIndex: KnowledgeIndex;
1064
+ candidateIndex: KnowledgeIndex;
1065
+ baseHash: string;
1066
+ candidateHash: string;
1067
+ validation: ValidateKnowledgeResult;
1068
+ readiness?: EvalKnowledgeBundleBuildResult;
1069
+ kbQuality: KnowledgeBaseQualityReport;
1070
+ lifecycle?: RunRagKnowledgeImprovementLoopResult;
1071
+ signal?: AbortSignal;
1127
1072
  }
1128
1073
  type KnowledgeImprovementEvaluator = (input: KnowledgeImprovementEvaluationInput) => Promise<KnowledgeImprovementMetric> | KnowledgeImprovementMetric;
1129
1074
  interface KnowledgeImprovementCandidateRecord {
1130
- iteration: number;
1131
- candidateId: string;
1132
- baseHash: string;
1133
- candidateHash?: string;
1134
- evidenceHash?: string;
1135
- promotionPlanHash?: string;
1136
- /** Durable one-way boundary preventing final-case reuse after interruption. */
1137
- finalEvaluationStartedAt?: string;
1138
- status: KnowledgeImprovementStatus;
1139
- createdAt: string;
1140
- updatedAt: string;
1075
+ iteration: number;
1076
+ candidateId: string;
1077
+ baseHash: string;
1078
+ candidateHash?: string;
1079
+ evidenceHash?: string;
1080
+ promotionPlanHash?: string;
1081
+ /** Durable one-way boundary preventing final-case reuse after interruption. */
1082
+ finalEvaluationStartedAt?: string;
1083
+ status: KnowledgeImprovementStatus;
1084
+ createdAt: string;
1085
+ updatedAt: string;
1141
1086
  }
1142
1087
  interface KnowledgeImprovementRunState {
1143
- runId: string;
1144
- root: string;
1145
- goal: string;
1146
- implementationRef: string;
1147
- status: KnowledgeImprovementStatus;
1148
- baseHash: string;
1149
- createdAt: string;
1150
- updatedAt: string;
1151
- ownerId?: string;
1152
- candidates: KnowledgeImprovementCandidateRecord[];
1153
- promotedCandidateId?: string;
1154
- blockedReason?: string;
1088
+ runId: string;
1089
+ root: string;
1090
+ goal: string;
1091
+ implementationRef: string;
1092
+ status: KnowledgeImprovementStatus;
1093
+ baseHash: string;
1094
+ createdAt: string;
1095
+ updatedAt: string;
1096
+ ownerId?: string;
1097
+ candidates: KnowledgeImprovementCandidateRecord[];
1098
+ promotedCandidateId?: string;
1099
+ blockedReason?: string;
1155
1100
  }
1156
1101
  interface KnowledgeImprovementResult {
1157
- runId: string;
1158
- state: KnowledgeImprovementRunState;
1159
- candidate?: KnowledgeImprovementCandidateRecord;
1160
- evaluation?: KnowledgeImprovementMetric;
1161
- lifecycle?: RunRagKnowledgeImprovementLoopResult;
1162
- promoted: boolean;
1163
- blocked: boolean;
1102
+ runId: string;
1103
+ state: KnowledgeImprovementRunState;
1104
+ candidate?: KnowledgeImprovementCandidateRecord;
1105
+ evaluation?: KnowledgeImprovementMetric;
1106
+ lifecycle?: RunRagKnowledgeImprovementLoopResult;
1107
+ promoted: boolean;
1108
+ blocked: boolean;
1164
1109
  }
1165
1110
  type KnowledgeImprovementTarget = 'candidate' | 'baseline';
1166
1111
  interface KnowledgeImprovementMutationReceipt {
1167
- target: KnowledgeImprovementTarget;
1168
- beforeHash: string;
1169
- afterHash: string;
1170
- changed: boolean;
1171
- transactionId: string | null;
1172
- recovered: boolean;
1112
+ target: KnowledgeImprovementTarget;
1113
+ beforeHash: string;
1114
+ afterHash: string;
1115
+ changed: boolean;
1116
+ transactionId: string | null;
1117
+ recovered: boolean;
1173
1118
  }
1174
1119
  interface KnowledgeImprovementMutationResult extends KnowledgeImprovementResult {
1175
- candidate: KnowledgeImprovementCandidateRecord;
1176
- mutation: KnowledgeImprovementMutationReceipt;
1177
- activationResult?: AgentImprovementActivationResult;
1120
+ candidate: KnowledgeImprovementCandidateRecord;
1121
+ mutation: KnowledgeImprovementMutationReceipt;
1122
+ activationResult?: AgentImprovementActivationResult;
1178
1123
  }
1179
1124
  interface KnowledgeImprovementActivationPersistence {
1180
- activation: AgentImprovementActivation;
1181
- attemptedAt: string;
1182
- identity: string;
1183
- /** May run again after interruption; keep this deterministic and free of external side effects. */
1184
- createResult(mutation: KnowledgeImprovementMutationReceipt): Promise<AgentImprovementActivationResult> | AgentImprovementActivationResult;
1125
+ activation: AgentImprovementActivation;
1126
+ attemptedAt: string;
1127
+ identity: string;
1128
+ /** May run again after interruption; keep this deterministic and free of external side effects. */
1129
+ createResult(mutation: KnowledgeImprovementMutationReceipt): Promise<AgentImprovementActivationResult> | AgentImprovementActivationResult;
1185
1130
  }
1186
1131
  declare const KnowledgeImprovementRunStateSchema: z.ZodObject<{
1187
- runId: z.ZodString;
1188
- root: z.ZodString;
1189
- goal: z.ZodString;
1190
- implementationRef: z.ZodString;
1132
+ runId: z.ZodString;
1133
+ root: z.ZodString;
1134
+ goal: z.ZodString;
1135
+ implementationRef: z.ZodString;
1136
+ status: z.ZodEnum<{
1137
+ blocked: "blocked";
1138
+ "candidate-ready": "candidate-ready";
1139
+ promoted: "promoted";
1140
+ rejected: "rejected";
1141
+ running: "running";
1142
+ }>;
1143
+ baseHash: z.ZodString;
1144
+ createdAt: z.ZodISODateTime;
1145
+ updatedAt: z.ZodISODateTime;
1146
+ ownerId: z.ZodOptional<z.ZodString>;
1147
+ candidates: z.ZodArray<z.ZodObject<{
1148
+ iteration: z.ZodNumber;
1149
+ candidateId: z.ZodString;
1150
+ baseHash: z.ZodString;
1151
+ candidateHash: z.ZodOptional<z.ZodString>;
1152
+ evidenceHash: z.ZodOptional<z.ZodString>;
1153
+ promotionPlanHash: z.ZodOptional<z.ZodString>;
1154
+ finalEvaluationStartedAt: z.ZodOptional<z.ZodISODateTime>;
1191
1155
  status: z.ZodEnum<{
1192
- rejected: "rejected";
1193
- promoted: "promoted";
1194
- running: "running";
1195
- "candidate-ready": "candidate-ready";
1196
- blocked: "blocked";
1156
+ blocked: "blocked";
1157
+ "candidate-ready": "candidate-ready";
1158
+ promoted: "promoted";
1159
+ rejected: "rejected";
1160
+ running: "running";
1197
1161
  }>;
1198
- baseHash: z.ZodString;
1199
1162
  createdAt: z.ZodISODateTime;
1200
1163
  updatedAt: z.ZodISODateTime;
1201
- ownerId: z.ZodOptional<z.ZodString>;
1202
- candidates: z.ZodArray<z.ZodObject<{
1203
- iteration: z.ZodNumber;
1204
- candidateId: z.ZodString;
1205
- baseHash: z.ZodString;
1206
- candidateHash: z.ZodOptional<z.ZodString>;
1207
- evidenceHash: z.ZodOptional<z.ZodString>;
1208
- promotionPlanHash: z.ZodOptional<z.ZodString>;
1209
- finalEvaluationStartedAt: z.ZodOptional<z.ZodISODateTime>;
1210
- status: z.ZodEnum<{
1211
- rejected: "rejected";
1212
- promoted: "promoted";
1213
- running: "running";
1214
- "candidate-ready": "candidate-ready";
1215
- blocked: "blocked";
1216
- }>;
1217
- createdAt: z.ZodISODateTime;
1218
- updatedAt: z.ZodISODateTime;
1219
- }, z.core.$strict>>;
1220
- promotedCandidateId: z.ZodOptional<z.ZodString>;
1221
- blockedReason: z.ZodOptional<z.ZodString>;
1164
+ }, z.core.$strict>>;
1165
+ promotedCandidateId: z.ZodOptional<z.ZodString>;
1166
+ blockedReason: z.ZodOptional<z.ZodString>;
1222
1167
  }, z.core.$strict>;
1223
1168
  declare const KnowledgeImprovementEvidenceSchema: z.ZodObject<{
1224
- kind: z.ZodLiteral<"knowledge-improvement-evidence">;
1225
- runId: z.ZodString;
1226
- candidateId: z.ZodString;
1227
- iteration: z.ZodNumber;
1228
- goalHash: z.ZodString;
1229
- implementationRef: z.ZodString;
1230
- baseHash: z.ZodString;
1231
- candidateHash: z.ZodString;
1232
- promotionPlanHash: z.ZodString;
1233
- validation: z.ZodUnknown;
1234
- readiness: z.ZodNullable<z.ZodUnknown>;
1235
- kbQuality: z.ZodUnknown;
1236
- evaluation: z.ZodObject<{
1237
- score: z.ZodNumber;
1238
- passed: z.ZodBoolean;
1239
- dimensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
1240
- notes: z.ZodOptional<z.ZodString>;
1241
- provenance: z.ZodDiscriminatedUnion<[z.ZodObject<{
1242
- evaluator: z.ZodString;
1243
- version: z.ZodString;
1244
- method: z.ZodLiteral<"deterministic">;
1245
- }, z.core.$strict>, z.ZodObject<{
1246
- evaluator: z.ZodString;
1247
- version: z.ZodString;
1248
- method: z.ZodEnum<{
1249
- composite: "composite";
1250
- sampled: "sampled";
1251
- }>;
1252
- corpusHash: z.ZodString;
1253
- runRecords: z.ZodArray<z.ZodCustom<RunRecord, RunRecord>>;
1254
- }, z.core.$strict>, z.ZodObject<{
1255
- evaluator: z.ZodString;
1256
- version: z.ZodString;
1257
- method: z.ZodLiteral<"model">;
1258
- model: z.ZodString;
1259
- corpusHash: z.ZodString;
1260
- runRecords: z.ZodArray<z.ZodCustom<RunRecord, RunRecord>>;
1261
- }, z.core.$strict>], "method">;
1262
- }, z.core.$strict>;
1263
- lifecycle: z.ZodNullable<z.ZodUnknown>;
1169
+ kind: z.ZodLiteral<"knowledge-improvement-evidence">;
1170
+ runId: z.ZodString;
1171
+ candidateId: z.ZodString;
1172
+ iteration: z.ZodNumber;
1173
+ goalHash: z.ZodString;
1174
+ implementationRef: z.ZodString;
1175
+ baseHash: z.ZodString;
1176
+ candidateHash: z.ZodString;
1177
+ promotionPlanHash: z.ZodString;
1178
+ validation: z.ZodUnknown;
1179
+ readiness: z.ZodNullable<z.ZodUnknown>;
1180
+ kbQuality: z.ZodUnknown;
1181
+ evaluation: z.ZodObject<{
1182
+ score: z.ZodNumber;
1183
+ passed: z.ZodBoolean;
1184
+ dimensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
1185
+ notes: z.ZodOptional<z.ZodString>;
1186
+ provenance: z.ZodDiscriminatedUnion<[z.ZodObject<{
1187
+ evaluator: z.ZodString;
1188
+ version: z.ZodString;
1189
+ method: z.ZodLiteral<"deterministic">;
1190
+ }, z.core.$strict>, z.ZodObject<{
1191
+ evaluator: z.ZodString;
1192
+ version: z.ZodString;
1193
+ method: z.ZodEnum<{
1194
+ composite: "composite";
1195
+ sampled: "sampled";
1196
+ }>;
1197
+ corpusHash: z.ZodString;
1198
+ runRecords: z.ZodArray<z.ZodCustom<RunRecord, RunRecord>>;
1199
+ }, z.core.$strict>, z.ZodObject<{
1200
+ evaluator: z.ZodString;
1201
+ version: z.ZodString;
1202
+ method: z.ZodLiteral<"model">;
1203
+ model: z.ZodString;
1204
+ corpusHash: z.ZodString;
1205
+ runRecords: z.ZodArray<z.ZodCustom<RunRecord, RunRecord>>;
1206
+ }, z.core.$strict>], "method">;
1207
+ }, z.core.$strict>;
1208
+ lifecycle: z.ZodNullable<z.ZodUnknown>;
1264
1209
  }, z.core.$strict>;
1265
1210
  type KnowledgeImprovementEvidence = z.infer<typeof KnowledgeImprovementEvidenceSchema>;
1266
1211
  /** Portable identity of one measured candidate. Paths and mutable run state are deliberately excluded. */
1267
1212
  declare const KnowledgeImprovementCandidateRefSchema: z.ZodObject<{
1268
- kind: z.ZodLiteral<"knowledge-improvement-candidate">;
1269
- runId: z.ZodString;
1270
- candidateId: z.ZodString;
1271
- goalHash: z.ZodString;
1272
- baseHash: z.ZodString;
1273
- candidateHash: z.ZodString;
1274
- evidenceHash: z.ZodString;
1275
- promotionPlanHash: z.ZodString;
1213
+ kind: z.ZodLiteral<"knowledge-improvement-candidate">;
1214
+ runId: z.ZodString;
1215
+ candidateId: z.ZodString;
1216
+ goalHash: z.ZodString;
1217
+ baseHash: z.ZodString;
1218
+ candidateHash: z.ZodString;
1219
+ evidenceHash: z.ZodString;
1220
+ promotionPlanHash: z.ZodString;
1276
1221
  }, z.core.$strict>;
1277
1222
  type KnowledgeImprovementCandidateRef = z.infer<typeof KnowledgeImprovementCandidateRefSchema>;
1278
1223
  interface PromoteKnowledgeCandidateOptions {
1279
- root: string;
1280
- candidate: KnowledgeImprovementCandidateRef;
1281
- activation?: KnowledgeImprovementActivationPersistence;
1282
- ownerId?: string;
1283
- leaseTtlMs?: number;
1284
- now?: () => Date;
1285
- onState?: (state: KnowledgeImprovementRunState) => Promise<void> | void;
1224
+ root: string;
1225
+ candidate: KnowledgeImprovementCandidateRef;
1226
+ activation?: KnowledgeImprovementActivationPersistence;
1227
+ ownerId?: string;
1228
+ leaseTtlMs?: number;
1229
+ now?: () => Date;
1230
+ onState?: (state: KnowledgeImprovementRunState) => Promise<void> | void;
1286
1231
  }
1287
1232
  type RestoreKnowledgeCandidateBaselineOptions = PromoteKnowledgeCandidateOptions;
1288
1233
  interface LoadKnowledgeImprovementActivationResultOptions {
1289
- root: string;
1290
- candidate: KnowledgeImprovementCandidateRef;
1291
- activation: AgentImprovementActivation;
1292
- identity: string;
1234
+ root: string;
1235
+ candidate: KnowledgeImprovementCandidateRef;
1236
+ activation: AgentImprovementActivation;
1237
+ identity: string;
1293
1238
  }
1294
1239
  interface UseKnowledgeImprovementCandidateOptions {
1295
- root: string;
1296
- candidate: KnowledgeImprovementCandidateRef;
1240
+ root: string;
1241
+ candidate: KnowledgeImprovementCandidateRef;
1297
1242
  }
1298
1243
  interface ResolvedKnowledgeImprovementComparisonSnapshot {
1299
- root: string;
1300
- hash: string;
1244
+ root: string;
1245
+ hash: string;
1301
1246
  }
1302
1247
  interface ResolvedKnowledgeImprovementComparison {
1303
- reference: KnowledgeImprovementCandidateRef;
1304
- evaluation: KnowledgeImprovementMetric;
1305
- baseline: ResolvedKnowledgeImprovementComparisonSnapshot;
1306
- candidate: ResolvedKnowledgeImprovementComparisonSnapshot;
1248
+ reference: KnowledgeImprovementCandidateRef;
1249
+ evaluation: KnowledgeImprovementMetric;
1250
+ baseline: ResolvedKnowledgeImprovementComparisonSnapshot;
1251
+ candidate: ResolvedKnowledgeImprovementComparisonSnapshot;
1307
1252
  }
1308
1253
  interface ResolvedKnowledgeImprovementCandidate {
1309
- root: string;
1310
- candidate: KnowledgeImprovementCandidateRef;
1311
- evaluation: KnowledgeImprovementMetric;
1254
+ root: string;
1255
+ candidate: KnowledgeImprovementCandidateRef;
1256
+ evaluation: KnowledgeImprovementMetric;
1312
1257
  }
1313
1258
  interface KnowledgeImprovementRetrievalOptions extends Omit<RunRetrievalImprovementLoopOptions, 'index' | 'runDir'> {
1314
- runDir?: RunRetrievalImprovementLoopOptions['runDir'];
1259
+ runDir?: RunRetrievalImprovementLoopOptions['runDir'];
1315
1260
  }
1316
1261
  type KnowledgeImprovementRagOptimizationRunInput = Parameters<RunRagOptimizationOptions['run']>[0] & {
1317
- runId: string;
1318
- iteration: number;
1319
- candidateId: string;
1320
- root: string;
1321
- baselineRoot: string;
1322
- candidateRoot: string;
1323
- candidateIndex: KnowledgeIndex;
1324
- baseHash: string;
1262
+ runId: string;
1263
+ iteration: number;
1264
+ candidateId: string;
1265
+ root: string;
1266
+ baselineRoot: string;
1267
+ candidateRoot: string;
1268
+ candidateIndex: KnowledgeIndex;
1269
+ baseHash: string;
1325
1270
  };
1326
1271
  interface KnowledgeImprovementRagOptimizationOptions extends Omit<RunRagOptimizationOptions, 'run' | 'runDir'> {
1327
- runDir?: RunRagOptimizationOptions['runDir'];
1328
- run(input: KnowledgeImprovementRagOptimizationRunInput): Promise<RagAnswerEvalArtifact>;
1272
+ runDir?: RunRagOptimizationOptions['runDir'];
1273
+ run(input: KnowledgeImprovementRagOptimizationRunInput): Promise<RagAnswerEvalArtifact>;
1329
1274
  }
1330
1275
  interface KnowledgeImprovementUpdateInput extends RagKnowledgeUpdateInput {
1331
- runId: string;
1332
- iteration: number;
1333
- candidateId: string;
1334
- root: string;
1335
- baselineRoot: string;
1336
- candidateRoot: string;
1337
- baseHash: string;
1276
+ runId: string;
1277
+ iteration: number;
1278
+ candidateId: string;
1279
+ root: string;
1280
+ baselineRoot: string;
1281
+ candidateRoot: string;
1282
+ baseHash: string;
1338
1283
  }
1339
1284
  type KnowledgeImprovementUpdate = (input: KnowledgeImprovementUpdateInput) => Promise<RagKnowledgeUpdateResult> | RagKnowledgeUpdateResult;
1340
1285
  interface KnowledgeImprovementOptions {
1341
- root: string;
1342
- goal: string;
1343
- /**
1344
- * Immutable identity covering callbacks, evaluation policy, models, indexes,
1345
- * external services, and all other behavior that can affect this run.
1346
- */
1347
- implementationRef: string;
1348
- runId?: string;
1349
- ownerId?: string;
1350
- leaseTtlMs?: number;
1351
- resume?: boolean;
1352
- maxCandidates?: number;
1353
- candidateResearchIterations?: number;
1354
- strict?: ValidateKnowledgeOptions['strict'];
1355
- readinessSpecs?: KnowledgeReadinessSpec[];
1356
- readinessTaskId?: string;
1357
- readiness?: Omit<BuildEvalKnowledgeBundleOptions, 'taskId' | 'index' | 'specs'>;
1358
- kbQuality?: KnowledgeBaseQualityOptions;
1359
- step?: RunKnowledgeResearchLoopOptions['step'];
1360
- knowledgeResearch?: Omit<RagKnowledgeResearchOptions, 'root'>;
1361
- ragOptimization?: KnowledgeImprovementRagOptimizationOptions;
1362
- retrieval?: KnowledgeImprovementRetrievalOptions;
1363
- diagnose?: NonNullable<RunRagKnowledgeImprovementLoopOptions['diagnose']>;
1364
- acquireKnowledge?: NonNullable<RunRagKnowledgeImprovementLoopOptions['acquireKnowledge']>;
1365
- updateKnowledge?: KnowledgeImprovementUpdate;
1366
- evaluateAnswers?: NonNullable<RunRagKnowledgeImprovementLoopOptions['evaluateAnswers']>;
1367
- answerQualityCostCeiling?: RunRagKnowledgeImprovementLoopOptions['answerQualityCostCeiling'];
1368
- decidePromotion?: NonNullable<RunRagKnowledgeImprovementLoopOptions['decidePromotion']>;
1369
- enabledPhases?: readonly RagKnowledgeImprovementPhase[];
1370
- requiredPhases?: readonly RagKnowledgeImprovementPhase[];
1371
- /** Repeatable candidate screening that must not use final cases. */
1372
- evaluateDevelopment?: KnowledgeImprovementEvaluator;
1373
- /** Single-use final evaluator. A failure ends the run. */
1374
- evaluate?: KnowledgeImprovementEvaluator;
1375
- signal?: AbortSignal;
1376
- now?: () => Date;
1377
- onState?: (state: KnowledgeImprovementRunState) => Promise<void> | void;
1378
- }
1379
-
1286
+ root: string;
1287
+ goal: string;
1288
+ /**
1289
+ * Immutable identity covering callbacks, evaluation policy, models, indexes,
1290
+ * external services, and all other behavior that can affect this run.
1291
+ */
1292
+ implementationRef: string;
1293
+ runId?: string;
1294
+ ownerId?: string;
1295
+ leaseTtlMs?: number;
1296
+ resume?: boolean;
1297
+ maxCandidates?: number;
1298
+ candidateResearchIterations?: number;
1299
+ strict?: ValidateKnowledgeOptions['strict'];
1300
+ readinessSpecs?: KnowledgeReadinessSpec[];
1301
+ readinessTaskId?: string;
1302
+ readiness?: Omit<BuildEvalKnowledgeBundleOptions, 'taskId' | 'index' | 'specs'>;
1303
+ kbQuality?: KnowledgeBaseQualityOptions;
1304
+ step?: RunKnowledgeResearchLoopOptions['step'];
1305
+ knowledgeResearch?: Omit<RagKnowledgeResearchOptions, 'root'>;
1306
+ ragOptimization?: KnowledgeImprovementRagOptimizationOptions;
1307
+ retrieval?: KnowledgeImprovementRetrievalOptions;
1308
+ diagnose?: NonNullable<RunRagKnowledgeImprovementLoopOptions['diagnose']>;
1309
+ acquireKnowledge?: NonNullable<RunRagKnowledgeImprovementLoopOptions['acquireKnowledge']>;
1310
+ updateKnowledge?: KnowledgeImprovementUpdate;
1311
+ evaluateAnswers?: NonNullable<RunRagKnowledgeImprovementLoopOptions['evaluateAnswers']>;
1312
+ answerQualityCostCeiling?: RunRagKnowledgeImprovementLoopOptions['answerQualityCostCeiling'];
1313
+ decidePromotion?: NonNullable<RunRagKnowledgeImprovementLoopOptions['decidePromotion']>;
1314
+ enabledPhases?: readonly RagKnowledgeImprovementPhase[];
1315
+ requiredPhases?: readonly RagKnowledgeImprovementPhase[];
1316
+ /** Repeatable candidate screening that must not use final cases. */
1317
+ evaluateDevelopment?: KnowledgeImprovementEvaluator;
1318
+ /** Single-use final evaluator. A failure ends the run. */
1319
+ evaluate?: KnowledgeImprovementEvaluator;
1320
+ signal?: AbortSignal;
1321
+ now?: () => Date;
1322
+ onState?: (state: KnowledgeImprovementRunState) => Promise<void> | void;
1323
+ }
1324
+ //#endregion
1325
+ //#region src/kb-improvement/activation.d.ts
1380
1326
  /** Load the durable result for one exact activation without changing knowledge or run state. */
1381
1327
  declare function loadKnowledgeImprovementActivationResult(options: LoadKnowledgeImprovementActivationResultOptions): Promise<AgentImprovementActivationResult | null>;
1382
-
1328
+ //#endregion
1329
+ //#region src/kb-improvement/optimization.d.ts
1383
1330
  type PolicyCandidateOptions = Omit<KnowledgeImprovementOptions, 'root' | 'goal' | 'implementationRef' | 'runId' | 'maxCandidates' | 'step' | 'knowledgeResearch' | 'updateKnowledge'>;
1384
1331
  type PolicyOptimizationBaseOptions<TPolicy extends AgentCandidateJsonValue, TScenario extends Scenario, TArtifact> = Omit<RunSerializedKnowledgeOptimizationOptions<TPolicy, TScenario, TArtifact>, 'baseline' | 'method' | 'trainScenarios' | 'selectionScenarios' | 'finalScenarios' | 'executionRef'>;
1385
1332
  interface OptimizeKnowledgeBasePolicyOptions<TPolicy extends AgentCandidateJsonValue, TScenario extends Scenario, TArtifact> extends PolicyOptimizationBaseOptions<TPolicy, TScenario, TArtifact> {
1386
- root: string;
1387
- goal: string;
1388
- baselinePolicy: TPolicy;
1389
- method: OptimizationMethod<TScenario, TArtifact>;
1390
- trainScenarios: readonly TScenario[];
1391
- selectionScenarios: readonly TScenario[];
1392
- finalScenarios: readonly TScenario[];
1393
- /** Commit or content identity for evaluation, applyPolicy, and external dependencies. */
1394
- policyApplicationRef: string;
1395
- /** Optional namespace for parallel materialization of the same measured policy. */
1396
- candidateRunLabel?: string;
1397
- candidate?: PolicyCandidateOptions;
1398
- applyPolicy(input: KnowledgeImprovementUpdateInput & {
1399
- policy: TPolicy;
1400
- policySurface: string;
1401
- policySurfaceHash: string;
1402
- optimizationMethod: string;
1403
- }): Promise<{
1404
- applied: boolean;
1405
- summary: string;
1406
- metadata?: Record<string, AgentCandidateJsonValue>;
1407
- }>;
1333
+ root: string;
1334
+ goal: string;
1335
+ baselinePolicy: TPolicy;
1336
+ method: OptimizationMethod<TScenario, TArtifact>;
1337
+ trainScenarios: readonly TScenario[];
1338
+ selectionScenarios: readonly TScenario[];
1339
+ finalScenarios: readonly TScenario[];
1340
+ /** Commit or content identity for evaluation, applyPolicy, and external dependencies. */
1341
+ policyApplicationRef: string;
1342
+ /** Optional namespace for parallel materialization of the same measured policy. */
1343
+ candidateRunLabel?: string;
1344
+ candidate?: PolicyCandidateOptions;
1345
+ applyPolicy(input: KnowledgeImprovementUpdateInput & {
1346
+ policy: TPolicy;
1347
+ policySurface: string;
1348
+ policySurfaceHash: string;
1349
+ optimizationMethod: string;
1350
+ }): Promise<{
1351
+ applied: boolean;
1352
+ summary: string;
1353
+ metadata?: Record<string, AgentCandidateJsonValue>;
1354
+ }>;
1408
1355
  }
1409
1356
  interface OptimizeKnowledgeBasePolicyResult<TPolicy extends AgentCandidateJsonValue> {
1410
- optimization: RunSerializedKnowledgeOptimizationResult<TPolicy>;
1411
- improvement: KnowledgeImprovementResult;
1357
+ optimization: RunSerializedKnowledgeOptimizationResult<TPolicy>;
1358
+ improvement: KnowledgeImprovementResult;
1412
1359
  }
1413
1360
  /**
1414
1361
  * Optimizes a serialized KB-maintenance policy, then materializes the selected
@@ -1416,29 +1363,33 @@ interface OptimizeKnowledgeBasePolicyResult<TPolicy extends AgentCandidateJsonVa
1416
1363
  */
1417
1364
  declare function optimizeKnowledgeBasePolicy<TPolicy extends AgentCandidateJsonValue, TScenario extends Scenario, TArtifact>(options: OptimizeKnowledgeBasePolicyOptions<TPolicy, TScenario, TArtifact>): Promise<OptimizeKnowledgeBasePolicyResult<TPolicy>>;
1418
1365
  type KnowledgePolicyDispatch<TPolicy extends AgentCandidateJsonValue, TScenario extends Scenario, TArtifact> = (input: {
1419
- candidate: TPolicy;
1420
- candidateSurface: string;
1421
- candidateSurfaceHash: string;
1422
- scenario: TScenario;
1423
- context: DispatchContext;
1366
+ candidate: TPolicy;
1367
+ candidateSurface: string;
1368
+ candidateSurfaceHash: string;
1369
+ scenario: TScenario;
1370
+ context: DispatchContext;
1424
1371
  }) => Promise<TArtifact>;
1425
-
1372
+ //#endregion
1373
+ //#region src/kb-improvement/run.d.ts
1426
1374
  declare function improveKnowledgeBase(options: KnowledgeImprovementOptions): Promise<KnowledgeImprovementResult>;
1427
-
1375
+ //#endregion
1376
+ //#region src/kb-improvement/state.d.ts
1428
1377
  declare function knowledgeImprovementRunId(root: string, goal: string): string;
1429
1378
  declare function knowledgeImprovementRunDir(root: string, runId: string): string;
1430
1379
  declare function loadKnowledgeImprovementState(root: string, runId: string): Promise<KnowledgeImprovementRunState | null>;
1431
1380
  interface KnowledgeImprovementEvent extends Record<string, unknown> {
1432
- at: string;
1433
- type: string;
1381
+ at: string;
1382
+ type: string;
1434
1383
  }
1435
1384
  declare function loadKnowledgeImprovementEvents(root: string, runId: string): Promise<KnowledgeImprovementEvent[]>;
1436
-
1385
+ //#endregion
1386
+ //#region src/kb-improvement/transition.d.ts
1437
1387
  /** Promote one previously measured candidate without rerunning research or evaluation. */
1438
1388
  declare function promoteKnowledgeCandidate(options: PromoteKnowledgeCandidateOptions): Promise<KnowledgeImprovementMutationResult>;
1439
1389
  /** Restore the frozen baseline paired with one previously measured candidate. */
1440
1390
  declare function restoreKnowledgeCandidateBaseline(options: RestoreKnowledgeCandidateBaselineOptions): Promise<KnowledgeImprovementMutationResult>;
1441
-
1391
+ //#endregion
1392
+ //#region src/kb-improvement/workspace.d.ts
1442
1393
  /** Freeze the exact knowledge bytes and measured evidence a later approval may promote. */
1443
1394
  declare function knowledgeImprovementCandidateRef(result: Pick<KnowledgeImprovementResult, 'runId' | 'state' | 'candidate'>): KnowledgeImprovementCandidateRef;
1444
1395
  /** Use both frozen sides of one measured comparison in isolated, integrity-checked copies. */
@@ -1446,12 +1397,14 @@ declare function withKnowledgeImprovementComparison<T>(options: UseKnowledgeImpr
1446
1397
  /** Use the frozen candidate side of one measured comparison. */
1447
1398
  declare function withKnowledgeImprovementCandidate<T>(options: UseKnowledgeImprovementCandidateOptions, use: (candidate: ResolvedKnowledgeImprovementCandidate) => Promise<T> | T): Promise<T>;
1448
1399
  declare function hashKnowledgeBase(root: string): Promise<string>;
1449
-
1400
+ //#endregion
1401
+ //#region src/agent-candidate.d.ts
1450
1402
  /** Convert a measured knowledge candidate into the shared review and execution identity. */
1451
1403
  declare function toAgentCandidateKnowledgeRef(candidate: KnowledgeImprovementCandidateRef): AgentCandidateKnowledgeRef;
1452
1404
  /** Recover agent-knowledge's candidate identity from the shared contract. */
1453
1405
  declare function fromAgentCandidateKnowledgeRef(candidate: AgentCandidateKnowledgeRef): KnowledgeImprovementCandidateRef;
1454
-
1406
+ //#endregion
1407
+ //#region src/changes.d.ts
1455
1408
  /**
1456
1409
  * Change detection across snapshots of one source's fragments.
1457
1410
  *
@@ -1481,117 +1434,83 @@ declare function fromAgentCandidateKnowledgeRef(candidate: AgentCandidateKnowled
1481
1434
  */
1482
1435
  type KnowledgeChangeKind = 'added' | 'removed' | 'modified';
1483
1436
  interface KnowledgeChange {
1484
- /** Source-scoped id (matches `KnowledgeFragment.id`). */
1485
- fragmentId: string;
1486
- kind: KnowledgeChangeKind;
1487
- /**
1488
- * For `added`: full body of the new fragment.
1489
- * For `removed`: full body of the prior fragment.
1490
- * For `modified`: unified-diff-style payload `{ before, after }` body strings.
1491
- */
1492
- diff?: {
1493
- before?: string;
1494
- after?: string;
1495
- };
1496
- /**
1497
- * Eval dimensions to re-score. Computed as the union of both fragments'
1498
- * `dimensionHints`. The eval cron treats this as a set of campaign tags.
1499
- */
1500
- affectedDimensions: string[];
1501
- /** URL of the affected authority page (from whichever side has it). */
1502
- url?: string;
1503
- /**
1504
- * Source-attested change time. For `modified`, takes the NEXT fragment's
1505
- * `sourceUpdatedAt`. For `removed`, takes the PRIOR fragment's
1506
- * `sourceUpdatedAt`. For `added`, takes the NEXT fragment's
1507
- * `sourceUpdatedAt`. Consumers index changes by this date.
1508
- */
1509
- detectedAt: string;
1437
+ /** Source-scoped id (matches `KnowledgeFragment.id`). */
1438
+ fragmentId: string;
1439
+ kind: KnowledgeChangeKind;
1440
+ /**
1441
+ * For `added`: full body of the new fragment.
1442
+ * For `removed`: full body of the prior fragment.
1443
+ * For `modified`: unified-diff-style payload `{ before, after }` body strings.
1444
+ */
1445
+ diff?: {
1446
+ before?: string;
1447
+ after?: string;
1448
+ };
1449
+ /**
1450
+ * Eval dimensions to re-score. Computed as the union of both fragments'
1451
+ * `dimensionHints`. The eval cron treats this as a set of campaign tags.
1452
+ */
1453
+ affectedDimensions: string[];
1454
+ /** URL of the affected authority page (from whichever side has it). */
1455
+ url?: string;
1456
+ /**
1457
+ * Source-attested change time. For `modified`, takes the NEXT fragment's
1458
+ * `sourceUpdatedAt`. For `removed`, takes the PRIOR fragment's
1459
+ * `sourceUpdatedAt`. For `added`, takes the NEXT fragment's
1460
+ * `sourceUpdatedAt`. Consumers index changes by this date.
1461
+ */
1462
+ detectedAt: string;
1510
1463
  }
1511
1464
  interface DetectChangesResult {
1512
- changes: KnowledgeChange[];
1513
- /** Counts by kind — handy for dashboards. */
1514
- summary: {
1515
- added: number;
1516
- removed: number;
1517
- modified: number;
1518
- };
1519
- /** Non-fatal diagnostics (duplicate ids, dropped unverifiable fragments). */
1520
- warnings: string[];
1465
+ changes: KnowledgeChange[];
1466
+ /** Counts by kind — handy for dashboards. */
1467
+ summary: {
1468
+ added: number;
1469
+ removed: number;
1470
+ modified: number;
1471
+ };
1472
+ /** Non-fatal diagnostics (duplicate ids, dropped unverifiable fragments). */
1473
+ warnings: string[];
1521
1474
  }
1522
1475
  interface DetectChangesOptions {
1523
- /**
1524
- * When true (default), unverifiable fragments are dropped from both
1525
- * sides before comparison. Set false ONLY when debugging block-page
1526
- * issues — comparing against unverifiable content emits false
1527
- * `removed`/`modified` changes.
1528
- */
1529
- skipUnverifiable?: boolean;
1530
- /**
1531
- * When provided, only changes whose `affectedDimensions` intersect this
1532
- * set are returned. Useful for cron loops that schedule per-dimension
1533
- * eval campaigns and only care about a subset.
1534
- */
1535
- filterDimensions?: string[];
1476
+ /**
1477
+ * When true (default), unverifiable fragments are dropped from both
1478
+ * sides before comparison. Set false ONLY when debugging block-page
1479
+ * issues — comparing against unverifiable content emits false
1480
+ * `removed`/`modified` changes.
1481
+ */
1482
+ skipUnverifiable?: boolean;
1483
+ /**
1484
+ * When provided, only changes whose `affectedDimensions` intersect this
1485
+ * set are returned. Useful for cron loops that schedule per-dimension
1486
+ * eval campaigns and only care about a subset.
1487
+ */
1488
+ filterDimensions?: string[];
1536
1489
  }
1537
1490
  declare function detectChanges(prev: KnowledgeFragment[], next: KnowledgeFragment[], options?: DetectChangesOptions): DetectChangesResult;
1538
-
1491
+ //#endregion
1492
+ //#region src/chunking.d.ts
1539
1493
  interface ChunkingOptions {
1540
- targetChars: number;
1541
- maxChars: number;
1542
- minChars: number;
1543
- overlapChars: number;
1494
+ targetChars: number;
1495
+ maxChars: number;
1496
+ minChars: number;
1497
+ overlapChars: number;
1544
1498
  }
1545
1499
  interface KnowledgeChunk {
1546
- index: number;
1547
- text: string;
1548
- headingPath: string;
1549
- charStart: number;
1550
- charEnd: number;
1551
- oversized: boolean;
1500
+ index: number;
1501
+ text: string;
1502
+ headingPath: string;
1503
+ charStart: number;
1504
+ charEnd: number;
1505
+ oversized: boolean;
1552
1506
  }
1553
1507
  declare function chunkMarkdown(content: string, options?: Partial<ChunkingOptions>): KnowledgeChunk[];
1554
1508
  declare function stripFrontmatter(content: string): {
1555
- body: string;
1556
- bodyOffset: number;
1509
+ body: string;
1510
+ bodyOffset: number;
1557
1511
  };
1558
-
1559
- /**
1560
- * Claim-grounding mode for `runVerifiedResearchLoop`.
1561
- *
1562
- * The two-agent loop's existing verifier judges a source's on-topic RELEVANCE
1563
- * (is this page about the goal?). On the topic sets we have measured, its
1564
- * cleanliness win is dominated by DE-DUPLICATION — which a deterministic
1565
- * content-hash / canonical-URL check captures at ~none of the LLM premium (see
1566
- * `docs/results/cost-quality.md`). That makes the LLM verifier look expensive
1567
- * for what a cheap rule already does.
1568
- *
1569
- * Claim-grounding targets a DIFFERENT, harder error band: a citation that is
1570
- * relevant and unique but **misattributed** — the page is on-topic, the URL is
1571
- * real, yet the specific CLAIM the source is cited for does NOT actually appear
1572
- * in the page. This is the citation-fabrication failure mode of LLM research:
1573
- * the model writes a plausible sentence and hangs a real URL off it that never
1574
- * says any such thing. Neither de-dup nor a relevance judge catches it (both can
1575
- * pass a misattributed-but-on-topic page); only checking the claim against the
1576
- * fetched text does.
1577
- *
1578
- * The check is EXECUTABLE GROUND TRUTH, not another LLM opinion: the worker
1579
- * attaches the specific claim it is citing the source for, and the verifier
1580
- * tests whether that claim is PRESENT (verbatim, normalized, or as a sufficient
1581
- * content-word overlap / close paraphrase) in the `htmlToText` output of the
1582
- * page the worker actually fetched. A claim that is not grounded is rejected as
1583
- * misattributed. Because the oracle is deterministic text presence — not a model
1584
- * call — it is a deployable, non-oracle verifier: it can run in production with
1585
- * zero inference cost, OR be composed with the LLM relevance verifier so the
1586
- * loop rejects BOTH off-topic AND misattributed sources.
1587
- *
1588
- * This module is content-free and any-topic: it adds (1) a way for a proposal to
1589
- * carry the claim it is cited for, (2) the `groundClaimInText` oracle, and (3) a
1590
- * `ResearchDriver` that gates on grounding. It composes the existing
1591
- * `ResearchDriver` / `ResearchSourceProposal` contracts and the shipped
1592
- * `htmlToText`; it reinvents none of them.
1593
- */
1594
-
1512
+ //#endregion
1513
+ //#region src/claim-grounding.d.ts
1595
1514
  /**
1596
1515
  * Metadata key under which a proposal carries the specific claim it is cited
1597
1516
  * for. The worker sets `metadata[citedClaimKey] = '<the claim>'`; the
@@ -1603,31 +1522,31 @@ declare function citedClaimOf(source: ResearchSourceProposal): string | undefine
1603
1522
  /** Attach a cited claim to a proposal (immutably returns a new proposal). */
1604
1523
  declare function withCitedClaim(source: ResearchSourceProposal, claim: string): ResearchSourceProposal;
1605
1524
  interface GroundingResult {
1606
- /** True when the claim is sufficiently present in the page text. */
1607
- grounded: boolean;
1608
- /** How the claim matched (or why it didn't). For audit/notes. */
1609
- mode: 'verbatim' | 'normalized' | 'overlap' | 'absent' | 'empty-claim' | 'empty-text';
1610
- /**
1611
- * Fraction of the claim's content words found in the page text. 1 for a
1612
- * verbatim/normalized hit; the measured overlap otherwise.
1613
- */
1614
- overlap: number;
1615
- /** Content words present in the claim but NOT in the page text. */
1616
- missingWords: string[];
1525
+ /** True when the claim is sufficiently present in the page text. */
1526
+ grounded: boolean;
1527
+ /** How the claim matched (or why it didn't). For audit/notes. */
1528
+ mode: 'verbatim' | 'normalized' | 'overlap' | 'absent' | 'empty-claim' | 'empty-text';
1529
+ /**
1530
+ * Fraction of the claim's content words found in the page text. 1 for a
1531
+ * verbatim/normalized hit; the measured overlap otherwise.
1532
+ */
1533
+ overlap: number;
1534
+ /** Content words present in the claim but NOT in the page text. */
1535
+ missingWords: string[];
1617
1536
  }
1618
1537
  interface GroundClaimOptions {
1619
- /**
1620
- * Minimum fraction of the claim's content words that must appear in the page
1621
- * text to count as a close paraphrase when there is no verbatim/normalized
1622
- * hit. Default 0.7 — a high bar, because a misattribution is exactly a claim
1623
- * whose specific words the page does not contain.
1624
- */
1625
- minOverlap?: number;
1626
- /**
1627
- * Content words shorter than this are ignored (drops "the", "of", "is", …)
1628
- * and never count toward overlap. Default 3.
1629
- */
1630
- minWordLength?: number;
1538
+ /**
1539
+ * Minimum fraction of the claim's content words that must appear in the page
1540
+ * text to count as a close paraphrase when there is no verbatim/normalized
1541
+ * hit. Default 0.7 — a high bar, because a misattribution is exactly a claim
1542
+ * whose specific words the page does not contain.
1543
+ */
1544
+ minOverlap?: number;
1545
+ /**
1546
+ * Content words shorter than this are ignored (drops "the", "of", "is", …)
1547
+ * and never count toward overlap. Default 3.
1548
+ */
1549
+ minWordLength?: number;
1631
1550
  }
1632
1551
  /**
1633
1552
  * THE ORACLE. Is `claim` grounded in `pageText` (the `htmlToText` output of the
@@ -1646,21 +1565,21 @@ interface GroundClaimOptions {
1646
1565
  */
1647
1566
  declare function groundClaimInText(claim: string, pageText: string, options?: GroundClaimOptions): GroundingResult;
1648
1567
  interface ClaimGroundingDriverOptions extends GroundClaimOptions {
1649
- /**
1650
- * Optional second verifier to compose AFTER grounding passes. When set, a
1651
- * source must BOTH ground its claim AND pass this verifier (e.g. the LLM
1652
- * relevance driver's `verifySource`). Lets the loop reject off-topic AND
1653
- * misattributed sources in one driver. Omit for the pure, zero-inference
1654
- * grounding gate.
1655
- */
1656
- relevanceVerifier?: (source: ResearchSourceProposal, ctx: SourceVerificationContext) => Promise<SourceVerdict> | SourceVerdict;
1657
- /**
1658
- * What to do when a proposal carries NO cited claim. `'reject'` (default) is
1659
- * fail-closed: in claim-grounding mode every source must declare what it is
1660
- * cited for, so an un-annotated source is treated as ungrounded. `'accept'`
1661
- * lets unannotated sources through to the relevance verifier, if present.
1662
- */
1663
- onMissingClaim?: 'reject' | 'accept';
1568
+ /**
1569
+ * Optional second verifier to compose AFTER grounding passes. When set, a
1570
+ * source must BOTH ground its claim AND pass this verifier (e.g. the LLM
1571
+ * relevance driver's `verifySource`). Lets the loop reject off-topic AND
1572
+ * misattributed sources in one driver. Omit for the pure, zero-inference
1573
+ * grounding gate.
1574
+ */
1575
+ relevanceVerifier?: (source: ResearchSourceProposal, ctx: SourceVerificationContext) => Promise<SourceVerdict> | SourceVerdict;
1576
+ /**
1577
+ * What to do when a proposal carries NO cited claim. `'reject'` (default) is
1578
+ * fail-closed: in claim-grounding mode every source must declare what it is
1579
+ * cited for, so an un-annotated source is treated as ungrounded. `'accept'`
1580
+ * lets unannotated sources through to the relevance verifier, if present.
1581
+ */
1582
+ onMissingClaim?: 'reject' | 'accept';
1664
1583
  }
1665
1584
  /**
1666
1585
  * A `ResearchDriver`-shaped verifier (just the `verifySource` arm) that gates on
@@ -1673,10 +1592,10 @@ interface ClaimGroundingDriverOptions extends GroundClaimOptions {
1673
1592
  */
1674
1593
  declare function createClaimGroundingVerifier(options?: ClaimGroundingDriverOptions): (source: ResearchSourceProposal, ctx: SourceVerificationContext) => Promise<SourceVerdict>;
1675
1594
  interface WorkerClaimDecorationOptions {
1676
- router?: RouterClient;
1677
- router_options?: TangleRouterOptions;
1678
- /** Max output tokens for the claim-extraction call. Default 1200 (glm floor). */
1679
- maxTokens?: number;
1595
+ router?: RouterClient;
1596
+ router_options?: TangleRouterOptions;
1597
+ /** Max output tokens for the claim-extraction call. Default 1200 (glm floor). */
1598
+ maxTokens?: number;
1680
1599
  }
1681
1600
  /**
1682
1601
  * Ask an LLM to state, for one source, the single specific factual claim a
@@ -1692,98 +1611,72 @@ interface WorkerClaimDecorationOptions {
1692
1611
  * `onMissingClaim` policy then decides).
1693
1612
  */
1694
1613
  declare function createClaimDecorator(options?: WorkerClaimDecorationOptions): (source: ResearchSourceProposal, goal: string) => Promise<ResearchSourceProposal>;
1695
-
1696
- /**
1697
- * The SINGLE-AGENT COLLECTION driver — the blind-collection baseline (Arm A).
1698
- *
1699
- * This is the honest null the depth A/B is measured against. The other drivers
1700
- * spend extra inference to do something differentiated:
1701
- * - `createVerifyingResearchDriver` runs an LLM gate per source (Arm B),
1702
- * - `createResearchDrivingDriver` extracts claims, tracks corroboration, and
1703
- * synthesizes deep follow-up questions to drive depth (Arm C).
1704
- *
1705
- * This driver does NONE of that. It is a pass-through: it accepts every source
1706
- * the worker proposes and contributes no research, no gating, and no steering of
1707
- * its own. The loop still dedups exact-uri duplicates before calling
1708
- * `verifySource` (that is the loop's job, not the driver's), and the default
1709
- * `foldGaps` (a plain bulleted list of the still-open readiness gaps) still folds
1710
- * the gaps into the worker's next prompt — so the worker keeps researching, but
1711
- * NOTHING intelligent sits between the worker and the knowledge base.
1712
- *
1713
- * In other words: ONE agent (the worker) collects sources round after round, and
1714
- * the "driver" is an inert rubber stamp. That is exactly what "single-agent
1715
- * collection" means — the topology with zero coordinator intelligence — so its
1716
- * material-facts score is the floor every other arm must beat to justify its
1717
- * extra inference cost.
1718
- *
1719
- * It adds NO router calls of its own: `verifySource` is a synchronous accept and
1720
- * `foldGaps` is omitted so the loop uses its built-in gap list. So Arm A's cost
1721
- * is the worker's cost alone — the cleanest possible blind-collection baseline.
1722
- */
1723
-
1614
+ //#endregion
1615
+ //#region src/collection-research-driver.d.ts
1724
1616
  /**
1725
1617
  * Build the single-agent collection driver. Accepts every source; never gates,
1726
1618
  * never researches, never steers beyond the loop's default open-gap list. The
1727
1619
  * worker is the only agent that thinks.
1728
1620
  */
1729
1621
  declare function createCollectionResearchDriver(): ResearchDriver;
1730
-
1622
+ //#endregion
1623
+ //#region src/discovery.d.ts
1731
1624
  interface DiscoveryTask {
1732
- id: string;
1733
- goal: string;
1734
- query?: string;
1735
- sourceHints?: string[];
1736
- metadata?: Record<string, unknown>;
1625
+ id: string;
1626
+ goal: string;
1627
+ query?: string;
1628
+ sourceHints?: string[];
1629
+ metadata?: Record<string, unknown>;
1737
1630
  }
1738
1631
  interface DiscoveryResult {
1739
- taskId: string;
1740
- summary: string;
1741
- sourceUris?: string[];
1742
- claims?: Array<{
1743
- text: string;
1744
- sourceUri?: string;
1745
- confidence?: number;
1746
- }>;
1747
- followUpTasks?: DiscoveryTask[];
1748
- metadata?: Record<string, unknown>;
1632
+ taskId: string;
1633
+ summary: string;
1634
+ sourceUris?: string[];
1635
+ claims?: Array<{
1636
+ text: string;
1637
+ sourceUri?: string;
1638
+ confidence?: number;
1639
+ }>;
1640
+ followUpTasks?: DiscoveryTask[];
1641
+ metadata?: Record<string, unknown>;
1749
1642
  }
1750
1643
  interface KnowledgeDiscoveryWorker {
1751
- run(task: DiscoveryTask, signal?: AbortSignal): Promise<DiscoveryResult> | DiscoveryResult;
1644
+ run(task: DiscoveryTask, signal?: AbortSignal): Promise<DiscoveryResult> | DiscoveryResult;
1752
1645
  }
1753
1646
  interface KnowledgeDiscoveryDispatcher {
1754
- dispatch(tasks: DiscoveryTask[], options?: {
1755
- concurrency?: number;
1756
- signal?: AbortSignal;
1757
- }): Promise<DiscoveryResult[]>;
1647
+ dispatch(tasks: DiscoveryTask[], options?: {
1648
+ concurrency?: number;
1649
+ signal?: AbortSignal;
1650
+ }): Promise<DiscoveryResult[]>;
1758
1651
  }
1759
1652
  type DiscoveryLoopStopReason = 'complete' | 'max-rounds' | 'max-tasks' | 'aborted';
1760
1653
  interface DiscoveryLoopRound {
1761
- round: number;
1762
- tasks: DiscoveryTask[];
1763
- results: DiscoveryResult[];
1764
- queuedFollowUps: DiscoveryTask[];
1654
+ round: number;
1655
+ tasks: DiscoveryTask[];
1656
+ results: DiscoveryResult[];
1657
+ queuedFollowUps: DiscoveryTask[];
1765
1658
  }
1766
1659
  interface DiscoveryLoopResult {
1767
- stopReason: DiscoveryLoopStopReason;
1768
- tasksDispatched: number;
1769
- results: DiscoveryResult[];
1770
- rounds: DiscoveryLoopRound[];
1771
- /** Tasks retained, not dropped, when a configured limit stops the loop. */
1772
- pendingTasks: DiscoveryTask[];
1773
- /** Structurally identical task identities ignored to prevent cycles. */
1774
- duplicateTaskIds: string[];
1660
+ stopReason: DiscoveryLoopStopReason;
1661
+ tasksDispatched: number;
1662
+ results: DiscoveryResult[];
1663
+ rounds: DiscoveryLoopRound[];
1664
+ /** Tasks retained, not dropped, when a configured limit stops the loop. */
1665
+ pendingTasks: DiscoveryTask[];
1666
+ /** Structurally identical task identities ignored to prevent cycles. */
1667
+ duplicateTaskIds: string[];
1775
1668
  }
1776
1669
  interface RunDiscoveryLoopOptions {
1777
- dispatcher: KnowledgeDiscoveryDispatcher;
1778
- initialTasks: readonly DiscoveryTask[];
1779
- /** Maximum follow-up depth including the initial dispatch. Default 3. */
1780
- maxRounds?: number;
1781
- /** Maximum tasks dispatched across all rounds. Default 24. */
1782
- maxTasks?: number;
1783
- /** Forwarded to the dispatcher. Default 4. */
1784
- concurrency?: number;
1785
- signal?: AbortSignal;
1786
- onRound?: (round: DiscoveryLoopRound) => Promise<void> | void;
1670
+ dispatcher: KnowledgeDiscoveryDispatcher;
1671
+ initialTasks: readonly DiscoveryTask[];
1672
+ /** Maximum follow-up depth including the initial dispatch. Default 3. */
1673
+ maxRounds?: number;
1674
+ /** Maximum tasks dispatched across all rounds. Default 24. */
1675
+ maxTasks?: number;
1676
+ /** Forwarded to the dispatcher. Default 4. */
1677
+ concurrency?: number;
1678
+ signal?: AbortSignal;
1679
+ onRound?: (round: DiscoveryLoopRound) => Promise<void> | void;
1787
1680
  }
1788
1681
  /**
1789
1682
  * Dispatch discovery tasks and recursively pursue worker-proposed follow-ups.
@@ -1793,36 +1686,38 @@ interface RunDiscoveryLoopOptions {
1793
1686
  */
1794
1687
  declare function runDiscoveryLoop(options: RunDiscoveryLoopOptions): Promise<DiscoveryLoopResult>;
1795
1688
  declare function createLocalDiscoveryDispatcher(worker: KnowledgeDiscoveryWorker): KnowledgeDiscoveryDispatcher;
1796
-
1689
+ //#endregion
1690
+ //#region src/events.d.ts
1797
1691
  interface KnowledgeEventQuery {
1798
- type?: KnowledgeEventType;
1799
- target?: string;
1800
- limit?: number;
1692
+ type?: KnowledgeEventType;
1693
+ target?: string;
1694
+ limit?: number;
1801
1695
  }
1802
1696
  declare function createKnowledgeEvent(input: {
1803
- type: KnowledgeEventType;
1804
- actor?: string;
1805
- target?: string;
1806
- metadata?: Record<string, unknown>;
1807
- now?: () => Date;
1697
+ type: KnowledgeEventType;
1698
+ actor?: string;
1699
+ target?: string;
1700
+ metadata?: Record<string, unknown>;
1701
+ now?: () => Date;
1808
1702
  }): KnowledgeEvent;
1809
-
1703
+ //#endregion
1704
+ //#region src/filesystem-search-provider.d.ts
1810
1705
  interface FileSystemSearchProviderOptions {
1811
- /** Knowledge-base root containing `knowledge/` and `.agent-knowledge/`. */
1812
- root: string;
1813
- /** Optional warm index, useful when the caller already built one. */
1814
- index?: KnowledgeIndex;
1815
- /** Default result count for `search()`. Defaults to 10. */
1816
- defaultLimit?: number;
1817
- /**
1818
- * `manual` caches the index until `refresh: true` or `invalidate()`.
1819
- * `always` rebuilds from disk on every search.
1820
- */
1821
- refresh?: 'manual' | 'always';
1706
+ /** Knowledge-base root containing `knowledge/` and `.agent-knowledge/`. */
1707
+ root: string;
1708
+ /** Optional warm index, useful when the caller already built one. */
1709
+ index?: KnowledgeIndex;
1710
+ /** Default result count for `search()`. Defaults to 10. */
1711
+ defaultLimit?: number;
1712
+ /**
1713
+ * `manual` caches the index until `refresh: true` or `invalidate()`.
1714
+ * `always` rebuilds from disk on every search.
1715
+ */
1716
+ refresh?: 'manual' | 'always';
1822
1717
  }
1823
1718
  interface FileSystemSearchOptions {
1824
- limit?: number;
1825
- refresh?: boolean;
1719
+ limit?: number;
1720
+ refresh?: boolean;
1826
1721
  }
1827
1722
  /**
1828
1723
  * File-first retrieval over an `agent-knowledge` KB.
@@ -1831,19 +1726,20 @@ interface FileSystemSearchOptions {
1831
1726
  * markdown knowledge files before adding embeddings, rerankers, or a vector DB.
1832
1727
  */
1833
1728
  declare class FileSystemSearchProvider {
1834
- readonly root: string;
1835
- private index;
1836
- private readonly defaultLimit;
1837
- private readonly refreshMode;
1838
- constructor(options: FileSystemSearchProviderOptions);
1839
- getIndex(options?: FileSystemSearchOptions): Promise<KnowledgeIndex>;
1840
- search(query: string, options?: FileSystemSearchOptions): Promise<KnowledgeSearchResult[]>;
1841
- retrieve(query: string, options?: FileSystemSearchOptions): Promise<RetrievedKnowledgeHit[]>;
1842
- asRetrievalEvalRetriever(): RetrievalEvalRetriever;
1843
- invalidate(): void;
1729
+ readonly root: string;
1730
+ private index;
1731
+ private readonly defaultLimit;
1732
+ private readonly refreshMode;
1733
+ constructor(options: FileSystemSearchProviderOptions);
1734
+ getIndex(options?: FileSystemSearchOptions): Promise<KnowledgeIndex>;
1735
+ search(query: string, options?: FileSystemSearchOptions): Promise<KnowledgeSearchResult[]>;
1736
+ retrieve(query: string, options?: FileSystemSearchOptions): Promise<RetrievedKnowledgeHit[]>;
1737
+ asRetrievalEvalRetriever(): RetrievalEvalRetriever;
1738
+ invalidate(): void;
1844
1739
  }
1845
1740
  declare function createFileSystemSearchProvider(options: FileSystemSearchProviderOptions): FileSystemSearchProvider;
1846
-
1741
+ //#endregion
1742
+ //#region src/freshness.d.ts
1847
1743
  /**
1848
1744
  * Knowledge freshness store: tracks when each `(workspaceId, sourceId)` pair
1849
1745
  * was last successfully refreshed, and reports staleness against a TTL.
@@ -1874,44 +1770,44 @@ declare function createFileSystemSearchProvider(options: FileSystemSearchProvide
1874
1770
  */
1875
1771
  /** Identity for one freshness record. */
1876
1772
  interface FreshnessKey {
1877
- workspaceId: string;
1878
- sourceId: string;
1773
+ workspaceId: string;
1774
+ sourceId: string;
1879
1775
  }
1880
1776
  /** TTL bound for staleness checks. */
1881
1777
  interface FreshnessTtl extends FreshnessKey {
1882
- /** Milliseconds; the record is stale when `Date.now() - last() > ttlMs`. */
1883
- ttlMs: number;
1884
- /** Injected clock for deterministic tests; defaults to system time. */
1885
- now?: Date;
1778
+ /** Milliseconds; the record is stale when `Date.now() - last() > ttlMs`. */
1779
+ ttlMs: number;
1780
+ /** Injected clock for deterministic tests; defaults to system time. */
1781
+ now?: Date;
1886
1782
  }
1887
1783
  /** Mark argument. */
1888
1784
  interface FreshnessMark extends FreshnessKey {
1889
- when: Date;
1890
- /** Optional content hash captured at refresh time; aids debugging. */
1891
- contentHash?: string;
1785
+ when: Date;
1786
+ /** Optional content hash captured at refresh time; aids debugging. */
1787
+ contentHash?: string;
1892
1788
  }
1893
1789
  interface KnowledgeFreshnessStore {
1894
- /** Last refresh time, or null if never refreshed. */
1895
- last(key: FreshnessKey): Promise<Date | null>;
1896
- /** Record a successful refresh. */
1897
- mark(input: FreshnessMark): Promise<void>;
1898
- /** True iff `last(key)` is null or older than `ttlMs`. */
1899
- stale(input: FreshnessTtl): Promise<boolean>;
1900
- /** All records for a workspace. */
1901
- list(workspaceId: string): Promise<FreshnessRecord[]>;
1790
+ /** Last refresh time, or null if never refreshed. */
1791
+ last(key: FreshnessKey): Promise<Date | null>;
1792
+ /** Record a successful refresh. */
1793
+ mark(input: FreshnessMark): Promise<void>;
1794
+ /** True iff `last(key)` is null or older than `ttlMs`. */
1795
+ stale(input: FreshnessTtl): Promise<boolean>;
1796
+ /** All records for a workspace. */
1797
+ list(workspaceId: string): Promise<FreshnessRecord[]>;
1902
1798
  }
1903
1799
  interface FreshnessRecord {
1904
- workspaceId: string;
1905
- sourceId: string;
1906
- lastRefreshedAt: string;
1907
- contentHash?: string;
1800
+ workspaceId: string;
1801
+ sourceId: string;
1802
+ lastRefreshedAt: string;
1803
+ contentHash?: string;
1908
1804
  }
1909
1805
  interface FileSystemFreshnessStoreOptions {
1910
- /**
1911
- * Knowledge root. The store writes to `<root>/.agent-knowledge/freshness.json`,
1912
- * mirroring the convention used by `sources.json`.
1913
- */
1914
- root: string;
1806
+ /**
1807
+ * Knowledge root. The store writes to `<root>/.agent-knowledge/freshness.json`,
1808
+ * mirroring the convention used by `sources.json`.
1809
+ */
1810
+ root: string;
1915
1811
  }
1916
1812
  /**
1917
1813
  * Filesystem-backed implementation. Single JSON file per knowledge root,
@@ -1939,74 +1835,80 @@ declare function createFileSystemFreshnessStore(options: FileSystemFreshnessStor
1939
1835
  * ```
1940
1836
  */
1941
1837
  interface D1Adapter {
1942
- get(workspaceId: string, sourceId: string): Promise<FreshnessRecord | null>;
1943
- upsert(record: FreshnessRecord): Promise<void>;
1944
- listByWorkspace(workspaceId: string): Promise<FreshnessRecord[]>;
1838
+ get(workspaceId: string, sourceId: string): Promise<FreshnessRecord | null>;
1839
+ upsert(record: FreshnessRecord): Promise<void>;
1840
+ listByWorkspace(workspaceId: string): Promise<FreshnessRecord[]>;
1945
1841
  }
1946
1842
  declare function createD1FreshnessStoreStub(adapter: D1Adapter): KnowledgeFreshnessStore;
1947
-
1843
+ //#endregion
1844
+ //#region src/frontmatter.d.ts
1948
1845
  interface ParsedFrontmatter {
1949
- frontmatter: Record<string, unknown>;
1950
- body: string;
1846
+ frontmatter: Record<string, unknown>;
1847
+ body: string;
1951
1848
  }
1952
1849
  declare function parseFrontmatter(content: string): ParsedFrontmatter;
1953
1850
  declare function formatFrontmatter(frontmatter: Record<string, unknown>, body: string): string;
1954
-
1851
+ //#endregion
1852
+ //#region src/graph.d.ts
1955
1853
  declare function buildKnowledgeGraph(pages: KnowledgePage[]): KnowledgeGraph;
1956
-
1854
+ //#endregion
1855
+ //#region src/ids.d.ts
1957
1856
  declare function sha256(text: string): string;
1958
1857
  declare function slugify(input: string): string;
1959
1858
  declare function stableId(prefix: string, content: string): string;
1960
-
1859
+ //#endregion
1860
+ //#region src/indexer.d.ts
1961
1861
  declare function buildKnowledgeIndex(root: string): Promise<KnowledgeIndex>;
1962
1862
  declare function writeKnowledgeIndex(root: string): Promise<KnowledgeIndex>;
1963
-
1863
+ //#endregion
1864
+ //#region src/inspect.d.ts
1964
1865
  interface KnowledgeInspection {
1965
- pageCount: number;
1966
- sourceCount: number;
1967
- expiredSourceCount: number;
1968
- staleSourceCount: number;
1969
- edgeCount: number;
1970
- findingCount: number;
1971
- blockingFindingCount: number;
1972
- topPages: Array<{
1973
- path: string;
1974
- title: string;
1975
- degree: number;
1976
- sources: number;
1977
- }>;
1978
- sourceFreshness: SourceFreshnessInspection[];
1979
- findings: KnowledgeLintFinding[];
1866
+ pageCount: number;
1867
+ sourceCount: number;
1868
+ expiredSourceCount: number;
1869
+ staleSourceCount: number;
1870
+ edgeCount: number;
1871
+ findingCount: number;
1872
+ blockingFindingCount: number;
1873
+ topPages: Array<{
1874
+ path: string;
1875
+ title: string;
1876
+ degree: number;
1877
+ sources: number;
1878
+ }>;
1879
+ sourceFreshness: SourceFreshnessInspection[];
1880
+ findings: KnowledgeLintFinding[];
1980
1881
  }
1981
1882
  interface SourceFreshnessInspection {
1982
- id: string;
1983
- title?: string;
1984
- uri: string;
1985
- status: 'fresh' | 'expired' | 'unknown';
1986
- validUntil?: string;
1987
- lastVerifiedAt?: string;
1883
+ id: string;
1884
+ title?: string;
1885
+ uri: string;
1886
+ status: 'fresh' | 'expired' | 'unknown';
1887
+ validUntil?: string;
1888
+ lastVerifiedAt?: string;
1988
1889
  }
1989
1890
  declare function inspectKnowledgeIndex(index: KnowledgeIndex, options?: {
1990
- now?: Date;
1891
+ now?: Date;
1991
1892
  }): KnowledgeInspection;
1992
1893
  interface KnowledgeExplanation {
1993
- target: string;
1994
- page?: KnowledgePage;
1995
- sources: Array<{
1996
- id: string;
1997
- title?: string;
1998
- uri: string;
1999
- }>;
2000
- links: string[];
2001
- inbound: string[];
2002
- related: Array<{
2003
- path: string;
2004
- title: string;
2005
- score: number;
2006
- }>;
1894
+ target: string;
1895
+ page?: KnowledgePage;
1896
+ sources: Array<{
1897
+ id: string;
1898
+ title?: string;
1899
+ uri: string;
1900
+ }>;
1901
+ links: string[];
1902
+ inbound: string[];
1903
+ related: Array<{
1904
+ path: string;
1905
+ title: string;
1906
+ score: number;
1907
+ }>;
2007
1908
  }
2008
1909
  declare function explainKnowledgeTarget(index: KnowledgeIndex, target: string): KnowledgeExplanation;
2009
-
1910
+ //#endregion
1911
+ //#region src/investment-thesis-set.d.ts
2010
1912
  /**
2011
1913
  * HELD-OUT INVESTMENT-RESEARCH EVAL SET.
2012
1914
  *
@@ -2056,71 +1958,71 @@ declare function explainKnowledgeTarget(index: KnowledgeIndex, target: string):
2056
1958
  */
2057
1959
  /** A required answer component: satisfied when any synonym fragment is present. */
2058
1960
  interface ExpectedGroup {
2059
- /** Human label for the component (for the doc / audit). */
2060
- label: string;
2061
- /** Case-insensitive substring fragments; any one present satisfies the group. */
2062
- anyOf: string[];
1961
+ /** Human label for the component (for the doc / audit). */
1962
+ label: string;
1963
+ /** Case-insensitive substring fragments; any one present satisfies the group. */
1964
+ anyOf: string[];
2063
1965
  }
2064
1966
  /** Lens the fact belongs to — so a set can be checked for category coverage. */
2065
1967
  type MaterialFactLens = 'concentration' | 'leverage' | 'margin-trend' | 'liquidity' | 'capital-return' | 'governance' | 'off-balance-sheet' | 'regulatory';
2066
1968
  /** One held-out material fact with a checkable expected answer + its provenance. */
2067
1969
  interface MaterialFact {
2068
- /** Stable id, `ticker/fN`. */
2069
- id: string;
2070
- /** Which analyst lens this fact exercises. For coverage + the doc. */
2071
- lens: MaterialFactLens;
2072
- /**
2073
- * The material fact, in plain words — for the doc/audit. NEVER shown to a loop.
2074
- * This is the thing a thorough analyst would flag and a ticker search misses.
2075
- */
2076
- fact: string;
2077
- /**
2078
- * The checkable answer as required keyword GROUPS. The thesis text must contain
2079
- * at least `minGroups` of these groups (default: all). A group is satisfied
2080
- * when ANY of its `anyOf` fragments appears (case-insensitive substring).
2081
- */
2082
- expected: ExpectedGroup[];
2083
- /**
2084
- * Minimum number of `expected` groups the thesis must contain to count the
2085
- * fact SURFACED. Default = all groups (the strict bar). Lowered (and documented
2086
- * inline) only when the fact is genuinely satisfiable by a subset.
2087
- */
2088
- minGroups?: number;
2089
- /**
2090
- * PROVENANCE. The primary source URL this fact was read from — an SEC EDGAR
2091
- * 10-K primary document, fetched live during curation.
2092
- */
2093
- sourceUrl: string;
2094
- /**
2095
- * The literal value / phrase read out of `sourceUrl` that grounds the fact.
2096
- * This is the "cite the actual filing + the value" requirement — verbatim or
2097
- * near-verbatim from the filing, with the figure.
2098
- */
2099
- evidence: string;
1970
+ /** Stable id, `ticker/fN`. */
1971
+ id: string;
1972
+ /** Which analyst lens this fact exercises. For coverage + the doc. */
1973
+ lens: MaterialFactLens;
1974
+ /**
1975
+ * The material fact, in plain words — for the doc/audit. NEVER shown to a loop.
1976
+ * This is the thing a thorough analyst would flag and a ticker search misses.
1977
+ */
1978
+ fact: string;
1979
+ /**
1980
+ * The checkable answer as required keyword GROUPS. The thesis text must contain
1981
+ * at least `minGroups` of these groups (default: all). A group is satisfied
1982
+ * when ANY of its `anyOf` fragments appears (case-insensitive substring).
1983
+ */
1984
+ expected: ExpectedGroup[];
1985
+ /**
1986
+ * Minimum number of `expected` groups the thesis must contain to count the
1987
+ * fact SURFACED. Default = all groups (the strict bar). Lowered (and documented
1988
+ * inline) only when the fact is genuinely satisfiable by a subset.
1989
+ */
1990
+ minGroups?: number;
1991
+ /**
1992
+ * PROVENANCE. The primary source URL this fact was read from — an SEC EDGAR
1993
+ * 10-K primary document, fetched live during curation.
1994
+ */
1995
+ sourceUrl: string;
1996
+ /**
1997
+ * The literal value / phrase read out of `sourceUrl` that grounds the fact.
1998
+ * This is the "cite the actual filing + the value" requirement — verbatim or
1999
+ * near-verbatim from the filing, with the figure.
2000
+ */
2001
+ evidence: string;
2100
2002
  }
2101
2003
  /** A company + the cutoff a loop researches as-of + its held-out material facts. */
2102
2004
  interface CompanyEvalCase {
2103
- /** Ticker as of the cutoff. */
2104
- ticker: string;
2105
- /** Legal name as of the cutoff (what the loop is told to research). */
2106
- company: string;
2107
- /** SEC Central Index Key (CIK), zero-stripped — the EDGAR filer id. */
2108
- cik: string;
2109
- /**
2110
- * Research-as-of date (ISO). The loop must reason as if it is this date; every
2111
- * `evidence` value was knowable on or before it. >= 18 months before this set
2112
- * was curated, so the outcome is known but is NOT a checklist item.
2113
- */
2114
- cutoff: string;
2115
- /** Sector, for coverage / the curation-bias disclosure. */
2116
- sector: string;
2117
- /**
2118
- * The known POST-cutoff outcome — recorded for the reader ONLY, never graded.
2119
- * Keeping it out of `facts` is what makes the set hindsight-free.
2120
- */
2121
- knownOutcome: string;
2122
- /** The held-out material facts for this company. */
2123
- facts: MaterialFact[];
2005
+ /** Ticker as of the cutoff. */
2006
+ ticker: string;
2007
+ /** Legal name as of the cutoff (what the loop is told to research). */
2008
+ company: string;
2009
+ /** SEC Central Index Key (CIK), zero-stripped — the EDGAR filer id. */
2010
+ cik: string;
2011
+ /**
2012
+ * Research-as-of date (ISO). The loop must reason as if it is this date; every
2013
+ * `evidence` value was knowable on or before it. >= 18 months before this set
2014
+ * was curated, so the outcome is known but is NOT a checklist item.
2015
+ */
2016
+ cutoff: string;
2017
+ /** Sector, for coverage / the curation-bias disclosure. */
2018
+ sector: string;
2019
+ /**
2020
+ * The known POST-cutoff outcome — recorded for the reader ONLY, never graded.
2021
+ * Keeping it out of `facts` is what makes the set hindsight-free.
2022
+ */
2023
+ knownOutcome: string;
2024
+ /** The held-out material facts for this company. */
2025
+ facts: MaterialFact[];
2124
2026
  }
2125
2027
  /**
2126
2028
  * The eval set. 5 public companies, 5-8 held-out material facts each, every fact
@@ -2143,54 +2045,35 @@ declare const investmentThesisSet: CompanyEvalCase[];
2143
2045
  * reproducible — so the eval never leaks into a model the loop could observe.
2144
2046
  */
2145
2047
  declare function gradeFactAgainstText(fact: MaterialFact, thesisText: string): {
2146
- surfaced: boolean;
2147
- groupsFound: number;
2148
- groupsTotal: number;
2149
- foundLabels: string[];
2048
+ surfaced: boolean;
2049
+ groupsFound: number;
2050
+ groupsTotal: number;
2051
+ foundLabels: string[];
2150
2052
  };
2151
2053
  /** Grade a whole company's thesis text: how many of its held-out facts it surfaces. */
2152
2054
  declare function gradeCompanyAgainstText(company: CompanyEvalCase, thesisText: string): {
2153
- surfaced: number;
2154
- total: number;
2155
- perFact: ReturnType<typeof gradeFactAgainstText>[];
2055
+ surfaced: number;
2056
+ total: number;
2057
+ perFact: ReturnType<typeof gradeFactAgainstText>[];
2156
2058
  };
2157
2059
  /** Total held-out facts across the set (the denominator the doc reports). */
2158
2060
  declare function totalMaterialFacts(set?: CompanyEvalCase[]): number;
2159
2061
  /** Count facts per lens across the set — used to report (and bound) curation bias. */
2160
2062
  declare function lensDistribution(set?: CompanyEvalCase[]): Record<MaterialFactLens, number>;
2161
-
2162
- /**
2163
- * The INVESTMENT-THESIS research task.
2164
- *
2165
- * Given `{ company, ticker, cik, cutoff }`, drive the SAME two-agent research
2166
- * loop the ML deep-question A/B uses (`runVerifiedResearchLoop` + the real web
2167
- * worker) to research the company AS OF the cutoff — web + SEC EDGAR, both public
2168
- * — and produce an investment-thesis PAGE in the knowledge base: a judgment, the
2169
- * drivers, and the risks, grounded in what it fetched.
2170
- *
2171
- * This file builds NOTHING new for the loop: it composes the existing worker +
2172
- * driver + loop, supplies the readiness specs that steer the worker toward the
2173
- * filing-level evidence (the analyst lenses), then writes a synthesis thesis page
2174
- * the metric (`materialFactsSurfaced`) grades against the HELD-OUT checklist.
2175
- *
2176
- * THE FIREWALL: the task is told ONLY company + ticker + cutoff (+ the generic
2177
- * analyst-lens readiness specs every company gets). It is NEVER shown the
2178
- * checklist. The checklist is read only afterward, by the metric. So a high score
2179
- * is research depth, not teaching-to-the-test.
2180
- */
2181
-
2063
+ //#endregion
2064
+ //#region src/investment-thesis-task.d.ts
2182
2065
  /** The minimal brief a thesis run is given — the firewall boundary. */
2183
2066
  interface ThesisTaskInput {
2184
- /** Legal name as of the cutoff — what the loop researches. */
2185
- company: string;
2186
- /** Ticker as of the cutoff. */
2187
- ticker: string;
2188
- /** SEC Central Index Key (CIK), zero-stripped — the EDGAR filer id. */
2189
- cik: string;
2190
- /** Research-as-of date (ISO). The loop must reason as if it is this date. */
2191
- cutoff: string;
2192
- /** Sector, for the readiness query context (NOT a checklist hint). */
2193
- sector?: string;
2067
+ /** Legal name as of the cutoff — what the loop researches. */
2068
+ company: string;
2069
+ /** Ticker as of the cutoff. */
2070
+ ticker: string;
2071
+ /** SEC Central Index Key (CIK), zero-stripped — the EDGAR filer id. */
2072
+ cik: string;
2073
+ /** Research-as-of date (ISO). The loop must reason as if it is this date. */
2074
+ cutoff: string;
2075
+ /** Sector, for the readiness query context (NOT a checklist hint). */
2076
+ sector?: string;
2194
2077
  }
2195
2078
  /**
2196
2079
  * The generic analyst-lens readiness specs every company gets. They are the ONLY
@@ -2206,26 +2089,26 @@ interface ThesisTaskInput {
2206
2089
  */
2207
2090
  declare function thesisReadinessSpecs(input: ThesisTaskInput): KnowledgeReadinessSpec[];
2208
2091
  interface ThesisRunOptions {
2209
- /** The KB root the loop writes into. */
2210
- root: string;
2211
- /** Shared router client (web search + chat). Defaults to env creds. */
2212
- router: RouterClient;
2213
- /** The driver — verify/dedup or research-driving. The loop's coordinator. */
2214
- driver: ResearchDriver;
2215
- /** Round budget. Default 3 (the depth-driving driver needs >1). */
2216
- maxRounds?: number;
2217
- /** Worker tuning forwarded to `createWebResearchWorker`. */
2218
- workerOptions?: Omit<WebResearchWorkerOptions, 'router'>;
2219
- /** Max tokens for the synthesis pass. Default 1600 (above glm-5.2's reasoning floor). */
2220
- synthesisMaxTokens?: number;
2221
- signal?: AbortSignal;
2092
+ /** The KB root the loop writes into. */
2093
+ root: string;
2094
+ /** Shared router client (web search + chat). Defaults to env creds. */
2095
+ router: RouterClient;
2096
+ /** The driver — verify/dedup or research-driving. The loop's coordinator. */
2097
+ driver: ResearchDriver;
2098
+ /** Round budget. Default 3 (the depth-driving driver needs >1). */
2099
+ maxRounds?: number;
2100
+ /** Worker tuning forwarded to `createWebResearchWorker`. */
2101
+ workerOptions?: Omit<WebResearchWorkerOptions, 'router'>;
2102
+ /** Max tokens for the synthesis pass. Default 1600 (above glm-5.2's reasoning floor). */
2103
+ synthesisMaxTokens?: number;
2104
+ signal?: AbortSignal;
2222
2105
  }
2223
2106
  interface ThesisRunResult {
2224
- loop: VerifiedResearchLoopResult;
2225
- /** The synthesized thesis text. */
2226
- thesis: string;
2227
- /** Path of the thesis page written into the KB. */
2228
- thesisPath: string;
2107
+ loop: VerifiedResearchLoopResult;
2108
+ /** The synthesized thesis text. */
2109
+ thesis: string;
2110
+ /** Path of the thesis page written into the KB. */
2111
+ thesisPath: string;
2229
2112
  }
2230
2113
  /**
2231
2114
  * Run the full thesis task: drive the two-agent loop to research the company AS
@@ -2234,101 +2117,79 @@ interface ThesisRunResult {
2234
2117
  * `materialFactsSurfaced(root, checklist)` — the checklist is never passed here.
2235
2118
  */
2236
2119
  declare function runInvestmentThesisTask(input: ThesisTaskInput, options: ThesisRunOptions): Promise<ThesisRunResult>;
2237
-
2120
+ //#endregion
2121
+ //#region src/kb-store.d.ts
2238
2122
  interface KbStore {
2239
- putSource(source: SourceRecord): Promise<void>;
2240
- getSource(id: string): Promise<SourceRecord | null>;
2241
- listSources(): Promise<SourceRecord[]>;
2242
- putPage(page: KnowledgePage): Promise<void>;
2243
- getPage(idOrPath: string): Promise<KnowledgePage | null>;
2244
- listPages(): Promise<KnowledgePage[]>;
2245
- putIndex(index: KnowledgeIndex): Promise<void>;
2246
- getIndex(): Promise<KnowledgeIndex | null>;
2247
- putEvent(event: KnowledgeEvent): Promise<void>;
2248
- listEvents(query?: KnowledgeEventQuery): Promise<KnowledgeEvent[]>;
2123
+ putSource(source: SourceRecord): Promise<void>;
2124
+ getSource(id: string): Promise<SourceRecord | null>;
2125
+ listSources(): Promise<SourceRecord[]>;
2126
+ putPage(page: KnowledgePage): Promise<void>;
2127
+ getPage(idOrPath: string): Promise<KnowledgePage | null>;
2128
+ listPages(): Promise<KnowledgePage[]>;
2129
+ putIndex(index: KnowledgeIndex): Promise<void>;
2130
+ getIndex(): Promise<KnowledgeIndex | null>;
2131
+ putEvent(event: KnowledgeEvent): Promise<void>;
2132
+ listEvents(query?: KnowledgeEventQuery): Promise<KnowledgeEvent[]>;
2249
2133
  }
2250
2134
  declare class MemoryKbStore implements KbStore {
2251
- private readonly sources;
2252
- private readonly pages;
2253
- private readonly events;
2254
- private index;
2255
- putSource(source: SourceRecord): Promise<void>;
2256
- getSource(id: string): Promise<SourceRecord | null>;
2257
- listSources(): Promise<SourceRecord[]>;
2258
- putPage(page: KnowledgePage): Promise<void>;
2259
- getPage(idOrPath: string): Promise<KnowledgePage | null>;
2260
- listPages(): Promise<KnowledgePage[]>;
2261
- putIndex(index: KnowledgeIndex): Promise<void>;
2262
- getIndex(): Promise<KnowledgeIndex | null>;
2263
- putEvent(event: KnowledgeEvent): Promise<void>;
2264
- listEvents(query?: KnowledgeEventQuery): Promise<KnowledgeEvent[]>;
2135
+ private readonly sources;
2136
+ private readonly pages;
2137
+ private readonly events;
2138
+ private index;
2139
+ putSource(source: SourceRecord): Promise<void>;
2140
+ getSource(id: string): Promise<SourceRecord | null>;
2141
+ listSources(): Promise<SourceRecord[]>;
2142
+ putPage(page: KnowledgePage): Promise<void>;
2143
+ getPage(idOrPath: string): Promise<KnowledgePage | null>;
2144
+ listPages(): Promise<KnowledgePage[]>;
2145
+ putIndex(index: KnowledgeIndex): Promise<void>;
2146
+ getIndex(): Promise<KnowledgeIndex | null>;
2147
+ putEvent(event: KnowledgeEvent): Promise<void>;
2148
+ listEvents(query?: KnowledgeEventQuery): Promise<KnowledgeEvent[]>;
2265
2149
  }
2266
2150
  declare class FileSystemKbStore implements KbStore {
2267
- private readonly dir;
2268
- constructor(dir: string);
2269
- putSource(source: SourceRecord): Promise<void>;
2270
- getSource(id: string): Promise<SourceRecord | null>;
2271
- listSources(): Promise<SourceRecord[]>;
2272
- putPage(page: KnowledgePage): Promise<void>;
2273
- getPage(idOrPath: string): Promise<KnowledgePage | null>;
2274
- listPages(): Promise<KnowledgePage[]>;
2275
- putIndex(index: KnowledgeIndex): Promise<void>;
2276
- getIndex(): Promise<KnowledgeIndex | null>;
2277
- putEvent(event: KnowledgeEvent): Promise<void>;
2278
- listEvents(query?: KnowledgeEventQuery): Promise<KnowledgeEvent[]>;
2279
- private updateIndex;
2280
- private readIndex;
2281
- private readEvents;
2282
- }
2283
-
2151
+ private readonly dir;
2152
+ constructor(dir: string);
2153
+ putSource(source: SourceRecord): Promise<void>;
2154
+ getSource(id: string): Promise<SourceRecord | null>;
2155
+ listSources(): Promise<SourceRecord[]>;
2156
+ putPage(page: KnowledgePage): Promise<void>;
2157
+ getPage(idOrPath: string): Promise<KnowledgePage | null>;
2158
+ listPages(): Promise<KnowledgePage[]>;
2159
+ putIndex(index: KnowledgeIndex): Promise<void>;
2160
+ getIndex(): Promise<KnowledgeIndex | null>;
2161
+ putEvent(event: KnowledgeEvent): Promise<void>;
2162
+ listEvents(query?: KnowledgeEventQuery): Promise<KnowledgeEvent[]>;
2163
+ private updateIndex;
2164
+ private readIndex;
2165
+ private readEvents;
2166
+ }
2167
+ //#endregion
2168
+ //#region src/lint.d.ts
2284
2169
  declare function lintKnowledgeIndex(index: KnowledgeIndex): KnowledgeLintFinding[];
2285
-
2286
- /**
2287
- * `materialFactsSurfaced` — the held-out investment-research METRIC.
2288
- *
2289
- * Given a knowledge base a research loop built for a company and the company's
2290
- * HELD-OUT material-fact checklist (`tests/eval/investment-thesis-set.ts`, never
2291
- * shown to the loop), this returns the FRACTION of checklist items the KB's
2292
- * pages surface + ground. The check is the same `$0`, model-free, deterministic
2293
- * substring grader the loop's checklist already ships (`gradeFactAgainstText` /
2294
- * `gradeCompanyAgainstText`) — so the answer key never reaches a model the loop
2295
- * could observe, exactly the firewall the ML deep-question exam uses.
2296
- *
2297
- * The ONLY thing this file adds over the raw grader is the KB→text join: it reads
2298
- * the curated pages (and the raw source text) the loop wrote and hands their
2299
- * concatenation to the grader. That join mirrors `kbText` in the research-quality
2300
- * A/B (research-driving-ab.test.ts) so the thesis metric and the ML-exam metric
2301
- * read a KB the same way.
2302
- *
2303
- * WHY pages AND source text: an honest thesis surfaces a buried fact in its
2304
- * curated thesis PAGE (the judgment), but a loop whose page is thin while its
2305
- * fetched filings are rich should still get credit for what it actually pulled.
2306
- * Grading the union is the faithful, not the lenient, choice — it rewards the
2307
- * loop that REACHED the filing even if its synthesis was terse, and it cannot
2308
- * manufacture a hit the underlying evidence does not contain.
2309
- */
2310
-
2170
+ //#endregion
2171
+ //#region src/material-facts-metric.d.ts
2311
2172
  /** Per-fact grade plus the fact's id/lens, for the audit trail. */
2312
2173
  interface FactResult {
2313
- id: string;
2314
- lens: CompanyEvalCase['facts'][number]['lens'];
2315
- surfaced: boolean;
2316
- groupsFound: number;
2317
- groupsTotal: number;
2318
- foundLabels: string[];
2174
+ id: string;
2175
+ lens: CompanyEvalCase['facts'][number]['lens'];
2176
+ surfaced: boolean;
2177
+ groupsFound: number;
2178
+ groupsTotal: number;
2179
+ foundLabels: string[];
2319
2180
  }
2320
2181
  /** The metric's result for one company: the surfaced fraction + the per-fact trail. */
2321
2182
  interface MaterialFactsResult {
2322
- ticker: string;
2323
- company: string;
2324
- /** Held-out facts the KB surfaced + grounded. */
2325
- surfaced: number;
2326
- /** Total held-out facts for this company (the denominator). */
2327
- total: number;
2328
- /** `surfaced / total` in [0, 1]. */
2329
- fraction: number;
2330
- /** Per-fact grade, in checklist order, for the doc / audit. */
2331
- perFact: FactResult[];
2183
+ ticker: string;
2184
+ company: string;
2185
+ /** Held-out facts the KB surfaced + grounded. */
2186
+ surfaced: number;
2187
+ /** Total held-out facts for this company (the denominator). */
2188
+ total: number;
2189
+ /** `surfaced / total` in [0, 1]. */
2190
+ fraction: number;
2191
+ /** Per-fact grade, in checklist order, for the doc / audit. */
2192
+ perFact: FactResult[];
2332
2193
  }
2333
2194
  /**
2334
2195
  * Join a KB index into the single text blob the grader scans: every curated PAGE
@@ -2356,82 +2217,59 @@ declare function materialFactsSurfacedInText(company: CompanyEvalCase, kbText: s
2356
2217
  * never passed to the loop, and is read only here, after the loop finished.
2357
2218
  */
2358
2219
  declare function materialFactsSurfaced(kb: string | KnowledgeIndex, checklist: CompanyEvalCase): Promise<MaterialFactsResult>;
2359
-
2220
+ //#endregion
2221
+ //#region src/mutation-lock.d.ts
2360
2222
  interface PendingKnowledgeMutation {
2361
- transactionId: string;
2362
- purpose: string;
2363
- recoveryOwner?: string;
2364
- createdAt: string;
2365
- direction: 'apply' | 'rollback';
2366
- paths: string[];
2223
+ transactionId: string;
2224
+ purpose: string;
2225
+ recoveryOwner?: string;
2226
+ createdAt: string;
2227
+ direction: 'apply' | 'rollback';
2228
+ paths: string[];
2367
2229
  }
2368
2230
  interface RecoverPendingKnowledgeMutationOptions {
2369
- transactionId: string;
2370
- action: 'apply' | 'rollback';
2231
+ transactionId: string;
2232
+ action: 'apply' | 'rollback';
2371
2233
  }
2372
2234
  declare function inspectPendingKnowledgeMutation(root: string): Promise<PendingKnowledgeMutation | null>;
2373
2235
  declare function recoverPendingKnowledgeMutation(root: string, options: RecoverPendingKnowledgeMutationOptions): Promise<void>;
2374
-
2375
- /**
2376
- * Bridge from `AnalystFinding` (agent-eval) to knowledge proposals.
2377
- *
2378
- * Closes the failure → wiki side of the recursive-self-improvement
2379
- * loop: a knowledge-gap or knowledge-poisoning finding produced by an
2380
- * analyst becomes a concrete proposal an operator (or auto-merge bot)
2381
- * can review and apply. The bridge is intentionally lossless on the
2382
- * fail-loud side — a finding the parser can't classify returns a
2383
- * `KnowledgeProposalParseError` rather than a silent skip, so the
2384
- * loop never accepts an underspecified edit.
2385
- *
2386
- * Subject grammar this bridge understands (analyst-side convention,
2387
- * stamped in the kind prompts):
2388
- *
2389
- * agent-knowledge:wiki:<page-slug> create / update page
2390
- * agent-knowledge:wiki:<page-slug>#<heading> insert section under page
2391
- * agent-knowledge:claim:<topic> draft claim row
2392
- * agent-knowledge:raw:<source-id> lift raw → curated
2393
- * agent-knowledge:stale:<page-slug> mark page superseded
2394
- *
2395
- * Anything else (websearch:outdated:*, tool-doc:*, system-prompt:*,
2396
- * memory:*) is NOT a knowledge-base concern and returns `null` so the
2397
- * loop's improvement-applier handles it.
2398
- */
2399
-
2236
+ //#endregion
2237
+ //#region src/propose-from-finding.d.ts
2400
2238
  interface KnowledgeProposal {
2401
- /**
2402
- * Stable id derived from the finding so cross-run diffs share an
2403
- * identity. Re-proposing the same finding produces the same id.
2404
- */
2405
- id: string;
2406
- /** The finding that generated this proposal — useful for audit + revert. */
2407
- sourceFindingId: string;
2408
- /** What the proposal does. */
2409
- kind: 'create-page' | 'update-page' | 'append-section' | 'create-claim' | 'lift-raw' | 'mark-stale';
2410
- /** Locus on disk (page slug or claim topic). */
2411
- locus: string;
2412
- /**
2413
- * Page write blocks the standard `applyKnowledgeWriteBlocks` consumer
2414
- * accepts. Empty for proposals that don't change page text (e.g.
2415
- * `create-claim` produces a `claim` field instead).
2416
- */
2417
- writeBlocks: KnowledgeWriteBlock[];
2418
- /**
2419
- * Granular claim draft for proposals whose unit-of-change is a claim
2420
- * row rather than a whole page. `status: 'draft'` until reviewed.
2421
- */
2422
- claim?: KnowledgeClaim;
2423
- /** Per-proposal metadata: severity, confidence, source span. */
2424
- metadata: {
2425
- severity: AnalystSeverity;
2426
- confidence: number;
2427
- evidence_uri?: string;
2428
- analyst_id: string;
2429
- };
2239
+ /**
2240
+ * Stable id derived from the finding so cross-run diffs share an
2241
+ * identity. Re-proposing the same finding produces the same id.
2242
+ */
2243
+ id: string;
2244
+ /** The finding that generated this proposal — useful for audit + revert. */
2245
+ sourceFindingId: string;
2246
+ /** What the proposal does. */
2247
+ kind: 'create-page' | 'update-page' | 'append-section' | 'create-claim' | 'lift-raw' | 'mark-stale';
2248
+ /** Locus on disk (page slug or claim topic). */
2249
+ locus: string;
2250
+ /**
2251
+ * Page write blocks the standard `applyKnowledgeWriteBlocks` consumer
2252
+ * accepts. Empty for proposals that don't change page text (e.g.
2253
+ * `create-claim` produces a `claim` field instead).
2254
+ */
2255
+ writeBlocks: KnowledgeWriteBlock[];
2256
+ /**
2257
+ * Granular claim draft for proposals whose unit-of-change is a claim
2258
+ * row rather than a whole page. `status: 'draft'` until reviewed.
2259
+ */
2260
+ claim?: KnowledgeClaim;
2261
+ /** Per-proposal metadata: severity, confidence, source span. */
2262
+ metadata: {
2263
+ severity: AnalystSeverity;
2264
+ confidence: number;
2265
+ evidence_uri?: string;
2266
+ analyst_id: string;
2267
+ };
2430
2268
  }
2431
2269
  declare class KnowledgeProposalParseError extends Error {
2432
- readonly findingId: string;
2433
- readonly subject: string;
2434
- constructor(findingId: string, subject: string, message: string);
2270
+ readonly findingId: string;
2271
+ readonly subject: string;
2272
+ constructor(findingId: string, subject: string, message: string);
2435
2273
  }
2436
2274
  /**
2437
2275
  * Convert one `AnalystFinding` into a knowledge proposal. Returns
@@ -2452,194 +2290,153 @@ declare function proposeFromFinding(finding: AnalystFinding): KnowledgeProposal
2452
2290
  * decides per-error whether to abort or continue.
2453
2291
  */
2454
2292
  interface ProposeFromFindingsResult {
2455
- proposals: KnowledgeProposal[];
2456
- skipped: number;
2457
- errors: KnowledgeProposalParseError[];
2293
+ proposals: KnowledgeProposal[];
2294
+ skipped: number;
2295
+ errors: KnowledgeProposalParseError[];
2458
2296
  }
2459
2297
  declare function proposeFromFindings(findings: ReadonlyArray<AnalystFinding>): ProposeFromFindingsResult;
2460
-
2298
+ //#endregion
2299
+ //#region src/readiness-check.d.ts
2461
2300
  interface EvaluateKnowledgeBaseReadinessOptions {
2462
- root: string;
2463
- goal: string;
2464
- readinessSpecs?: readonly KnowledgeReadinessSpec[];
2465
- readinessTaskId?: string;
2466
- readiness?: Omit<BuildEvalKnowledgeBundleOptions, 'taskId' | 'index' | 'specs'>;
2467
- strict?: ValidateKnowledgeOptions['strict'];
2468
- kbQuality?: KnowledgeBaseQualityOptions;
2301
+ root: string;
2302
+ goal: string;
2303
+ readinessSpecs?: readonly KnowledgeReadinessSpec[];
2304
+ readinessTaskId?: string;
2305
+ readiness?: Omit<BuildEvalKnowledgeBundleOptions, 'taskId' | 'index' | 'specs'>;
2306
+ strict?: ValidateKnowledgeOptions['strict'];
2307
+ kbQuality?: KnowledgeBaseQualityOptions;
2469
2308
  }
2470
2309
  interface KnowledgeBaseReadinessEvaluation {
2471
- ready: boolean;
2472
- summary: string;
2473
- index: KnowledgeIndex;
2474
- validation: ValidateKnowledgeResult;
2475
- readiness?: EvalKnowledgeBundleBuildResult;
2476
- kbQuality: KnowledgeBaseQualityReport;
2477
- dimensions: {
2478
- validation: number;
2479
- kb_quality: number;
2480
- blocking_readiness: number;
2481
- };
2310
+ ready: boolean;
2311
+ summary: string;
2312
+ index: KnowledgeIndex;
2313
+ validation: ValidateKnowledgeResult;
2314
+ readiness?: EvalKnowledgeBundleBuildResult;
2315
+ kbQuality: KnowledgeBaseQualityReport;
2316
+ dimensions: {
2317
+ validation: number;
2318
+ kb_quality: number;
2319
+ blocking_readiness: number;
2320
+ };
2482
2321
  }
2483
2322
  declare function evaluateKnowledgeBaseReadiness(options: EvaluateKnowledgeBaseReadinessOptions): Promise<KnowledgeBaseReadinessEvaluation>;
2484
-
2323
+ //#endregion
2324
+ //#region src/release.d.ts
2485
2325
  interface KnowledgeReleaseReport {
2486
- release: KnowledgeRelease;
2487
- scorecard: ReleaseConfidenceScorecard;
2488
- candidateRuns: RunRecord[];
2489
- baselineRuns: RunRecord[];
2326
+ release: KnowledgeRelease;
2327
+ scorecard: ReleaseConfidenceScorecard;
2328
+ candidateRuns: RunRecord[];
2329
+ baselineRuns: RunRecord[];
2490
2330
  }
2491
2331
  /**
2492
2332
  * Build a knowledge release report from candidate and baseline run records,
2493
2333
  * optional trace evidence, and an optional decision record.
2494
2334
  */
2495
2335
  interface KnowledgeReleaseInput {
2496
- candidateId: string;
2497
- baselineId?: string;
2498
- candidateRuns: RunRecord[];
2499
- baselineRuns?: RunRecord[];
2500
- traces?: ReleaseTraceEvidence[];
2501
- gateDecision?: GateDecision | null;
2502
- /** Scenario corpus used to prove train and holdout split coverage. */
2503
- scenarios?: readonly DatasetScenario[];
2504
- /**
2505
- * Require both a holdout scenario and a holdout run.
2506
- * Provide `scenarios` with at least one `split: 'holdout'` item when true.
2507
- */
2508
- hasHoldout?: boolean;
2509
- /** Candidate is the search-best variant — a promotion precondition. Default true. */
2510
- promotedIsBest?: boolean;
2511
- createdAt?: string;
2512
- minScore?: number;
2336
+ candidateId: string;
2337
+ baselineId?: string;
2338
+ candidateRuns: RunRecord[];
2339
+ baselineRuns?: RunRecord[];
2340
+ traces?: ReleaseTraceEvidence[];
2341
+ gateDecision?: GateDecision | null;
2342
+ /** Scenario corpus used to prove train and holdout split coverage. */
2343
+ scenarios?: readonly DatasetScenario[];
2344
+ /**
2345
+ * Require both a holdout scenario and a holdout run.
2346
+ * Provide `scenarios` with at least one `split: 'holdout'` item when true.
2347
+ */
2348
+ hasHoldout?: boolean;
2349
+ /** Candidate is the search-best variant — a promotion precondition. Default true. */
2350
+ promotedIsBest?: boolean;
2351
+ createdAt?: string;
2352
+ minScore?: number;
2513
2353
  }
2514
2354
  declare function knowledgeReleaseReport(input: KnowledgeReleaseInput): KnowledgeReleaseReport;
2515
-
2516
- /**
2517
- * Research-DRIVING driver for `runVerifiedResearchLoop`.
2518
- *
2519
- * The shipped drivers all FILTER the worker's sources:
2520
- * - `createVerifyingResearchDriver` judges on-topic relevance,
2521
- * - `createAdaptiveResearchDriver` dedups then triages then escalates,
2522
- * - `createClaimGroundingVerifier` rejects misattributed citations.
2523
- *
2524
- * This driver does the OPPOSITE job: instead of narrowing the worker's output,
2525
- * it DRIVES the research DEEPER each round. Its value is not "fewer sources" —
2526
- * it is "more answered, better-corroborated sub-questions". Concretely, each
2527
- * round it:
2528
- *
2529
- * 1. EXTRACTS the key claims from the worker's new sources (one LLM pass per
2530
- * source, in `verifySource`; falls back to a deterministic sentence-pull
2531
- * when the model is unavailable so a round never silently extracts nothing).
2532
- * 2. TRACKS each claim's support — the set of INDEPENDENT sources (by canonical
2533
- * host) that assert it — and detects CONTRADICTIONS between a new claim and
2534
- * one already on the ledger.
2535
- * 3. GENERATES the next round's DEEP sub-questions from the accumulated claims,
2536
- * in four kinds — comparative ("how does X's tradeoff differ from Y's?"),
2537
- * mechanism ("under what precise condition does X fail?"), gap ("what
2538
- * specific result is missing?"), and contradiction ("does any source
2539
- * challenge claim Z?").
2540
- * 4. FLAGS weakly-supported claims (only ONE independent source) and
2541
- * contradicted claims as INVALIDATION targets and demands the worker find
2542
- * corroborating / refuting evidence for them.
2543
- * 5. FOLDS the deep sub-questions + invalidation challenges into the worker's
2544
- * next prompt via the loop's `foldGaps` → `steer` channel — that is the
2545
- * mechanism that drives DEPTH and VALIDATION rather than breadth.
2546
- *
2547
- * COMPLETION (`isComplete` / the `done` judgment the caller gates on) does NOT
2548
- * look at source COUNT. It is done only when every deep sub-question it raised
2549
- * has been addressed AND every key claim is either supported by >= 2 independent
2550
- * sources OR explicitly marked CONTESTED (a contradiction the loop surfaced and
2551
- * could not resolve). A KB with twenty sources all asserting one unchallenged
2552
- * claim is NOT done; a KB whose handful of claims are each corroborated or
2553
- * contested IS.
2554
- *
2555
- * It reuses `runVerifiedResearchLoop` (it is a plain `ResearchDriver`), the web
2556
- * worker, `sha256` (claim identity), `canonicalizeUrl` (independent-source
2557
- * identity), and the `RouterClient` chat surface; it reinvents none of them.
2558
- */
2559
-
2355
+ //#endregion
2356
+ //#region src/research-driving-driver.d.ts
2560
2357
  /** The four deep sub-question kinds the driver generates to drive depth. */
2561
2358
  type DeepQuestionKind = 'comparative' | 'mechanism' | 'gap' | 'contradiction';
2562
2359
  /** A deep sub-question the driver folds into the worker's next prompt. */
2563
2360
  interface DeepQuestion {
2564
- kind: DeepQuestionKind;
2565
- text: string;
2566
- /** sha256-derived stable id, so "addressed" can be tracked across rounds. */
2567
- id: string;
2568
- /** Claim id(s) this question interrogates (for contradiction/mechanism kinds). */
2569
- claimIds: string[];
2570
- /** True once a later round's evidence addressed it (see `markAddressed`). */
2571
- addressed: boolean;
2572
- /** The round this question was raised in. */
2573
- raisedRound: number;
2361
+ kind: DeepQuestionKind;
2362
+ text: string;
2363
+ /** sha256-derived stable id, so "addressed" can be tracked across rounds. */
2364
+ id: string;
2365
+ /** Claim id(s) this question interrogates (for contradiction/mechanism kinds). */
2366
+ claimIds: string[];
2367
+ /** True once a later round's evidence addressed it (see `markAddressed`). */
2368
+ addressed: boolean;
2369
+ /** The round this question was raised in. */
2370
+ raisedRound: number;
2574
2371
  }
2575
2372
  /** One tracked claim plus the independent sources that assert it. */
2576
2373
  interface TrackedClaim {
2577
- id: string;
2578
- /** The claim text as first extracted (kept for prompts/audit). */
2579
- text: string;
2580
- /** Canonical hosts of the INDEPENDENT sources that assert this claim. */
2581
- supportingHosts: Set<string>;
2582
- /** Source URIs that assert this claim (provenance; may share a host). */
2583
- supportingUris: string[];
2584
- /** Claim ids this claim was found to CONTRADICT (and vice versa). */
2585
- contradicts: Set<string>;
2586
- /**
2587
- * CONTESTED = a contradiction the loop surfaced but could not resolve to a
2588
- * single supported claim. A contested claim counts as "settled enough to be
2589
- * done" (we report the disagreement) even with < 2 independent sources.
2590
- */
2591
- contested: boolean;
2592
- firstSeenRound: number;
2374
+ id: string;
2375
+ /** The claim text as first extracted (kept for prompts/audit). */
2376
+ text: string;
2377
+ /** Canonical hosts of the INDEPENDENT sources that assert this claim. */
2378
+ supportingHosts: Set<string>;
2379
+ /** Source URIs that assert this claim (provenance; may share a host). */
2380
+ supportingUris: string[];
2381
+ /** Claim ids this claim was found to CONTRADICT (and vice versa). */
2382
+ contradicts: Set<string>;
2383
+ /**
2384
+ * CONTESTED = a contradiction the loop surfaced but could not resolve to a
2385
+ * single supported claim. A contested claim counts as "settled enough to be
2386
+ * done" (we report the disagreement) even with < 2 independent sources.
2387
+ */
2388
+ contested: boolean;
2389
+ firstSeenRound: number;
2593
2390
  }
2594
2391
  /** The driver's accumulated research state — the completion oracle reads this. */
2595
2392
  interface ResearchDrivingState {
2596
- /** Every claim extracted from the worker's sources, by id. */
2597
- claims: TrackedClaim[];
2598
- /** Every deep sub-question raised, by id. */
2599
- questions: DeepQuestion[];
2600
- /** Claims with exactly one independent source AND not contested. */
2601
- weaklySupported: TrackedClaim[];
2602
- /** Claims supported by >= 2 independent sources. */
2603
- corroborated: TrackedClaim[];
2604
- /** Claims marked contested (a surfaced, unresolved contradiction). */
2605
- contested: TrackedClaim[];
2606
- /** Deep questions still unaddressed. */
2607
- openQuestions: DeepQuestion[];
2608
- /** How many rounds the driver has folded steer for. */
2609
- rounds: number;
2393
+ /** Every claim extracted from the worker's sources, by id. */
2394
+ claims: TrackedClaim[];
2395
+ /** Every deep sub-question raised, by id. */
2396
+ questions: DeepQuestion[];
2397
+ /** Claims with exactly one independent source AND not contested. */
2398
+ weaklySupported: TrackedClaim[];
2399
+ /** Claims supported by >= 2 independent sources. */
2400
+ corroborated: TrackedClaim[];
2401
+ /** Claims marked contested (a surfaced, unresolved contradiction). */
2402
+ contested: TrackedClaim[];
2403
+ /** Deep questions still unaddressed. */
2404
+ openQuestions: DeepQuestion[];
2405
+ /** How many rounds the driver has folded steer for. */
2406
+ rounds: number;
2610
2407
  }
2611
2408
  interface ResearchDrivingDriverOptions {
2612
- /** Router client for claim extraction + deep-question generation. */
2613
- router?: RouterClient;
2614
- router_options?: TangleRouterOptions;
2615
- /**
2616
- * A claim is CORROBORATED at this many INDEPENDENT supporting sources (distinct
2617
- * canonical hosts). Default 2 — the task's ">= 2 independent sources" bar.
2618
- */
2619
- minIndependentSources?: number;
2620
- /** Max deep sub-questions to fold into one round's steer. Default 6. */
2621
- maxQuestionsPerRound?: number;
2622
- /** Max claims to extract from a single source. Default 3. */
2623
- maxClaimsPerSource?: number;
2624
- /**
2625
- * When the extractor LLM is unavailable, fall back to a deterministic claim
2626
- * pull (the source's leading sentences) so the driver still drives. Default
2627
- * true. Set false to require the model (claims will be empty without it).
2628
- */
2629
- deterministicFallback?: boolean;
2630
- /** Observe each round's generated steer (for instrumentation / the script). */
2631
- onSteer?: (steer: ResearchDrivingSteer) => void;
2409
+ /** Router client for claim extraction + deep-question generation. */
2410
+ router?: RouterClient;
2411
+ router_options?: TangleRouterOptions;
2412
+ /**
2413
+ * A claim is CORROBORATED at this many INDEPENDENT supporting sources (distinct
2414
+ * canonical hosts). Default 2 — the task's ">= 2 independent sources" bar.
2415
+ */
2416
+ minIndependentSources?: number;
2417
+ /** Max deep sub-questions to fold into one round's steer. Default 6. */
2418
+ maxQuestionsPerRound?: number;
2419
+ /** Max claims to extract from a single source. Default 3. */
2420
+ maxClaimsPerSource?: number;
2421
+ /**
2422
+ * When the extractor LLM is unavailable, fall back to a deterministic claim
2423
+ * pull (the source's leading sentences) so the driver still drives. Default
2424
+ * true. Set false to require the model (claims will be empty without it).
2425
+ */
2426
+ deterministicFallback?: boolean;
2427
+ /** Observe each round's generated steer (for instrumentation / the script). */
2428
+ onSteer?: (steer: ResearchDrivingSteer) => void;
2632
2429
  }
2633
2430
  /** What the driver folded into one round's worker prompt, surfaced for audit. */
2634
2431
  interface ResearchDrivingSteer {
2635
- round: number;
2636
- deepQuestions: DeepQuestion[];
2637
- /** Claims it demanded corroborating/refuting evidence for this round. */
2638
- invalidationTargets: TrackedClaim[];
2639
- /** The readiness gaps it interleaved (passed through from the loop). */
2640
- gaps: KnowledgeGap[];
2641
- /** The full steer text handed to the worker. */
2642
- text: string;
2432
+ round: number;
2433
+ deepQuestions: DeepQuestion[];
2434
+ /** Claims it demanded corroborating/refuting evidence for this round. */
2435
+ invalidationTargets: TrackedClaim[];
2436
+ /** The readiness gaps it interleaved (passed through from the loop). */
2437
+ gaps: KnowledgeGap[];
2438
+ /** The full steer text handed to the worker. */
2439
+ text: string;
2643
2440
  }
2644
2441
  /**
2645
2442
  * The research-driving driver. It is a `ResearchDriver` (drops straight into
@@ -2647,25 +2444,45 @@ interface ResearchDrivingSteer {
2647
2444
  * how `createAdaptiveResearchDriver` exposes `stats()`.
2648
2445
  */
2649
2446
  interface ResearchDrivingDriver extends ResearchDriver {
2650
- /** Live snapshot of the claim ledger + deep questions. */
2651
- researchState(): ResearchDrivingState;
2652
- /**
2653
- * The completion oracle — gate `done` on THIS, not on source count. True when
2654
- * every deep sub-question is addressed AND every claim is corroborated
2655
- * (>= `minIndependentSources` independent sources) or explicitly contested.
2656
- * False while any claim is weakly-supported or any deep question is open.
2657
- * Returns false before any claim has been seen (nothing researched yet).
2658
- */
2659
- isComplete(): boolean;
2660
- /**
2661
- * The last round's generated steer, or undefined before the first fold. Useful
2662
- * to assert the driver produced deeper questions / invalidation challenges.
2663
- */
2664
- lastSteer(): ResearchDrivingSteer | undefined;
2447
+ /** Live snapshot of the claim ledger + deep questions. */
2448
+ researchState(): ResearchDrivingState;
2449
+ /**
2450
+ * The completion oracle — gate `done` on THIS, not on source count. True when
2451
+ * every deep sub-question is addressed AND every claim is corroborated
2452
+ * (>= `minIndependentSources` independent sources) or explicitly contested.
2453
+ * False while any claim is weakly-supported or any deep question is open.
2454
+ * Returns false before any claim has been seen (nothing researched yet).
2455
+ */
2456
+ isComplete(): boolean;
2457
+ /**
2458
+ * The last round's generated steer, or undefined before the first fold. Useful
2459
+ * to assert the driver produced deeper questions / invalidation challenges.
2460
+ */
2461
+ lastSteer(): ResearchDrivingSteer | undefined;
2665
2462
  }
2666
2463
  declare function createResearchDrivingDriver(options?: ResearchDrivingDriverOptions): ResearchDrivingDriver;
2667
-
2464
+ //#endregion
2465
+ //#region src/schemas.d.ts
2668
2466
  declare const SourceAnchorSchema: z.ZodObject<{
2467
+ id: z.ZodString;
2468
+ sourceId: z.ZodString;
2469
+ label: z.ZodOptional<z.ZodString>;
2470
+ page: z.ZodOptional<z.ZodNumber>;
2471
+ lineStart: z.ZodOptional<z.ZodNumber>;
2472
+ lineEnd: z.ZodOptional<z.ZodNumber>;
2473
+ charStart: z.ZodOptional<z.ZodNumber>;
2474
+ charEnd: z.ZodOptional<z.ZodNumber>;
2475
+ timestampMs: z.ZodOptional<z.ZodNumber>;
2476
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2477
+ }, z.core.$strip>;
2478
+ declare const SourceRecordSchema: z.ZodObject<{
2479
+ id: z.ZodString;
2480
+ uri: z.ZodString;
2481
+ title: z.ZodOptional<z.ZodString>;
2482
+ mediaType: z.ZodOptional<z.ZodString>;
2483
+ contentHash: z.ZodString;
2484
+ text: z.ZodOptional<z.ZodString>;
2485
+ anchors: z.ZodOptional<z.ZodArray<z.ZodObject<{
2669
2486
  id: z.ZodString;
2670
2487
  sourceId: z.ZodString;
2671
2488
  label: z.ZodOptional<z.ZodString>;
@@ -2676,8 +2493,41 @@ declare const SourceAnchorSchema: z.ZodObject<{
2676
2493
  charEnd: z.ZodOptional<z.ZodNumber>;
2677
2494
  timestampMs: z.ZodOptional<z.ZodNumber>;
2678
2495
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2496
+ }, z.core.$strip>>>;
2497
+ validUntil: z.ZodOptional<z.ZodISODateTime>;
2498
+ lastVerifiedAt: z.ZodOptional<z.ZodISODateTime>;
2499
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2500
+ createdAt: z.ZodString;
2679
2501
  }, z.core.$strip>;
2680
- declare const SourceRecordSchema: z.ZodObject<{
2502
+ declare const KnowledgePageSchema: z.ZodObject<{
2503
+ id: z.ZodString;
2504
+ path: z.ZodString;
2505
+ title: z.ZodString;
2506
+ text: z.ZodString;
2507
+ frontmatter: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2508
+ sourceIds: z.ZodArray<z.ZodString>;
2509
+ tags: z.ZodArray<z.ZodString>;
2510
+ outLinks: z.ZodArray<z.ZodString>;
2511
+ }, z.core.$strip>;
2512
+ declare const KnowledgeGraphNodeSchema: z.ZodObject<{
2513
+ id: z.ZodString;
2514
+ title: z.ZodString;
2515
+ path: z.ZodString;
2516
+ tags: z.ZodArray<z.ZodString>;
2517
+ sourceIds: z.ZodArray<z.ZodString>;
2518
+ outDegree: z.ZodNumber;
2519
+ inDegree: z.ZodNumber;
2520
+ }, z.core.$strip>;
2521
+ declare const KnowledgeGraphEdgeSchema: z.ZodObject<{
2522
+ source: z.ZodString;
2523
+ target: z.ZodString;
2524
+ weight: z.ZodNumber;
2525
+ reasons: z.ZodArray<z.ZodString>;
2526
+ }, z.core.$strip>;
2527
+ declare const KnowledgeIndexSchema: z.ZodObject<{
2528
+ root: z.ZodString;
2529
+ generatedAt: z.ZodString;
2530
+ sources: z.ZodArray<z.ZodObject<{
2681
2531
  id: z.ZodString;
2682
2532
  uri: z.ZodString;
2683
2533
  title: z.ZodOptional<z.ZodString>;
@@ -2685,23 +2535,23 @@ declare const SourceRecordSchema: z.ZodObject<{
2685
2535
  contentHash: z.ZodString;
2686
2536
  text: z.ZodOptional<z.ZodString>;
2687
2537
  anchors: z.ZodOptional<z.ZodArray<z.ZodObject<{
2688
- id: z.ZodString;
2689
- sourceId: z.ZodString;
2690
- label: z.ZodOptional<z.ZodString>;
2691
- page: z.ZodOptional<z.ZodNumber>;
2692
- lineStart: z.ZodOptional<z.ZodNumber>;
2693
- lineEnd: z.ZodOptional<z.ZodNumber>;
2694
- charStart: z.ZodOptional<z.ZodNumber>;
2695
- charEnd: z.ZodOptional<z.ZodNumber>;
2696
- timestampMs: z.ZodOptional<z.ZodNumber>;
2697
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2538
+ id: z.ZodString;
2539
+ sourceId: z.ZodString;
2540
+ label: z.ZodOptional<z.ZodString>;
2541
+ page: z.ZodOptional<z.ZodNumber>;
2542
+ lineStart: z.ZodOptional<z.ZodNumber>;
2543
+ lineEnd: z.ZodOptional<z.ZodNumber>;
2544
+ charStart: z.ZodOptional<z.ZodNumber>;
2545
+ charEnd: z.ZodOptional<z.ZodNumber>;
2546
+ timestampMs: z.ZodOptional<z.ZodNumber>;
2547
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2698
2548
  }, z.core.$strip>>>;
2699
2549
  validUntil: z.ZodOptional<z.ZodISODateTime>;
2700
2550
  lastVerifiedAt: z.ZodOptional<z.ZodISODateTime>;
2701
2551
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2702
2552
  createdAt: z.ZodString;
2703
- }, z.core.$strip>;
2704
- declare const KnowledgePageSchema: z.ZodObject<{
2553
+ }, z.core.$strip>>;
2554
+ pages: z.ZodArray<z.ZodObject<{
2705
2555
  id: z.ZodString;
2706
2556
  path: z.ZodString;
2707
2557
  title: z.ZodString;
@@ -2710,147 +2560,97 @@ declare const KnowledgePageSchema: z.ZodObject<{
2710
2560
  sourceIds: z.ZodArray<z.ZodString>;
2711
2561
  tags: z.ZodArray<z.ZodString>;
2712
2562
  outLinks: z.ZodArray<z.ZodString>;
2713
- }, z.core.$strip>;
2714
- declare const KnowledgeGraphNodeSchema: z.ZodObject<{
2715
- id: z.ZodString;
2716
- title: z.ZodString;
2717
- path: z.ZodString;
2718
- tags: z.ZodArray<z.ZodString>;
2719
- sourceIds: z.ZodArray<z.ZodString>;
2720
- outDegree: z.ZodNumber;
2721
- inDegree: z.ZodNumber;
2722
- }, z.core.$strip>;
2723
- declare const KnowledgeGraphEdgeSchema: z.ZodObject<{
2724
- source: z.ZodString;
2725
- target: z.ZodString;
2726
- weight: z.ZodNumber;
2727
- reasons: z.ZodArray<z.ZodString>;
2728
- }, z.core.$strip>;
2729
- declare const KnowledgeIndexSchema: z.ZodObject<{
2730
- root: z.ZodString;
2731
- generatedAt: z.ZodString;
2732
- sources: z.ZodArray<z.ZodObject<{
2733
- id: z.ZodString;
2734
- uri: z.ZodString;
2735
- title: z.ZodOptional<z.ZodString>;
2736
- mediaType: z.ZodOptional<z.ZodString>;
2737
- contentHash: z.ZodString;
2738
- text: z.ZodOptional<z.ZodString>;
2739
- anchors: z.ZodOptional<z.ZodArray<z.ZodObject<{
2740
- id: z.ZodString;
2741
- sourceId: z.ZodString;
2742
- label: z.ZodOptional<z.ZodString>;
2743
- page: z.ZodOptional<z.ZodNumber>;
2744
- lineStart: z.ZodOptional<z.ZodNumber>;
2745
- lineEnd: z.ZodOptional<z.ZodNumber>;
2746
- charStart: z.ZodOptional<z.ZodNumber>;
2747
- charEnd: z.ZodOptional<z.ZodNumber>;
2748
- timestampMs: z.ZodOptional<z.ZodNumber>;
2749
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2750
- }, z.core.$strip>>>;
2751
- validUntil: z.ZodOptional<z.ZodISODateTime>;
2752
- lastVerifiedAt: z.ZodOptional<z.ZodISODateTime>;
2753
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2754
- createdAt: z.ZodString;
2563
+ }, z.core.$strip>>;
2564
+ graph: z.ZodObject<{
2565
+ nodes: z.ZodArray<z.ZodObject<{
2566
+ id: z.ZodString;
2567
+ title: z.ZodString;
2568
+ path: z.ZodString;
2569
+ tags: z.ZodArray<z.ZodString>;
2570
+ sourceIds: z.ZodArray<z.ZodString>;
2571
+ outDegree: z.ZodNumber;
2572
+ inDegree: z.ZodNumber;
2755
2573
  }, z.core.$strip>>;
2756
- pages: z.ZodArray<z.ZodObject<{
2757
- id: z.ZodString;
2758
- path: z.ZodString;
2759
- title: z.ZodString;
2760
- text: z.ZodString;
2761
- frontmatter: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2762
- sourceIds: z.ZodArray<z.ZodString>;
2763
- tags: z.ZodArray<z.ZodString>;
2764
- outLinks: z.ZodArray<z.ZodString>;
2574
+ edges: z.ZodArray<z.ZodObject<{
2575
+ source: z.ZodString;
2576
+ target: z.ZodString;
2577
+ weight: z.ZodNumber;
2578
+ reasons: z.ZodArray<z.ZodString>;
2765
2579
  }, z.core.$strip>>;
2766
- graph: z.ZodObject<{
2767
- nodes: z.ZodArray<z.ZodObject<{
2768
- id: z.ZodString;
2769
- title: z.ZodString;
2770
- path: z.ZodString;
2771
- tags: z.ZodArray<z.ZodString>;
2772
- sourceIds: z.ZodArray<z.ZodString>;
2773
- outDegree: z.ZodNumber;
2774
- inDegree: z.ZodNumber;
2775
- }, z.core.$strip>>;
2776
- edges: z.ZodArray<z.ZodObject<{
2777
- source: z.ZodString;
2778
- target: z.ZodString;
2779
- weight: z.ZodNumber;
2780
- reasons: z.ZodArray<z.ZodString>;
2781
- }, z.core.$strip>>;
2782
- }, z.core.$strip>;
2580
+ }, z.core.$strip>;
2783
2581
  }, z.core.$strip>;
2784
2582
  declare const KnowledgeEventSchema: z.ZodObject<{
2785
- id: z.ZodString;
2786
- type: z.ZodEnum<{
2787
- "source.added": "source.added";
2788
- "proposal.applied": "proposal.applied";
2789
- "index.built": "index.built";
2790
- "lint.run": "lint.run";
2791
- "optimization.run": "optimization.run";
2792
- "release.promoted": "release.promoted";
2793
- "release.rejected": "release.rejected";
2794
- }>;
2795
- createdAt: z.ZodString;
2796
- actor: z.ZodOptional<z.ZodString>;
2797
- target: z.ZodOptional<z.ZodString>;
2798
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2583
+ id: z.ZodString;
2584
+ type: z.ZodEnum<{
2585
+ "index.built": "index.built";
2586
+ "lint.run": "lint.run";
2587
+ "optimization.run": "optimization.run";
2588
+ "proposal.applied": "proposal.applied";
2589
+ "release.promoted": "release.promoted";
2590
+ "release.rejected": "release.rejected";
2591
+ "source.added": "source.added";
2592
+ }>;
2593
+ createdAt: z.ZodString;
2594
+ actor: z.ZodOptional<z.ZodString>;
2595
+ target: z.ZodOptional<z.ZodString>;
2596
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2799
2597
  }, z.core.$strip>;
2800
2598
  declare const KnowledgeBaseCandidateSchema: z.ZodObject<{
2599
+ id: z.ZodString;
2600
+ units: z.ZodArray<z.ZodObject<{
2801
2601
  id: z.ZodString;
2802
- units: z.ZodArray<z.ZodObject<{
2803
- id: z.ZodString;
2804
- title: z.ZodString;
2805
- text: z.ZodString;
2806
- claims: z.ZodOptional<z.ZodArray<z.ZodObject<{
2807
- id: z.ZodString;
2808
- text: z.ZodString;
2809
- refs: z.ZodArray<z.ZodObject<{
2810
- sourceId: z.ZodString;
2811
- anchorId: z.ZodOptional<z.ZodString>;
2812
- quote: z.ZodOptional<z.ZodString>;
2813
- }, z.core.$strip>>;
2814
- confidence: z.ZodOptional<z.ZodNumber>;
2815
- status: z.ZodOptional<z.ZodEnum<{
2816
- draft: "draft";
2817
- active: "active";
2818
- superseded: "superseded";
2819
- rejected: "rejected";
2820
- }>>;
2821
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2822
- }, z.core.$strip>>>;
2823
- relations: z.ZodOptional<z.ZodArray<z.ZodObject<{
2824
- sourceId: z.ZodString;
2825
- targetId: z.ZodString;
2826
- predicate: z.ZodString;
2827
- weight: z.ZodOptional<z.ZodNumber>;
2828
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2829
- }, z.core.$strip>>>;
2830
- sourceIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
2831
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
2832
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2833
- updatedAt: z.ZodOptional<z.ZodString>;
2834
- }, z.core.$strip>>;
2835
- retrievalPolicy: z.ZodOptional<z.ZodString>;
2836
- synthesisPolicy: z.ZodOptional<z.ZodString>;
2837
- questionPolicy: z.ZodOptional<z.ZodString>;
2838
- updatePolicy: z.ZodOptional<z.ZodString>;
2602
+ title: z.ZodString;
2603
+ text: z.ZodString;
2604
+ claims: z.ZodOptional<z.ZodArray<z.ZodObject<{
2605
+ id: z.ZodString;
2606
+ text: z.ZodString;
2607
+ refs: z.ZodArray<z.ZodObject<{
2608
+ sourceId: z.ZodString;
2609
+ anchorId: z.ZodOptional<z.ZodString>;
2610
+ quote: z.ZodOptional<z.ZodString>;
2611
+ }, z.core.$strip>>;
2612
+ confidence: z.ZodOptional<z.ZodNumber>;
2613
+ status: z.ZodOptional<z.ZodEnum<{
2614
+ active: "active";
2615
+ draft: "draft";
2616
+ rejected: "rejected";
2617
+ superseded: "superseded";
2618
+ }>>;
2619
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2620
+ }, z.core.$strip>>>;
2621
+ relations: z.ZodOptional<z.ZodArray<z.ZodObject<{
2622
+ sourceId: z.ZodString;
2623
+ targetId: z.ZodString;
2624
+ predicate: z.ZodString;
2625
+ weight: z.ZodOptional<z.ZodNumber>;
2626
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2627
+ }, z.core.$strip>>>;
2628
+ sourceIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
2629
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
2839
2630
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2631
+ updatedAt: z.ZodOptional<z.ZodString>;
2632
+ }, z.core.$strip>>;
2633
+ retrievalPolicy: z.ZodOptional<z.ZodString>;
2634
+ synthesisPolicy: z.ZodOptional<z.ZodString>;
2635
+ questionPolicy: z.ZodOptional<z.ZodString>;
2636
+ updatePolicy: z.ZodOptional<z.ZodString>;
2637
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2840
2638
  }, z.core.$strip>;
2841
-
2639
+ //#endregion
2640
+ //#region src/search.d.ts
2842
2641
  declare function searchKnowledge(index: KnowledgeIndex, query: string, limit?: number): KnowledgeSearchResult[];
2843
2642
  declare function tokenizeQuery(query: string): string[];
2844
2643
  declare function reciprocalRankFusion(rankLists: string[][], k?: number): Map<string, number>;
2845
-
2644
+ //#endregion
2645
+ //#region src/store.d.ts
2846
2646
  interface KnowledgeLayout {
2847
- root: string;
2848
- knowledgeDir: string;
2849
- rawSourcesDir: string;
2850
- sourceRegistryPath: string;
2851
- indexPath: string;
2852
- logPath: string;
2853
- cacheDir: string;
2647
+ root: string;
2648
+ knowledgeDir: string;
2649
+ rawSourcesDir: string;
2650
+ sourceRegistryPath: string;
2651
+ indexPath: string;
2652
+ logPath: string;
2653
+ cacheDir: string;
2854
2654
  }
2855
2655
  declare function layoutFor(root: string): KnowledgeLayout;
2856
2656
  /**
@@ -2873,12 +2673,15 @@ declare function isScaffoldPath(path: string): boolean;
2873
2673
  declare function initKnowledgeBase(root: string): Promise<KnowledgeLayout>;
2874
2674
  declare function loadKnowledgePages(root: string): Promise<KnowledgePage[]>;
2875
2675
  declare function writeJson(path: string, value: unknown): Promise<void>;
2876
-
2676
+ //#endregion
2677
+ //#region src/wikilinks.d.ts
2877
2678
  declare const WIKILINK_REGEX: RegExp;
2878
2679
  declare function extractWikilinks(content: string): string[];
2879
2680
  declare function normalizeLinkTarget(target: string): string;
2880
-
2681
+ //#endregion
2682
+ //#region src/write-protocol.d.ts
2881
2683
  declare function isSafeKnowledgePath(path: string, allowedPrefixes?: string[]): boolean;
2882
2684
  declare function parseKnowledgeWriteBlocks(text: string, allowedPrefixes?: string[]): KnowledgeWriteParseResult;
2883
-
2884
- export { type AdaptiveDecision, type AdaptiveDriverOptions, type AdaptiveResearchDriver, type AdaptiveStats, type AddSourceOptions, type AddSourceTextInput, type ApplyWriteBlocksResult, type BuildEvalKnowledgeBundleOptions, type ChunkingOptions, type ClaimGroundingDriverOptions, type CompanyEvalCase, type D1Adapter, type DedupReason, type DeepQuestion, type DeepQuestionKind, type DefineReadinessSpecInput, type DetectChangesOptions, type DetectChangesResult, type DiscoveryLoopResult, type DiscoveryLoopRound, type DiscoveryLoopStopReason, type DiscoveryResult, type DiscoveryTask, type DriverResearchContext, type EvalKnowledgeBundleBuildResult, type EvaluateKnowledgeBaseReadinessOptions, type ExpectedGroup, type ExternalRagEvalScore, type FactResult, type FileSystemFreshnessStoreOptions, FileSystemKbStore, type FileSystemSearchOptions, FileSystemSearchProvider, type FileSystemSearchProviderOptions, type FreshnessKey, type FreshnessMark, type FreshnessRecord, type FreshnessTtl, type GroundClaimOptions, type GroundingResult, type KbStore, KnowledgeBaseCandidateSchema, type KnowledgeBaseQualityOptions, type KnowledgeBaseQualityReport, type KnowledgeBaseReadinessEvaluation, type KnowledgeChange, type KnowledgeChangeKind, type KnowledgeChunk, KnowledgeClaim, type KnowledgeControlLoopAction, type KnowledgeControlLoopActionResult, type KnowledgeControlLoopAdapter, type KnowledgeControlLoopAdapterOptions, type KnowledgeControlLoopState, type KnowledgeDiscoveryDispatcher, type KnowledgeDiscoveryWorker, KnowledgeEvent, type KnowledgeEventQuery, KnowledgeEventSchema, KnowledgeEventType, type KnowledgeExplanation, KnowledgeFragment, type KnowledgeFreshnessStore, type KnowledgeGap, KnowledgeGraph, KnowledgeGraphEdgeSchema, KnowledgeGraphNodeSchema, type KnowledgeImprovementActivationPersistence, type KnowledgeImprovementCandidateRecord, type KnowledgeImprovementCandidateRef, KnowledgeImprovementCandidateRefSchema, type KnowledgeImprovementEvaluationInput, type KnowledgeImprovementEvaluator, type KnowledgeImprovementEvent, type KnowledgeImprovementEvidence, KnowledgeImprovementEvidenceSchema, type KnowledgeImprovementMetric, type KnowledgeImprovementMetricProvenance, type KnowledgeImprovementMutationReceipt, type KnowledgeImprovementMutationResult, type KnowledgeImprovementOptions, type KnowledgeImprovementRagOptimizationOptions, type KnowledgeImprovementRagOptimizationRunInput, type KnowledgeImprovementResult, type KnowledgeImprovementRetrievalOptions, type KnowledgeImprovementRunState, KnowledgeImprovementRunStateSchema, type KnowledgeImprovementStatus, type KnowledgeImprovementTarget, type KnowledgeImprovementUpdate, type KnowledgeImprovementUpdateInput, KnowledgeIndex, KnowledgeIndexSchema, type KnowledgeInspection, type KnowledgeLayout, KnowledgeLintFinding, KnowledgePage, KnowledgePageSchema, type KnowledgePolicyDispatch, type KnowledgeProposal, KnowledgeProposalParseError, type KnowledgeReadinessSpec, KnowledgeRelease, type KnowledgeReleaseInput, type KnowledgeReleaseReport, type KnowledgeResearchLoopContext, type KnowledgeResearchLoopDecision, type KnowledgeResearchLoopResult, type KnowledgeResearchLoopStep, KnowledgeSearchResult, KnowledgeWriteBlock, KnowledgeWriteParseResult, type LoadKnowledgeImprovementActivationResultOptions, type MaterialFact, type MaterialFactLens, type MaterialFactsResult, MemoryKbStore, type OptimizeKnowledgeBasePolicyOptions, type OptimizeKnowledgeBasePolicyResult, type ParsedFrontmatter, type PendingKnowledgeMutation, type PromoteKnowledgeCandidateOptions, type ProposeFromFindingsResult, READINESS_SPEC_DEFAULTS, type RagAnswerEvalArtifact, type RagAnswerEvalCase, type RagAnswerEvalScenario, type RagAnswerMetricSummary, type RagAnswerQualityHookOptions, type RagAnswerQualityInput, type RagAnswerQualityJudgeOptions, type RagAnswerQualityResult, type RagCalibrationOptions, type RagCalibrationResult, type RagDiagnosisInput, type RagEvalCitation, type RagEvalClaim, type RagEvalContext, type RagEvalMetricKey, type RagEvalProvider, type RagEvalSlice, type RagGapFinding, type RagGapKind, type RagGapSeverity, type RagKnowledgeAcquisitionInput, type RagKnowledgeImprovementPhase, type RagKnowledgeImprovementPhaseResult, type RagKnowledgeImprovementPhaseStatus, type RagKnowledgeResearchOptions, type RagKnowledgeUpdateInput, type RagKnowledgeUpdateResult, type RagOptimizationConfig, type RagOptimizationSelection, type RagPhaseInputBase, type RagPromotionInput, type RagPromotionResult, type RagRequiredContext, type RecoverPendingKnowledgeMutationOptions, type RejectedSource, type ResearchContribution, type ResearchDriver, type ResearchDrivingDriver, type ResearchDrivingDriverOptions, type ResearchDrivingState, type ResearchDrivingSteer, type ResearchSourceProposal, type ResearchWorker, type ResolvedKnowledgeImprovementCandidate, type ResolvedKnowledgeImprovementComparison, type ResolvedKnowledgeImprovementComparisonSnapshot, type RestoreKnowledgeCandidateBaselineOptions, RetrievalConfig, RetrievalEvalArtifact, RetrievalEvalRetriever, RetrievalEvalScenario, RetrievalMetricWeights, type RetrievalOptimizationSelection, RetrievedKnowledgeHit, type RouterClient, RouterError, type RouterUsage, type RunDiscoveryLoopOptions, type RunKnowledgeResearchLoopOptions, type RunRagKnowledgeImprovementLoopOptions, type RunRagKnowledgeImprovementLoopResult, type RunRagOptimizationOptions, type RunRagOptimizationResult, type RunRetrievalImprovementLoopOptions, type RunRetrievalImprovementLoopResult, RunSerializedKnowledgeOptimizationOptions, RunSerializedKnowledgeOptimizationResult, SCAFFOLD_PAGE_BASENAMES, type SourceAdapter, type SourceAdapterInput, type SourceAdapterOutput, SourceAnchorSchema, type SourceFreshnessInspection, SourceRecord, SourceRecordSchema, SourceRegistry, type SourceVerdict, type SourceVerificationContext, type TangleRouterOptions, type ThesisRunOptions, type ThesisRunResult, type ThesisTaskInput, type TrackedClaim, type TriageClass, type UseKnowledgeImprovementCandidateOptions, type ValidateKnowledgeOptions, type ValidateKnowledgeResult, type VerifiedResearchLoopOptions, type VerifiedResearchLoopResult, type VerifiedResearchRound, type VerifyingDriverOptions, WIKILINK_REGEX, type WebResearchWorkerOptions, type WebSearchHit, type WorkerClaimDecorationOptions, type WorkerResearchContext, addSourcePath, addSourceText, applyKnowledgeWriteBlocks, applyKnowledgeWriteBlocksFile, buildEvalKnowledgeBundle, buildKnowledgeGraph, buildKnowledgeIndex, calibrateRagAnswerJudge, canonicalizeUrl, chunkMarkdown, citedClaimKey, citedClaimOf, contentKey, createAdaptiveResearchDriver, createClaimDecorator, createClaimGroundingVerifier, createCollectionResearchDriver, createD1FreshnessStoreStub, createFileSystemFreshnessStore, createFileSystemSearchProvider, createKnowledgeControlLoopAdapter, createKnowledgeEvent, createLocalDiscoveryDispatcher, createRagAnswerQualityHook, createResearchDrivingDriver, createTangleRouterClient, createVerifyingResearchDriver, createWebResearchWorker, defineReadinessSpec, detectChanges, diagnoseRagAnswerFailure, evaluateKnowledgeBaseReadiness, explainKnowledgeTarget, extractWikilinks, formatFrontmatter, fromAgentCandidateKnowledgeRef, gradeCompanyAgainstText, gradeFactAgainstText, groundClaimInText, hashKnowledgeBase, improveKnowledgeBase, initKnowledgeBase, inspectKnowledgeIndex, inspectPendingKnowledgeMutation, investmentThesisSet, isSafeKnowledgePath, isScaffoldPath, kbIndexToText, knowledgeImprovementCandidateRef, knowledgeImprovementRunDir, knowledgeImprovementRunId, knowledgeReleaseReport, layoutFor, lensDistribution, lintKnowledgeIndex, loadKnowledgeImprovementActivationResult, loadKnowledgeImprovementEvents, loadKnowledgeImprovementState, loadKnowledgePages, loadSourceRegistry, materialFactsSurfaced, materialFactsSurfacedInText, mediaTypeFor, normalizeExternalRagScores, normalizeLinkTarget, optimizeKnowledgeBasePolicy, parseFrontmatter, parseKnowledgeWriteBlocks, promoteKnowledgeCandidate, proposeFromFinding, proposeFromFindings, ragAnswerQualityJudge, reciprocalRankFusion, recoverPendingKnowledgeMutation, restoreKnowledgeCandidateBaseline, runDiscoveryLoop, runInvestmentThesisTask, runKnowledgeResearchLoop, runRagKnowledgeImprovementLoop, runRagOptimization, runRetrievalImprovementLoop, runVerifiedResearchLoop, scoreKnowledgeBaseIndex, scoreRagAnswerArtifact, searchKnowledge, sha256, slugify, sourceMatchesGaps, sourceRegistryPath, stableId, stripFrontmatter, textSourceAdapter, thesisReadinessSpecs, toAgentCandidateKnowledgeRef, toDeepEvalTestCases, toRagCheckerRecords, toRagasEvaluationRows, toTruLensRecords, tokenizeQuery, totalMaterialFacts, triageSource, validateKnowledgeIndex, withCitedClaim, withKnowledgeImprovementCandidate, withKnowledgeImprovementComparison, writeJson, writeKnowledgeIndex, writeSourceRegistry };
2685
+ //#endregion
2686
+ export { AdaptiveDecision, AdaptiveDriverOptions, AdaptiveResearchDriver, AdaptiveStats, AddSourceOptions, AddSourceTextInput, AgentMemoryAcquireRunLease, type AgentMemoryActivation, type AgentMemoryActivationDriver, AgentMemoryAdapter, type AgentMemoryAttemptEvent, AgentMemoryBranch, AgentMemoryBranchIsolation, AgentMemoryBranchLifetime, AgentMemoryBranchSnapshot, AgentMemoryContext, AgentMemoryControllerMode, type AgentMemoryDimensionComparison, type AgentMemoryExecutionContext, type AgentMemoryExecutionCostMeter, type AgentMemoryExecutionCostReceipt, type AgentMemoryExecutionPaidCallInput, type AgentMemoryExecutionPaidCallResult, type AgentMemoryExecutionStep, type AgentMemoryExperimentCandidate, type AgentMemoryExperimentRankingRow, type AgentMemoryExperimentRunLease, type AgentMemoryFinalEvaluation, type AgentMemoryFinalPair, AgentMemoryHit, AgentMemoryHitSchema, type AgentMemoryImprovementRunLease, AgentMemoryJournalEntry, AgentMemoryKind, AgentMemoryKindSchema, AgentMemoryLifecycleTimeoutError, AgentMemoryLifecycleUnsafeError, type AgentMemoryPromotionDecision, AgentMemoryRunLease, AgentMemoryScope, AgentMemoryScopeSchema, AgentMemorySearchOptions, type AgentMemorySequence, type AgentMemorySequenceArtifact, type AgentMemorySequenceProbe, type AgentMemorySequenceProbeResult, type AgentMemorySequenceScenario, type AgentMemorySequenceStep, AgentMemorySharingPolicy, AgentMemoryVisibility, AgentMemoryWriteInput, AgentMemoryWriteInputSchema, AgentMemoryWriteResult, ApplyWriteBlocksResult, type BuildAgentMemorySequencesFromBenchmarkCasesOptions, BuildEvalKnowledgeBundleOptions, type BuildRetrievalBenchmarkCasesFromQrelsOptions, BuildRetrievalEvalDispatchOptions, ChunkingOptions, ClaimGroundingDriverOptions, ClaimRef, CompanyEvalCase, CornellLiiSelector, CornellLiiSourceOptions, CreateAgentMemoryBranchOptions, D1Adapter, DEFAULT_MEMORY_CLEANUP_TIMEOUT_MS, DedupReason, DeepQuestion, DeepQuestionKind, DefineReadinessSpecInput, DetectChangesOptions, DetectChangesResult, DiscoveryLoopResult, DiscoveryLoopRound, DiscoveryLoopStopReason, DiscoveryResult, DiscoveryTask, DriverResearchContext, EvalKnowledgeBundleBuildResult, EvaluateKnowledgeBaseReadinessOptions, ExpectedGroup, type ExternalRagEvalScore, FactResult, FetchOpts, FileSystemFreshnessStoreOptions, FileSystemKbStore, FileSystemSearchOptions, FileSystemSearchProvider, FileSystemSearchProviderOptions, ForkAgentMemoryBranchSnapshotOptions, FragmentProvenance, FreshnessKey, FreshnessMark, FreshnessRecord, FreshnessTtl, GraphitiMcpClientLike, GraphitiMemoryAdapterOptions, GraphitiToolNames, GroundClaimOptions, GroundingResult, INDUSTRY_MEMORY_BENCHMARKS, INDUSTRY_RAG_BENCHMARKS, IRS_DIMENSION_HINTS, IrsPublicationsSourceOptions, KbStore, type KnowledgeAnswerBenchmarkCase, type KnowledgeAnswerBenchmarkTaskKind, KnowledgeBaseCandidate, KnowledgeBaseCandidateSchema, type KnowledgeBaseQualityOptions, type KnowledgeBaseQualityReport, KnowledgeBaseReadinessEvaluation, type KnowledgeBenchmarkArtifact, type KnowledgeBenchmarkCase, type KnowledgeBenchmarkCaseBase, type KnowledgeBenchmarkDistribution, type KnowledgeBenchmarkEvaluation, type KnowledgeBenchmarkFamily, type KnowledgeBenchmarkReport, type KnowledgeBenchmarkResponder, type KnowledgeBenchmarkScenario, type KnowledgeBenchmarkSliceSummary, type KnowledgeBenchmarkSource, type KnowledgeBenchmarkSpec, type KnowledgeBenchmarkSplit, type KnowledgeBenchmarkTaskKind, KnowledgeChange, KnowledgeChangeKind, KnowledgeChunk, KnowledgeClaim, type KnowledgeClaimMatcher, KnowledgeControlLoopAction, KnowledgeControlLoopActionResult, KnowledgeControlLoopAdapter, KnowledgeControlLoopAdapterOptions, KnowledgeControlLoopState, KnowledgeDiscoveryDispatcher, KnowledgeDiscoveryWorker, KnowledgeEvent, KnowledgeEventQuery, KnowledgeEventSchema, KnowledgeEventType, KnowledgeExplanation, KnowledgeFragment, KnowledgeFreshnessStore, KnowledgeGap, KnowledgeGraph, KnowledgeGraphEdge, KnowledgeGraphEdgeSchema, KnowledgeGraphNode, KnowledgeGraphNodeSchema, KnowledgeId, type KnowledgeImprovementActivationPersistence, type KnowledgeImprovementCandidateRecord, type KnowledgeImprovementCandidateRef, KnowledgeImprovementCandidateRefSchema, type KnowledgeImprovementEvaluationInput, type KnowledgeImprovementEvaluator, type KnowledgeImprovementEvent, type KnowledgeImprovementEvidence, KnowledgeImprovementEvidenceSchema, type KnowledgeImprovementMetric, type KnowledgeImprovementMetricProvenance, type KnowledgeImprovementMutationReceipt, type KnowledgeImprovementMutationResult, type KnowledgeImprovementOptions, type KnowledgeImprovementRagOptimizationOptions, type KnowledgeImprovementRagOptimizationRunInput, type KnowledgeImprovementResult, type KnowledgeImprovementRetrievalOptions, type KnowledgeImprovementRunState, KnowledgeImprovementRunStateSchema, type KnowledgeImprovementStatus, type KnowledgeImprovementTarget, type KnowledgeImprovementUpdate, type KnowledgeImprovementUpdateInput, KnowledgeIndex, KnowledgeIndexSchema, KnowledgeInspection, KnowledgeLayout, KnowledgeLintFinding, type KnowledgeMemoryBenchmarkCase, type KnowledgeMemoryBenchmarkTaskKind, type KnowledgeMemoryEvent, type KnowledgeMemoryFactMatcher, KnowledgePage, KnowledgePageSchema, KnowledgePolicy, type KnowledgePolicyDispatch, KnowledgeProposal, KnowledgeProposalParseError, KnowledgeReadinessSpec, KnowledgeRelation, KnowledgeRelease, KnowledgeReleaseInput, KnowledgeReleaseReport, KnowledgeResearchLoopContext, KnowledgeResearchLoopDecision, KnowledgeResearchLoopResult, KnowledgeResearchLoopStep, type KnowledgeRetrievalBenchmarkCase, type KnowledgeRetrievalBenchmarkQrel, type KnowledgeRetrievalBenchmarkQuery, KnowledgeSearchResult, KnowledgeSource, KnowledgeUnit, KnowledgeWriteBlock, KnowledgeWriteParseResult, type LoadKnowledgeImprovementActivationResultOptions, MAX_RESPONSE_BYTES, MIN_REQUEST_GAP_MS, MaterialFact, MaterialFactLens, MaterialFactsResult, Mem0ClientMode, Mem0HostedClient, Mem0HostedMemoryAdapterOptions, Mem0MemoryAdapterOptions, Mem0OssClient, Mem0OssMemoryAdapterOptions, type MemoryAdapterBenchmarkCandidate, type MemoryAdapterBenchmarkRankingRow, type MemoryConfigScenario, MemoryKbStore, Neo4jAgentMemoryAdapterOptions, type OptimizeKnowledgeBasePolicyOptions, type OptimizeKnowledgeBasePolicyResult, OwnedAgentMemoryRunLease, POLITE_USER_AGENT, ParsedFrontmatter, PartitionRetrievalScenariosOptions, type PendingKnowledgeMutation, PoliteFetchOptions, PoliteFetchResult, type PromoteKnowledgeCandidateOptions, ProposeFromFindingsResult, READINESS_SPEC_DEFAULTS, type RagAnswerEvalArtifact, type RagAnswerEvalCase, type RagAnswerEvalScenario, type RagAnswerMetricSummary, type RagAnswerQualityHookOptions, RagAnswerQualityInput, type RagAnswerQualityJudgeOptions, RagAnswerQualityResult, type RagCalibrationOptions, type RagCalibrationResult, RagDiagnosisInput, type RagEvalCitation, type RagEvalClaim, type RagEvalContext, type RagEvalMetricKey, type RagEvalProvider, type RagEvalSlice, RagGapFinding, RagGapKind, RagGapSeverity, RagKnowledgeAcquisitionInput, RagKnowledgeImprovementPhase, RagKnowledgeImprovementPhaseResult, RagKnowledgeImprovementPhaseStatus, RagKnowledgeResearchOptions, RagKnowledgeUpdateInput, RagKnowledgeUpdateResult, RagOptimizationConfig, RagOptimizationSelection, RagPhaseInputBase, RagPromotionInput, RagPromotionResult, type RagRequiredContext, type RecoverPendingKnowledgeMutationOptions, RejectedSource, ResearchContribution, ResearchDriver, ResearchDrivingDriver, ResearchDrivingDriverOptions, ResearchDrivingState, ResearchDrivingSteer, ResearchSourceProposal, ResearchWorker, type ResolvedKnowledgeImprovementCandidate, type ResolvedKnowledgeImprovementComparison, type ResolvedKnowledgeImprovementComparisonSnapshot, type RestoreKnowledgeCandidateBaselineOptions, RetrievalConfig, RetrievalEvalArtifact, RetrievalEvalRetriever, RetrievalEvalRetrieverInput, RetrievalEvalRetrieverResult, RetrievalEvalScenario, RetrievalGoldTarget, RetrievalHoldoutBypassReason, RetrievalHoldoutCallContext, RetrievalHoldoutConfig, RetrievalHoldoutEligibleItem, RetrievalHoldoutEvent, RetrievalHoldoutOffPolicyOptions, RetrievalHoldoutOffPolicyResult, RetrievalHoldoutResult, RetrievalHoldoutSessionState, RetrievalHoldoutSessionSummary, RetrievalMetricSummary, RetrievalMetricWeights, RetrievalOptimizationSelection, RetrievalRecallJudgeOptions, RetrievalScenarioPartitions, RetrievedKnowledgeHit, RetrievedSourceSpan, RouterClient, RouterError, RouterUsage, type RunAgentMemoryExperimentOptions, type RunAgentMemoryExperimentResult, type RunAgentMemoryImprovementOptions, type RunAgentMemoryImprovementResult, RunDiscoveryLoopOptions, type RunKnowledgeBenchmarkSuiteOptions, type RunKnowledgeBenchmarkSuiteResult, RunKnowledgeResearchLoopOptions, type RunMemoryAdapterBenchmarkOptions, type RunMemoryAdapterBenchmarkResult, RunRagKnowledgeImprovementLoopOptions, RunRagKnowledgeImprovementLoopResult, RunRagOptimizationOptions, RunRagOptimizationResult, RunRetrievalImprovementLoopOptions, RunRetrievalImprovementLoopResult, RunSerializedKnowledgeOptimizationOptions, RunSerializedKnowledgeOptimizationResult, SCAFFOLD_PAGE_BASENAMES, SerializedCandidate, SerializedCandidateCodec, SourceAdapter, SourceAdapterInput, SourceAdapterOutput, SourceAnchor, SourceAnchorSchema, SourceFreshnessInspection, SourceRecord, SourceRecordSchema, SourceRegistry, SourceVerdict, SourceVerificationContext, StateSosEntity, StateSosSourceConfig, TangleRouterOptions, ThesisRunOptions, ThesisRunResult, ThesisTaskInput, TrackedClaim, TriageClass, type UseKnowledgeImprovementCandidateOptions, ValidateKnowledgeOptions, ValidateKnowledgeResult, VerifiedResearchLoopOptions, VerifiedResearchLoopResult, VerifiedResearchRound, VerifyingDriverOptions, WIKILINK_REGEX, WebResearchWorkerOptions, WebSearchHit, WorkerClaimDecorationOptions, WorkerResearchContext, __resetHttpThrottle, acquireAgentMemoryRunLease, addSourcePath, addSourceText, agentMemorySequenceJudge, applyKnowledgeWriteBlocks, applyKnowledgeWriteBlocksFile, applyRetrievalHoldout, applySessionStickyRetrievalHoldout, buildAgentMemorySequenceScenarios, buildAgentMemorySequencesFromBenchmarkCases, buildEvalKnowledgeBundle, buildFirstPartyMemoryLifecycleBenchmarkCases, buildIndustryMemoryBenchmarkSmokeCases, buildIndustryRagBenchmarkSmokeCases, buildKnowledgeBenchmarkScenarios, buildKnowledgeGraph, buildKnowledgeIndex, buildRetrievalBenchmarkCasesFromQrels, buildRetrievalEvalDispatch, calibrateRagAnswerJudge, canonicalizeUrl, chunkMarkdown, citedClaimKey, citedClaimOf, contentKey, createAdaptiveResearchDriver, createAgentMemoryBranch, createClaimDecorator, createClaimGroundingVerifier, createCollectionResearchDriver, createCornellLiiSource, createD1FreshnessStoreStub, createFileSystemFreshnessStore, createFileSystemSearchProvider, createGraphitiMemoryAdapter, createInMemoryBenchmarkAdapter, createIrsPublicationsSource, createKnowledgeControlLoopAdapter, createKnowledgeEvent, createLocalDiscoveryDispatcher, createMem0MemoryAdapter, createMemoryExecutionPool, createNeo4jAgentMemoryAdapter, createNoopMemoryBenchmarkAdapter, createRagAnswerQualityHook, createResearchDrivingDriver, createStateSosSource, createTangleRouterClient, createVerifyingResearchDriver, createWebResearchWorker, defaultGetMemoryContext, defineReadinessSpec, detectChanges, deterministicRng, diagnoseRagAnswerFailure, emitRetrievalHoldoutBypass, evaluateKnowledgeBaseReadiness, explainKnowledgeTarget, extractLinks, extractWikilinks, firstMatch, forkAgentMemoryBranchSnapshot, formatFrontmatter, fromAgentCandidateKnowledgeRef, gradeCompanyAgainstText, gradeFactAgainstText, graphitiMemoryAdapterIdentity, groundClaimInText, hashKnowledgeBase, htmlToText, improveKnowledgeBase, initKnowledgeBase, innerHtmlById, inspectKnowledgeIndex, inspectPendingKnowledgeMutation, investmentThesisSet, isKnowledgeMemoryBenchmarkCase, isSafeKnowledgePath, isScaffoldPath, jsonCandidateCodec, jsonObjectCandidateCodec, kbIndexToText, knowledgeBenchmarkJudge, knowledgeImprovementCandidateRef, knowledgeImprovementRunDir, knowledgeImprovementRunId, knowledgeReleaseReport, layoutFor, lensDistribution, lintKnowledgeIndex, loadKnowledgeImprovementActivationResult, loadKnowledgeImprovementEvents, loadKnowledgeImprovementState, loadKnowledgePages, loadSourceRegistry, looksLikeBlockPage, materialFactsSurfaced, materialFactsSurfacedInText, mediaTypeFor, mem0MemoryAdapterIdentity, memoryHitToSourceRecord, memoryRecoveryDelayMs, memoryWriteResultToSourceRecord, normalizeExternalRagScores, normalizeLinkTarget, optimizeKnowledgeBasePolicy, parseFrontmatter, parseKnowledgeBenchmarkJsonl, parseKnowledgeBenchmarkQrels, parseKnowledgeWriteBlocks, partitionRetrievalScenarios, politeFetch, promoteKnowledgeCandidate, proposeFromFinding, proposeFromFindings, ragAnswerQualityJudge, reciprocalRankFusion, recoverPendingKnowledgeMutation, renderKnowledgeBenchmarkReportMarkdown, renderMemoryContext, resetRetrievalHoldoutRegistry, resolveMemoryCleanupTimeoutMs, respondToIndustryMemoryBenchmarkSmokeCase, respondToIndustryRagBenchmarkSmokeCase, restoreKnowledgeCandidateBaseline, retrievalConfigFromSurface, retrievalConfigSurface, retrievalHoldoutConfigHash, retrievalRecallJudge, runAgentMemoryExperiment, runAgentMemoryImprovement, runBoundedMemoryLifecycle, runDiscoveryLoop, runInvestmentThesisTask, runKnowledgeBenchmarkSuite, runKnowledgeResearchLoop, runMemoryAdapterBenchmark, runRagKnowledgeImprovementLoop, runRagOptimization, runRetrievalImprovementLoop, runSerializedKnowledgeOptimization, runVerifiedResearchLoop, scenarioContentFingerprint, scoreKnowledgeBaseIndex, scoreKnowledgeBenchmarkArtifact, scoreMemoryBenchmarkArtifact, scoreRagAnswerArtifact, scoreRetrievalArtifact, searchKnowledge, sha256, sleepForMemoryRecovery, slugify, sourceMatchesGaps, sourceRegistryPath, stableId, stripFrontmatter, summarizeKnowledgeBenchmarkCampaign, textSourceAdapter, thesisReadinessSpecs, toAgentCandidateKnowledgeRef, toDeepEvalTestCases, toOffPolicyTrajectory, toRagCheckerRecords, toRagasEvaluationRows, toTruLensRecords, tokenizeQuery, totalMaterialFacts, triageSource, validateKnowledgeIndex, withCitedClaim, withKnowledgeImprovementCandidate, withKnowledgeImprovementComparison, writeJson, writeKnowledgeIndex, writeSourceRegistry };
2687
+ //# sourceMappingURL=index.d.ts.map