clawvault 2.6.3 → 2.6.5

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 (127) hide show
  1. package/README.md +351 -21
  2. package/bin/clawvault.js +8 -2
  3. package/bin/command-runtime.js +9 -1
  4. package/bin/register-maintenance-commands.js +19 -0
  5. package/bin/register-query-commands.js +58 -6
  6. package/bin/register-workgraph-commands.js +451 -0
  7. package/dist/chunk-2GKPENIR.js +66 -0
  8. package/dist/{chunk-VXEOHTSL.js → chunk-2JQ3O2YL.js} +1 -1
  9. package/dist/{chunk-VR5NE7PZ.js → chunk-2RAZ4ZFE.js} +1 -1
  10. package/dist/chunk-2ZDO52B4.js +52 -0
  11. package/dist/{chunk-ZZA73MFY.js → chunk-33DOSHTA.js} +176 -36
  12. package/dist/chunk-4BQTQMJP.js +93 -0
  13. package/dist/{chunk-MAKNAHAW.js → chunk-5PJ4STIC.js} +98 -8
  14. package/dist/{chunk-RVYA52PY.js → chunk-5UM4PMMM.js} +1 -1
  15. package/dist/{chunk-4VQTUVH7.js → chunk-7YZWHM36.js} +52 -26
  16. package/dist/{chunk-4VRIMU4O.js → chunk-A4EAUO7T.js} +5 -5
  17. package/dist/{chunk-R6SXNSFD.js → chunk-BV5KWZKR.js} +3 -3
  18. package/dist/chunk-FBITHIZF.js +351 -0
  19. package/dist/{chunk-Q2J5YTUF.js → chunk-FUSLEY6L.js} +751 -34
  20. package/dist/chunk-GNJL4YGR.js +79 -0
  21. package/dist/{chunk-42MXU7A6.js → chunk-K4GFGKFD.js} +51 -47
  22. package/dist/{chunk-PBEE567J.js → chunk-KSZROBFH.js} +2 -2
  23. package/dist/chunk-L4HSSQ6T.js +152 -0
  24. package/dist/{chunk-PZ2AUU2W.js → chunk-LMKQ7NIF.js} +206 -37
  25. package/dist/{chunk-6546Q4OR.js → chunk-M5O6FQ66.js} +6 -6
  26. package/dist/chunk-MM6QGW3P.js +207 -0
  27. package/dist/{chunk-T76H47ZS.js → chunk-MNPUYCHQ.js} +1 -1
  28. package/dist/{chunk-P5EPF6MB.js → chunk-MW5C6ZQA.js} +110 -13
  29. package/dist/{chunk-OZ7RIXTO.js → chunk-QSRRMEYM.js} +2 -2
  30. package/dist/chunk-RHISK3SZ.js +189 -0
  31. package/dist/{chunk-3BTHWPMB.js → chunk-S5OJEGFG.js} +2 -2
  32. package/dist/{chunk-MGDEINGP.js → chunk-SS4B7P7V.js} +1 -1
  33. package/dist/{chunk-ME37YNW3.js → chunk-SV7T4HRE.js} +4 -4
  34. package/dist/{chunk-IEVLHNLU.js → chunk-T3FKSZSN.js} +3 -3
  35. package/dist/{chunk-DTEHFAL7.js → chunk-TS6NDVOU.js} +2 -2
  36. package/dist/chunk-U4O6C46S.js +154 -0
  37. package/dist/{chunk-ITPEXLHA.js → chunk-URXDAUVH.js} +24 -5
  38. package/dist/chunk-WMGIIABP.js +15 -0
  39. package/dist/{chunk-QVMXF7FY.js → chunk-X3SPPUFG.js} +50 -0
  40. package/dist/{chunk-THRJVD4L.js → chunk-Y6VJKXGL.js} +1 -1
  41. package/dist/{chunk-RCBMXTWS.js → chunk-YD7SVXTF.js} +39 -7
  42. package/dist/{chunk-HIHOUSXS.js → chunk-YXQCA6B7.js} +105 -1
  43. package/dist/cli/index.js +20 -18
  44. package/dist/commands/archive.js +3 -2
  45. package/dist/commands/backlog.js +1 -0
  46. package/dist/commands/blocked.js +1 -0
  47. package/dist/commands/canvas.js +2 -1
  48. package/dist/commands/checkpoint.js +1 -0
  49. package/dist/commands/compat.js +2 -1
  50. package/dist/commands/context.js +6 -4
  51. package/dist/commands/doctor.d.ts +10 -1
  52. package/dist/commands/doctor.js +13 -10
  53. package/dist/commands/embed.js +5 -3
  54. package/dist/commands/entities.js +2 -1
  55. package/dist/commands/graph.js +4 -3
  56. package/dist/commands/inject.d.ts +1 -1
  57. package/dist/commands/inject.js +5 -4
  58. package/dist/commands/kanban.js +1 -0
  59. package/dist/commands/link.js +5 -4
  60. package/dist/commands/migrate-observations.js +3 -2
  61. package/dist/commands/observe.js +9 -7
  62. package/dist/commands/project.js +1 -0
  63. package/dist/commands/rebuild-embeddings.d.ts +21 -0
  64. package/dist/commands/rebuild-embeddings.js +91 -0
  65. package/dist/commands/rebuild.js +6 -4
  66. package/dist/commands/recover.js +1 -0
  67. package/dist/commands/reflect.js +5 -4
  68. package/dist/commands/repair-session.js +1 -0
  69. package/dist/commands/replay.js +7 -6
  70. package/dist/commands/session-recap.js +1 -0
  71. package/dist/commands/setup.js +3 -2
  72. package/dist/commands/shell-init.js +2 -0
  73. package/dist/commands/sleep.d.ts +1 -1
  74. package/dist/commands/sleep.js +10 -8
  75. package/dist/commands/status.js +13 -82
  76. package/dist/commands/sync-bd.js +3 -2
  77. package/dist/commands/tailscale.js +3 -2
  78. package/dist/commands/task.js +1 -0
  79. package/dist/commands/template.js +1 -0
  80. package/dist/commands/wake.d.ts +1 -1
  81. package/dist/commands/wake.js +5 -3
  82. package/dist/index.d.ts +254 -10
  83. package/dist/index.js +288 -155
  84. package/dist/{inject-x65KXWPk.d.ts → inject-DYUrDqQO.d.ts} +2 -2
  85. package/dist/ledger-B7g7jhqG.d.ts +44 -0
  86. package/dist/lib/auto-linker.js +2 -1
  87. package/dist/lib/canvas-layout.js +1 -0
  88. package/dist/lib/config.d.ts +27 -3
  89. package/dist/lib/config.js +4 -1
  90. package/dist/lib/entity-index.js +1 -0
  91. package/dist/lib/project-utils.js +1 -0
  92. package/dist/lib/session-repair.js +1 -0
  93. package/dist/lib/session-utils.js +1 -0
  94. package/dist/lib/tailscale.js +1 -0
  95. package/dist/lib/task-utils.js +1 -0
  96. package/dist/lib/template-engine.js +1 -0
  97. package/dist/lib/webdav.js +1 -0
  98. package/dist/onnxruntime_binding-5QEF3SUC.node +0 -0
  99. package/dist/onnxruntime_binding-BKPKNEGC.node +0 -0
  100. package/dist/onnxruntime_binding-FMOXGIUT.node +0 -0
  101. package/dist/onnxruntime_binding-OI2KMXC5.node +0 -0
  102. package/dist/onnxruntime_binding-UX44MLAZ.node +0 -0
  103. package/dist/onnxruntime_binding-Y2W7N7WY.node +0 -0
  104. package/dist/registry-BR4326o0.d.ts +30 -0
  105. package/dist/store-CA-6sKCJ.d.ts +34 -0
  106. package/dist/thread-B9LhXNU0.d.ts +41 -0
  107. package/dist/transformers.node-A2ZRORSQ.js +46775 -0
  108. package/dist/{types-C74wgGL1.d.ts → types-BbWJoC1c.d.ts} +1 -1
  109. package/dist/workgraph/index.d.ts +5 -0
  110. package/dist/workgraph/index.js +23 -0
  111. package/dist/workgraph/ledger.d.ts +2 -0
  112. package/dist/workgraph/ledger.js +25 -0
  113. package/dist/workgraph/registry.d.ts +2 -0
  114. package/dist/workgraph/registry.js +19 -0
  115. package/dist/workgraph/store.d.ts +2 -0
  116. package/dist/workgraph/store.js +25 -0
  117. package/dist/workgraph/thread.d.ts +2 -0
  118. package/dist/workgraph/thread.js +25 -0
  119. package/dist/workgraph/types.d.ts +54 -0
  120. package/dist/workgraph/types.js +7 -0
  121. package/hooks/clawvault/handler.js +714 -2
  122. package/hooks/clawvault/handler.test.js +153 -0
  123. package/hooks/clawvault/openclaw.plugin.json +72 -0
  124. package/openclaw.plugin.json +14 -2
  125. package/package.json +5 -4
  126. package/dist/chunk-4QYGFWRM.js +0 -88
  127. package/dist/chunk-MXSSG3QU.js +0 -42
