@psiclawops/hypermem 0.5.0 → 0.5.1

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 (160) hide show
  1. package/dist/background-indexer.d.ts +132 -0
  2. package/dist/background-indexer.d.ts.map +1 -0
  3. package/dist/background-indexer.js +1044 -0
  4. package/dist/cache.d.ts +110 -0
  5. package/dist/cache.d.ts.map +1 -0
  6. package/dist/cache.js +495 -0
  7. package/dist/compaction-fence.d.ts +89 -0
  8. package/dist/compaction-fence.d.ts.map +1 -0
  9. package/dist/compaction-fence.js +153 -0
  10. package/dist/compositor.d.ts +226 -0
  11. package/dist/compositor.d.ts.map +1 -0
  12. package/dist/compositor.js +2558 -0
  13. package/dist/content-type-classifier.d.ts +41 -0
  14. package/dist/content-type-classifier.d.ts.map +1 -0
  15. package/dist/content-type-classifier.js +181 -0
  16. package/dist/cross-agent.d.ts +62 -0
  17. package/dist/cross-agent.d.ts.map +1 -0
  18. package/dist/cross-agent.js +259 -0
  19. package/dist/db.d.ts +131 -0
  20. package/dist/db.d.ts.map +1 -0
  21. package/dist/db.js +402 -0
  22. package/dist/desired-state-store.d.ts +100 -0
  23. package/dist/desired-state-store.d.ts.map +1 -0
  24. package/dist/desired-state-store.js +222 -0
  25. package/dist/doc-chunk-store.d.ts +140 -0
  26. package/dist/doc-chunk-store.d.ts.map +1 -0
  27. package/dist/doc-chunk-store.js +391 -0
  28. package/dist/doc-chunker.d.ts +99 -0
  29. package/dist/doc-chunker.d.ts.map +1 -0
  30. package/dist/doc-chunker.js +324 -0
  31. package/dist/dreaming-promoter.d.ts +86 -0
  32. package/dist/dreaming-promoter.d.ts.map +1 -0
  33. package/dist/dreaming-promoter.js +381 -0
  34. package/dist/episode-store.d.ts +49 -0
  35. package/dist/episode-store.d.ts.map +1 -0
  36. package/dist/episode-store.js +135 -0
  37. package/dist/fact-store.d.ts +75 -0
  38. package/dist/fact-store.d.ts.map +1 -0
  39. package/dist/fact-store.js +236 -0
  40. package/dist/fleet-store.d.ts +144 -0
  41. package/dist/fleet-store.d.ts.map +1 -0
  42. package/dist/fleet-store.js +276 -0
  43. package/dist/fos-mod.d.ts +178 -0
  44. package/dist/fos-mod.d.ts.map +1 -0
  45. package/dist/fos-mod.js +416 -0
  46. package/dist/hybrid-retrieval.d.ts +64 -0
  47. package/dist/hybrid-retrieval.d.ts.map +1 -0
  48. package/dist/hybrid-retrieval.js +344 -0
  49. package/dist/image-eviction.d.ts +49 -0
  50. package/dist/image-eviction.d.ts.map +1 -0
  51. package/dist/image-eviction.js +251 -0
  52. package/dist/index.d.ts +650 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/index.js +1072 -0
  55. package/dist/keystone-scorer.d.ts +51 -0
  56. package/dist/keystone-scorer.d.ts.map +1 -0
  57. package/dist/keystone-scorer.js +52 -0
  58. package/dist/knowledge-graph.d.ts +110 -0
  59. package/dist/knowledge-graph.d.ts.map +1 -0
  60. package/dist/knowledge-graph.js +305 -0
  61. package/dist/knowledge-lint.d.ts +29 -0
  62. package/dist/knowledge-lint.d.ts.map +1 -0
  63. package/dist/knowledge-lint.js +116 -0
  64. package/dist/knowledge-store.d.ts +72 -0
  65. package/dist/knowledge-store.d.ts.map +1 -0
  66. package/dist/knowledge-store.js +247 -0
  67. package/dist/library-schema.d.ts +22 -0
  68. package/dist/library-schema.d.ts.map +1 -0
  69. package/dist/library-schema.js +1038 -0
  70. package/dist/message-store.d.ts +89 -0
  71. package/dist/message-store.d.ts.map +1 -0
  72. package/dist/message-store.js +323 -0
  73. package/dist/metrics-dashboard.d.ts +114 -0
  74. package/dist/metrics-dashboard.d.ts.map +1 -0
  75. package/dist/metrics-dashboard.js +260 -0
  76. package/dist/obsidian-exporter.d.ts +57 -0
  77. package/dist/obsidian-exporter.d.ts.map +1 -0
  78. package/dist/obsidian-exporter.js +274 -0
  79. package/dist/obsidian-watcher.d.ts +147 -0
  80. package/dist/obsidian-watcher.d.ts.map +1 -0
  81. package/dist/obsidian-watcher.js +403 -0
  82. package/dist/open-domain.d.ts +46 -0
  83. package/dist/open-domain.d.ts.map +1 -0
  84. package/dist/open-domain.js +125 -0
  85. package/dist/preference-store.d.ts +54 -0
  86. package/dist/preference-store.d.ts.map +1 -0
  87. package/dist/preference-store.js +109 -0
  88. package/dist/preservation-gate.d.ts +82 -0
  89. package/dist/preservation-gate.d.ts.map +1 -0
  90. package/dist/preservation-gate.js +150 -0
  91. package/dist/proactive-pass.d.ts +63 -0
  92. package/dist/proactive-pass.d.ts.map +1 -0
  93. package/dist/proactive-pass.js +239 -0
  94. package/dist/profiles.d.ts +44 -0
  95. package/dist/profiles.d.ts.map +1 -0
  96. package/dist/profiles.js +227 -0
  97. package/dist/provider-translator.d.ts +50 -0
  98. package/dist/provider-translator.d.ts.map +1 -0
  99. package/dist/provider-translator.js +403 -0
  100. package/dist/rate-limiter.d.ts +76 -0
  101. package/dist/rate-limiter.d.ts.map +1 -0
  102. package/dist/rate-limiter.js +179 -0
  103. package/dist/repair-tool-pairs.d.ts +38 -0
  104. package/dist/repair-tool-pairs.d.ts.map +1 -0
  105. package/dist/repair-tool-pairs.js +138 -0
  106. package/dist/retrieval-policy.d.ts +51 -0
  107. package/dist/retrieval-policy.d.ts.map +1 -0
  108. package/dist/retrieval-policy.js +77 -0
  109. package/dist/schema.d.ts +15 -0
  110. package/dist/schema.d.ts.map +1 -0
  111. package/dist/schema.js +229 -0
  112. package/dist/secret-scanner.d.ts +51 -0
  113. package/dist/secret-scanner.d.ts.map +1 -0
  114. package/dist/secret-scanner.js +248 -0
  115. package/dist/seed.d.ts +108 -0
  116. package/dist/seed.d.ts.map +1 -0
  117. package/dist/seed.js +177 -0
  118. package/dist/session-flusher.d.ts +53 -0
  119. package/dist/session-flusher.d.ts.map +1 -0
  120. package/dist/session-flusher.js +69 -0
  121. package/dist/session-topic-map.d.ts +41 -0
  122. package/dist/session-topic-map.d.ts.map +1 -0
  123. package/dist/session-topic-map.js +77 -0
  124. package/dist/spawn-context.d.ts +54 -0
  125. package/dist/spawn-context.d.ts.map +1 -0
  126. package/dist/spawn-context.js +159 -0
  127. package/dist/system-store.d.ts +73 -0
  128. package/dist/system-store.d.ts.map +1 -0
  129. package/dist/system-store.js +182 -0
  130. package/dist/temporal-store.d.ts +80 -0
  131. package/dist/temporal-store.d.ts.map +1 -0
  132. package/dist/temporal-store.js +149 -0
  133. package/dist/topic-detector.d.ts +35 -0
  134. package/dist/topic-detector.d.ts.map +1 -0
  135. package/dist/topic-detector.js +249 -0
  136. package/dist/topic-store.d.ts +45 -0
  137. package/dist/topic-store.d.ts.map +1 -0
  138. package/dist/topic-store.js +136 -0
  139. package/dist/topic-synthesizer.d.ts +51 -0
  140. package/dist/topic-synthesizer.d.ts.map +1 -0
  141. package/dist/topic-synthesizer.js +315 -0
  142. package/dist/trigger-registry.d.ts +63 -0
  143. package/dist/trigger-registry.d.ts.map +1 -0
  144. package/dist/trigger-registry.js +163 -0
  145. package/dist/types.d.ts +533 -0
  146. package/dist/types.d.ts.map +1 -0
  147. package/dist/types.js +9 -0
  148. package/dist/vector-store.d.ts +170 -0
  149. package/dist/vector-store.d.ts.map +1 -0
  150. package/dist/vector-store.js +677 -0
  151. package/dist/version.d.ts +34 -0
  152. package/dist/version.d.ts.map +1 -0
  153. package/dist/version.js +34 -0
  154. package/dist/wiki-page-emitter.d.ts +65 -0
  155. package/dist/wiki-page-emitter.d.ts.map +1 -0
  156. package/dist/wiki-page-emitter.js +258 -0
  157. package/dist/work-store.d.ts +112 -0
  158. package/dist/work-store.d.ts.map +1 -0
  159. package/dist/work-store.js +273 -0
  160. package/package.json +1 -1
