clawvault 3.0.0 → 3.2.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/README.md +352 -20
- package/bin/clawvault.js +8 -2
- package/bin/command-registration.test.js +3 -1
- package/bin/command-runtime.js +9 -1
- package/bin/register-core-commands.js +23 -10
- package/bin/register-maintenance-commands.js +39 -3
- package/bin/register-query-commands.js +58 -29
- package/bin/register-task-commands.js +18 -1
- package/bin/register-task-commands.test.js +16 -0
- package/bin/register-vault-operations-commands.js +29 -1
- package/bin/register-workgraph-commands.js +1368 -0
- package/dashboard/lib/graph-diff.js +104 -0
- package/dashboard/lib/graph-diff.test.js +75 -0
- package/dashboard/lib/vault-parser.js +556 -0
- package/dashboard/lib/vault-parser.test.js +254 -0
- package/dashboard/public/app.js +796 -0
- package/dashboard/public/index.html +52 -0
- package/dashboard/public/styles.css +221 -0
- package/dashboard/server.js +374 -0
- package/dist/{chunk-F2JEUD4J.js → chunk-23YDQ3QU.js} +6 -8
- package/dist/{chunk-C7OK5WKP.js → chunk-2JQ3O2YL.js} +4 -4
- package/dist/{chunk-VR5NE7PZ.js → chunk-2RAZ4ZFE.js} +1 -1
- package/dist/chunk-2ZDO52B4.js +52 -0
- package/dist/{chunk-ZZA73MFY.js → chunk-33DOSHTA.js} +176 -36
- package/dist/chunk-33VSQP4J.js +37 -0
- package/dist/chunk-4BQTQMJP.js +93 -0
- package/dist/{chunk-GUKMRGM7.js → chunk-4OXMU5S2.js} +1 -1
- package/dist/{chunk-62YTUT6J.js → chunk-4PY655YM.js} +15 -3
- package/dist/chunk-6FH3IULF.js +352 -0
- package/dist/{chunk-3NSBOUT3.js → chunk-77Q5CSPJ.js} +404 -80
- package/dist/{chunk-4VQTUVH7.js → chunk-7YZWHM36.js} +52 -26
- package/dist/chunk-BSJ6RIT7.js +447 -0
- package/dist/chunk-BUEW6IIK.js +364 -0
- package/dist/{chunk-WGRQ6HDV.js → chunk-CLJTREDS.js} +74 -14
- package/dist/chunk-EK6S23ZB.js +469 -0
- package/dist/{chunk-LNJA2UGL.js → chunk-ESFLMDRB.js} +9 -86
- package/dist/{chunk-H34S76MB.js → chunk-ESVS6K2B.js} +6 -6
- package/dist/{chunk-WAZ3NLWL.js → chunk-F55HGNU4.js} +0 -47
- package/dist/{chunk-QK3UCXWL.js → chunk-FHFUXL6G.js} +2 -2
- package/dist/{chunk-YKTA5JOJ.js → chunk-GAOWA7GR.js} +212 -46
- package/dist/chunk-GGA32J2R.js +784 -0
- package/dist/chunk-GNJL4YGR.js +79 -0
- package/dist/chunk-MDIH26GC.js +183 -0
- package/dist/{chunk-LYHGEHXG.js → chunk-MFAWT5O5.js} +0 -1
- package/dist/chunk-MM6QGW3P.js +207 -0
- package/dist/{chunk-P5EPF6MB.js → chunk-MW5C6ZQA.js} +110 -13
- package/dist/chunk-NCKFNBHJ.js +257 -0
- package/dist/{chunk-QBLMXKF2.js → chunk-OIWVQYQF.js} +1 -1
- package/dist/{chunk-42MXU7A6.js → chunk-P62WHA27.js} +58 -47
- package/dist/chunk-PBACDKKP.js +66 -0
- package/dist/{chunk-VGLOTGAS.js → chunk-QSHD36LH.js} +2 -2
- package/dist/{chunk-OZ7RIXTO.js → chunk-QSRRMEYM.js} +2 -2
- package/dist/chunk-QVEERJSP.js +152 -0
- package/dist/{chunk-N2AXRYLC.js → chunk-QWQ3TIKS.js} +1 -1
- package/dist/{chunk-3DHXQHYG.js → chunk-R2MIW5G7.js} +1 -1
- package/dist/{chunk-SJSFRIYS.js → chunk-SLXOR3CC.js} +2 -2
- package/dist/chunk-SS4B7P7V.js +99 -0
- package/dist/{chunk-JY6FYXIT.js → chunk-STCQGCEQ.js} +6 -11
- package/dist/chunk-U4O6C46S.js +154 -0
- package/dist/{chunk-ITPEXLHA.js → chunk-URXDAUVH.js} +24 -5
- package/dist/chunk-VSL7KY3M.js +189 -0
- package/dist/{chunk-U55BGUAU.js → chunk-W4SPAEE7.js} +6 -6
- package/dist/chunk-WMGIIABP.js +15 -0
- package/dist/{chunk-3D6BCTP6.js → chunk-X3SPPUFG.js} +51 -39
- package/dist/{chunk-THRJVD4L.js → chunk-Y6VJKXGL.js} +1 -1
- package/dist/{chunk-ZVVFWOLW.js → chunk-ZN54U2OZ.js} +123 -10
- package/dist/cli/index.js +32 -25
- package/dist/commands/archive.js +3 -3
- package/dist/commands/backlog.js +3 -3
- package/dist/commands/blocked.js +3 -3
- package/dist/commands/canvas.d.ts +15 -0
- package/dist/commands/canvas.js +200 -0
- package/dist/commands/checkpoint.js +2 -2
- package/dist/commands/compat.js +2 -2
- package/dist/commands/context.js +8 -6
- package/dist/commands/doctor.d.ts +11 -7
- package/dist/commands/doctor.js +18 -16
- package/dist/commands/embed.js +5 -6
- package/dist/commands/entities.js +2 -2
- package/dist/commands/graph.js +4 -4
- package/dist/commands/inject.d.ts +1 -1
- package/dist/commands/inject.js +5 -6
- package/dist/commands/kanban.js +4 -4
- package/dist/commands/link.js +5 -5
- package/dist/commands/migrate-observations.js +4 -4
- package/dist/commands/observe.d.ts +0 -1
- package/dist/commands/observe.js +14 -13
- package/dist/commands/project.js +5 -5
- package/dist/commands/rebuild-embeddings.d.ts +21 -0
- package/dist/commands/rebuild-embeddings.js +91 -0
- package/dist/commands/rebuild.js +12 -11
- package/dist/commands/recover.js +3 -3
- package/dist/commands/reflect.js +6 -7
- package/dist/commands/repair-session.js +1 -1
- package/dist/commands/replay.js +14 -14
- package/dist/commands/session-recap.js +1 -1
- package/dist/commands/setup.d.ts +2 -90
- package/dist/commands/setup.js +3 -21
- package/dist/commands/shell-init.js +1 -1
- package/dist/commands/sleep.d.ts +1 -1
- package/dist/commands/sleep.js +20 -19
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.js +57 -35
- package/dist/commands/sync-bd.d.ts +10 -0
- package/dist/commands/sync-bd.js +10 -0
- package/dist/commands/tailscale.js +3 -3
- package/dist/commands/task.js +4 -4
- package/dist/commands/template.js +2 -2
- package/dist/commands/wake.d.ts +1 -1
- package/dist/commands/wake.js +11 -10
- package/dist/commands/workgraph.d.ts +124 -0
- package/dist/commands/workgraph.js +38 -0
- package/dist/index.d.ts +337 -191
- package/dist/index.js +387 -118
- package/dist/{inject-Bzi5E-By.d.cts → inject-DYUrDqQO.d.ts} +3 -3
- package/dist/ledger-B7g7jhqG.d.ts +44 -0
- package/dist/lib/auto-linker.js +2 -2
- package/dist/lib/canvas-layout.d.ts +100 -16
- package/dist/lib/canvas-layout.js +21 -78
- package/dist/lib/config.d.ts +27 -3
- package/dist/lib/config.js +4 -2
- package/dist/lib/entity-index.js +1 -1
- package/dist/lib/project-utils.js +4 -4
- package/dist/lib/session-repair.js +1 -1
- package/dist/lib/session-utils.js +1 -1
- package/dist/lib/tailscale.js +1 -1
- package/dist/lib/task-utils.js +3 -3
- package/dist/lib/template-engine.js +1 -1
- package/dist/lib/webdav.js +1 -1
- package/dist/onnxruntime_binding-5QEF3SUC.node +0 -0
- package/dist/onnxruntime_binding-BKPKNEGC.node +0 -0
- package/dist/onnxruntime_binding-FMOXGIUT.node +0 -0
- package/dist/onnxruntime_binding-OI2KMXC5.node +0 -0
- package/dist/onnxruntime_binding-UX44MLAZ.node +0 -0
- package/dist/onnxruntime_binding-Y2W7N7WY.node +0 -0
- package/dist/openclaw-plugin.d.ts +8 -0
- package/dist/openclaw-plugin.js +14 -0
- package/dist/registry-BR4326o0.d.ts +30 -0
- package/dist/store-CA-6sKCJ.d.ts +34 -0
- package/dist/thread-B9LhXNU0.d.ts +41 -0
- package/dist/transformers.node-A2ZRORSQ.js +46775 -0
- package/dist/{types-Y2_Um2Ls.d.cts → types-BbWJoC1c.d.ts} +1 -44
- package/dist/workgraph/index.d.ts +5 -0
- package/dist/workgraph/index.js +23 -0
- package/dist/workgraph/ledger.d.ts +2 -0
- package/dist/workgraph/ledger.js +25 -0
- package/dist/workgraph/registry.d.ts +2 -0
- package/dist/workgraph/registry.js +19 -0
- package/dist/workgraph/store.d.ts +2 -0
- package/dist/workgraph/store.js +25 -0
- package/dist/workgraph/thread.d.ts +2 -0
- package/dist/workgraph/thread.js +25 -0
- package/dist/workgraph/types.d.ts +54 -0
- package/dist/workgraph/types.js +7 -0
- package/hooks/clawvault/HOOK.md +34 -4
- package/hooks/clawvault/handler.js +760 -78
- package/hooks/clawvault/handler.test.js +235 -79
- package/hooks/clawvault/openclaw.plugin.json +72 -0
- package/openclaw.plugin.json +65 -38
- package/package.json +15 -18
- package/dist/chunk-3RG5ZIWI.js +0 -10
- package/dist/chunk-6U6MK36V.js +0 -205
- package/dist/chunk-7R7O6STJ.js +0 -88
- package/dist/chunk-CMB7UL7C.js +0 -327
- package/dist/chunk-DEFFDRVP.js +0 -938
- package/dist/chunk-E7MFQB6D.js +0 -163
- package/dist/chunk-GAJV4IGR.js +0 -82
- package/dist/chunk-GQSLDZTS.js +0 -560
- package/dist/chunk-K234IDRJ.js +0 -1073
- package/dist/chunk-MFM6K7PU.js +0 -374
- package/dist/chunk-MXSSG3QU.js +0 -42
- package/dist/chunk-PAH27GSN.js +0 -108
- package/dist/cli/index.cjs +0 -10033
- package/dist/cli/index.d.cts +0 -5
- package/dist/commands/archive.cjs +0 -287
- package/dist/commands/archive.d.cts +0 -11
- package/dist/commands/backlog.cjs +0 -721
- package/dist/commands/backlog.d.cts +0 -53
- package/dist/commands/blocked.cjs +0 -204
- package/dist/commands/blocked.d.cts +0 -26
- package/dist/commands/checkpoint.cjs +0 -244
- package/dist/commands/checkpoint.d.cts +0 -41
- package/dist/commands/compat.cjs +0 -369
- package/dist/commands/compat.d.cts +0 -28
- package/dist/commands/context.cjs +0 -2989
- package/dist/commands/context.d.cts +0 -2
- package/dist/commands/doctor.cjs +0 -3062
- package/dist/commands/doctor.d.cts +0 -21
- package/dist/commands/embed.cjs +0 -232
- package/dist/commands/embed.d.cts +0 -17
- package/dist/commands/entities.cjs +0 -141
- package/dist/commands/entities.d.cts +0 -7
- package/dist/commands/graph.cjs +0 -501
- package/dist/commands/graph.d.cts +0 -21
- package/dist/commands/inject.cjs +0 -1636
- package/dist/commands/inject.d.cts +0 -2
- package/dist/commands/kanban.cjs +0 -884
- package/dist/commands/kanban.d.cts +0 -63
- package/dist/commands/link.cjs +0 -965
- package/dist/commands/link.d.cts +0 -11
- package/dist/commands/migrate-observations.cjs +0 -362
- package/dist/commands/migrate-observations.d.cts +0 -19
- package/dist/commands/observe.cjs +0 -4099
- package/dist/commands/observe.d.cts +0 -23
- package/dist/commands/project.cjs +0 -1341
- package/dist/commands/project.d.cts +0 -85
- package/dist/commands/rebuild.cjs +0 -3136
- package/dist/commands/rebuild.d.cts +0 -11
- package/dist/commands/recover.cjs +0 -361
- package/dist/commands/recover.d.cts +0 -38
- package/dist/commands/reflect.cjs +0 -1008
- package/dist/commands/reflect.d.cts +0 -11
- package/dist/commands/repair-session.cjs +0 -457
- package/dist/commands/repair-session.d.cts +0 -38
- package/dist/commands/replay.cjs +0 -4103
- package/dist/commands/replay.d.cts +0 -16
- package/dist/commands/session-recap.cjs +0 -353
- package/dist/commands/session-recap.d.cts +0 -27
- package/dist/commands/setup.cjs +0 -1345
- package/dist/commands/setup.d.cts +0 -100
- package/dist/commands/shell-init.cjs +0 -75
- package/dist/commands/shell-init.d.cts +0 -7
- package/dist/commands/sleep.cjs +0 -6028
- package/dist/commands/sleep.d.cts +0 -36
- package/dist/commands/status.cjs +0 -2736
- package/dist/commands/status.d.cts +0 -52
- package/dist/commands/tailscale.cjs +0 -1532
- package/dist/commands/tailscale.d.cts +0 -52
- package/dist/commands/task.cjs +0 -1236
- package/dist/commands/task.d.cts +0 -97
- package/dist/commands/template.cjs +0 -457
- package/dist/commands/template.d.cts +0 -36
- package/dist/commands/wake.cjs +0 -2626
- package/dist/commands/wake.d.cts +0 -22
- package/dist/context-BUGaWpyL.d.cts +0 -46
- package/dist/index.cjs +0 -14526
- package/dist/index.d.cts +0 -858
- package/dist/inject-Bzi5E-By.d.ts +0 -137
- package/dist/lib/auto-linker.cjs +0 -176
- package/dist/lib/auto-linker.d.cts +0 -26
- package/dist/lib/canvas-layout.cjs +0 -136
- package/dist/lib/canvas-layout.d.cts +0 -31
- package/dist/lib/config.cjs +0 -78
- package/dist/lib/config.d.cts +0 -11
- package/dist/lib/entity-index.cjs +0 -84
- package/dist/lib/entity-index.d.cts +0 -26
- package/dist/lib/project-utils.cjs +0 -864
- package/dist/lib/project-utils.d.cts +0 -97
- package/dist/lib/session-repair.cjs +0 -239
- package/dist/lib/session-repair.d.cts +0 -110
- package/dist/lib/session-utils.cjs +0 -209
- package/dist/lib/session-utils.d.cts +0 -63
- package/dist/lib/tailscale.cjs +0 -1183
- package/dist/lib/tailscale.d.cts +0 -225
- package/dist/lib/task-utils.cjs +0 -1137
- package/dist/lib/task-utils.d.cts +0 -208
- package/dist/lib/template-engine.cjs +0 -47
- package/dist/lib/template-engine.d.cts +0 -11
- package/dist/lib/webdav.cjs +0 -568
- package/dist/lib/webdav.d.cts +0 -109
- package/dist/plugin/index.cjs +0 -1907
- package/dist/plugin/index.d.cts +0 -36
- package/dist/plugin/index.d.ts +0 -36
- package/dist/plugin/index.js +0 -572
- package/dist/plugin/inject.cjs +0 -356
- package/dist/plugin/inject.d.cts +0 -54
- package/dist/plugin/inject.d.ts +0 -54
- package/dist/plugin/inject.js +0 -17
- package/dist/plugin/observe.cjs +0 -631
- package/dist/plugin/observe.d.cts +0 -39
- package/dist/plugin/observe.d.ts +0 -39
- package/dist/plugin/observe.js +0 -18
- package/dist/plugin/templates.cjs +0 -593
- package/dist/plugin/templates.d.cts +0 -52
- package/dist/plugin/templates.d.ts +0 -52
- package/dist/plugin/templates.js +0 -25
- package/dist/plugin/types.cjs +0 -18
- package/dist/plugin/types.d.cts +0 -209
- package/dist/plugin/types.d.ts +0 -209
- package/dist/plugin/types.js +0 -0
- package/dist/plugin/vault.cjs +0 -927
- package/dist/plugin/vault.d.cts +0 -68
- package/dist/plugin/vault.d.ts +0 -68
- package/dist/plugin/vault.js +0 -22
- package/dist/types-Y2_Um2Ls.d.ts +0 -205
- package/templates/memory-event.md +0 -67
- package/templates/party.md +0 -63
- package/templates/primitive-registry.yaml +0 -551
- package/templates/run.md +0 -68
- package/templates/trigger.md +0 -68
- package/templates/workspace.md +0 -50
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { V as VaultConfig,
|
|
3
|
-
export {
|
|
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
|
-
|
|
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
|
-
|
|
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';
|
|
20
|
+
export { SyncBdCommandOptions, registerSyncBdCommand, syncBdCommand } from './commands/sync-bd.js';
|
|
18
21
|
export { SessionRecapFormat, SessionRecapOptions, SessionRecapResult, SessionTurn, buildSessionRecap, formatSessionRecapMarkdown, sessionRecapCommand } from './commands/session-recap.js';
|
|
19
22
|
export { findNearestVaultPath, getVaultPath, resolveVaultPath } from './lib/config.js';
|
|
20
23
|
export { registerCliCommands } from './cli/index.js';
|
|
@@ -156,6 +159,16 @@ declare class ClawVault {
|
|
|
156
159
|
* Parse a handoff document back into structured form
|
|
157
160
|
*/
|
|
158
161
|
private parseHandoff;
|
|
162
|
+
/**
|
|
163
|
+
* Safely convert a date value to ISO string format.
|
|
164
|
+
* Handles Date objects, strings, and undefined values.
|
|
165
|
+
*/
|
|
166
|
+
private toDateString;
|
|
167
|
+
/**
|
|
168
|
+
* Extract the date portion (YYYY-MM-DD) from an ISO date string or Date object.
|
|
169
|
+
* Provides safe handling for various date formats.
|
|
170
|
+
*/
|
|
171
|
+
private extractDatePart;
|
|
159
172
|
private applyQmdConfig;
|
|
160
173
|
private slugify;
|
|
161
174
|
private saveIndex;
|
|
@@ -178,137 +191,52 @@ declare function createVault(vaultPath: string, options?: Partial<VaultConfig>,
|
|
|
178
191
|
skipGraph?: boolean;
|
|
179
192
|
}): Promise<ClawVault>;
|
|
180
193
|
|
|
181
|
-
interface
|
|
194
|
+
interface MigrateCommandOptions {
|
|
182
195
|
vaultPath?: string;
|
|
183
|
-
since?: string;
|
|
184
196
|
dryRun?: boolean;
|
|
185
|
-
|
|
197
|
+
force?: boolean;
|
|
198
|
+
json?: boolean;
|
|
186
199
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
type LegacyObservationPriority = '🔴' | '🟡' | '🟢';
|
|
193
|
-
type ObservationLineKind = 'scored' | 'emoji';
|
|
194
|
-
interface ParsedObservationRecord {
|
|
195
|
-
date: string;
|
|
196
|
-
type: ObservationType;
|
|
197
|
-
confidence: number;
|
|
198
|
-
importance: number;
|
|
199
|
-
content: string;
|
|
200
|
-
format: ObservationLineKind;
|
|
201
|
-
priority?: LegacyObservationPriority;
|
|
202
|
-
time?: string;
|
|
203
|
-
rawLine: string;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Reweave — Backward memory consolidation for ClawVault
|
|
208
|
-
*
|
|
209
|
-
* When new observations are written, reweave performs a backward pass over
|
|
210
|
-
* existing observations to detect knowledge updates (same entity, new value).
|
|
211
|
-
* Older observations are marked as superseded so search always returns the
|
|
212
|
-
* latest version of a fact.
|
|
213
|
-
*
|
|
214
|
-
* Design inspired by Ars Contexta's "notes are hypotheses" philosophy —
|
|
215
|
-
* every observation is a claim that can be superseded by newer evidence.
|
|
216
|
-
*/
|
|
217
|
-
|
|
218
|
-
interface SupersessionRecord {
|
|
219
|
-
/** The older observation that was superseded */
|
|
220
|
-
oldObservation: ParsedObservationRecord;
|
|
221
|
-
/** The newer observation that supersedes it */
|
|
222
|
-
newObservation: ParsedObservationRecord;
|
|
223
|
-
/** File path of the older observation */
|
|
224
|
-
oldFile: string;
|
|
225
|
-
/** File path of the newer observation */
|
|
226
|
-
newFile: string;
|
|
227
|
-
/** Reason for supersession */
|
|
228
|
-
reason: string;
|
|
229
|
-
/** Timestamp of detection */
|
|
230
|
-
detectedAt: string;
|
|
231
|
-
}
|
|
232
|
-
interface ReweaveResult {
|
|
233
|
-
/** Number of observation files scanned */
|
|
234
|
-
filesScanned: number;
|
|
235
|
-
/** Number of individual observations checked */
|
|
236
|
-
observationsChecked: number;
|
|
237
|
-
/** Supersession records found/applied */
|
|
238
|
-
supersessions: SupersessionRecord[];
|
|
239
|
-
/** Whether this was a dry run */
|
|
240
|
-
dryRun: boolean;
|
|
200
|
+
interface MigrationAction {
|
|
201
|
+
type: MigrationIssueType;
|
|
202
|
+
description: string;
|
|
203
|
+
success: boolean;
|
|
204
|
+
error?: string;
|
|
241
205
|
}
|
|
242
|
-
interface
|
|
206
|
+
interface MigrateResult {
|
|
243
207
|
vaultPath: string;
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
dryRun
|
|
248
|
-
/** Similarity threshold for entity matching (0-1). Default 0.6 */
|
|
249
|
-
similarityThreshold?: number;
|
|
208
|
+
issuesFound: number;
|
|
209
|
+
issuesFixed: number;
|
|
210
|
+
actions: MigrationAction[];
|
|
211
|
+
dryRun: boolean;
|
|
250
212
|
}
|
|
251
|
-
declare function
|
|
252
|
-
declare function
|
|
253
|
-
|
|
254
|
-
detectedAt: string;
|
|
255
|
-
} | null;
|
|
256
|
-
/**
|
|
257
|
-
* Extract key entities/subjects from an observation for matching.
|
|
258
|
-
* Returns normalized tokens that represent the "what" of the observation.
|
|
259
|
-
*/
|
|
260
|
-
declare function extractEntities(content: string): string[];
|
|
261
|
-
/**
|
|
262
|
-
* Compute similarity between two observations based on entity overlap.
|
|
263
|
-
* Returns 0-1 where 1 = identical entities.
|
|
264
|
-
*/
|
|
265
|
-
declare function entitySimilarity(a: string[], b: string[]): number;
|
|
266
|
-
/**
|
|
267
|
-
* Check if two observations represent a knowledge update.
|
|
268
|
-
* Both must be about the same entity/subject but with different values.
|
|
269
|
-
*
|
|
270
|
-
* Heuristic: high entity overlap + different observation content = update.
|
|
271
|
-
* Same content = duplicate, not update.
|
|
272
|
-
*/
|
|
273
|
-
declare function isKnowledgeUpdate(older: ParsedObservationRecord, newer: ParsedObservationRecord, threshold?: number): {
|
|
274
|
-
isUpdate: boolean;
|
|
275
|
-
reason: string;
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* Run backward consolidation across observations.
|
|
279
|
-
*
|
|
280
|
-
* For each newer observation, check all older observations for knowledge updates.
|
|
281
|
-
* When found, mark the older one as superseded.
|
|
282
|
-
*/
|
|
283
|
-
declare function reweave(options: ReweaveOptions): ReweaveResult;
|
|
284
|
-
/**
|
|
285
|
-
* Filter search results to prefer latest versions of superseded observations.
|
|
286
|
-
* When multiple observations cover the same entity, only keep the newest.
|
|
287
|
-
*
|
|
288
|
-
* This is called from the search pipeline to boost knowledge update accuracy.
|
|
289
|
-
*/
|
|
290
|
-
declare function filterSuperseded(lines: string[]): string[];
|
|
291
|
-
/**
|
|
292
|
-
* Given observation markdown content, return only non-superseded lines.
|
|
293
|
-
* Preserves date headings and structure.
|
|
294
|
-
*/
|
|
295
|
-
declare function stripSupersededObservations(markdown: string): string;
|
|
213
|
+
declare function migrate(options?: MigrateCommandOptions): Promise<MigrateResult>;
|
|
214
|
+
declare function migrateCommand(options?: MigrateCommandOptions): Promise<MigrateResult>;
|
|
215
|
+
declare function registerMigrateCommand(program: Command): void;
|
|
296
216
|
|
|
297
217
|
/**
|
|
298
218
|
* ClawVault Search Engine - qmd Backend
|
|
299
219
|
* Uses qmd CLI for BM25 and vector search
|
|
300
|
-
*
|
|
301
|
-
* v2.7.0 enhancements:
|
|
302
|
-
* 1. Chunk-level BM25 pre-filtering (from eval v4 adapter)
|
|
303
|
-
* 2. Exhaustive threshold-based retrieval (from eval v6 adapter)
|
|
304
|
-
* 3. Preference extraction pipeline (from eval v3 adapter)
|
|
305
|
-
* 4. Temporal date indexing at ingest time (from eval v8 design)
|
|
306
220
|
*/
|
|
307
221
|
|
|
308
222
|
declare const QMD_INSTALL_URL = "https://github.com/tobi/qmd";
|
|
309
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
|
+
}
|
|
310
230
|
declare class QmdUnavailableError extends Error {
|
|
311
|
-
|
|
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);
|
|
312
240
|
}
|
|
313
241
|
/**
|
|
314
242
|
* Check if qmd is available
|
|
@@ -322,31 +250,6 @@ declare function qmdUpdate(collection?: string, indexName?: string): void;
|
|
|
322
250
|
* Trigger qmd embed (create/update vector embeddings)
|
|
323
251
|
*/
|
|
324
252
|
declare function qmdEmbed(collection?: string, indexName?: string): void;
|
|
325
|
-
/**
|
|
326
|
-
* Split text into ~maxChars sentence-aligned chunks with overlap.
|
|
327
|
-
*/
|
|
328
|
-
declare function sentenceChunk(text: string, maxChars?: number, overlapSentences?: number): string[];
|
|
329
|
-
/**
|
|
330
|
-
* BM25-rank chunks within a document by keyword overlap.
|
|
331
|
-
* Returns the top `max` chunks sorted by relevance, always including the
|
|
332
|
-
* first chunk (session context) when available.
|
|
333
|
-
*/
|
|
334
|
-
declare function bm25RankChunks(chunks: string[], terms: string[], max?: number): {
|
|
335
|
-
text: string;
|
|
336
|
-
score: number;
|
|
337
|
-
}[];
|
|
338
|
-
/**
|
|
339
|
-
* Extract all date references from text content. Designed to run at ingest
|
|
340
|
-
* time so temporal queries can use structured dates + JS arithmetic instead
|
|
341
|
-
* of relying on LLM date math at query time.
|
|
342
|
-
*/
|
|
343
|
-
declare function extractDates(text: string, sessionDateStr?: string): ExtractedDate[];
|
|
344
|
-
/**
|
|
345
|
-
* Extract user preferences from conversation text. Runs at ingest time to
|
|
346
|
-
* build a structured preference index for personalised recommendations.
|
|
347
|
-
*/
|
|
348
|
-
declare function extractPreferences(text: string, documentId?: string): ExtractedPreference[];
|
|
349
|
-
declare function classifyQuestion(q: string): 'preference' | 'temporal' | 'aggregation' | 'default';
|
|
350
253
|
/**
|
|
351
254
|
* QMD Search Engine - wraps qmd CLI
|
|
352
255
|
*/
|
|
@@ -356,16 +259,14 @@ declare class SearchEngine {
|
|
|
356
259
|
private vaultPath;
|
|
357
260
|
private collectionRoot;
|
|
358
261
|
private qmdIndexName?;
|
|
359
|
-
/** v2.7 — Per-document date index built at ingest time */
|
|
360
|
-
private dateIndex;
|
|
361
|
-
/** v2.7 — Per-document preference index built at ingest time */
|
|
362
|
-
private preferenceIndex;
|
|
363
|
-
/** v2.7 — Per-document chunk cache for BM25 pre-filtering */
|
|
364
|
-
private chunkCache;
|
|
365
262
|
/**
|
|
366
263
|
* Set the collection name (usually vault name)
|
|
367
264
|
*/
|
|
368
265
|
setCollection(name: string): void;
|
|
266
|
+
/**
|
|
267
|
+
* Get the current collection name
|
|
268
|
+
*/
|
|
269
|
+
getCollection(): string;
|
|
369
270
|
/**
|
|
370
271
|
* Set the vault path for file resolution
|
|
371
272
|
*/
|
|
@@ -379,8 +280,7 @@ declare class SearchEngine {
|
|
|
379
280
|
*/
|
|
380
281
|
setIndexName(indexName?: string): void;
|
|
381
282
|
/**
|
|
382
|
-
* Add or update a document in the local cache
|
|
383
|
-
* v2.7: also extracts dates, preferences, and chunks at ingest time.
|
|
283
|
+
* Add or update a document in the local cache
|
|
384
284
|
* Note: qmd indexing happens via qmd update command
|
|
385
285
|
*/
|
|
386
286
|
addDocument(doc: Document): void;
|
|
@@ -405,32 +305,6 @@ declare class SearchEngine {
|
|
|
405
305
|
*/
|
|
406
306
|
query(query: string, options?: SearchOptions): SearchResult[];
|
|
407
307
|
private runQmdQuery;
|
|
408
|
-
/**
|
|
409
|
-
* v2.7 — Chunk-level BM25 pre-filtered search. Ranks chunks within each
|
|
410
|
-
* document by keyword relevance before semantic ranking, so relevant
|
|
411
|
-
* content deep in long documents isn't missed.
|
|
412
|
-
*
|
|
413
|
-
* Returns results with snippets from the best-matching chunks.
|
|
414
|
-
*/
|
|
415
|
-
chunkPrefilterSearch(query: string, options?: SearchOptions): SearchResult[];
|
|
416
|
-
/**
|
|
417
|
-
* v2.7 — Exhaustive threshold-based search for aggregation queries.
|
|
418
|
-
* Keeps pulling results until relevance drops below threshold.
|
|
419
|
-
*/
|
|
420
|
-
exhaustiveSearch(query: string, threshold?: number, maxResults?: number): SearchResult[];
|
|
421
|
-
/**
|
|
422
|
-
* v2.7 — Get all extracted dates, optionally filtered by document ids.
|
|
423
|
-
*/
|
|
424
|
-
getDates(documentIds?: string[]): ExtractedDate[];
|
|
425
|
-
/**
|
|
426
|
-
* v2.7 — Get all extracted preferences, optionally filtered by document ids.
|
|
427
|
-
*/
|
|
428
|
-
getPreferences(documentIds?: string[]): ExtractedPreference[];
|
|
429
|
-
/**
|
|
430
|
-
* v2.7 — Search with automatic strategy selection based on question type.
|
|
431
|
-
* Classifies the query and routes to the appropriate pipeline.
|
|
432
|
-
*/
|
|
433
|
-
smartQuery(query: string, options?: SearchOptions): SearchResult[];
|
|
434
308
|
/**
|
|
435
309
|
* Convert qmd results to ClawVault SearchResult format
|
|
436
310
|
*/
|
|
@@ -441,11 +315,6 @@ declare class SearchEngine {
|
|
|
441
315
|
* Convert qmd:// URI to file path
|
|
442
316
|
*/
|
|
443
317
|
private qmdUriToPath;
|
|
444
|
-
/**
|
|
445
|
-
* v2.8 — Filter superseded observation lines from snippet text.
|
|
446
|
-
* Ensures search results prefer the latest version of knowledge.
|
|
447
|
-
*/
|
|
448
|
-
private stripSupersededFromSnippet;
|
|
449
318
|
/**
|
|
450
319
|
* Clean up qmd snippet format
|
|
451
320
|
*/
|
|
@@ -459,7 +328,7 @@ declare class SearchEngine {
|
|
|
459
328
|
*/
|
|
460
329
|
get size(): number;
|
|
461
330
|
/**
|
|
462
|
-
* Clear the local document cache
|
|
331
|
+
* Clear the local document cache
|
|
463
332
|
*/
|
|
464
333
|
clear(): void;
|
|
465
334
|
/**
|
|
@@ -484,15 +353,93 @@ declare function extractWikiLinks(content: string): string[];
|
|
|
484
353
|
*/
|
|
485
354
|
declare function extractTags(content: string): string[];
|
|
486
355
|
|
|
487
|
-
|
|
488
|
-
|
|
356
|
+
/**
|
|
357
|
+
* ClawVault Hybrid Search — BM25 + Semantic Embeddings + RRF
|
|
358
|
+
*
|
|
359
|
+
* Proven in LongMemEval benchmarks:
|
|
360
|
+
* - v28 pipeline: 57.0% overall (up from 52.6% with BM25-only)
|
|
361
|
+
* - Multi-session: 45.9% (up from 28.6%)
|
|
362
|
+
* - Single-session-user: 85.7% (up from 72.9%)
|
|
363
|
+
*
|
|
364
|
+
* Architecture:
|
|
365
|
+
* 1. BM25 via existing qmd search
|
|
366
|
+
* 2. Semantic via @huggingface/transformers (all-MiniLM-L6-v2)
|
|
367
|
+
* 3. Reciprocal Rank Fusion (k=60)
|
|
368
|
+
*/
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Compute embedding for a text string
|
|
372
|
+
*/
|
|
373
|
+
declare function embed(text: string): Promise<Float32Array>;
|
|
374
|
+
/**
|
|
375
|
+
* Compute embeddings for multiple texts
|
|
376
|
+
*/
|
|
377
|
+
declare function embedBatch(texts: string[]): Promise<Float32Array[]>;
|
|
378
|
+
/**
|
|
379
|
+
* Cosine similarity between two normalized vectors
|
|
380
|
+
*/
|
|
381
|
+
declare function cosineSimilarity(a: Float32Array, b: Float32Array): number;
|
|
382
|
+
/**
|
|
383
|
+
* Embedding cache — stores embeddings on disk alongside vault files
|
|
384
|
+
*/
|
|
385
|
+
declare class EmbeddingCache {
|
|
386
|
+
private cachePath;
|
|
387
|
+
private cache;
|
|
388
|
+
private dirty;
|
|
389
|
+
constructor(vaultPath: string);
|
|
390
|
+
/**
|
|
391
|
+
* Load cache from disk
|
|
392
|
+
*/
|
|
393
|
+
load(): void;
|
|
394
|
+
/**
|
|
395
|
+
* Save cache to disk
|
|
396
|
+
*/
|
|
397
|
+
save(): void;
|
|
398
|
+
get(key: string): Float32Array | undefined;
|
|
399
|
+
set(key: string, embedding: Float32Array): void;
|
|
400
|
+
has(key: string): boolean;
|
|
401
|
+
entries(): IterableIterator<[string, Float32Array]>;
|
|
402
|
+
get size(): number;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Reciprocal Rank Fusion of two ranked lists
|
|
406
|
+
*/
|
|
407
|
+
declare function reciprocalRankFusion(list1: {
|
|
408
|
+
id: string;
|
|
409
|
+
score: number;
|
|
410
|
+
}[], list2: {
|
|
411
|
+
id: string;
|
|
412
|
+
score: number;
|
|
413
|
+
}[], k?: number): {
|
|
414
|
+
id: string;
|
|
415
|
+
score: number;
|
|
416
|
+
}[];
|
|
417
|
+
/**
|
|
418
|
+
* Semantic search against embedding cache
|
|
419
|
+
*/
|
|
420
|
+
declare function semanticSearch(query: string, cache: EmbeddingCache, topK?: number): Promise<{
|
|
421
|
+
id: string;
|
|
422
|
+
score: number;
|
|
423
|
+
}[]>;
|
|
424
|
+
/**
|
|
425
|
+
* Hybrid search: combines BM25 results with semantic results via RRF
|
|
426
|
+
*/
|
|
427
|
+
declare function hybridSearch(query: string, bm25Results: SearchResult[], cache: EmbeddingCache, options?: {
|
|
428
|
+
topK?: number;
|
|
429
|
+
rrfK?: number;
|
|
430
|
+
}): Promise<SearchResult[]>;
|
|
431
|
+
|
|
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"];
|
|
489
434
|
declare const THEMES: readonly ["neural", "minimal", "none"];
|
|
490
435
|
declare const CONTEXT_PROFILES: readonly ["default", "planning", "incident", "handoff", "auto"];
|
|
436
|
+
declare const FACT_EXTRACTION_MODES: readonly ["off", "rule", "llm", "hybrid"];
|
|
491
437
|
type ObserveProvider = (typeof OBSERVE_PROVIDERS)[number];
|
|
492
438
|
type ObserverCompressionProvider = (typeof OBSERVER_COMPRESSION_PROVIDERS)[number];
|
|
493
439
|
type Theme = (typeof THEMES)[number];
|
|
494
440
|
type ContextProfile = (typeof CONTEXT_PROFILES)[number];
|
|
495
|
-
type
|
|
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';
|
|
496
443
|
interface RouteRule {
|
|
497
444
|
pattern: string;
|
|
498
445
|
target: string;
|
|
@@ -513,6 +460,198 @@ declare function removeRouteRule(vaultPath: string, pattern: string): boolean;
|
|
|
513
460
|
declare function matchRouteRule(text: string, routes: RouteRule[]): RouteRule | null;
|
|
514
461
|
declare function testRouteRule(vaultPath: string, text: string): RouteRule | null;
|
|
515
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. If Ollama is running locally, use Ollama (free, always available)
|
|
510
|
+
* 4. Fall back to default provider resolution
|
|
511
|
+
*/
|
|
512
|
+
declare function createFactExtractionAdapter(options?: LlmAdapterOptions): LlmAdapter;
|
|
513
|
+
/**
|
|
514
|
+
* Create an LLM function compatible with extractFactsLlm.
|
|
515
|
+
* This wraps the adapter into the function signature expected by fact-extractor.ts.
|
|
516
|
+
*/
|
|
517
|
+
declare function createLlmFunction(adapter: LlmAdapter): ((prompt: string) => Promise<string>) | undefined;
|
|
518
|
+
/**
|
|
519
|
+
* Resolve the effective fact extraction mode based on configuration and availability.
|
|
520
|
+
*
|
|
521
|
+
* - 'off': Never extract facts
|
|
522
|
+
* - 'rule': Only use rule-based extraction (no LLM)
|
|
523
|
+
* - 'llm': Prefer LLM extraction, fall back to rules if LLM unavailable
|
|
524
|
+
* - 'hybrid': Use both LLM and rules, merge results (future enhancement)
|
|
525
|
+
*/
|
|
526
|
+
declare function resolveFactExtractionMode(configuredMode: FactExtractionMode | undefined, adapter?: LlmAdapter): {
|
|
527
|
+
mode: FactExtractionMode;
|
|
528
|
+
useLlm: boolean;
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Write-time fact extraction for ClawVault v3.
|
|
533
|
+
*
|
|
534
|
+
* When a memory is stored, this module extracts structured facts:
|
|
535
|
+
* (entity, relation, value, timestamp, confidence)
|
|
536
|
+
*
|
|
537
|
+
* Two modes:
|
|
538
|
+
* 1. LLM extraction (accurate but requires API key)
|
|
539
|
+
* 2. Rule-based extraction (fast, no deps, lower quality)
|
|
540
|
+
*
|
|
541
|
+
* Extracted facts are stored alongside raw markdown in .clawvault/facts.jsonl
|
|
542
|
+
* and used to build the entity-relationship graph.
|
|
543
|
+
*/
|
|
544
|
+
interface ExtractedFact {
|
|
545
|
+
/** Unique ID for this fact */
|
|
546
|
+
id: string;
|
|
547
|
+
/** The entity this fact is about (person, place, thing) */
|
|
548
|
+
entity: string;
|
|
549
|
+
/** Normalized entity name for dedup */
|
|
550
|
+
entityNorm: string;
|
|
551
|
+
/** Relationship type (e.g., "prefers", "works_at", "lives_in", "bought") */
|
|
552
|
+
relation: string;
|
|
553
|
+
/** The value/object of the relation */
|
|
554
|
+
value: string;
|
|
555
|
+
/** When this fact was established */
|
|
556
|
+
validFrom: string;
|
|
557
|
+
/** When this fact was superseded (null = still current) */
|
|
558
|
+
validUntil: string | null;
|
|
559
|
+
/** Confidence 0-1 */
|
|
560
|
+
confidence: number;
|
|
561
|
+
/** Category: preference, fact, decision, entity, event */
|
|
562
|
+
category: 'preference' | 'fact' | 'decision' | 'entity' | 'event' | 'other';
|
|
563
|
+
/** Source file path (relative to vault) */
|
|
564
|
+
source: string;
|
|
565
|
+
/** Raw text this was extracted from */
|
|
566
|
+
rawText: string;
|
|
567
|
+
}
|
|
568
|
+
interface ExtractionResult {
|
|
569
|
+
facts: ExtractedFact[];
|
|
570
|
+
/** Number of conflicts resolved (existing facts updated) */
|
|
571
|
+
conflictsResolved: number;
|
|
572
|
+
/** Processing time in ms */
|
|
573
|
+
durationMs: number;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Normalize an entity name for dedup matching.
|
|
577
|
+
* "Pedro Sobral" -> "pedro sobral"
|
|
578
|
+
* "pedro" -> "pedro"
|
|
579
|
+
* "Dr. Smith" -> "dr smith"
|
|
580
|
+
*/
|
|
581
|
+
declare function normalizeEntity(name: string): string;
|
|
582
|
+
/**
|
|
583
|
+
* Generate a deterministic fact ID from entity + relation + value.
|
|
584
|
+
*/
|
|
585
|
+
declare function factId(entity: string, relation: string, value: string): string;
|
|
586
|
+
/**
|
|
587
|
+
* Extract facts from raw text using rule-based patterns.
|
|
588
|
+
* Fast, no LLM needed, but lower quality.
|
|
589
|
+
*/
|
|
590
|
+
declare function extractFactsRuleBased(text: string, source: string, timestamp?: string): ExtractedFact[];
|
|
591
|
+
/**
|
|
592
|
+
* Extract facts using an LLM. Higher quality but requires API key.
|
|
593
|
+
* Falls back to rule-based if LLM unavailable.
|
|
594
|
+
*/
|
|
595
|
+
declare function extractFactsLlm(text: string, source: string, timestamp?: string, llmFn?: (prompt: string) => Promise<string>): Promise<ExtractedFact[]>;
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Fact Store — persistent storage + conflict resolution for extracted facts.
|
|
599
|
+
*
|
|
600
|
+
* Facts are stored in .clawvault/facts.jsonl (append-only log).
|
|
601
|
+
* An in-memory index enables fast lookup by entity, relation, category.
|
|
602
|
+
* Conflict resolution: when a new fact matches an existing one by entity+relation,
|
|
603
|
+
* the old fact gets validUntil set and the new fact replaces it.
|
|
604
|
+
*/
|
|
605
|
+
|
|
606
|
+
interface FactStoreStats {
|
|
607
|
+
totalFacts: number;
|
|
608
|
+
activeFacts: number;
|
|
609
|
+
supersededFacts: number;
|
|
610
|
+
entities: number;
|
|
611
|
+
relations: number;
|
|
612
|
+
}
|
|
613
|
+
declare class FactStore {
|
|
614
|
+
private facts;
|
|
615
|
+
private byEntity;
|
|
616
|
+
private byRelation;
|
|
617
|
+
private byCategory;
|
|
618
|
+
private factsPath;
|
|
619
|
+
private dirty;
|
|
620
|
+
constructor(vaultPath: string);
|
|
621
|
+
/** Load facts from disk */
|
|
622
|
+
load(): void;
|
|
623
|
+
/** Add facts with conflict resolution. Returns number of conflicts resolved. */
|
|
624
|
+
addFacts(newFacts: ExtractedFact[]): number;
|
|
625
|
+
/** Find an existing fact that conflicts with the new one */
|
|
626
|
+
private findConflict;
|
|
627
|
+
/** Check if two values are similar enough to be considered the same fact */
|
|
628
|
+
private isSimilarValue;
|
|
629
|
+
/** Relations where only one value can be active at a time */
|
|
630
|
+
private isExclusiveRelation;
|
|
631
|
+
/** Index a fact in all lookup maps */
|
|
632
|
+
private indexFact;
|
|
633
|
+
/** Save facts to disk (full rewrite for consistency) */
|
|
634
|
+
save(): void;
|
|
635
|
+
/** Append new facts to disk (faster than full rewrite) */
|
|
636
|
+
append(facts: ExtractedFact[]): void;
|
|
637
|
+
/** Get all active facts for an entity */
|
|
638
|
+
getEntityFacts(entity: string): ExtractedFact[];
|
|
639
|
+
/** Get all active facts for a relation */
|
|
640
|
+
getRelationFacts(relation: string): ExtractedFact[];
|
|
641
|
+
/** Get all active facts in a category */
|
|
642
|
+
getCategoryFacts(category: string): ExtractedFact[];
|
|
643
|
+
/** Get all active preferences */
|
|
644
|
+
getPreferences(): ExtractedFact[];
|
|
645
|
+
/** Search facts by text query (simple keyword match) */
|
|
646
|
+
searchFacts(query: string): ExtractedFact[];
|
|
647
|
+
/** Get facts valid at a specific time */
|
|
648
|
+
getFactsAt(timestamp: string): ExtractedFact[];
|
|
649
|
+
/** Get stats */
|
|
650
|
+
stats(): FactStoreStats;
|
|
651
|
+
/** Get all facts (for testing/debugging) */
|
|
652
|
+
getAllFacts(): ExtractedFact[];
|
|
653
|
+
}
|
|
654
|
+
|
|
516
655
|
/**
|
|
517
656
|
* Transition Ledger for ClawVault
|
|
518
657
|
* Logs task status transitions to JSONL files and supports querying.
|
|
@@ -569,7 +708,7 @@ interface CompressorOptions {
|
|
|
569
708
|
now?: () => Date;
|
|
570
709
|
fetchImpl?: typeof fetch;
|
|
571
710
|
}
|
|
572
|
-
type CompressionProvider = 'anthropic' | 'openai' | 'gemini' | 'openai-compatible' | 'ollama';
|
|
711
|
+
type CompressionProvider = 'anthropic' | 'openai' | 'gemini' | 'xai' | 'openai-compatible' | 'ollama' | 'minimax' | 'zai';
|
|
573
712
|
declare class Compressor {
|
|
574
713
|
private readonly provider?;
|
|
575
714
|
private readonly model?;
|
|
@@ -579,6 +718,13 @@ declare class Compressor {
|
|
|
579
718
|
private readonly fetchImpl;
|
|
580
719
|
constructor(options?: CompressorOptions);
|
|
581
720
|
compress(messages: string[], existingObservations: string): Promise<string>;
|
|
721
|
+
private sanitizeIncomingMessages;
|
|
722
|
+
private sanitizeIncomingMessage;
|
|
723
|
+
private normalizeMessageRole;
|
|
724
|
+
private isConversationRolePrefix;
|
|
725
|
+
private shouldDropMessageRole;
|
|
726
|
+
private stripNoisyData;
|
|
727
|
+
private isLikelyStructuredNoise;
|
|
582
728
|
private resolveProvider;
|
|
583
729
|
private resolveConfiguredProvider;
|
|
584
730
|
private resolveProviderFromEnv;
|
|
@@ -592,6 +738,7 @@ declare class Compressor {
|
|
|
592
738
|
private extractOpenAIContent;
|
|
593
739
|
private callAnthropic;
|
|
594
740
|
private callOpenAI;
|
|
741
|
+
private callXAI;
|
|
595
742
|
private callOpenAICompatible;
|
|
596
743
|
private callGemini;
|
|
597
744
|
private normalizeLlmOutput;
|
|
@@ -700,7 +847,6 @@ interface ActiveObserveOptions {
|
|
|
700
847
|
reflectThreshold?: number;
|
|
701
848
|
model?: string;
|
|
702
849
|
extractTasks?: boolean;
|
|
703
|
-
maxSessions?: number;
|
|
704
850
|
}
|
|
705
851
|
interface ActiveObservationCandidate {
|
|
706
852
|
sessionId: string;
|
|
@@ -855,4 +1001,4 @@ declare function runReflection(options: ReflectOptions): Promise<ReflectResult>;
|
|
|
855
1001
|
declare const VERSION: string;
|
|
856
1002
|
declare function registerCommanderCommands(program: Command): Command;
|
|
857
1003
|
|
|
858
|
-
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,
|
|
1004
|
+
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 };
|