package/dist/index.d.ts CHANGED
@@ -1,17 +1,19 @@
1
1
  import { Command } from 'commander';
2
- import { V as VaultConfig, S as StoreOptions, D as Document, a as SearchOptions, b as SearchResult, c as SyncOptions, d as SyncResult, C as Category, M as MemoryType, H as HandoffDocument, e as SessionRecap } from './types-C74wgGL1.js';
3
- export { f as DEFAULT_CATEGORIES, g as DEFAULT_CONFIG, h as MEMORY_TYPES, T as TYPE_TO_CATEGORY, i as VaultMeta } from './types-C74wgGL1.js';
2
+ import { V as VaultConfig, a as StoreOptions, D as Document, b as SearchOptions, c as SearchResult, d as SyncOptions, e as SyncResult, C as Category, M as MemoryType, H as HandoffDocument, S as SessionRecap } from './types-BbWJoC1c.js';
3
+ export { f as DEFAULT_CATEGORIES, g as DEFAULT_CONFIG, h as MEMORY_TYPES, T as TYPE_TO_CATEGORY, i as VaultMeta } from './types-BbWJoC1c.js';
4
4
  export { setupCommand } from './commands/setup.js';
5
5
  export { CompatCheck, CompatCommandOptions, CompatReport, CompatStatus, checkOpenClawCompatibility, compatCommand, compatibilityExitCode } from './commands/compat.js';
