@equationalapplications/expo-llm-wiki 2.3.0 → 2.5.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 CHANGED
@@ -1,383 +1,69 @@
1
- # expo-llm-wiki
1
+ # @equationalapplications/expo-llm-wiki
2
2
 
3
- [![GitHub Tag](https://img.shields.io/github/v/tag/equationalapplications/expo-llm-wiki?label=github%20tag)](https://github.com/equationalapplications/expo-llm-wiki/tags)
4
- [![npm version](https://img.shields.io/npm/v/%40equationalapplications%2Fexpo-llm-wiki?label=npm)](https://www.npmjs.com/package/@equationalapplications/expo-llm-wiki)
5
- [![npm downloads](https://img.shields.io/npm/dm/%40equationalapplications%2Fexpo-llm-wiki?label=downloads)](https://www.npmjs.com/package/@equationalapplications/expo-llm-wiki)
6
- [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
3
+ Expo/React Native adapter for @equationalapplications/core-llm-wiki, powered by `expo-sqlite`.
7
4
 
8
- Offline-first, SQLite-backed memory for LLM apps built with Expo. Handles FTS5 search, episodic event logging, background fact extraction, and memory healing — bring your own LLM.
9
-
10
- ## Key Principles
11
-
12
- - **Bring Your Own Inference (BYOI):** Provide one `generateText` function. The package owns prompt construction, JSON parsing, and database writes.
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 TB
23
- subgraph API["API Layer"]
24
- direction TB
25
- write["write(event)"]
26
- ingest["ingestDocument()"]
27
- librarian["runLibrarian()"]
28
- heal["runHeal()"]
29
- read["read(entityId, query)"]
30
- end
31
-
32
- subgraph LLMLayer["LLM Provider"]
33
- LLM["LLMProvider.generateText()"]
34
- end
35
-
36
- subgraph SQLiteLayer["SQLite Database"]
37
- direction TB
38
- events[(events)]
39
- entries[("entries<br/>(facts)")]
40
- tasks[(tasks)]
41
- end
42
-
43
- subgraph ReadPath["Read Path"]
44
- FTS5(["FTS5 search"])
45
- Bundle(["MemoryBundle<br/>facts · tasks · events"])
46
- end
47
-
48
- %% Write paths
49
- write --> events
50
- events -. "≥ threshold" .-> librarian
51
-
52
- %% LLM calls
53
- librarian --> LLM
54
- heal --> LLM
55
- ingest --> LLM
56
-
57
- %% Database writes
58
- LLM --> entries
59
- LLM --> tasks
60
-
61
- %% Read path
62
- read --> FTS5
63
- FTS5 --> entries
64
- entries --> Bundle
65
- tasks --> Bundle
66
- events --> Bundle
67
- ```
5
+ ## Features
68
6
 
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`
69
10
 
70
11
  ## Installation
71
12
 
72
- In your Expo project:
73
-
74
13
  ```bash
75
14
  npx expo install expo-sqlite
76
- npm install expo-llm-wiki
15
+ npm install @equationalapplications/expo-llm-wiki
77
16
  ```
78
17
 
79
- Use `npx expo install` for `expo-sqlite` so Expo's version resolver picks the correct native build for your SDK version.
80
-
81
- ## Setup
18
+ ## Usage
82
19
 
83
20
  ```typescript
84
- import { createWiki } from 'expo-llm-wiki';
85
- import * as SQLite from 'expo-sqlite';
21
+ import { createWiki } from '@equationalapplications/expo-llm-wiki';
22
+ import { openDatabaseSync } from 'expo-sqlite';
86
23
 
87
- const db = await SQLite.openDatabaseAsync('my-app.db');
24
+ const db = openDatabaseSync('wiki.db');
88
25
 
89
26
  const wiki = createWiki(db, {
90
27
  llmProvider: {
91
28
  generateText: async ({ systemPrompt, userPrompt }) => {
92
- // Connect to OpenAI, Gemini, a local model, etc.
93
- // Must return a raw string (JSON, optionally in a markdown code fence).
94
- const response = await openai.chat.completions.create({
95
- model: 'gpt-4o-mini',
96
- messages: [
97
- { role: 'system', content: systemPrompt },
98
- { role: 'user', content: userPrompt },
99
- ],
100
- });
101
- return response.choices[0].message.content ?? '{}';
29
+ // Your LLM call must return the model output as a string
30
+ return 'Model output';
102
31
  },
103
32
  },
104
- config: {
105
- tablePrefix: 'llm_wiki_', // optional, default: 'llm_wiki_'
106
- maxFtsResults: 10, // optional, default: 10
107
- autoLibrarianThreshold: 20, // optional, default: 20
108
- maxChunkLength: 6000, // optional, default: 6000 (char count, not bytes)
109
- chunkOverlap: 400, // optional, default: 400 (overlap between chunks in characters)
110
- chunkConcurrency: 1, // optional, default: 1 (parallel LLM calls per ingestDocument)
111
- pruneRetainSoftDeletedFor: 7, // optional, default: 7 (days before hard-deleting soft-deleted rows)
112
- pruneEventsAfter: 30, // optional, default: 30 (days before hard-deleting old events)
113
- },
114
33
  });
115
34
 
116
- // Create tables and FTS5 indexes (call once on app startup)
35
+ // Initialize tables (call once on app startup)
117
36
  await wiki.setup();
118
- ```
119
-
120
- ## Core API
121
-
122
- ### Read
123
-
124
- FTS5 full-text search over facts, plus open tasks and recent events:
125
-
126
- ```typescript
127
- const { facts, tasks, events } = await wiki.read('entity-123', 'weekend plans');
128
- // facts: WikiFact[] — matched by FTS5, ranked by confidence + access count
129
- // tasks: WikiTask[] — pending and in-progress only
130
- // events: WikiEvent[] — 10 most recent, ascending
131
- ```
132
-
133
- Pass an empty string to skip FTS and return the most recently updated facts.
134
-
135
- ### Write
136
-
137
- Log an episodic event. Automatically triggers the librarian pass once enough events accumulate:
138
-
139
- ```typescript
140
- await wiki.write('entity-123', {
141
- event_type: 'observation',
142
- summary: 'User mentioned they love hiking on weekends.',
143
- });
144
- // event_type: 'observation' | 'decision' | 'action' | 'outcome'
145
- ```
146
-
147
- ### Ingest Document
148
-
149
- 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.
150
-
151
- ```typescript
152
- const result = await wiki.ingestDocument('entity-123', {
153
- // sourceRef is normalized: only [A-Za-z0-9._\- ] are kept, all other characters
154
- // (including `/`) are stripped. Use underscores or dots as path separators to
155
- // avoid accidental collisions (e.g. 'docs_preferences.md' not 'docs/preferences.md').
156
- sourceRef: 'preferences.md', // stable identifier
157
- sourceHash: sha256(content), // for change detection
158
- documentChunk: content,
159
- maxChunkLength: 12000, // optional, character count
160
- chunkOverlap: 400, // optional, overlap in characters
161
- chunkConcurrency: 1, // optional, parallel LLM calls per ingest (default: 1)
162
- });
163
- // result: { truncated: boolean; chunks: number }
164
- // truncated: true if at least one hard-split was required (no sentence boundary)
165
- // chunks: number of LLM calls made
166
- ```
167
-
168
- ### Background Maintenance
169
-
170
- ```typescript
171
- // Consolidate recent events into durable facts (auto-triggered by write, or call manually)
172
- await wiki.runLibrarian('entity-123');
173
-
174
- // Resolve contradictions, downgrade stale claims, remove obsolete facts
175
- await wiki.runHeal('entity-123');
176
- ```
177
-
178
- ### Format Context
179
-
180
- Convert a `MemoryBundle` into a string ready for LLM prompt injection:
181
-
182
- ```typescript
183
- import { formatContext } from 'expo-llm-wiki';
184
-
185
- const bundle = await wiki.read('entity-123', 'weekend plans');
186
- const context = formatContext(bundle, {
187
- format: 'markdown', // 'markdown' (default) | 'plain'
188
- maxFacts: 10, // default 10
189
- maxTasks: 10, // default 10
190
- maxEvents: 10, // default 10
191
- includeConfidence: true, // default true — appends (certain/inferred/tentative)
192
- includeTags: true, // default true — appends [tag1, tag2]
193
- factWeights: {
194
- confidence: 1.0, // default 1.0
195
- accessCount: 0.3, // default 0.3 — log(1 + access_count) * weight
196
- recency: 0.5, // default 0.5 — decays over 30d
197
- },
198
- });
199
-
200
- // Inject into your system prompt:
201
- const systemPrompt = `You are a helpful assistant.\n\n${context}`;
202
- ```
203
-
204
- Facts are ranked by a weighted score combining confidence tier, access frequency, and recency. Returns an empty string for an empty bundle.
205
-
206
- ### Forget
207
-
208
- ```typescript
209
- const result = await wiki.forget('entity-123', { entryId: 'fact_abc' }); // single fact
210
- // result: { deleted: { entries: number; tasks: number } }
211
-
212
- await wiki.forget('entity-123', { taskId: 'task_xyz' }); // single task
213
- // sourceRef is normalized the same way as in ingestDocument (slashes stripped)
214
- await wiki.forget('entity-123', { sourceRef: 'x.md' }); // all facts from a document
215
- await wiki.forget('entity-123', { clearAll: true }); // wipe entity
216
- ```
217
-
218
- 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 } }`.
219
-
220
- ### Check for Changes
221
-
222
- Skip re-ingest if a document's content hasn't changed since the last ingest:
223
-
224
- ```typescript
225
- const changed = await wiki.hasChanged('entity-123', 'preferences.md', sha256(content));
226
- if (changed) {
227
- await wiki.ingestDocument('entity-123', { sourceRef: 'preferences.md', sourceHash: sha256(content), documentChunk: content });
228
- }
229
- ```
230
37
 
231
- Returns `true` if the document has never been ingested, all prior ingest results were forgotten, or the stored hash differs from the supplied one. Returns `false` if the stored hash matches exactly.
232
-
233
- Throws `Error` if `sourceRef` or `sourceHash` is invalid (same rules as `ingestDocument`).
234
-
235
- ### Prune (Hard Delete)
236
-
237
- Hard-delete aged soft-deleted entries/tasks and old events to reclaim storage:
238
-
239
- ```typescript
240
- const result = await wiki.runPrune('entity-123', {
241
- retainSoftDeletedFor: 7, // days — hard-delete entries/tasks soft-deleted > 7d ago; null to skip
242
- retainEventsFor: 30, // days since created_at — hard-delete old events; null to skip
243
- vacuum: false, // set true to VACUUM (slow on mobile, rewrites entire DB)
244
- });
245
- // result: { entries: number; tasks: number; events: number }
246
- ```
247
-
248
- Defaults: `retainSoftDeletedFor = config.pruneRetainSoftDeletedFor ?? 7`, `retainEventsFor = config.pruneEventsAfter ?? 30`, `vacuum = false`.
249
-
250
- Throws `WikiBusyError` if librarian, heal, ingest, or another prune is in-flight for the same entity. `ingestDocument`, `runLibrarian`, and `runHeal` reciprocally throw `WikiBusyError` if a prune is in-flight.
251
-
252
- ---
253
-
254
- ## React / Expo Component API
255
-
256
- Import from `expo-llm-wiki/react`. This entry point is separate so non-React consumers do not transitively import React.
257
-
258
- ### Provider
259
-
260
- Wrap once at app root (or any subtree that needs memory access):
261
-
262
- ```typescript
263
- import { WikiProvider } from 'expo-llm-wiki/react';
264
- import { createWiki } from 'expo-llm-wiki';
265
-
266
- const wiki = createWiki(db, { llmProvider });
267
-
268
- export default function App() {
269
- return (
270
- <WikiProvider wiki={wiki}>
271
- <YourApp />
272
- </WikiProvider>
273
- );
274
- }
275
- ```
276
-
277
- ### `useMemoryRead(entityId, query)`
278
-
279
- 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.
280
-
281
- ```typescript
282
- const { data, isPending, error, refetch } = useMemoryRead('entity-123', 'weekend plans');
283
- // data: MemoryBundle | null
284
- ```
285
-
286
- ### `useWikiWrite()`
287
-
288
- ```typescript
289
- const { execute, isPending, error } = useWikiWrite();
290
-
291
- await execute('entity-123', {
292
- event_type: 'observation',
293
- summary: 'User mentioned they love hiking.',
294
- });
38
+ // Use wiki instance
39
+ await wiki.write('user-123', { event_type: 'observation', summary: '...' });
295
40
  ```
296
41
 
297
- ### `useWikiMaintenance()`
42
+ ## With React
298
43
 
299
- Shared `isPending` true if any operation is in-flight. See [extended form below](#usewikimaintenance-extended) for `runPrune`:
44
+ `@equationalapplications/expo-llm-wiki` re-exports all hooks and `WikiProvider` from `@equationalapplications/react-llm-wiki`:
300
45
 
301
46
  ```typescript
302
- const { runLibrarian, runHeal, runPrune, isPending, error } = useWikiMaintenance();
47
+ import { WikiProvider } from '@equationalapplications/expo-llm-wiki';
303
48
 
304
- await runLibrarian('entity-123');
305
- await runHeal('entity-123');
49
+ <WikiProvider wiki={wiki}>
50
+ <MyApp />
51
+ </WikiProvider>
306
52
  ```
307
53
 
308
- ### `useWikiIngest()`
54
+ Then use hooks in components:
309
55
 
310
56
  ```typescript
311
- const { execute, lastResult, isPending, error } = useWikiIngest();
312
- // lastResult: { truncated: boolean; chunks: number } | null
57
+ import { useMemoryRead } from '@equationalapplications/expo-llm-wiki';
313
58
 
314
- const result = await execute('entity-123', {
315
- sourceRef: 'preferences.md', // slashes are stripped by normalizeSourceRef
316
- sourceHash: sha256(content),
317
- documentChunk: content,
318
- });
319
- // result.truncated — true if any hard-splits were required
320
- // result.chunks — number of LLM calls made
321
- ```
322
-
323
- ### `useWikiForget()`
324
-
325
- ```typescript
326
- const { execute, lastResult, isPending, error } = useWikiForget();
327
- // lastResult: { deleted: { entries: number; tasks: number } } | null
328
-
329
- const result = await execute('entity-123', { entryId: 'fact_abc' });
330
- // result.deleted.entries — rows soft-deleted
331
- ```
332
-
333
- ### `useWikiHasChanged()`
334
-
335
- ```typescript
336
- const { execute, lastResult, isPending, error } = useWikiHasChanged();
337
- // lastResult: boolean | null
338
-
339
- const changed = await execute('entity-123', 'preferences.md', sha256(content));
340
- ```
341
-
342
- ### `useWikiMaintenance()` (extended)
343
-
344
- `runPrune` is now available alongside `runLibrarian` and `runHeal`. Shared `isPending` is true if any operation is in-flight. `lastResult` is a discriminated union — check `.operation` to narrow the type:
345
-
346
- ```typescript
347
- const { runLibrarian, runHeal, runPrune, lastResult, isPending, error } = useWikiMaintenance();
348
-
349
- await runLibrarian('entity-123');
350
- // lastResult: { operation: 'librarian', result: void }
351
-
352
- await runHeal('entity-123');
353
- // lastResult: { operation: 'heal', result: void }
354
-
355
- const counts = await runPrune('entity-123', { retainSoftDeletedFor: 7, retainEventsFor: 30 });
356
- // counts: { entries: number; tasks: number; events: number }
357
- // lastResult: { operation: 'prune', result: { entries: number; tasks: number; events: number } }
358
-
359
- if (lastResult?.operation === 'prune') {
360
- console.log(lastResult.result.entries); // type-safe access to prune counts
361
- }
362
- ```
363
-
364
- The exported `MaintenanceResult` type can be imported for typed consumers:
365
-
366
- ```typescript
367
- import type { MaintenanceResult } from 'expo-llm-wiki/react';
368
- ```
369
-
370
- All mutation hooks follow the same pattern (`TResult` is specific per hook):
371
-
372
- ```typescript
373
- {
374
- execute: (...args) => Promise<TResult>;
375
- lastResult: TResult | null; // result of the last successful call; null before first call or after an error
376
- isPending: boolean;
377
- 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>;
378
64
  }
379
65
  ```
380
66
 
381
- ---
67
+ ## License
382
68
 
383
- Made with ❤️ by Equational Applications LLC. [https://equationalapplications.com/](https://equationalapplications.com/)
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 };
@@ -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":[]}
@@ -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,11 +1,8 @@
1
1
  import * as SQLite from 'expo-sqlite';
2
- import { M as MemoryDump, F as FormattedMemoryDump, a as MemoryBundle, b as FormatContextOptions, W as WikiOptions, c as WikiMemory } from './WikiMemory-ChQmVyvA.mjs';
3
- export { E as EntityStatus, d as ExtractedFact, e as ExtractedTask, L as LLMProvider, f as WikiBusyError, g as WikiCheckpoint, h as WikiConfig, i as WikiEvent, j as WikiFact, k as WikiTask } from './WikiMemory-ChQmVyvA.mjs';
4
-
5
- declare function formatMemoryDump(dump: MemoryDump): FormattedMemoryDump;
6
-
7
- declare function formatContext(bundle: MemoryBundle, options?: FormatContextOptions): string;
2
+ import { WikiOptions, WikiMemory } from '@equationalapplications/core-llm-wiki';
3
+ export * from '@equationalapplications/core-llm-wiki';
4
+ export * from '@equationalapplications/react-llm-wiki';
8
5
 
9
6
  declare function createWiki(db: SQLite.SQLiteDatabase, options: WikiOptions): WikiMemory;
10
7
 
11
- export { FormatContextOptions, FormattedMemoryDump, MemoryBundle, MemoryDump, WikiMemory, WikiOptions, createWiki, formatContext, formatMemoryDump };
8
+ export { createWiki };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,8 @@
1
1
  import * as SQLite from 'expo-sqlite';
2
- import { M as MemoryDump, F as FormattedMemoryDump, a as MemoryBundle, b as FormatContextOptions, W as WikiOptions, c as WikiMemory } from './WikiMemory-ChQmVyvA.js';
3
- export { E as EntityStatus, d as ExtractedFact, e as ExtractedTask, L as LLMProvider, f as WikiBusyError, g as WikiCheckpoint, h as WikiConfig, i as WikiEvent, j as WikiFact, k as WikiTask } from './WikiMemory-ChQmVyvA.js';
4
-
5
- declare function formatMemoryDump(dump: MemoryDump): FormattedMemoryDump;
6
-
7
- declare function formatContext(bundle: MemoryBundle, options?: FormatContextOptions): string;
2
+ import { WikiOptions, WikiMemory } from '@equationalapplications/core-llm-wiki';
3
+ export * from '@equationalapplications/core-llm-wiki';
4
+ export * from '@equationalapplications/react-llm-wiki';
8
5
 
9
6
  declare function createWiki(db: SQLite.SQLiteDatabase, options: WikiOptions): WikiMemory;
10
7
 
11
- export { FormatContextOptions, FormattedMemoryDump, MemoryBundle, MemoryDump, WikiMemory, WikiOptions, createWiki, formatContext, formatMemoryDump };
8
+ export { createWiki };