@equationalapplications/react-llm-wiki 4.13.0 → 4.14.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 +12 -0
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -341,6 +341,18 @@ await execute(['user-123']);
|
|
|
341
341
|
// lastResult: MemoryDump | null
|
|
342
342
|
```
|
|
343
343
|
|
|
344
|
+
### `useEntityStatus(entityId)`
|
|
345
|
+
|
|
346
|
+
Live status for an entity's background jobs (ingest, librarian, heal). Updates whenever a transition occurs — no polling.
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
const { ingesting, librarian, heal } = useEntityStatus('user-123');
|
|
350
|
+
|
|
351
|
+
if (ingesting || librarian || heal) {
|
|
352
|
+
return <Spinner label={ingesting ? 'Ingesting…' : librarian ? 'Organizing…' : 'Healing…'} />;
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
344
356
|
## Multi-Entity Reads
|
|
345
357
|
|
|
346
358
|
`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:
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WikiMemory, ReadOptions, MemoryBundle, WikiEvent, MemoryDump } from '@equationalapplications/core-llm-wiki';
|
|
1
|
+
import { WikiMemory, ReadOptions, MemoryBundle, WikiEvent, MemoryDump, EntityStatus } 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';
|
|
@@ -116,4 +116,6 @@ declare function useWikiHasChanged(): {
|
|
|
116
116
|
error: Error | null;
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
declare function useEntityStatus(entityId: string): EntityStatus;
|
|
120
|
+
|
|
121
|
+
export { type MaintenanceResult, WikiProvider, useEntityStatus, useMemoryRead, useWiki, useWikiExport, useWikiForget, useWikiHasChanged, useWikiIngest, useWikiMaintenance, useWikiWrite };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WikiMemory, ReadOptions, MemoryBundle, WikiEvent, MemoryDump } from '@equationalapplications/core-llm-wiki';
|
|
1
|
+
import { WikiMemory, ReadOptions, MemoryBundle, WikiEvent, MemoryDump, EntityStatus } 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';
|
|
@@ -116,4 +116,6 @@ declare function useWikiHasChanged(): {
|
|
|
116
116
|
error: Error | null;
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
declare function useEntityStatus(entityId: string): EntityStatus;
|
|
120
|
+
|
|
121
|
+
export { type MaintenanceResult, WikiProvider, useEntityStatus, useMemoryRead, useWiki, useWikiExport, useWikiForget, useWikiHasChanged, useWikiIngest, useWikiMaintenance, useWikiWrite };
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
var index_exports = {};
|
|
23
23
|
__export(index_exports, {
|
|
24
24
|
WikiProvider: () => WikiProvider,
|
|
25
|
+
useEntityStatus: () => useEntityStatus,
|
|
25
26
|
useMemoryRead: () => useMemoryRead,
|
|
26
27
|
useWiki: () => useWiki,
|
|
27
28
|
useWikiExport: () => useWikiExport,
|
|
@@ -362,9 +363,28 @@ function useWikiHasChanged() {
|
|
|
362
363
|
);
|
|
363
364
|
return { execute, lastResult, isPending, error };
|
|
364
365
|
}
|
|
366
|
+
|
|
367
|
+
// src/useEntityStatus.ts
|
|
368
|
+
var import_react9 = require("react");
|
|
369
|
+
function useEntityStatus(entityId) {
|
|
370
|
+
const wiki = useWiki();
|
|
371
|
+
const [snapshot, setSnapshot] = (0, import_react9.useState)(() => ({
|
|
372
|
+
wiki,
|
|
373
|
+
entityId,
|
|
374
|
+
status: wiki.getEntityStatus(entityId)
|
|
375
|
+
}));
|
|
376
|
+
(0, import_react9.useEffect)(() => {
|
|
377
|
+
setSnapshot({ wiki, entityId, status: wiki.getEntityStatus(entityId) });
|
|
378
|
+
return wiki.subscribeEntityStatus(entityId, (status) => {
|
|
379
|
+
setSnapshot({ wiki, entityId, status });
|
|
380
|
+
});
|
|
381
|
+
}, [wiki, entityId]);
|
|
382
|
+
return snapshot.wiki === wiki && snapshot.entityId === entityId ? snapshot.status : wiki.getEntityStatus(entityId);
|
|
383
|
+
}
|
|
365
384
|
// Annotate the CommonJS export names for ESM import in node:
|
|
366
385
|
0 && (module.exports = {
|
|
367
386
|
WikiProvider,
|
|
387
|
+
useEntityStatus,
|
|
368
388
|
useMemoryRead,
|
|
369
389
|
useWiki,
|
|
370
390
|
useWikiExport,
|
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"],"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';\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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;AAC3B,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;","names":["import_react","import_react","error","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"],"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;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;AA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+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"]}
|
package/dist/index.mjs
CHANGED
|
@@ -329,8 +329,27 @@ function useWikiHasChanged() {
|
|
|
329
329
|
);
|
|
330
330
|
return { execute, lastResult, isPending, error };
|
|
331
331
|
}
|
|
332
|
+
|
|
333
|
+
// src/useEntityStatus.ts
|
|
334
|
+
import { useState as useState8, useEffect as useEffect2 } from "react";
|
|
335
|
+
function useEntityStatus(entityId) {
|
|
336
|
+
const wiki = useWiki();
|
|
337
|
+
const [snapshot, setSnapshot] = useState8(() => ({
|
|
338
|
+
wiki,
|
|
339
|
+
entityId,
|
|
340
|
+
status: wiki.getEntityStatus(entityId)
|
|
341
|
+
}));
|
|
342
|
+
useEffect2(() => {
|
|
343
|
+
setSnapshot({ wiki, entityId, status: wiki.getEntityStatus(entityId) });
|
|
344
|
+
return wiki.subscribeEntityStatus(entityId, (status) => {
|
|
345
|
+
setSnapshot({ wiki, entityId, status });
|
|
346
|
+
});
|
|
347
|
+
}, [wiki, entityId]);
|
|
348
|
+
return snapshot.wiki === wiki && snapshot.entityId === entityId ? snapshot.status : wiki.getEntityStatus(entityId);
|
|
349
|
+
}
|
|
332
350
|
export {
|
|
333
351
|
WikiProvider,
|
|
352
|
+
useEntityStatus,
|
|
334
353
|
useMemoryRead,
|
|
335
354
|
useWiki,
|
|
336
355
|
useWikiExport,
|
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"],"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';\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"],"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,IAC9B,OAAO;AACL,iBAAW,iBAAiB,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,cAAc,CAAC;AAAA,IACzE;AAAA,EACF;AAKA,MAAI,KAAK,iBAAi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AI;AACb,iBAAa,IAAI;AACjB,kBAAc,IAAI;AAClB,QAAI;AACF,YAAM,SAAS,MAAM,QAAQ,QAAQ,WAAW,SAAS;AACzD,oBAAc,MAAM;AACpB,aAAO;AAAA,IACT,SAAS,GAAG;AACV,YAAM,MAAM,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,CAAC,CAAC;AACxD,eAAS,GAAG;AACZ,YAAM;AAAA,IACR,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO,EAAE,SAAS,YAAY,WAAW,MAAM;AACjD;;;AC/BA,SAAS,YAAAC,WAAU,eAAAC,cAAa,UAAAC,eAAc;AAGvC,SAAS,oBAAoB;AAClC,QAAM,OAAO,QAAQ;AACrB,QAAM,UAAUC,QAAO,IAAI;AAC3B,UAAQ,UAAU;AAElB,QAAM,CAAC,WAAW,YAAY,IAAIC,UAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAIA,UAAuB,IAAI;AACrD,QAAM,CAAC,YAAY,aAAa,IAAIA,UAAyB,IAAI;AAEjE,QAAM,UAAUC;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;","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"]}
|
|
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,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Y,aAAa,IAAIA,UAAyB,IAAI;AAEjE,QAAM,UAAUC;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,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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equationalapplications/react-llm-wiki",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.14.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.14.0"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=20"
|