6
6
  export { GraphSummary, graphCommand, graphSummary } from './commands/graph.js';
7
7
  export { KanbanGroupBy, KanbanImportChange, KanbanImportOptions, KanbanImportResult, KanbanLane, KanbanSyncOptions, KanbanSyncResult, ParsedKanbanBoard, ParsedKanbanLane, buildKanbanLanes, extractCardSlug, formatKanbanCard, generateKanbanMarkdown, importKanbanBoard, kanbanCommand, parseKanbanMarkdown, syncKanbanBoard } from './commands/kanban.js';
8
8
  export { C as ContextEntry, a as ContextFormat, b as ContextOptions, c as ContextProfile, d as ContextProfileInput, e as ContextProfileOption, f as ContextResult, R as ResolvedContextProfile, g as buildContext, h as contextCommand, i as formatContextMarkdown, j as inferContextProfile, n as normalizeContextProfileInput, r as registerContextCommand, k as resolveContextProfile } from './context-BUGaWpyL.js';
9
- export { I as InjectCommandOptions, a as InjectFormat, b as InjectMatch, c as InjectMatchReason, d as InjectMatchSource, e as InjectResult, f as InjectRuntimeOptions, g as InjectSourceCategory, h as InjectableItem, L as LlmCompletionOptions, i as LlmProvider, M as MEMORY_GRAPH_SCHEMA_VERSION, j as MemoryGraph, k as MemoryGraphEdge, l as MemoryGraphEdgeType, m as MemoryGraphIndex, n as MemoryGraphNode, o as MemoryGraphNodeType, p as MemoryGraphStats, q as buildInjectionResult, r as buildOrUpdateMemoryGraphIndex, s as deterministicInjectMatches, t as getMemoryGraph, u as indexInjectableItems, v as injectCommand, w as loadMemoryGraphIndex, x as registerInjectCommand, y as requestLlmCompletion, z as resolveLlmProvider, A as runPromptInjection } from './inject-x65KXWPk.js';
9
+ import { L as LlmProvider } from './inject-DYUrDqQO.js';
10
+ export { I as InjectCommandOptions, a as InjectFormat, b as InjectMatch, c as InjectMatchReason, d as InjectMatchSource, e as InjectResult, f as InjectRuntimeOptions, g as InjectSourceCategory, h as InjectableItem, i as LlmCompletionOptions, M as MEMORY_GRAPH_SCHEMA_VERSION, j as MemoryGraph, k as MemoryGraphEdge, l as MemoryGraphEdgeType, m as MemoryGraphIndex, n as MemoryGraphNode, o as MemoryGraphNodeType, p as MemoryGraphStats, q as buildInjectionResult, r as buildOrUpdateMemoryGraphIndex, s as deterministicInjectMatches, t as getMemoryGraph, u as indexInjectableItems, v as injectCommand, w as loadMemoryGraphIndex, x as registerInjectCommand, y as requestLlmCompletion, z as resolveLlmProvider, A as runPromptInjection } from './inject-DYUrDqQO.js';
10
11
  export { ObserveCommandOptions, observeCommand, registerObserveCommand } from './commands/observe.js';
