@exellix/memorix-narrix-adapter
v2.0.0
Published
Memorix-to-Narrix adapter: converts Memorix database payloads into Narrix run inputs (record/text/docs/chat) with interpretable metadata.
Maintainers
Readme
@exellix/memorix-narrix-adapter
Memorix-to-Narrix adapter: converts Memorix database payloads into Narrix run inputs (record / text / docs / chat) with interpretable metadata.
- Layer: Adapter (bridge between Memorix entity/event/knowledge memory and Narrix SDK).
- Ecosystem: Exellix Memorix + Narrix.
- Capability: Interprets arbitrary
memorixpayloads and produces a singleNarrixRunInputplus interpretation (kind, strategy, confidence).
Uses @x12i/memorix-retrieval and @x12i/memorix-descriptors for Memorix content objects and record identity on the entity / event / knowledge databases.
Installation
npm install @exellix/memorix-narrix-adapterClone (source)
git clone [email protected]:exellix/memorix-narrix-adapter.git
cd memorix-narrix-adapterQuick start
import { adaptMemorixToNarrixInput } from "@exellix/memorix-narrix-adapter";
const result = adaptMemorixToNarrixInput({
datasetId: "my-dataset",
memorix: {
entityMemory: { currentRecord: { entityId: "ent-123", orderId: "123" } },
eventMemory: { input: { sourceMeta: { jobId: "j1" } } }
}
});
if (result.ok) {
console.log(result.narrixInput.medium); // "record"
console.log(result.interpretation.kind); // "record"
console.log(result.interpretation.confidence); // "guessed" | "hinted" | "exact"
} else {
console.log(result.error, result.message, result.attempted);
}Public API
Functions and class
| Export | Description |
|--------|-------------|
| adaptMemorixToNarrixInput(input, config?) | One-shot adaptation: builds an adapter and returns MemorixNarrixAdapterResult. |
| MemorixNarrixAdapter | Class that holds config and exposes adapt(input). Use when you need to reuse one instance. |
| defaultAdapterConfig | Default config object; merge or override for custom behavior. |
Deprecated aliases (adaptMemoryToNarrixInput, MemoryNarrixAdapter, MemoryNarrixAdapterInput, etc.) remain exported for migration.
Types (exported)
- Input:
MemorixNarrixAdapterInput—{ datasetId: string; mediumHint?: "record" \| "text" \| "docs" \| "chat"; memorix: unknown }. - Result:
MemorixNarrixAdapterResult=MemorixNarrixAdapterSuccess | MemorixNarrixAdapterFailure. - Success:
ok: true,narrixInput: NarrixRunInput,interpretation, optionaldebug. - Failure:
ok: false,error,message,attempted,foundSummary,interpretation. - Narrix run inputs:
NarrixRunInput=NarrixRecordInput | NarrixTextInput | NarrixDocsInput | NarrixChatInput(each hasmediumanddatasetId). - Config:
MemorixNarrixAdapterConfig— optional overrides forwalker,record,sourceMeta,text,summary,debug.
How it works
Memorix database memory tiers
Default record and sourceMeta paths align with Memorix databases:
| Tier | Database (default) | Typical paths |
|------|-------------------|---------------|
| entity | memorix-entities | entityMemory.currentRecord, entityMemory.sourceMeta |
| event | memorix-events | eventMemory.input.record, eventMemory.input.sourceMeta |
| knowledge | memorix-knowledge | knowledgeMemory.currentRecord, knowledgeMemory.sourceMeta |
Strategy pipeline
The adapter runs a fixed list of strategies in order. The first strategy that returns a match produces the result.
- detect-existing-narrix-input — If
memorixis already a validNarrixRunInput, pass it through. Confidence:exact. - legacy-normalization — Legacy shapes without
medium(record,text,pages,messages). - record-from-memorix — Walk the payload and pick record-like objects on configured
record.preferPaths. UsesresolveMemorixRecordIdentitywhen the path is under a Memorix tier. - chat-from-memorix —
thread.messagesor rootmessages. - docs-from-memorix —
document.pages, rootpages, or string arrays. - text-from-memorix — Plain string,
.text, memorix-content-object (contentKey+previewvia@x12i/memorix-retrieval), or JSON serialization fallback.
If no strategy matches, returns error: "NO_USABLE_INPUT" with attempted and foundSummary.
Medium hint
mediumHint reorders the pipeline so strategies for that medium run first (it does not force a medium).
Build and test
npm run build
npm run test
npm run test:watchPublishing
npm run build
npm run test
npm publishSet repository in package.json to your Git repo (default: https://github.com/exellix/memorix-narrix-adapter).
To point the Git remote at SSH:
git remote set-url origin [email protected]:exellix/memorix-narrix-adapter.gitLicense
ISC.