@@ -0,0 +1,72 @@
1
+ /**
2
+ * hypermem Knowledge Store
3
+ *
4
+ * Long-term structured knowledge — replaces MEMORY.md.
5
+ * Lives in the central library DB.
6
+ * Knowledge entries are keyed (domain + key), versioned via superseded_by,
7
+ * and linked to each other via knowledge_links.
8
+ */
9
+ import type { DatabaseSync } from 'node:sqlite';
10
+ import type { Knowledge } from './types.js';
11
+ export type LinkType = 'supports' | 'contradicts' | 'depends_on' | 'supersedes' | 'related';
12
+ export declare class KnowledgeStore {
13
+ private readonly db;
14
+ constructor(db: DatabaseSync);
15
+ /**
16
+ * Upsert a knowledge entry.
17
+ *
18
+ * Versioning semantics:
19
+ * - If no active entry exists: insert as version 1
20
+ * - If same content: refresh confidence + timestamp only (no new version)
21
+ * - If different content: insert as new version (max_version + 1), mark
22
+ * previous active row as superseded_by = new_id
23
+ *
24
+ * This guarantees version history is real rows, not in-place overwrites.
25
+ * The unique constraint is (agent_id, domain, key, version) so each
26
+ * version is a distinct row.
27
+ */
28
+ upsert(agentId: string, domain: string, key: string, content: string, opts?: {
29
+ confidence?: number;
30
+ visibility?: string;
31
+ sourceType?: string;
32
+ sourceRef?: string;
33
+ expiresAt?: string;
34
+ }): Knowledge;
35
+ /**
36
+ * Get current (non-superseded) knowledge for an agent.
37
+ */
38
+ getActive(agentId: string, opts?: {
39
+ domain?: string;
40
+ limit?: number;
41
+ }): Knowledge[];
42
+ /**
43
+ * Get a specific knowledge entry by domain + key.
44
+ */
45
+ get(agentId: string, domain: string, key: string): Knowledge | null;
46
+ /**
47
+ * Get the version history of a knowledge entry.
48
+ */
49
+ getHistory(agentId: string, domain: string, key: string): Knowledge[];
50
+ /**
51
+ * Search knowledge by content.
52
+ */
53
+ search(agentId: string, query: string, limit?: number): Knowledge[];
54
+ /**
55
+ * List all domains for an agent.
56
+ */
57
+ getDomains(agentId: string): string[];
58
+ /**
59
+ * Add a link between knowledge entries.
60
+ */
61
+ addLink(fromId: number, toId: number, linkType: LinkType): void;
62
+ /**
63
+ * Get knowledge count.
64
+ */
65
+ getCount(agentId: string): number;
66
+ /**
67
+ * Import from MEMORY.md content.
68
+ * Parses markdown sections into domain/key/content entries.
69
+ */
70
+ importFromMarkdown(agentId: string, markdown: string, sourcePath: string): number;
71
+ }
72
+ //# sourceMappingURL=knowledge-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledge-store.d.ts","sourceRoot":"","sources":["../src/knowledge-store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAwB5C,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,aAAa,GAAG,YAAY,GAAG,YAAY,GAAG,SAAS,CAAC;AAE5F,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,YAAY;IAE7C;;;;;;;;;;;;OAYG;IACH,MAAM,CACJ,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QACL,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GACA,SAAS;IA4EZ;;OAEG;IACH,SAAS,CACP,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,SAAS,EAAE;IAyBd;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAUnE;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE;IAUrE;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,SAAS,EAAE;IAavE;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IAUrC;;OAEG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAO/D;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAOjC;;;OAGG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;CAwDlF"}
@@ -0,0 +1,247 @@
1
+ /**
2
+ * hypermem Knowledge Store
3
+ *
4
+ * Long-term structured knowledge — replaces MEMORY.md.
5
+ * Lives in the central library DB.
6
+ * Knowledge entries are keyed (domain + key), versioned via superseded_by,
7
+ * and linked to each other via knowledge_links.
8
+ */
9
+ import { isSafeForSharedVisibility, requiresScan } from './secret-scanner.js';
10
+ function nowIso() {
11
+ return new Date().toISOString();
12
+ }
13
+ function parseKnowledgeRow(row) {
14
+ return {
15
+ id: row.id,
16
+ agentId: row.agent_id,
17
+ domain: row.domain,
18
+ key: row.key,
19
+ content: row.content,
20
+ confidence: row.confidence,
21
+ sourceType: row.source_type,
22
+ sourceRef: row.source_ref || null,
23
+ createdAt: row.created_at,
24
+ updatedAt: row.updated_at,
25
+ expiresAt: row.expires_at || null,
26
+ supersededBy: row.superseded_by || null,
27
+ };
28
+ }
29
+ export class KnowledgeStore {
30
+ db;
31
+ constructor(db) {
32
+ this.db = db;
33
+ }
34
+ /**
35
+ * Upsert a knowledge entry.
36
+ *
37
+ * Versioning semantics:
38
+ * - If no active entry exists: insert as version 1
39
+ * - If same content: refresh confidence + timestamp only (no new version)
40
+ * - If different content: insert as new version (max_version + 1), mark
41
+ * previous active row as superseded_by = new_id
42
+ *
43
+ * This guarantees version history is real rows, not in-place overwrites.
44
+ * The unique constraint is (agent_id, domain, key, version) so each
45
+ * version is a distinct row.
46
+ */
47
+ upsert(agentId, domain, key, content, opts) {
48
+ const now = nowIso();
49
+ const sourceType = opts?.sourceType || 'manual';
50
+ const confidence = opts?.confidence ?? 1.0;
51
+ // Secret gate: if requested visibility is shared, verify content is clean.
52
+ // Downgrade to 'private' rather than reject — matches episode-store pattern.
53
+ let visibility = opts?.visibility ?? 'private';
54
+ if (requiresScan(visibility) && !isSafeForSharedVisibility(content)) {
55
+ visibility = 'private';
56
+ }
57
+ // Find current active entry (not superseded, not expired)
58
+ const existing = this.db.prepare(`
59
+ SELECT * FROM knowledge
60
+ WHERE agent_id = ? AND domain = ? AND key = ?
61
+ AND superseded_by IS NULL
62
+ AND (expires_at IS NULL OR expires_at > datetime('now'))
63
+ ORDER BY version DESC LIMIT 1
64
+ `).get(agentId, domain, key);
65
+ if (existing && existing.content === content) {
66
+ // Same content — refresh confidence and timestamp only, no new version
67
+ this.db.prepare('UPDATE knowledge SET confidence = ?, updated_at = ? WHERE id = ?').run(confidence, now, existing.id);
68
+ return parseKnowledgeRow({ ...existing, confidence, updated_at: now });
69
+ }
70
+ // Determine next version number
71
+ const maxVersionRow = this.db.prepare(`
72
+ SELECT MAX(version) AS max_version FROM knowledge
73
+ WHERE agent_id = ? AND domain = ? AND key = ?
74
+ `).get(agentId, domain, key);
75
+ const nextVersion = (maxVersionRow?.max_version ?? 0) + 1;
76
+ // Insert new version row (no ON CONFLICT — version column ensures uniqueness)
77
+ const result = this.db.prepare(`
78
+ INSERT INTO knowledge
79
+ (agent_id, domain, key, version, content, confidence, visibility, source_type, source_ref,
80
+ created_at, updated_at, expires_at)
81
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
82
+ `).run(agentId, domain, key, nextVersion, content, confidence, visibility, sourceType, opts?.sourceRef ?? null, now, now, opts?.expiresAt ?? null);
83
+ const newId = result.lastInsertRowid;
84
+ // Mark previous active entry as superseded by this new version
85
+ if (existing) {
86
+ this.db.prepare('UPDATE knowledge SET superseded_by = ?, updated_at = ? WHERE id = ?').run(newId, now, existing.id);
87
+ // Link: new version supersedes old version
88
+ this.addLink(newId, existing.id, 'supersedes');
89
+ }
90
+ return {
91
+ id: newId,
92
+ agentId,
93
+ domain,
94
+ key,
95
+ content,
96
+ confidence,
97
+ sourceType,
98
+ sourceRef: opts?.sourceRef ?? null,
99
+ createdAt: now,
100
+ updatedAt: now,
101
+ expiresAt: opts?.expiresAt ?? null,
102
+ supersededBy: null,
103
+ };
104
+ }
105
+ /**
106
+ * Get current (non-superseded) knowledge for an agent.
107
+ */
108
+ getActive(agentId, opts) {
109
+ let sql = `
110
+ SELECT * FROM knowledge
111
+ WHERE agent_id = ?
112
+ AND superseded_by IS NULL
113
+ AND (expires_at IS NULL OR expires_at > datetime('now'))
114
+ `;
115
+ const params = [agentId];
116
+ if (opts?.domain) {
117
+ sql += ' AND domain = ?';
118
+ params.push(opts.domain);
119
+ }
120
+ sql += ' ORDER BY domain, key';
121
+ if (opts?.limit) {
122
+ sql += ' LIMIT ?';
123
+ params.push(opts.limit);
124
+ }
125
+ const rows = this.db.prepare(sql).all(...params);
126
+ return rows.map(parseKnowledgeRow);
127
+ }
128
+ /**
129
+ * Get a specific knowledge entry by domain + key.
130
+ */
131
+ get(agentId, domain, key) {
132
+ const row = this.db.prepare(`
133
+ SELECT * FROM knowledge
134
+ WHERE agent_id = ? AND domain = ? AND key = ?
135
+ AND superseded_by IS NULL
136
+ `).get(agentId, domain, key);
137
+ return row ? parseKnowledgeRow(row) : null;
138
+ }
139
+ /**
140
+ * Get the version history of a knowledge entry.
141
+ */
142
+ getHistory(agentId, domain, key) {
143
+ const rows = this.db.prepare(`
144
+ SELECT * FROM knowledge
145
+ WHERE agent_id = ? AND domain = ? AND key = ?
146
+ ORDER BY created_at DESC
147
+ `).all(agentId, domain, key);
148
+ return rows.map(parseKnowledgeRow);
149
+ }
150
+ /**
151
+ * Search knowledge by content.
152
+ */
153
+ search(agentId, query, limit = 20) {
154
+ const rows = this.db.prepare(`
155
+ SELECT * FROM knowledge
156
+ WHERE agent_id = ?
157
+ AND superseded_by IS NULL
158
+ AND (content LIKE ? OR key LIKE ?)
159
+ ORDER BY confidence DESC
160
+ LIMIT ?
161
+ `).all(agentId, `%${query}%`, `%${query}%`, limit);
162
+ return rows.map(parseKnowledgeRow);
163
+ }
164
+ /**
165
+ * List all domains for an agent.
166
+ */
167
+ getDomains(agentId) {
168
+ const rows = this.db.prepare(`
169
+ SELECT DISTINCT domain FROM knowledge
170
+ WHERE agent_id = ? AND superseded_by IS NULL
171
+ ORDER BY domain
172
+ `).all(agentId);
173
+ return rows.map(r => r.domain);
174
+ }
175
+ /**
176
+ * Add a link between knowledge entries.
177
+ */
178
+ addLink(fromId, toId, linkType) {
179
+ this.db.prepare(`
180
+ INSERT OR IGNORE INTO knowledge_links (from_type, from_id, to_type, to_id, link_type, created_at)
181
+ VALUES ('knowledge', ?, 'knowledge', ?, ?, ?)
182
+ `).run(fromId, toId, linkType, nowIso());
183
+ }
184
+ /**
185
+ * Get knowledge count.
186
+ */
187
+ getCount(agentId) {
188
+ const row = this.db.prepare('SELECT COUNT(*) AS count FROM knowledge WHERE agent_id = ? AND superseded_by IS NULL').get(agentId);
189
+ return row.count;
190
+ }
191
+ /**
192
+ * Import from MEMORY.md content.
193
+ * Parses markdown sections into domain/key/content entries.
194
+ */
195
+ importFromMarkdown(agentId, markdown, sourcePath) {
196
+ const lines = markdown.split('\n');
197
+ let currentDomain = 'general';
198
+ let currentKey = '';
199
+ let currentContent = [];
200
+ let imported = 0;
201
+ const flush = () => {
202
+ if (currentKey && currentContent.length > 0) {
203
+ this.upsert(agentId, currentDomain, currentKey, currentContent.join('\n').trim(), {
204
+ sourceType: 'manual',
205
+ sourceRef: sourcePath,
206
+ });
207
+ imported++;
208
+ }
209
+ currentContent = [];
210
+ };
211
+ for (const line of lines) {
212
+ // ## Section = domain
213
+ if (line.startsWith('## ')) {
214
+ flush();
215
+ currentDomain = line.replace('## ', '').trim().toLowerCase().replace(/\s+/g, '_');
216
+ currentKey = '';
217
+ continue;
218
+ }
219
+ // ### Subsection or **Bold** = key
220
+ if (line.startsWith('### ')) {
221
+ flush();
222
+ currentKey = line.replace('### ', '').trim();
223
+ continue;
224
+ }
225
+ // - **Key:** Value pattern
226
+ const kvMatch = line.match(/^[-*]\s+\*\*(.+?)\*\*[:\s]+(.+)/);
227
+ if (kvMatch) {
228
+ flush();
229
+ currentKey = kvMatch[1].trim();
230
+ currentContent.push(kvMatch[2].trim());
231
+ continue;
232
+ }
233
+ // Regular content line
234
+ if (currentKey) {
235
+ currentContent.push(line);
236
+ }
237
+ else if (line.trim()) {
238
+ // Content without a key — use line hash as key
239
+ currentKey = `note_${lines.indexOf(line)}`;
240
+ currentContent.push(line);
241
+ }
242
+ }
243
+ flush();
244
+ return imported;
245
+ }
246
+ }
247
+ //# sourceMappingURL=knowledge-store.js.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * hypermem Library Schema — Fleet-Wide Structured Knowledge
3
+ *
4
+ * Single database: ~/.openclaw/hypermem/library.db
5
+ * The "crown jewel" — durable, backed up, low-write-frequency.
6
+ *
7
+ * Collections:
8
+ * 1. Library entries (versioned docs, specs, reference material)
9
+ * 2. Facts (agent-learned truths)
10
+ * 3. Preferences (behavioral patterns)
11
+ * 4. Knowledge (structured domain knowledge, supersedable)
12
+ * 5. Episodes (significant events)
13
+ * 6. Fleet registry (agents, orgs)
14
+ * 7. System registry (server state, config)
15
+ * 8. Session registry (lifecycle tracking)
16
+ * 9. Work items (fleet kanban)
17
+ * 10. Topics (cross-session thread tracking)
18
+ */
19
+ import type { DatabaseSync } from 'node:sqlite';
20
+ export declare const LIBRARY_SCHEMA_VERSION = 13;
21
+ export declare function migrateLibrary(db: DatabaseSync, engineVersion?: string): void;
22
+ //# sourceMappingURL=library-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"library-schema.d.ts","sourceRoot":"","sources":["../src/library-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAs5BzC,wBAAgB,cAAc,CAAC,EAAE,EAAE,YAAY,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CA8L7E"}