@tangle-network/agent-knowledge 6.1.11 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/AGENTS.md +9 -0
  2. package/CHANGELOG.md +25 -0
  3. package/README.md +1 -1
  4. package/dist/benchmarks/index.d.ts +1 -1
  5. package/dist/benchmarks/index.js +1 -1
  6. package/dist/{benchmarks-CmW6iORW.js → benchmarks-C8L7HJb4.js} +2 -2
  7. package/dist/{benchmarks-CmW6iORW.js.map → benchmarks-C8L7HJb4.js.map} +1 -1
  8. package/dist/cli.js +1 -1
  9. package/dist/{ids-DRqPZ42_.js → ids-Bevz_pXV.js} +6 -2
  10. package/dist/ids-Bevz_pXV.js.map +1 -0
  11. package/dist/{index-CIW3G4s_.d.ts → index-D0wc4GYg.d.ts} +2 -2
  12. package/dist/{index-CIW3G4s_.d.ts.map → index-D0wc4GYg.d.ts.map} +1 -1
  13. package/dist/{index-CGBctbit.d.ts → index-Dwp3Mx-w.d.ts} +3 -3
  14. package/dist/{index-CGBctbit.d.ts.map → index-Dwp3Mx-w.d.ts.map} +1 -1
  15. package/dist/index.d.ts +377 -43
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +294 -198
  18. package/dist/index.js.map +1 -1
  19. package/dist/{inspect-DAXpFyrs.js → inspect-CJQGYuKa.js} +809 -17
  20. package/dist/inspect-CJQGYuKa.js.map +1 -0
  21. package/dist/memory/index.d.ts +2 -2
  22. package/dist/memory/index.js +2 -2
  23. package/dist/{memory-C6KPRhoU.js → memory-CIYRB_Q8.js} +3 -3
  24. package/dist/{memory-C6KPRhoU.js.map → memory-CIYRB_Q8.js.map} +1 -1
  25. package/dist/sources/index.js +1 -1
  26. package/dist/types-BOfmvDe-.d.ts +306 -0
  27. package/dist/{types-DcCCzreS.d.ts.map → types-BOfmvDe-.d.ts.map} +1 -1
  28. package/dist/viz/index.d.ts +1 -1
  29. package/docs/architecture.md +32 -0
  30. package/package.json +1 -1
  31. package/dist/ids-DRqPZ42_.js.map +0 -1
  32. package/dist/inspect-DAXpFyrs.js.map +0 -1
  33. package/dist/types-DcCCzreS.d.ts +0 -175
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { $ as writeFileDurableWithinRoot, A as loadKnowledgePages, B as withKnowledgeMutation, C as SourceAnchorSchema, D as initKnowledgeBase, E as SCAFFOLD_PAGE_BASENAMES, F as formatFrontmatter, G as knowledgeFileTransactionPlanHash, H as applyKnowledgeFileTransaction, I as parseFrontmatter, J as isMissingFile, K as prepareKnowledgeFileTransaction, L as acquireDurableFileLock, M as WIKILINK_REGEX, N as extractWikilinks, O as isScaffoldPath, P as normalizeLinkTarget, Q as withSafeDirectory, R as inspectPendingKnowledgeMutation, S as KnowledgePageSchema, T as buildKnowledgeGraph, U as assertKnowledgeMutationPath, V as withKnowledgeRead, W as finishKnowledgeFileTransaction, X as readRegularFileWithinRoot, Y as listRegularFilesWithinRoot, Z as renameDurable, _ as KnowledgeBaseCandidateSchema, a as applyKnowledgeWriteBlocksFile, b as KnowledgeGraphNodeSchema, c as validateKnowledgeIndex, d as writeKnowledgeIndex, et as writeJsonDurableWithinRoot, f as addSourcePath, g as writeSourceRegistry, h as sourceRegistryPath, i as applyKnowledgeWriteBlocks, j as writeJson, k as layoutFor, l as lintKnowledgeIndex, m as loadSourceRegistry, n as inspectKnowledgeIndex, nt as textSourceAdapter, o as isSafeKnowledgePath, p as addSourceText, q as rollbackKnowledgeFileTransaction, r as stringMetadata, s as parseKnowledgeWriteBlocks, t as explainKnowledgeTarget, tt as mediaTypeFor, u as buildKnowledgeIndex, v as KnowledgeEventSchema, w as SourceRecordSchema, x as KnowledgeIndexSchema, y as KnowledgeGraphEdgeSchema, z as recoverPendingKnowledgeMutation } from "./inspect-DAXpFyrs.js";
2
- import { n as slugify, r as stableId, t as sha256 } from "./ids-DRqPZ42_.js";
3
- import { A as assertImmutableRef, C as resetRetrievalHoldoutRegistry, D as jsonObjectCandidateCodec, E as jsonCandidateCodec, O as runSerializedKnowledgeOptimization, S as emitRetrievalHoldoutBypass, T as toOffPolicyTrajectory, _ as defaultGetMemoryContext, a as createNeo4jAgentMemoryAdapter, b as applySessionStickyRetrievalHoldout, c as runAgentMemoryImprovement, d as runAgentMemoryExperiment, f as agentMemorySequenceJudge, g as forkAgentMemoryBranchSnapshot, h as createAgentMemoryBranch, i as AgentMemoryWriteInputSchema, k as scenarioContentFingerprint, l as createGraphitiMemoryAdapter, m as buildAgentMemorySequencesFromBenchmarkCases, n as AgentMemoryKindSchema, o as createMem0MemoryAdapter, p as buildAgentMemorySequenceScenarios, r as AgentMemoryScopeSchema, s as mem0MemoryAdapterIdentity, t as AgentMemoryHitSchema, u as graphitiMemoryAdapterIdentity, v as renderMemoryContext, w as retrievalHoldoutConfigHash, x as deterministicRng, y as applyRetrievalHoldout } from "./memory-C6KPRhoU.js";
1
+ import { $ as mergeTrackedClaims, A as KnowledgeGraphNodeSchema, At as removeDurable, B as ClaimLedgerGoalConflictError, Bt as textSourceAdapter, C as KB_STORE_DIR, Ct as prepareKnowledgeFileTransaction, D as KnowledgeBaseCandidateSchema, Dt as listRegularFilesWithinRoot, E as DeepQuestionSchema, Et as isMissingFile, F as ResearchClaimRecordSchema, Ft as writeFileDurable, G as claimEvidenceId, H as assertResearchClaimEvidenceIntegrity, I as ResearchSourceVersionSchema, It as writeFileDurableWithinRoot, J as deepQuestionId, K as claimId, L as SourceAnchorSchema, Lt as writeJsonDurable, M as KnowledgePageSchema, Mt as syncDirectory, N as ResearchClaimEvidenceSchema, Nt as withSafeDescendant, O as KnowledgeEventSchema, Ot as readRegularFileNoFollow, P as ResearchClaimLedgerSchema, Pt as withSafeDirectory, Q as mergeClaimLedgers, R as SourceRecordSchema, Rt as writeJsonDurableWithinRoot, S as KB_INDEX_PATH, St as knowledgeFileTransactionPlanHash, T as assertClaimLedgerId, Tt as isKernelAnchoredPath, U as assertResearchClaimLedgerIntegrity, V as assertDeepQuestionIntegrity, W as assertTrackedClaimIntegrity, X as linkClaimContradictions, Y as emptyClaimLedger, Z as materializeRegisteredClaimEvidence, _ as writeSourceRegistry, _t as withKnowledgeMutation, a as applyKnowledgeWriteBlocksFile, at as isScaffoldPath, b as KB_CLAIM_LEDGER_DIR, bt as assertKnowledgeMutationPath, c as validateKnowledgeIndex, ct as writeJson, d as writeKnowledgeIndex, dt as normalizeLinkTarget, et as normalizeClaimText, f as addSourcePath, ft as formatFrontmatter, g as sourceRegistryPath, gt as recoverPendingKnowledgeMutation, h as snapshotSourceTextInput, ht as inspectPendingKnowledgeMutation, i as applyKnowledgeWriteBlocks, it as initKnowledgeBase, j as KnowledgeIndexSchema, jt as renameDurable, k as KnowledgeGraphEdgeSchema, kt as readRegularFileWithinRoot, l as lintKnowledgeIndex, lt as WIKILINK_REGEX, m as loadSourceRegistry, mt as acquireDurableFileLock, n as inspectKnowledgeIndex, nt as buildKnowledgeGraph, o as isSafeKnowledgePath, ot as layoutFor, p as addSourceText, pt as parseFrontmatter, q as claimSourceHost, r as stringMetadata, rt as SCAFFOLD_PAGE_BASENAMES, s as parseKnowledgeWriteBlocks, st as loadKnowledgePages, t as explainKnowledgeTarget, tt as researchSourceVersionKey, u as buildKnowledgeIndex, ut as extractWikilinks, v as ClaimLedgerMigrationRequiredError, vt as withKnowledgeRead, w as MemoryKbStore, wt as rollbackKnowledgeFileTransaction, x as KB_EVENTS_PATH, xt as finishKnowledgeFileTransaction, y as FileSystemKbStore, yt as applyKnowledgeFileTransaction, z as KNOWLEDGE_EVENT_TYPES, zt as mediaTypeFor } from "./inspect-CJQGYuKa.js";
2
+ import { i as textSourceId, n as slugify, r as stableId, t as sha256 } from "./ids-Bevz_pXV.js";
3
+ import { A as assertImmutableRef, C as resetRetrievalHoldoutRegistry, D as jsonObjectCandidateCodec, E as jsonCandidateCodec, O as runSerializedKnowledgeOptimization, S as emitRetrievalHoldoutBypass, T as toOffPolicyTrajectory, _ as defaultGetMemoryContext, a as createNeo4jAgentMemoryAdapter, b as applySessionStickyRetrievalHoldout, c as runAgentMemoryImprovement, d as runAgentMemoryExperiment, f as agentMemorySequenceJudge, g as forkAgentMemoryBranchSnapshot, h as createAgentMemoryBranch, i as AgentMemoryWriteInputSchema, k as scenarioContentFingerprint, l as createGraphitiMemoryAdapter, m as buildAgentMemorySequencesFromBenchmarkCases, n as AgentMemoryKindSchema, o as createMem0MemoryAdapter, p as buildAgentMemorySequenceScenarios, r as AgentMemoryScopeSchema, s as mem0MemoryAdapterIdentity, t as AgentMemoryHitSchema, u as graphitiMemoryAdapterIdentity, v as renderMemoryContext, w as retrievalHoldoutConfigHash, x as deterministicRng, y as applyRetrievalHoldout } from "./memory-CIYRB_Q8.js";
4
4
  import { n as searchKnowledge, r as tokenizeQuery, t as reciprocalRankFusion } from "./search-CP0QtBJZ.js";
