@equationalapplications/expo-llm-wiki 2.2.0 → 2.4.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 +31 -235
- package/dist/chunk-6DVBBIYR.mjs +24 -0
- package/dist/chunk-6DVBBIYR.mjs.map +1 -0
- package/dist/factory.d.mts +12 -0
- package/dist/factory.d.ts +12 -0
- package/dist/factory.js +56 -0
- package/dist/factory.js.map +1 -0
- package/dist/factory.mjs +13 -0
- package/dist/factory.mjs.map +1 -0
- package/dist/index.d.mts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +25 -1095
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +9 -1095
- package/dist/index.mjs.map +1 -0
- package/package.json +19 -46
- package/dist/WikiMemory-CjlQ68X0.d.mts +0 -180
- package/dist/WikiMemory-CjlQ68X0.d.ts +0 -180
- package/dist/react/index.d.mts +0 -79
- package/dist/react/index.d.ts +0 -79
- package/dist/react/index.js +0 -260
- package/dist/react/index.mjs +0 -226
package/README.md
CHANGED
|
@@ -1,273 +1,69 @@
|
|
|
1
|
-
# expo-llm-wiki
|
|
1
|
+
# @equationalapplications/expo-llm-wiki
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://www.npmjs.com/package/@equationalapplications/expo-llm-wiki)
|
|
5
|
-
[](https://www.npmjs.com/package/@equationalapplications/expo-llm-wiki)
|
|
6
|
-
[](LICENSE)
|
|
3
|
+
Expo/React Native adapter for @equationalapplications/core-llm-wiki, powered by `expo-sqlite`.
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
## Features
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- **
|
|
13
|
-
- **Namespace Safe:** All tables are prefixed (default: `llm_wiki_`) — no collisions with your existing database.
|
|
14
|
-
- **Multi-Entity:** Multiple independent "brains" in one database via `entityId`.
|
|
15
|
-
- **Offline First:** Reads are fully local via SQLite FTS5, typically under 50ms.
|
|
16
|
-
- **Morphological Matching:** Porter stemming enables recall across word forms — queries for `running` match facts about `run`, `runs`, etc., without manual synonym configuration.
|
|
17
|
-
- **Full Unicode Support:** UTF-8 and UTF-16 (including surrogate pairs for emoji) are fully supported. Chunks are split safely at sentence boundaries; surrogate pairs are never fragmented.
|
|
18
|
-
|
|
19
|
-
## How It Works
|
|
20
|
-
|
|
21
|
-
```mermaid
|
|
22
|
-
flowchart LR
|
|
23
|
-
subgraph API
|
|
24
|
-
direction TB
|
|
25
|
-
write["write(event)"]
|
|
26
|
-
ingest["ingestDocument()"]
|
|
27
|
-
librarian["runLibrarian()"]
|
|
28
|
-
heal["runHeal()"]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
subgraph SQLite
|
|
32
|
-
direction TB
|
|
33
|
-
events[(events)]
|
|
34
|
-
entries[("entries\n(facts)")]
|
|
35
|
-
tasks[(tasks)]
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
LLM["LLMProvider\n.generateText()"]
|
|
39
|
-
|
|
40
|
-
read["read(entityId, query)"]
|
|
41
|
-
FTS5(["FTS5 search"])
|
|
42
|
-
Bundle(["MemoryBundle\nfacts · tasks · events"])
|
|
43
|
-
|
|
44
|
-
write --> events
|
|
45
|
-
events -. "≥ threshold" .-> librarian
|
|
46
|
-
librarian --> LLM
|
|
47
|
-
heal --> LLM
|
|
48
|
-
ingest --> LLM
|
|
49
|
-
LLM --> entries
|
|
50
|
-
LLM --> tasks
|
|
51
|
-
|
|
52
|
-
read --> FTS5
|
|
53
|
-
FTS5 --> entries
|
|
54
|
-
entries --> Bundle
|
|
55
|
-
tasks --> Bundle
|
|
56
|
-
events --> Bundle
|
|
57
|
-
```
|
|
7
|
+
- **Expo-ready** — Pre-configured for React Native + Expo
|
|
8
|
+
- **Built on `expo-sqlite`** — Stable, well-supported SQLite driver
|
|
9
|
+
- **React hooks** — `WikiProvider`, `useMemoryRead`, and all other hooks are re-exported directly from `@equationalapplications/expo-llm-wiki`
|
|
58
10
|
|
|
59
11
|
## Installation
|
|
60
12
|
|
|
61
|
-
In your Expo project:
|
|
62
|
-
|
|
63
13
|
```bash
|
|
64
14
|
npx expo install expo-sqlite
|
|
65
|
-
npm install expo-llm-wiki
|
|
15
|
+
npm install @equationalapplications/expo-llm-wiki
|
|
66
16
|
```
|
|
67
17
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
## Setup
|
|
18
|
+
## Usage
|
|
71
19
|
|
|
72
20
|
```typescript
|
|
73
|
-
import { createWiki } from 'expo-llm-wiki';
|
|
74
|
-
import
|
|
21
|
+
import { createWiki } from '@equationalapplications/expo-llm-wiki';
|
|
22
|
+
import { openDatabaseSync } from 'expo-sqlite';
|
|
75
23
|
|
|
76
|
-
const db =
|
|
24
|
+
const db = openDatabaseSync('wiki.db');
|
|
77
25
|
|
|
78
26
|
const wiki = createWiki(db, {
|
|
79
27
|
llmProvider: {
|
|
80
28
|
generateText: async ({ systemPrompt, userPrompt }) => {
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
const response = await openai.chat.completions.create({
|
|
84
|
-
model: 'gpt-4o-mini',
|
|
85
|
-
messages: [
|
|
86
|
-
{ role: 'system', content: systemPrompt },
|
|
87
|
-
{ role: 'user', content: userPrompt },
|
|
88
|
-
],
|
|
89
|
-
});
|
|
90
|
-
return response.choices[0].message.content ?? '{}';
|
|
29
|
+
// Your LLM call — must return the model output as a string
|
|
30
|
+
return 'Model output';
|
|
91
31
|
},
|
|
92
32
|
},
|
|
93
|
-
config: {
|
|
94
|
-
tablePrefix: 'llm_wiki_', // optional, default: 'llm_wiki_'
|
|
95
|
-
maxFtsResults: 10, // optional, default: 10
|
|
96
|
-
autoLibrarianThreshold: 20, // optional, default: 20
|
|
97
|
-
maxChunkLength: 6000, // optional, default: 6000 (char count, not bytes)
|
|
98
|
-
chunkOverlap: 400, // optional, default: 400 (overlap between chunks in characters)
|
|
99
|
-
chunkConcurrency: 1, // optional, default: 1 (parallel LLM calls per ingestDocument)
|
|
100
|
-
},
|
|
101
33
|
});
|
|
102
34
|
|
|
103
|
-
//
|
|
35
|
+
// Initialize tables (call once on app startup)
|
|
104
36
|
await wiki.setup();
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## Core API
|
|
108
|
-
|
|
109
|
-
### Read
|
|
110
37
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
```typescript
|
|
114
|
-
const { facts, tasks, events } = await wiki.read('entity-123', 'weekend plans');
|
|
115
|
-
// facts: WikiFact[] — matched by FTS5, ranked by confidence + access count
|
|
116
|
-
// tasks: WikiTask[] — pending and in-progress only
|
|
117
|
-
// events: WikiEvent[] — 10 most recent, ascending
|
|
38
|
+
// Use wiki instance
|
|
39
|
+
await wiki.write('user-123', { event_type: 'observation', summary: '...' });
|
|
118
40
|
```
|
|
119
41
|
|
|
120
|
-
|
|
42
|
+
## With React
|
|
121
43
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
Log an episodic event. Automatically triggers the librarian pass once enough events accumulate:
|
|
44
|
+
`@equationalapplications/expo-llm-wiki` re-exports all hooks and `WikiProvider` from `@equationalapplications/react-llm-wiki`:
|
|
125
45
|
|
|
126
46
|
```typescript
|
|
127
|
-
|
|
128
|
-
event_type: 'observation',
|
|
129
|
-
summary: 'User mentioned they love hiking on weekends.',
|
|
130
|
-
});
|
|
131
|
-
// event_type: 'observation' | 'decision' | 'action' | 'outcome'
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### Ingest Document
|
|
135
|
-
|
|
136
|
-
Extract facts from a document (chunked internally). Idempotent — re-calling with the same `sourceRef` replaces the prior extraction. Documents are automatically chunked at sentence boundaries; if a sentence exceeds `maxChunkLength`, it is hard-split.
|
|
137
|
-
|
|
138
|
-
```typescript
|
|
139
|
-
const result = await wiki.ingestDocument('entity-123', {
|
|
140
|
-
// sourceRef is normalized: only [A-Za-z0-9._\- ] are kept, all other characters
|
|
141
|
-
// (including `/`) are stripped. Use underscores or dots as path separators to
|
|
142
|
-
// avoid accidental collisions (e.g. 'docs_preferences.md' not 'docs/preferences.md').
|
|
143
|
-
sourceRef: 'preferences.md', // stable identifier
|
|
144
|
-
sourceHash: sha256(content), // for change detection
|
|
145
|
-
documentChunk: content,
|
|
146
|
-
maxChunkLength: 12000, // optional, character count
|
|
147
|
-
chunkOverlap: 400, // optional, overlap in characters
|
|
148
|
-
chunkConcurrency: 1, // optional, parallel LLM calls per ingest (default: 1)
|
|
149
|
-
});
|
|
150
|
-
// result: { truncated: boolean; chunks: number }
|
|
151
|
-
// truncated: true if at least one hard-split was required (no sentence boundary)
|
|
152
|
-
// chunks: number of LLM calls made
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### Background Maintenance
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
// Consolidate recent events into durable facts (auto-triggered by write, or call manually)
|
|
159
|
-
await wiki.runLibrarian('entity-123');
|
|
47
|
+
import { WikiProvider } from '@equationalapplications/expo-llm-wiki';
|
|
160
48
|
|
|
161
|
-
|
|
162
|
-
|
|
49
|
+
<WikiProvider wiki={wiki}>
|
|
50
|
+
<MyApp />
|
|
51
|
+
</WikiProvider>
|
|
163
52
|
```
|
|
164
53
|
|
|
165
|
-
|
|
54
|
+
Then use hooks in components:
|
|
166
55
|
|
|
167
56
|
```typescript
|
|
168
|
-
|
|
169
|
-
// result: { deleted: { entries: number; tasks: number } }
|
|
170
|
-
|
|
171
|
-
await wiki.forget('entity-123', { taskId: 'task_xyz' }); // single task
|
|
172
|
-
// sourceRef is normalized the same way as in ingestDocument (slashes stripped)
|
|
173
|
-
await wiki.forget('entity-123', { sourceRef: 'x.md' }); // all facts from a document
|
|
174
|
-
await wiki.forget('entity-123', { clearAll: true }); // wipe entity
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
Throws `Error` if `sourceRef` or `sourceHash` is provided but invalid. Soft-deletes are idempotent — calling again with the same parameters returns `{ deleted: { entries: 0; tasks: 0 } }`.
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
## React / Expo Component API
|
|
182
|
-
|
|
183
|
-
Import from `expo-llm-wiki/react`. This entry point is separate so non-React consumers do not transitively import React.
|
|
184
|
-
|
|
185
|
-
### Provider
|
|
186
|
-
|
|
187
|
-
Wrap once at app root (or any subtree that needs memory access):
|
|
57
|
+
import { useMemoryRead } from '@equationalapplications/expo-llm-wiki';
|
|
188
58
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
export default function App() {
|
|
196
|
-
return (
|
|
197
|
-
<WikiProvider wiki={wiki}>
|
|
198
|
-
<YourApp />
|
|
199
|
-
</WikiProvider>
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### `useMemoryRead(entityId, query)`
|
|
205
|
-
|
|
206
|
-
Reactive read. Fetches on mount and whenever `entityId` or `query` changes. In-flight results always land before a queued re-fetch starts — results are never silently discarded.
|
|
207
|
-
|
|
208
|
-
```typescript
|
|
209
|
-
const { data, isPending, error, refetch } = useMemoryRead('entity-123', 'weekend plans');
|
|
210
|
-
// data: MemoryBundle | null
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
### `useWikiWrite()`
|
|
214
|
-
|
|
215
|
-
```typescript
|
|
216
|
-
const { execute, isPending, error } = useWikiWrite();
|
|
217
|
-
|
|
218
|
-
await execute('entity-123', {
|
|
219
|
-
event_type: 'observation',
|
|
220
|
-
summary: 'User mentioned they love hiking.',
|
|
221
|
-
});
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### `useWikiMaintenance()`
|
|
225
|
-
|
|
226
|
-
Shared `isPending` — true if either operation is in-flight:
|
|
227
|
-
|
|
228
|
-
```typescript
|
|
229
|
-
const { runLibrarian, runHeal, isPending, error } = useWikiMaintenance();
|
|
230
|
-
|
|
231
|
-
await runLibrarian('entity-123');
|
|
232
|
-
await runHeal('entity-123');
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### `useWikiIngest()`
|
|
236
|
-
|
|
237
|
-
```typescript
|
|
238
|
-
const { execute, lastResult, isPending, error } = useWikiIngest();
|
|
239
|
-
// lastResult: { truncated: boolean; chunks: number } | null
|
|
240
|
-
|
|
241
|
-
const result = await execute('entity-123', {
|
|
242
|
-
sourceRef: 'preferences.md', // slashes are stripped by normalizeSourceRef
|
|
243
|
-
sourceHash: sha256(content),
|
|
244
|
-
documentChunk: content,
|
|
245
|
-
});
|
|
246
|
-
// result.truncated — true if any hard-splits were required
|
|
247
|
-
// result.chunks — number of LLM calls made
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
### `useWikiForget()`
|
|
251
|
-
|
|
252
|
-
```typescript
|
|
253
|
-
const { execute, lastResult, isPending, error } = useWikiForget();
|
|
254
|
-
// lastResult: { deleted: { entries: number; tasks: number } } | null
|
|
255
|
-
|
|
256
|
-
const result = await execute('entity-123', { entryId: 'fact_abc' });
|
|
257
|
-
// result.deleted.entries — rows soft-deleted
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
All mutation hooks follow the same pattern (`TResult` is specific per hook):
|
|
261
|
-
|
|
262
|
-
```typescript
|
|
263
|
-
{
|
|
264
|
-
execute: (...args) => Promise<TResult>;
|
|
265
|
-
lastResult: TResult | null; // result of the last successful call; null before first call or after an error
|
|
266
|
-
isPending: boolean;
|
|
267
|
-
error: Error | null; // cleared on the next execute call
|
|
59
|
+
export function UserProfile({ userId }: { userId: string }) {
|
|
60
|
+
const { data, isPending } = useMemoryRead(userId, 'preferences');
|
|
61
|
+
|
|
62
|
+
if (isPending) return <Text>Loading...</Text>;
|
|
63
|
+
return <Text>{data?.facts.map(f => f.title).join(', ')}</Text>;
|
|
268
64
|
}
|
|
269
65
|
```
|
|
270
66
|
|
|
271
|
-
|
|
67
|
+
## License
|
|
272
68
|
|
|
273
|
-
|
|
69
|
+
MIT
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/adapter.ts
|
|
2
|
+
function createExpoAdapter(db) {
|
|
3
|
+
return {
|
|
4
|
+
execAsync: (sql) => db.execAsync(sql),
|
|
5
|
+
runAsync: async (sql, params = []) => {
|
|
6
|
+
const result = await db.runAsync(sql, params);
|
|
7
|
+
return { changes: result.changes, lastInsertRowId: result.lastInsertRowId };
|
|
8
|
+
},
|
|
9
|
+
getAllAsync: (sql, params = []) => db.getAllAsync(sql, params),
|
|
10
|
+
getFirstAsync: (sql, params = []) => db.getFirstAsync(sql, params),
|
|
11
|
+
withTransactionAsync: (fn) => {
|
|
12
|
+
let captured;
|
|
13
|
+
return db.withTransactionAsync(() => fn().then((v) => {
|
|
14
|
+
captured = v;
|
|
15
|
+
})).then(() => captured);
|
|
16
|
+
},
|
|
17
|
+
closeAsync: () => db.closeAsync()
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
createExpoAdapter
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=chunk-6DVBBIYR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapter.ts"],"sourcesContent":["import type * as SQLite from 'expo-sqlite';\nimport type { SQLiteAdapter } from '@equationalapplications/core-llm-wiki';\n\nexport function createExpoAdapter(db: SQLite.SQLiteDatabase): SQLiteAdapter {\n return {\n execAsync: (sql) => db.execAsync(sql),\n runAsync: async (sql, params = []) => {\n const result = await db.runAsync(sql, params as any[]);\n return { changes: result.changes, lastInsertRowId: result.lastInsertRowId };\n },\n getAllAsync: (sql, params = []) => db.getAllAsync(sql, params as any[]),\n getFirstAsync: (sql, params = []) => db.getFirstAsync(sql, params as any[]),\n withTransactionAsync: (fn) => {\n // expo-sqlite only accepts () => Promise<void>; capture the result to satisfy the generic interface\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let captured: any;\n return db.withTransactionAsync(() => fn().then(v => { captured = v; })).then(() => captured);\n },\n closeAsync: () => db.closeAsync(),\n };\n}\n"],"mappings":";AAGO,SAAS,kBAAkB,IAA0C;AAC1E,SAAO;AAAA,IACL,WAAW,CAAC,QAAQ,GAAG,UAAU,GAAG;AAAA,IACpC,UAAU,OAAO,KAAK,SAAS,CAAC,MAAM;AACpC,YAAM,SAAS,MAAM,GAAG,SAAS,KAAK,MAAe;AACrD,aAAO,EAAE,SAAS,OAAO,SAAS,iBAAiB,OAAO,gBAAgB;AAAA,IAC5E;AAAA,IACA,aAAa,CAAC,KAAK,SAAS,CAAC,MAAM,GAAG,YAAY,KAAK,MAAe;AAAA,IACtE,eAAe,CAAC,KAAK,SAAS,CAAC,MAAM,GAAG,cAAc,KAAK,MAAe;AAAA,IAC1E,sBAAsB,CAAC,OAAO;AAG5B,UAAI;AACJ,aAAO,GAAG,qBAAqB,MAAM,GAAG,EAAE,KAAK,OAAK;AAAE,mBAAW;AAAA,MAAG,CAAC,CAAC,EAAE,KAAK,MAAM,QAAQ;AAAA,IAC7F;AAAA,IACA,YAAY,MAAM,GAAG,WAAW;AAAA,EAClC;AACF;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as SQLite from 'expo-sqlite';
|
|
2
|
+
import { WikiOptions, WikiMemory } from '@equationalapplications/core-llm-wiki';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create a WikiMemory instance from an expo-sqlite SQLiteDatabase.
|
|
6
|
+
* This factory is exported as a separate subpath (`@equationalapplications/expo-llm-wiki/factory`)
|
|
7
|
+
* so that callers can obtain `createWiki` without loading the React hooks
|
|
8
|
+
* that `@equationalapplications/expo-llm-wiki`'s main entry re-exports from `@equationalapplications/react-llm-wiki`.
|
|
9
|
+
*/
|
|
10
|
+
declare function createWiki(db: SQLite.SQLiteDatabase, options: WikiOptions): WikiMemory;
|
|
11
|
+
|
|
12
|
+
export { createWiki };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as SQLite from 'expo-sqlite';
|
|
2
|
+
import { WikiOptions, WikiMemory } from '@equationalapplications/core-llm-wiki';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create a WikiMemory instance from an expo-sqlite SQLiteDatabase.
|
|
6
|
+
* This factory is exported as a separate subpath (`@equationalapplications/expo-llm-wiki/factory`)
|
|
7
|
+
* so that callers can obtain `createWiki` without loading the React hooks
|
|
8
|
+
* that `@equationalapplications/expo-llm-wiki`'s main entry re-exports from `@equationalapplications/react-llm-wiki`.
|
|
9
|
+
*/
|
|
10
|
+
declare function createWiki(db: SQLite.SQLiteDatabase, options: WikiOptions): WikiMemory;
|
|
11
|
+
|
|
12
|
+
export { createWiki };
|
package/dist/factory.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/factory.ts
|
|
21
|
+
var factory_exports = {};
|
|
22
|
+
__export(factory_exports, {
|
|
23
|
+
createWiki: () => createWiki
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(factory_exports);
|
|
26
|
+
var import_core_llm_wiki = require("@equationalapplications/core-llm-wiki");
|
|
27
|
+
|
|
28
|
+
// src/adapter.ts
|
|
29
|
+
function createExpoAdapter(db) {
|
|
30
|
+
return {
|
|
31
|
+
execAsync: (sql) => db.execAsync(sql),
|
|
32
|
+
runAsync: async (sql, params = []) => {
|
|
33
|
+
const result = await db.runAsync(sql, params);
|
|
34
|
+
return { changes: result.changes, lastInsertRowId: result.lastInsertRowId };
|
|
35
|
+
},
|
|
36
|
+
getAllAsync: (sql, params = []) => db.getAllAsync(sql, params),
|
|
37
|
+
getFirstAsync: (sql, params = []) => db.getFirstAsync(sql, params),
|
|
38
|
+
withTransactionAsync: (fn) => {
|
|
39
|
+
let captured;
|
|
40
|
+
return db.withTransactionAsync(() => fn().then((v) => {
|
|
41
|
+
captured = v;
|
|
42
|
+
})).then(() => captured);
|
|
43
|
+
},
|
|
44
|
+
closeAsync: () => db.closeAsync()
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/factory.ts
|
|
49
|
+
function createWiki(db, options) {
|
|
50
|
+
return new import_core_llm_wiki.WikiMemory(createExpoAdapter(db), options);
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
createWiki
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/factory.ts","../src/adapter.ts"],"sourcesContent":["import type * as SQLite from 'expo-sqlite';\nimport { WikiMemory, type WikiOptions } from '@equationalapplications/core-llm-wiki';\nimport { createExpoAdapter } from './adapter';\n\n/**\n * Create a WikiMemory instance from an expo-sqlite SQLiteDatabase.\n * This factory is exported as a separate subpath (`@equationalapplications/expo-llm-wiki/factory`)\n * so that callers can obtain `createWiki` without loading the React hooks\n * that `@equationalapplications/expo-llm-wiki`'s main entry re-exports from `@equationalapplications/react-llm-wiki`.\n */\nexport function createWiki(db: SQLite.SQLiteDatabase, options: WikiOptions): WikiMemory {\n return new WikiMemory(createExpoAdapter(db), options);\n}\n","import type * as SQLite from 'expo-sqlite';\nimport type { SQLiteAdapter } from '@equationalapplications/core-llm-wiki';\n\nexport function createExpoAdapter(db: SQLite.SQLiteDatabase): SQLiteAdapter {\n return {\n execAsync: (sql) => db.execAsync(sql),\n runAsync: async (sql, params = []) => {\n const result = await db.runAsync(sql, params as any[]);\n return { changes: result.changes, lastInsertRowId: result.lastInsertRowId };\n },\n getAllAsync: (sql, params = []) => db.getAllAsync(sql, params as any[]),\n getFirstAsync: (sql, params = []) => db.getFirstAsync(sql, params as any[]),\n withTransactionAsync: (fn) => {\n // expo-sqlite only accepts () => Promise<void>; capture the result to satisfy the generic interface\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let captured: any;\n return db.withTransactionAsync(() => fn().then(v => { captured = v; })).then(() => captured);\n },\n closeAsync: () => db.closeAsync(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAA6C;;;ACEtC,SAAS,kBAAkB,IAA0C;AAC1E,SAAO;AAAA,IACL,WAAW,CAAC,QAAQ,GAAG,UAAU,GAAG;AAAA,IACpC,UAAU,OAAO,KAAK,SAAS,CAAC,MAAM;AACpC,YAAM,SAAS,MAAM,GAAG,SAAS,KAAK,MAAe;AACrD,aAAO,EAAE,SAAS,OAAO,SAAS,iBAAiB,OAAO,gBAAgB;AAAA,IAC5E;AAAA,IACA,aAAa,CAAC,KAAK,SAAS,CAAC,MAAM,GAAG,YAAY,KAAK,MAAe;AAAA,IACtE,eAAe,CAAC,KAAK,SAAS,CAAC,MAAM,GAAG,cAAc,KAAK,MAAe;AAAA,IAC1E,sBAAsB,CAAC,OAAO;AAG5B,UAAI;AACJ,aAAO,GAAG,qBAAqB,MAAM,GAAG,EAAE,KAAK,OAAK;AAAE,mBAAW;AAAA,MAAG,CAAC,CAAC,EAAE,KAAK,MAAM,QAAQ;AAAA,IAC7F;AAAA,IACA,YAAY,MAAM,GAAG,WAAW;AAAA,EAClC;AACF;;;ADVO,SAAS,WAAW,IAA2B,SAAkC;AACtF,SAAO,IAAI,gCAAW,kBAAkB,EAAE,GAAG,OAAO;AACtD;","names":[]}
|
package/dist/factory.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createExpoAdapter
|
|
3
|
+
} from "./chunk-6DVBBIYR.mjs";
|
|
4
|
+
|
|
5
|
+
// src/factory.ts
|
|
6
|
+
import { WikiMemory } from "@equationalapplications/core-llm-wiki";
|
|
7
|
+
function createWiki(db, options) {
|
|
8
|
+
return new WikiMemory(createExpoAdapter(db), options);
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
createWiki
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=factory.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/factory.ts"],"sourcesContent":["import type * as SQLite from 'expo-sqlite';\nimport { WikiMemory, type WikiOptions } from '@equationalapplications/core-llm-wiki';\nimport { createExpoAdapter } from './adapter';\n\n/**\n * Create a WikiMemory instance from an expo-sqlite SQLiteDatabase.\n * This factory is exported as a separate subpath (`@equationalapplications/expo-llm-wiki/factory`)\n * so that callers can obtain `createWiki` without loading the React hooks\n * that `@equationalapplications/expo-llm-wiki`'s main entry re-exports from `@equationalapplications/react-llm-wiki`.\n */\nexport function createWiki(db: SQLite.SQLiteDatabase, options: WikiOptions): WikiMemory {\n return new WikiMemory(createExpoAdapter(db), options);\n}\n"],"mappings":";;;;;AACA,SAAS,kBAAoC;AAStC,SAAS,WAAW,IAA2B,SAAkC;AACtF,SAAO,IAAI,WAAW,kBAAkB,EAAE,GAAG,OAAO;AACtD;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as SQLite from 'expo-sqlite';
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
declare function formatMemoryDump(dump: MemoryDump): FormattedMemoryDump;
|
|
2
|
+
import { WikiOptions, WikiMemory } from '@equationalapplications/core-llm-wiki';
|
|
3
|
+
export * from '@equationalapplications/core-llm-wiki';
|
|
4
|
+
export * from '@equationalapplications/react-llm-wiki';
|
|
6
5
|
|
|
7
6
|
declare function createWiki(db: SQLite.SQLiteDatabase, options: WikiOptions): WikiMemory;
|
|
8
7
|
|
|
9
|
-
export {
|
|
8
|
+
export { createWiki };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as SQLite from 'expo-sqlite';
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
declare function formatMemoryDump(dump: MemoryDump): FormattedMemoryDump;
|
|
2
|
+
import { WikiOptions, WikiMemory } from '@equationalapplications/core-llm-wiki';
|
|
3
|
+
export * from '@equationalapplications/core-llm-wiki';
|
|
4
|
+
export * from '@equationalapplications/react-llm-wiki';
|
|
6
5
|
|
|
7
6
|
declare function createWiki(db: SQLite.SQLiteDatabase, options: WikiOptions): WikiMemory;
|
|
8
7
|
|
|
9
|
-
export {
|
|
8
|
+
export { createWiki };
|