@tangle-network/agent-knowledge 1.1.1 → 1.3.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.
package/dist/index.d.ts CHANGED
@@ -1,25 +1,9 @@
1
- import { c as KnowledgeWriteParseResult, S as SourceRecord, d as KnowledgeEventType, e as KnowledgeEvent, f as KnowledgePage, g as KnowledgeIndex, h as SourceRegistry, b as KnowledgeGraph, i as KnowledgeSearchResult, j as KnowledgeLintFinding, k as KnowledgeBaseCandidate, l as KnowledgeRelease } from './types-YkFkfwJG.js';
2
- export { C as ClaimRef, m as KnowledgeClaim, K as KnowledgeGraphEdge, a as KnowledgeGraphNode, n as KnowledgeId, o as KnowledgePolicy, p as KnowledgeRelation, q as KnowledgeUnit, r as KnowledgeWriteBlock, s as SourceAnchor } from './types-YkFkfwJG.js';
1
+ import { S as SourceRecord, c as KnowledgeIndex, d as KnowledgeSearchResult, e as KnowledgeEventType, f as KnowledgeEvent, g as KnowledgePage, b as KnowledgeGraph, h as KnowledgeLintFinding, i as KnowledgeBaseCandidate, j as KnowledgeWriteBlock, k as KnowledgeClaim, l as KnowledgeRelease, m as SourceRegistry, n as KnowledgeWriteParseResult } from './types-CAeh7Lwb.js';
2
+ export { C as ClaimRef, K as KnowledgeGraphEdge, a as KnowledgeGraphNode, o as KnowledgeId, p as KnowledgePolicy, q as KnowledgeRelation, r as KnowledgeUnit, s as SourceAnchor } from './types-CAeh7Lwb.js';
3
+ import { KnowledgeFragment } from './sources/index.js';
4
+ 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';
5
+ import { KnowledgeRequirementCategory, KnowledgeAcquisitionMode, KnowledgeImportance, KnowledgeFreshness, KnowledgeSensitivity, KnowledgeRequirement, KnowledgeBundle, KnowledgeReadinessReport, UserQuestion, DataAcquisitionPlan, MultiShotVariant, MultiShotOptimizationConfig, MultiShotRunner, MultiShotScorer, MultiShotMutateAdapter, MultiShotOptimizationResult, AnalystSeverity, AnalystFinding, ReleaseConfidenceScorecard, RunRecord, ControlRuntimeConfig, ControlEvalResult } from '@tangle-network/agent-eval';
3
6
  import { z } from 'zod';
4
- import { MultiShotVariant, MultiShotOptimizationConfig, MultiShotRunner, MultiShotScorer, MultiShotMutateAdapter, MultiShotOptimizationResult, ReleaseConfidenceScorecard, RunRecord, KnowledgeRequirementCategory, KnowledgeAcquisitionMode, KnowledgeImportance, KnowledgeFreshness, KnowledgeSensitivity, KnowledgeRequirement, KnowledgeBundle, KnowledgeReadinessReport, UserQuestion, DataAcquisitionPlan } from '@tangle-network/agent-eval';
5
-
6
- declare function sha256(text: string): string;
7
- declare function slugify(input: string): string;
8
- declare function stableId(prefix: string, content: string): string;
9
-
10
- interface ParsedFrontmatter {
11
- frontmatter: Record<string, unknown>;
12
- body: string;
13
- }
14
- declare function parseFrontmatter(content: string): ParsedFrontmatter;
15
- declare function formatFrontmatter(frontmatter: Record<string, unknown>, body: string): string;
16
-
17
- declare const WIKILINK_REGEX: RegExp;
18
- declare function extractWikilinks(content: string): string[];
19
- declare function normalizeLinkTarget(target: string): string;
20
-
21
- declare function isSafeKnowledgePath(path: string, allowedPrefixes?: string[]): boolean;
22
- declare function parseKnowledgeWriteBlocks(text: string, allowedPrefixes?: string[]): KnowledgeWriteParseResult;
23
7
 