11
12
  export { ReflectCommandOptions, reflectCommand, registerReflectCommand } from './commands/reflect.js';
12
13
  export { ArchiveCommandOptions, archiveCommand, registerArchiveCommand } from './commands/archive.js';
13
14
  export { RebuildCommandOptions, rebuildCommand, registerRebuildCommand } from './commands/rebuild.js';
14
- export { DoctorCheck, DoctorReport, DoctorStatus, doctor } from './commands/doctor.js';
15
+ import { MigrationIssueType } from './commands/doctor.js';
16
+ export { DoctorCheck, DoctorReport, DoctorStatus, MigrationIssue, doctor } from './commands/doctor.js';
15
17
  export { EmbedCommandOptions, EmbedCommandResult, embedCommand, registerEmbedCommand } from './commands/embed.js';
16
18
  export { ReplayCommandOptions, registerReplayCommand, replayCommand } from './commands/replay.js';
17
19
  export { MigrateObservationsOptions, MigrateObservationsResult, migrateObservations, migrateObservationsCommand, registerMigrateObservationsCommand } from './commands/migrate-observations.js';
@@ -189,6 +191,29 @@ declare function createVault(vaultPath: string, options?: Partial<VaultConfig>,
189
191
  skipGraph?: boolean;
190
192
  }): Promise<ClawVault>;
191
193
 
194
+ interface MigrateCommandOptions {
195
+ vaultPath?: string;
196
+ dryRun?: boolean;
197
+ force?: boolean;
198
+ json?: boolean;
199
+ }
200
+ interface MigrationAction {
201
+ type: MigrationIssueType;
202
+ description: string;
203
+ success: boolean;
204
+ error?: string;
205
+ }
206
+ interface MigrateResult {
207
+ vaultPath: string;
208
+ issuesFound: number;
209
+ issuesFixed: number;
210
+ actions: MigrationAction[];
211
+ dryRun: boolean;
212
+ }
213
+ declare function migrate(options?: MigrateCommandOptions): Promise<MigrateResult>;
214
+ declare function migrateCommand(options?: MigrateCommandOptions): Promise<MigrateResult>;
215
+ declare function registerMigrateCommand(program: Command): void;
216
+
192
217
  /**
193
218
  * ClawVault Search Engine - qmd Backend
194
219
  * Uses qmd CLI for BM25 and vector search
@@ -196,8 +221,22 @@ declare function createVault(vaultPath: string, options?: Partial<VaultConfig>,
196
221
 
197
222
  declare const QMD_INSTALL_URL = "https://github.com/tobi/qmd";
198
223
  declare const QMD_INSTALL_COMMAND = "bun install -g github:tobi/qmd";
224
+ type QmdErrorCode = 'NOT_INSTALLED' | 'NOT_CONFIGURED' | 'COLLECTION_NOT_FOUND' | 'EXECUTION_FAILED';
225
+ interface QmdErrorDetails {
226
+ code: QmdErrorCode;
227
+ message: string;
228
+ hint: string;
229
+ }
199
230
  declare class QmdUnavailableError extends Error {
200
- constructor(message?: string);
231
+ readonly code: QmdErrorCode;
232
+ readonly hint: string;
233
+ constructor(code?: QmdErrorCode, additionalContext?: string);
234
+ toUserMessage(): string;
235
+ }
236
+ declare function getQmdErrorDetails(code: QmdErrorCode): QmdErrorDetails;
237
+ declare class QmdConfigurationError extends Error {
238
+ readonly hint?: string | undefined;
239
+ constructor(message: string, hint?: string | undefined);
201
240
  }
202
241
  /**
203
242
  * Check if qmd is available
@@ -224,6 +263,10 @@ declare class SearchEngine {
224
263
  * Set the collection name (usually vault name)
225
264
  */
226
265
  setCollection(name: string): void;
266
+ /**
267
+ * Get the current collection name
268
+ */
269
+ getCollection(): string;
227
270
  /**
228
271
  * Set the vault path for file resolution
229
272
  */
