clawvault 3.2.0 → 3.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/README.md +54 -14
- package/bin/clawvault.js +0 -2
- package/bin/command-registration.test.js +13 -1
- package/bin/help-contract.test.js +14 -0
- package/bin/register-core-commands.js +88 -0
- package/bin/register-core-commands.test.js +80 -0
- package/bin/register-maintenance-commands.js +57 -6
- package/bin/register-query-commands.js +10 -28
- package/bin/test-helpers/cli-command-fixtures.js +1 -0
- package/dist/chunk-2PKBIKDH.js +130 -0
- package/dist/{chunk-2JQ3O2YL.js → chunk-5EFSWZO6.js} +3 -3
- package/dist/{chunk-77Q5CSPJ.js → chunk-7SWP5FKU.js} +33 -701
- package/dist/{chunk-URXDAUVH.js → chunk-AXSJIFOJ.js} +174 -1
- package/dist/{chunk-23YDQ3QU.js → chunk-BLQXXX7Q.js} +6 -6
- package/dist/chunk-CSHO3PJB.js +684 -0
- package/dist/{chunk-SLXOR3CC.js → chunk-DOIUYIXV.js} +2 -2
- package/dist/{chunk-NCKFNBHJ.js → chunk-DVOUSOR3.js} +79 -5
- package/dist/{chunk-CLJTREDS.js → chunk-ECGJYWNA.js} +193 -41
- package/dist/{chunk-BUEW6IIK.js → chunk-EL6UBSX5.js} +5 -5
- package/dist/{chunk-6FH3IULF.js → chunk-FZ5I2NF7.js} +1 -1
- package/dist/{chunk-ZN54U2OZ.js → chunk-GFCHWMGD.js} +3 -3
- package/dist/{chunk-GNJL4YGR.js → chunk-GJO3CFUN.js} +30 -6
- package/dist/chunk-H3JZIB5O.js +322 -0
- package/dist/chunk-HEHO7SMV.js +51 -0
- package/dist/{chunk-STCQGCEQ.js → chunk-HGDDW24U.js} +3 -3
- package/dist/chunk-J3YUXVID.js +907 -0
- package/dist/{chunk-Y6VJKXGL.js → chunk-KCYWJDDW.js} +1 -1
- package/dist/{chunk-W4SPAEE7.js → chunk-OFOCU2V4.js} +5 -4
- package/dist/chunk-PTWPPVC7.js +972 -0
- package/dist/{chunk-QSHD36LH.js → chunk-QFWERBDP.js} +2 -2
- package/dist/{chunk-QSRRMEYM.js → chunk-S7N7HI5E.js} +1 -1
- package/dist/{chunk-PBACDKKP.js → chunk-T7E764W3.js} +3 -3
- package/dist/chunk-TDWFBDAQ.js +1016 -0
- package/dist/{chunk-ESVS6K2B.js → chunk-TWMI3SNN.js} +6 -5
- package/dist/{chunk-2RAZ4ZFE.js → chunk-VBILES4B.js} +1 -1
- package/dist/{chunk-ESFLMDRB.js → chunk-VXAGOLDP.js} +3 -3
- package/dist/chunk-YCUVAOFC.js +158 -0
- package/dist/{chunk-SS4B7P7V.js → chunk-YIDV4VV2.js} +1 -1
- package/dist/chunk-ZKWPCBYT.js +600 -0
- package/dist/cli/index.js +24 -24
- package/dist/commands/archive.js +2 -2
- package/dist/commands/benchmark.d.ts +12 -0
- package/dist/commands/benchmark.js +12 -0
- package/dist/commands/context.js +6 -5
- package/dist/commands/doctor.d.ts +8 -3
- package/dist/commands/doctor.js +6 -20
- package/dist/commands/embed.js +5 -4
- package/dist/commands/entities.js +1 -1
- package/dist/commands/graph.js +2 -2
- package/dist/commands/inbox.d.ts +23 -0
- package/dist/commands/inbox.js +11 -0
- package/dist/commands/inject.d.ts +1 -1
- package/dist/commands/inject.js +3 -3
- package/dist/commands/link.js +6 -6
- package/dist/commands/maintain.d.ts +32 -0
- package/dist/commands/maintain.js +12 -0
- package/dist/commands/migrate-observations.js +2 -2
- package/dist/commands/observe.js +9 -8
- package/dist/commands/rebuild-embeddings.js +47 -16
- package/dist/commands/rebuild.js +7 -6
- package/dist/commands/reflect.js +5 -5
- package/dist/commands/replay.js +8 -7
- package/dist/commands/setup.js +3 -2
- package/dist/commands/sleep.d.ts +1 -1
- package/dist/commands/sleep.js +17 -15
- package/dist/commands/status.js +26 -24
- package/dist/commands/sync-bd.js +2 -2
- package/dist/commands/tailscale.js +2 -2
- package/dist/commands/wake.d.ts +1 -1
- package/dist/commands/wake.js +8 -7
- package/dist/index.d.ts +168 -16
- package/dist/index.js +271 -108
- package/dist/{inject-DYUrDqQO.d.ts → inject-DEb_jpLi.d.ts} +3 -1
- package/dist/lib/config.js +1 -1
- package/dist/{types-BbWJoC1c.d.ts → types-DslKvCaj.d.ts} +51 -1
- package/hooks/clawvault/HOOK.md +22 -5
- package/hooks/clawvault/handler.js +213 -78
- package/hooks/clawvault/handler.test.js +109 -43
- package/hooks/clawvault/integrity.js +112 -0
- package/hooks/clawvault/integrity.test.js +32 -0
- package/hooks/clawvault/openclaw.plugin.json +133 -15
- package/openclaw.plugin.json +126 -20
- package/package.json +2 -2
- package/bin/register-workgraph-commands.js +0 -1368
- package/dist/chunk-33VSQP4J.js +0 -37
- package/dist/chunk-4BQTQMJP.js +0 -93
- package/dist/chunk-EK6S23ZB.js +0 -469
- package/dist/chunk-GAOWA7GR.js +0 -501
- package/dist/chunk-GGA32J2R.js +0 -784
- package/dist/chunk-MM6QGW3P.js +0 -207
- package/dist/chunk-QVEERJSP.js +0 -152
- package/dist/chunk-U4O6C46S.js +0 -154
- package/dist/chunk-VSL7KY3M.js +0 -189
- package/dist/chunk-WMGIIABP.js +0 -15
- package/dist/commands/workgraph.d.ts +0 -124
- package/dist/commands/workgraph.js +0 -38
- package/dist/ledger-B7g7jhqG.d.ts +0 -44
- package/dist/registry-BR4326o0.d.ts +0 -30
- package/dist/store-CA-6sKCJ.d.ts +0 -34
- package/dist/thread-B9LhXNU0.d.ts +0 -41
- package/dist/workgraph/index.d.ts +0 -5
- package/dist/workgraph/index.js +0 -23
- package/dist/workgraph/ledger.d.ts +0 -2
- package/dist/workgraph/ledger.js +0 -25
- package/dist/workgraph/registry.d.ts +0 -2
- package/dist/workgraph/registry.js +0 -19
- package/dist/workgraph/store.d.ts +0 -2
- package/dist/workgraph/store.js +0 -25
- package/dist/workgraph/thread.d.ts +0 -2
- package/dist/workgraph/thread.js +0 -25
- package/dist/workgraph/types.d.ts +0 -54
- package/dist/workgraph/types.js +0 -7
package/dist/index.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
registerSyncBdCommand,
|
|
3
|
+
syncBdCommand
|
|
4
|
+
} from "./chunk-YIDV4VV2.js";
|
|
5
|
+
import {
|
|
6
|
+
rebuildCommand,
|
|
7
|
+
registerRebuildCommand
|
|
8
|
+
} from "./chunk-QFWERBDP.js";
|
|
1
9
|
import {
|
|
2
10
|
registerReplayCommand,
|
|
3
11
|
replayCommand
|
|
4
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-HGDDW24U.js";
|
|
5
13
|
import {
|
|
6
14
|
buildSessionRecap,
|
|
7
15
|
formatSessionRecapMarkdown,
|
|
@@ -9,57 +17,37 @@ import {
|
|
|
9
17
|
} from "./chunk-ZKGY7WTT.js";
|
|
10
18
|
import {
|
|
11
19
|
setupCommand
|
|
12
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-EL6UBSX5.js";
|
|
13
21
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
buildKanbanLanes,
|
|
23
|
+
extractCardSlug,
|
|
24
|
+
formatKanbanCard,
|
|
25
|
+
generateKanbanMarkdown,
|
|
26
|
+
importKanbanBoard,
|
|
27
|
+
kanbanCommand,
|
|
28
|
+
parseKanbanMarkdown,
|
|
29
|
+
syncKanbanBoard
|
|
30
|
+
} from "./chunk-4OXMU5S2.js";
|
|
17
31
|
import {
|
|
18
32
|
migrateObservations,
|
|
19
33
|
migrateObservationsCommand,
|
|
20
34
|
registerMigrateObservationsCommand
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import {
|
|
23
|
-
EmbeddingCache,
|
|
24
|
-
cosineSimilarity,
|
|
25
|
-
embed,
|
|
26
|
-
embedBatch,
|
|
27
|
-
hybridSearch,
|
|
28
|
-
reciprocalRankFusion,
|
|
29
|
-
semanticSearch
|
|
30
|
-
} from "./chunk-U4O6C46S.js";
|
|
31
|
-
import {
|
|
32
|
-
rebuildCommand,
|
|
33
|
-
registerRebuildCommand
|
|
34
|
-
} from "./chunk-QSHD36LH.js";
|
|
35
|
-
import {
|
|
36
|
-
doctor
|
|
37
|
-
} from "./chunk-GAOWA7GR.js";
|
|
38
|
-
import "./chunk-7YZWHM36.js";
|
|
39
|
-
import "./chunk-7ZRP733D.js";
|
|
35
|
+
} from "./chunk-5EFSWZO6.js";
|
|
40
36
|
import {
|
|
41
37
|
checkOpenClawCompatibility,
|
|
42
38
|
compatCommand,
|
|
43
39
|
compatibilityExitCode
|
|
44
40
|
} from "./chunk-X3SPPUFG.js";
|
|
45
|
-
import
|
|
41
|
+
import {
|
|
42
|
+
doctor
|
|
43
|
+
} from "./chunk-CSHO3PJB.js";
|
|
46
44
|
import {
|
|
47
45
|
graphCommand,
|
|
48
46
|
graphSummary
|
|
49
|
-
} from "./chunk-
|
|
50
|
-
import {
|
|
51
|
-
buildKanbanLanes,
|
|
52
|
-
extractCardSlug,
|
|
53
|
-
formatKanbanCard,
|
|
54
|
-
generateKanbanMarkdown,
|
|
55
|
-
importKanbanBoard,
|
|
56
|
-
kanbanCommand,
|
|
57
|
-
parseKanbanMarkdown,
|
|
58
|
-
syncKanbanBoard
|
|
59
|
-
} from "./chunk-4OXMU5S2.js";
|
|
47
|
+
} from "./chunk-S7N7HI5E.js";
|
|
60
48
|
import {
|
|
61
49
|
registerCliCommands
|
|
62
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-YCUVAOFC.js";
|
|
63
51
|
import {
|
|
64
52
|
registerTailscaleCommands,
|
|
65
53
|
registerTailscaleDiscoverCommand,
|
|
@@ -70,7 +58,7 @@ import {
|
|
|
70
58
|
tailscaleServeCommand,
|
|
71
59
|
tailscaleStatusCommand,
|
|
72
60
|
tailscaleSyncCommand
|
|
73
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-KCYWJDDW.js";
|
|
74
62
|
import {
|
|
75
63
|
CLAWVAULT_SERVE_PATH,
|
|
76
64
|
DEFAULT_SERVE_PORT,
|
|
@@ -93,45 +81,37 @@ import {
|
|
|
93
81
|
syncWithPeer
|
|
94
82
|
} from "./chunk-TIGW564L.js";
|
|
95
83
|
import "./chunk-IVRIKYFE.js";
|
|
96
|
-
import "./chunk-GGA32J2R.js";
|
|
97
|
-
import "./chunk-VSL7KY3M.js";
|
|
98
|
-
import "./chunk-QVEERJSP.js";
|
|
99
|
-
import "./chunk-4BQTQMJP.js";
|
|
100
|
-
import "./chunk-MM6QGW3P.js";
|
|
101
|
-
import "./chunk-WMGIIABP.js";
|
|
102
|
-
import {
|
|
103
|
-
SessionWatcher,
|
|
104
|
-
observeCommand,
|
|
105
|
-
registerObserveCommand
|
|
106
|
-
} from "./chunk-23YDQ3QU.js";
|
|
107
|
-
import {
|
|
108
|
-
parseSessionFile
|
|
109
|
-
} from "./chunk-MW5C6ZQA.js";
|
|
110
84
|
import {
|
|
111
85
|
reflectCommand,
|
|
112
86
|
registerReflectCommand
|
|
113
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-DOIUYIXV.js";
|
|
114
88
|
import {
|
|
115
89
|
runReflection
|
|
116
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-TWMI3SNN.js";
|
|
117
91
|
import {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
92
|
+
buildInjectionResult,
|
|
93
|
+
deterministicInjectMatches,
|
|
94
|
+
indexInjectableItems,
|
|
95
|
+
injectCommand,
|
|
96
|
+
registerInjectCommand,
|
|
97
|
+
runPromptInjection
|
|
98
|
+
} from "./chunk-OFOCU2V4.js";
|
|
99
|
+
import {
|
|
100
|
+
maintainCommand,
|
|
101
|
+
registerMaintainCommand
|
|
102
|
+
} from "./chunk-TDWFBDAQ.js";
|
|
103
|
+
import {
|
|
104
|
+
SessionWatcher,
|
|
105
|
+
observeCommand,
|
|
106
|
+
registerObserveCommand
|
|
107
|
+
} from "./chunk-BLQXXX7Q.js";
|
|
126
108
|
import {
|
|
127
109
|
getObserverStaleness,
|
|
128
110
|
getScaledObservationThresholdBytes,
|
|
129
111
|
observeActiveSessions,
|
|
130
112
|
parseSessionSourceLabel
|
|
131
|
-
} from "./chunk-
|
|
132
|
-
import "./chunk-HRLWZGMA.js";
|
|
113
|
+
} from "./chunk-VXAGOLDP.js";
|
|
133
114
|
import {
|
|
134
|
-
Compressor,
|
|
135
115
|
Observer,
|
|
136
116
|
Reflector,
|
|
137
117
|
createDefaultAdapter,
|
|
@@ -139,7 +119,12 @@ import {
|
|
|
139
119
|
createGeminiFlashAdapter,
|
|
140
120
|
createLlmFunction,
|
|
141
121
|
resolveFactExtractionMode
|
|
142
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-7SWP5FKU.js";
|
|
123
|
+
import "./chunk-HRLWZGMA.js";
|
|
124
|
+
import {
|
|
125
|
+
requestLlmCompletion,
|
|
126
|
+
resolveLlmProvider
|
|
127
|
+
} from "./chunk-DVOUSOR3.js";
|
|
143
128
|
import {
|
|
144
129
|
archiveProject,
|
|
145
130
|
createProject,
|
|
@@ -150,10 +135,27 @@ import {
|
|
|
150
135
|
updateProject
|
|
151
136
|
} from "./chunk-4PY655YM.js";
|
|
152
137
|
import {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
138
|
+
SUPPORTED_CONFIG_KEYS,
|
|
139
|
+
addRouteRule,
|
|
140
|
+
getConfig,
|
|
141
|
+
getConfigValue,
|
|
142
|
+
listConfig,
|
|
143
|
+
listRouteRules,
|
|
144
|
+
matchRouteRule,
|
|
145
|
+
removeRouteRule,
|
|
146
|
+
resetConfig,
|
|
147
|
+
setConfigValue,
|
|
148
|
+
testRouteRule
|
|
149
|
+
} from "./chunk-AXSJIFOJ.js";
|
|
150
|
+
import {
|
|
151
|
+
buildContext,
|
|
152
|
+
contextCommand,
|
|
153
|
+
formatContextMarkdown,
|
|
154
|
+
inferContextProfile,
|
|
155
|
+
normalizeContextProfileInput,
|
|
156
|
+
registerContextCommand,
|
|
157
|
+
resolveContextProfile
|
|
158
|
+
} from "./chunk-GFCHWMGD.js";
|
|
157
159
|
import {
|
|
158
160
|
FactStore,
|
|
159
161
|
extractFactsLlm,
|
|
@@ -161,15 +163,25 @@ import {
|
|
|
161
163
|
factId,
|
|
162
164
|
normalizeEntity
|
|
163
165
|
} from "./chunk-BSJ6RIT7.js";
|
|
164
|
-
import
|
|
166
|
+
import {
|
|
167
|
+
ClawVault,
|
|
168
|
+
createVault,
|
|
169
|
+
findVault
|
|
170
|
+
} from "./chunk-ECGJYWNA.js";
|
|
171
|
+
import {
|
|
172
|
+
DEFAULT_CATEGORIES,
|
|
173
|
+
DEFAULT_CONFIG,
|
|
174
|
+
MEMORY_TYPES,
|
|
175
|
+
TYPE_TO_CATEGORY
|
|
176
|
+
} from "./chunk-2CDEETQN.js";
|
|
165
177
|
import {
|
|
166
178
|
embedCommand,
|
|
167
179
|
registerEmbedCommand
|
|
168
|
-
} from "./chunk-
|
|
180
|
+
} from "./chunk-T7E764W3.js";
|
|
169
181
|
import {
|
|
170
182
|
loadVaultQmdConfig,
|
|
171
183
|
removeQmdCollection
|
|
172
|
-
} from "./chunk-
|
|
184
|
+
} from "./chunk-FZ5I2NF7.js";
|
|
173
185
|
import {
|
|
174
186
|
QMD_INSTALL_COMMAND,
|
|
175
187
|
QMD_INSTALL_URL,
|
|
@@ -182,42 +194,17 @@ import {
|
|
|
182
194
|
hasQmd,
|
|
183
195
|
qmdEmbed,
|
|
184
196
|
qmdUpdate
|
|
185
|
-
} from "./chunk-
|
|
197
|
+
} from "./chunk-PTWPPVC7.js";
|
|
198
|
+
import "./chunk-H3JZIB5O.js";
|
|
186
199
|
import {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
registerInjectCommand,
|
|
192
|
-
runPromptInjection
|
|
193
|
-
} from "./chunk-W4SPAEE7.js";
|
|
194
|
-
import {
|
|
195
|
-
SUPPORTED_CONFIG_KEYS,
|
|
196
|
-
addRouteRule,
|
|
197
|
-
getConfig,
|
|
198
|
-
getConfigValue,
|
|
199
|
-
listConfig,
|
|
200
|
-
listRouteRules,
|
|
201
|
-
matchRouteRule,
|
|
202
|
-
removeRouteRule,
|
|
203
|
-
resetConfig,
|
|
204
|
-
setConfigValue,
|
|
205
|
-
testRouteRule
|
|
206
|
-
} from "./chunk-URXDAUVH.js";
|
|
207
|
-
import {
|
|
208
|
-
requestLlmCompletion,
|
|
209
|
-
resolveLlmProvider
|
|
210
|
-
} from "./chunk-NCKFNBHJ.js";
|
|
211
|
-
import {
|
|
212
|
-
DEFAULT_CATEGORIES,
|
|
213
|
-
DEFAULT_CONFIG,
|
|
214
|
-
MEMORY_TYPES,
|
|
215
|
-
TYPE_TO_CATEGORY
|
|
216
|
-
} from "./chunk-2CDEETQN.js";
|
|
200
|
+
inboxAddCommand,
|
|
201
|
+
registerInboxCommand
|
|
202
|
+
} from "./chunk-HEHO7SMV.js";
|
|
203
|
+
import "./chunk-2PKBIKDH.js";
|
|
217
204
|
import {
|
|
218
205
|
archiveCommand,
|
|
219
206
|
registerArchiveCommand
|
|
220
|
-
} from "./chunk-
|
|
207
|
+
} from "./chunk-VBILES4B.js";
|
|
221
208
|
import {
|
|
222
209
|
archiveObservations
|
|
223
210
|
} from "./chunk-MQUJNOHK.js";
|
|
@@ -225,7 +212,25 @@ import {
|
|
|
225
212
|
findNearestVaultPath,
|
|
226
213
|
getVaultPath,
|
|
227
214
|
resolveVaultPath
|
|
228
|
-
} from "./chunk-
|
|
215
|
+
} from "./chunk-GJO3CFUN.js";
|
|
216
|
+
import {
|
|
217
|
+
benchmarkObserverCommand,
|
|
218
|
+
compareObservationText,
|
|
219
|
+
extractKeywordSetFromTranscript,
|
|
220
|
+
formatObserverBenchmarkSummary,
|
|
221
|
+
loadObserverBenchmarkFixtures,
|
|
222
|
+
matchObservationRecords,
|
|
223
|
+
registerBenchmarkCommand,
|
|
224
|
+
runObserverBenchmark,
|
|
225
|
+
scoreFixtureObservations
|
|
226
|
+
} from "./chunk-ZKWPCBYT.js";
|
|
227
|
+
import {
|
|
228
|
+
parseSessionFile
|
|
229
|
+
} from "./chunk-MW5C6ZQA.js";
|
|
230
|
+
import {
|
|
231
|
+
Compressor
|
|
232
|
+
} from "./chunk-J3YUXVID.js";
|
|
233
|
+
import "./chunk-FHFUXL6G.js";
|
|
229
234
|
import {
|
|
230
235
|
MEMORY_GRAPH_SCHEMA_VERSION,
|
|
231
236
|
buildOrUpdateMemoryGraphIndex,
|
|
@@ -254,7 +259,7 @@ import {
|
|
|
254
259
|
import "./chunk-2ZDO52B4.js";
|
|
255
260
|
|
|
256
261
|
// src/index.ts
|
|
257
|
-
import * as
|
|
262
|
+
import * as fs3 from "fs";
|
|
258
263
|
|
|
259
264
|
// src/commands/migrate.ts
|
|
260
265
|
import * as fs from "fs";
|
|
@@ -493,11 +498,156 @@ function registerMigrateCommand(program) {
|
|
|
493
498
|
});
|
|
494
499
|
}
|
|
495
500
|
|
|
501
|
+
// src/lib/hybrid-search.ts
|
|
502
|
+
import * as fs2 from "fs";
|
|
503
|
+
import * as path2 from "path";
|
|
504
|
+
var embeddingPipeline = null;
|
|
505
|
+
var pipelineLoading = null;
|
|
506
|
+
async function getEmbeddingPipeline() {
|
|
507
|
+
if (embeddingPipeline) return embeddingPipeline;
|
|
508
|
+
if (pipelineLoading) return pipelineLoading;
|
|
509
|
+
pipelineLoading = (async () => {
|
|
510
|
+
const { pipeline } = await import("./transformers.node-A2ZRORSQ.js");
|
|
511
|
+
embeddingPipeline = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2", {
|
|
512
|
+
dtype: "fp32"
|
|
513
|
+
});
|
|
514
|
+
return embeddingPipeline;
|
|
515
|
+
})();
|
|
516
|
+
return pipelineLoading;
|
|
517
|
+
}
|
|
518
|
+
async function embed(text) {
|
|
519
|
+
const pipe = await getEmbeddingPipeline();
|
|
520
|
+
const result = await pipe(text, { pooling: "mean", normalize: true });
|
|
521
|
+
return new Float32Array(result.data);
|
|
522
|
+
}
|
|
523
|
+
async function embedBatch(texts) {
|
|
524
|
+
const pipe = await getEmbeddingPipeline();
|
|
525
|
+
const results = [];
|
|
526
|
+
const batchSize = 32;
|
|
527
|
+
for (let i = 0; i < texts.length; i += batchSize) {
|
|
528
|
+
const batch = texts.slice(i, i + batchSize);
|
|
529
|
+
for (const text of batch) {
|
|
530
|
+
const result = await pipe(text, { pooling: "mean", normalize: true });
|
|
531
|
+
results.push(new Float32Array(result.data));
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return results;
|
|
535
|
+
}
|
|
536
|
+
function cosineSimilarity(a, b) {
|
|
537
|
+
let dot = 0;
|
|
538
|
+
for (let i = 0; i < a.length; i++) {
|
|
539
|
+
dot += a[i] * b[i];
|
|
540
|
+
}
|
|
541
|
+
return dot;
|
|
542
|
+
}
|
|
543
|
+
var EmbeddingCache = class {
|
|
544
|
+
cachePath;
|
|
545
|
+
cache = /* @__PURE__ */ new Map();
|
|
546
|
+
dirty = false;
|
|
547
|
+
constructor(vaultPath) {
|
|
548
|
+
this.cachePath = path2.join(vaultPath, ".clawvault", "embeddings.bin");
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Load cache from disk
|
|
552
|
+
*/
|
|
553
|
+
load() {
|
|
554
|
+
try {
|
|
555
|
+
if (!fs2.existsSync(this.cachePath)) return;
|
|
556
|
+
const data = JSON.parse(fs2.readFileSync(this.cachePath + ".json", "utf-8"));
|
|
557
|
+
for (const [key, arr] of Object.entries(data)) {
|
|
558
|
+
this.cache.set(key, new Float32Array(arr));
|
|
559
|
+
}
|
|
560
|
+
} catch {
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Save cache to disk
|
|
565
|
+
*/
|
|
566
|
+
save() {
|
|
567
|
+
if (!this.dirty) return;
|
|
568
|
+
const dir = path2.dirname(this.cachePath);
|
|
569
|
+
if (!fs2.existsSync(dir)) fs2.mkdirSync(dir, { recursive: true });
|
|
570
|
+
const data = {};
|
|
571
|
+
for (const [key, arr] of this.cache.entries()) {
|
|
572
|
+
data[key] = Array.from(arr);
|
|
573
|
+
}
|
|
574
|
+
fs2.writeFileSync(this.cachePath + ".json", JSON.stringify(data));
|
|
575
|
+
this.dirty = false;
|
|
576
|
+
}
|
|
577
|
+
get(key) {
|
|
578
|
+
return this.cache.get(key);
|
|
579
|
+
}
|
|
580
|
+
set(key, embedding) {
|
|
581
|
+
this.cache.set(key, embedding);
|
|
582
|
+
this.dirty = true;
|
|
583
|
+
}
|
|
584
|
+
has(key) {
|
|
585
|
+
return this.cache.has(key);
|
|
586
|
+
}
|
|
587
|
+
entries() {
|
|
588
|
+
return this.cache.entries();
|
|
589
|
+
}
|
|
590
|
+
get size() {
|
|
591
|
+
return this.cache.size;
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
function reciprocalRankFusion(list1, list2, k = 60) {
|
|
595
|
+
const scores = /* @__PURE__ */ new Map();
|
|
596
|
+
for (let rank = 0; rank < list1.length; rank++) {
|
|
597
|
+
const { id } = list1[rank];
|
|
598
|
+
scores.set(id, (scores.get(id) || 0) + 1 / (k + rank + 1));
|
|
599
|
+
}
|
|
600
|
+
for (let rank = 0; rank < list2.length; rank++) {
|
|
601
|
+
const { id } = list2[rank];
|
|
602
|
+
scores.set(id, (scores.get(id) || 0) + 1 / (k + rank + 1));
|
|
603
|
+
}
|
|
604
|
+
return Array.from(scores.entries()).map(([id, score]) => ({ id, score })).sort((a, b) => b.score - a.score);
|
|
605
|
+
}
|
|
606
|
+
async function semanticSearch(query, cache, topK = 20) {
|
|
607
|
+
const queryEmb = await embed(query);
|
|
608
|
+
const results = [];
|
|
609
|
+
for (const [id, docEmb] of cache.entries()) {
|
|
610
|
+
results.push({ id, score: cosineSimilarity(queryEmb, docEmb) });
|
|
611
|
+
}
|
|
612
|
+
results.sort((a, b) => b.score - a.score);
|
|
613
|
+
return results.slice(0, topK);
|
|
614
|
+
}
|
|
615
|
+
async function hybridSearch(query, bm25Results, cache, options = {}) {
|
|
616
|
+
const { topK = 20, rrfK = 60 } = options;
|
|
617
|
+
const bm25Ranked = bm25Results.map((r) => ({ id: r.document.path || r.document.id, score: r.score }));
|
|
618
|
+
const semanticRanked = await semanticSearch(query, cache, topK);
|
|
619
|
+
const fused = reciprocalRankFusion(bm25Ranked, semanticRanked, rrfK);
|
|
620
|
+
const bm25Map = new Map(bm25Results.map((r) => [r.document.path || r.document.id, r]));
|
|
621
|
+
return fused.slice(0, topK).map(({ id, score }) => {
|
|
622
|
+
const existing = bm25Map.get(id);
|
|
623
|
+
if (existing) {
|
|
624
|
+
return { ...existing, score };
|
|
625
|
+
}
|
|
626
|
+
const minimalDoc = {
|
|
627
|
+
id: id.replace(/\.md$/, ""),
|
|
628
|
+
path: id.endsWith(".md") ? id : id + ".md",
|
|
629
|
+
title: (id.split("/").pop() || id).replace(/\.md$/, ""),
|
|
630
|
+
content: "",
|
|
631
|
+
category: id.split("/")[0] || "root",
|
|
632
|
+
frontmatter: {},
|
|
633
|
+
links: [],
|
|
634
|
+
tags: [],
|
|
635
|
+
modified: /* @__PURE__ */ new Date()
|
|
636
|
+
};
|
|
637
|
+
return {
|
|
638
|
+
document: minimalDoc,
|
|
639
|
+
score,
|
|
640
|
+
snippet: "",
|
|
641
|
+
matchedTerms: []
|
|
642
|
+
};
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
|
|
496
646
|
// src/index.ts
|
|
497
647
|
function readPackageVersion() {
|
|
498
648
|
try {
|
|
499
649
|
const pkgUrl = new URL("../package.json", import.meta.url);
|
|
500
|
-
const pkg = JSON.parse(
|
|
650
|
+
const pkg = JSON.parse(fs3.readFileSync(pkgUrl, "utf-8"));
|
|
501
651
|
return pkg.version ?? "0.0.0";
|
|
502
652
|
} catch {
|
|
503
653
|
return "0.0.0";
|
|
@@ -534,6 +684,7 @@ export {
|
|
|
534
684
|
archiveCommand,
|
|
535
685
|
archiveObservations,
|
|
536
686
|
archiveProject,
|
|
687
|
+
benchmarkObserverCommand,
|
|
537
688
|
buildContext,
|
|
538
689
|
buildInjectionResult,
|
|
539
690
|
buildKanbanLanes,
|
|
@@ -544,6 +695,7 @@ export {
|
|
|
544
695
|
checkOpenClawCompatibility,
|
|
545
696
|
checkPeerClawVault,
|
|
546
697
|
compareManifests,
|
|
698
|
+
compareObservationText,
|
|
547
699
|
compatCommand,
|
|
548
700
|
compatibilityExitCode,
|
|
549
701
|
completeTask,
|
|
@@ -566,6 +718,7 @@ export {
|
|
|
566
718
|
extractCardSlug,
|
|
567
719
|
extractFactsLlm,
|
|
568
720
|
extractFactsRuleBased,
|
|
721
|
+
extractKeywordSetFromTranscript,
|
|
569
722
|
extractTags,
|
|
570
723
|
extractWikiLinks,
|
|
571
724
|
factId,
|
|
@@ -576,6 +729,7 @@ export {
|
|
|
576
729
|
findVault,
|
|
577
730
|
formatContextMarkdown,
|
|
578
731
|
formatKanbanCard,
|
|
732
|
+
formatObserverBenchmarkSummary,
|
|
579
733
|
formatSessionRecapMarkdown,
|
|
580
734
|
formatTransitionsTable,
|
|
581
735
|
generateKanbanMarkdown,
|
|
@@ -598,6 +752,7 @@ export {
|
|
|
598
752
|
hasTailscale,
|
|
599
753
|
hybridSearch,
|
|
600
754
|
importKanbanBoard,
|
|
755
|
+
inboxAddCommand,
|
|
601
756
|
indexInjectableItems,
|
|
602
757
|
inferContextProfile,
|
|
603
758
|
injectCommand,
|
|
@@ -609,6 +764,9 @@ export {
|
|
|
609
764
|
listRouteRules,
|
|
610
765
|
listSubtasks,
|
|
611
766
|
loadMemoryGraphIndex,
|
|
767
|
+
loadObserverBenchmarkFixtures,
|
|
768
|
+
maintainCommand,
|
|
769
|
+
matchObservationRecords,
|
|
612
770
|
matchRouteRule,
|
|
613
771
|
migrate,
|
|
614
772
|
migrateCommand,
|
|
@@ -631,11 +789,14 @@ export {
|
|
|
631
789
|
reciprocalRankFusion,
|
|
632
790
|
reflectCommand,
|
|
633
791
|
registerArchiveCommand,
|
|
792
|
+
registerBenchmarkCommand,
|
|
634
793
|
registerCliCommands,
|
|
635
794
|
registerCommanderCommands,
|
|
636
795
|
registerContextCommand,
|
|
637
796
|
registerEmbedCommand,
|
|
797
|
+
registerInboxCommand,
|
|
638
798
|
registerInjectCommand,
|
|
799
|
+
registerMaintainCommand,
|
|
639
800
|
registerMigrateCommand,
|
|
640
801
|
registerMigrateObservationsCommand,
|
|
641
802
|
registerObserveCommand,
|
|
@@ -658,8 +819,10 @@ export {
|
|
|
658
819
|
resolveLlmProvider,
|
|
659
820
|
resolvePeerIP,
|
|
660
821
|
resolveVaultPath,
|
|
822
|
+
runObserverBenchmark,
|
|
661
823
|
runPromptInjection,
|
|
662
824
|
runReflection,
|
|
825
|
+
scoreFixtureObservations,
|
|
663
826
|
semanticSearch,
|
|
664
827
|
serveVault,
|
|
665
828
|
sessionRecapCommand,
|
|
@@ -58,10 +58,12 @@ declare function getMemoryGraph(vaultPath: string, options?: {
|
|
|
58
58
|
}): Promise<MemoryGraph>;
|
|
59
59
|
|
|
60
60
|
type LlmProvider = 'anthropic' | 'openai' | 'gemini' | 'xai' | 'openclaw';
|
|
61
|
+
type LlmModelTier = 'background' | 'default' | 'complex';
|
|
61
62
|
interface LlmCompletionOptions {
|
|
62
63
|
prompt: string;
|
|
63
64
|
provider?: LlmProvider | null;
|
|
64
65
|
model?: string;
|
|
66
|
+
tier?: LlmModelTier;
|
|
65
67
|
systemPrompt?: string;
|
|
66
68
|
temperature?: number;
|
|
67
69
|
maxTokens?: number;
|
|
@@ -134,4 +136,4 @@ declare function buildInjectionResult(message: string, options: InjectCommandOpt
|
|
|
134
136
|
declare function injectCommand(message: string, options: InjectCommandOptions): Promise<void>;
|
|
135
137
|
declare function registerInjectCommand(program: Command): void;
|
|
136
138
|
|
|
137
|
-
export {
|
|
139
|
+
export { resolveLlmProvider as A, runPromptInjection as B, type InjectCommandOptions as I, type LlmProvider as L, MEMORY_GRAPH_SCHEMA_VERSION as M, type LlmModelTier as a, type InjectFormat as b, type InjectMatch as c, type InjectMatchReason as d, type InjectMatchSource as e, type InjectResult as f, type InjectRuntimeOptions as g, type InjectSourceCategory as h, type InjectableItem as i, type LlmCompletionOptions as j, type MemoryGraph as k, type MemoryGraphEdge as l, type MemoryGraphEdgeType as m, type MemoryGraphIndex as n, type MemoryGraphNode as o, type MemoryGraphNodeType as p, type MemoryGraphStats as q, buildInjectionResult as r, buildOrUpdateMemoryGraphIndex as s, deterministicInjectMatches as t, getMemoryGraph as u, indexInjectableItems as v, injectCommand as w, loadMemoryGraphIndex as x, registerInjectCommand as y, requestLlmCompletion as z };
|
package/dist/lib/config.js
CHANGED
|
@@ -14,6 +14,8 @@ interface VaultConfig {
|
|
|
14
14
|
qmdRoot?: string;
|
|
15
15
|
/** Custom templates path (optional) */
|
|
16
16
|
templatesPath?: string;
|
|
17
|
+
/** Search configuration */
|
|
18
|
+
search?: VaultSearchConfig;
|
|
17
19
|
}
|
|
18
20
|
interface VaultMeta {
|
|
19
21
|
name: string;
|
|
@@ -26,6 +28,37 @@ interface VaultMeta {
|
|
|
26
28
|
qmdCollection?: string;
|
|
27
29
|
/** Root path for qmd collection (defaults to vault path) */
|
|
28
30
|
qmdRoot?: string;
|
|
31
|
+
/** Search configuration */
|
|
32
|
+
search?: VaultSearchConfig;
|
|
33
|
+
}
|
|
34
|
+
type SearchBackend = 'in-process' | 'qmd';
|
|
35
|
+
type EmbeddingProvider = 'none' | 'openai' | 'gemini' | 'ollama';
|
|
36
|
+
type RerankProvider = 'none' | 'jina' | 'voyage' | 'siliconflow' | 'pinecone';
|
|
37
|
+
interface VaultSearchConfig {
|
|
38
|
+
/**
|
|
39
|
+
* Default backend used for search commands.
|
|
40
|
+
* in-process is default and recommended for constrained devices.
|
|
41
|
+
*/
|
|
42
|
+
backend?: SearchBackend;
|
|
43
|
+
/** Allow qmd fallback when installed and in-process search fails */
|
|
44
|
+
qmdFallback?: boolean;
|
|
45
|
+
/** Chunk size in characters for in-process BM25 indexing */
|
|
46
|
+
chunkSize?: number;
|
|
47
|
+
/** Chunk overlap in characters for in-process BM25 indexing */
|
|
48
|
+
chunkOverlap?: number;
|
|
49
|
+
embeddings?: {
|
|
50
|
+
provider?: EmbeddingProvider;
|
|
51
|
+
model?: string;
|
|
52
|
+
baseUrl?: string;
|
|
53
|
+
apiKey?: string;
|
|
54
|
+
};
|
|
55
|
+
rerank?: {
|
|
56
|
+
provider?: RerankProvider;
|
|
57
|
+
model?: string;
|
|
58
|
+
endpoint?: string;
|
|
59
|
+
apiKey?: string;
|
|
60
|
+
weight?: number;
|
|
61
|
+
};
|
|
29
62
|
}
|
|
30
63
|
interface Document {
|
|
31
64
|
/** Unique ID (relative path without extension) */
|
|
@@ -89,6 +122,23 @@ interface StoreOptions {
|
|
|
89
122
|
/** Optional qmd index name override (defaults to configured/global index) */
|
|
90
123
|
qmdIndexName?: string;
|
|
91
124
|
}
|
|
125
|
+
type PatchMode = 'append' | 'replace' | 'content';
|
|
126
|
+
interface PatchOptions {
|
|
127
|
+
/** Document id/path to patch (e.g. decisions/my-note or decisions/my-note.md) */
|
|
128
|
+
idOrPath: string;
|
|
129
|
+
/** Patch mode */
|
|
130
|
+
mode: PatchMode;
|
|
131
|
+
/** Text to append when mode=append */
|
|
132
|
+
append?: string;
|
|
133
|
+
/** Search text when mode=replace */
|
|
134
|
+
replace?: string;
|
|
135
|
+
/** Replacement text when mode=replace */
|
|
136
|
+
with?: string;
|
|
137
|
+
/** Replacement body when mode=content */
|
|
138
|
+
content?: string;
|
|
139
|
+
/** Optional markdown section heading (without #) to scope the patch */
|
|
140
|
+
section?: string;
|
|
141
|
+
}
|
|
92
142
|
interface SyncOptions {
|
|
93
143
|
/** Target directory to sync to */
|
|
94
144
|
target: string;
|
|
@@ -159,4 +209,4 @@ interface SessionRecap {
|
|
|
159
209
|
}
|
|
160
210
|
declare const DEFAULT_CONFIG: Partial<VaultConfig>;
|
|
161
211
|
|
|
162
|
-
export { type Category as C, type Document as D, type HandoffDocument as H, type MemoryType as M, type
|
|
212
|
+
export { type Category as C, type Document as D, type EmbeddingProvider as E, type HandoffDocument as H, type MemoryType as M, type PatchOptions as P, type RerankProvider as R, type StoreOptions as S, TYPE_TO_CATEGORY as T, type VaultConfig as V, type SearchOptions as a, type SearchResult as b, type SyncOptions as c, type SyncResult as d, type SessionRecap as e, type VaultSearchConfig as f, DEFAULT_CATEGORIES as g, DEFAULT_CONFIG as h, MEMORY_TYPES as i, type PatchMode as j, type SearchBackend as k, type VaultMeta as l };
|