@equationalapplications/core-llm-wiki 4.15.0 → 4.15.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 (2) hide show
  1. package/README.md +61 -7
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -20,6 +20,7 @@ Platform-agnostic TypeScript engine for hybrid LLM memory. Features episodic fac
20
20
  - **Immutable vs mutable facts** — Use `WikiFact.source_type` to distinguish document-sourced facts (`immutable_document`) from derived or user-provided facts (`librarian_inferred`, `user_stated`, `user_confirmed`). Immutable document facts are not rewritten by `runLibrarian()` or `runHeal()` and can only be removed by `forget()` or re-ingesting.
21
21
  - **Full-featured memory** — Facts, tasks, events, maintenance jobs (librarian, heal, reembed, prune)
22
22
  - **Type-safe** — Built with TypeScript, full type exports
23
+ - **Interoperability:** Supports [Open Knowledge Format (OKF) v0.1](https://github.com/GoogleCloudPlatform/knowledge-catalog/tree/main/okf) import and export.
23
24
 
24
25
  ## Installation
25
26
 
@@ -444,6 +445,58 @@ Notes:
444
445
  - A throwing callback is caught (logged via `console.error`) and does not block other subscribers or the underlying job.
445
446
  - Subscriptions are scoped to a single `entityId`. There is no wildcard or "all entities" form.
446
447
 
448
+ ## OKF Import/Export
449
+
450
+ The core package integrates with `@equationalapplications/core-okf` to seamlessly adapt wiki data dumps to and from Open Knowledge Format (OKF) v0.1 bundles.
451
+
452
+ ### Exporting an OKF Bundle
453
+
454
+ Convert an existing wiki dump into a flat array of OKF files, ready to be written to disk or zipped:
455
+
456
+ ```typescript
457
+ import { formatOkfBundle } from '@equationalapplications/core-llm-wiki';
458
+
459
+ const dump = await wiki.exportDump(['entity-123']);
460
+ const { files } = formatOkfBundle(dump);
461
+
462
+ // files: Array<{ path: string; content: string }>
463
+ // e.g., [{ path: 'entities/entity-123/facts/fact_abc.md', content: '---\n...' }]
464
+ ```
465
+
466
+ ### Importing an OKF Bundle
467
+
468
+ Parse raw OKF files back into a `MemoryDump` that the wiki can ingest:
469
+
470
+ ```typescript
471
+ import { parseOkfBundle } from '@equationalapplications/core-llm-wiki';
472
+
473
+ // Assuming you read OKF files for this entity (e.g. under `entities/entity-123/`) from disk/zip into OkfFile[] shape
474
+ const dump = parseOkfBundle('entity-123', files, {
475
+ defaultSchema: 'fact',
476
+ typeMapping: {
477
+ 'custom_type': 'fact',
478
+ 'archived': 'ignore', // Skips these concepts
479
+ },
480
+ });
481
+
482
+ await wiki.importDump(dump, { merge: true });
483
+ ```
484
+
485
+ **Routing Precedence:** Concepts are routed into either the `entries` (facts) or `tasks` tables based on a three-step fallback:
486
+
487
+ 1. `OkfImportOptions.typeMapping` explicitly mapping an OKF `type` to `'fact'`, `'task'`, or `'ignore'`.
488
+ 2. Directory convention (e.g., files in `/facts/` become facts, `/tasks/` become tasks).
489
+ 3. The `OkfImportOptions.defaultSchema` (defaults to `'fact'`).
490
+
491
+ ### WikiEdge and Markdown Links
492
+
493
+ A `WikiEdge` represents a markdown cross-link found inside a concept body, resolved to a `source_id` and `target_id`.
494
+ Edges automatically round-trip during OKF import and export. Because the markdown body is the source of truth for edges in the OKF spec, edges are extracted during `parseOkfBundle()` and persisted via the `EdgeRepository` on `importDump()` — there is no separate edge export step required. The `edges` array is included in bundles returned by `getMemoryBundle()` / `exportDump()` (not by `read()`).
495
+
496
+ ### The `okf_type` Field
497
+
498
+ Facts and tasks include a nullable `okf_type` column. This preserves the literal OKF `type` string from an imported bundle frontmatter, independent of whether the item was routed to the `entries` or `tasks` table. When `formatOkfBundle` runs, it restores this specific string, falling back to `'fact'` or `'task'` if the field is null (ensuring non-imported rows export cleanly).
499
+
447
500
  ## Security
448
501
 
449
502
  `@equationalapplications/core-llm-wiki` enforces multiple security layers:
@@ -706,13 +759,14 @@ The flowchart shows:
706
759
 
707
760
  ## Monorepo Ecosystem
708
761
 
709
- | Package | Description |
710
- |---------|-------------|
711
- | **`@equationalapplications/core-llm-wiki`** | Pure TypeScript core — DB-agnostic, bring your own SQLite adapter |
712
- | [`@equationalapplications/expo-llm-wiki`](https://www.npmjs.com/package/@equationalapplications/expo-llm-wiki) | Expo / React Native adapter with `expo-sqlite` |
713
- | [`@equationalapplications/react-llm-wiki`](https://www.npmjs.com/package/@equationalapplications/react-llm-wiki) | React hooks + web adapter with `sql.js` |
714
- | [`@equationalapplications/prisma-outbox`](https://www.npmjs.com/package/@equationalapplications/prisma-outbox) | Sync SQLite outbox events to Prisma in a transaction |
715
- | [`@equationalapplications/core-llm-tools`](https://www.npmjs.com/package/@equationalapplications/core-llm-tools) | Platform-agnostic Gemini tool schemas + capability scope injector |
762
+ | Package | Purpose |
763
+ | ----- | ----- |
764
+ | **@equationalapplications/core-llm-wiki** | Persistent episodic memory |
765
+ | [@equationalapplications/expo-llm-wiki](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/expo/README.md) | Persistent episodic memory for Expo/React Native |
766
+ | [@equationalapplications/react-llm-wiki](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/react/README.md) | Persistent episodic memory for Web |
767
+ | [@equationalapplications/prisma-outbox](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/prisma-outbox/README.md) | Sync SQLite outbox events to Prisma |
768
+ | [@equationalapplications/core-llm-tools](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/core-llm-tools/README.md) | Gemini tool schemas and capability injector |
769
+ | [@equationalapplications/core-okf](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/okf/README.md) | Zero-dependency Open Knowledge Format (OKF) v0.1 primitives — parse and produce interoperable knowledge bundles. |
716
770
 
717
771
  ## License
718
772
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equationalapplications/core-llm-wiki",
3
- "version": "4.15.0",
3
+ "version": "4.15.1",
4
4
  "description": "Platform-agnostic TypeScript engine for hybrid LLM memory. Features episodic fact extraction, semantic vector search, and multi-agent architectures over SQLite. Bring your own adapter.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "minisearch": "^7.0.0",
57
- "@equationalapplications/core-okf": "4.15.0"
57
+ "@equationalapplications/core-okf": "4.15.1"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/better-sqlite3": "^7.6.13",