5
- import { A as INDUSTRY_RAG_BENCHMARKS, B as memoryWriteResultToSourceRecord, F as respondToIndustryRagBenchmarkSmokeCase, G as retrievalRecallJudge, H as partitionRetrievalScenarios, I as isKnowledgeMemoryBenchmarkCase, K as scoreRetrievalArtifact, L as createInMemoryBenchmarkAdapter, M as buildIndustryMemoryBenchmarkSmokeCases, N as buildIndustryRagBenchmarkSmokeCases, P as respondToIndustryMemoryBenchmarkSmokeCase, R as createNoopMemoryBenchmarkAdapter, U as retrievalConfigFromSurface, V as buildRetrievalEvalDispatch, W as retrievalConfigSurface, _ as memoryRecoveryDelayMs, a as buildKnowledgeBenchmarkScenarios, b as runBoundedMemoryLifecycle, c as runKnowledgeBenchmarkSuite, d as summarizeKnowledgeBenchmarkCampaign, f as acquireAgentMemoryRunLease, g as createMemoryExecutionPool, h as DEFAULT_MEMORY_CLEANUP_TIMEOUT_MS, i as runMemoryAdapterBenchmark, j as buildFirstPartyMemoryLifecycleBenchmarkCases, k as INDUSTRY_MEMORY_BENCHMARKS, l as scoreKnowledgeBenchmarkArtifact, m as AgentMemoryLifecycleUnsafeError, n as parseKnowledgeBenchmarkJsonl, o as knowledgeBenchmarkJudge, p as AgentMemoryLifecycleTimeoutError, r as parseKnowledgeBenchmarkQrels, s as renderKnowledgeBenchmarkReportMarkdown, t as buildRetrievalBenchmarkCasesFromQrels, u as scoreMemoryBenchmarkArtifact, x as sleepForMemoryRecovery, y as resolveMemoryCleanupTimeoutMs, z as memoryHitToSourceRecord } from "./benchmarks-CmW6iORW.js";
5
+ import { A as INDUSTRY_RAG_BENCHMARKS, B as memoryWriteResultToSourceRecord, F as respondToIndustryRagBenchmarkSmokeCase, G as retrievalRecallJudge, H as partitionRetrievalScenarios, I as isKnowledgeMemoryBenchmarkCase, K as scoreRetrievalArtifact, L as createInMemoryBenchmarkAdapter, M as buildIndustryMemoryBenchmarkSmokeCases, N as buildIndustryRagBenchmarkSmokeCases, P as respondToIndustryMemoryBenchmarkSmokeCase, R as createNoopMemoryBenchmarkAdapter, U as retrievalConfigFromSurface, V as buildRetrievalEvalDispatch, W as retrievalConfigSurface, _ as memoryRecoveryDelayMs, a as buildKnowledgeBenchmarkScenarios, b as runBoundedMemoryLifecycle, c as runKnowledgeBenchmarkSuite, d as summarizeKnowledgeBenchmarkCampaign, f as acquireAgentMemoryRunLease, g as createMemoryExecutionPool, h as DEFAULT_MEMORY_CLEANUP_TIMEOUT_MS, i as runMemoryAdapterBenchmark, j as buildFirstPartyMemoryLifecycleBenchmarkCases, k as INDUSTRY_MEMORY_BENCHMARKS, l as scoreKnowledgeBenchmarkArtifact, m as AgentMemoryLifecycleUnsafeError, n as parseKnowledgeBenchmarkJsonl, o as knowledgeBenchmarkJudge, p as AgentMemoryLifecycleTimeoutError, r as parseKnowledgeBenchmarkQrels, s as renderKnowledgeBenchmarkReportMarkdown, t as buildRetrievalBenchmarkCasesFromQrels, u as scoreMemoryBenchmarkArtifact, x as sleepForMemoryRecovery, y as resolveMemoryCleanupTimeoutMs, z as memoryHitToSourceRecord } from "./benchmarks-C8L7HJb4.js";
6
6
  import { IRS_DIMENSION_HINTS, MAX_RESPONSE_BYTES, MIN_REQUEST_GAP_MS, POLITE_USER_AGENT, __resetHttpThrottle, createCornellLiiSource, createIrsPublicationsSource, createStateSosSource, extractLinks, firstMatch, htmlToText, innerHtmlById, looksLikeBlockPage, politeFetch } from "./sources/index.js";