24
8
  interface SourceAdapterInput {
25
9
  uri: string;
@@ -39,15 +23,698 @@ interface SourceAdapter {
39
23
  canLoad(input: SourceAdapterInput): boolean;
40
24
  load(input: SourceAdapterInput): Promise<SourceAdapterOutput> | SourceAdapterOutput;
41
25
  }
42
- declare const textSourceAdapter: SourceAdapter;
43
- declare function mediaTypeFor(uri: string): string;
44
-
45
- interface ApplyWriteBlocksResult {
46
- written: string[];
47
- warnings: string[];
26
+ declare const textSourceAdapter: SourceAdapter;
27
+ declare function mediaTypeFor(uri: string): string;
28
+
29
+ /**
30
+ * Change detection across snapshots of one source's fragments.
31
+ *
32
+ * The output drives the continuous-ingestion loop: each `KnowledgeChange`
33
+ * carries the eval dimensions affected (`affectedDimensions`), which an
34
+ * agent-eval campaign scheduler consumes to decide which campaigns to
35
+ * re-run. Three change kinds:
36
+ *
37
+ * - `added` — fragment id appears in `next` but not `prev`.
38
+ * - `removed` — fragment id appears in `prev` but not `next`. Typical
39
+ * trigger: an authority retires a Wex slug, or a state SOS reorganises
40
+ * its forms catalogue.
41
+ * - `modified` — fragment id appears in both, body hash differs. This
42
+ * is the dominant change kind in practice — the Ryan-LLC v. FTC
43
+ * vacatur case manifests as a `modified` on the Wex non-compete
44
+ * fragment, NOT as a removed one.
45
+ *
46
+ * Unverifiable fragments are filtered out before diffing — comparing a
47
+ * captcha-blocked snapshot against a real one would falsely fire every
48
+ * fragment as removed. The caller can inspect the raw lists if they want
49
+ * to surface block-page failures.
50
+ *
51
+ * Within-snapshot duplicate ids are an upstream bug; this function picks
52
+ * the LAST one and emits a diagnostic via the `warnings` field.
53
+ *
54
+ * @stable
55
+ */
56
+ type KnowledgeChangeKind = 'added' | 'removed' | 'modified';
57
+ interface KnowledgeChange {
58
+ /** Source-scoped id (matches `KnowledgeFragment.id`). */
59
+ fragmentId: string;
60
+ kind: KnowledgeChangeKind;
61
+ /**
62
+ * For `added`: full body of the new fragment.
63
+ * For `removed`: full body of the prior fragment.
64
+ * For `modified`: unified-diff-style payload `{ before, after }` body strings.
65
+ */
66
+ diff?: {
67
+ before?: string;
68
+ after?: string;
69
+ };
70
+ /**
71
+ * Eval dimensions to re-score. Computed as the union of both fragments'
72
+ * `dimensionHints`. The eval cron treats this as a set of campaign tags.
73
+ */
74
+ affectedDimensions: string[];
75
+ /** URL of the affected authority page (from whichever side has it). */
76
+ url?: string;
77
+ /**
78
+ * Source-attested change time. For `modified`, takes the NEXT fragment's
79
+ * `sourceUpdatedAt`. For `removed`, takes the PRIOR fragment's
80
+ * `sourceUpdatedAt`. For `added`, takes the NEXT fragment's
81
+ * `sourceUpdatedAt`. Consumers index changes by this date.
82
+ */
83
+ detectedAt: string;
84
+ }
85
+ interface DetectChangesResult {
86
+ changes: KnowledgeChange[];
87
+ /** Counts by kind — handy for dashboards. */
88
+ summary: {
89
+ added: number;
90
+ removed: number;
91
+ modified: number;
92
+ };
93
+ /** Non-fatal diagnostics (duplicate ids, dropped unverifiable fragments). */
94
+ warnings: string[];
95
+ }
96
+ interface DetectChangesOptions {
97
+ /**
98
+ * When true (default), unverifiable fragments are dropped from both
99
+ * sides before comparison. Set false ONLY when debugging block-page
100
+ * issues — comparing against unverifiable content emits false
101
+ * `removed`/`modified` changes.
102
+ */
103
+ skipUnverifiable?: boolean;
104
+ /**
105
+ * When provided, only changes whose `affectedDimensions` intersect this
106
+ * set are returned. Useful for cron loops that schedule per-dimension
107
+ * eval campaigns and only care about a subset.
108
+ */
109
+ filterDimensions?: string[];
110
+ }
111
+ declare function detectChanges(prev: KnowledgeFragment[], next: KnowledgeFragment[], options?: DetectChangesOptions): DetectChangesResult;
112
+
113
+ interface ChunkingOptions {
114
+ targetChars: number;
115
+ maxChars: number;
116
+ minChars: number;
117
+ overlapChars: number;
118
+ }
119
+ interface KnowledgeChunk {
120
+ index: number;
121
+ text: string;
122
+ headingPath: string;
123
+ charStart: number;
124
+ charEnd: number;
125
+ oversized: boolean;
126
+ }
127
+ declare function chunkMarkdown(content: string, options?: Partial<ChunkingOptions>): KnowledgeChunk[];
128
+ declare function stripFrontmatter(content: string): {
129
+ body: string;
130
+ bodyOffset: number;
131
+ };
132
+
133
+ interface DiscoveryTask {
134
+ id: string;
135
+ goal: string;
136
+ query?: string;
137
+ sourceHints?: string[];
138
+ metadata?: Record<string, unknown>;
139
+ }
140
+ interface DiscoveryResult {
141
+ taskId: string;
142
+ summary: string;
143
+ sourceUris?: string[];
144
+ claims?: Array<{
145
+ text: string;
146
+ sourceUri?: string;
147
+ confidence?: number;
148
+ }>;
149
+ followUpTasks?: DiscoveryTask[];
150
+ metadata?: Record<string, unknown>;
151
+ }
152
+ interface KnowledgeDiscoveryWorker {
153
+ run(task: DiscoveryTask, signal?: AbortSignal): Promise<DiscoveryResult> | DiscoveryResult;
154
+ }
155
+ interface KnowledgeDiscoveryDispatcher {
156
+ dispatch(tasks: DiscoveryTask[], options?: {
157
+ concurrency?: number;
158
+ signal?: AbortSignal;
159
+ }): Promise<DiscoveryResult[]>;
160
+ }
161
+ declare function createLocalDiscoveryDispatcher(worker: KnowledgeDiscoveryWorker): KnowledgeDiscoveryDispatcher;
162
+
163
+ interface KnowledgeReadinessSpec {
164
+ id: string;
165
+ description: string;
166
+ query: string;
167
+ requiredFor: string[];
168
+ category: KnowledgeRequirementCategory;
169
+ acquisitionMode: KnowledgeAcquisitionMode;
170
+ importance: KnowledgeImportance;
171
+ freshness: KnowledgeFreshness;
172
+ sensitivity: KnowledgeSensitivity;
173
+ confidenceNeeded: number;
174
+ fallbackPolicy?: KnowledgeRequirement['fallbackPolicy'];
175
+ minSources?: number;
176
+ minHits?: number;
177
+ metadata?: Record<string, unknown>;
178
+ }
179
+ /**
180
+ * Defaults applied by `defineReadinessSpec` when the caller omits the field.
181
+ *
182
+ * These are deliberately conservative: a domain-specific topic that an agent
183
+ * needs grounded to a high-confidence threshold from at least one authoritative
184
+ * source. Override any field to specialise (e.g. `freshness: 'daily'` for a
185
+ * topic that must reflect today's regulatory state).
186
+ */
187
+ declare const READINESS_SPEC_DEFAULTS: {
188
+ readonly category: "domain_specific";
189
+ readonly acquisitionMode: "search_web";
190
+ readonly importance: "high";
191
+ readonly freshness: "monthly";
192
+ readonly sensitivity: "public";
193
+ readonly confidenceNeeded: 0.7;
194
+ readonly minSources: 1;
195
+ readonly minHits: 2;
196
+ };
197
+ /**
198
+ * Inputs accepted by `defineReadinessSpec`. The four fields the caller cannot
199
+ * sanely default (id, description, query, requiredFor) are required; everything
200
+ * else is optional and pulls from `READINESS_SPEC_DEFAULTS`.
201
+ */
202
+ type DefineReadinessSpecInput = Pick<KnowledgeReadinessSpec, 'id' | 'description' | 'query' | 'requiredFor'> & Partial<Omit<KnowledgeReadinessSpec, 'id' | 'description' | 'query' | 'requiredFor'>>;
203
+ /**
204
+ * Builder that returns a fully-typed `KnowledgeReadinessSpec` from a slim input.
205
+ *
206
+ * Motivation: `KnowledgeReadinessSpec` has eleven required fields. Most of them
207
+ * (category, acquisition mode, importance, freshness, sensitivity, confidence
208
+ * threshold, source/hit minima) have a clear default for domain-specific KB
209
+ * topics — agents end up copy-pasting the same boilerplate across every spec.
210
+ * This helper collapses that boilerplate while keeping every field overridable.
211
+ *
212
+ * @example
213
+ * defineReadinessSpec({
214
+ * id: 'coop/intent-grounding',
215
+ * description: 'Required grounding for coop pack intent stage',
216
+ * query: 'flock size space ventilation predator',
217
+ * requiredFor: ['IntentIntakeAgent', 'requirements'],
218
+ * })
219
+ *
220
+ * @example // override defaults where the topic demands it
221
+ * defineReadinessSpec({
222
+ * id: 'medical/dosing',
223
+ * description: 'Dosing guidance for compounding pharmacy',
224
+ * query: 'compounding dose schedule',
225
+ * requiredFor: ['DosingAgent'],
226
+ * importance: 'blocking',
227
+ * freshness: 'daily',
228
+ * sensitivity: 'private',
229
+ * confidenceNeeded: 0.95,
230
+ * minSources: 3,
231
+ * })
232
+ */
233
+ declare function defineReadinessSpec(input: DefineReadinessSpecInput): KnowledgeReadinessSpec;
234
+ interface BuildEvalKnowledgeBundleOptions {
235
+ taskId: string;
236
+ index: KnowledgeIndex;
237
+ specs: KnowledgeReadinessSpec[];
238
+ userAnswers?: Record<string, string>;
239
+ searchLimit?: number;
240
+ metadata?: Record<string, unknown>;
241
+ now?: Date;
242
+ }
243
+ interface EvalKnowledgeBundleBuildResult {
244
+ bundle: KnowledgeBundle;
245
+ report: KnowledgeReadinessReport;
246
+ requirements: KnowledgeRequirement[];
247
+ searchResultsByRequirement: Record<string, KnowledgeSearchResult[]>;
248
+ questions: UserQuestion[];
249
+ acquisitionPlans: DataAcquisitionPlan[];
250
+ }
251
+ declare function buildEvalKnowledgeBundle(options: BuildEvalKnowledgeBundleOptions): EvalKnowledgeBundleBuildResult;
252
+
253
+ interface KnowledgeEventQuery {
254
+ type?: KnowledgeEventType;
255
+ target?: string;
256
+ limit?: number;
257
+ }
258
+ declare function createKnowledgeEvent(input: {
259
+ type: KnowledgeEventType;
260
+ actor?: string;
261
+ target?: string;
262
+ metadata?: Record<string, unknown>;
263
+ now?: () => Date;
264
+ }): KnowledgeEvent;
265
+
266
+ /**
267
+ * Knowledge freshness store: tracks when each `(workspaceId, sourceId)` pair
268
+ * was last successfully refreshed, and reports staleness against a TTL.
269
+ *
270
+ * The contract is intentionally minimal — just enough to drive a cron loop:
271
+ *
272
+ * ```ts
273
+ * const store = createFileSystemFreshnessStore({ root: '.agent-knowledge' })
274
+ * for (const source of sources) {
275
+ * if (await store.stale({ workspaceId, sourceId: source.id, ttlMs: DAY })) {
276
+ * const fragments = await source.fetch({ cacheDir })
277
+ * await persistFragments(fragments)
278
+ * await store.mark({ workspaceId, sourceId: source.id, when: new Date() })
279
+ * }
280
+ * }
281
+ * ```
282
+ *
283
+ * Per-tenant isolation is enforced by `workspaceId` keying — there is no
284
+ * global mutable state across workspaces.
285
+ *
286
+ * Two adapters ship in-package:
287
+ *
288
+ * - `createFileSystemFreshnessStore` — JSON file under the knowledge root,
289
+ * mirrors the layout convention already used by `sources.json`.
290
+ * - `createD1FreshnessStoreStub` — adapter scaffold for Cloudflare D1 /
291
+ * Postgres. Production consumers should implement the `D1Adapter`
292
+ * interface inside their own app; this stub exists to anchor the shape.
293
+ *
294
+ * @stable contract — interface is frozen at 0.x within this major.
295
+ * @stable filesystem adapter
296
+ * @experimental D1 stub — interface will evolve as real consumers wire it.
297
+ */
298
+ /** Identity for one freshness record. */
299
+ interface FreshnessKey {
300
+ workspaceId: string;
301
+ sourceId: string;
302
+ }
303
+ /** TTL bound for staleness checks. */
304
+ interface FreshnessTtl extends FreshnessKey {
305
+ /** Milliseconds — `Date.now() - last() > ttlMs` ⇒ stale. */
306
+ ttlMs: number;
307
+ /** Injected clock for deterministic tests; defaults to system time. */
308
+ now?: Date;
309
+ }
310
+ /** Mark argument. */
311
+ interface FreshnessMark extends FreshnessKey {
312
+ when: Date;
313
+ /** Optional content hash captured at refresh time; aids debugging. */
314
+ contentHash?: string;
315
+ }
316
+ interface KnowledgeFreshnessStore {
317
+ /** Last refresh time, or null if never refreshed. */
318
+ last(key: FreshnessKey): Promise<Date | null>;
319
+ /** Record a successful refresh. */
320
+ mark(input: FreshnessMark): Promise<void>;
321
+ /** True iff `last(key)` is null or older than `ttlMs`. */
322
+ stale(input: FreshnessTtl): Promise<boolean>;
323
+ /** All records for a workspace — useful for dashboards / debugging. */
324
+ list(workspaceId: string): Promise<FreshnessRecord[]>;
325
+ }
326
+ interface FreshnessRecord {
327
+ workspaceId: string;
328
+ sourceId: string;
329
+ lastRefreshedAt: string;
330
+ contentHash?: string;
331
+ }
332
+ interface FileSystemFreshnessStoreOptions {
333
+ /**
334
+ * Knowledge root. The store writes to `<root>/.agent-knowledge/freshness.json`,
335
+ * mirroring the convention used by `sources.json`.
336
+ */
337
+ root: string;
338
+ }
339
+ /**
340
+ * Filesystem-backed implementation. Single JSON file per knowledge root,
341
+ * indexed by `${workspaceId}::${sourceId}`. Reads parse on every call —
342
+ * cron tick rate is well below the cost of one JSON parse.
343
+ *
344
+ * Concurrent writes from a single process serialize through `writeQueue`.
345
+ * Cross-process concurrency is undefined; the consuming app should run the
346
+ * cron in a single worker.
347
+ */
348
+ declare function createFileSystemFreshnessStore(options: FileSystemFreshnessStoreOptions): KnowledgeFreshnessStore;
349
+ /**
350
+ * D1 / Postgres adapter scaffold. Production consumers implement
351
+ * `D1Adapter` against their own driver (better-sqlite3, postgres,
352
+ * Cloudflare D1 binding, ...). This factory wires the adapter to the
353
+ * `KnowledgeFreshnessStore` interface.
354
+ *
355
+ * The expected schema:
356
+ *
357
+ * ```sql
358
+ * CREATE TABLE knowledge_freshness (
359
+ * workspace_id TEXT NOT NULL,
360
+ * source_id TEXT NOT NULL,
361
+ * last_refreshed_at TEXT NOT NULL,
362
+ * content_hash TEXT,
363
+ * PRIMARY KEY (workspace_id, source_id)
364
+ * );
365
+ * ```
366
+ */
367
+ interface D1Adapter {
368
+ get(workspaceId: string, sourceId: string): Promise<FreshnessRecord | null>;
369
+ upsert(record: FreshnessRecord): Promise<void>;
370
+ listByWorkspace(workspaceId: string): Promise<FreshnessRecord[]>;
371
+ }
372
+ declare function createD1FreshnessStoreStub(adapter: D1Adapter): KnowledgeFreshnessStore;
373
+
374
+ interface ParsedFrontmatter {
375
+ frontmatter: Record<string, unknown>;
376
+ body: string;
377
+ }
378
+ declare function parseFrontmatter(content: string): ParsedFrontmatter;
379
+ declare function formatFrontmatter(frontmatter: Record<string, unknown>, body: string): string;
380
+
381
+ declare function buildKnowledgeGraph(pages: KnowledgePage[]): KnowledgeGraph;
382
+
383
+ declare function sha256(text: string): string;
384
+ declare function slugify(input: string): string;
385
+ declare function stableId(prefix: string, content: string): string;
386
+
387
+ declare function buildKnowledgeIndex(root: string): Promise<KnowledgeIndex>;
388
+ declare function writeKnowledgeIndex(root: string): Promise<KnowledgeIndex>;
389
+
390
+ interface KnowledgeInspection {
391
+ pageCount: number;
392
+ sourceCount: number;
393
+ expiredSourceCount: number;
394
+ staleSourceCount: number;
395
+ edgeCount: number;
396
+ findingCount: number;
397
+ blockingFindingCount: number;
398
+ topPages: Array<{
399
+ path: string;
400
+ title: string;
401
+ degree: number;
402
+ sources: number;
403
+ }>;
404
+ sourceFreshness: SourceFreshnessInspection[];
405
+ findings: KnowledgeLintFinding[];
406
+ }
407
+ interface SourceFreshnessInspection {
408
+ id: string;
409
+ title?: string;
410
+ uri: string;
411
+ status: 'fresh' | 'expired' | 'unknown';
412
+ validUntil?: string;
413
+ lastVerifiedAt?: string;
414
+ }
415
+ declare function inspectKnowledgeIndex(index: KnowledgeIndex, options?: {
416
+ now?: Date;
417
+ }): KnowledgeInspection;
418
+ interface KnowledgeExplanation {
419
+ target: string;
420
+ page?: KnowledgePage;
421
+ sources: Array<{
422
+ id: string;
423
+ title?: string;
424
+ uri: string;
425
+ }>;
426
+ links: string[];
427
+ inbound: string[];
428
+ related: Array<{
429
+ path: string;
430
+ title: string;
431
+ score: number;
432
+ }>;
433
+ }
434
+ declare function explainKnowledgeTarget(index: KnowledgeIndex, target: string): KnowledgeExplanation;
435
+
436
+ interface KbStore {
437
+ putSource(source: SourceRecord): Promise<void>;
438
+ getSource(id: string): Promise<SourceRecord | null>;
439
+ listSources(): Promise<SourceRecord[]>;
440
+ putPage(page: KnowledgePage): Promise<void>;
441
+ getPage(idOrPath: string): Promise<KnowledgePage | null>;
442
+ listPages(): Promise<KnowledgePage[]>;
443
+ putIndex(index: KnowledgeIndex): Promise<void>;
444
+ getIndex(): Promise<KnowledgeIndex | null>;
445
+ putEvent(event: KnowledgeEvent): Promise<void>;
446
+ listEvents(query?: KnowledgeEventQuery): Promise<KnowledgeEvent[]>;
447
+ }
448
+ declare class MemoryKbStore implements KbStore {
449
+ private readonly sources;
450
+ private readonly pages;
451
+ private readonly events;
452
+ private index;
453
+ putSource(source: SourceRecord): Promise<void>;
454
+ getSource(id: string): Promise<SourceRecord | null>;
455
+ listSources(): Promise<SourceRecord[]>;
456
+ putPage(page: KnowledgePage): Promise<void>;
457
+ getPage(idOrPath: string): Promise<KnowledgePage | null>;
458
+ listPages(): Promise<KnowledgePage[]>;
459
+ putIndex(index: KnowledgeIndex): Promise<void>;
460
+ getIndex(): Promise<KnowledgeIndex | null>;
461
+ putEvent(event: KnowledgeEvent): Promise<void>;
462
+ listEvents(query?: KnowledgeEventQuery): Promise<KnowledgeEvent[]>;
463
+ }
464
+ declare class FileSystemKbStore extends MemoryKbStore {
465
+ private readonly dir;
466
+ constructor(dir: string);
467
+ putIndex(index: KnowledgeIndex): Promise<void>;
468
+ getIndex(): Promise<KnowledgeIndex | null>;
469
+ putEvent(event: KnowledgeEvent): Promise<void>;
470
+ }
471
+
472
+ declare function lintKnowledgeIndex(index: KnowledgeIndex): KnowledgeLintFinding[];
473
+
474
+ type KnowledgeBaseVariant = MultiShotVariant<KnowledgeBaseCandidate>;
475
+ interface KnowledgeOptimizationConfig extends Omit<MultiShotOptimizationConfig<KnowledgeBaseCandidate>, 'runner' | 'scorer' | 'mutateAdapter' | 'target'> {
476
+ target?: string;
477
+ runner: MultiShotRunner<KnowledgeBaseCandidate>;
478
+ scorer: MultiShotScorer<KnowledgeBaseCandidate>;
479
+ mutateAdapter: MultiShotMutateAdapter<KnowledgeBaseCandidate>;
480
+ }
481
+ declare function runKnowledgeBaseOptimization(config: KnowledgeOptimizationConfig): Promise<MultiShotOptimizationResult<KnowledgeBaseCandidate>>;
482
+ declare function knowledgeVariantFromCandidate(candidate: KnowledgeBaseCandidate, options?: {
483
+ id?: string;
484
+ label?: string;
485
+ generation?: number;
486
+ }): KnowledgeBaseVariant;
487
+
488
+ interface ApplyWriteBlocksResult {
489
+ written: string[];
490
+ warnings: string[];
491
+ }
492
+ declare function applyKnowledgeWriteBlocks(root: string, proposalText: string): Promise<ApplyWriteBlocksResult>;
493
+ declare function applyKnowledgeWriteBlocksFile(root: string, proposalPath: string): Promise<ApplyWriteBlocksResult>;
494
+
495
+ /**
496
+ * Bridge from `AnalystFinding` (agent-eval) to knowledge proposals.
497
+ *
498
+ * Closes the failure → wiki side of the recursive-self-improvement
499
+ * loop: a knowledge-gap or knowledge-poisoning finding produced by an
500
+ * analyst becomes a concrete proposal an operator (or auto-merge bot)
501
+ * can review and apply. The bridge is intentionally lossless on the
502
+ * fail-loud side — a finding the parser can't classify returns a
503
+ * `KnowledgeProposalParseError` rather than a silent skip, so the
504
+ * loop never accepts an underspecified edit.
505
+ *
506
+ * Subject grammar this bridge understands (analyst-side convention,
507
+ * stamped in the kind prompts):
508
+ *
509
+ * agent-knowledge:wiki:<page-slug> create / update page
510
+ * agent-knowledge:wiki:<page-slug>#<heading> insert section under page
511
+ * agent-knowledge:claim:<topic> draft claim row
512
+ * agent-knowledge:raw:<source-id> lift raw → curated
513
+ * agent-knowledge:stale:<page-slug> mark page superseded
514
+ *
515
+ * Anything else (websearch:outdated:*, tool-doc:*, system-prompt:*,
516
+ * memory:*) is NOT a knowledge-base concern and returns `null` so the
517
+ * loop's improvement-applier handles it.
518
+ */
519
+
520
+ interface KnowledgeProposal {
521
+ /**
522
+ * Stable id derived from the finding so cross-run diffs share an
523
+ * identity. Re-proposing the same finding produces the same id.
524
+ */
525
+ id: string;
526
+ /** The finding that generated this proposal — useful for audit + revert. */
527
+ sourceFindingId: string;
528
+ /** What the proposal does. */
529
+ kind: 'create-page' | 'update-page' | 'append-section' | 'create-claim' | 'lift-raw' | 'mark-stale';
530
+ /** Locus on disk (page slug or claim topic). */
531
+ locus: string;
532
+ /**
533
+ * Page write blocks the standard `applyKnowledgeWriteBlocks` consumer
534
+ * accepts. Empty for proposals that don't change page text (e.g.
535
+ * `create-claim` produces a `claim` field instead).
536
+ */
537
+ writeBlocks: KnowledgeWriteBlock[];
538
+ /**
539
+ * Granular claim draft for proposals whose unit-of-change is a claim
540
+ * row rather than a whole page. `status: 'draft'` until reviewed.
541
+ */
542
+ claim?: KnowledgeClaim;
543
+ /** Per-proposal metadata: severity, confidence, source span. */
544
+ metadata: {
545
+ severity: AnalystSeverity;
546
+ confidence: number;
547
+ evidence_uri?: string;
548
+ analyst_id: string;
549
+ };
550
+ }
551
+ declare class KnowledgeProposalParseError extends Error {
552
+ readonly findingId: string;
553
+ readonly subject: string;
554
+ constructor(findingId: string, subject: string, message: string);
555
+ }
556
+ /**
557
+ * Convert one `AnalystFinding` into a knowledge proposal. Returns
558
+ * `null` when the finding's locus isn't a knowledge-base concern
559
+ * (`websearch:outdated:*`, `tool-doc:*`, `system-prompt:*`,
560
+ * `memory:*`, missing subject). Throws when the locus IS a
561
+ * knowledge-base concern but is malformed — that's a bug in the
562
+ * analyst prompt and should fail loud.
563
+ *
564
+ * Caller convention: feed the function the analyst's full findings
565
+ * list and filter out the `null`s; the orchestrator passes the
566
+ * remaining proposals to the existing review / apply pipeline.
567
+ */
568
+ declare function proposeFromFinding(finding: AnalystFinding): KnowledgeProposal | null;
569
+ /**
570
+ * Plural convenience: filter + map across an entire findings batch
571
+ * with one call. Parse errors collect into `errors[]`; the loop
572
+ * decides per-error whether to abort or continue.
573
+ */
574
+ interface ProposeFromFindingsResult {
575
+ proposals: KnowledgeProposal[];
576
+ skipped: number;
577
+ errors: KnowledgeProposalParseError[];
578
+ }
579
+ declare function proposeFromFindings(findings: ReadonlyArray<AnalystFinding>): ProposeFromFindingsResult;
580
+
581
+ interface KnowledgeReleaseReport {
582
+ release: KnowledgeRelease;
583
+ scorecard: ReleaseConfidenceScorecard;
584
+ candidateRuns: RunRecord[];
585
+ baselineRuns: RunRecord[];
586
+ }
587
+ declare function knowledgeReleaseReportFromOptimization(result: MultiShotOptimizationResult<KnowledgeBaseCandidate>, options?: {
588
+ runRecords?: RunRecord[];
589
+ createdAt?: string;
590
+ minScore?: number;
591
+ }): KnowledgeReleaseReport;
592
+
593
+ interface AddSourceOptions {
594
+ copyIntoRaw?: boolean;
595
+ adapters?: SourceAdapter[];
596
+ now?: () => Date;
597
+ }
598
+ interface AddSourceTextInput {
599
+ uri: string;
600
+ text: string;
601
+ title?: string;
602
+ mediaType?: string;
603
+ validUntil?: string;
604
+ lastVerifiedAt?: string;
605
+ metadata?: Record<string, unknown>;
606
+ }
607
+ declare function loadSourceRegistry(root: string): Promise<SourceRegistry>;
608
+ declare function writeSourceRegistry(root: string, registry: SourceRegistry): Promise<void>;
609
+ declare function addSourcePath(root: string, sourcePath: string, options?: AddSourceOptions): Promise<SourceRecord[]>;
610
+ declare function addSourceText(root: string, input: AddSourceTextInput, options?: Pick<AddSourceOptions, 'adapters' | 'now'>): Promise<SourceRecord>;
611
+ declare function sourceRegistryPath(root: string): string;
612
+
613
+ interface ValidateKnowledgeOptions {
614
+ strict?: boolean;
615
+ }
616
+ interface ValidateKnowledgeResult {
617
+ ok: boolean;
618
+ findings: KnowledgeLintFinding[];
619
+ }
620
+ declare function validateKnowledgeIndex(index: KnowledgeIndex, options?: ValidateKnowledgeOptions): ValidateKnowledgeResult;
621
+
622
+ interface KnowledgeResearchLoopContext {
623
+ root: string;
624
+ goal: string;
625
+ iteration: number;
626
+ index: KnowledgeIndex;
627
+ lintFindings: KnowledgeLintFinding[];
628
+ validation: ValidateKnowledgeResult;
629
+ readiness?: EvalKnowledgeBundleBuildResult;
630
+ previousSteps: KnowledgeResearchLoopStep[];
631
+ signal?: AbortSignal;
632
+ }
633
+ interface KnowledgeResearchLoopDecision {
634
+ /**
635
+ * Free-form notes from the researcher. Keep this human-readable; products can
636
+ * store it as the research transcript.
637
+ */
638
+ notes?: string;
639
+ /**
640
+ * Local files to register as immutable sources before applying proposals.
641
+ */
642
+ sourcePaths?: string[];
643
+ /**
644
+ * Textual source artifacts discovered by an agent, browser worker, connector,
645
+ * or deep-research process.
646
+ */
647
+ sourceTexts?: AddSourceTextInput[];
648
+ /**
649
+ * Safe write protocol text. The loop parses and applies only accepted
650
+ * `---FILE: knowledge/...---` blocks.
651
+ */
652
+ proposalText?: string;
653
+ /**
654
+ * The researcher decides when the wiki is good enough. The loop deliberately
655
+ * does not encode a domain-specific definition of "done".
656
+ */
657
+ done?: boolean;
658
+ metadata?: Record<string, unknown>;
659
+ }
660
+ interface KnowledgeResearchLoopStep {
661
+ iteration: number;
662
+ notes?: string;
663
+ addedSources: SourceRecord[];
664
+ applied?: ApplyWriteBlocksResult;
665
+ lintFindings: KnowledgeLintFinding[];
666
+ validation: ValidateKnowledgeResult;
667
+ readiness?: EvalKnowledgeBundleBuildResult;
668
+ event: KnowledgeEvent;
669
+ done: boolean;
670
+ metadata?: Record<string, unknown>;
671
+ }
672
+ interface RunKnowledgeResearchLoopOptions {
673
+ root: string;
674
+ goal: string;
675
+ maxIterations?: number;
676
+ actor?: string;
677
+ strict?: ValidateKnowledgeOptions['strict'];
678
+ readinessSpecs?: KnowledgeReadinessSpec[];
679
+ readinessTaskId?: string;
680
+ readiness?: Omit<BuildEvalKnowledgeBundleOptions, 'taskId' | 'index' | 'specs'>;
681
+ sourceOptions?: Pick<AddSourceOptions, 'adapters' | 'now'>;
682
+ signal?: AbortSignal;
683
+ step(context: KnowledgeResearchLoopContext): Promise<KnowledgeResearchLoopDecision> | KnowledgeResearchLoopDecision;
684
+ onStep?: (step: KnowledgeResearchLoopStep) => Promise<void> | void;
685
+ }
686
+ interface KnowledgeResearchLoopResult {
687
+ root: string;
688
+ goal: string;
689
+ iterations: number;
690
+ done: boolean;
691
+ index: KnowledgeIndex;
692
+ lintFindings: KnowledgeLintFinding[];
693
+ validation: ValidateKnowledgeResult;
694
+ readiness?: EvalKnowledgeBundleBuildResult;
695
+ steps: KnowledgeResearchLoopStep[];
696
+ }
697
+ type KnowledgeControlLoopState = KnowledgeResearchLoopContext;
698
+ type KnowledgeControlLoopAction = KnowledgeResearchLoopDecision;
699
+ type KnowledgeControlLoopActionResult = KnowledgeResearchLoopStep;
700
+ interface KnowledgeControlLoopAdapterOptions {
701
+ root: string;
702
+ goal: string;
703
+ actor?: string;
704
+ strict?: ValidateKnowledgeOptions['strict'];
705
+ readinessSpecs?: KnowledgeReadinessSpec[];
706
+ readinessTaskId?: string;
707
+ readiness?: Omit<BuildEvalKnowledgeBundleOptions, 'taskId' | 'index' | 'specs'>;
708
+ sourceOptions?: Pick<AddSourceOptions, 'adapters' | 'now'>;
48
709
  }
49
- declare function applyKnowledgeWriteBlocks(root: string, proposalText: string): Promise<ApplyWriteBlocksResult>;
50
- declare function applyKnowledgeWriteBlocksFile(root: string, proposalPath: string): Promise<ApplyWriteBlocksResult>;
710
+ type KnowledgeControlLoopAdapter = Pick<ControlRuntimeConfig<KnowledgeControlLoopState, KnowledgeControlLoopAction, KnowledgeControlLoopActionResult, ControlEvalResult>, 'intent' | 'observe' | 'validate' | 'act' | 'shouldStop'>;
711
+ /**
712
+ * Adapter for running knowledge growth through `agent-eval`'s generic control
713
+ * runtime. The caller still owns `decide`: that can be a proposer agent,
714
+ * reviewer agent, deterministic policy, or a composition of all three.
715
+ */
716
+ declare function createKnowledgeControlLoopAdapter(options: KnowledgeControlLoopAdapterOptions): KnowledgeControlLoopAdapter;
717
+ declare function runKnowledgeResearchLoop(options: RunKnowledgeResearchLoopOptions): Promise<KnowledgeResearchLoopResult>;
51
718
 
52
719
  declare const SourceAnchorSchema: z.ZodObject<{
53
720
  id: z.ZodString;
@@ -219,104 +886,9 @@ declare const KnowledgeBaseCandidateSchema: z.ZodObject<{
219
886
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
220
887
  }, z.core.$strip>;
221
888
 
222
- interface KnowledgeEventQuery {
223
- type?: KnowledgeEventType;
224
- target?: string;
225
- limit?: number;
226
- }
227
- declare function createKnowledgeEvent(input: {
228
- type: KnowledgeEventType;
229
- actor?: string;
230
- target?: string;
231
- metadata?: Record<string, unknown>;
232
- now?: () => Date;
233
- }): KnowledgeEvent;
234
-
235
- interface KbStore {
236
- putSource(source: SourceRecord): Promise<void>;
237
- getSource(id: string): Promise<SourceRecord | null>;
238
- listSources(): Promise<SourceRecord[]>;
239
- putPage(page: KnowledgePage): Promise<void>;
240
- getPage(idOrPath: string): Promise<KnowledgePage | null>;
241
- listPages(): Promise<KnowledgePage[]>;
242
- putIndex(index: KnowledgeIndex): Promise<void>;
243
- getIndex(): Promise<KnowledgeIndex | null>;
244
- putEvent(event: KnowledgeEvent): Promise<void>;
245
- listEvents(query?: KnowledgeEventQuery): Promise<KnowledgeEvent[]>;
246
- }
247
- declare class MemoryKbStore implements KbStore {
248
- private readonly sources;
249
- private readonly pages;
250
- private readonly events;
251
- private index;
252
- putSource(source: SourceRecord): Promise<void>;
253
- getSource(id: string): Promise<SourceRecord | null>;
254
- listSources(): Promise<SourceRecord[]>;
255
- putPage(page: KnowledgePage): Promise<void>;
256
- getPage(idOrPath: string): Promise<KnowledgePage | null>;
257
- listPages(): Promise<KnowledgePage[]>;
258
- putIndex(index: KnowledgeIndex): Promise<void>;
259
- getIndex(): Promise<KnowledgeIndex | null>;
260
- putEvent(event: KnowledgeEvent): Promise<void>;
261
- listEvents(query?: KnowledgeEventQuery): Promise<KnowledgeEvent[]>;
262
- }
263
- declare class FileSystemKbStore extends MemoryKbStore {
264
- private readonly dir;
265
- constructor(dir: string);
266
- putIndex(index: KnowledgeIndex): Promise<void>;
267
- getIndex(): Promise<KnowledgeIndex | null>;
268
- putEvent(event: KnowledgeEvent): Promise<void>;
269
- }
270
-
271
- interface DiscoveryTask {
272
- id: string;
273
- goal: string;
274
- query?: string;
275
- sourceHints?: string[];
276
- metadata?: Record<string, unknown>;
277
- }
278
- interface DiscoveryResult {
279
- taskId: string;
280
- summary: string;
281
- sourceUris?: string[];
282
- claims?: Array<{
283
- text: string;
284
- sourceUri?: string;
285
- confidence?: number;
286
- }>;
287
- followUpTasks?: DiscoveryTask[];
288
- metadata?: Record<string, unknown>;
289
- }
290
- interface KnowledgeDiscoveryWorker {
291
- run(task: DiscoveryTask, signal?: AbortSignal): Promise<DiscoveryResult> | DiscoveryResult;
292
- }
293
- interface KnowledgeDiscoveryDispatcher {
294
- dispatch(tasks: DiscoveryTask[], options?: {
295
- concurrency?: number;
296
- signal?: AbortSignal;
297
- }): Promise<DiscoveryResult[]>;
298
- }
299
- declare function createLocalDiscoveryDispatcher(worker: KnowledgeDiscoveryWorker): KnowledgeDiscoveryDispatcher;
300
-
301
- interface ChunkingOptions {
302
- targetChars: number;
303
- maxChars: number;
304
- minChars: number;
305
- overlapChars: number;
306
- }
307
- interface KnowledgeChunk {
308
- index: number;
309
- text: string;
310
- headingPath: string;
311
- charStart: number;
312
- charEnd: number;
313
- oversized: boolean;
314
- }
315
- declare function chunkMarkdown(content: string, options?: Partial<ChunkingOptions>): KnowledgeChunk[];
316
- declare function stripFrontmatter(content: string): {
317
- body: string;
318
- bodyOffset: number;
319
- };
889
+ declare function searchKnowledge(index: KnowledgeIndex, query: string, limit?: number): KnowledgeSearchResult[];
890
+ declare function tokenizeQuery(query: string): string[];
891
+ declare function reciprocalRankFusion(rankLists: string[][], k?: number): Map<string, number>;
320
892
 
321
893
  interface KnowledgeLayout {
322
894
  root: string;
@@ -349,141 +921,11 @@ declare function initKnowledgeBase(root: string): Promise<KnowledgeLayout>;
349
921
  declare function loadKnowledgePages(root: string): Promise<KnowledgePage[]>;
350
922
  declare function writeJson(path: string, value: unknown): Promise<void>;
351
923
 
352
- interface AddSourceOptions {
353
- copyIntoRaw?: boolean;
354
- adapters?: SourceAdapter[];
355
- now?: () => Date;
356
- }
357
- declare function loadSourceRegistry(root: string): Promise<SourceRegistry>;
358
- declare function writeSourceRegistry(root: string, registry: SourceRegistry): Promise<void>;
359
- declare function addSourcePath(root: string, sourcePath: string, options?: AddSourceOptions): Promise<SourceRecord[]>;
360
- declare function sourceRegistryPath(root: string): string;
361
-
362
- declare function buildKnowledgeGraph(pages: KnowledgePage[]): KnowledgeGraph;
363
-
364
- declare function searchKnowledge(index: KnowledgeIndex, query: string, limit?: number): KnowledgeSearchResult[];
365
- declare function tokenizeQuery(query: string): string[];
366
- declare function reciprocalRankFusion(rankLists: string[][], k?: number): Map<string, number>;
367
-
368
- declare function buildKnowledgeIndex(root: string): Promise<KnowledgeIndex>;
369
- declare function writeKnowledgeIndex(root: string): Promise<KnowledgeIndex>;
370
-
371
- declare function lintKnowledgeIndex(index: KnowledgeIndex): KnowledgeLintFinding[];
372
-
373
- interface KnowledgeInspection {
374
- pageCount: number;
375
- sourceCount: number;
376
- expiredSourceCount: number;
377
- staleSourceCount: number;
378
- edgeCount: number;
379
- findingCount: number;
380
- blockingFindingCount: number;
381
- topPages: Array<{
382
- path: string;
383
- title: string;
384
- degree: number;
385
- sources: number;
386
- }>;
387
- sourceFreshness: SourceFreshnessInspection[];
388
- findings: KnowledgeLintFinding[];
389
- }
390
- interface SourceFreshnessInspection {
391
- id: string;
392
- title?: string;
393
- uri: string;
394
- status: 'fresh' | 'expired' | 'unknown';
395
- validUntil?: string;
396
- lastVerifiedAt?: string;
397
- }
398
- declare function inspectKnowledgeIndex(index: KnowledgeIndex, options?: {
399
- now?: Date;
400
- }): KnowledgeInspection;
401
- interface KnowledgeExplanation {
402
- target: string;
403
- page?: KnowledgePage;
404
- sources: Array<{
405
- id: string;
406
- title?: string;
407
- uri: string;
408
- }>;
409
- links: string[];
410
- inbound: string[];
411
- related: Array<{
412
- path: string;
413
- title: string;
414
- score: number;
415
- }>;
416
- }
417
- declare function explainKnowledgeTarget(index: KnowledgeIndex, target: string): KnowledgeExplanation;
418
-
419
- interface ValidateKnowledgeOptions {
420
- strict?: boolean;
421
- }
422
- interface ValidateKnowledgeResult {
423
- ok: boolean;
424
- findings: KnowledgeLintFinding[];
425
- }
426
- declare function validateKnowledgeIndex(index: KnowledgeIndex, options?: ValidateKnowledgeOptions): ValidateKnowledgeResult;
427
-
428
- type KnowledgeBaseVariant = MultiShotVariant<KnowledgeBaseCandidate>;
429
- interface KnowledgeOptimizationConfig extends Omit<MultiShotOptimizationConfig<KnowledgeBaseCandidate>, 'runner' | 'scorer' | 'mutateAdapter' | 'target'> {
430
- target?: string;
431
- runner: MultiShotRunner<KnowledgeBaseCandidate>;
432
- scorer: MultiShotScorer<KnowledgeBaseCandidate>;
433
- mutateAdapter: MultiShotMutateAdapter<KnowledgeBaseCandidate>;
434
- }
435
- declare function runKnowledgeBaseOptimization(config: KnowledgeOptimizationConfig): Promise<MultiShotOptimizationResult<KnowledgeBaseCandidate>>;
436
- declare function knowledgeVariantFromCandidate(candidate: KnowledgeBaseCandidate, options?: {
437
- id?: string;
438
- label?: string;
439
- generation?: number;
440
- }): KnowledgeBaseVariant;
441
-
442
- interface KnowledgeReleaseReport {
443
- release: KnowledgeRelease;
444
- scorecard: ReleaseConfidenceScorecard;
445
- candidateRuns: RunRecord[];
446
- baselineRuns: RunRecord[];
447
- }
448
- declare function knowledgeReleaseReportFromOptimization(result: MultiShotOptimizationResult<KnowledgeBaseCandidate>, options?: {
449
- runRecords?: RunRecord[];
450
- createdAt?: string;
451
- minScore?: number;
452
- }): KnowledgeReleaseReport;
924
+ declare const WIKILINK_REGEX: RegExp;
925
+ declare function extractWikilinks(content: string): string[];
926
+ declare function normalizeLinkTarget(target: string): string;
453
927
 
454
- interface KnowledgeReadinessSpec {
455
- id: string;
456
- description: string;
457
- query: string;
458
- requiredFor: string[];
459
- category: KnowledgeRequirementCategory;
460
- acquisitionMode: KnowledgeAcquisitionMode;
461
- importance: KnowledgeImportance;
462
- freshness: KnowledgeFreshness;
463
- sensitivity: KnowledgeSensitivity;
464
- confidenceNeeded: number;
465
- fallbackPolicy?: KnowledgeRequirement['fallbackPolicy'];
466
- minSources?: number;
467
- minHits?: number;
468
- metadata?: Record<string, unknown>;
469
- }
470
- interface BuildEvalKnowledgeBundleOptions {
471
- taskId: string;
472
- index: KnowledgeIndex;
473
- specs: KnowledgeReadinessSpec[];
474
- userAnswers?: Record<string, string>;
475
- searchLimit?: number;
476
- metadata?: Record<string, unknown>;
477
- now?: Date;
478
- }
479
- interface EvalKnowledgeBundleBuildResult {
480
- bundle: KnowledgeBundle;
481
- report: KnowledgeReadinessReport;
482
- requirements: KnowledgeRequirement[];
483
- searchResultsByRequirement: Record<string, KnowledgeSearchResult[]>;
484
- questions: UserQuestion[];
485
- acquisitionPlans: DataAcquisitionPlan[];
486
- }
487
- declare function buildEvalKnowledgeBundle(options: BuildEvalKnowledgeBundleOptions): EvalKnowledgeBundleBuildResult;
928
+ declare function isSafeKnowledgePath(path: string, allowedPrefixes?: string[]): boolean;
929
+ declare function parseKnowledgeWriteBlocks(text: string, allowedPrefixes?: string[]): KnowledgeWriteParseResult;
488
930
 
489
- export { type AddSourceOptions, type ApplyWriteBlocksResult, type BuildEvalKnowledgeBundleOptions, type ChunkingOptions, type DiscoveryResult, type DiscoveryTask, type EvalKnowledgeBundleBuildResult, FileSystemKbStore, type KbStore, KnowledgeBaseCandidate, KnowledgeBaseCandidateSchema, type KnowledgeBaseVariant, type KnowledgeChunk, type KnowledgeDiscoveryDispatcher, type KnowledgeDiscoveryWorker, KnowledgeEvent, type KnowledgeEventQuery, KnowledgeEventSchema, KnowledgeEventType, type KnowledgeExplanation, KnowledgeGraph, KnowledgeGraphEdgeSchema, KnowledgeGraphNodeSchema, KnowledgeIndex, KnowledgeIndexSchema, type KnowledgeInspection, type KnowledgeLayout, KnowledgeLintFinding, type KnowledgeOptimizationConfig, KnowledgePage, KnowledgePageSchema, type KnowledgeReadinessSpec, KnowledgeRelease, type KnowledgeReleaseReport, KnowledgeSearchResult, KnowledgeWriteParseResult, MemoryKbStore, type ParsedFrontmatter, SCAFFOLD_PAGE_BASENAMES, type SourceAdapter, type SourceAdapterInput, type SourceAdapterOutput, SourceAnchorSchema, type SourceFreshnessInspection, SourceRecord, SourceRecordSchema, SourceRegistry, type ValidateKnowledgeOptions, type ValidateKnowledgeResult, WIKILINK_REGEX, addSourcePath, applyKnowledgeWriteBlocks, applyKnowledgeWriteBlocksFile, buildEvalKnowledgeBundle, buildKnowledgeGraph, buildKnowledgeIndex, chunkMarkdown, createKnowledgeEvent, createLocalDiscoveryDispatcher, explainKnowledgeTarget, extractWikilinks, formatFrontmatter, initKnowledgeBase, inspectKnowledgeIndex, isSafeKnowledgePath, isScaffoldPath, knowledgeReleaseReportFromOptimization, knowledgeVariantFromCandidate, layoutFor, lintKnowledgeIndex, loadKnowledgePages, loadSourceRegistry, mediaTypeFor, normalizeLinkTarget, parseFrontmatter, parseKnowledgeWriteBlocks, reciprocalRankFusion, runKnowledgeBaseOptimization, searchKnowledge, sha256, slugify, sourceRegistryPath, stableId, stripFrontmatter, textSourceAdapter, tokenizeQuery, validateKnowledgeIndex, writeJson, writeKnowledgeIndex, writeSourceRegistry };
931
+ export { type AddSourceOptions, type AddSourceTextInput, type ApplyWriteBlocksResult, type BuildEvalKnowledgeBundleOptions, type ChunkingOptions, type D1Adapter, type DefineReadinessSpecInput, type DetectChangesOptions, type DetectChangesResult, type DiscoveryResult, type DiscoveryTask, type EvalKnowledgeBundleBuildResult, type FileSystemFreshnessStoreOptions, FileSystemKbStore, type FreshnessKey, type FreshnessMark, type FreshnessRecord, type FreshnessTtl, type KbStore, KnowledgeBaseCandidate, KnowledgeBaseCandidateSchema, type KnowledgeBaseVariant, 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, KnowledgeGraph, KnowledgeGraphEdgeSchema, KnowledgeGraphNodeSchema, KnowledgeIndex, KnowledgeIndexSchema, type KnowledgeInspection, type KnowledgeLayout, KnowledgeLintFinding, type KnowledgeOptimizationConfig, KnowledgePage, KnowledgePageSchema, type KnowledgeProposal, KnowledgeProposalParseError, type KnowledgeReadinessSpec, KnowledgeRelease, type KnowledgeReleaseReport, type KnowledgeResearchLoopContext, type KnowledgeResearchLoopDecision, type KnowledgeResearchLoopResult, type KnowledgeResearchLoopStep, KnowledgeSearchResult, KnowledgeWriteBlock, KnowledgeWriteParseResult, MemoryKbStore, type ParsedFrontmatter, type ProposeFromFindingsResult, READINESS_SPEC_DEFAULTS, type RunKnowledgeResearchLoopOptions, SCAFFOLD_PAGE_BASENAMES, type SourceAdapter, type SourceAdapterInput, type SourceAdapterOutput, SourceAnchorSchema, type SourceFreshnessInspection, SourceRecord, SourceRecordSchema, SourceRegistry, type ValidateKnowledgeOptions, type ValidateKnowledgeResult, WIKILINK_REGEX, addSourcePath, addSourceText, applyKnowledgeWriteBlocks, applyKnowledgeWriteBlocksFile, buildEvalKnowledgeBundle, buildKnowledgeGraph, buildKnowledgeIndex, chunkMarkdown, createD1FreshnessStoreStub, createFileSystemFreshnessStore, createKnowledgeControlLoopAdapter, createKnowledgeEvent, createLocalDiscoveryDispatcher, defineReadinessSpec, detectChanges, explainKnowledgeTarget, extractWikilinks, formatFrontmatter, initKnowledgeBase, inspectKnowledgeIndex, isSafeKnowledgePath, isScaffoldPath, knowledgeReleaseReportFromOptimization, knowledgeVariantFromCandidate, layoutFor, lintKnowledgeIndex, loadKnowledgePages, loadSourceRegistry, mediaTypeFor, normalizeLinkTarget, parseFrontmatter, parseKnowledgeWriteBlocks, proposeFromFinding, proposeFromFindings, reciprocalRankFusion, runKnowledgeBaseOptimization, runKnowledgeResearchLoop, searchKnowledge, sha256, slugify, sourceRegistryPath, stableId, stripFrontmatter, textSourceAdapter, tokenizeQuery, validateKnowledgeIndex, writeJson, writeKnowledgeIndex, writeSourceRegistry };