@wjmwjmwb/memme 0.1.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.
- package/README.md +36 -0
- package/index.d.ts +293 -0
- package/index.js +315 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# MemMe Node.js SDK
|
|
2
|
+
|
|
3
|
+
MemMe stores memory data in one SQLite file and uses the VexDB-Lite SQLite
|
|
4
|
+
extension for vector search.
|
|
5
|
+
|
|
6
|
+
## Supported platforms
|
|
7
|
+
|
|
8
|
+
Published packages currently support macOS and Linux on x64 and arm64. Windows
|
|
9
|
+
publication is disabled because VexDB-Lite v0.0.17 does not provide a Windows
|
|
10
|
+
SQLite extension asset.
|
|
11
|
+
|
|
12
|
+
The extension is not bundled in the npm package. Download the matching trusted
|
|
13
|
+
VexDB-Lite SQLite extension and pass its absolute path to the constructor:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
const { MemoryStore } = require("@wjmwjmwb/memme");
|
|
17
|
+
|
|
18
|
+
const store = MemoryStore.newMock(
|
|
19
|
+
"memory.db",
|
|
20
|
+
384,
|
|
21
|
+
"/opt/vexdb-lite/vexdb_lite.so",
|
|
22
|
+
);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Existing applications can continue to use the environment variable:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
export MEMME_VEXDB_LITE_EXTENSION=/opt/vexdb-lite/vexdb_lite.so
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
const store = MemoryStore.newMock("memory.db", 384);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Mobile and WASM publication remains paused until VexDB-Lite static registration
|
|
36
|
+
uses the same SQLite instance as MemMe.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
/** Memory result returned to JavaScript. */
|
|
7
|
+
export interface MemoryResult {
|
|
8
|
+
id: string
|
|
9
|
+
content: string
|
|
10
|
+
userId: string
|
|
11
|
+
agentId?: string
|
|
12
|
+
appId?: string
|
|
13
|
+
runId?: string
|
|
14
|
+
score?: number
|
|
15
|
+
createdAt: string
|
|
16
|
+
updatedAt: string
|
|
17
|
+
metadata?: string
|
|
18
|
+
importance?: number
|
|
19
|
+
accessCount?: number
|
|
20
|
+
immutable: boolean
|
|
21
|
+
expirationDate?: string
|
|
22
|
+
categories?: Array<string>
|
|
23
|
+
memoryType?: string
|
|
24
|
+
retention?: number
|
|
25
|
+
stability?: number
|
|
26
|
+
privacy: string
|
|
27
|
+
eventTime?: string
|
|
28
|
+
episodeId?: string
|
|
29
|
+
sessionId?: string
|
|
30
|
+
}
|
|
31
|
+
/** A chat message for smart operations. */
|
|
32
|
+
export interface ChatMessage {
|
|
33
|
+
role: string
|
|
34
|
+
content: string
|
|
35
|
+
}
|
|
36
|
+
/** Entity in the knowledge graph. */
|
|
37
|
+
export interface Entity {
|
|
38
|
+
id: string
|
|
39
|
+
name: string
|
|
40
|
+
entityType?: string
|
|
41
|
+
userId: string
|
|
42
|
+
}
|
|
43
|
+
/** Relationship in the knowledge graph. */
|
|
44
|
+
export interface GraphRelation {
|
|
45
|
+
id: string
|
|
46
|
+
source: string
|
|
47
|
+
sourceId: string
|
|
48
|
+
target: string
|
|
49
|
+
targetId: string
|
|
50
|
+
relationType: string
|
|
51
|
+
userId: string
|
|
52
|
+
description?: string
|
|
53
|
+
}
|
|
54
|
+
/** A history record. */
|
|
55
|
+
export interface HistoryRecord {
|
|
56
|
+
id: string
|
|
57
|
+
memoryId: string
|
|
58
|
+
oldMemory?: string
|
|
59
|
+
newMemory: string
|
|
60
|
+
event: string
|
|
61
|
+
createdAt: string
|
|
62
|
+
}
|
|
63
|
+
/** User statistics. */
|
|
64
|
+
export interface UserStats {
|
|
65
|
+
userId: string
|
|
66
|
+
totalMemories: number
|
|
67
|
+
totalEntities: number
|
|
68
|
+
totalRelationships: number
|
|
69
|
+
earliestMemory?: string
|
|
70
|
+
latestMemory?: string
|
|
71
|
+
uniqueAgents: number
|
|
72
|
+
}
|
|
73
|
+
/** Memory count per time period. */
|
|
74
|
+
export interface TimeBucket {
|
|
75
|
+
period: string
|
|
76
|
+
count: number
|
|
77
|
+
}
|
|
78
|
+
/** Top entity by relationship count. */
|
|
79
|
+
export interface EntityStat {
|
|
80
|
+
name: string
|
|
81
|
+
entityType?: string
|
|
82
|
+
relationshipCount: number
|
|
83
|
+
}
|
|
84
|
+
/** An episode (compressed understanding of a session). */
|
|
85
|
+
export interface Episode {
|
|
86
|
+
episodeId: string
|
|
87
|
+
title: string
|
|
88
|
+
summary: string
|
|
89
|
+
startedAt: string
|
|
90
|
+
endedAt?: string
|
|
91
|
+
significance: number
|
|
92
|
+
outcome?: string
|
|
93
|
+
sourceId?: string
|
|
94
|
+
eventIds: Array<string>
|
|
95
|
+
sessionIds: Array<string>
|
|
96
|
+
userId: string
|
|
97
|
+
createdAt: string
|
|
98
|
+
lastRecalled?: string
|
|
99
|
+
recallCount: number
|
|
100
|
+
storageStrength: number
|
|
101
|
+
retrievalStrength: number
|
|
102
|
+
score?: number
|
|
103
|
+
}
|
|
104
|
+
/** A stream event (single event in a session). */
|
|
105
|
+
export interface StreamEvent {
|
|
106
|
+
eventId: string
|
|
107
|
+
eventType: string
|
|
108
|
+
content: string
|
|
109
|
+
timestamp: string
|
|
110
|
+
sessionId?: string
|
|
111
|
+
sourceId?: string
|
|
112
|
+
userId: string
|
|
113
|
+
parentId?: string
|
|
114
|
+
metadata?: string
|
|
115
|
+
processed: boolean
|
|
116
|
+
purifiedContent?: string
|
|
117
|
+
location?: string
|
|
118
|
+
}
|
|
119
|
+
/** A session (immutable event container). */
|
|
120
|
+
export interface Session {
|
|
121
|
+
sessionId: string
|
|
122
|
+
userId: string
|
|
123
|
+
sourceId?: string
|
|
124
|
+
startedAt: string
|
|
125
|
+
endedAt?: string
|
|
126
|
+
metadata?: string
|
|
127
|
+
createdAt: string
|
|
128
|
+
eventCount: number
|
|
129
|
+
}
|
|
130
|
+
/** Session context assembled for retrieval-augmented generation. */
|
|
131
|
+
export interface SessionContext {
|
|
132
|
+
sessionId: string
|
|
133
|
+
events: Array<StreamEvent>
|
|
134
|
+
tokensUsed: number
|
|
135
|
+
tokenBudget: number
|
|
136
|
+
episodeSummary?: string
|
|
137
|
+
purifiedCount: number
|
|
138
|
+
rawCount: number
|
|
139
|
+
}
|
|
140
|
+
/** An identity trait extracted from memories. */
|
|
141
|
+
export interface IdentityTrait {
|
|
142
|
+
traitId: string
|
|
143
|
+
traitType: string
|
|
144
|
+
content: string
|
|
145
|
+
confidence: number
|
|
146
|
+
evidenceIds: Array<string>
|
|
147
|
+
userId: string
|
|
148
|
+
createdAt: string
|
|
149
|
+
updatedAt?: string
|
|
150
|
+
}
|
|
151
|
+
/** A meditation (deep processing) record. */
|
|
152
|
+
export interface MeditationRecord {
|
|
153
|
+
meditationId: string
|
|
154
|
+
triggeredBy: string
|
|
155
|
+
startedAt: string
|
|
156
|
+
finishedAt?: string
|
|
157
|
+
status: string
|
|
158
|
+
userId: string
|
|
159
|
+
eventsProcessed: number
|
|
160
|
+
episodesCreated: number
|
|
161
|
+
memoriesCreated: number
|
|
162
|
+
memoriesUpdated: number
|
|
163
|
+
memoriesDecayed: number
|
|
164
|
+
entitiesCreated: number
|
|
165
|
+
relationsCreated: number
|
|
166
|
+
conflictsFound: number
|
|
167
|
+
journal?: string
|
|
168
|
+
metadata?: string
|
|
169
|
+
}
|
|
170
|
+
/** Result of appending events to a session. */
|
|
171
|
+
export interface AppendEventsResult {
|
|
172
|
+
sessionId: string
|
|
173
|
+
eventsAppended: number
|
|
174
|
+
totalUnprocessed: number
|
|
175
|
+
compactNeeded: boolean
|
|
176
|
+
}
|
|
177
|
+
/** Result of compacting a session into an episode. */
|
|
178
|
+
export interface CompactResult {
|
|
179
|
+
sessionId: string
|
|
180
|
+
episodeId: string
|
|
181
|
+
memories: Array<MemoryResult>
|
|
182
|
+
eventsProcessed: number
|
|
183
|
+
}
|
|
184
|
+
/** Graph search result. */
|
|
185
|
+
export interface GraphSearchResult {
|
|
186
|
+
entities: Array<Entity>
|
|
187
|
+
relations: Array<GraphRelation>
|
|
188
|
+
}
|
|
189
|
+
/** The main MemMe memory store. */
|
|
190
|
+
export declare class MemoryStore {
|
|
191
|
+
/**
|
|
192
|
+
* Create a new MemoryStore with mock embedder (for testing).
|
|
193
|
+
* Pass a trusted VexDB-Lite extension path explicitly, or omit it to use
|
|
194
|
+
* MEMME_VEXDB_LITE_EXTENSION.
|
|
195
|
+
*/
|
|
196
|
+
static newMock(dbPath?: string | undefined | null, dims?: number | undefined | null, vexdbExtensionPath?: string | undefined | null): MemoryStore
|
|
197
|
+
/**
|
|
198
|
+
* Create a new MemoryStore with mock embedder AND mock LLM (for E2E testing).
|
|
199
|
+
* The mock LLM returns pre-scripted responses in order.
|
|
200
|
+
* Pass an array of JSON strings that the LLM should return.
|
|
201
|
+
*/
|
|
202
|
+
static newMockWithLlm(responses: Array<string>, dbPath?: string | undefined | null, dims?: number | undefined | null, vexdbExtensionPath?: string | undefined | null): MemoryStore
|
|
203
|
+
/** Create a new MemoryStore with OpenAI-compatible embedder. */
|
|
204
|
+
static newOpenai(apiKey: string, dbPath?: string | undefined | null, baseUrl?: string | undefined | null, model?: string | undefined | null, dims?: number | undefined | null, vexdbExtensionPath?: string | undefined | null): MemoryStore
|
|
205
|
+
/** Configure LLM provider at runtime. Call once after construction. */
|
|
206
|
+
setLlmProvider(apiKey: string, model: string, baseUrl?: string | undefined | null): void
|
|
207
|
+
/**
|
|
208
|
+
* Backup the database to a file path.
|
|
209
|
+
* Returns metadata about the backup (size, memory count, schema version).
|
|
210
|
+
*/
|
|
211
|
+
backupToPath(path: string): any
|
|
212
|
+
/**
|
|
213
|
+
* Restore the database from a backup file.
|
|
214
|
+
* **Warning**: The caller must re-create the MemoryStore after calling this.
|
|
215
|
+
*/
|
|
216
|
+
restoreFromBackup(backupPath: string): void
|
|
217
|
+
/** Run diagnostic checks on storage, embedder, and LLM. */
|
|
218
|
+
diagnose(): any
|
|
219
|
+
/** Check if an LLM provider is configured. */
|
|
220
|
+
hasLlm(): boolean
|
|
221
|
+
/** Persist LLM configuration to the database. */
|
|
222
|
+
saveLlmConfig(apiKey: string, model: string, baseUrl: string): void
|
|
223
|
+
/** Load persisted LLM configuration. Returns [apiKey, model, baseUrl] or null. */
|
|
224
|
+
loadLlmConfig(): Array<string> | null
|
|
225
|
+
/** Add a memory (vector dedup, no LLM). */
|
|
226
|
+
add(content: string, userId: string, agentId?: string | undefined | null, runId?: string | undefined | null, metadata?: string | undefined | null): Promise<MemoryResult>
|
|
227
|
+
/** Search memories. */
|
|
228
|
+
search(query: string, userId: string, agentId?: string | undefined | null, runId?: string | undefined | null, limit?: number | undefined | null, threshold?: number | undefined | null): Promise<Array<MemoryResult>>
|
|
229
|
+
/** Get a memory by ID. */
|
|
230
|
+
get(id: string): Promise<MemoryResult | null>
|
|
231
|
+
/** Update a memory. */
|
|
232
|
+
update(id: string, content: string): Promise<MemoryResult>
|
|
233
|
+
/** Delete a memory. */
|
|
234
|
+
delete(id: string): Promise<void>
|
|
235
|
+
/** List memories. */
|
|
236
|
+
list(userId: string, agentId?: string | undefined | null, runId?: string | undefined | null, limit?: number | undefined | null): Promise<Array<MemoryResult>>
|
|
237
|
+
/**
|
|
238
|
+
* Hybrid search (vector + FTS with RRF fusion).
|
|
239
|
+
*
|
|
240
|
+
* RRF weights are configured at store construction time.
|
|
241
|
+
*/
|
|
242
|
+
hybridSearch(query: string, userId: string, agentId?: string | undefined | null, runId?: string | undefined | null, limit?: number | undefined | null): Promise<Array<MemoryResult>>
|
|
243
|
+
/** Rebuild FTS index. */
|
|
244
|
+
rebuildFtsIndex(): Promise<void>
|
|
245
|
+
/** Delete all memories matching filters. */
|
|
246
|
+
deleteAll(userId: string, agentId?: string | undefined | null, runId?: string | undefined | null, appId?: string | undefined | null): Promise<number>
|
|
247
|
+
/** Get change history for a memory. */
|
|
248
|
+
history(memoryId: string): Promise<Array<HistoryRecord>>
|
|
249
|
+
/** Reset the entire store — delete ALL data. Destructive. */
|
|
250
|
+
reset(): Promise<void>
|
|
251
|
+
/** Append chat messages as events to a session. Returns whether compact is needed. */
|
|
252
|
+
appendEvents(sessionId: string, messages: Array<ChatMessage>, userId: string, metadata?: string | undefined | null): Promise<AppendEventsResult>
|
|
253
|
+
/** Compact a session: extract memories + create episode from unprocessed events. */
|
|
254
|
+
compact(sessionId: string): Promise<CompactResult>
|
|
255
|
+
/** Get a session by ID. */
|
|
256
|
+
getSession(sessionId: string): Promise<Session | null>
|
|
257
|
+
/** List sessions for a user. */
|
|
258
|
+
listSessions(userId: string, sourceId?: string | undefined | null, since?: string | undefined | null, until?: string | undefined | null, limit?: number | undefined | null, offset?: number | undefined | null): Promise<Array<Session>>
|
|
259
|
+
/** Delete a session and its events. */
|
|
260
|
+
deleteSession(sessionId: string): Promise<void>
|
|
261
|
+
/** Get events in a session (paginated). */
|
|
262
|
+
getSessionEvents(sessionId: string, limit?: number | undefined | null, offset?: number | undefined | null): Promise<Array<StreamEvent>>
|
|
263
|
+
/** Assemble session context for RAG with token budget. */
|
|
264
|
+
getSessionContext(sessionId: string, tokenBudget?: number | undefined | null, includeSummary?: boolean | undefined | null, maxEvents?: number | undefined | null): Promise<SessionContext>
|
|
265
|
+
/** List episodes for a user. */
|
|
266
|
+
listEpisodes(userId: string, limit?: number | undefined | null, offset?: number | undefined | null, since?: string | undefined | null, until?: string | undefined | null): Promise<Array<Episode>>
|
|
267
|
+
/** Get an episode by ID. */
|
|
268
|
+
getEpisode(episodeId: string): Promise<Episode | null>
|
|
269
|
+
/** Get messages (events) in an episode. */
|
|
270
|
+
getEpisodeMessages(episodeId: string, limit?: number | undefined | null, offset?: number | undefined | null): Promise<Array<StreamEvent>>
|
|
271
|
+
/** Search episodes by semantic similarity. */
|
|
272
|
+
searchEpisodes(query: string, userId: string, limit?: number | undefined | null): Promise<Array<Episode>>
|
|
273
|
+
/** Search messages within an episode by semantic similarity. */
|
|
274
|
+
searchEpisodeMessages(episodeId: string, query: string, limit?: number | undefined | null): Promise<Array<StreamEvent>>
|
|
275
|
+
/** Delete an episode. */
|
|
276
|
+
deleteEpisode(episodeId: string): Promise<void>
|
|
277
|
+
/** List all identity traits for a user. */
|
|
278
|
+
listIdentityTraits(userId: string): Promise<Array<IdentityTrait>>
|
|
279
|
+
/** Add or update an identity trait. */
|
|
280
|
+
addIdentityTrait(traitType: string, content: string, userId: string, confidence?: number | undefined | null, evidenceIds?: Array<string> | undefined | null): Promise<IdentityTrait>
|
|
281
|
+
/** Trigger deep processing (meditation): decay, extraction, graph, identity. */
|
|
282
|
+
meditate(userId: string, triggeredBy: string, since?: string | undefined | null): Promise<MeditationRecord>
|
|
283
|
+
/** Add graph with LLM. */
|
|
284
|
+
addGraph(text: string, userId: string, llmApiKey: string, llmModel?: string | undefined | null, llmBaseUrl?: string | undefined | null): Promise<GraphSearchResult>
|
|
285
|
+
/** Search graph (no LLM). */
|
|
286
|
+
searchGraph(query: string, userId: string, depth?: number | undefined | null): Promise<GraphSearchResult>
|
|
287
|
+
/** Get summary statistics for a user. */
|
|
288
|
+
userStats(userId: string): Promise<UserStats>
|
|
289
|
+
/** Get memory creation frequency by time period. */
|
|
290
|
+
memoryFrequency(userId: string, granularity: string, limit?: number | undefined | null): Promise<Array<TimeBucket>>
|
|
291
|
+
/** Get top entities by relationship count. */
|
|
292
|
+
topEntities(userId: string, limit?: number | undefined | null): Promise<Array<EntityStat>>
|
|
293
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* prettier-ignore */
|
|
4
|
+
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
6
|
+
|
|
7
|
+
const { existsSync, readFileSync } = require('fs')
|
|
8
|
+
const { join } = require('path')
|
|
9
|
+
|
|
10
|
+
const { platform, arch } = process
|
|
11
|
+
|
|
12
|
+
let nativeBinding = null
|
|
13
|
+
let localFileExisted = false
|
|
14
|
+
let loadError = null
|
|
15
|
+
|
|
16
|
+
function isMusl() {
|
|
17
|
+
// For Node 10
|
|
18
|
+
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
19
|
+
try {
|
|
20
|
+
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
21
|
+
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
const { glibcVersionRuntime } = process.report.getReport().header
|
|
27
|
+
return !glibcVersionRuntime
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
switch (platform) {
|
|
32
|
+
case 'android':
|
|
33
|
+
switch (arch) {
|
|
34
|
+
case 'arm64':
|
|
35
|
+
localFileExisted = existsSync(join(__dirname, 'memme.android-arm64.node'))
|
|
36
|
+
try {
|
|
37
|
+
if (localFileExisted) {
|
|
38
|
+
nativeBinding = require('./memme.android-arm64.node')
|
|
39
|
+
} else {
|
|
40
|
+
nativeBinding = require('memme-android-arm64')
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
loadError = e
|
|
44
|
+
}
|
|
45
|
+
break
|
|
46
|
+
case 'arm':
|
|
47
|
+
localFileExisted = existsSync(join(__dirname, 'memme.android-arm-eabi.node'))
|
|
48
|
+
try {
|
|
49
|
+
if (localFileExisted) {
|
|
50
|
+
nativeBinding = require('./memme.android-arm-eabi.node')
|
|
51
|
+
} else {
|
|
52
|
+
nativeBinding = require('memme-android-arm-eabi')
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
loadError = e
|
|
56
|
+
}
|
|
57
|
+
break
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
60
|
+
}
|
|
61
|
+
break
|
|
62
|
+
case 'win32':
|
|
63
|
+
switch (arch) {
|
|
64
|
+
case 'x64':
|
|
65
|
+
localFileExisted = existsSync(
|
|
66
|
+
join(__dirname, 'memme.win32-x64-msvc.node')
|
|
67
|
+
)
|
|
68
|
+
try {
|
|
69
|
+
if (localFileExisted) {
|
|
70
|
+
nativeBinding = require('./memme.win32-x64-msvc.node')
|
|
71
|
+
} else {
|
|
72
|
+
nativeBinding = require('memme-win32-x64-msvc')
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadError = e
|
|
76
|
+
}
|
|
77
|
+
break
|
|
78
|
+
case 'ia32':
|
|
79
|
+
localFileExisted = existsSync(
|
|
80
|
+
join(__dirname, 'memme.win32-ia32-msvc.node')
|
|
81
|
+
)
|
|
82
|
+
try {
|
|
83
|
+
if (localFileExisted) {
|
|
84
|
+
nativeBinding = require('./memme.win32-ia32-msvc.node')
|
|
85
|
+
} else {
|
|
86
|
+
nativeBinding = require('memme-win32-ia32-msvc')
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {
|
|
89
|
+
loadError = e
|
|
90
|
+
}
|
|
91
|
+
break
|
|
92
|
+
case 'arm64':
|
|
93
|
+
localFileExisted = existsSync(
|
|
94
|
+
join(__dirname, 'memme.win32-arm64-msvc.node')
|
|
95
|
+
)
|
|
96
|
+
try {
|
|
97
|
+
if (localFileExisted) {
|
|
98
|
+
nativeBinding = require('./memme.win32-arm64-msvc.node')
|
|
99
|
+
} else {
|
|
100
|
+
nativeBinding = require('memme-win32-arm64-msvc')
|
|
101
|
+
}
|
|
102
|
+
} catch (e) {
|
|
103
|
+
loadError = e
|
|
104
|
+
}
|
|
105
|
+
break
|
|
106
|
+
default:
|
|
107
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
108
|
+
}
|
|
109
|
+
break
|
|
110
|
+
case 'darwin':
|
|
111
|
+
localFileExisted = existsSync(join(__dirname, 'memme.darwin-universal.node'))
|
|
112
|
+
try {
|
|
113
|
+
if (localFileExisted) {
|
|
114
|
+
nativeBinding = require('./memme.darwin-universal.node')
|
|
115
|
+
} else {
|
|
116
|
+
nativeBinding = require('memme-darwin-universal')
|
|
117
|
+
}
|
|
118
|
+
break
|
|
119
|
+
} catch {}
|
|
120
|
+
switch (arch) {
|
|
121
|
+
case 'x64':
|
|
122
|
+
localFileExisted = existsSync(join(__dirname, 'memme.darwin-x64.node'))
|
|
123
|
+
try {
|
|
124
|
+
if (localFileExisted) {
|
|
125
|
+
nativeBinding = require('./memme.darwin-x64.node')
|
|
126
|
+
} else {
|
|
127
|
+
nativeBinding = require('memme-darwin-x64')
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
loadError = e
|
|
131
|
+
}
|
|
132
|
+
break
|
|
133
|
+
case 'arm64':
|
|
134
|
+
localFileExisted = existsSync(
|
|
135
|
+
join(__dirname, 'memme.darwin-arm64.node')
|
|
136
|
+
)
|
|
137
|
+
try {
|
|
138
|
+
if (localFileExisted) {
|
|
139
|
+
nativeBinding = require('./memme.darwin-arm64.node')
|
|
140
|
+
} else {
|
|
141
|
+
nativeBinding = require('memme-darwin-arm64')
|
|
142
|
+
}
|
|
143
|
+
} catch (e) {
|
|
144
|
+
loadError = e
|
|
145
|
+
}
|
|
146
|
+
break
|
|
147
|
+
default:
|
|
148
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
149
|
+
}
|
|
150
|
+
break
|
|
151
|
+
case 'freebsd':
|
|
152
|
+
if (arch !== 'x64') {
|
|
153
|
+
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
154
|
+
}
|
|
155
|
+
localFileExisted = existsSync(join(__dirname, 'memme.freebsd-x64.node'))
|
|
156
|
+
try {
|
|
157
|
+
if (localFileExisted) {
|
|
158
|
+
nativeBinding = require('./memme.freebsd-x64.node')
|
|
159
|
+
} else {
|
|
160
|
+
nativeBinding = require('memme-freebsd-x64')
|
|
161
|
+
}
|
|
162
|
+
} catch (e) {
|
|
163
|
+
loadError = e
|
|
164
|
+
}
|
|
165
|
+
break
|
|
166
|
+
case 'linux':
|
|
167
|
+
switch (arch) {
|
|
168
|
+
case 'x64':
|
|
169
|
+
if (isMusl()) {
|
|
170
|
+
localFileExisted = existsSync(
|
|
171
|
+
join(__dirname, 'memme.linux-x64-musl.node')
|
|
172
|
+
)
|
|
173
|
+
try {
|
|
174
|
+
if (localFileExisted) {
|
|
175
|
+
nativeBinding = require('./memme.linux-x64-musl.node')
|
|
176
|
+
} else {
|
|
177
|
+
nativeBinding = require('memme-linux-x64-musl')
|
|
178
|
+
}
|
|
179
|
+
} catch (e) {
|
|
180
|
+
loadError = e
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
localFileExisted = existsSync(
|
|
184
|
+
join(__dirname, 'memme.linux-x64-gnu.node')
|
|
185
|
+
)
|
|
186
|
+
try {
|
|
187
|
+
if (localFileExisted) {
|
|
188
|
+
nativeBinding = require('./memme.linux-x64-gnu.node')
|
|
189
|
+
} else {
|
|
190
|
+
nativeBinding = require('memme-linux-x64-gnu')
|
|
191
|
+
}
|
|
192
|
+
} catch (e) {
|
|
193
|
+
loadError = e
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
break
|
|
197
|
+
case 'arm64':
|
|
198
|
+
if (isMusl()) {
|
|
199
|
+
localFileExisted = existsSync(
|
|
200
|
+
join(__dirname, 'memme.linux-arm64-musl.node')
|
|
201
|
+
)
|
|
202
|
+
try {
|
|
203
|
+
if (localFileExisted) {
|
|
204
|
+
nativeBinding = require('./memme.linux-arm64-musl.node')
|
|
205
|
+
} else {
|
|
206
|
+
nativeBinding = require('memme-linux-arm64-musl')
|
|
207
|
+
}
|
|
208
|
+
} catch (e) {
|
|
209
|
+
loadError = e
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
localFileExisted = existsSync(
|
|
213
|
+
join(__dirname, 'memme.linux-arm64-gnu.node')
|
|
214
|
+
)
|
|
215
|
+
try {
|
|
216
|
+
if (localFileExisted) {
|
|
217
|
+
nativeBinding = require('./memme.linux-arm64-gnu.node')
|
|
218
|
+
} else {
|
|
219
|
+
nativeBinding = require('memme-linux-arm64-gnu')
|
|
220
|
+
}
|
|
221
|
+
} catch (e) {
|
|
222
|
+
loadError = e
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
break
|
|
226
|
+
case 'arm':
|
|
227
|
+
if (isMusl()) {
|
|
228
|
+
localFileExisted = existsSync(
|
|
229
|
+
join(__dirname, 'memme.linux-arm-musleabihf.node')
|
|
230
|
+
)
|
|
231
|
+
try {
|
|
232
|
+
if (localFileExisted) {
|
|
233
|
+
nativeBinding = require('./memme.linux-arm-musleabihf.node')
|
|
234
|
+
} else {
|
|
235
|
+
nativeBinding = require('memme-linux-arm-musleabihf')
|
|
236
|
+
}
|
|
237
|
+
} catch (e) {
|
|
238
|
+
loadError = e
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
localFileExisted = existsSync(
|
|
242
|
+
join(__dirname, 'memme.linux-arm-gnueabihf.node')
|
|
243
|
+
)
|
|
244
|
+
try {
|
|
245
|
+
if (localFileExisted) {
|
|
246
|
+
nativeBinding = require('./memme.linux-arm-gnueabihf.node')
|
|
247
|
+
} else {
|
|
248
|
+
nativeBinding = require('memme-linux-arm-gnueabihf')
|
|
249
|
+
}
|
|
250
|
+
} catch (e) {
|
|
251
|
+
loadError = e
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
break
|
|
255
|
+
case 'riscv64':
|
|
256
|
+
if (isMusl()) {
|
|
257
|
+
localFileExisted = existsSync(
|
|
258
|
+
join(__dirname, 'memme.linux-riscv64-musl.node')
|
|
259
|
+
)
|
|
260
|
+
try {
|
|
261
|
+
if (localFileExisted) {
|
|
262
|
+
nativeBinding = require('./memme.linux-riscv64-musl.node')
|
|
263
|
+
} else {
|
|
264
|
+
nativeBinding = require('memme-linux-riscv64-musl')
|
|
265
|
+
}
|
|
266
|
+
} catch (e) {
|
|
267
|
+
loadError = e
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
localFileExisted = existsSync(
|
|
271
|
+
join(__dirname, 'memme.linux-riscv64-gnu.node')
|
|
272
|
+
)
|
|
273
|
+
try {
|
|
274
|
+
if (localFileExisted) {
|
|
275
|
+
nativeBinding = require('./memme.linux-riscv64-gnu.node')
|
|
276
|
+
} else {
|
|
277
|
+
nativeBinding = require('memme-linux-riscv64-gnu')
|
|
278
|
+
}
|
|
279
|
+
} catch (e) {
|
|
280
|
+
loadError = e
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
break
|
|
284
|
+
case 's390x':
|
|
285
|
+
localFileExisted = existsSync(
|
|
286
|
+
join(__dirname, 'memme.linux-s390x-gnu.node')
|
|
287
|
+
)
|
|
288
|
+
try {
|
|
289
|
+
if (localFileExisted) {
|
|
290
|
+
nativeBinding = require('./memme.linux-s390x-gnu.node')
|
|
291
|
+
} else {
|
|
292
|
+
nativeBinding = require('memme-linux-s390x-gnu')
|
|
293
|
+
}
|
|
294
|
+
} catch (e) {
|
|
295
|
+
loadError = e
|
|
296
|
+
}
|
|
297
|
+
break
|
|
298
|
+
default:
|
|
299
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
300
|
+
}
|
|
301
|
+
break
|
|
302
|
+
default:
|
|
303
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (!nativeBinding) {
|
|
307
|
+
if (loadError) {
|
|
308
|
+
throw loadError
|
|
309
|
+
}
|
|
310
|
+
throw new Error(`Failed to load native binding`)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const { MemoryStore } = nativeBinding
|
|
314
|
+
|
|
315
|
+
module.exports.MemoryStore = MemoryStore
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wjmwjmwb/memme",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Edge-first AI memory engine powered by SQLite — vector search, knowledge graph, BM25, and forgetting curve in a single file",
|
|
5
|
+
"keywords": ["ai", "memory", "embedding", "sqlite", "edge", "offline", "vector-database", "knowledge-graph", "rag", "llm"],
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "MemMe Contributors",
|
|
8
|
+
"os": ["darwin", "linux"],
|
|
9
|
+
"homepage": "https://github.com/vibeinging/MemMe",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/vibeinging/MemMe.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/vibeinging/MemMe/issues"
|
|
16
|
+
},
|
|
17
|
+
"main": "index.js",
|
|
18
|
+
"types": "index.d.ts",
|
|
19
|
+
"napi": {
|
|
20
|
+
"name": "memme",
|
|
21
|
+
"triples": {
|
|
22
|
+
"defaults": false,
|
|
23
|
+
"additional": [
|
|
24
|
+
"x86_64-apple-darwin",
|
|
25
|
+
"aarch64-apple-darwin",
|
|
26
|
+
"x86_64-unknown-linux-gnu",
|
|
27
|
+
"aarch64-unknown-linux-gnu"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"index.js",
|
|
33
|
+
"index.d.ts",
|
|
34
|
+
"README.md",
|
|
35
|
+
"package.json"
|
|
36
|
+
],
|
|
37
|
+
"optionalDependencies": {
|
|
38
|
+
"memme-darwin-arm64": "0.1.1",
|
|
39
|
+
"memme-darwin-x64": "0.1.1",
|
|
40
|
+
"memme-linux-arm64-gnu": "0.1.1",
|
|
41
|
+
"memme-linux-x64-gnu": "0.1.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@napi-rs/cli": "^2.18.0",
|
|
45
|
+
"vitest": "^4.1.2"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"artifacts": "napi artifacts",
|
|
49
|
+
"build": "napi build --platform --release --cargo-cwd .",
|
|
50
|
+
"build:debug": "napi build --platform --cargo-cwd .",
|
|
51
|
+
"prepublishOnly": "napi prepublish -t npm",
|
|
52
|
+
"version": "napi version"
|
|
53
|
+
}
|
|
54
|
+
}
|