@@ -386,15 +429,17 @@ declare function hybridSearch(query: string, bm25Results: SearchResult[], cache:
386
429
  rrfK?: number;
387
430
  }): Promise<SearchResult[]>;
388
431
 
389
- declare const OBSERVE_PROVIDERS: readonly ["anthropic", "openai", "gemini"];
390
- declare const OBSERVER_COMPRESSION_PROVIDERS: readonly ["anthropic", "openai", "gemini", "openai-compatible", "ollama"];
432
+ declare const OBSERVE_PROVIDERS: readonly ["anthropic", "openai", "gemini", "xai", "openclaw"];
433
+ declare const OBSERVER_COMPRESSION_PROVIDERS: readonly ["anthropic", "openai", "gemini", "xai", "openai-compatible", "ollama", "openclaw", "minimax", "zai"];
391
434
  declare const THEMES: readonly ["neural", "minimal", "none"];
392
435
  declare const CONTEXT_PROFILES: readonly ["default", "planning", "incident", "handoff", "auto"];
436
+ declare const FACT_EXTRACTION_MODES: readonly ["off", "rule", "llm", "hybrid"];
393
437
  type ObserveProvider = (typeof OBSERVE_PROVIDERS)[number];
394
438
  type ObserverCompressionProvider = (typeof OBSERVER_COMPRESSION_PROVIDERS)[number];
395
439
  type Theme = (typeof THEMES)[number];
396
440
  type ContextProfile = (typeof CONTEXT_PROFILES)[number];