7
7
  import { createHash } from "node:crypto";
8
8
  import { cp, lstat, mkdir, mkdtemp, readFile, rm, stat } from "node:fs/promises";
@@ -546,7 +546,7 @@ function triageSource(source, options) {
546
546
  triage: "drop",
547
547
  reason: `thin body (${bodyLen} < ${options.minBodyChars} chars)`
548
548
  };
549
- const host = hostOf$1(source.uri);
549
+ const host = hostOf(source.uri);
550
550
  if (host.length > 0 && options.authoritativeHosts.some((suffix) => hostMatches(host, suffix)) && bodyLen >= options.substantialBodyChars) return {
551
551
  triage: "keep",
552
552
  reason: `authoritative host ${host} + substantial body (${bodyLen})`
@@ -556,7 +556,7 @@ function triageSource(source, options) {
556
556
  reason: `unknown host ${host || "(none)"}, body ${bodyLen} chars`
557
557
  };
558
558
  }
559
- function hostOf$1(uri) {
559
+ function hostOf(uri) {
560
560
  try {
561
561
  return new URL(uri.trim()).hostname.toLowerCase().replace(/^www\./, "");
562
562
  } catch {
@@ -5082,8 +5082,10 @@ async function materialFactsSurfaced(kb, checklist) {
5082
5082
  async function runVerifiedResearchLoop(options) {
5083
5083
  const maxRounds = Math.max(1, options.maxRounds ?? 3);
5084
5084
  await initKnowledgeBase(options.root);
5085
+ const store = new FileSystemKbStore({ root: options.root });
5085
5086
  const steps = [];
5086
5087
  let index = await buildKnowledgeIndex(options.root);
5088
+ await confirmRegisteredSources(options.driver, index.sources);
5087
5089
  let readiness = readinessFor(options, index);
5088
5090
  let ready = isReady(readiness?.report);
5089
5091
  let steer;
@@ -5103,7 +5105,8 @@ async function runVerifiedResearchLoop(options) {
5103
5105
  const accepted = [];
5104
5106
  const rejectedWorkerSources = [];
5105
5107
  const existingUris = new Set(index.sources.flatMap((source) => typeof source.metadata?.originalUri === "string" ? [source.metadata.originalUri] : []));
5106
- for (const source of workerContribution.sources ?? []) {
5108
+ for (const proposedSource of workerContribution.sources ?? []) {
5109
+ const source = snapshotSourceTextInput(proposedSource);
5107
5110
  if (isDuplicate(source, existingUris, accepted)) {
5108
5111
  rejectedWorkerSources.push({
5109
5112
  source,
@@ -5127,6 +5130,7 @@ async function runVerifiedResearchLoop(options) {
5127
5130
  });
5128
5131
  }
5129
5132
  const acceptedWorkerSources = await registerSources(options, accepted);
5133
+ await confirmRegisteredSources(options.driver, acceptedWorkerSources);
5130
5134
  const writtenPages = [];
5131
5135
  writtenPages.push(...await applyPages(options.root, workerContribution, acceptedWorkerSources));
5132
5136
  index = await buildKnowledgeIndex(options.root);
@@ -5146,13 +5150,18 @@ async function runVerifiedResearchLoop(options) {
5146
5150
  });
5147
5151
  driverNotes = driverContribution.notes;
5148
5152
  driverSources = await registerSources(options, driverContribution.sources ?? []);
5153
+ await confirmRegisteredSources(options.driver, driverSources);
5149
5154
  writtenPages.push(...await applyPages(options.root, driverContribution, driverSources));
5150
5155
  index = await buildKnowledgeIndex(options.root);
5151
5156
  readiness = readinessFor(options, index);
5152
5157
  }
5153
5158
  ready = isReady(readiness?.report);
5154
5159
  const remainingGaps = gapsFromReadiness(readiness);
5155
- steer = ready ? void 0 : foldGaps(options.driver, remainingGaps);
5160
+ if (ready || remainingGaps.length === 0) steer = void 0;
5161
+ else {
5162
+ await options.driver.prepareFold?.();
5163
+ steer = foldGaps(options.driver, remainingGaps);
5164
+ }
5156
5165
  const step = {
5157
5166
  round,
5158
5167
  gaps,
@@ -5182,6 +5191,8 @@ async function runVerifiedResearchLoop(options) {
5182
5191
  driver: driverNotes
5183
5192
  }
5184
5193
  };
5194
+ await options.driver.checkpoint?.();
5195
+ await store.putEvent(step.event);
5185
5196
  steps.push(step);
5186
5197
  await options.onRound?.(step);
5187
5198
  }
@@ -5225,9 +5236,18 @@ function isDuplicate(source, existingUris, accepted) {
5225
5236
  }
5226
5237
  async function registerSources(options, sources) {
5227
5238
  const records = [];
5228
- for (const source of sources) records.push(await addSourceText(options.root, source, options.sourceOptions));
5239
+ for (const candidate of sources) {
5240
+ const source = snapshotSourceTextInput(candidate);
5241
+ records.push(await addSourceText(options.root, source, options.sourceOptions));
5242
+ }
5229
5243
  return records;
5230
5244
  }
5245
+ async function confirmRegisteredSources(driver, sources) {
5246
+ if (!driver.commitSources) return;
5247
+ const textSources = sources.filter((source) => typeof source.metadata?.originalUri === "string");
5248
+ if (textSources.length === 0) return;
5249
+ await driver.commitSources(textSources);
5250
+ }
5231
5251
  /**
5232
5252
  * Apply a contribution's curated pages. Static `proposalText` plus a
5233
5253
  * `buildPages(acceptedSources)` result are concatenated and run through the safe
@@ -5248,11 +5268,11 @@ function requireReadiness(readiness, options) {
5248
5268
  return buildEvalKnowledgeBundle({
5249
5269
  ...options.readiness ?? {},
5250
5270
  taskId: options.readinessTaskId ?? options.goal,
5251
- index: emptyIndex$1(options.root),
5271
+ index: emptyIndex(options.root),
5252
5272
  specs: []
5253
5273
  });
5254
5274
  }
5255
- function emptyIndex$1(root) {
5275
+ function emptyIndex(root) {
5256
5276
  return {
5257
5277
  root,
5258
5278
  generatedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
@@ -5436,159 +5456,6 @@ async function runInvestmentThesisTask(input, options) {
5436
5456
  };
5437
5457
  }
5438
5458
  //#endregion
5439
- //#region src/kb-store.ts
5440
- var MemoryKbStore = class {
5441
- sources = /* @__PURE__ */ new Map();
5442
- pages = /* @__PURE__ */ new Map();
5443
- events = [];
5444
- index = null;
5445
- async putSource(source) {
5446
- this.sources.set(source.id, clone(source));
5447
- }
5448
- async getSource(id) {
5449
- return clone(this.sources.get(id) ?? null);
5450
- }
5451
- async listSources() {
5452
- return [...this.sources.values()].map(clone);
5453
- }
5454
- async putPage(page) {
5455
- this.pages.set(page.id, clone(page));
5456
- }
5457
- async getPage(idOrPath) {
5458
- return clone(this.pages.get(idOrPath) ?? [...this.pages.values()].find((page) => page.path === idOrPath) ?? null);
5459
- }
5460
- async listPages() {
5461
- return [...this.pages.values()].map(clone);
5462
- }
5463
- async putIndex(index) {
5464
- this.index = clone(index);
5465
- }
5466
- async getIndex() {
5467
- if (this.index) return clone(this.index);
5468
- const pages = await this.listPages();
5469
- const sources = await this.listSources();
5470
- return {
5471
- root: "memory",
5472
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
5473
- sources,
5474
- pages,
5475
- graph: buildKnowledgeGraph(pages)
5476
- };
5477
- }
5478
- async putEvent(event) {
5479
- this.events.push(clone(event));
5480
- }
5481
- async listEvents(query = {}) {
5482
- let out = this.events;
5483
- if (query.type) out = out.filter((event) => event.type === query.type);
5484
- if (query.target) out = out.filter((event) => event.target === query.target);
5485
- out = [...out].sort((a, b) => a.createdAt.localeCompare(b.createdAt));
5486
- return out.slice(-(query.limit ?? out.length)).map(clone);
5487
- }
5488
- };
5489
- const knowledgeEventsSchema = z.array(KnowledgeEventSchema);
5490
- var FileSystemKbStore = class {
5491
- dir;
5492
- constructor(dir) {
5493
- this.dir = dir;
5494
- }
5495
- async putSource(source) {
5496
- const parsed = SourceRecordSchema.parse(source);
5497
- await this.updateIndex((index) => ({
5498
- ...index,
5499
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
5500
- sources: [parsed, ...index.sources.filter((entry) => entry.id !== parsed.id)]
5501
- }));
5502
- }
5503
- async getSource(id) {
5504
- return withKnowledgeRead(this.dir, async () => {
5505
- return clone((await this.readIndex())?.sources.find((source) => source.id === id) ?? null);
5506
- });
5507
- }
5508
- async listSources() {
5509
- return withKnowledgeRead(this.dir, async () => clone((await this.readIndex())?.sources ?? []));
5510
- }
5511
- async putPage(page) {
5512
- const parsed = KnowledgePageSchema.parse(page);
5513
- await this.updateIndex((index) => {
5514
- const pages = [parsed, ...index.pages.filter((entry) => entry.id !== parsed.id)];
5515
- return {
5516
- ...index,
5517
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
5518
- pages,
5519
- graph: buildKnowledgeGraph(pages)
5520
- };
5521
- });
5522
- }
5523
- async getPage(idOrPath) {
5524
- return withKnowledgeRead(this.dir, async () => {
5525
- return clone((await this.readIndex())?.pages.find((page) => page.id === idOrPath || page.path === idOrPath) ?? null);
5526
- });
5527
- }
5528
- async listPages() {
5529
- return withKnowledgeRead(this.dir, async () => clone((await this.readIndex())?.pages ?? []));
5530
- }
5531
- async putIndex(index) {
5532
- const parsed = KnowledgeIndexSchema.parse(index);
5533
- await withKnowledgeMutation(this.dir, () => writeJsonDurableWithinRoot(this.dir, "index.json", parsed));
5534
- }
5535
- async getIndex() {
5536
- return withKnowledgeRead(this.dir, () => this.readIndex());
5537
- }
5538
- async putEvent(event) {
5539
- const parsed = KnowledgeEventSchema.parse(event);
5540
- await withKnowledgeMutation(this.dir, async () => {
5541
- const next = [...(await this.readEvents()).filter((entry) => entry.id !== parsed.id), parsed].sort((a, b) => a.createdAt.localeCompare(b.createdAt));
5542
- await writeJsonDurableWithinRoot(this.dir, "events.json", next);
5543
- });
5544
- }
5545
- async listEvents(query = {}) {
5546
- return withKnowledgeRead(this.dir, async () => {
5547
- let events = await this.readEvents();
5548
- if (query.type) events = events.filter((event) => event.type === query.type);
5549
- if (query.target) events = events.filter((event) => event.target === query.target);
5550
- return clone(events.slice(-(query.limit ?? events.length)));
5551
- });
5552
- }
5553
- async updateIndex(change) {
5554
- await withKnowledgeMutation(this.dir, async () => {
5555
- const current = await this.readIndex() ?? emptyIndex(this.dir);
5556
- const next = KnowledgeIndexSchema.parse(change(current));
5557
- await writeJsonDurableWithinRoot(this.dir, "index.json", next);
5558
- });
5559
- }
5560
- async readIndex() {
5561
- return readJsonFile(this.dir, "index.json", KnowledgeIndexSchema);
5562
- }
5563
- async readEvents() {
5564
- return await readJsonFile(this.dir, "events.json", knowledgeEventsSchema) ?? [];
5565
- }
5566
- };
5567
- function emptyIndex(root) {
5568
- return {
5569
- root,
5570
- generatedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
5571
- sources: [],
5572
- pages: [],
5573
- graph: {
5574
- nodes: [],
5575
- edges: []
5576
- }
5577
- };
5578
- }
5579
- async function readJsonFile(root, relativePath, schema) {
5580
- try {
5581
- const file = await readRegularFileWithinRoot(root, relativePath);
5582
- return schema.parse(JSON.parse(file.bytes.toString("utf8")));
5583
- } catch (error) {
5584
- if (error?.code === "ENOENT") return null;
5585
- throw error;
5586
- }
5587
- }
5588
- function clone(value) {
5589
- return value == null ? value : JSON.parse(JSON.stringify(value));
5590
- }
5591
- //#endregion
5592
5459
  //#region src/propose-from-finding.ts
5593
5460
  var KnowledgeProposalParseError = class extends Error {
5594
5461
  findingId;
@@ -5941,29 +5808,133 @@ function knowledgeReleaseReport(input) {
5941
5808
  * contested IS.
5942
5809
  *
5943
5810
  * It reuses `runVerifiedResearchLoop` (it is a plain `ResearchDriver`), the web
5944
- * worker, `sha256` (claim identity), `canonicalizeUrl` (independent-source
5945
- * identity), and the `RouterClient` chat surface; it reinvents none of them.
5811
+ * worker, `claim-ledger.ts` (claim identity, independent-source identity, and
5812
+ * the merge rule), and the `RouterClient` chat surface; it reinvents none of
5813
+ * them.
5814
+ */
5815
+ /**
5816
+ * The in-memory driver. Its belief state lives for exactly as long as the
5817
+ * process does — use `createPersistentResearchDrivingDriver` when the run must
5818
+ * survive a crash or resume.
5946
5819
  */
5947
5820
  function createResearchDrivingDriver(options = {}) {
5821
+ return buildDriver(options);
5822
+ }
5823
+ /**
5824
+ * The durable driver: same behaviour, plus its claim ledger is read from the
5825
+ * store at construction and written back after every claim and every round.
5826
+ *
5827
+ * Construction is asynchronous because loading is I/O, and loading has to happen
5828
+ * before the caller can read `researchState()` or `isComplete()` — a driver that
5829
+ * loaded lazily would answer "nothing researched, not complete" for a run that
5830
+ * had already corroborated everything.
5831
+ */
5832
+ async function createPersistentResearchDrivingDriver(options) {
5833
+ const ledgerId = assertClaimLedgerId(options.ledgerId);
5834
+ const existing = await options.store.getClaimLedger(ledgerId);
5835
+ const driver = buildDriver(options, {
5836
+ store: options.store,
5837
+ ledgerId
5838
+ }, existing ?? void 0);
5839
+ if (existing && (existing.preparedRounds ?? existing.rounds) > existing.rounds) await driver.checkpoint();
5840
+ return driver;
5841
+ }
5842
+ function buildDriver(options, persistence, restored) {
5948
5843
  const minIndependentSources = Math.max(2, options.minIndependentSources ?? 2);
5949
5844
  const maxQuestionsPerRound = Math.max(1, options.maxQuestionsPerRound ?? 6);
5950
5845
  const maxClaimsPerSource = Math.max(1, options.maxClaimsPerSource ?? 3);
5951
5846
  const deterministicFallback = options.deterministicFallback ?? true;
5952
- const claims = /* @__PURE__ */ new Map();
5953
- const questions = /* @__PURE__ */ new Map();
5954
- let rounds = 0;
5847
+ const claims = new Map((restored?.claims ?? []).map((claim) => [claim.id, fromRecord(claim)]));
5848
+ const claimEvidence = new Map((restored?.claimEvidence ?? []).map((evidence) => [evidence.id, evidence]));
5849
+ const registeredSources = new Map((restored?.registeredSources ?? []).map((source) => [source.sourceId, source]));
5850
+ const questions = new Map((restored?.questions ?? []).map((question) => [question.id, question]));
5851
+ let rounds = restored?.rounds ?? 0;
5852
+ let preparedRounds = Math.max(rounds, restored?.preparedRounds ?? rounds);
5853
+ let goal = restored?.goal;
5955
5854
  let lastSteer;
5855
+ if (preparedRounds > rounds) {
5856
+ for (let round = rounds + 1; round <= preparedRounds; round += 1) for (const question of synthesizeDeepQuestions([...claims.values()], round).slice(0, maxQuestionsPerRound)) if (!questions.has(question.id)) questions.set(question.id, question);
5857
+ rounds = preparedRounds;
5858
+ }
5859
+ function toLedger() {
5860
+ return {
5861
+ schemaVersion: 2,
5862
+ id: persistence?.ledgerId ?? "in-memory",
5863
+ ...goal === void 0 ? {} : { goal },
5864
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
5865
+ rounds,
5866
+ ...preparedRounds > rounds ? { preparedRounds } : {},
5867
+ claimEvidence: [...claimEvidence.values()].sort((left, right) => left.id.localeCompare(right.id)),
5868
+ registeredSources: [...registeredSources.values()].sort((left, right) => left.sourceId.localeCompare(right.sourceId)),
5869
+ claims: [...claims.values()].map((claim) => ({
5870
+ ...claim,
5871
+ supportingHosts: [...new Set(claim.supportingHosts)].sort(),
5872
+ supportingUris: [...new Set(claim.supportingUris)].sort(),
5873
+ contradicts: [...new Set(claim.contradicts)].sort()
5874
+ })).sort((a, b) => a.id.localeCompare(b.id)),
5875
+ questions: [...questions.values()].map((question) => ({
5876
+ ...question,
5877
+ claimIds: [...new Set(question.claimIds)].sort()
5878
+ })).sort((a, b) => a.id.localeCompare(b.id))
5879
+ };
5880
+ }
5881
+ /**
5882
+ * Write this driver's belief state into the stored ledger and adopt the
5883
+ * result.
5884
+ *
5885
+ * It merges rather than overwrites, and then rehydrates from the merged
5886
+ * record, which is the whole of what makes knowledge compound across
5887
+ * workers. Two drivers on one ledger id — a resumed run beside a still-live
5888
+ * one, or two workers researching one goal in parallel — would otherwise each
5889
+ * write a whole record built from what it read before the other wrote, and
5890
+ * the later write would erase the earlier writer's claims. Rehydrating means
5891
+ * a claim another worker corroborated counts toward THIS driver's completion
5892
+ * oracle from the next round onward.
5893
+ */
5894
+ async function persist() {
5895
+ if (!persistence) return;
5896
+ const mine = toLedger();
5897
+ const merged = await persistence.store.mergeClaimLedger(persistence.ledgerId, (current) => current === null ? mine : mergeClaimLedgers(current, mine));
5898
+ claims.clear();
5899
+ for (const claim of merged.claims) claims.set(claim.id, fromRecord(claim));
5900
+ claimEvidence.clear();
5901
+ for (const evidence of merged.claimEvidence) claimEvidence.set(evidence.id, evidence);
5902
+ registeredSources.clear();
5903
+ for (const source of merged.registeredSources) registeredSources.set(source.sourceId, source);
5904
+ questions.clear();
5905
+ for (const question of merged.questions) questions.set(question.id, question);
5906
+ rounds = Math.max(rounds, merged.rounds);
5907
+ preparedRounds = Math.max(rounds, merged.preparedRounds ?? merged.rounds);
5908
+ goal = merged.goal ?? goal;
5909
+ }
5910
+ async function prepareFold() {
5911
+ if (!persistence) return;
5912
+ preparedRounds = Math.max(preparedRounds, rounds + 1);
5913
+ await persist();
5914
+ }
5915
+ /**
5916
+ * A ledger accumulates evidence FOR a goal. Reusing one id across two goals
5917
+ * merges two runs' beliefs into one corroboration count, which is worse than
5918
+ * losing them, so it fails rather than merging.
5919
+ */
5920
+ function bindGoal(nextGoal) {
5921
+ if (goal === void 0) {
5922
+ goal = nextGoal;
5923
+ return;
5924
+ }
5925
+ if (goal !== nextGoal) throw new Error(`claim ledger '${persistence?.ledgerId ?? "in-memory"}' accumulated evidence for goal '${goal}' and cannot be reused for '${nextGoal}'`);
5926
+ }
5956
5927
  function resolveRouter() {
5957
5928
  return options.router ?? createTangleRouterClient(options.router_options);
5958
5929
  }
5959
5930
  /** Record a claim from a source, growing its independent-source support. */
5960
5931
  function recordClaim(extracted, sourceUri, round) {
5961
5932
  const id = claimId(extracted.text);
5962
- const host = hostOf(sourceUri);
5933
+ const host = claimSourceHost(sourceUri);
5963
5934
  const existing = claims.get(id);
5964
5935
  if (existing) {
5965
5936
  if (host) existing.supportingHosts.add(host);
5966
- if (!existing.supportingUris.includes(sourceUri)) existing.supportingUris.push(sourceUri);
5937
+ addUnique(existing.supportingUris, sourceUri);
5967
5938
  linkContradiction(existing, extracted.contradictsExistingId);
5968
5939
  return existing;
5969
5940
  }
@@ -5980,6 +5951,73 @@ function createResearchDrivingDriver(options = {}) {
5980
5951
  claims.set(id, tracked);
5981
5952
  return tracked;
5982
5953
  }
5954
+ /** Persist an extraction observation without treating its source as registered. */
5955
+ function recordEvidence(extracted, sourceVersion, round) {
5956
+ const text = extracted.text.trim();
5957
+ const observedClaimId = claimId(text);
5958
+ const contradictsClaimId = extracted.contradictsExistingId === observedClaimId ? void 0 : extracted.contradictsExistingId;
5959
+ const evidence = {
5960
+ id: claimEvidenceId({
5961
+ claimId: observedClaimId,
5962
+ sourceId: sourceVersion.sourceId,
5963
+ sourceUri: sourceVersion.uri,
5964
+ sourceContentHash: sourceVersion.contentHash,
5965
+ contradictsClaimId
5966
+ }),
5967
+ claimId: observedClaimId,
5968
+ text,
5969
+ sourceId: sourceVersion.sourceId,
5970
+ sourceUri: sourceVersion.uri,
5971
+ sourceContentHash: sourceVersion.contentHash,
5972
+ ...contradictsClaimId === void 0 ? {} : { contradictsClaimId },
5973
+ firstSeenRound: round
5974
+ };
5975
+ const existing = claimEvidence.get(evidence.id);
5976
+ if (!existing) {
5977
+ claimEvidence.set(evidence.id, evidence);
5978
+ return evidence;
5979
+ }
5980
+ const merged = {
5981
+ ...evidence.firstSeenRound < existing.firstSeenRound || evidence.firstSeenRound === existing.firstSeenRound && evidence.text < existing.text ? evidence : existing,
5982
+ firstSeenRound: Math.min(existing.firstSeenRound, evidence.firstSeenRound)
5983
+ };
5984
+ claimEvidence.set(merged.id, merged);
5985
+ return merged;
5986
+ }
5987
+ /** Materialize evidence for newly confirmed exact source versions into live claims. */
5988
+ function materializeEvidenceFor(sourceVersions) {
5989
+ const evidence = [...claimEvidence.values()].filter((item) => sourceVersions.has(sourceVersionKeyOfEvidence(item)));
5990
+ const texts = [];
5991
+ for (const item of evidence) {
5992
+ recordClaim({
5993
+ text: item.text,
5994
+ contradictsExistingId: item.contradictsClaimId
5995
+ }, item.sourceUri, item.firstSeenRound);
5996
+ texts.push(item.text);
5997
+ }
5998
+ for (const item of evidence) {
5999
+ const claim = claims.get(item.claimId);
6000
+ if (claim) linkContradiction(claim, item.contradictsClaimId);
6001
+ }
6002
+ return texts;
6003
+ }
6004
+ async function commitSources(sources) {
6005
+ const versions = sources.map(sourceVersionOfRecord);
6006
+ const nextRegistered = new Map(registeredSources);
6007
+ const newlyRegistered = /* @__PURE__ */ new Set();
6008
+ for (const version of versions) {
6009
+ const key = researchSourceVersionKey(version);
6010
+ const existing = nextRegistered.get(version.sourceId);
6011
+ if (existing && researchSourceVersionKey(existing) !== key) throw new Error(`registered source '${version.sourceId}' has conflicting immutable content`);
6012
+ if (existing) continue;
6013
+ nextRegistered.set(version.sourceId, version);
6014
+ newlyRegistered.add(key);
6015
+ }
6016
+ registeredSources.clear();
6017
+ for (const [sourceId, version] of nextRegistered) registeredSources.set(sourceId, version);
6018
+ if (newlyRegistered.size > 0) markAddressed(materializeEvidenceFor(newlyRegistered));
6019
+ await persist();
6020
+ }
5983
6021
  /** Wire a bidirectional contradiction edge and mark BOTH claims contested. */
5984
6022
  function linkContradiction(claim, otherId) {
5985
6023
  if (!otherId || otherId === claim.id) return;
@@ -6049,17 +6087,26 @@ function createResearchDrivingDriver(options = {}) {
6049
6087
  * because such a source cannot drive the research and pollutes the KB.
6050
6088
  */
6051
6089
  async verifySource(source, ctx) {
6052
- const extracted = await extractClaims(source, ctx);
6090
+ const sourceSnapshot = snapshotSourceTextInput(source);
6091
+ const goalSnapshot = ctx.goal;
6092
+ const roundSnapshot = ctx.round;
6093
+ const sourceVersion = sourceVersionOfProposal(sourceSnapshot);
6094
+ bindGoal(goalSnapshot);
6095
+ const extracted = await extractClaims(sourceSnapshot, goalSnapshot);
6053
6096
  if (extracted.length === 0) return {
6054
6097
  accept: false,
6055
6098
  reason: "no extractable claim: source yields nothing to drive the research deeper"
6056
6099
  };
6057
- const newTexts = [];
6058
- for (const claim of extracted) {
6059
- recordClaim(claim, source.uri, ctx.round);
6060
- newTexts.push(claim.text);
6100
+ for (const claim of extracted) recordEvidence(claim, sourceVersion, roundSnapshot);
6101
+ if (!persistence) {
6102
+ const key = researchSourceVersionKey(sourceVersion);
6103
+ registeredSources.set(sourceVersion.sourceId, sourceVersion);
6104
+ markAddressed(materializeEvidenceFor(/* @__PURE__ */ new Set([key])));
6105
+ } else {
6106
+ const registered = registeredSources.get(sourceVersion.sourceId);
6107
+ if (registered && researchSourceVersionKey(registered) === researchSourceVersionKey(sourceVersion)) markAddressed(materializeEvidenceFor(/* @__PURE__ */ new Set([researchSourceVersionKey(sourceVersion)])));
6061
6108
  }
6062
- markAddressed(newTexts);
6109
+ await persist();
6063
6110
  return { accept: true };
6064
6111
  },
6065
6112
  /**
@@ -6069,6 +6116,7 @@ function createResearchDrivingDriver(options = {}) {
6069
6116
  * (3) INVALIDATION challenges for weakly-supported / contradicted claims.
6070
6117
  */
6071
6118
  foldGaps(gaps) {
6119
+ if (persistence && preparedRounds <= rounds) throw new Error("persistent research driver must prepareFold before foldGaps");
6072
6120
  rounds += 1;
6073
6121
  const round = rounds;
6074
6122
  const ledger = [...claims.values()];
@@ -6096,15 +6144,35 @@ function createResearchDrivingDriver(options = {}) {
6096
6144
  },
6097
6145
  lastSteer() {
6098
6146
  return lastSteer;
6099
- }
6147
+ },
6148
+ checkpoint: persist,
6149
+ prepareFold,
6150
+ commitSources,
6151
+ toLedger
6100
6152
  };
6101
- async function extractClaims(source, ctx) {
6102
- const fromLlm = await extractClaimsWithLlm(source, ctx, [...claims.values()]);
6153
+ async function extractClaims(source, goal) {
6154
+ const fromLlm = await extractClaimsWithLlm(source, goal, claimsForExtraction());
6103
6155
  if (fromLlm.length > 0) return fromLlm.slice(0, maxClaimsPerSource);
6104
6156
  if (deterministicFallback) return deterministicClaims(source).slice(0, maxClaimsPerSource);
6105
6157
  return [];
6106
6158
  }
6107
- async function extractClaimsWithLlm(source, ctx, ledger) {
6159
+ function claimsForExtraction() {
6160
+ const known = new Map(claims);
6161
+ for (const evidence of claimEvidence.values()) {
6162
+ if (known.has(evidence.claimId)) continue;
6163
+ known.set(evidence.claimId, {
6164
+ id: evidence.claimId,
6165
+ text: evidence.text,
6166
+ supportingHosts: /* @__PURE__ */ new Set(),
6167
+ supportingUris: [],
6168
+ contradicts: /* @__PURE__ */ new Set(),
6169
+ contested: false,
6170
+ firstSeenRound: evidence.firstSeenRound
6171
+ });
6172
+ }
6173
+ return [...known.values()];
6174
+ }
6175
+ async function extractClaimsWithLlm(source, goal, ledger) {
6108
6176
  let router;
6109
6177
  try {
6110
6178
  router = resolveRouter();
@@ -6115,7 +6183,7 @@ function createResearchDrivingDriver(options = {}) {
6115
6183
  const ledgerLines = ledger.slice(0, 20).map((claim) => `- [${claim.id}] ${claim.text}`).join("\n");
6116
6184
  const system = `You extract the KEY factual claims a researcher would cite a page for, and flag CONTRADICTIONS with claims already on the ledger. A claim is one concrete, checkable assertion using the page's own terms and numbers. Return ONLY a JSON array; each item is {"claim": string, "contradicts": string|null} where contradicts is the bracketed [id] of a ledger claim this page DIRECTLY contradicts, else null. Return at most ${maxClaimsPerSource} claims. No prose.`;
6117
6185
  const user = [
6118
- `Research goal: ${ctx.goal}`,
6186
+ `Research goal: ${goal}`,
6119
6187
  `Page title: ${source.title ?? "(none)"}`,
6120
6188
  ledgerLines ? `Claims already on the ledger:\n${ledgerLines}` : "Ledger is empty.",
6121
6189
  `Page excerpt:\n${excerpt}`,
@@ -6173,29 +6241,57 @@ function createResearchDrivingDriver(options = {}) {
6173
6241
  return out.sort((a, b) => priority[a.kind] - priority[b.kind]);
6174
6242
  }
6175
6243
  }
6244
+ function sourceVersionOfProposal(source) {
6245
+ const contentHash = sha256(source.text);
6246
+ return {
6247
+ sourceId: textSourceId(source.uri, contentHash),
6248
+ uri: source.uri,
6249
+ contentHash
6250
+ };
6251
+ }
6252
+ function sourceVersionOfRecord(source) {
6253
+ const originalUri = source.metadata?.originalUri;
6254
+ if (typeof originalUri !== "string" || originalUri.length === 0) throw new Error(`registered source '${source.id}' has no originalUri`);
6255
+ if (!/^[a-f0-9]{64}$/.test(source.contentHash)) throw new Error(`registered source '${source.id}' contentHash is not a SHA-256 digest`);
6256
+ const expectedSourceId = textSourceId(originalUri, source.contentHash);
6257
+ if (source.id !== expectedSourceId) throw new Error(`registered source '${source.id}' does not match URI-and-content identity '${expectedSourceId}'`);
6258
+ return {
6259
+ sourceId: source.id,
6260
+ uri: originalUri,
6261
+ contentHash: source.contentHash
6262
+ };
6263
+ }
6264
+ function sourceVersionKeyOfEvidence(evidence) {
6265
+ return researchSourceVersionKey({
6266
+ sourceId: evidence.sourceId,
6267
+ uri: evidence.sourceUri,
6268
+ contentHash: evidence.sourceContentHash
6269
+ });
6270
+ }
6176
6271
  function makeQuestion(kind, text, claimIds, raisedRound) {
6177
6272
  return {
6178
6273
  kind,
6179
6274
  text,
6180
- id: `q_${sha256(`${kind}:${text}`).slice(0, 16)}`,
6181
- claimIds,
6275
+ id: deepQuestionId(kind, text),
6276
+ claimIds: [...new Set(claimIds)].sort(),
6182
6277
  addressed: false,
6183
6278
  raisedRound
6184
6279
  };
6185
6280
  }
6186
- /** Claim identity = sha256 of the normalized claim text (same words ⇒ same claim). */
6187
- function claimId(text) {
6188
- return `c_${sha256(normalizeText(text)).slice(0, 16)}`;
6189
- }
6190
- function hostOf(uri) {
6191
- try {
6192
- return new URL(uri.trim()).hostname.toLowerCase().replace(/^www\./, "");
6193
- } catch {
6194
- return canonicalizeUrl(uri);
6195
- }
6281
+ function fromRecord(claim) {
6282
+ return {
6283
+ ...claim,
6284
+ supportingHosts: new Set(claim.supportingHosts),
6285
+ supportingUris: [...claim.supportingUris],
6286
+ contradicts: new Set(claim.contradicts)
6287
+ };
6196
6288
  }
6197
- function normalizeText(text) {
6198
- return text.toLowerCase().replace(/[^\p{L}\p{N}\s]+/gu, " ").replace(/\s+/g, " ").trim();
6289
+ /**
6290
+ * Set-like insert into the array form. The ledger's collections are arrays so
6291
+ * they survive `JSON.stringify`; dedup is enforced here instead of by the type.
6292
+ */
6293
+ function addUnique(values, value) {
6294
+ if (!values.includes(value)) values.push(value);
6199
6295
  }
6200
6296
  const stopwords = /* @__PURE__ */ new Set([
6201
6297
  "the",
@@ -6249,7 +6345,7 @@ const stopwords = /* @__PURE__ */ new Set([
6249
6345
  "them"
6250
6346
  ]);
6251
6347
  function contentWordSet(text) {
6252
- return new Set(normalizeText(text).split(" ").filter((word) => word.length >= 3 && !stopwords.has(word)));
6348
+ return new Set(normalizeClaimText(text).split(" ").filter((word) => word.length >= 3 && !stopwords.has(word)));
6253
6349
  }
6254
6350
  function overlapFraction(a, b) {
6255
6351
  if (a.size === 0) return 0;
@@ -6326,6 +6422,6 @@ function buildSteerText(gaps, deepQuestions, invalidationTargets, minIndependent
6326
6422
  return lines.join("\n");
6327
6423
  }
6328
6424
  //#endregion
6329
- export { AgentMemoryHitSchema, AgentMemoryKindSchema, AgentMemoryLifecycleTimeoutError, AgentMemoryLifecycleUnsafeError, AgentMemoryScopeSchema, AgentMemoryWriteInputSchema, DEFAULT_MEMORY_CLEANUP_TIMEOUT_MS, FileSystemKbStore, FileSystemSearchProvider, INDUSTRY_MEMORY_BENCHMARKS, INDUSTRY_RAG_BENCHMARKS, IRS_DIMENSION_HINTS, KnowledgeBaseCandidateSchema, KnowledgeEventSchema, KnowledgeGraphEdgeSchema, KnowledgeGraphNodeSchema, KnowledgeImprovementCandidateRefSchema, KnowledgeImprovementEvidenceSchema, KnowledgeImprovementRunStateSchema, KnowledgeIndexSchema, KnowledgePageSchema, KnowledgeProposalParseError, MAX_RESPONSE_BYTES, MIN_REQUEST_GAP_MS, MemoryKbStore, POLITE_USER_AGENT, READINESS_SPEC_DEFAULTS, RouterError, SCAFFOLD_PAGE_BASENAMES, SourceAnchorSchema, SourceRecordSchema, WIKILINK_REGEX, __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 };
6425
+ export { AgentMemoryHitSchema, AgentMemoryKindSchema, AgentMemoryLifecycleTimeoutError, AgentMemoryLifecycleUnsafeError, AgentMemoryScopeSchema, AgentMemoryWriteInputSchema, ClaimLedgerGoalConflictError, ClaimLedgerMigrationRequiredError, DEFAULT_MEMORY_CLEANUP_TIMEOUT_MS, DeepQuestionSchema, FileSystemKbStore, FileSystemSearchProvider, INDUSTRY_MEMORY_BENCHMARKS, INDUSTRY_RAG_BENCHMARKS, IRS_DIMENSION_HINTS, KB_CLAIM_LEDGER_DIR, KB_EVENTS_PATH, KB_INDEX_PATH, KB_STORE_DIR, KNOWLEDGE_EVENT_TYPES, KnowledgeBaseCandidateSchema, KnowledgeEventSchema, KnowledgeGraphEdgeSchema, KnowledgeGraphNodeSchema, KnowledgeImprovementCandidateRefSchema, KnowledgeImprovementEvidenceSchema, KnowledgeImprovementRunStateSchema, KnowledgeIndexSchema, KnowledgePageSchema, KnowledgeProposalParseError, MAX_RESPONSE_BYTES, MIN_REQUEST_GAP_MS, MemoryKbStore, POLITE_USER_AGENT, READINESS_SPEC_DEFAULTS, ResearchClaimEvidenceSchema, ResearchClaimLedgerSchema, ResearchClaimRecordSchema, ResearchSourceVersionSchema, RouterError, SCAFFOLD_PAGE_BASENAMES, SourceAnchorSchema, SourceRecordSchema, WIKILINK_REGEX, __resetHttpThrottle, acquireAgentMemoryRunLease, addSourcePath, addSourceText, agentMemorySequenceJudge, applyKnowledgeWriteBlocks, applyKnowledgeWriteBlocksFile, applyRetrievalHoldout, applySessionStickyRetrievalHoldout, assertClaimLedgerId, assertDeepQuestionIntegrity, assertResearchClaimEvidenceIntegrity, assertResearchClaimLedgerIntegrity, assertTrackedClaimIntegrity, buildAgentMemorySequenceScenarios, buildAgentMemorySequencesFromBenchmarkCases, buildEvalKnowledgeBundle, buildFirstPartyMemoryLifecycleBenchmarkCases, buildIndustryMemoryBenchmarkSmokeCases, buildIndustryRagBenchmarkSmokeCases, buildKnowledgeBenchmarkScenarios, buildKnowledgeGraph, buildKnowledgeIndex, buildRetrievalBenchmarkCasesFromQrels, buildRetrievalEvalDispatch, calibrateRagAnswerJudge, canonicalizeUrl, chunkMarkdown, citedClaimKey, citedClaimOf, claimEvidenceId, claimId, claimSourceHost, contentKey, createAdaptiveResearchDriver, createAgentMemoryBranch, createClaimDecorator, createClaimGroundingVerifier, createCollectionResearchDriver, createCornellLiiSource, createD1FreshnessStoreStub, createFileSystemFreshnessStore, createFileSystemSearchProvider, createGraphitiMemoryAdapter, createInMemoryBenchmarkAdapter, createIrsPublicationsSource, createKnowledgeControlLoopAdapter, createKnowledgeEvent, createLocalDiscoveryDispatcher, createMem0MemoryAdapter, createMemoryExecutionPool, createNeo4jAgentMemoryAdapter, createNoopMemoryBenchmarkAdapter, createPersistentResearchDrivingDriver, createRagAnswerQualityHook, createResearchDrivingDriver, createStateSosSource, createTangleRouterClient, createVerifyingResearchDriver, createWebResearchWorker, deepQuestionId, defaultGetMemoryContext, defineReadinessSpec, detectChanges, deterministicRng, diagnoseRagAnswerFailure, emitRetrievalHoldoutBypass, emptyClaimLedger, evaluateKnowledgeBaseReadiness, explainKnowledgeTarget, extractLinks, extractWikilinks, firstMatch, forkAgentMemoryBranchSnapshot, formatFrontmatter, fromAgentCandidateKnowledgeRef, gradeCompanyAgainstText, gradeFactAgainstText, graphitiMemoryAdapterIdentity, groundClaimInText, hashKnowledgeBase, htmlToText, improveKnowledgeBase, initKnowledgeBase, innerHtmlById, inspectKnowledgeIndex, inspectPendingKnowledgeMutation, investmentThesisSet, isKernelAnchoredPath, isKnowledgeMemoryBenchmarkCase, isMissingFile, isSafeKnowledgePath, isScaffoldPath, jsonCandidateCodec, jsonObjectCandidateCodec, kbIndexToText, knowledgeBenchmarkJudge, knowledgeImprovementCandidateRef, knowledgeImprovementRunDir, knowledgeImprovementRunId, knowledgeReleaseReport, layoutFor, lensDistribution, linkClaimContradictions, lintKnowledgeIndex, listRegularFilesWithinRoot, loadKnowledgeImprovementActivationResult, loadKnowledgeImprovementEvents, loadKnowledgeImprovementState, loadKnowledgePages, loadSourceRegistry, looksLikeBlockPage, materialFactsSurfaced, materialFactsSurfacedInText, materializeRegisteredClaimEvidence, mediaTypeFor, mem0MemoryAdapterIdentity, memoryHitToSourceRecord, memoryRecoveryDelayMs, memoryWriteResultToSourceRecord, mergeClaimLedgers, mergeTrackedClaims, normalizeClaimText, normalizeExternalRagScores, normalizeLinkTarget, optimizeKnowledgeBasePolicy, parseFrontmatter, parseKnowledgeBenchmarkJsonl, parseKnowledgeBenchmarkQrels, parseKnowledgeWriteBlocks, partitionRetrievalScenarios, politeFetch, promoteKnowledgeCandidate, proposeFromFinding, proposeFromFindings, ragAnswerQualityJudge, readRegularFileNoFollow, readRegularFileWithinRoot, reciprocalRankFusion, recoverPendingKnowledgeMutation, removeDurable, renameDurable, renderKnowledgeBenchmarkReportMarkdown, renderMemoryContext, researchSourceVersionKey, 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, snapshotSourceTextInput, sourceMatchesGaps, sourceRegistryPath, stableId, stripFrontmatter, summarizeKnowledgeBenchmarkCampaign, syncDirectory, textSourceAdapter, textSourceId, thesisReadinessSpecs, toAgentCandidateKnowledgeRef, toDeepEvalTestCases, toOffPolicyTrajectory, toRagCheckerRecords, toRagasEvaluationRows, toTruLensRecords, tokenizeQuery, totalMaterialFacts, triageSource, validateKnowledgeIndex, withCitedClaim, withKnowledgeImprovementCandidate, withKnowledgeImprovementComparison, withSafeDescendant, withSafeDirectory, writeFileDurable, writeFileDurableWithinRoot, writeJson, writeJsonDurable, writeJsonDurableWithinRoot, writeKnowledgeIndex, writeSourceRegistry };
6330
6426
 
6331
6427
  //# sourceMappingURL=index.js.map