agentfootprint 8.6.0 → 8.8.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/AGENTS.md +12 -4
- package/CLAUDE.md +4 -2
- package/README.md +1 -1
- package/ai-instructions/claude-code/SKILL.md +1 -1
- package/ai-instructions/setup.sh +0 -0
- package/bin/agentfootprint-lint-tools.mjs +0 -0
- package/dist/core/agent/AgentBuilder.js +104 -0
- package/dist/core/agent/AgentBuilder.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +12 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +12 -1
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/memoryRecallInjections.js +100 -10
- package/dist/core/agent/memoryRecallInjections.js.map +1 -1
- package/dist/core/agent/stages/deliver.js.map +1 -1
- package/dist/core/slots/buildSystemPromptSlot.js +10 -0
- package/dist/core/slots/buildSystemPromptSlot.js.map +1 -1
- package/dist/core/slots/buildToolsSlot.js +77 -0
- package/dist/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/core/slots/helpers.js +12 -10
- package/dist/core/slots/helpers.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.js +104 -0
- package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
- package/dist/esm/core/agent/buildAgentChart.js +13 -2
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js +13 -2
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/memoryRecallInjections.d.ts +13 -3
- package/dist/esm/core/agent/memoryRecallInjections.js +101 -11
- package/dist/esm/core/agent/memoryRecallInjections.js.map +1 -1
- package/dist/esm/core/agent/stages/deliver.d.ts +6 -3
- package/dist/esm/core/agent/stages/deliver.js.map +1 -1
- package/dist/esm/core/slots/buildSystemPromptSlot.js +10 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.js.map +1 -1
- package/dist/esm/core/slots/buildToolsSlot.js +78 -1
- package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/esm/core/slots/helpers.d.ts +11 -2
- package/dist/esm/core/slots/helpers.js +11 -9
- package/dist/esm/core/slots/helpers.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +92 -0
- package/dist/esm/events/registry.d.ts +5 -1
- package/dist/esm/events/registry.js +4 -0
- package/dist/esm/events/registry.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +6 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/fnv1a.d.ts +16 -0
- package/dist/esm/lib/fnv1a.js +24 -0
- package/dist/esm/lib/fnv1a.js.map +1 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +15 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.js +16 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.js.map +1 -1
- package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +9 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.js.map +1 -1
- package/dist/esm/lib/injection-engine/index.d.ts +3 -3
- package/dist/esm/lib/injection-engine/index.js +8 -3
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillContract.d.ts +25 -2
- package/dist/esm/lib/injection-engine/skillContract.js +11 -4
- package/dist/esm/lib/injection-engine/skillContract.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraph.d.ts +65 -4
- package/dist/esm/lib/injection-engine/skillGraph.js +36 -11
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +47 -7
- package/dist/esm/lib/injection-engine/skillGraphCheckup.js +165 -13
- package/dist/esm/lib/injection-engine/skillGraphCheckup.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillsFromDir.d.ts +24 -0
- package/dist/esm/lib/injection-engine/skillsFromDir.js +19 -0
- package/dist/esm/lib/injection-engine/skillsFromDir.js.map +1 -1
- package/dist/esm/lib/injection-engine/types.d.ts +25 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/rag/defineRAG.d.ts +126 -26
- package/dist/esm/lib/rag/defineRAG.js +112 -25
- package/dist/esm/lib/rag/defineRAG.js.map +1 -1
- package/dist/esm/lib/rag/index.d.ts +1 -1
- package/dist/esm/lib/rag/index.js +1 -1
- package/dist/esm/lib/rag/index.js.map +1 -1
- package/dist/esm/memory/define.js +38 -2
- package/dist/esm/memory/define.js.map +1 -1
- package/dist/esm/memory/define.types.d.ts +93 -1
- package/dist/esm/memory/define.types.js +18 -0
- package/dist/esm/memory/define.types.js.map +1 -1
- package/dist/esm/memory/embedding/loadRelevant.d.ts +49 -15
- package/dist/esm/memory/embedding/loadRelevant.js +136 -7
- package/dist/esm/memory/embedding/loadRelevant.js.map +1 -1
- package/dist/esm/memory/index.d.ts +2 -1
- package/dist/esm/memory/index.js +2 -1
- package/dist/esm/memory/index.js.map +1 -1
- package/dist/esm/memory/pipeline/semantic.d.ts +15 -0
- package/dist/esm/memory/pipeline/semantic.js +3 -1
- package/dist/esm/memory/pipeline/semantic.js.map +1 -1
- package/dist/esm/memory/retrieval/index.d.ts +10 -0
- package/dist/esm/memory/retrieval/index.js +3 -0
- package/dist/esm/memory/retrieval/index.js.map +1 -0
- package/dist/esm/memory/retrieval/provenance.d.ts +43 -0
- package/dist/esm/memory/retrieval/provenance.js +60 -0
- package/dist/esm/memory/retrieval/provenance.js.map +1 -0
- package/dist/esm/memory/retrieval/topK.d.ts +67 -0
- package/dist/esm/memory/retrieval/topK.js +53 -0
- package/dist/esm/memory/retrieval/topK.js.map +1 -0
- package/dist/esm/memory/retrieval/types.d.ts +189 -0
- package/dist/esm/memory/retrieval/types.js +2 -0
- package/dist/esm/memory/retrieval/types.js.map +1 -0
- package/dist/esm/memory/stages/formatDefault.d.ts +52 -26
- package/dist/esm/memory/stages/formatDefault.js +118 -28
- package/dist/esm/memory/stages/formatDefault.js.map +1 -1
- package/dist/esm/memory/stages/pickByBudget.js +53 -3
- package/dist/esm/memory/stages/pickByBudget.js.map +1 -1
- package/dist/esm/memory/stages/types.d.ts +15 -0
- package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +25 -0
- package/dist/esm/memory/wire/mountMemoryPipeline.js +11 -2
- package/dist/esm/memory/wire/mountMemoryPipeline.js.map +1 -1
- package/dist/esm/tool-providers/index.d.ts +1 -1
- package/dist/esm/tool-providers/index.js +4 -1
- package/dist/esm/tool-providers/index.js.map +1 -1
- package/dist/esm/tool-providers/skillScopedTools.d.ts +4 -0
- package/dist/esm/tool-providers/skillScopedTools.js +33 -2
- package/dist/esm/tool-providers/skillScopedTools.js.map +1 -1
- package/dist/esm/tool-providers/types.d.ts +25 -0
- package/dist/events/registry.js +4 -0
- package/dist/events/registry.js.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/fnv1a.js +28 -0
- package/dist/lib/fnv1a.js.map +1 -0
- package/dist/lib/injection-engine/factories/defineRelevanceHint.js +17 -1
- package/dist/lib/injection-engine/factories/defineRelevanceHint.js.map +1 -1
- package/dist/lib/injection-engine/factories/defineSkill.js.map +1 -1
- package/dist/lib/injection-engine/index.js +7 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillContract.js +11 -4
- package/dist/lib/injection-engine/skillContract.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +37 -11
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/skillGraphCheckup.js +165 -13
- package/dist/lib/injection-engine/skillGraphCheckup.js.map +1 -1
- package/dist/lib/injection-engine/skillsFromDir.js +19 -0
- package/dist/lib/injection-engine/skillsFromDir.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/lib/rag/defineRAG.js +113 -26
- package/dist/lib/rag/defineRAG.js.map +1 -1
- package/dist/lib/rag/index.js +2 -1
- package/dist/lib/rag/index.js.map +1 -1
- package/dist/memory/define.js +38 -2
- package/dist/memory/define.js.map +1 -1
- package/dist/memory/define.types.js +21 -1
- package/dist/memory/define.types.js.map +1 -1
- package/dist/memory/embedding/loadRelevant.js +138 -8
- package/dist/memory/embedding/loadRelevant.js.map +1 -1
- package/dist/memory/index.js +5 -1
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/pipeline/semantic.js +2 -0
- package/dist/memory/pipeline/semantic.js.map +1 -1
- package/dist/memory/retrieval/index.js +9 -0
- package/dist/memory/retrieval/index.js.map +1 -0
- package/dist/memory/retrieval/provenance.js +65 -0
- package/dist/memory/retrieval/provenance.js.map +1 -0
- package/dist/memory/retrieval/topK.js +57 -0
- package/dist/memory/retrieval/topK.js.map +1 -0
- package/dist/memory/retrieval/types.js +3 -0
- package/dist/memory/retrieval/types.js.map +1 -0
- package/dist/memory/stages/formatDefault.js +118 -28
- package/dist/memory/stages/formatDefault.js.map +1 -1
- package/dist/memory/stages/pickByBudget.js +53 -3
- package/dist/memory/stages/pickByBudget.js.map +1 -1
- package/dist/memory/wire/mountMemoryPipeline.js +11 -2
- package/dist/memory/wire/mountMemoryPipeline.js.map +1 -1
- package/dist/tool-providers/index.js +5 -1
- package/dist/tool-providers/index.js.map +1 -1
- package/dist/tool-providers/skillScopedTools.js +35 -3
- package/dist/tool-providers/skillScopedTools.js.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/memoryRecallInjections.d.ts +13 -3
- package/dist/types/core/agent/memoryRecallInjections.d.ts.map +1 -1
- package/dist/types/core/agent/stages/deliver.d.ts +6 -3
- package/dist/types/core/agent/stages/deliver.d.ts.map +1 -1
- package/dist/types/core/slots/buildSystemPromptSlot.d.ts.map +1 -1
- package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
- package/dist/types/core/slots/helpers.d.ts +11 -2
- package/dist/types/core/slots/helpers.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +92 -0
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/registry.d.ts +5 -1
- package/dist/types/events/registry.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/fnv1a.d.ts +17 -0
- package/dist/types/lib/fnv1a.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/factories/defineRelevanceHint.d.ts +15 -0
- package/dist/types/lib/injection-engine/factories/defineRelevanceHint.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/factories/defineSkill.d.ts +9 -0
- package/dist/types/lib/injection-engine/factories/defineSkill.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/index.d.ts +3 -3
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillContract.d.ts +25 -2
- package/dist/types/lib/injection-engine/skillContract.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +65 -4
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraphCheckup.d.ts +47 -7
- package/dist/types/lib/injection-engine/skillGraphCheckup.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillsFromDir.d.ts +24 -0
- package/dist/types/lib/injection-engine/skillsFromDir.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +25 -0
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/lib/rag/defineRAG.d.ts +126 -26
- package/dist/types/lib/rag/defineRAG.d.ts.map +1 -1
- package/dist/types/lib/rag/index.d.ts +1 -1
- package/dist/types/lib/rag/index.d.ts.map +1 -1
- package/dist/types/memory/define.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +93 -1
- package/dist/types/memory/define.types.d.ts.map +1 -1
- package/dist/types/memory/embedding/loadRelevant.d.ts +49 -15
- package/dist/types/memory/embedding/loadRelevant.d.ts.map +1 -1
- package/dist/types/memory/index.d.ts +2 -1
- package/dist/types/memory/index.d.ts.map +1 -1
- package/dist/types/memory/pipeline/semantic.d.ts +15 -0
- package/dist/types/memory/pipeline/semantic.d.ts.map +1 -1
- package/dist/types/memory/retrieval/index.d.ts +11 -0
- package/dist/types/memory/retrieval/index.d.ts.map +1 -0
- package/dist/types/memory/retrieval/provenance.d.ts +44 -0
- package/dist/types/memory/retrieval/provenance.d.ts.map +1 -0
- package/dist/types/memory/retrieval/topK.d.ts +68 -0
- package/dist/types/memory/retrieval/topK.d.ts.map +1 -0
- package/dist/types/memory/retrieval/types.d.ts +190 -0
- package/dist/types/memory/retrieval/types.d.ts.map +1 -0
- package/dist/types/memory/stages/formatDefault.d.ts +52 -26
- package/dist/types/memory/stages/formatDefault.d.ts.map +1 -1
- package/dist/types/memory/stages/pickByBudget.d.ts.map +1 -1
- package/dist/types/memory/stages/types.d.ts +15 -0
- package/dist/types/memory/stages/types.d.ts.map +1 -1
- package/dist/types/memory/wire/mountMemoryPipeline.d.ts +25 -0
- package/dist/types/memory/wire/mountMemoryPipeline.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +1 -1
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/dist/types/tool-providers/skillScopedTools.d.ts +4 -0
- package/dist/types/tool-providers/skillScopedTools.d.ts.map +1 -1
- package/dist/types/tool-providers/types.d.ts +25 -0
- package/dist/types/tool-providers/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,23 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* defineRAG —
|
|
2
|
+
* defineRAG — retrieval-augmented generation over a document corpus.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* strategy: TOP_K })` — the rename is for intent + ergonomics.
|
|
4
|
+
* Embed the user's question, retrieve the most similar chunks from a
|
|
5
|
+
* vector store, inject them into the system-prompt slot of the next LLM
|
|
6
|
+
* call. It is the same machinery as `defineMemory({ type: SEMANTIC,
|
|
7
|
+
* strategy: TOP_K })` — with three differences that are not cosmetic:
|
|
9
8
|
*
|
|
10
9
|
* defineMemory ─┬─► EPISODIC (raw conversation)
|
|
11
10
|
* ├─► SEMANTIC (extracted facts / RAG chunks)
|
|
12
11
|
* ├─► NARRATIVE (beats / summaries)
|
|
13
12
|
* └─► CAUSAL (footprintjs decision snapshots)
|
|
14
13
|
*
|
|
15
|
-
* defineRAG ─► SEMANTIC + TOP_K
|
|
16
|
-
*
|
|
14
|
+
* defineRAG ─► SEMANTIC + TOP_K, READ-ONLY, over a NAMED CORPUS,
|
|
15
|
+
* rendered as citable <source> blocks.
|
|
16
|
+
*
|
|
17
|
+
* ─── What changed in 8.8.0, and why ────────────────────────────────────
|
|
18
|
+
*
|
|
19
|
+
* **1. A corpus is read-only.** Until 8.8.0 `defineRAG` also mounted the
|
|
20
|
+
* semantic pipeline's WRITE half, which embedded every conversation turn
|
|
21
|
+
* and stored it in the same namespace as the documents. The consequence
|
|
22
|
+
* was measurable and bad: the user's own question, re-embedded, is the
|
|
23
|
+
* single best-scoring "document" in the corpus (cosine 1.0 against
|
|
24
|
+
* itself), so it came back as retrieval hit #1 and consumed a slot in
|
|
25
|
+
* the top-K budget that a real passage should have had. A corpus is not
|
|
26
|
+
* a conversation log. Nothing this retriever reads is written back.
|
|
27
|
+
*
|
|
28
|
+
* If you want conversation memory ALONGSIDE a corpus, that is what
|
|
29
|
+
* `defineMemory` is for, and the two are registered separately, each
|
|
30
|
+
* with its own store:
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* const agent = Agent.create({ provider })
|
|
34
|
+
* .rag(defineRAG({ id: 'product-docs', store: corpusStore, embedder }))
|
|
35
|
+
* .memory(defineMemory({
|
|
36
|
+
* id: 'chat',
|
|
37
|
+
* type: MEMORY_TYPES.EPISODIC,
|
|
38
|
+
* strategy: { kind: MEMORY_STRATEGIES.WINDOW, size: 10 },
|
|
39
|
+
* store: conversationStore,
|
|
40
|
+
* }))
|
|
41
|
+
* .build();
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* **2. The corpus has its own namespace.** A memory reads under the
|
|
45
|
+
* identity passed to `agent.run()`. For conversation recall that is
|
|
46
|
+
* right. For a shared corpus it was the reason the documented example
|
|
47
|
+
* retrieved NOTHING: `indexDocuments` writes under
|
|
48
|
+
* `{ conversationId: '_global' }` by default, while a run with no
|
|
49
|
+
* explicit identity gets `{ conversationId: 'run-<timestamp>-<n>' }` —
|
|
50
|
+
* so the write side and the read side never met, silently. `corpus`
|
|
51
|
+
* defaults to the same `'_global'` the indexer uses, so the documented
|
|
52
|
+
* example works with no extra arguments; pass it explicitly when you
|
|
53
|
+
* index per tenant.
|
|
54
|
+
*
|
|
55
|
+
* **3. Chunks are citable.** Retrieved passages render as
|
|
56
|
+
* `<source id="refunds.md#3" doc="refunds.md" score="0.81">` under a
|
|
57
|
+
* corpus header, instead of the conversation-recall shape that printed
|
|
58
|
+
* `role="unknown" turn="0"` on a page of a PDF and gave the model
|
|
59
|
+
* nothing to cite.
|
|
17
60
|
*
|
|
18
61
|
* Pattern: Composition over duplication — defineRAG returns a
|
|
19
62
|
* MemoryDefinition produced by defineMemory. No new engine
|
|
20
|
-
* code, no new slot subflow, no new
|
|
63
|
+
* code, no new slot subflow, no new stage.
|
|
21
64
|
*
|
|
22
65
|
* Role: Layer-3 context-engineering primitive. Lives next to
|
|
23
66
|
* defineSkill / defineSteering / defineInstruction / defineFact
|
|
@@ -25,27 +68,32 @@
|
|
|
25
68
|
* (RAG content is computed at runtime via async retrieval —
|
|
26
69
|
* can't fit the synchronous Injection.inject shape).
|
|
27
70
|
*
|
|
28
|
-
* Emits:
|
|
29
|
-
*
|
|
30
|
-
*
|
|
71
|
+
* Emits: `agentfootprint.memory.retrieved` (once per retrieval, with
|
|
72
|
+
* every candidate and its score — including the rejected ones),
|
|
73
|
+
* `agentfootprint.memory.attached` (once per chunk that reached
|
|
74
|
+
* the prompt), and `agentfootprint.context.injected` with
|
|
75
|
+
* `source: 'rag'` (once per chunk).
|
|
31
76
|
*
|
|
32
77
|
* @see ./indexDocuments.ts for the seeding helper
|
|
33
78
|
* @see ../../memory/define.ts for the underlying factory
|
|
79
|
+
* @see ../../memory/retrieval/ for the retrieval seam
|
|
34
80
|
* @see ../../memory/asRoleRefusal.ts for why `asRole` is refused, not honoured
|
|
35
81
|
*
|
|
36
|
-
* @example Basic usage
|
|
82
|
+
* @example Basic usage — works with no identity argument anywhere
|
|
37
83
|
* ```ts
|
|
38
|
-
* import {
|
|
39
|
-
import { InMemoryStore, mockEmbedder } from 'agentfootprint/memory'
|
|
40
|
-
import { mock } from 'agentfootprint/
|
|
84
|
+
* import { Agent, defineRAG, indexDocuments } from 'agentfootprint';
|
|
85
|
+
* import { InMemoryStore, mockEmbedder } from 'agentfootprint/memory';
|
|
86
|
+
* import { mock } from 'agentfootprint/providers';
|
|
41
87
|
*
|
|
42
88
|
* const embedder = mockEmbedder();
|
|
43
89
|
* const store = new InMemoryStore();
|
|
44
90
|
*
|
|
45
|
-
* // Seed the
|
|
91
|
+
* // Seed the corpus once at startup (defaults to the '_global' namespace).
|
|
46
92
|
* await indexDocuments(store, embedder, [
|
|
47
|
-
* { id: '
|
|
48
|
-
*
|
|
93
|
+
* { id: 'refunds.md#0', content: 'Refunds are processed within 3 business days.',
|
|
94
|
+
* metadata: { source: 'refunds.md' } },
|
|
95
|
+
* { id: 'pricing.md#0', content: 'Pro plan costs $20/month.',
|
|
96
|
+
* metadata: { source: 'pricing.md' } },
|
|
49
97
|
* ]);
|
|
50
98
|
*
|
|
51
99
|
* const docs = defineRAG({
|
|
@@ -60,11 +108,27 @@ import { mock } from 'agentfootprint/llm-providers';
|
|
|
60
108
|
* const agent = Agent.create({ provider: mock({ reply: 'ok' }), model: 'mock' })
|
|
61
109
|
* .rag(docs)
|
|
62
110
|
* .build();
|
|
111
|
+
*
|
|
112
|
+
* agent.on('agentfootprint.memory.retrieved', (e) => {
|
|
113
|
+
* // every candidate, admitted or not, with its score and its reason
|
|
114
|
+
* console.log(e.payload.candidates);
|
|
115
|
+
* });
|
|
116
|
+
*
|
|
117
|
+
* await agent.run({ message: 'How long do refunds take?' });
|
|
63
118
|
* ```
|
|
64
119
|
*/
|
|
65
120
|
import type { Embedder } from '../../memory/embedding/index.js';
|
|
66
121
|
import type { MemoryStore } from '../../memory/store/index.js';
|
|
122
|
+
import type { MemoryIdentity } from '../../memory/identity/index.js';
|
|
67
123
|
import type { MemoryDefinition } from '../../memory/define.types.js';
|
|
124
|
+
import type { RetrievalStrategy } from '../../memory/retrieval/index.js';
|
|
125
|
+
/**
|
|
126
|
+
* The namespace a corpus lives in unless told otherwise — the same one
|
|
127
|
+
* `indexDocuments` writes to by default. The two defaults are one value
|
|
128
|
+
* on purpose: index with no options, retrieve with no options, and the
|
|
129
|
+
* documents are found.
|
|
130
|
+
*/
|
|
131
|
+
export declare const DEFAULT_CORPUS_IDENTITY: MemoryIdentity;
|
|
68
132
|
export interface DefineRAGOptions {
|
|
69
133
|
/** Stable id. Becomes the scope-key suffix and the Lens label. */
|
|
70
134
|
readonly id: string;
|
|
@@ -78,13 +142,13 @@ export interface DefineRAGOptions {
|
|
|
78
142
|
* Vector-capable store containing the indexed corpus. Must implement
|
|
79
143
|
* `search()`. Use `indexDocuments(store, embedder, docs)` at startup
|
|
80
144
|
* to populate it. Ships with `InMemoryStore` for dev/tests; swap to
|
|
81
|
-
*
|
|
145
|
+
* a durable adapter in production.
|
|
82
146
|
*/
|
|
83
147
|
readonly store: MemoryStore;
|
|
84
148
|
/**
|
|
85
149
|
* Embedder used for the read-side query. Pass the SAME embedder
|
|
86
|
-
* instance (or one with the same `
|
|
87
|
-
* — cross-model similarity scores are not comparable.
|
|
150
|
+
* instance (or one with the same `embedderId`) that was used for
|
|
151
|
+
* indexing — cross-model similarity scores are not comparable.
|
|
88
152
|
*/
|
|
89
153
|
readonly embedder: Embedder;
|
|
90
154
|
/**
|
|
@@ -93,10 +157,28 @@ export interface DefineRAGOptions {
|
|
|
93
157
|
* embedder swap doesn't pollute results.
|
|
94
158
|
*/
|
|
95
159
|
readonly embedderId?: string;
|
|
160
|
+
/**
|
|
161
|
+
* The namespace this corpus lives in. Default
|
|
162
|
+
* `{ conversationId: '_global' }` — the same default `indexDocuments`
|
|
163
|
+
* writes to, so the plain path needs no argument on either side.
|
|
164
|
+
*
|
|
165
|
+
* A corpus is deliberately NOT scoped to the run's identity: it is
|
|
166
|
+
* shared by every conversation, and reading it under a per-run
|
|
167
|
+
* conversation id is the bug this default fixes.
|
|
168
|
+
*
|
|
169
|
+
* **Multi-tenant:** pass the tenant's identity here AND the same one to
|
|
170
|
+
* `indexDocuments({ identity })`. A namespace that holds nothing is now
|
|
171
|
+
* reported (`corpusEmpty` on `agentfootprint.memory.retrieved`, plus a
|
|
172
|
+
* one-time warning naming the namespace), so a mismatch is loud rather
|
|
173
|
+
* than an empty answer.
|
|
174
|
+
*/
|
|
175
|
+
readonly corpus?: MemoryIdentity;
|
|
96
176
|
/**
|
|
97
177
|
* Top-K chunks to retrieve per turn. Default 3 (balanced —
|
|
98
178
|
* defends against lost-in-the-middle while giving multiple
|
|
99
179
|
* perspectives). Increase for richer context, decrease for cost.
|
|
180
|
+
*
|
|
181
|
+
* Shorthand for `retrieval: topK({ k })`; the two EXCLUDE.
|
|
100
182
|
*/
|
|
101
183
|
readonly topK?: number;
|
|
102
184
|
/**
|
|
@@ -106,12 +188,29 @@ export interface DefineRAGOptions {
|
|
|
106
188
|
*
|
|
107
189
|
* Tuning note: 0.7 is a high bar for some embedders. Sentence-BERT
|
|
108
190
|
* relatives (`all-MiniLM-L6-v2`, etc.) often score 0.4–0.6 even on
|
|
109
|
-
* relevant chunks.
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
191
|
+
* relevant chunks. You no longer have to guess: the rejected
|
|
192
|
+
* candidates and their scores are on every
|
|
193
|
+
* `agentfootprint.memory.retrieved` event, so the right threshold is
|
|
194
|
+
* a number you can read off a run.
|
|
195
|
+
*
|
|
196
|
+
* Shorthand for `retrieval: topK({ threshold })`; the two EXCLUDE.
|
|
113
197
|
*/
|
|
114
198
|
readonly threshold?: number;
|
|
199
|
+
/**
|
|
200
|
+
* The retrieval rule, spelled out. Replaces `topK` + `threshold`
|
|
201
|
+
* entirely — passing both is refused, because they could disagree
|
|
202
|
+
* and the recording would then name a `k` the run did not use.
|
|
203
|
+
*
|
|
204
|
+
* ```ts
|
|
205
|
+
* import { topK } from 'agentfootprint/memory';
|
|
206
|
+
* defineRAG({ id, store, embedder, retrieval: topK({ k: 5, threshold: 0.55 }) });
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* A cross-encoder re-ranker and a diversity (MMR) selector are the
|
|
210
|
+
* next two adapters behind this same interface; neither ships in
|
|
211
|
+
* 8.8.0, and the seam exists so that when they do, nothing else moves.
|
|
212
|
+
*/
|
|
213
|
+
readonly retrieval?: RetrievalStrategy;
|
|
115
214
|
}
|
|
116
215
|
/**
|
|
117
216
|
* Build a RAG context-engineering definition. The returned
|
|
@@ -120,5 +219,6 @@ export interface DefineRAGOptions {
|
|
|
120
219
|
*
|
|
121
220
|
* @throws when `store` does not implement `search()`. RAG requires a
|
|
122
221
|
* vector-capable adapter.
|
|
222
|
+
* @throws when `retrieval` is combined with `topK` or `threshold`.
|
|
123
223
|
*/
|
|
124
224
|
export declare function defineRAG(opts: DefineRAGOptions): MemoryDefinition;
|
|
@@ -1,23 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* defineRAG —
|
|
2
|
+
* defineRAG — retrieval-augmented generation over a document corpus.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* strategy: TOP_K })` — the rename is for intent + ergonomics.
|
|
4
|
+
* Embed the user's question, retrieve the most similar chunks from a
|
|
5
|
+
* vector store, inject them into the system-prompt slot of the next LLM
|
|
6
|
+
* call. It is the same machinery as `defineMemory({ type: SEMANTIC,
|
|
7
|
+
* strategy: TOP_K })` — with three differences that are not cosmetic:
|
|
9
8
|
*
|
|
10
9
|
* defineMemory ─┬─► EPISODIC (raw conversation)
|
|
11
10
|
* ├─► SEMANTIC (extracted facts / RAG chunks)
|
|
12
11
|
* ├─► NARRATIVE (beats / summaries)
|
|
13
12
|
* └─► CAUSAL (footprintjs decision snapshots)
|
|
14
13
|
*
|
|
15
|
-
* defineRAG ─► SEMANTIC + TOP_K
|
|
16
|
-
*
|
|
14
|
+
* defineRAG ─► SEMANTIC + TOP_K, READ-ONLY, over a NAMED CORPUS,
|
|
15
|
+
* rendered as citable <source> blocks.
|
|
16
|
+
*
|
|
17
|
+
* ─── What changed in 8.8.0, and why ────────────────────────────────────
|
|
18
|
+
*
|
|
19
|
+
* **1. A corpus is read-only.** Until 8.8.0 `defineRAG` also mounted the
|
|
20
|
+
* semantic pipeline's WRITE half, which embedded every conversation turn
|
|
21
|
+
* and stored it in the same namespace as the documents. The consequence
|
|
22
|
+
* was measurable and bad: the user's own question, re-embedded, is the
|
|
23
|
+
* single best-scoring "document" in the corpus (cosine 1.0 against
|
|
24
|
+
* itself), so it came back as retrieval hit #1 and consumed a slot in
|
|
25
|
+
* the top-K budget that a real passage should have had. A corpus is not
|
|
26
|
+
* a conversation log. Nothing this retriever reads is written back.
|
|
27
|
+
*
|
|
28
|
+
* If you want conversation memory ALONGSIDE a corpus, that is what
|
|
29
|
+
* `defineMemory` is for, and the two are registered separately, each
|
|
30
|
+
* with its own store:
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* const agent = Agent.create({ provider })
|
|
34
|
+
* .rag(defineRAG({ id: 'product-docs', store: corpusStore, embedder }))
|
|
35
|
+
* .memory(defineMemory({
|
|
36
|
+
* id: 'chat',
|
|
37
|
+
* type: MEMORY_TYPES.EPISODIC,
|
|
38
|
+
* strategy: { kind: MEMORY_STRATEGIES.WINDOW, size: 10 },
|
|
39
|
+
* store: conversationStore,
|
|
40
|
+
* }))
|
|
41
|
+
* .build();
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* **2. The corpus has its own namespace.** A memory reads under the
|
|
45
|
+
* identity passed to `agent.run()`. For conversation recall that is
|
|
46
|
+
* right. For a shared corpus it was the reason the documented example
|
|
47
|
+
* retrieved NOTHING: `indexDocuments` writes under
|
|
48
|
+
* `{ conversationId: '_global' }` by default, while a run with no
|
|
49
|
+
* explicit identity gets `{ conversationId: 'run-<timestamp>-<n>' }` —
|
|
50
|
+
* so the write side and the read side never met, silently. `corpus`
|
|
51
|
+
* defaults to the same `'_global'` the indexer uses, so the documented
|
|
52
|
+
* example works with no extra arguments; pass it explicitly when you
|
|
53
|
+
* index per tenant.
|
|
54
|
+
*
|
|
55
|
+
* **3. Chunks are citable.** Retrieved passages render as
|
|
56
|
+
* `<source id="refunds.md#3" doc="refunds.md" score="0.81">` under a
|
|
57
|
+
* corpus header, instead of the conversation-recall shape that printed
|
|
58
|
+
* `role="unknown" turn="0"` on a page of a PDF and gave the model
|
|
59
|
+
* nothing to cite.
|
|
17
60
|
*
|
|
18
61
|
* Pattern: Composition over duplication — defineRAG returns a
|
|
19
62
|
* MemoryDefinition produced by defineMemory. No new engine
|
|
20
|
-
* code, no new slot subflow, no new
|
|
63
|
+
* code, no new slot subflow, no new stage.
|
|
21
64
|
*
|
|
22
65
|
* Role: Layer-3 context-engineering primitive. Lives next to
|
|
23
66
|
* defineSkill / defineSteering / defineInstruction / defineFact
|
|
@@ -25,27 +68,32 @@
|
|
|
25
68
|
* (RAG content is computed at runtime via async retrieval —
|
|
26
69
|
* can't fit the synchronous Injection.inject shape).
|
|
27
70
|
*
|
|
28
|
-
* Emits:
|
|
29
|
-
*
|
|
30
|
-
*
|
|
71
|
+
* Emits: `agentfootprint.memory.retrieved` (once per retrieval, with
|
|
72
|
+
* every candidate and its score — including the rejected ones),
|
|
73
|
+
* `agentfootprint.memory.attached` (once per chunk that reached
|
|
74
|
+
* the prompt), and `agentfootprint.context.injected` with
|
|
75
|
+
* `source: 'rag'` (once per chunk).
|
|
31
76
|
*
|
|
32
77
|
* @see ./indexDocuments.ts for the seeding helper
|
|
33
78
|
* @see ../../memory/define.ts for the underlying factory
|
|
79
|
+
* @see ../../memory/retrieval/ for the retrieval seam
|
|
34
80
|
* @see ../../memory/asRoleRefusal.ts for why `asRole` is refused, not honoured
|
|
35
81
|
*
|
|
36
|
-
* @example Basic usage
|
|
82
|
+
* @example Basic usage — works with no identity argument anywhere
|
|
37
83
|
* ```ts
|
|
38
|
-
* import {
|
|
39
|
-
import { InMemoryStore, mockEmbedder } from 'agentfootprint/memory'
|
|
40
|
-
import { mock } from 'agentfootprint/
|
|
84
|
+
* import { Agent, defineRAG, indexDocuments } from 'agentfootprint';
|
|
85
|
+
* import { InMemoryStore, mockEmbedder } from 'agentfootprint/memory';
|
|
86
|
+
* import { mock } from 'agentfootprint/providers';
|
|
41
87
|
*
|
|
42
88
|
* const embedder = mockEmbedder();
|
|
43
89
|
* const store = new InMemoryStore();
|
|
44
90
|
*
|
|
45
|
-
* // Seed the
|
|
91
|
+
* // Seed the corpus once at startup (defaults to the '_global' namespace).
|
|
46
92
|
* await indexDocuments(store, embedder, [
|
|
47
|
-
* { id: '
|
|
48
|
-
*
|
|
93
|
+
* { id: 'refunds.md#0', content: 'Refunds are processed within 3 business days.',
|
|
94
|
+
* metadata: { source: 'refunds.md' } },
|
|
95
|
+
* { id: 'pricing.md#0', content: 'Pro plan costs $20/month.',
|
|
96
|
+
* metadata: { source: 'pricing.md' } },
|
|
49
97
|
* ]);
|
|
50
98
|
*
|
|
51
99
|
* const docs = defineRAG({
|
|
@@ -60,11 +108,25 @@ import { mock } from 'agentfootprint/llm-providers';
|
|
|
60
108
|
* const agent = Agent.create({ provider: mock({ reply: 'ok' }), model: 'mock' })
|
|
61
109
|
* .rag(docs)
|
|
62
110
|
* .build();
|
|
111
|
+
*
|
|
112
|
+
* agent.on('agentfootprint.memory.retrieved', (e) => {
|
|
113
|
+
* // every candidate, admitted or not, with its score and its reason
|
|
114
|
+
* console.log(e.payload.candidates);
|
|
115
|
+
* });
|
|
116
|
+
*
|
|
117
|
+
* await agent.run({ message: 'How long do refunds take?' });
|
|
63
118
|
* ```
|
|
64
119
|
*/
|
|
65
120
|
import { MEMORY_TYPES, MEMORY_STRATEGIES } from '../../memory/define.types.js';
|
|
66
121
|
import { defineMemory } from '../../memory/define.js';
|
|
67
122
|
import { refuseAsRole } from '../../memory/asRoleRefusal.js';
|
|
123
|
+
/**
|
|
124
|
+
* The namespace a corpus lives in unless told otherwise — the same one
|
|
125
|
+
* `indexDocuments` writes to by default. The two defaults are one value
|
|
126
|
+
* on purpose: index with no options, retrieve with no options, and the
|
|
127
|
+
* documents are found.
|
|
128
|
+
*/
|
|
129
|
+
export const DEFAULT_CORPUS_IDENTITY = { conversationId: '_global' };
|
|
68
130
|
/**
|
|
69
131
|
* Build a RAG context-engineering definition. The returned
|
|
70
132
|
* `MemoryDefinition` is registered on the Agent via `.rag(definition)`
|
|
@@ -72,6 +134,7 @@ import { refuseAsRole } from '../../memory/asRoleRefusal.js';
|
|
|
72
134
|
*
|
|
73
135
|
* @throws when `store` does not implement `search()`. RAG requires a
|
|
74
136
|
* vector-capable adapter.
|
|
137
|
+
* @throws when `retrieval` is combined with `topK` or `threshold`.
|
|
75
138
|
*/
|
|
76
139
|
export function defineRAG(opts) {
|
|
77
140
|
if (!opts.id || opts.id.trim() === '') {
|
|
@@ -91,17 +154,41 @@ export function defineRAG(opts) {
|
|
|
91
154
|
throw new Error(`defineRAG[${opts.id}]: store must implement search(). ` +
|
|
92
155
|
'Pass a vector-capable adapter (InMemoryStore, pgvector, Pinecone, ...).');
|
|
93
156
|
}
|
|
157
|
+
if (opts.retrieval !== undefined) {
|
|
158
|
+
const shorthand = [];
|
|
159
|
+
if (opts.topK !== undefined)
|
|
160
|
+
shorthand.push('`topK`');
|
|
161
|
+
if (opts.threshold !== undefined)
|
|
162
|
+
shorthand.push('`threshold`');
|
|
163
|
+
if (shorthand.length > 0) {
|
|
164
|
+
throw new Error(`defineRAG[${opts.id}]: ${shorthand.join(' and ')} cannot be combined with \`retrieval\` ` +
|
|
165
|
+
'— they are two spellings of the same rule and could disagree. Keep ' +
|
|
166
|
+
`\`retrieval: ${opts.retrieval.name}({ ... })\` and drop ${shorthand.join('/')}.`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
94
169
|
return defineMemory({
|
|
95
170
|
id: opts.id,
|
|
96
171
|
...(opts.description !== undefined && { description: opts.description }),
|
|
97
172
|
type: MEMORY_TYPES.SEMANTIC,
|
|
98
|
-
strategy:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
173
|
+
strategy: opts.retrieval !== undefined
|
|
174
|
+
? {
|
|
175
|
+
kind: MEMORY_STRATEGIES.TOP_K,
|
|
176
|
+
embedder: opts.embedder,
|
|
177
|
+
retrieval: opts.retrieval,
|
|
178
|
+
...(opts.embedderId !== undefined && { embedderId: opts.embedderId }),
|
|
179
|
+
}
|
|
180
|
+
: {
|
|
181
|
+
kind: MEMORY_STRATEGIES.TOP_K,
|
|
182
|
+
topK: opts.topK ?? 3,
|
|
183
|
+
threshold: opts.threshold ?? 0.7,
|
|
184
|
+
embedder: opts.embedder,
|
|
185
|
+
...(opts.embedderId !== undefined && { embedderId: opts.embedderId }),
|
|
186
|
+
},
|
|
104
187
|
store: opts.store,
|
|
188
|
+
// A corpus is not a conversation log — see the header.
|
|
189
|
+
readOnly: true,
|
|
190
|
+
corpus: opts.corpus ?? DEFAULT_CORPUS_IDENTITY,
|
|
191
|
+
flavor: 'rag',
|
|
105
192
|
});
|
|
106
193
|
}
|
|
107
194
|
//# sourceMappingURL=defineRAG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineRAG.js","sourceRoot":"","sources":["../../../../src/lib/rag/defineRAG.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"defineRAG.js","sourceRoot":"","sources":["../../../../src/lib/rag/defineRAG.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsHG;AAOH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAmB,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;AAuGrF;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,IAAsB;IAC9C,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IACD,sEAAsE;IACtE,oEAAoE;IACpE,uDAAuD;IACvD,YAAY,CAAC,IAAI,EAAE,cAAc,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,CAAC,EAAE,2BAA2B,CAAC,CAAC;IACnE,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,CAAC,EAAE,8BAA8B,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,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AAK;gBAC7B,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC;gBACpB,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,GAAG;gBAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;aACtE;QACP,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,uDAAuD;QACvD,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,uBAAuB;QAC9C,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* flavor. ONE factory + ONE seeding helper. Composes over the memory
|
|
4
4
|
* subsystem (semantic + top-K + strict threshold).
|
|
5
5
|
*/
|
|
6
|
-
export { defineRAG, type DefineRAGOptions } from './defineRAG.js';
|
|
6
|
+
export { defineRAG, DEFAULT_CORPUS_IDENTITY, type DefineRAGOptions } from './defineRAG.js';
|
|
7
7
|
export { indexDocuments, type IndexDocumentsOptions, type RagDocument } from './indexDocuments.js';
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* flavor. ONE factory + ONE seeding helper. Composes over the memory
|
|
4
4
|
* subsystem (semantic + top-K + strict threshold).
|
|
5
5
|
*/
|
|
6
|
-
export { defineRAG } from './defineRAG.js';
|
|
6
|
+
export { defineRAG, DEFAULT_CORPUS_IDENTITY } from './defineRAG.js';
|
|
7
7
|
export { indexDocuments } from './indexDocuments.js';
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/rag/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/rag/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAyB,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAgD,MAAM,qBAAqB,CAAC"}
|
|
@@ -65,14 +65,21 @@ import { MEMORY_TYPES, MEMORY_STRATEGIES, MEMORY_TIMING, } from './define.types.
|
|
|
65
65
|
export function defineMemory(options) {
|
|
66
66
|
validate(options);
|
|
67
67
|
const pipeline = buildPipeline(options);
|
|
68
|
+
// `readOnly` drops the write half entirely (8.8.0). Not "writes are
|
|
69
|
+
// skipped at runtime" — the subflow is never compiled and never mounted,
|
|
70
|
+
// so a read-only memory has no write stage in its chart, no write commit
|
|
71
|
+
// in its log, and nothing to disable later by accident.
|
|
72
|
+
const write = options.readOnly === true ? undefined : pipeline.write;
|
|
68
73
|
const definition = {
|
|
69
74
|
id: options.id,
|
|
70
75
|
...(options.description !== undefined && { description: options.description }),
|
|
71
76
|
type: options.type,
|
|
72
77
|
read: brandPipeline(pipeline.read),
|
|
73
|
-
...(
|
|
78
|
+
...(write !== undefined && { write: brandPipeline(write) }),
|
|
74
79
|
timing: options.timing ?? MEMORY_TIMING.TURN_START,
|
|
75
80
|
...(options.redact !== undefined && { redact: options.redact }),
|
|
81
|
+
...(options.corpus !== undefined && { corpus: options.corpus }),
|
|
82
|
+
...(options.flavor !== undefined && { flavor: options.flavor }),
|
|
76
83
|
...(options.type === MEMORY_TYPES.CAUSAL &&
|
|
77
84
|
options.projection !== undefined && {
|
|
78
85
|
projection: options.projection,
|
|
@@ -93,6 +100,26 @@ function validate(options) {
|
|
|
93
100
|
throw new Error(`defineMemory[id=${options.id}]: \`store\` is required. ` +
|
|
94
101
|
'Pass `new InMemoryStore()` for dev/tests, or a backed store for production.');
|
|
95
102
|
}
|
|
103
|
+
// The shorthand and the spelled-out rule EXCLUDE. Accepting both would
|
|
104
|
+
// mean one of two numbers silently loses, and the recording would name
|
|
105
|
+
// a `k` the run did not use.
|
|
106
|
+
// Read through a structural shape, not the union: the union's arms
|
|
107
|
+
// declare the OTHER spelling as `never`, so intersecting them here
|
|
108
|
+
// would make the very field this check reads unreadable.
|
|
109
|
+
const strategy = options.strategy;
|
|
110
|
+
if (strategy?.retrieval !== undefined) {
|
|
111
|
+
const shorthand = [];
|
|
112
|
+
if (strategy.topK !== undefined)
|
|
113
|
+
shorthand.push('`topK`');
|
|
114
|
+
if (strategy.threshold !== undefined)
|
|
115
|
+
shorthand.push('`threshold`');
|
|
116
|
+
if (shorthand.length > 0) {
|
|
117
|
+
throw new Error(`defineMemory[id=${options.id}]: ${shorthand.join(' and ')} cannot be combined with ` +
|
|
118
|
+
'`retrieval` — they are two spellings of the same rule and could disagree. ' +
|
|
119
|
+
`Keep the strategy (\`retrieval: ${strategy.retrieval.name}({ ... })\`) and drop ` +
|
|
120
|
+
`${shorthand.join('/')}, or drop \`retrieval\`.`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
96
123
|
}
|
|
97
124
|
// ─── Pipeline dispatch ─────────────────────────────────────────────
|
|
98
125
|
function buildPipeline(options) {
|
|
@@ -177,8 +204,11 @@ function buildSemanticPipeline(options) {
|
|
|
177
204
|
const config = {
|
|
178
205
|
store: options.store,
|
|
179
206
|
embedder: t.embedder,
|
|
180
|
-
k: t.topK,
|
|
207
|
+
...(t.topK !== undefined && { k: t.topK }),
|
|
181
208
|
...(t.threshold !== undefined && { minScore: t.threshold }),
|
|
209
|
+
...(t.embedderId !== undefined && { embedderId: t.embedderId }),
|
|
210
|
+
...(t.retrieval !== undefined && { retrieval: t.retrieval }),
|
|
211
|
+
...(options.flavor !== undefined && { flavor: options.flavor }),
|
|
182
212
|
};
|
|
183
213
|
return semanticPipeline(config);
|
|
184
214
|
}
|
|
@@ -268,6 +298,12 @@ function buildCausalPipeline(options) {
|
|
|
268
298
|
'Pass `new InMemoryStore({ embedder })` for dev/tests, or a vector adapter ' +
|
|
269
299
|
'(pgvector, Pinecone, Qdrant) for production.');
|
|
270
300
|
}
|
|
301
|
+
// CAUSAL predates the retrieval seam and reads the shorthand only. A
|
|
302
|
+
// strategy passed here would be accepted and ignored, so it is refused.
|
|
303
|
+
if (s.retrieval !== undefined) {
|
|
304
|
+
throw new Error(`defineMemory[${options.id}]: CAUSAL type does not read \`retrieval\` — snapshot recall ` +
|
|
305
|
+
'matches a stored query vector, not a document pool. Use `topK` + `threshold`.');
|
|
306
|
+
}
|
|
271
307
|
const config = {
|
|
272
308
|
store: options.store,
|
|
273
309
|
embedder: s.embedder,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../../src/memory/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,eAAe,EAA8B,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAA+B,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,YAAY,EAA2B,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAgC,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAA2B,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAA+B,MAAM,mBAAmB,CAAC;AAGlF,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,GAad,MAAM,mBAAmB,CAAC;AAG3B,sEAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,YAAY,CAAC,OAA4B;IACvD,QAAQ,CAAC,OAAO,CAAC,CAAC;IAElB,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAExC,MAAM,UAAU,GAAqB;QACnC,EAAE,EAAE,OA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