397
- type ManagedConfigKey = 'name' | 'categories' | 'theme' | 'observe.model' | 'observe.provider' | 'observer.compression.provider' | 'observer.compression.model' | 'observer.compression.baseUrl' | 'observer.compression.apiKey' | 'context.maxResults' | 'context.defaultProfile' | 'graph.maxHops' | 'inject.maxResults' | 'inject.useLlm' | 'inject.scope';
441
+ type FactExtractionMode$1 = (typeof FACT_EXTRACTION_MODES)[number];
442
+ type ManagedConfigKey = 'name' | 'categories' | 'theme' | 'observe.model' | 'observe.provider' | 'observer.compression.provider' | 'observer.compression.model' | 'observer.compression.baseUrl' | 'observer.compression.apiKey' | 'observer.factExtractionMode' | 'context.maxResults' | 'context.defaultProfile' | 'graph.maxHops' | 'inject.maxResults' | 'inject.useLlm' | 'inject.scope';
398
443
  interface RouteRule {
399
444
  pattern: string;
400
445
  target: string;
@@ -415,6 +460,197 @@ declare function removeRouteRule(vaultPath: string, pattern: string): boolean;
415
460
  declare function matchRouteRule(text: string, routes: RouteRule[]): RouteRule | null;
416
461
  declare function testRouteRule(vaultPath: string, text: string): RouteRule | null;
417
462
 
463
+ /**
464
+ * LLM Adapter for fact extraction.
465
+ *
466
+ * Provides a unified interface for calling LLMs to extract facts from text.
467
+ * Currently supports Gemini Flash as the primary adapter, with fallback to
468
+ * the existing LLM provider infrastructure.
469
+ */
470
+
471
+ type FactExtractionMode = 'off' | 'rule' | 'llm' | 'hybrid';
472
+ interface LlmAdapterOptions {
473
+ provider?: LlmProvider | null;
474
+ model?: string;
475
+ temperature?: number;
476
+ maxTokens?: number;
477
+ fetchImpl?: typeof fetch;
478
+ }
479
+ interface LlmAdapter {
480
+ /**
481
+ * Call the LLM with a prompt and return the response text.
482
+ */
483
+ call(prompt: string): Promise<string>;
484
+ /**
485
+ * Check if the adapter is available (has valid credentials).
486
+ */
487
+ isAvailable(): boolean;
488
+ /**
489
+ * Get the provider name for this adapter.
490
+ */
491
+ getProvider(): LlmProvider | null;
492
+ }
493
+ /**
494
+ * Create a Gemini Flash adapter for fact extraction.
495
+ * Uses the Gemini API with the flash model optimized for speed.
496
+ */
497
+ declare function createGeminiFlashAdapter(options?: LlmAdapterOptions): LlmAdapter;
498
+ /**
499
+ * Create an LLM adapter using the default provider resolution.
500
+ * Falls back through providers: openclaw -> anthropic -> openai -> gemini -> xai
501
+ */
502
+ declare function createDefaultAdapter(options?: LlmAdapterOptions): LlmAdapter;
503
+ /**
504
+ * Create an LLM adapter for fact extraction based on configuration.
505
+ *
506
+ * Priority:
507
+ * 1. If provider is explicitly specified, use that
508
+ * 2. If Gemini API key is available, prefer Gemini Flash for speed
509
+ * 3. Fall back to default provider resolution
510
+ */
511
+ declare function createFactExtractionAdapter(options?: LlmAdapterOptions): LlmAdapter;
512
+ /**
513
+ * Create an LLM function compatible with extractFactsLlm.
514
+ * This wraps the adapter into the function signature expected by fact-extractor.ts.
515
+ */
516
+ declare function createLlmFunction(adapter: LlmAdapter): ((prompt: string) => Promise<string>) | undefined;
517
+ /**
518
+ * Resolve the effective fact extraction mode based on configuration and availability.
519
+ *
520
+ * - 'off': Never extract facts
521
+ * - 'rule': Only use rule-based extraction (no LLM)
522
+ * - 'llm': Prefer LLM extraction, fall back to rules if LLM unavailable
523
+ * - 'hybrid': Use both LLM and rules, merge results (future enhancement)
524
+ */
525
+ declare function resolveFactExtractionMode(configuredMode: FactExtractionMode | undefined, adapter?: LlmAdapter): {
526
+ mode: FactExtractionMode;
527
+ useLlm: boolean;
528
+ };
529
+
530
+ /**
531
+ * Write-time fact extraction for ClawVault v3.
532
+ *
533
+ * When a memory is stored, this module extracts structured facts:
534
+ * (entity, relation, value, timestamp, confidence)
535
+ *
536
+ * Two modes:
537
+ * 1. LLM extraction (accurate but requires API key)
538
+ * 2. Rule-based extraction (fast, no deps, lower quality)
539
+ *
540
+ * Extracted facts are stored alongside raw markdown in .clawvault/facts.jsonl
541
+ * and used to build the entity-relationship graph.
542
+ */
543
+ interface ExtractedFact {
544
+ /** Unique ID for this fact */
545
+ id: string;
546
+ /** The entity this fact is about (person, place, thing) */
547
+ entity: string;
548
+ /** Normalized entity name for dedup */
549
+ entityNorm: string;
550
+ /** Relationship type (e.g., "prefers", "works_at", "lives_in", "bought") */
551
+ relation: string;
552
+ /** The value/object of the relation */
553
+ value: string;
554
+ /** When this fact was established */
555
+ validFrom: string;
556
+ /** When this fact was superseded (null = still current) */
557
+ validUntil: string | null;
558
+ /** Confidence 0-1 */
559
+ confidence: number;
560
+ /** Category: preference, fact, decision, entity, event */
561
+ category: 'preference' | 'fact' | 'decision' | 'entity' | 'event' | 'other';
562
+ /** Source file path (relative to vault) */
563
+ source: string;
564
+ /** Raw text this was extracted from */
565
+ rawText: string;
566
+ }
567
+ interface ExtractionResult {
568
+ facts: ExtractedFact[];
569
+ /** Number of conflicts resolved (existing facts updated) */
570
+ conflictsResolved: number;
571
+ /** Processing time in ms */
572
+ durationMs: number;
573
+ }
574
+ /**
575
+ * Normalize an entity name for dedup matching.
576
+ * "Pedro Sobral" -> "pedro sobral"
577
+ * "pedro" -> "pedro"
578
+ * "Dr. Smith" -> "dr smith"
579
+ */
580
+ declare function normalizeEntity(name: string): string;
581
+ /**
582
+ * Generate a deterministic fact ID from entity + relation + value.
583
+ */
584
+ declare function factId(entity: string, relation: string, value: string): string;
585
+ /**
586
+ * Extract facts from raw text using rule-based patterns.
587
+ * Fast, no LLM needed, but lower quality.
588
+ */
589
+ declare function extractFactsRuleBased(text: string, source: string, timestamp?: string): ExtractedFact[];
590
+ /**
591
+ * Extract facts using an LLM. Higher quality but requires API key.
592
+ * Falls back to rule-based if LLM unavailable.
593
+ */
594
+ declare function extractFactsLlm(text: string, source: string, timestamp?: string, llmFn?: (prompt: string) => Promise<string>): Promise<ExtractedFact[]>;
595
+
596
+ /**
597
+ * Fact Store — persistent storage + conflict resolution for extracted facts.
598
+ *
599
+ * Facts are stored in .clawvault/facts.jsonl (append-only log).
600
+ * An in-memory index enables fast lookup by entity, relation, category.
601
+ * Conflict resolution: when a new fact matches an existing one by entity+relation,
602
+ * the old fact gets validUntil set and the new fact replaces it.
603
+ */
604
+
605
+ interface FactStoreStats {
606
+ totalFacts: number;
607
+ activeFacts: number;
608
+ supersededFacts: number;
609
+ entities: number;
610
+ relations: number;
611
+ }
612
+ declare class FactStore {
613
+ private facts;
614
+ private byEntity;
615
+ private byRelation;
616
+ private byCategory;
617
+ private factsPath;
618
+ private dirty;
619
+ constructor(vaultPath: string);
620
+ /** Load facts from disk */
621
+ load(): void;
622
+ /** Add facts with conflict resolution. Returns number of conflicts resolved. */
623
+ addFacts(newFacts: ExtractedFact[]): number;
624
+ /** Find an existing fact that conflicts with the new one */
625
+ private findConflict;
626
+ /** Check if two values are similar enough to be considered the same fact */
627
+ private isSimilarValue;
628
+ /** Relations where only one value can be active at a time */
629
+ private isExclusiveRelation;
630
+ /** Index a fact in all lookup maps */
631
+ private indexFact;
632
+ /** Save facts to disk (full rewrite for consistency) */
633
+ save(): void;
634
+ /** Append new facts to disk (faster than full rewrite) */
635
+ append(facts: ExtractedFact[]): void;
636
+ /** Get all active facts for an entity */
637
+ getEntityFacts(entity: string): ExtractedFact[];
638
+ /** Get all active facts for a relation */
639
+ getRelationFacts(relation: string): ExtractedFact[];
640
+ /** Get all active facts in a category */
641
+ getCategoryFacts(category: string): ExtractedFact[];
642
+ /** Get all active preferences */
643
+ getPreferences(): ExtractedFact[];
644
+ /** Search facts by text query (simple keyword match) */
645
+ searchFacts(query: string): ExtractedFact[];
646
+ /** Get facts valid at a specific time */
647
+ getFactsAt(timestamp: string): ExtractedFact[];
648
+ /** Get stats */
649
+ stats(): FactStoreStats;
650
+ /** Get all facts (for testing/debugging) */
651
+ getAllFacts(): ExtractedFact[];
652
+ }
653
+
418
654
  /**
419
655
  * Transition Ledger for ClawVault
420
656
  * Logs task status transitions to JSONL files and supports querying.
@@ -471,7 +707,7 @@ interface CompressorOptions {
471
707
  now?: () => Date;
472
708
  fetchImpl?: typeof fetch;
473
709
  }
474
- type CompressionProvider = 'anthropic' | 'openai' | 'gemini' | 'openai-compatible' | 'ollama';
710
+ type CompressionProvider = 'anthropic' | 'openai' | 'gemini' | 'xai' | 'openai-compatible' | 'ollama' | 'minimax' | 'zai';
475
711
  declare class Compressor {
476
712
  private readonly provider?;
477
713
  private readonly model?;
@@ -481,6 +717,13 @@ declare class Compressor {
481
717
  private readonly fetchImpl;
482
718
  constructor(options?: CompressorOptions);
483
719
  compress(messages: string[], existingObservations: string): Promise<string>;
720
+ private sanitizeIncomingMessages;
721
+ private sanitizeIncomingMessage;
722
+ private normalizeMessageRole;
723
+ private isConversationRolePrefix;
724
+ private shouldDropMessageRole;
725
+ private stripNoisyData;
726
+ private isLikelyStructuredNoise;
484
727
  private resolveProvider;
485
728
  private resolveConfiguredProvider;
486
729
  private resolveProviderFromEnv;
@@ -494,6 +737,7 @@ declare class Compressor {
494
737
  private extractOpenAIContent;
495
738
  private callAnthropic;
496
739
  private callOpenAI;
740
+ private callXAI;
497
741
  private callOpenAICompatible;
498
742
  private callGemini;
499
743
  private normalizeLlmOutput;
@@ -756,4 +1000,4 @@ declare function runReflection(options: ReflectOptions): Promise<ReflectResult>;
756
1000
  declare const VERSION: string;
757
1001
  declare function registerCommanderCommands(program: Command): Command;
758
1002
 
759
- export { type ActiveObservationCandidate, type ActiveObservationFailure, type ActiveObserveOptions, type ActiveObserveResult, type ArchiveObservationsOptions, type ArchiveObservationsResult, Category, ClawVault, type CompressionProvider, Compressor, type CompressorOptions, type ContextProfile as ConfigDefaultProfile, Document, EmbeddingCache, HandoffDocument, type ManagedConfigKey, MemoryType, type ObserveCursorEntry, type ObserveCursorStore, type ObserveProvider, Observer, type ObserverCompressionProvider, type ObserverCompressor, type ObserverOptions, type ObserverReflector, type ObserverStalenessResult, QMD_INSTALL_COMMAND, QMD_INSTALL_URL, QmdUnavailableError, type ReflectOptions, type ReflectResult, Reflector, type ReflectorOptions, type RouteRule, SUPPORTED_CONFIG_KEYS, SearchEngine, SearchOptions, SearchResult, SessionRecap, SessionWatcher, type SessionWatcherOptions, StoreOptions, SyncOptions, SyncResult, type Theme, type TransitionEvent, VERSION, VaultConfig, addRouteRule, appendTransition, archiveObservations, buildTransitionEvent, cosineSimilarity, countBlockedTransitions, createVault, embed, embedBatch, extractTags, extractWikiLinks, findVault, formatTransitionsTable, getConfig, getConfigValue, getObserverStaleness, getScaledObservationThresholdBytes, hasQmd, hybridSearch, isRegression, listConfig, listRouteRules, matchRouteRule, observeActiveSessions, parseSessionFile, parseSessionSourceLabel, qmdEmbed, qmdUpdate, queryTransitions, readAllTransitions, reciprocalRankFusion, registerCommanderCommands, removeRouteRule, resetConfig, runReflection, semanticSearch, setConfigValue, testRouteRule };
1003
+ export { type ActiveObservationCandidate, type ActiveObservationFailure, type ActiveObserveOptions, type ActiveObserveResult, type ArchiveObservationsOptions, type ArchiveObservationsResult, Category, ClawVault, type CompressionProvider, Compressor, type CompressorOptions, type ContextProfile as ConfigDefaultProfile, Document, EmbeddingCache, type ExtractedFact, type ExtractionResult, type FactExtractionMode$1 as FactExtractionMode, FactStore, type FactStoreStats, HandoffDocument, type LlmAdapter, type LlmAdapterOptions, LlmProvider, type ManagedConfigKey, MemoryType, type MigrateCommandOptions, type MigrateResult, type MigrationAction, MigrationIssueType, type ObserveCursorEntry, type ObserveCursorStore, type ObserveProvider, Observer, type ObserverCompressionProvider, type ObserverCompressor, type ObserverOptions, type ObserverReflector, type ObserverStalenessResult, QMD_INSTALL_COMMAND, QMD_INSTALL_URL, QmdConfigurationError, type QmdErrorCode, type QmdErrorDetails, QmdUnavailableError, type ReflectOptions, type ReflectResult, Reflector, type ReflectorOptions, type RouteRule, SUPPORTED_CONFIG_KEYS, SearchEngine, SearchOptions, SearchResult, SessionRecap, SessionWatcher, type SessionWatcherOptions, StoreOptions, SyncOptions, SyncResult, type Theme, type TransitionEvent, VERSION, VaultConfig, addRouteRule, appendTransition, archiveObservations, buildTransitionEvent, cosineSimilarity, countBlockedTransitions, createDefaultAdapter, createFactExtractionAdapter, createGeminiFlashAdapter, createLlmFunction, createVault, embed, embedBatch, extractFactsLlm, extractFactsRuleBased, extractTags, extractWikiLinks, factId, findVault, formatTransitionsTable, getConfig, getConfigValue, getObserverStaleness, getQmdErrorDetails, getScaledObservationThresholdBytes, hasQmd, hybridSearch, isRegression, listConfig, listRouteRules, matchRouteRule, migrate, migrateCommand, normalizeEntity, observeActiveSessions, parseSessionFile, parseSessionSourceLabel, qmdEmbed, qmdUpdate, queryTransitions, readAllTransitions, reciprocalRankFusion, registerCommanderCommands, registerMigrateCommand, removeRouteRule, resetConfig, resolveFactExtractionMode, runReflection, semanticSearch, setConfigValue, testRouteRule };