@equationalapplications/react-llm-wiki 4.15.3 → 4.17.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 +83 -3
- package/dist/index.d.mts +49 -2
- package/dist/index.d.ts +49 -2
- package/dist/index.js +158 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +155 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,8 +16,10 @@ In-browser LLM memory for React web apps. Bring your own SQLite adapter (e.g., [
|
|
|
16
16
|
- **Retrieval tuning** — Per-call overrides for hybrid scoring, pre-filtering, result limits, and tier weights
|
|
17
17
|
- **Multi-entity reads** — Search across multiple `entity_id` namespaces in one pass with `tierWeights` and optional `includeZeroWeightEntities`
|
|
18
18
|
- **Source provenance** — `WikiFact.source_type` distinguishes immutable document facts (`immutable_document`) from mutable derived/user facts (`librarian_inferred`, `user_stated`, `user_confirmed`). Immutable document facts are preserved from librarian/heal rewriting and only removed by `forget()` or by re-ingesting the source.
|
|
19
|
+
- **Seeded ontologies** — Enforce strict taxonomies or allow emergent graph relationship extraction (`useOntologyManifest`, `useSetOntologyManifest`; Strict, Emergent, or Off; defaults to Off).
|
|
20
|
+
- **Graph traversal** — Walk the knowledge graph N hops from a fact and format the result for LLM prompts (`useWikiTraversal`, `formatGraphContext`).
|
|
19
21
|
- **Reactive reads** — Auto-refetch on `entityId`, query, or `options` changes
|
|
20
|
-
- **Mutation hooks** — `useWikiWrite`, `useWikiIngest`, `useWikiForget`, `useWikiMaintenance`, etc.
|
|
22
|
+
- **Mutation hooks** — `useWikiWrite`, `useWikiIngest`, `useWikiForget`, `useWikiMaintenance`, `useSetOntologyManifest`, etc.
|
|
21
23
|
- **Shared context** — Single `WikiProvider` per app, use anywhere
|
|
22
24
|
- **Full-featured memory** — Facts, tasks, events, maintenance jobs (librarian, heal, reembed, prune)
|
|
23
25
|
- **Interoperability:** Supports [Open Knowledge Format (OKF) v0.1](https://github.com/GoogleCloudPlatform/knowledge-catalog/tree/main/okf) import and export.
|
|
@@ -354,6 +356,73 @@ if (ingesting || librarian || heal) {
|
|
|
354
356
|
}
|
|
355
357
|
```
|
|
356
358
|
|
|
359
|
+
### `useOntologyManifest(entityId)`
|
|
360
|
+
|
|
361
|
+
Reactive read — fetches on mount and when `entityId` or `wiki` changes:
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
import { useOntologyManifest } from '@equationalapplications/react-llm-wiki';
|
|
365
|
+
|
|
366
|
+
const { manifest, mode, isPending, error, refetch } = useOntologyManifest('user-123');
|
|
367
|
+
// manifest: OntologyManifest | null
|
|
368
|
+
// mode: OntologyMode | null ('strict' | 'emergent' | 'off' when present)
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Note: `manifest` and `mode` are `null` when the entity has no persisted or seeded manifest (`getOntologyManifest` returned `null`). Call `refetch()` after mutations to refresh.
|
|
372
|
+
|
|
373
|
+
### `useSetOntologyManifest()`
|
|
374
|
+
|
|
375
|
+
Mutation — same `{ execute, isPending, error, lastResult }` contract as `useWikiWrite`:
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
import { useOntologyManifest, useSetOntologyManifest } from '@equationalapplications/react-llm-wiki';
|
|
379
|
+
|
|
380
|
+
export function OntologySettings({ entityId }: { entityId: string }) {
|
|
381
|
+
const { manifest, mode, refetch } = useOntologyManifest(entityId);
|
|
382
|
+
const { execute, isPending, error } = useSetOntologyManifest();
|
|
383
|
+
|
|
384
|
+
const handleSave = async () => {
|
|
385
|
+
await execute(entityId, {
|
|
386
|
+
node_types: [{ type: 'person', description: 'An individual.' }],
|
|
387
|
+
edge_types: [{
|
|
388
|
+
type: 'reports_to',
|
|
389
|
+
source_type: 'person',
|
|
390
|
+
target_type: 'person',
|
|
391
|
+
description: 'Reporting hierarchy.',
|
|
392
|
+
}],
|
|
393
|
+
}, { mode: 'strict' });
|
|
394
|
+
refetch();
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
// render manifest/mode; wire handleSave to a save button
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Global defaults and `seedManifests` bootstrap are configured at construction time via `createWiki(..., { config: { ontology: ... } })`. See the [core package README § Per-Entity Seeded Ontology](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/core/README.md#per-entity-seeded-ontology) for mode semantics and manifest schema.
|
|
402
|
+
|
|
403
|
+
`useSetOntologyManifest` does not automatically refresh `useOntologyManifest` — call `refetch()` after a successful `execute()`, same as `useWikiWrite` + `useMemoryRead`.
|
|
404
|
+
|
|
405
|
+
### `useWikiTraversal(entityId, options)`
|
|
406
|
+
|
|
407
|
+
Reactive read — fetches on mount and whenever `entityId` or `options` change. Walks the knowledge graph N hops outward from a fact (`options.sourceId`) using edges written by `runLibrarian()`/`ingestDocument()`'s Seeded Ontology extraction pass:
|
|
408
|
+
|
|
409
|
+
```typescript
|
|
410
|
+
import { useWikiTraversal, formatGraphContext } from '@equationalapplications/react-llm-wiki';
|
|
411
|
+
|
|
412
|
+
const { nodes, edges, isPending, error, refetch } = useWikiTraversal('user-123', {
|
|
413
|
+
sourceId: 'fact_42',
|
|
414
|
+
maxDepth: 2,
|
|
415
|
+
direction: 'both',
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
const promptContext = formatGraphContext({ nodes, edges });
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
- `maxDepth` is clamped to `[1, 3]` regardless of input.
|
|
422
|
+
- `edgeTypes: []` (explicit empty array) matches nothing; omitting it matches all edge types.
|
|
423
|
+
- Defaults (`maxTraversalNodes`, `minTraversalConfidence`, `traversalDirection`, `excludeSourceTypes`) can be set globally via `createWiki(..., { config: { maxTraversalNodes: 20, ... } })` and overridden per-call.
|
|
424
|
+
- `formatGraphContext()` is a pure function — call it with the hook's `{ nodes, edges }` to get a dense text block suitable for prompt injection.
|
|
425
|
+
|
|
357
426
|
## Multi-Entity Reads
|
|
358
427
|
|
|
359
428
|
`useMemoryRead` accepts a single entity ID or an array to search across namespaces in one pass. Pass `tierWeights` to apply per-entity score multipliers before the global top-K slice:
|
|
@@ -391,6 +460,8 @@ flowchart TD
|
|
|
391
460
|
C -->|"useWikiIngest()"| F["[Ingest Document]"]
|
|
392
461
|
C -->|"useWikiForget()"| G["[Delete Memory]"]
|
|
393
462
|
C -->|"useWikiMaintenance()"| H["[Run Jobs]"]
|
|
463
|
+
C -->|"useOntologyManifest(entityId)"| S["[Read Ontology]"]
|
|
464
|
+
C -->|"useSetOntologyManifest()"| T["[Update Ontology]"]
|
|
394
465
|
D --> I{"entityId, query,<br/>ReadOptions, or wiki changed?"}
|
|
395
466
|
I -->|"Yes"| J["Auto-refetch"]
|
|
396
467
|
I -->|"No"| K["Return cached data"]
|
|
@@ -399,10 +470,17 @@ flowchart TD
|
|
|
399
470
|
M --> N["Phase 1: Score facts<br/>Phase 2: Fetch winners"]
|
|
400
471
|
N --> O["Update component state"]
|
|
401
472
|
O --> P["Re-render with data"]
|
|
473
|
+
S --> I2{"entityId or wiki changed?"}
|
|
474
|
+
I2 -->|"Yes"| J2["Auto-refetch"]
|
|
475
|
+
I2 -->|"No"| K2["Return cached manifest/mode"]
|
|
476
|
+
J2 --> L2["Trigger getOntologyManifest()"]
|
|
477
|
+
L2 --> O2["Update component state"]
|
|
478
|
+
O2 --> P2["Re-render with manifest/mode"]
|
|
402
479
|
E --> Q["Execute write()"]
|
|
403
480
|
F --> Q
|
|
404
481
|
G --> Q
|
|
405
482
|
H --> Q
|
|
483
|
+
T --> Q
|
|
406
484
|
Q --> R["Write completes"]
|
|
407
485
|
```
|
|
408
486
|
|
|
@@ -410,8 +488,10 @@ flowchart TD
|
|
|
410
488
|
1. **Wrap app** with `<WikiProvider wiki={wiki}>` — provides wiki context
|
|
411
489
|
2. **Use hooks** in components — access memory reactively
|
|
412
490
|
3. **Read operations** auto-refetch when `entityId`, `query`, `wiki`, or `ReadOptions` values change; call `refetch()` to refresh manually
|
|
413
|
-
4. **
|
|
414
|
-
5. **
|
|
491
|
+
4. **Ontology reads** auto-refetch when `entityId` or `wiki` changes; call `refetch()` manually after ontology mutations
|
|
492
|
+
5. **Write operations** (write, ingest, forget, maintenance) do not automatically re-trigger `useMemoryRead`; call `refetch()` after a write to refresh read results
|
|
493
|
+
6. **Ontology writes** (`useSetOntologyManifest`) do not automatically re-trigger `useOntologyManifest` in the same component unless `refetch()` is called after `execute()` succeeds
|
|
494
|
+
7. **Re-render** with new data flowing back to UI
|
|
415
495
|
|
|
416
496
|
## Retrieval Engine Internals
|
|
417
497
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WikiMemory, ReadOptions, MemoryBundle, WikiEvent, MemoryDump, EntityStatus } from '@equationalapplications/core-llm-wiki';
|
|
1
|
+
import { WikiMemory, ReadOptions, MemoryBundle, WikiEvent, MemoryDump, EntityStatus, OntologyManifest, OntologyMode, WikiFact, WikiEdge, GraphTraversalOptions } from '@equationalapplications/core-llm-wiki';
|
|
2
2
|
export * from '@equationalapplications/core-llm-wiki';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
@@ -118,4 +118,51 @@ declare function useWikiHasChanged(): {
|
|
|
118
118
|
|
|
119
119
|
declare function useEntityStatus(entityId: string): EntityStatus;
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Reactive state returned by {@link useOntologyManifest}.
|
|
123
|
+
*/
|
|
124
|
+
interface OntologyManifestState {
|
|
125
|
+
/** Resolved manifest, or `null` when `getOntologyManifest` returns `null`. */
|
|
126
|
+
manifest: OntologyManifest | null;
|
|
127
|
+
/** Resolved mode, or `null` when no manifest row/seed applies. */
|
|
128
|
+
mode: OntologyMode | null;
|
|
129
|
+
isPending: boolean;
|
|
130
|
+
error: Error | null;
|
|
131
|
+
refetch: () => void;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Reactive read hook for an entity's ontology manifest and mode.
|
|
135
|
+
* Fetches on mount and whenever `entityId` or `wiki` changes.
|
|
136
|
+
* Call `refetch()` after mutations (e.g. {@link useSetOntologyManifest}) to refresh.
|
|
137
|
+
*/
|
|
138
|
+
declare function useOntologyManifest(entityId: string): OntologyManifestState;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Mutation hook for seeding or replacing an entity's ontology manifest.
|
|
142
|
+
* Mirrors the `{ execute, isPending, error, lastResult }` contract of {@link useWikiWrite}.
|
|
143
|
+
* Does not auto-refresh {@link useOntologyManifest} — call `refetch()` after a successful `execute()`.
|
|
144
|
+
*/
|
|
145
|
+
declare function useSetOntologyManifest(): {
|
|
146
|
+
execute: (entityId: string, manifest: OntologyManifest, options?: {
|
|
147
|
+
mode?: OntologyMode;
|
|
148
|
+
}) => Promise<void>;
|
|
149
|
+
lastResult: void | null;
|
|
150
|
+
isPending: boolean;
|
|
151
|
+
error: Error | null;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
interface WikiTraversalState {
|
|
155
|
+
nodes: WikiFact[];
|
|
156
|
+
edges: WikiEdge[];
|
|
157
|
+
isPending: boolean;
|
|
158
|
+
error: Error | null;
|
|
159
|
+
refetch: () => void;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Reactive read hook for graph traversal. Fetches on mount and whenever
|
|
163
|
+
* `entityId` or a stable serialization of `options` changes.
|
|
164
|
+
* Call `refetch()` after mutations that change the underlying edges (e.g. runLibrarian).
|
|
165
|
+
*/
|
|
166
|
+
declare function useWikiTraversal(entityId: string, options: GraphTraversalOptions): WikiTraversalState;
|
|
167
|
+
|
|
168
|
+
export { type MaintenanceResult, type OntologyManifestState, WikiProvider, type WikiTraversalState, useEntityStatus, useMemoryRead, useOntologyManifest, useSetOntologyManifest, useWiki, useWikiExport, useWikiForget, useWikiHasChanged, useWikiIngest, useWikiMaintenance, useWikiTraversal, useWikiWrite };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WikiMemory, ReadOptions, MemoryBundle, WikiEvent, MemoryDump, EntityStatus } from '@equationalapplications/core-llm-wiki';
|
|
1
|
+
import { WikiMemory, ReadOptions, MemoryBundle, WikiEvent, MemoryDump, EntityStatus, OntologyManifest, OntologyMode, WikiFact, WikiEdge, GraphTraversalOptions } from '@equationalapplications/core-llm-wiki';
|
|
2
2
|
export * from '@equationalapplications/core-llm-wiki';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
@@ -118,4 +118,51 @@ declare function useWikiHasChanged(): {
|
|
|
118
118
|
|
|
119
119
|
declare function useEntityStatus(entityId: string): EntityStatus;
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Reactive state returned by {@link useOntologyManifest}.
|
|
123
|
+
*/
|
|
124
|
+
interface OntologyManifestState {
|
|
125
|
+
/** Resolved manifest, or `null` when `getOntologyManifest` returns `null`. */
|
|
126
|
+
manifest: OntologyManifest | null;
|
|
127
|
+
/** Resolved mode, or `null` when no manifest row/seed applies. */
|
|
128
|
+
mode: OntologyMode | null;
|
|
129
|
+
isPending: boolean;
|
|
130
|
+
error: Error | null;
|
|
131
|
+
refetch: () => void;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Reactive read hook for an entity's ontology manifest and mode.
|
|
135
|
+
* Fetches on mount and whenever `entityId` or `wiki` changes.
|
|
136
|
+
* Call `refetch()` after mutations (e.g. {@link useSetOntologyManifest}) to refresh.
|
|
137
|
+
*/
|
|
138
|
+
declare function useOntologyManifest(entityId: string): OntologyManifestState;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Mutation hook for seeding or replacing an entity's ontology manifest.
|
|
142
|
+
* Mirrors the `{ execute, isPending, error, lastResult }` contract of {@link useWikiWrite}.
|
|
143
|
+
* Does not auto-refresh {@link useOntologyManifest} — call `refetch()` after a successful `execute()`.
|
|
144
|
+
*/
|
|
145
|
+
declare function useSetOntologyManifest(): {
|
|
146
|
+
execute: (entityId: string, manifest: OntologyManifest, options?: {
|
|
147
|
+
mode?: OntologyMode;
|
|
148
|
+
}) => Promise<void>;
|
|
149
|
+
lastResult: void | null;
|
|
150
|
+
isPending: boolean;
|
|
151
|
+
error: Error | null;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
interface WikiTraversalState {
|
|
155
|
+
nodes: WikiFact[];
|
|
156
|
+
edges: WikiEdge[];
|
|
157
|
+
isPending: boolean;
|
|
158
|
+
error: Error | null;
|
|
159
|
+
refetch: () => void;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Reactive read hook for graph traversal. Fetches on mount and whenever
|
|
163
|
+
* `entityId` or a stable serialization of `options` changes.
|
|
164
|
+
* Call `refetch()` after mutations that change the underlying edges (e.g. runLibrarian).
|
|
165
|
+
*/
|
|
166
|
+
declare function useWikiTraversal(entityId: string, options: GraphTraversalOptions): WikiTraversalState;
|
|
167
|
+
|
|
168
|
+
export { type MaintenanceResult, type OntologyManifestState, WikiProvider, type WikiTraversalState, useEntityStatus, useMemoryRead, useOntologyManifest, useSetOntologyManifest, useWiki, useWikiExport, useWikiForget, useWikiHasChanged, useWikiIngest, useWikiMaintenance, useWikiTraversal, useWikiWrite };
|
package/dist/index.js
CHANGED
|
@@ -24,12 +24,15 @@ __export(index_exports, {
|
|
|
24
24
|
WikiProvider: () => WikiProvider,
|
|
25
25
|
useEntityStatus: () => useEntityStatus,
|
|
26
26
|
useMemoryRead: () => useMemoryRead,
|
|
27
|
+
useOntologyManifest: () => useOntologyManifest,
|
|
28
|
+
useSetOntologyManifest: () => useSetOntologyManifest,
|
|
27
29
|
useWiki: () => useWiki,
|
|
28
30
|
useWikiExport: () => useWikiExport,
|
|
29
31
|
useWikiForget: () => useWikiForget,
|
|
30
32
|
useWikiHasChanged: () => useWikiHasChanged,
|
|
31
33
|
useWikiIngest: () => useWikiIngest,
|
|
32
34
|
useWikiMaintenance: () => useWikiMaintenance,
|
|
35
|
+
useWikiTraversal: () => useWikiTraversal,
|
|
33
36
|
useWikiWrite: () => useWikiWrite
|
|
34
37
|
});
|
|
35
38
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -381,17 +384,172 @@ function useEntityStatus(entityId) {
|
|
|
381
384
|
}, [wiki, entityId]);
|
|
382
385
|
return snapshot.wiki === wiki && snapshot.entityId === entityId ? snapshot.status : wiki.getEntityStatus(entityId);
|
|
383
386
|
}
|
|
387
|
+
|
|
388
|
+
// src/useOntologyManifest.ts
|
|
389
|
+
var import_react10 = require("react");
|
|
390
|
+
function useOntologyManifest(entityId) {
|
|
391
|
+
const wiki = useWiki();
|
|
392
|
+
const [manifest, setManifest] = (0, import_react10.useState)(null);
|
|
393
|
+
const [mode, setMode] = (0, import_react10.useState)(null);
|
|
394
|
+
const [isPending, setIsPending] = (0, import_react10.useState)(true);
|
|
395
|
+
const [error, setError] = (0, import_react10.useState)(null);
|
|
396
|
+
const wikiRef = (0, import_react10.useRef)(wiki);
|
|
397
|
+
wikiRef.current = wiki;
|
|
398
|
+
const entityIdRef = (0, import_react10.useRef)(entityId);
|
|
399
|
+
entityIdRef.current = entityId;
|
|
400
|
+
const fetchQueue = (0, import_react10.useRef)({ inFlight: false, pending: null });
|
|
401
|
+
const scheduleFetch = (0, import_react10.useRef)(function schedule(eid) {
|
|
402
|
+
const fq = fetchQueue.current;
|
|
403
|
+
if (fq.inFlight) {
|
|
404
|
+
fq.pending = eid;
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
fq.inFlight = true;
|
|
408
|
+
setIsPending(true);
|
|
409
|
+
wikiRef.current.getOntologyManifest(eid).then(
|
|
410
|
+
(result) => {
|
|
411
|
+
if (result) {
|
|
412
|
+
setManifest(result.manifest);
|
|
413
|
+
setMode(result.mode);
|
|
414
|
+
} else {
|
|
415
|
+
setManifest(null);
|
|
416
|
+
setMode(null);
|
|
417
|
+
}
|
|
418
|
+
setError(null);
|
|
419
|
+
},
|
|
420
|
+
(e) => {
|
|
421
|
+
setError(e instanceof Error ? e : new Error(String(e)));
|
|
422
|
+
}
|
|
423
|
+
).finally(() => {
|
|
424
|
+
fq.inFlight = false;
|
|
425
|
+
const next = fq.pending;
|
|
426
|
+
fq.pending = null;
|
|
427
|
+
if (next !== null) {
|
|
428
|
+
scheduleFetch.current(next);
|
|
429
|
+
} else {
|
|
430
|
+
setIsPending(false);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
(0, import_react10.useEffect)(() => {
|
|
435
|
+
scheduleFetch.current(entityIdRef.current);
|
|
436
|
+
}, [entityId, wiki]);
|
|
437
|
+
const refetch = (0, import_react10.useCallback)(() => {
|
|
438
|
+
scheduleFetch.current(entityIdRef.current);
|
|
439
|
+
}, [entityId]);
|
|
440
|
+
return { manifest, mode, isPending, error, refetch };
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// src/useSetOntologyManifest.ts
|
|
444
|
+
var import_react11 = require("react");
|
|
445
|
+
function useSetOntologyManifest() {
|
|
446
|
+
const wiki = useWiki();
|
|
447
|
+
const wikiRef = (0, import_react11.useRef)(wiki);
|
|
448
|
+
wikiRef.current = wiki;
|
|
449
|
+
const [isPending, setIsPending] = (0, import_react11.useState)(false);
|
|
450
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
451
|
+
const [lastResult, setLastResult] = (0, import_react11.useState)(null);
|
|
452
|
+
const execute = (0, import_react11.useCallback)(async (entityId, manifest, options) => {
|
|
453
|
+
setError(null);
|
|
454
|
+
setIsPending(true);
|
|
455
|
+
setLastResult(null);
|
|
456
|
+
try {
|
|
457
|
+
await wikiRef.current.setOntologyManifest(entityId, manifest, options);
|
|
458
|
+
setLastResult(void 0);
|
|
459
|
+
} catch (e) {
|
|
460
|
+
const error2 = e instanceof Error ? e : new Error(String(e));
|
|
461
|
+
setError(error2);
|
|
462
|
+
throw error2;
|
|
463
|
+
} finally {
|
|
464
|
+
setIsPending(false);
|
|
465
|
+
}
|
|
466
|
+
}, []);
|
|
467
|
+
return { execute, lastResult, isPending, error };
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// src/useWikiTraversal.ts
|
|
471
|
+
var import_react12 = require("react");
|
|
472
|
+
function normalizeTraversalOptionsKey(options) {
|
|
473
|
+
const normalized = { sourceId: options.sourceId };
|
|
474
|
+
if (options.maxDepth !== void 0) normalized.maxDepth = options.maxDepth;
|
|
475
|
+
if (options.direction !== void 0) normalized.direction = options.direction;
|
|
476
|
+
if (options.edgeTypes !== void 0) normalized.edgeTypes = [...options.edgeTypes].sort();
|
|
477
|
+
if (options.maxTraversalNodes !== void 0) normalized.maxTraversalNodes = options.maxTraversalNodes;
|
|
478
|
+
if (options.minTraversalConfidence !== void 0) normalized.minTraversalConfidence = options.minTraversalConfidence;
|
|
479
|
+
if (options.excludeSourceTypes !== void 0) normalized.excludeSourceTypes = [...options.excludeSourceTypes].sort();
|
|
480
|
+
const sortedKeys = Object.keys(normalized).sort();
|
|
481
|
+
const sorted = {};
|
|
482
|
+
for (const k of sortedKeys) {
|
|
483
|
+
sorted[k] = normalized[k];
|
|
484
|
+
}
|
|
485
|
+
return JSON.stringify(sorted);
|
|
486
|
+
}
|
|
487
|
+
function useWikiTraversal(entityId, options) {
|
|
488
|
+
const wiki = useWiki();
|
|
489
|
+
const [nodes, setNodes] = (0, import_react12.useState)([]);
|
|
490
|
+
const [edges, setEdges] = (0, import_react12.useState)([]);
|
|
491
|
+
const [isPending, setIsPending] = (0, import_react12.useState)(true);
|
|
492
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
493
|
+
const wikiRef = (0, import_react12.useRef)(wiki);
|
|
494
|
+
wikiRef.current = wiki;
|
|
495
|
+
const entityIdRef = (0, import_react12.useRef)(entityId);
|
|
496
|
+
entityIdRef.current = entityId;
|
|
497
|
+
const optionsRef = (0, import_react12.useRef)(options);
|
|
498
|
+
optionsRef.current = options;
|
|
499
|
+
const optionsKey = normalizeTraversalOptionsKey(options);
|
|
500
|
+
const fetchQueue = (0, import_react12.useRef)({ inFlight: false, pending: null });
|
|
501
|
+
const scheduleFetch = (0, import_react12.useRef)(function schedule(eid, opts) {
|
|
502
|
+
const fq = fetchQueue.current;
|
|
503
|
+
if (fq.inFlight) {
|
|
504
|
+
fq.pending = { entityId: eid, options: opts };
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
fq.inFlight = true;
|
|
508
|
+
setIsPending(true);
|
|
509
|
+
wikiRef.current.traverseGraph(eid, opts).then(
|
|
510
|
+
(result) => {
|
|
511
|
+
setNodes(result.nodes);
|
|
512
|
+
setEdges(result.edges);
|
|
513
|
+
setError(null);
|
|
514
|
+
},
|
|
515
|
+
(e) => {
|
|
516
|
+
setNodes([]);
|
|
517
|
+
setEdges([]);
|
|
518
|
+
setError(e instanceof Error ? e : new Error(String(e)));
|
|
519
|
+
}
|
|
520
|
+
).finally(() => {
|
|
521
|
+
fq.inFlight = false;
|
|
522
|
+
const next = fq.pending;
|
|
523
|
+
fq.pending = null;
|
|
524
|
+
if (next) {
|
|
525
|
+
scheduleFetch.current(next.entityId, next.options);
|
|
526
|
+
} else {
|
|
527
|
+
setIsPending(false);
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
(0, import_react12.useEffect)(() => {
|
|
532
|
+
scheduleFetch.current(entityIdRef.current, optionsRef.current);
|
|
533
|
+
}, [entityId, optionsKey, wiki]);
|
|
534
|
+
const refetch = (0, import_react12.useCallback)(() => {
|
|
535
|
+
scheduleFetch.current(entityIdRef.current, optionsRef.current);
|
|
536
|
+
}, [entityId, optionsKey]);
|
|
537
|
+
return { nodes, edges, isPending, error, refetch };
|
|
538
|
+
}
|
|
384
539
|
// Annotate the CommonJS export names for ESM import in node:
|
|
385
540
|
0 && (module.exports = {
|
|
386
541
|
WikiProvider,
|
|
387
542
|
useEntityStatus,
|
|
388
543
|
useMemoryRead,
|
|
544
|
+
useOntologyManifest,
|
|
545
|
+
useSetOntologyManifest,
|
|
389
546
|
useWiki,
|
|
390
547
|
useWikiExport,
|
|
391
548
|
useWikiForget,
|
|
392
549
|
useWikiHasChanged,
|
|
393
550
|
useWikiIngest,
|
|
394
551
|
useWikiMaintenance,
|
|
552
|
+
useWikiTraversal,
|
|
395
553
|
useWikiWrite,
|
|
396
554
|
...require("@equationalapplications/core-llm-wiki")
|
|
397
555
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/WikiContext.tsx","../src/useMemoryRead.ts","../src/useWikiWrite.ts","../src/useWikiMaintenance.ts","../src/useWikiIngest.ts","../src/useWikiForget.ts","../src/useWikiExport.ts","../src/useWikiHasChanged.ts","../src/useEntityStatus.ts"],"sourcesContent":["export * from '@equationalapplications/core-llm-wiki';\nexport { WikiProvider, useWiki } from './WikiContext';\nexport { useMemoryRead } from './useMemoryRead';\nexport { useWikiWrite } from './useWikiWrite';\nexport { useWikiMaintenance } from './useWikiMaintenance';\nexport type { MaintenanceResult } from './useWikiMaintenance';\nexport { useWikiIngest } from './useWikiIngest';\nexport { useWikiForget } from './useWikiForget';\nexport { useWikiExport } from './useWikiExport';\nexport { useWikiHasChanged } from './useWikiHasChanged';\nexport { useEntityStatus } from './useEntityStatus';\n","import React, { createContext, useContext, type ReactNode } from 'react';\nimport { WikiMemory } from '@equationalapplications/core-llm-wiki';\n\nconst WikiContext = createContext<WikiMemory | null>(null);\n\nexport function WikiProvider({ wiki, children }: { wiki: WikiMemory; children: ReactNode }) {\n return <WikiContext.Provider value={wiki}>{children}</WikiContext.Provider>;\n}\n\nexport function useWiki(): WikiMemory {\n const wiki = useContext(WikiContext);\n if (!wiki) throw new Error('useWiki must be used within WikiProvider');\n return wiki;\n}\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport type { MemoryBundle, ReadOptions } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\n/**\n * Normalize a ReadOptions object to a canonical string suitable for use as a\n * React effect dependency key. Normalization ensures:\n * - `undefined` and `{}` produce the same empty string (no spurious refetch)\n * - Non-serializable numbers are coerced to their effective values before\n * stringifying, matching how WikiMemory.read() resolves them:\n * · maxResults: NaN/±Infinity → 10 (read()'s hardcoded fallback, overrides config)\n * · preFilterLimit: NaN/±Infinity → null (disables config-level limit, same as null)\n * · hybridWeight: NaN → null (explicitly disables config-level weight; distinct from\n * undefined which defers to config); ±Infinity → clamped to 0/1\n * · tierWeights values: non-finite → 1.0, negative → 0 (mirrors core sanitization)\n * · tierWeights keys: projected onto the active entityId set (mirrors core's\n * sanitizeTierWeights which ignores weights for entities not in the request)\n * · tierWeights keys at default weight (1.0) are dropped — spec says missing\n * weights default to 1.0, so explicit 1.0 is behaviorally identical to omission\n * · tierWeights: {} or fully-filtered/all-default result is omitted (same as undefined)\n * · includeZeroWeightEntities: false/undefined are equivalent (both skip zero-weight\n * entities); only true is keyed, matching core's default behavior\n * - Keys are sorted so insertion-order differences never cause spurious refetches\n */\nfunction normalizeReadOptionsKey(entityId: string | string[], opts?: ReadOptions): string {\n if (!opts) return '';\n const normalized: Record<string, unknown> = {};\n\n // maxResults: undefined or null → omit (defer to config/default via ??);\n // non-finite (NaN/±Infinity) → 10 (read()'s hardcoded fallback, bypasses config);\n // finite → clamp to non-negative integer.\n if (opts.maxResults !== undefined && opts.maxResults !== null) {\n normalized.maxResults = Number.isFinite(opts.maxResults)\n ? Math.max(0, Math.trunc(opts.maxResults))\n : 10;\n }\n\n // preFilterLimit: undefined → omit (defer to config);\n // null or non-finite → null (disables config-level limit);\n // finite → clamp to non-negative integer.\n if (opts.preFilterLimit !== undefined) {\n if (opts.preFilterLimit === null || !Number.isFinite(opts.preFilterLimit)) {\n normalized.preFilterLimit = null;\n } else {\n normalized.preFilterLimit = Math.max(0, Math.trunc(opts.preFilterLimit));\n }\n }\n\n // hybridWeight: undefined or null → omit (defer to config via ??);\n // NaN → null (explicitly disables config hybrid weight; distinct from omitting);\n // ±Infinity and out-of-range finite → clamp to [0, 1].\n if (opts.hybridWeight !== undefined && opts.hybridWeight !== null) {\n normalized.hybridWeight = Number.isNaN(opts.hybridWeight)\n ? null\n : Math.max(0, Math.min(1, opts.hybridWeight));\n }\n\n // tierWeights: project onto the active entity set (core's sanitizeTierWeights only\n // considers weights for the requested entityIds, so unrelated keys have no behavioral\n // effect and should not contribute to the dep key). Sanitize values (non-finite → 1.0,\n // negative → 0) and sort keys to avoid spurious refetches from insertion-order or\n // logically-equivalent value differences. Drop entries at the default weight (1.0)\n // because missing weights also default to 1.0 per spec — explicit 1.0 is behaviorally\n // identical to omission. Use Object.create(null) to match core's sanitizeTierWeights\n // and avoid prototype-key edge cases (e.g. entityIds like __proto__). Omit entirely\n // when the projected+filtered result is empty (same as undefined).\n if (opts.tierWeights !== undefined) {\n const activeIds = new Set(Array.isArray(entityId) ? entityId : [entityId]);\n const tw = opts.tierWeights;\n const twKeys = Object.keys(tw).filter(k => activeIds.has(k)).sort();\n if (twKeys.length) {\n const sanitized = Object.create(null) as Record<string, number>;\n for (const k of twKeys) {\n const w = tw[k];\n sanitized[k] = !Number.isFinite(w) ? 1.0 : Math.max(0, w);\n }\n // Drop default-weight entries (1.0) — spec says missing weights default to 1.0\n const nonDefaultKeys = twKeys.filter(k => sanitized[k] !== 1.0);\n if (nonDefaultKeys.length) {\n normalized.tierWeights = JSON.stringify(sanitized, nonDefaultKeys);\n }\n }\n }\n\n // includeZeroWeightEntities: false and undefined are equivalent in core (both exclude\n // zero-weight entities from scored retrieval). Only key when true so toggling\n // undefined → false does not cause a spurious refetch.\n if (opts.includeZeroWeightEntities === true) {\n normalized.includeZeroWeightEntities = true;\n }\n\n const sortedKeys = Object.keys(normalized).sort();\n return sortedKeys.length ? JSON.stringify(normalized, sortedKeys) : '';\n}\n\nexport function useMemoryRead(entityId: string | string[], query: string, options?: ReadOptions) {\n const wiki = useWiki();\n const [data, setData] = useState<MemoryBundle | null>(null);\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const entityIdRef = useRef(entityId);\n entityIdRef.current = entityId;\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n // Stable dep key for entityId: sort+dedup so inline array literals (new reference\n // each render) don't cause spurious refetches. The same set of entity IDs always\n // produces the same key regardless of reference identity or insertion order.\n const entityIdKey = Array.isArray(entityId)\n ? [...new Set(entityId)].sort().join('\\0')\n : entityId;\n\n // Serialize a normalized form of options so:\n // - `undefined` and `{}` map to the same string (no spurious refetch)\n // - non-finite hybridWeight (±Infinity, NaN) is coerced to its effective value before\n // stringifying (JSON.stringify turns Infinity/NaN to `null`, losing type information)\n // - keys are sorted so insertion-order differences don't cause spurious refetches\n const optionsStr = normalizeReadOptionsKey(entityId, options);\n\n const fetchQueue = useRef<{\n inFlight: boolean;\n pending: { entityId: string | string[]; query: string } | null;\n }>({ inFlight: false, pending: null });\n\n // Stable scheduler: refs keep it from going stale across renders.\n // In-flight results are never discarded — spec requires them to land before\n // starting the next fetch with latest args.\n const scheduleFetch = useRef(function schedule(eid: string | string[], q: string) {\n const fq = fetchQueue.current;\n if (fq.inFlight) {\n fq.pending = { entityId: eid, query: q };\n return;\n }\n fq.inFlight = true;\n setIsPending(true);\n\n wikiRef.current.read(eid, q, optionsRef.current).then(\n (result) => { setData(result); setError(null); },\n (e: unknown) => { setError(e instanceof Error ? e : new Error(String(e))); }\n ).finally(() => {\n fq.inFlight = false;\n const next = fq.pending;\n fq.pending = null;\n if (next) {\n scheduleFetch.current(next.entityId, next.query);\n } else {\n setIsPending(false);\n }\n });\n });\n\n useEffect(() => {\n scheduleFetch.current(entityIdRef.current, query);\n }, [entityIdKey, query, wiki, optionsStr]);\n\n const refetch = useCallback(() => {\n scheduleFetch.current(entityIdRef.current, query);\n }, [entityIdKey, query]);\n\n return { data, isPending, error, refetch };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport type { WikiEvent } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\ntype WriteEvent = Omit<WikiEvent, 'id' | 'entity_id' | 'created_at'>;\n\nexport function useWikiWrite() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<void | null>(null);\n\n const execute = useCallback(async (entityId: string, event: WriteEvent): Promise<void> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n await wikiRef.current.write(entityId, event);\n setLastResult(undefined);\n } catch (e) {\n const error = e instanceof Error ? e : new Error(String(e));\n setError(error);\n throw error;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\nexport type MaintenanceResult =\n | { operation: 'librarian' | 'heal'; result: undefined }\n | { operation: 'prune'; result: { entries: number; tasks: number; events: number } };\n\nexport function useWikiMaintenance() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<MaintenanceResult | null>(null);\n // Counter so any overlapping maintenance operation keeps isPending=true until all complete\n const pendingCount = useRef(0);\n\n const runLibrarian = useCallback(async (entityId: string, options?: { promptOverride?: string }): Promise<void> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n await (options ? wikiRef.current.runLibrarian(entityId, options) : wikiRef.current.runLibrarian(entityId));\n setLastResult({ operation: 'librarian', result: undefined });\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n }, []);\n\n const runHeal = useCallback(async (entityId: string, options?: { promptOverride?: string }): Promise<void> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n await (options ? wikiRef.current.runHeal(entityId, options) : wikiRef.current.runHeal(entityId));\n setLastResult({ operation: 'heal', result: undefined });\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n }, []);\n\n const runPrune = useCallback(\n async (\n entityId: string,\n options?: {\n retainSoftDeletedFor?: number | null;\n retainEventsFor?: number | null;\n vacuum?: boolean;\n }\n ): Promise<{ entries: number; tasks: number; events: number }> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.runPrune(entityId, options);\n setLastResult({ operation: 'prune', result });\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n },\n []\n );\n\n const runReembed = useCallback(async (entityId?: string, opts?: { force?: boolean; skipExisting?: boolean }): Promise<{ embedded: number; skipped: number; failed: number }> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n // runReembed returns its result directly; it does not update the shared\n // MaintenanceResult/lastResult field (which only tracks librarian, heal, prune).\n // Using the return value directly avoids widening the MaintenanceResult union\n // in a way that would break existing consumers that exhaustively switch on\n // lastResult.operation.\n return await wikiRef.current.runReembed(entityId, opts);\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n }, []);\n\n return { runLibrarian, runHeal, runPrune, runReembed, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\ninterface IngestParams {\n sourceRef: string;\n sourceHash: string;\n documentChunk: string;\n maxChunkLength?: number;\n promptOverride?: string;\n}\n\ntype IngestResult = { truncated: boolean; chunks: number };\n\nexport function useWikiIngest() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<IngestResult | null>(null);\n\n const execute = useCallback(async (entityId: string, params: IngestParams): Promise<IngestResult> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.ingestDocument(entityId, params);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\ninterface ForgetParams {\n entryId?: string;\n taskId?: string;\n sourceRef?: string;\n sourceHash?: string;\n clearAll?: boolean;\n}\n\ntype ForgetResult = { deleted: { entries: number; tasks: number } };\n\nexport function useWikiForget() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<ForgetResult | null>(null);\n\n const execute = useCallback(async (entityId: string, params: ForgetParams): Promise<ForgetResult> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.forget(entityId, params);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\nimport type { MemoryDump } from '@equationalapplications/core-llm-wiki';\n\nexport function useWikiExport() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<MemoryDump | null>(null);\n\n const execute = useCallback(async (entityIds?: string[]): Promise<MemoryDump> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.exportDump(entityIds);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\nexport function useWikiHasChanged() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<boolean | null>(null);\n\n const execute = useCallback(\n async (entityId: string, sourceRef: string, sourceHash: string): Promise<boolean> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.hasChanged(entityId, sourceRef, sourceHash);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n },\n []\n );\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useEffect } from 'react';\nimport { useWiki } from './WikiContext';\nimport type { EntityStatus } from '@equationalapplications/core-llm-wiki';\n\nexport function useEntityStatus(entityId: string): EntityStatus {\n const wiki = useWiki();\n const [snapshot, setSnapshot] = useState(() => ({\n wiki,\n entityId,\n status: wiki.getEntityStatus(entityId),\n }));\n\n useEffect(() => {\n setSnapshot({ wiki, entityId, status: wiki.getEntityStatus(entityId) });\n return wiki.subscribeEntityStatus(entityId, (status) => {\n setSnapshot({ wiki, entityId, status });\n });\n }, [wiki, entityId]);\n\n return snapshot.wiki === wiki && snapshot.entityId === entityId\n ? snapshot.status\n : wiki.getEntityStatus(entityId);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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B,UAAQ,UAAU;AAElB,QAAM,CAAC,WAAW,YAAY,QAAI,wBAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAuB,IAAI;AACrD,QAAM,CAAC,YAAY,aAAa,QAAI,wBAAyB,IAAI;AAEjE,QAAM,cAAU;AAAA,IACd,OAAO,UAAkB,WAAmB,eAAyC;AACnF,eAAS,IAAI;AACb,mBAAa,IAAI;AACjB,oBAAc,IAAI;AAClB,UAAI;AACF,cAAM,SAAS,MAAM,QAAQ,QAAQ,WAAW,UAAU,WAAW,UAAU;AAC/E,sBAAc,MAAM;AACpB,eAAO;AAAA,MACT,SAAS,GAAG;AACV,cAAM,MAAM,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,CAAC,CAAC;AACxD,iBAAS,GAAG;AACZ,cAAM;AAAA,MACR,UAAE;AACA,qBAAa,KAAK;AAAA,MACpB;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,SAAS,YAAY,WAAW,MAAM;AACjD;;;ACjCA,IAAAC,gBAAoC;AAI7B,SAAS,gBAAgB,UAAgC;AAC9D,QAAM,OAAO,QAAQ;AACrB,QAAM,CAAC,UAAU,WAAW,QAAI,wBAAS,OAAO;AAAA,IAC9C;AAAA,IACA;AAAA,IACA,QAAQ,KAAK,gBAAgB,QAAQ;AAAA,EACvC,EAAE;AAEF,+BAAU,MAAM;AACd,gBAAY,EAAE,MAAM,UAAU,QAAQ,KAAK,gBAAgB,QAAQ,EAAE,CAAC;AACtE,WAAO,KAAK,sBAAsB,UAAU,CAAC,WAAW;AACtD,kBAAY,EAAE,MAAM,UAAU,OAAO,CAAC;AAAA,IACxC,CAAC;AAAA,EACH,GAAG,CAAC,MAAM,QAAQ,CAAC;AAEnB,SAAO,SAAS,SAAS,QAAQ,SAAS,aAAa,WACnD,SAAS,SACT,KAAK,gBAAgB,QAAQ;AACnC;","names":["import_react","import_react","error","import_react","import_react","import_react","import_react","import_react","import_react"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/WikiContext.tsx","../src/useMemoryRead.ts","../src/useWikiWrite.ts","../src/useWikiMaintenance.ts","../src/useWikiIngest.ts","../src/useWikiForget.ts","../src/useWikiExport.ts","../src/useWikiHasChanged.ts","../src/useEntityStatus.ts","../src/useOntologyManifest.ts","../src/useSetOntologyManifest.ts","../src/useWikiTraversal.ts"],"sourcesContent":["export * from '@equationalapplications/core-llm-wiki';\nexport { WikiProvider, useWiki } from './WikiContext';\nexport { useMemoryRead } from './useMemoryRead';\nexport { useWikiWrite } from './useWikiWrite';\nexport { useWikiMaintenance } from './useWikiMaintenance';\nexport type { MaintenanceResult } from './useWikiMaintenance';\nexport { useWikiIngest } from './useWikiIngest';\nexport { useWikiForget } from './useWikiForget';\nexport { useWikiExport } from './useWikiExport';\nexport { useWikiHasChanged } from './useWikiHasChanged';\nexport { useEntityStatus } from './useEntityStatus';\nexport { useOntologyManifest } from './useOntologyManifest';\nexport type { OntologyManifestState } from './useOntologyManifest';\nexport { useSetOntologyManifest } from './useSetOntologyManifest';\nexport { useWikiTraversal } from './useWikiTraversal';\nexport type { WikiTraversalState } from './useWikiTraversal';\n","import React, { createContext, useContext, type ReactNode } from 'react';\nimport { WikiMemory } from '@equationalapplications/core-llm-wiki';\n\nconst WikiContext = createContext<WikiMemory | null>(null);\n\nexport function WikiProvider({ wiki, children }: { wiki: WikiMemory; children: ReactNode }) {\n return <WikiContext.Provider value={wiki}>{children}</WikiContext.Provider>;\n}\n\nexport function useWiki(): WikiMemory {\n const wiki = useContext(WikiContext);\n if (!wiki) throw new Error('useWiki must be used within WikiProvider');\n return wiki;\n}\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport type { MemoryBundle, ReadOptions } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\n/**\n * Normalize a ReadOptions object to a canonical string suitable for use as a\n * React effect dependency key. Normalization ensures:\n * - `undefined` and `{}` produce the same empty string (no spurious refetch)\n * - Non-serializable numbers are coerced to their effective values before\n * stringifying, matching how WikiMemory.read() resolves them:\n * · maxResults: NaN/±Infinity → 10 (read()'s hardcoded fallback, overrides config)\n * · preFilterLimit: NaN/±Infinity → null (disables config-level limit, same as null)\n * · hybridWeight: NaN → null (explicitly disables config-level weight; distinct from\n * undefined which defers to config); ±Infinity → clamped to 0/1\n * · tierWeights values: non-finite → 1.0, negative → 0 (mirrors core sanitization)\n * · tierWeights keys: projected onto the active entityId set (mirrors core's\n * sanitizeTierWeights which ignores weights for entities not in the request)\n * · tierWeights keys at default weight (1.0) are dropped — spec says missing\n * weights default to 1.0, so explicit 1.0 is behaviorally identical to omission\n * · tierWeights: {} or fully-filtered/all-default result is omitted (same as undefined)\n * · includeZeroWeightEntities: false/undefined are equivalent (both skip zero-weight\n * entities); only true is keyed, matching core's default behavior\n * - Keys are sorted so insertion-order differences never cause spurious refetches\n */\nfunction normalizeReadOptionsKey(entityId: string | string[], opts?: ReadOptions): string {\n if (!opts) return '';\n const normalized: Record<string, unknown> = {};\n\n // maxResults: undefined or null → omit (defer to config/default via ??);\n // non-finite (NaN/±Infinity) → 10 (read()'s hardcoded fallback, bypasses config);\n // finite → clamp to non-negative integer.\n if (opts.maxResults !== undefined && opts.maxResults !== null) {\n normalized.maxResults = Number.isFinite(opts.maxResults)\n ? Math.max(0, Math.trunc(opts.maxResults))\n : 10;\n }\n\n // preFilterLimit: undefined → omit (defer to config);\n // null or non-finite → null (disables config-level limit);\n // finite → clamp to non-negative integer.\n if (opts.preFilterLimit !== undefined) {\n if (opts.preFilterLimit === null || !Number.isFinite(opts.preFilterLimit)) {\n normalized.preFilterLimit = null;\n } else {\n normalized.preFilterLimit = Math.max(0, Math.trunc(opts.preFilterLimit));\n }\n }\n\n // hybridWeight: undefined or null → omit (defer to config via ??);\n // NaN → null (explicitly disables config hybrid weight; distinct from omitting);\n // ±Infinity and out-of-range finite → clamp to [0, 1].\n if (opts.hybridWeight !== undefined && opts.hybridWeight !== null) {\n normalized.hybridWeight = Number.isNaN(opts.hybridWeight)\n ? null\n : Math.max(0, Math.min(1, opts.hybridWeight));\n }\n\n // tierWeights: project onto the active entity set (core's sanitizeTierWeights only\n // considers weights for the requested entityIds, so unrelated keys have no behavioral\n // effect and should not contribute to the dep key). Sanitize values (non-finite → 1.0,\n // negative → 0) and sort keys to avoid spurious refetches from insertion-order or\n // logically-equivalent value differences. Drop entries at the default weight (1.0)\n // because missing weights also default to 1.0 per spec — explicit 1.0 is behaviorally\n // identical to omission. Use Object.create(null) to match core's sanitizeTierWeights\n // and avoid prototype-key edge cases (e.g. entityIds like __proto__). Omit entirely\n // when the projected+filtered result is empty (same as undefined).\n if (opts.tierWeights !== undefined) {\n const activeIds = new Set(Array.isArray(entityId) ? entityId : [entityId]);\n const tw = opts.tierWeights;\n const twKeys = Object.keys(tw).filter(k => activeIds.has(k)).sort();\n if (twKeys.length) {\n const sanitized = Object.create(null) as Record<string, number>;\n for (const k of twKeys) {\n const w = tw[k];\n sanitized[k] = !Number.isFinite(w) ? 1.0 : Math.max(0, w);\n }\n // Drop default-weight entries (1.0) — spec says missing weights default to 1.0\n const nonDefaultKeys = twKeys.filter(k => sanitized[k] !== 1.0);\n if (nonDefaultKeys.length) {\n normalized.tierWeights = JSON.stringify(sanitized, nonDefaultKeys);\n }\n }\n }\n\n // includeZeroWeightEntities: false and undefined are equivalent in core (both exclude\n // zero-weight entities from scored retrieval). Only key when true so toggling\n // undefined → false does not cause a spurious refetch.\n if (opts.includeZeroWeightEntities === true) {\n normalized.includeZeroWeightEntities = true;\n }\n\n const sortedKeys = Object.keys(normalized).sort();\n return sortedKeys.length ? JSON.stringify(normalized, sortedKeys) : '';\n}\n\nexport function useMemoryRead(entityId: string | string[], query: string, options?: ReadOptions) {\n const wiki = useWiki();\n const [data, setData] = useState<MemoryBundle | null>(null);\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const entityIdRef = useRef(entityId);\n entityIdRef.current = entityId;\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n // Stable dep key for entityId: sort+dedup so inline array literals (new reference\n // each render) don't cause spurious refetches. The same set of entity IDs always\n // produces the same key regardless of reference identity or insertion order.\n const entityIdKey = Array.isArray(entityId)\n ? [...new Set(entityId)].sort().join('\\0')\n : entityId;\n\n // Serialize a normalized form of options so:\n // - `undefined` and `{}` map to the same string (no spurious refetch)\n // - non-finite hybridWeight (±Infinity, NaN) is coerced to its effective value before\n // stringifying (JSON.stringify turns Infinity/NaN to `null`, losing type information)\n // - keys are sorted so insertion-order differences don't cause spurious refetches\n const optionsStr = normalizeReadOptionsKey(entityId, options);\n\n const fetchQueue = useRef<{\n inFlight: boolean;\n pending: { entityId: string | string[]; query: string } | null;\n }>({ inFlight: false, pending: null });\n\n // Stable scheduler: refs keep it from going stale across renders.\n // In-flight results are never discarded — spec requires them to land before\n // starting the next fetch with latest args.\n const scheduleFetch = useRef(function schedule(eid: string | string[], q: string) {\n const fq = fetchQueue.current;\n if (fq.inFlight) {\n fq.pending = { entityId: eid, query: q };\n return;\n }\n fq.inFlight = true;\n setIsPending(true);\n\n wikiRef.current.read(eid, q, optionsRef.current).then(\n (result) => { setData(result); setError(null); },\n (e: unknown) => { setError(e instanceof Error ? e : new Error(String(e))); }\n ).finally(() => {\n fq.inFlight = false;\n const next = fq.pending;\n fq.pending = null;\n if (next) {\n scheduleFetch.current(next.entityId, next.query);\n } else {\n setIsPending(false);\n }\n });\n });\n\n useEffect(() => {\n scheduleFetch.current(entityIdRef.current, query);\n }, [entityIdKey, query, wiki, optionsStr]);\n\n const refetch = useCallback(() => {\n scheduleFetch.current(entityIdRef.current, query);\n }, [entityIdKey, query]);\n\n return { data, isPending, error, refetch };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport type { WikiEvent } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\ntype WriteEvent = Omit<WikiEvent, 'id' | 'entity_id' | 'created_at'>;\n\nexport function useWikiWrite() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<void | null>(null);\n\n const execute = useCallback(async (entityId: string, event: WriteEvent): Promise<void> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n await wikiRef.current.write(entityId, event);\n setLastResult(undefined);\n } catch (e) {\n const error = e instanceof Error ? e : new Error(String(e));\n setError(error);\n throw error;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\nexport type MaintenanceResult =\n | { operation: 'librarian' | 'heal'; result: undefined }\n | { operation: 'prune'; result: { entries: number; tasks: number; events: number } };\n\nexport function useWikiMaintenance() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<MaintenanceResult | null>(null);\n // Counter so any overlapping maintenance operation keeps isPending=true until all complete\n const pendingCount = useRef(0);\n\n const runLibrarian = useCallback(async (entityId: string, options?: { promptOverride?: string }): Promise<void> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n await (options ? wikiRef.current.runLibrarian(entityId, options) : wikiRef.current.runLibrarian(entityId));\n setLastResult({ operation: 'librarian', result: undefined });\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n }, []);\n\n const runHeal = useCallback(async (entityId: string, options?: { promptOverride?: string }): Promise<void> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n await (options ? wikiRef.current.runHeal(entityId, options) : wikiRef.current.runHeal(entityId));\n setLastResult({ operation: 'heal', result: undefined });\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n }, []);\n\n const runPrune = useCallback(\n async (\n entityId: string,\n options?: {\n retainSoftDeletedFor?: number | null;\n retainEventsFor?: number | null;\n vacuum?: boolean;\n }\n ): Promise<{ entries: number; tasks: number; events: number }> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.runPrune(entityId, options);\n setLastResult({ operation: 'prune', result });\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n },\n []\n );\n\n const runReembed = useCallback(async (entityId?: string, opts?: { force?: boolean; skipExisting?: boolean }): Promise<{ embedded: number; skipped: number; failed: number }> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n // runReembed returns its result directly; it does not update the shared\n // MaintenanceResult/lastResult field (which only tracks librarian, heal, prune).\n // Using the return value directly avoids widening the MaintenanceResult union\n // in a way that would break existing consumers that exhaustively switch on\n // lastResult.operation.\n return await wikiRef.current.runReembed(entityId, opts);\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n }, []);\n\n return { runLibrarian, runHeal, runPrune, runReembed, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\ninterface IngestParams {\n sourceRef: string;\n sourceHash: string;\n documentChunk: string;\n maxChunkLength?: number;\n promptOverride?: string;\n}\n\ntype IngestResult = { truncated: boolean; chunks: number };\n\nexport function useWikiIngest() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<IngestResult | null>(null);\n\n const execute = useCallback(async (entityId: string, params: IngestParams): Promise<IngestResult> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.ingestDocument(entityId, params);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\ninterface ForgetParams {\n entryId?: string;\n taskId?: string;\n sourceRef?: string;\n sourceHash?: string;\n clearAll?: boolean;\n}\n\ntype ForgetResult = { deleted: { entries: number; tasks: number } };\n\nexport function useWikiForget() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<ForgetResult | null>(null);\n\n const execute = useCallback(async (entityId: string, params: ForgetParams): Promise<ForgetResult> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.forget(entityId, params);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\nimport type { MemoryDump } from '@equationalapplications/core-llm-wiki';\n\nexport function useWikiExport() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<MemoryDump | null>(null);\n\n const execute = useCallback(async (entityIds?: string[]): Promise<MemoryDump> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.exportDump(entityIds);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\nexport function useWikiHasChanged() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<boolean | null>(null);\n\n const execute = useCallback(\n async (entityId: string, sourceRef: string, sourceHash: string): Promise<boolean> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.hasChanged(entityId, sourceRef, sourceHash);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n },\n []\n );\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useEffect } from 'react';\nimport { useWiki } from './WikiContext';\nimport type { EntityStatus } from '@equationalapplications/core-llm-wiki';\n\nexport function useEntityStatus(entityId: string): EntityStatus {\n const wiki = useWiki();\n const [snapshot, setSnapshot] = useState(() => ({\n wiki,\n entityId,\n status: wiki.getEntityStatus(entityId),\n }));\n\n useEffect(() => {\n setSnapshot({ wiki, entityId, status: wiki.getEntityStatus(entityId) });\n return wiki.subscribeEntityStatus(entityId, (status) => {\n setSnapshot({ wiki, entityId, status });\n });\n }, [wiki, entityId]);\n\n return snapshot.wiki === wiki && snapshot.entityId === entityId\n ? snapshot.status\n : wiki.getEntityStatus(entityId);\n}\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport type { OntologyManifest, OntologyMode } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\n/**\n * Reactive state returned by {@link useOntologyManifest}.\n */\nexport interface OntologyManifestState {\n /** Resolved manifest, or `null` when `getOntologyManifest` returns `null`. */\n manifest: OntologyManifest | null;\n /** Resolved mode, or `null` when no manifest row/seed applies. */\n mode: OntologyMode | null;\n isPending: boolean;\n error: Error | null;\n refetch: () => void;\n}\n\n/**\n * Reactive read hook for an entity's ontology manifest and mode.\n * Fetches on mount and whenever `entityId` or `wiki` changes.\n * Call `refetch()` after mutations (e.g. {@link useSetOntologyManifest}) to refresh.\n */\nexport function useOntologyManifest(entityId: string): OntologyManifestState {\n const wiki = useWiki();\n const [manifest, setManifest] = useState<OntologyManifest | null>(null);\n const [mode, setMode] = useState<OntologyMode | null>(null);\n const [isPending, setIsPending] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const entityIdRef = useRef(entityId);\n entityIdRef.current = entityId;\n\n const fetchQueue = useRef<{\n inFlight: boolean;\n pending: string | null;\n }>({ inFlight: false, pending: null });\n\n const scheduleFetch = useRef(function schedule(eid: string) {\n const fq = fetchQueue.current;\n if (fq.inFlight) {\n fq.pending = eid;\n return;\n }\n fq.inFlight = true;\n setIsPending(true);\n\n wikiRef.current.getOntologyManifest(eid).then(\n (result) => {\n if (result) {\n setManifest(result.manifest);\n setMode(result.mode);\n } else {\n setManifest(null);\n setMode(null);\n }\n setError(null);\n },\n (e: unknown) => {\n setError(e instanceof Error ? e : new Error(String(e)));\n },\n ).finally(() => {\n fq.inFlight = false;\n const next = fq.pending;\n fq.pending = null;\n if (next !== null) {\n scheduleFetch.current(next);\n } else {\n setIsPending(false);\n }\n });\n });\n\n useEffect(() => {\n scheduleFetch.current(entityIdRef.current);\n }, [entityId, wiki]);\n\n const refetch = useCallback(() => {\n scheduleFetch.current(entityIdRef.current);\n }, [entityId]);\n\n return { manifest, mode, isPending, error, refetch };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport type { OntologyManifest, OntologyMode } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\n/**\n * Mutation hook for seeding or replacing an entity's ontology manifest.\n * Mirrors the `{ execute, isPending, error, lastResult }` contract of {@link useWikiWrite}.\n * Does not auto-refresh {@link useOntologyManifest} — call `refetch()` after a successful `execute()`.\n */\nexport function useSetOntologyManifest() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<void | null>(null);\n\n const execute = useCallback(async (\n entityId: string,\n manifest: OntologyManifest,\n options?: { mode?: OntologyMode },\n ): Promise<void> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n await wikiRef.current.setOntologyManifest(entityId, manifest, options);\n setLastResult(undefined);\n } catch (e) {\n const error = e instanceof Error ? e : new Error(String(e));\n setError(error);\n throw error;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport type { GraphTraversalOptions, WikiFact, WikiEdge } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\nexport interface WikiTraversalState {\n nodes: WikiFact[];\n edges: WikiEdge[];\n isPending: boolean;\n error: Error | null;\n refetch: () => void;\n}\n\n/**\n * Stable dep key for a GraphTraversalOptions object so inline object literals\n * (new reference each render) don't cause spurious refetches. Sorted-key\n * JSON.stringify, mirroring normalizeReadOptionsKey in useMemoryRead.ts.\n */\nfunction normalizeTraversalOptionsKey(options: GraphTraversalOptions): string {\n const normalized: Record<string, unknown> = { sourceId: options.sourceId };\n\n if (options.maxDepth !== undefined) normalized.maxDepth = options.maxDepth;\n if (options.direction !== undefined) normalized.direction = options.direction;\n if (options.edgeTypes !== undefined) normalized.edgeTypes = [...options.edgeTypes].sort();\n if (options.maxTraversalNodes !== undefined) normalized.maxTraversalNodes = options.maxTraversalNodes;\n if (options.minTraversalConfidence !== undefined) normalized.minTraversalConfidence = options.minTraversalConfidence;\n if (options.excludeSourceTypes !== undefined) normalized.excludeSourceTypes = [...options.excludeSourceTypes].sort();\n\n const sortedKeys = Object.keys(normalized).sort();\n const sorted: Record<string, unknown> = {};\n for (const k of sortedKeys) {\n sorted[k] = normalized[k];\n }\n // Do not pass sortedKeys as a JSON.stringify replacer — array values would lose\n // their elements because replacer keys must be object property names, not indices.\n return JSON.stringify(sorted);\n}\n\n/**\n * Reactive read hook for graph traversal. Fetches on mount and whenever\n * `entityId` or a stable serialization of `options` changes.\n * Call `refetch()` after mutations that change the underlying edges (e.g. runLibrarian).\n */\nexport function useWikiTraversal(entityId: string, options: GraphTraversalOptions): WikiTraversalState {\n const wiki = useWiki();\n const [nodes, setNodes] = useState<WikiFact[]>([]);\n const [edges, setEdges] = useState<WikiEdge[]>([]);\n const [isPending, setIsPending] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const entityIdRef = useRef(entityId);\n entityIdRef.current = entityId;\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const optionsKey = normalizeTraversalOptionsKey(options);\n\n const fetchQueue = useRef<{\n inFlight: boolean;\n pending: { entityId: string; options: GraphTraversalOptions } | null;\n }>({ inFlight: false, pending: null });\n\n // Stable scheduler: refs keep it from going stale across renders.\n // In-flight results are never discarded.\n const scheduleFetch = useRef(function schedule(eid: string, opts: GraphTraversalOptions) {\n const fq = fetchQueue.current;\n if (fq.inFlight) {\n fq.pending = { entityId: eid, options: opts };\n return;\n }\n fq.inFlight = true;\n setIsPending(true);\n\n wikiRef.current.traverseGraph(eid, opts).then(\n (result) => {\n setNodes(result.nodes);\n setEdges(result.edges);\n setError(null);\n },\n (e: unknown) => {\n setNodes([]);\n setEdges([]);\n setError(e instanceof Error ? e : new Error(String(e)));\n },\n ).finally(() => {\n fq.inFlight = false;\n const next = fq.pending;\n fq.pending = null;\n if (next) {\n scheduleFetch.current(next.entityId, next.options);\n } else {\n setIsPending(false);\n }\n });\n });\n\n useEffect(() => {\n scheduleFetch.current(entityIdRef.current, optionsRef.current);\n }, [entityId, optionsKey, wiki]);\n\n const refetch = useCallback(() => {\n scheduleFetch.current(entityIdRef.current, optionsRef.current);\n }, [entityId, optionsKey]);\n\n return { nodes, edges, isPending, error, refetch };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAc,kDAAd;;;ACAA,mBAAiE;AAMxD;AAHT,IAAM,kBAAc,4BAAiC,IAAI;AAElD,SAAS,aAAa,EAAE,MAAM,SAAS,GAA8C;AAC1F,SAAO,4CAAC,YAAY,UAAZ,EAAqB,OAAO,MAAO,UAAS;AACtD;AAEO,SAAS,UAAsB;AACpC,QAAM,WAAO,yBAAW,WAAW;AACnC,MAAI,CAAC,KAAM,OAAM,IAAI,MAAM,0CAA0C;AACrE,SAAO;AACT;;;ACbA,IAAAA,gBAAyD;AAwBzD,SAAS,wBAAwB,UAA6B,MAA4B;AACxF,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,aAAsC,CAAC;AAK7C,MAAI,KAAK,eAAe,UAAa,KAAK,eAAe,MAAM;AAC7D,eAAW,aAAa,OAAO,SAAS,KAAK,UAAU,IACnD,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,UAAU,CAAC,IACvC;AAAA,EACN;AAKA,MAAI,KAAK,mBAAmB,QAAW;AACrC,QAAI,KAAK,mBAAmB,QAAQ,CAAC,OAAO,SAAS,KAAK,cAAc,GAAG;AACzE,iBAAW,iBAAiB;AAAA,IAC9B,OAAO;AACL,iBAAW,iBAAiB,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,cAAc,CAAC;AAAA,IACzE;AAAA,EACF;AAKA,MAAI,KAAK,iBAAiB,UAAa,KAAK,iBAAiB,MAAM;AACjE,eAAW,eAAe,OAAO,MAAM,KAAK,YAAY,IACpD,OACA,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG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WAAW;AACd,iBAAa,IAAI;AAEjB,YAAQ,QAAQ,cAAc,KAAK,IAAI,EAAE;AAAA,MACvC,CAAC,WAAW;AACV,iBAAS,OAAO,KAAK;AACrB,iBAAS,OAAO,KAAK;AACrB,iBAAS,IAAI;AAAA,MACf;AAAA,MACA,CAAC,MAAe;AACd,iBAAS,CAAC,CAAC;AACX,iBAAS,CAAC,CAAC;AACX,iBAAS,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC;AAAA,MACxD;AAAA,IACF,EAAE,QAAQ,MAAM;AACd,SAAG,WAAW;AACd,YAAM,OAAO,GAAG;AAChB,SAAG,UAAU;AACb,UAAI,MAAM;AACR,sBAAc,QAAQ,KAAK,UAAU,KAAK,OAAO;AAAA,MACnD,OAAO;AACL,qBAAa,KAAK;AAAA,MACpB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,gCAAU,MAAM;AACd,kBAAc,QAAQ,YAAY,SAAS,WAAW,OAAO;AAAA,EAC/D,GAAG,CAAC,UAAU,YAAY,IAAI,CAAC;AAE/B,QAAM,cAAU,4BAAY,MAAM;AAChC,kBAAc,QAAQ,YAAY,SAAS,WAAW,OAAO;AAAA,EAC/D,GAAG,CAAC,UAAU,UAAU,CAAC;AAEzB,SAAO,EAAE,OAAO,OAAO,WAAW,OAAO,QAAQ;AACnD;","names":["import_react","import_react","error","import_react","import_react","import_react","import_react","import_react","import_react","import_react","import_react","error","import_react"]}
|
package/dist/index.mjs
CHANGED
|
@@ -347,16 +347,171 @@ function useEntityStatus(entityId) {
|
|
|
347
347
|
}, [wiki, entityId]);
|
|
348
348
|
return snapshot.wiki === wiki && snapshot.entityId === entityId ? snapshot.status : wiki.getEntityStatus(entityId);
|
|
349
349
|
}
|
|
350
|
+
|
|
351
|
+
// src/useOntologyManifest.ts
|
|
352
|
+
import { useState as useState9, useEffect as useEffect3, useCallback as useCallback8, useRef as useRef8 } from "react";
|
|
353
|
+
function useOntologyManifest(entityId) {
|
|
354
|
+
const wiki = useWiki();
|
|
355
|
+
const [manifest, setManifest] = useState9(null);
|
|
356
|
+
const [mode, setMode] = useState9(null);
|
|
357
|
+
const [isPending, setIsPending] = useState9(true);
|
|
358
|
+
const [error, setError] = useState9(null);
|
|
359
|
+
const wikiRef = useRef8(wiki);
|
|
360
|
+
wikiRef.current = wiki;
|
|
361
|
+
const entityIdRef = useRef8(entityId);
|
|
362
|
+
entityIdRef.current = entityId;
|
|
363
|
+
const fetchQueue = useRef8({ inFlight: false, pending: null });
|
|
364
|
+
const scheduleFetch = useRef8(function schedule(eid) {
|
|
365
|
+
const fq = fetchQueue.current;
|
|
366
|
+
if (fq.inFlight) {
|
|
367
|
+
fq.pending = eid;
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
fq.inFlight = true;
|
|
371
|
+
setIsPending(true);
|
|
372
|
+
wikiRef.current.getOntologyManifest(eid).then(
|
|
373
|
+
(result) => {
|
|
374
|
+
if (result) {
|
|
375
|
+
setManifest(result.manifest);
|
|
376
|
+
setMode(result.mode);
|
|
377
|
+
} else {
|
|
378
|
+
setManifest(null);
|
|
379
|
+
setMode(null);
|
|
380
|
+
}
|
|
381
|
+
setError(null);
|
|
382
|
+
},
|
|
383
|
+
(e) => {
|
|
384
|
+
setError(e instanceof Error ? e : new Error(String(e)));
|
|
385
|
+
}
|
|
386
|
+
).finally(() => {
|
|
387
|
+
fq.inFlight = false;
|
|
388
|
+
const next = fq.pending;
|
|
389
|
+
fq.pending = null;
|
|
390
|
+
if (next !== null) {
|
|
391
|
+
scheduleFetch.current(next);
|
|
392
|
+
} else {
|
|
393
|
+
setIsPending(false);
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
useEffect3(() => {
|
|
398
|
+
scheduleFetch.current(entityIdRef.current);
|
|
399
|
+
}, [entityId, wiki]);
|
|
400
|
+
const refetch = useCallback8(() => {
|
|
401
|
+
scheduleFetch.current(entityIdRef.current);
|
|
402
|
+
}, [entityId]);
|
|
403
|
+
return { manifest, mode, isPending, error, refetch };
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// src/useSetOntologyManifest.ts
|
|
407
|
+
import { useState as useState10, useCallback as useCallback9, useRef as useRef9 } from "react";
|
|
408
|
+
function useSetOntologyManifest() {
|
|
409
|
+
const wiki = useWiki();
|
|
410
|
+
const wikiRef = useRef9(wiki);
|
|
411
|
+
wikiRef.current = wiki;
|
|
412
|
+
const [isPending, setIsPending] = useState10(false);
|
|
413
|
+
const [error, setError] = useState10(null);
|
|
414
|
+
const [lastResult, setLastResult] = useState10(null);
|
|
415
|
+
const execute = useCallback9(async (entityId, manifest, options) => {
|
|
416
|
+
setError(null);
|
|
417
|
+
setIsPending(true);
|
|
418
|
+
setLastResult(null);
|
|
419
|
+
try {
|
|
420
|
+
await wikiRef.current.setOntologyManifest(entityId, manifest, options);
|
|
421
|
+
setLastResult(void 0);
|
|
422
|
+
} catch (e) {
|
|
423
|
+
const error2 = e instanceof Error ? e : new Error(String(e));
|
|
424
|
+
setError(error2);
|
|
425
|
+
throw error2;
|
|
426
|
+
} finally {
|
|
427
|
+
setIsPending(false);
|
|
428
|
+
}
|
|
429
|
+
}, []);
|
|
430
|
+
return { execute, lastResult, isPending, error };
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// src/useWikiTraversal.ts
|
|
434
|
+
import { useState as useState11, useEffect as useEffect4, useCallback as useCallback10, useRef as useRef10 } from "react";
|
|
435
|
+
function normalizeTraversalOptionsKey(options) {
|
|
436
|
+
const normalized = { sourceId: options.sourceId };
|
|
437
|
+
if (options.maxDepth !== void 0) normalized.maxDepth = options.maxDepth;
|
|
438
|
+
if (options.direction !== void 0) normalized.direction = options.direction;
|
|
439
|
+
if (options.edgeTypes !== void 0) normalized.edgeTypes = [...options.edgeTypes].sort();
|
|
440
|
+
if (options.maxTraversalNodes !== void 0) normalized.maxTraversalNodes = options.maxTraversalNodes;
|
|
441
|
+
if (options.minTraversalConfidence !== void 0) normalized.minTraversalConfidence = options.minTraversalConfidence;
|
|
442
|
+
if (options.excludeSourceTypes !== void 0) normalized.excludeSourceTypes = [...options.excludeSourceTypes].sort();
|
|
443
|
+
const sortedKeys = Object.keys(normalized).sort();
|
|
444
|
+
const sorted = {};
|
|
445
|
+
for (const k of sortedKeys) {
|
|
446
|
+
sorted[k] = normalized[k];
|
|
447
|
+
}
|
|
448
|
+
return JSON.stringify(sorted);
|
|
449
|
+
}
|
|
450
|
+
function useWikiTraversal(entityId, options) {
|
|
451
|
+
const wiki = useWiki();
|
|
452
|
+
const [nodes, setNodes] = useState11([]);
|
|
453
|
+
const [edges, setEdges] = useState11([]);
|
|
454
|
+
const [isPending, setIsPending] = useState11(true);
|
|
455
|
+
const [error, setError] = useState11(null);
|
|
456
|
+
const wikiRef = useRef10(wiki);
|
|
457
|
+
wikiRef.current = wiki;
|
|
458
|
+
const entityIdRef = useRef10(entityId);
|
|
459
|
+
entityIdRef.current = entityId;
|
|
460
|
+
const optionsRef = useRef10(options);
|
|
461
|
+
optionsRef.current = options;
|
|
462
|
+
const optionsKey = normalizeTraversalOptionsKey(options);
|
|
463
|
+
const fetchQueue = useRef10({ inFlight: false, pending: null });
|
|
464
|
+
const scheduleFetch = useRef10(function schedule(eid, opts) {
|
|
465
|
+
const fq = fetchQueue.current;
|
|
466
|
+
if (fq.inFlight) {
|
|
467
|
+
fq.pending = { entityId: eid, options: opts };
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
fq.inFlight = true;
|
|
471
|
+
setIsPending(true);
|
|
472
|
+
wikiRef.current.traverseGraph(eid, opts).then(
|
|
473
|
+
(result) => {
|
|
474
|
+
setNodes(result.nodes);
|
|
475
|
+
setEdges(result.edges);
|
|
476
|
+
setError(null);
|
|
477
|
+
},
|
|
478
|
+
(e) => {
|
|
479
|
+
setNodes([]);
|
|
480
|
+
setEdges([]);
|
|
481
|
+
setError(e instanceof Error ? e : new Error(String(e)));
|
|
482
|
+
}
|
|
483
|
+
).finally(() => {
|
|
484
|
+
fq.inFlight = false;
|
|
485
|
+
const next = fq.pending;
|
|
486
|
+
fq.pending = null;
|
|
487
|
+
if (next) {
|
|
488
|
+
scheduleFetch.current(next.entityId, next.options);
|
|
489
|
+
} else {
|
|
490
|
+
setIsPending(false);
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
useEffect4(() => {
|
|
495
|
+
scheduleFetch.current(entityIdRef.current, optionsRef.current);
|
|
496
|
+
}, [entityId, optionsKey, wiki]);
|
|
497
|
+
const refetch = useCallback10(() => {
|
|
498
|
+
scheduleFetch.current(entityIdRef.current, optionsRef.current);
|
|
499
|
+
}, [entityId, optionsKey]);
|
|
500
|
+
return { nodes, edges, isPending, error, refetch };
|
|
501
|
+
}
|
|
350
502
|
export {
|
|
351
503
|
WikiProvider,
|
|
352
504
|
useEntityStatus,
|
|
353
505
|
useMemoryRead,
|
|
506
|
+
useOntologyManifest,
|
|
507
|
+
useSetOntologyManifest,
|
|
354
508
|
useWiki,
|
|
355
509
|
useWikiExport,
|
|
356
510
|
useWikiForget,
|
|
357
511
|
useWikiHasChanged,
|
|
358
512
|
useWikiIngest,
|
|
359
513
|
useWikiMaintenance,
|
|
514
|
+
useWikiTraversal,
|
|
360
515
|
useWikiWrite
|
|
361
516
|
};
|
|
362
517
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/WikiContext.tsx","../src/useMemoryRead.ts","../src/useWikiWrite.ts","../src/useWikiMaintenance.ts","../src/useWikiIngest.ts","../src/useWikiForget.ts","../src/useWikiExport.ts","../src/useWikiHasChanged.ts","../src/useEntityStatus.ts"],"sourcesContent":["export * from '@equationalapplications/core-llm-wiki';\nexport { WikiProvider, useWiki } from './WikiContext';\nexport { useMemoryRead } from './useMemoryRead';\nexport { useWikiWrite } from './useWikiWrite';\nexport { useWikiMaintenance } from './useWikiMaintenance';\nexport type { MaintenanceResult } from './useWikiMaintenance';\nexport { useWikiIngest } from './useWikiIngest';\nexport { useWikiForget } from './useWikiForget';\nexport { useWikiExport } from './useWikiExport';\nexport { useWikiHasChanged } from './useWikiHasChanged';\nexport { useEntityStatus } from './useEntityStatus';\n","import React, { createContext, useContext, type ReactNode } from 'react';\nimport { WikiMemory } from '@equationalapplications/core-llm-wiki';\n\nconst WikiContext = createContext<WikiMemory | null>(null);\n\nexport function WikiProvider({ wiki, children }: { wiki: WikiMemory; children: ReactNode }) {\n return <WikiContext.Provider value={wiki}>{children}</WikiContext.Provider>;\n}\n\nexport function useWiki(): WikiMemory {\n const wiki = useContext(WikiContext);\n if (!wiki) throw new Error('useWiki must be used within WikiProvider');\n return wiki;\n}\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport type { MemoryBundle, ReadOptions } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\n/**\n * Normalize a ReadOptions object to a canonical string suitable for use as a\n * React effect dependency key. Normalization ensures:\n * - `undefined` and `{}` produce the same empty string (no spurious refetch)\n * - Non-serializable numbers are coerced to their effective values before\n * stringifying, matching how WikiMemory.read() resolves them:\n * · maxResults: NaN/±Infinity → 10 (read()'s hardcoded fallback, overrides config)\n * · preFilterLimit: NaN/±Infinity → null (disables config-level limit, same as null)\n * · hybridWeight: NaN → null (explicitly disables config-level weight; distinct from\n * undefined which defers to config); ±Infinity → clamped to 0/1\n * · tierWeights values: non-finite → 1.0, negative → 0 (mirrors core sanitization)\n * · tierWeights keys: projected onto the active entityId set (mirrors core's\n * sanitizeTierWeights which ignores weights for entities not in the request)\n * · tierWeights keys at default weight (1.0) are dropped — spec says missing\n * weights default to 1.0, so explicit 1.0 is behaviorally identical to omission\n * · tierWeights: {} or fully-filtered/all-default result is omitted (same as undefined)\n * · includeZeroWeightEntities: false/undefined are equivalent (both skip zero-weight\n * entities); only true is keyed, matching core's default behavior\n * - Keys are sorted so insertion-order differences never cause spurious refetches\n */\nfunction normalizeReadOptionsKey(entityId: string | string[], opts?: ReadOptions): string {\n if (!opts) return '';\n const normalized: Record<string, unknown> = {};\n\n // maxResults: undefined or null → omit (defer to config/default via ??);\n // non-finite (NaN/±Infinity) → 10 (read()'s hardcoded fallback, bypasses config);\n // finite → clamp to non-negative integer.\n if (opts.maxResults !== undefined && opts.maxResults !== null) {\n normalized.maxResults = Number.isFinite(opts.maxResults)\n ? Math.max(0, Math.trunc(opts.maxResults))\n : 10;\n }\n\n // preFilterLimit: undefined → omit (defer to config);\n // null or non-finite → null (disables config-level limit);\n // finite → clamp to non-negative integer.\n if (opts.preFilterLimit !== undefined) {\n if (opts.preFilterLimit === null || !Number.isFinite(opts.preFilterLimit)) {\n normalized.preFilterLimit = null;\n } else {\n normalized.preFilterLimit = Math.max(0, Math.trunc(opts.preFilterLimit));\n }\n }\n\n // hybridWeight: undefined or null → omit (defer to config via ??);\n // NaN → null (explicitly disables config hybrid weight; distinct from omitting);\n // ±Infinity and out-of-range finite → clamp to [0, 1].\n if (opts.hybridWeight !== undefined && opts.hybridWeight !== null) {\n normalized.hybridWeight = Number.isNaN(opts.hybridWeight)\n ? null\n : Math.max(0, Math.min(1, opts.hybridWeight));\n }\n\n // tierWeights: project onto the active entity set (core's sanitizeTierWeights only\n // considers weights for the requested entityIds, so unrelated keys have no behavioral\n // effect and should not contribute to the dep key). Sanitize values (non-finite → 1.0,\n // negative → 0) and sort keys to avoid spurious refetches from insertion-order or\n // logically-equivalent value differences. Drop entries at the default weight (1.0)\n // because missing weights also default to 1.0 per spec — explicit 1.0 is behaviorally\n // identical to omission. Use Object.create(null) to match core's sanitizeTierWeights\n // and avoid prototype-key edge cases (e.g. entityIds like __proto__). Omit entirely\n // when the projected+filtered result is empty (same as undefined).\n if (opts.tierWeights !== undefined) {\n const activeIds = new Set(Array.isArray(entityId) ? entityId : [entityId]);\n const tw = opts.tierWeights;\n const twKeys = Object.keys(tw).filter(k => activeIds.has(k)).sort();\n if (twKeys.length) {\n const sanitized = Object.create(null) as Record<string, number>;\n for (const k of twKeys) {\n const w = tw[k];\n sanitized[k] = !Number.isFinite(w) ? 1.0 : Math.max(0, w);\n }\n // Drop default-weight entries (1.0) — spec says missing weights default to 1.0\n const nonDefaultKeys = twKeys.filter(k => sanitized[k] !== 1.0);\n if (nonDefaultKeys.length) {\n normalized.tierWeights = JSON.stringify(sanitized, nonDefaultKeys);\n }\n }\n }\n\n // includeZeroWeightEntities: false and undefined are equivalent in core (both exclude\n // zero-weight entities from scored retrieval). Only key when true so toggling\n // undefined → false does not cause a spurious refetch.\n if (opts.includeZeroWeightEntities === true) {\n normalized.includeZeroWeightEntities = true;\n }\n\n const sortedKeys = Object.keys(normalized).sort();\n return sortedKeys.length ? JSON.stringify(normalized, sortedKeys) : '';\n}\n\nexport function useMemoryRead(entityId: string | string[], query: string, options?: ReadOptions) {\n const wiki = useWiki();\n const [data, setData] = useState<MemoryBundle | null>(null);\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const entityIdRef = useRef(entityId);\n entityIdRef.current = entityId;\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n // Stable dep key for entityId: sort+dedup so inline array literals (new reference\n // each render) don't cause spurious refetches. The same set of entity IDs always\n // produces the same key regardless of reference identity or insertion order.\n const entityIdKey = Array.isArray(entityId)\n ? [...new Set(entityId)].sort().join('\\0')\n : entityId;\n\n // Serialize a normalized form of options so:\n // - `undefined` and `{}` map to the same string (no spurious refetch)\n // - non-finite hybridWeight (±Infinity, NaN) is coerced to its effective value before\n // stringifying (JSON.stringify turns Infinity/NaN to `null`, losing type information)\n // - keys are sorted so insertion-order differences don't cause spurious refetches\n const optionsStr = normalizeReadOptionsKey(entityId, options);\n\n const fetchQueue = useRef<{\n inFlight: boolean;\n pending: { entityId: string | string[]; query: string } | null;\n }>({ inFlight: false, pending: null });\n\n // Stable scheduler: refs keep it from going stale across renders.\n // In-flight results are never discarded — spec requires them to land before\n // starting the next fetch with latest args.\n const scheduleFetch = useRef(function schedule(eid: string | string[], q: string) {\n const fq = fetchQueue.current;\n if (fq.inFlight) {\n fq.pending = { entityId: eid, query: q };\n return;\n }\n fq.inFlight = true;\n setIsPending(true);\n\n wikiRef.current.read(eid, q, optionsRef.current).then(\n (result) => { setData(result); setError(null); },\n (e: unknown) => { setError(e instanceof Error ? e : new Error(String(e))); }\n ).finally(() => {\n fq.inFlight = false;\n const next = fq.pending;\n fq.pending = null;\n if (next) {\n scheduleFetch.current(next.entityId, next.query);\n } else {\n setIsPending(false);\n }\n });\n });\n\n useEffect(() => {\n scheduleFetch.current(entityIdRef.current, query);\n }, [entityIdKey, query, wiki, optionsStr]);\n\n const refetch = useCallback(() => {\n scheduleFetch.current(entityIdRef.current, query);\n }, [entityIdKey, query]);\n\n return { data, isPending, error, refetch };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport type { WikiEvent } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\ntype WriteEvent = Omit<WikiEvent, 'id' | 'entity_id' | 'created_at'>;\n\nexport function useWikiWrite() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<void | null>(null);\n\n const execute = useCallback(async (entityId: string, event: WriteEvent): Promise<void> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n await wikiRef.current.write(entityId, event);\n setLastResult(undefined);\n } catch (e) {\n const error = e instanceof Error ? e : new Error(String(e));\n setError(error);\n throw error;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\nexport type MaintenanceResult =\n | { operation: 'librarian' | 'heal'; result: undefined }\n | { operation: 'prune'; result: { entries: number; tasks: number; events: number } };\n\nexport function useWikiMaintenance() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<MaintenanceResult | null>(null);\n // Counter so any overlapping maintenance operation keeps isPending=true until all complete\n const pendingCount = useRef(0);\n\n const runLibrarian = useCallback(async (entityId: string, options?: { promptOverride?: string }): Promise<void> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n await (options ? wikiRef.current.runLibrarian(entityId, options) : wikiRef.current.runLibrarian(entityId));\n setLastResult({ operation: 'librarian', result: undefined });\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n }, []);\n\n const runHeal = useCallback(async (entityId: string, options?: { promptOverride?: string }): Promise<void> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n await (options ? wikiRef.current.runHeal(entityId, options) : wikiRef.current.runHeal(entityId));\n setLastResult({ operation: 'heal', result: undefined });\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n }, []);\n\n const runPrune = useCallback(\n async (\n entityId: string,\n options?: {\n retainSoftDeletedFor?: number | null;\n retainEventsFor?: number | null;\n vacuum?: boolean;\n }\n ): Promise<{ entries: number; tasks: number; events: number }> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.runPrune(entityId, options);\n setLastResult({ operation: 'prune', result });\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n },\n []\n );\n\n const runReembed = useCallback(async (entityId?: string, opts?: { force?: boolean; skipExisting?: boolean }): Promise<{ embedded: number; skipped: number; failed: number }> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n // runReembed returns its result directly; it does not update the shared\n // MaintenanceResult/lastResult field (which only tracks librarian, heal, prune).\n // Using the return value directly avoids widening the MaintenanceResult union\n // in a way that would break existing consumers that exhaustively switch on\n // lastResult.operation.\n return await wikiRef.current.runReembed(entityId, opts);\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n }, []);\n\n return { runLibrarian, runHeal, runPrune, runReembed, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\ninterface IngestParams {\n sourceRef: string;\n sourceHash: string;\n documentChunk: string;\n maxChunkLength?: number;\n promptOverride?: string;\n}\n\ntype IngestResult = { truncated: boolean; chunks: number };\n\nexport function useWikiIngest() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<IngestResult | null>(null);\n\n const execute = useCallback(async (entityId: string, params: IngestParams): Promise<IngestResult> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.ingestDocument(entityId, params);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\ninterface ForgetParams {\n entryId?: string;\n taskId?: string;\n sourceRef?: string;\n sourceHash?: string;\n clearAll?: boolean;\n}\n\ntype ForgetResult = { deleted: { entries: number; tasks: number } };\n\nexport function useWikiForget() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<ForgetResult | null>(null);\n\n const execute = useCallback(async (entityId: string, params: ForgetParams): Promise<ForgetResult> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.forget(entityId, params);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\nimport type { MemoryDump } from '@equationalapplications/core-llm-wiki';\n\nexport function useWikiExport() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<MemoryDump | null>(null);\n\n const execute = useCallback(async (entityIds?: string[]): Promise<MemoryDump> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.exportDump(entityIds);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\nexport function useWikiHasChanged() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<boolean | null>(null);\n\n const execute = useCallback(\n async (entityId: string, sourceRef: string, sourceHash: string): Promise<boolean> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.hasChanged(entityId, sourceRef, sourceHash);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n },\n []\n );\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useEffect } from 'react';\nimport { useWiki } from './WikiContext';\nimport type { EntityStatus } from '@equationalapplications/core-llm-wiki';\n\nexport function useEntityStatus(entityId: string): EntityStatus {\n const wiki = useWiki();\n const [snapshot, setSnapshot] = useState(() => ({\n wiki,\n entityId,\n status: wiki.getEntityStatus(entityId),\n }));\n\n useEffect(() => {\n setSnapshot({ wiki, entityId, status: wiki.getEntityStatus(entityId) });\n return wiki.subscribeEntityStatus(entityId, (status) => {\n setSnapshot({ wiki, entityId, status });\n });\n }, [wiki, entityId]);\n\n return snapshot.wiki === wiki && snapshot.entityId === entityId\n ? snapshot.status\n : wiki.getEntityStatus(entityId);\n}\n"],"mappings":";AAAA,cAAc;;;ACAd,SAAgB,eAAe,kBAAkC;AAMxD;AAHT,IAAM,cAAc,cAAiC,IAAI;AAElD,SAAS,aAAa,EAAE,MAAM,SAAS,GAA8C;AAC1F,SAAO,oBAAC,YAAY,UAAZ,EAAqB,OAAO,MAAO,UAAS;AACtD;AAEO,SAAS,UAAsB;AACpC,QAAM,OAAO,WAAW,WAAW;AACnC,MAAI,CAAC,KAAM,OAAM,IAAI,MAAM,0CAA0C;AACrE,SAAO;AACT;;;ACbA,SAAS,UAAU,WAAW,aAAa,cAAc;AAwBzD,SAAS,wBAAwB,UAA6B,MAA4B;AACxF,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,aAAsC,CAAC;AAK7C,MAAI,KAAK,eAAe,UAAa,KAAK,eAAe,MAAM;AAC7D,eAAW,aAAa,OAAO,SAAS,KAAK,UAAU,IACnD,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,UAAU,CAAC,IACvC;AAAA,EACN;AAKA,MAAI,KAAK,mBAAmB,QAAW;AACrC,QAAI,KAAK,mBAAmB,QAAQ,CAAC,OAAO,SAAS,KAAK,cAAc,GAAG;AACzE,iBAAW,iBAAiB;AAAA,IA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H;AAEA,SAAO,EAAE,SAAS,YAAY,WAAW,MAAM;AACjD;;;ACjCA,SAAS,YAAAC,WAAU,aAAAC,kBAAiB;AAI7B,SAAS,gBAAgB,UAAgC;AAC9D,QAAM,OAAO,QAAQ;AACrB,QAAM,CAAC,UAAU,WAAW,IAAIC,UAAS,OAAO;AAAA,IAC9C;AAAA,IACA;AAAA,IACA,QAAQ,KAAK,gBAAgB,QAAQ;AAAA,EACvC,EAAE;AAEF,EAAAC,WAAU,MAAM;AACd,gBAAY,EAAE,MAAM,UAAU,QAAQ,KAAK,gBAAgB,QAAQ,EAAE,CAAC;AACtE,WAAO,KAAK,sBAAsB,UAAU,CAAC,WAAW;AACtD,kBAAY,EAAE,MAAM,UAAU,OAAO,CAAC;AAAA,IACxC,CAAC;AAAA,EACH,GAAG,CAAC,MAAM,QAAQ,CAAC;AAEnB,SAAO,SAAS,SAAS,QAAQ,SAAS,aAAa,WACnD,SAAS,SACT,KAAK,gBAAgB,QAAQ;AACnC;","names":["useState","useCallback","useRef","useRef","useState","useCallback","error","useState","useCallback","useRef","useRef","useState","useCallback","useState","useCallback","useRef","useRef","useState","useCallback","useState","useCallback","useRef","useRef","useState","useCallback","useState","useCallback","useRef","useRef","useState","useCallback","useState","useCallback","useRef","useRef","useState","useCallback","useState","useEffect","useState","useEffect"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/WikiContext.tsx","../src/useMemoryRead.ts","../src/useWikiWrite.ts","../src/useWikiMaintenance.ts","../src/useWikiIngest.ts","../src/useWikiForget.ts","../src/useWikiExport.ts","../src/useWikiHasChanged.ts","../src/useEntityStatus.ts","../src/useOntologyManifest.ts","../src/useSetOntologyManifest.ts","../src/useWikiTraversal.ts"],"sourcesContent":["export * from '@equationalapplications/core-llm-wiki';\nexport { WikiProvider, useWiki } from './WikiContext';\nexport { useMemoryRead } from './useMemoryRead';\nexport { useWikiWrite } from './useWikiWrite';\nexport { useWikiMaintenance } from './useWikiMaintenance';\nexport type { MaintenanceResult } from './useWikiMaintenance';\nexport { useWikiIngest } from './useWikiIngest';\nexport { useWikiForget } from './useWikiForget';\nexport { useWikiExport } from './useWikiExport';\nexport { useWikiHasChanged } from './useWikiHasChanged';\nexport { useEntityStatus } from './useEntityStatus';\nexport { useOntologyManifest } from './useOntologyManifest';\nexport type { OntologyManifestState } from './useOntologyManifest';\nexport { useSetOntologyManifest } from './useSetOntologyManifest';\nexport { useWikiTraversal } from './useWikiTraversal';\nexport type { WikiTraversalState } from './useWikiTraversal';\n","import React, { createContext, useContext, type ReactNode } from 'react';\nimport { WikiMemory } from '@equationalapplications/core-llm-wiki';\n\nconst WikiContext = createContext<WikiMemory | null>(null);\n\nexport function WikiProvider({ wiki, children }: { wiki: WikiMemory; children: ReactNode }) {\n return <WikiContext.Provider value={wiki}>{children}</WikiContext.Provider>;\n}\n\nexport function useWiki(): WikiMemory {\n const wiki = useContext(WikiContext);\n if (!wiki) throw new Error('useWiki must be used within WikiProvider');\n return wiki;\n}\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport type { MemoryBundle, ReadOptions } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\n/**\n * Normalize a ReadOptions object to a canonical string suitable for use as a\n * React effect dependency key. Normalization ensures:\n * - `undefined` and `{}` produce the same empty string (no spurious refetch)\n * - Non-serializable numbers are coerced to their effective values before\n * stringifying, matching how WikiMemory.read() resolves them:\n * · maxResults: NaN/±Infinity → 10 (read()'s hardcoded fallback, overrides config)\n * · preFilterLimit: NaN/±Infinity → null (disables config-level limit, same as null)\n * · hybridWeight: NaN → null (explicitly disables config-level weight; distinct from\n * undefined which defers to config); ±Infinity → clamped to 0/1\n * · tierWeights values: non-finite → 1.0, negative → 0 (mirrors core sanitization)\n * · tierWeights keys: projected onto the active entityId set (mirrors core's\n * sanitizeTierWeights which ignores weights for entities not in the request)\n * · tierWeights keys at default weight (1.0) are dropped — spec says missing\n * weights default to 1.0, so explicit 1.0 is behaviorally identical to omission\n * · tierWeights: {} or fully-filtered/all-default result is omitted (same as undefined)\n * · includeZeroWeightEntities: false/undefined are equivalent (both skip zero-weight\n * entities); only true is keyed, matching core's default behavior\n * - Keys are sorted so insertion-order differences never cause spurious refetches\n */\nfunction normalizeReadOptionsKey(entityId: string | string[], opts?: ReadOptions): string {\n if (!opts) return '';\n const normalized: Record<string, unknown> = {};\n\n // maxResults: undefined or null → omit (defer to config/default via ??);\n // non-finite (NaN/±Infinity) → 10 (read()'s hardcoded fallback, bypasses config);\n // finite → clamp to non-negative integer.\n if (opts.maxResults !== undefined && opts.maxResults !== null) {\n normalized.maxResults = Number.isFinite(opts.maxResults)\n ? Math.max(0, Math.trunc(opts.maxResults))\n : 10;\n }\n\n // preFilterLimit: undefined → omit (defer to config);\n // null or non-finite → null (disables config-level limit);\n // finite → clamp to non-negative integer.\n if (opts.preFilterLimit !== undefined) {\n if (opts.preFilterLimit === null || !Number.isFinite(opts.preFilterLimit)) {\n normalized.preFilterLimit = null;\n } else {\n normalized.preFilterLimit = Math.max(0, Math.trunc(opts.preFilterLimit));\n }\n }\n\n // hybridWeight: undefined or null → omit (defer to config via ??);\n // NaN → null (explicitly disables config hybrid weight; distinct from omitting);\n // ±Infinity and out-of-range finite → clamp to [0, 1].\n if (opts.hybridWeight !== undefined && opts.hybridWeight !== null) {\n normalized.hybridWeight = Number.isNaN(opts.hybridWeight)\n ? null\n : Math.max(0, Math.min(1, opts.hybridWeight));\n }\n\n // tierWeights: project onto the active entity set (core's sanitizeTierWeights only\n // considers weights for the requested entityIds, so unrelated keys have no behavioral\n // effect and should not contribute to the dep key). Sanitize values (non-finite → 1.0,\n // negative → 0) and sort keys to avoid spurious refetches from insertion-order or\n // logically-equivalent value differences. Drop entries at the default weight (1.0)\n // because missing weights also default to 1.0 per spec — explicit 1.0 is behaviorally\n // identical to omission. Use Object.create(null) to match core's sanitizeTierWeights\n // and avoid prototype-key edge cases (e.g. entityIds like __proto__). Omit entirely\n // when the projected+filtered result is empty (same as undefined).\n if (opts.tierWeights !== undefined) {\n const activeIds = new Set(Array.isArray(entityId) ? entityId : [entityId]);\n const tw = opts.tierWeights;\n const twKeys = Object.keys(tw).filter(k => activeIds.has(k)).sort();\n if (twKeys.length) {\n const sanitized = Object.create(null) as Record<string, number>;\n for (const k of twKeys) {\n const w = tw[k];\n sanitized[k] = !Number.isFinite(w) ? 1.0 : Math.max(0, w);\n }\n // Drop default-weight entries (1.0) — spec says missing weights default to 1.0\n const nonDefaultKeys = twKeys.filter(k => sanitized[k] !== 1.0);\n if (nonDefaultKeys.length) {\n normalized.tierWeights = JSON.stringify(sanitized, nonDefaultKeys);\n }\n }\n }\n\n // includeZeroWeightEntities: false and undefined are equivalent in core (both exclude\n // zero-weight entities from scored retrieval). Only key when true so toggling\n // undefined → false does not cause a spurious refetch.\n if (opts.includeZeroWeightEntities === true) {\n normalized.includeZeroWeightEntities = true;\n }\n\n const sortedKeys = Object.keys(normalized).sort();\n return sortedKeys.length ? JSON.stringify(normalized, sortedKeys) : '';\n}\n\nexport function useMemoryRead(entityId: string | string[], query: string, options?: ReadOptions) {\n const wiki = useWiki();\n const [data, setData] = useState<MemoryBundle | null>(null);\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const entityIdRef = useRef(entityId);\n entityIdRef.current = entityId;\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n // Stable dep key for entityId: sort+dedup so inline array literals (new reference\n // each render) don't cause spurious refetches. The same set of entity IDs always\n // produces the same key regardless of reference identity or insertion order.\n const entityIdKey = Array.isArray(entityId)\n ? [...new Set(entityId)].sort().join('\\0')\n : entityId;\n\n // Serialize a normalized form of options so:\n // - `undefined` and `{}` map to the same string (no spurious refetch)\n // - non-finite hybridWeight (±Infinity, NaN) is coerced to its effective value before\n // stringifying (JSON.stringify turns Infinity/NaN to `null`, losing type information)\n // - keys are sorted so insertion-order differences don't cause spurious refetches\n const optionsStr = normalizeReadOptionsKey(entityId, options);\n\n const fetchQueue = useRef<{\n inFlight: boolean;\n pending: { entityId: string | string[]; query: string } | null;\n }>({ inFlight: false, pending: null });\n\n // Stable scheduler: refs keep it from going stale across renders.\n // In-flight results are never discarded — spec requires them to land before\n // starting the next fetch with latest args.\n const scheduleFetch = useRef(function schedule(eid: string | string[], q: string) {\n const fq = fetchQueue.current;\n if (fq.inFlight) {\n fq.pending = { entityId: eid, query: q };\n return;\n }\n fq.inFlight = true;\n setIsPending(true);\n\n wikiRef.current.read(eid, q, optionsRef.current).then(\n (result) => { setData(result); setError(null); },\n (e: unknown) => { setError(e instanceof Error ? e : new Error(String(e))); }\n ).finally(() => {\n fq.inFlight = false;\n const next = fq.pending;\n fq.pending = null;\n if (next) {\n scheduleFetch.current(next.entityId, next.query);\n } else {\n setIsPending(false);\n }\n });\n });\n\n useEffect(() => {\n scheduleFetch.current(entityIdRef.current, query);\n }, [entityIdKey, query, wiki, optionsStr]);\n\n const refetch = useCallback(() => {\n scheduleFetch.current(entityIdRef.current, query);\n }, [entityIdKey, query]);\n\n return { data, isPending, error, refetch };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport type { WikiEvent } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\ntype WriteEvent = Omit<WikiEvent, 'id' | 'entity_id' | 'created_at'>;\n\nexport function useWikiWrite() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<void | null>(null);\n\n const execute = useCallback(async (entityId: string, event: WriteEvent): Promise<void> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n await wikiRef.current.write(entityId, event);\n setLastResult(undefined);\n } catch (e) {\n const error = e instanceof Error ? e : new Error(String(e));\n setError(error);\n throw error;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\nexport type MaintenanceResult =\n | { operation: 'librarian' | 'heal'; result: undefined }\n | { operation: 'prune'; result: { entries: number; tasks: number; events: number } };\n\nexport function useWikiMaintenance() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<MaintenanceResult | null>(null);\n // Counter so any overlapping maintenance operation keeps isPending=true until all complete\n const pendingCount = useRef(0);\n\n const runLibrarian = useCallback(async (entityId: string, options?: { promptOverride?: string }): Promise<void> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n await (options ? wikiRef.current.runLibrarian(entityId, options) : wikiRef.current.runLibrarian(entityId));\n setLastResult({ operation: 'librarian', result: undefined });\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n }, []);\n\n const runHeal = useCallback(async (entityId: string, options?: { promptOverride?: string }): Promise<void> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n await (options ? wikiRef.current.runHeal(entityId, options) : wikiRef.current.runHeal(entityId));\n setLastResult({ operation: 'heal', result: undefined });\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n }, []);\n\n const runPrune = useCallback(\n async (\n entityId: string,\n options?: {\n retainSoftDeletedFor?: number | null;\n retainEventsFor?: number | null;\n vacuum?: boolean;\n }\n ): Promise<{ entries: number; tasks: number; events: number }> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.runPrune(entityId, options);\n setLastResult({ operation: 'prune', result });\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n },\n []\n );\n\n const runReembed = useCallback(async (entityId?: string, opts?: { force?: boolean; skipExisting?: boolean }): Promise<{ embedded: number; skipped: number; failed: number }> => {\n setError(null);\n pendingCount.current += 1;\n setIsPending(true);\n setLastResult(null);\n try {\n // runReembed returns its result directly; it does not update the shared\n // MaintenanceResult/lastResult field (which only tracks librarian, heal, prune).\n // Using the return value directly avoids widening the MaintenanceResult union\n // in a way that would break existing consumers that exhaustively switch on\n // lastResult.operation.\n return await wikiRef.current.runReembed(entityId, opts);\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n pendingCount.current -= 1;\n if (pendingCount.current === 0) setIsPending(false);\n }\n }, []);\n\n return { runLibrarian, runHeal, runPrune, runReembed, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\ninterface IngestParams {\n sourceRef: string;\n sourceHash: string;\n documentChunk: string;\n maxChunkLength?: number;\n promptOverride?: string;\n}\n\ntype IngestResult = { truncated: boolean; chunks: number };\n\nexport function useWikiIngest() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<IngestResult | null>(null);\n\n const execute = useCallback(async (entityId: string, params: IngestParams): Promise<IngestResult> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.ingestDocument(entityId, params);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\ninterface ForgetParams {\n entryId?: string;\n taskId?: string;\n sourceRef?: string;\n sourceHash?: string;\n clearAll?: boolean;\n}\n\ntype ForgetResult = { deleted: { entries: number; tasks: number } };\n\nexport function useWikiForget() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<ForgetResult | null>(null);\n\n const execute = useCallback(async (entityId: string, params: ForgetParams): Promise<ForgetResult> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.forget(entityId, params);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\nimport type { MemoryDump } from '@equationalapplications/core-llm-wiki';\n\nexport function useWikiExport() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<MemoryDump | null>(null);\n\n const execute = useCallback(async (entityIds?: string[]): Promise<MemoryDump> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.exportDump(entityIds);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useWiki } from './WikiContext';\n\nexport function useWikiHasChanged() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<boolean | null>(null);\n\n const execute = useCallback(\n async (entityId: string, sourceRef: string, sourceHash: string): Promise<boolean> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n const result = await wikiRef.current.hasChanged(entityId, sourceRef, sourceHash);\n setLastResult(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setIsPending(false);\n }\n },\n []\n );\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useEffect } from 'react';\nimport { useWiki } from './WikiContext';\nimport type { EntityStatus } from '@equationalapplications/core-llm-wiki';\n\nexport function useEntityStatus(entityId: string): EntityStatus {\n const wiki = useWiki();\n const [snapshot, setSnapshot] = useState(() => ({\n wiki,\n entityId,\n status: wiki.getEntityStatus(entityId),\n }));\n\n useEffect(() => {\n setSnapshot({ wiki, entityId, status: wiki.getEntityStatus(entityId) });\n return wiki.subscribeEntityStatus(entityId, (status) => {\n setSnapshot({ wiki, entityId, status });\n });\n }, [wiki, entityId]);\n\n return snapshot.wiki === wiki && snapshot.entityId === entityId\n ? snapshot.status\n : wiki.getEntityStatus(entityId);\n}\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport type { OntologyManifest, OntologyMode } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\n/**\n * Reactive state returned by {@link useOntologyManifest}.\n */\nexport interface OntologyManifestState {\n /** Resolved manifest, or `null` when `getOntologyManifest` returns `null`. */\n manifest: OntologyManifest | null;\n /** Resolved mode, or `null` when no manifest row/seed applies. */\n mode: OntologyMode | null;\n isPending: boolean;\n error: Error | null;\n refetch: () => void;\n}\n\n/**\n * Reactive read hook for an entity's ontology manifest and mode.\n * Fetches on mount and whenever `entityId` or `wiki` changes.\n * Call `refetch()` after mutations (e.g. {@link useSetOntologyManifest}) to refresh.\n */\nexport function useOntologyManifest(entityId: string): OntologyManifestState {\n const wiki = useWiki();\n const [manifest, setManifest] = useState<OntologyManifest | null>(null);\n const [mode, setMode] = useState<OntologyMode | null>(null);\n const [isPending, setIsPending] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const entityIdRef = useRef(entityId);\n entityIdRef.current = entityId;\n\n const fetchQueue = useRef<{\n inFlight: boolean;\n pending: string | null;\n }>({ inFlight: false, pending: null });\n\n const scheduleFetch = useRef(function schedule(eid: string) {\n const fq = fetchQueue.current;\n if (fq.inFlight) {\n fq.pending = eid;\n return;\n }\n fq.inFlight = true;\n setIsPending(true);\n\n wikiRef.current.getOntologyManifest(eid).then(\n (result) => {\n if (result) {\n setManifest(result.manifest);\n setMode(result.mode);\n } else {\n setManifest(null);\n setMode(null);\n }\n setError(null);\n },\n (e: unknown) => {\n setError(e instanceof Error ? e : new Error(String(e)));\n },\n ).finally(() => {\n fq.inFlight = false;\n const next = fq.pending;\n fq.pending = null;\n if (next !== null) {\n scheduleFetch.current(next);\n } else {\n setIsPending(false);\n }\n });\n });\n\n useEffect(() => {\n scheduleFetch.current(entityIdRef.current);\n }, [entityId, wiki]);\n\n const refetch = useCallback(() => {\n scheduleFetch.current(entityIdRef.current);\n }, [entityId]);\n\n return { manifest, mode, isPending, error, refetch };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport type { OntologyManifest, OntologyMode } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\n/**\n * Mutation hook for seeding or replacing an entity's ontology manifest.\n * Mirrors the `{ execute, isPending, error, lastResult }` contract of {@link useWikiWrite}.\n * Does not auto-refresh {@link useOntologyManifest} — call `refetch()` after a successful `execute()`.\n */\nexport function useSetOntologyManifest() {\n const wiki = useWiki();\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [lastResult, setLastResult] = useState<void | null>(null);\n\n const execute = useCallback(async (\n entityId: string,\n manifest: OntologyManifest,\n options?: { mode?: OntologyMode },\n ): Promise<void> => {\n setError(null);\n setIsPending(true);\n setLastResult(null);\n try {\n await wikiRef.current.setOntologyManifest(entityId, manifest, options);\n setLastResult(undefined);\n } catch (e) {\n const error = e instanceof Error ? e : new Error(String(e));\n setError(error);\n throw error;\n } finally {\n setIsPending(false);\n }\n }, []);\n\n return { execute, lastResult, isPending, error };\n}\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport type { GraphTraversalOptions, WikiFact, WikiEdge } from '@equationalapplications/core-llm-wiki';\nimport { useWiki } from './WikiContext';\n\nexport interface WikiTraversalState {\n nodes: WikiFact[];\n edges: WikiEdge[];\n isPending: boolean;\n error: Error | null;\n refetch: () => void;\n}\n\n/**\n * Stable dep key for a GraphTraversalOptions object so inline object literals\n * (new reference each render) don't cause spurious refetches. Sorted-key\n * JSON.stringify, mirroring normalizeReadOptionsKey in useMemoryRead.ts.\n */\nfunction normalizeTraversalOptionsKey(options: GraphTraversalOptions): string {\n const normalized: Record<string, unknown> = { sourceId: options.sourceId };\n\n if (options.maxDepth !== undefined) normalized.maxDepth = options.maxDepth;\n if (options.direction !== undefined) normalized.direction = options.direction;\n if (options.edgeTypes !== undefined) normalized.edgeTypes = [...options.edgeTypes].sort();\n if (options.maxTraversalNodes !== undefined) normalized.maxTraversalNodes = options.maxTraversalNodes;\n if (options.minTraversalConfidence !== undefined) normalized.minTraversalConfidence = options.minTraversalConfidence;\n if (options.excludeSourceTypes !== undefined) normalized.excludeSourceTypes = [...options.excludeSourceTypes].sort();\n\n const sortedKeys = Object.keys(normalized).sort();\n const sorted: Record<string, unknown> = {};\n for (const k of sortedKeys) {\n sorted[k] = normalized[k];\n }\n // Do not pass sortedKeys as a JSON.stringify replacer — array values would lose\n // their elements because replacer keys must be object property names, not indices.\n return JSON.stringify(sorted);\n}\n\n/**\n * Reactive read hook for graph traversal. Fetches on mount and whenever\n * `entityId` or a stable serialization of `options` changes.\n * Call `refetch()` after mutations that change the underlying edges (e.g. runLibrarian).\n */\nexport function useWikiTraversal(entityId: string, options: GraphTraversalOptions): WikiTraversalState {\n const wiki = useWiki();\n const [nodes, setNodes] = useState<WikiFact[]>([]);\n const [edges, setEdges] = useState<WikiEdge[]>([]);\n const [isPending, setIsPending] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const wikiRef = useRef(wiki);\n wikiRef.current = wiki;\n\n const entityIdRef = useRef(entityId);\n entityIdRef.current = entityId;\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const optionsKey = normalizeTraversalOptionsKey(options);\n\n const fetchQueue = useRef<{\n inFlight: boolean;\n pending: { entityId: string; options: GraphTraversalOptions } | null;\n }>({ inFlight: false, pending: null });\n\n // Stable scheduler: refs keep it from going stale across renders.\n // In-flight results are never discarded.\n const scheduleFetch = useRef(function schedule(eid: string, opts: GraphTraversalOptions) {\n const fq = fetchQueue.current;\n if (fq.inFlight) {\n fq.pending = { entityId: eid, options: opts };\n return;\n }\n fq.inFlight = true;\n setIsPending(true);\n\n wikiRef.current.traverseGraph(eid, opts).then(\n (result) => {\n setNodes(result.nodes);\n setEdges(result.edges);\n setError(null);\n },\n (e: unknown) => {\n setNodes([]);\n setEdges([]);\n setError(e instanceof Error ? e : new Error(String(e)));\n },\n ).finally(() => {\n fq.inFlight = false;\n const next = fq.pending;\n fq.pending = null;\n if (next) {\n scheduleFetch.current(next.entityId, next.options);\n } else {\n setIsPending(false);\n }\n });\n });\n\n useEffect(() => {\n scheduleFetch.current(entityIdRef.current, optionsRef.current);\n }, [entityId, optionsKey, wiki]);\n\n const refetch = useCallback(() => {\n scheduleFetch.current(entityIdRef.current, optionsRef.current);\n }, [entityId, optionsKey]);\n\n return { nodes, edges, isPending, error, refetch };\n}\n"],"mappings":";AAAA,cAAc;;;ACAd,SAAgB,eAAe,kBAAkC;AAMxD;AAHT,IAAM,cAAc,cAAiC,IAAI;AAElD,SAAS,aAAa,EAAE,MAAM,SAAS,GAA8C;AAC1F,SAAO,oBAAC,YAAY,UAAZ,EAAqB,OAAO,MAAO,UAAS;AACtD;AAEO,SAAS,UAAsB;AACpC,QAAM,OAAO,WAAW,WAAW;AACnC,MAAI,CAAC,KAAM,OA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CAAC;AACX,iBAAS,CAAC,CAAC;AACX,iBAAS,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC;AAAA,MACxD;AAAA,IACF,EAAE,QAAQ,MAAM;AACd,SAAG,WAAW;AACd,YAAM,OAAO,GAAG;AAChB,SAAG,UAAU;AACb,UAAI,MAAM;AACR,sBAAc,QAAQ,KAAK,UAAU,KAAK,OAAO;AAAA,MACnD,OAAO;AACL,qBAAa,KAAK;AAAA,MACpB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,EAAAC,WAAU,MAAM;AACd,kBAAc,QAAQ,YAAY,SAAS,WAAW,OAAO;AAAA,EAC/D,GAAG,CAAC,UAAU,YAAY,IAAI,CAAC;AAE/B,QAAM,UAAUC,cAAY,MAAM;AAChC,kBAAc,QAAQ,YAAY,SAAS,WAAW,OAAO;AAAA,EAC/D,GAAG,CAAC,UAAU,UAAU,CAAC;AAEzB,SAAO,EAAE,OAAO,OAAO,WAAW,OAAO,QAAQ;AACnD;","names":["useState","useCallback","useRef","useRef","useState","useCallback","error","useState","useCallback","useRef","useRef","useState","useCallback","useState","useCallback","useRef","useRef","useState","useCallback","useState","useCallback","useRef","useRef","useState","useCallback","useState","useCallback","useRef","useRef","useState","useCallback","useState","useCallback","useRef","useRef","useState","useCallback","useState","useEffect","useState","useEffect","useState","useEffect","useCallback","useRef","useState","useRef","useEffect","useCallback","useState","useCallback","useRef","useRef","useState","useCallback","error","useState","useEffect","useCallback","useRef","useState","useRef","useEffect","useCallback"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equationalapplications/react-llm-wiki",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.0",
|
|
4
4
|
"description": "In-browser LLM memory for React web apps. Bring your own SQLite adapter (e.g., sql.js WebAssembly) for a complete, zero-server RAG experience.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"registry": "https://registry.npmjs.org"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@equationalapplications/core-llm-wiki": "4.
|
|
59
|
+
"@equationalapplications/core-llm-wiki": "4.17.0"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=20"
|