agentfootprint 8.7.0 → 8.9.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.
Files changed (245) hide show
  1. package/AGENTS.md +12 -4
  2. package/CLAUDE.md +7 -3
  3. package/ai-instructions/claude-code/SKILL.md +1 -1
  4. package/ai-instructions/setup.sh +0 -0
  5. package/bin/agentfootprint-lint-tools.mjs +0 -0
  6. package/dist/adapters/memory/sqliteVector.js +875 -0
  7. package/dist/adapters/memory/sqliteVector.js.map +1 -0
  8. package/dist/core/Agent.js +6 -0
  9. package/dist/core/Agent.js.map +1 -1
  10. package/dist/core/agent/buildAgentChart.js +12 -1
  11. package/dist/core/agent/buildAgentChart.js.map +1 -1
  12. package/dist/core/agent/buildDynamicAgentChart.js +12 -1
  13. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  14. package/dist/core/agent/memoryRecallInjections.js +100 -10
  15. package/dist/core/agent/memoryRecallInjections.js.map +1 -1
  16. package/dist/core/agent/stages/deliver.js.map +1 -1
  17. package/dist/core/slots/buildSystemPromptSlot.js +10 -0
  18. package/dist/core/slots/buildSystemPromptSlot.js.map +1 -1
  19. package/dist/core/slots/helpers.js +12 -10
  20. package/dist/core/slots/helpers.js.map +1 -1
  21. package/dist/embedders/index.js +11 -0
  22. package/dist/embedders/index.js.map +1 -1
  23. package/dist/esm/adapters/memory/sqliteVector.d.ts +251 -0
  24. package/dist/esm/adapters/memory/sqliteVector.js +869 -0
  25. package/dist/esm/adapters/memory/sqliteVector.js.map +1 -0
  26. package/dist/esm/core/Agent.js +6 -0
  27. package/dist/esm/core/Agent.js.map +1 -1
  28. package/dist/esm/core/agent/buildAgentChart.js +13 -2
  29. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  30. package/dist/esm/core/agent/buildDynamicAgentChart.js +13 -2
  31. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  32. package/dist/esm/core/agent/memoryRecallInjections.d.ts +13 -3
  33. package/dist/esm/core/agent/memoryRecallInjections.js +101 -11
  34. package/dist/esm/core/agent/memoryRecallInjections.js.map +1 -1
  35. package/dist/esm/core/agent/stages/deliver.d.ts +6 -3
  36. package/dist/esm/core/agent/stages/deliver.js.map +1 -1
  37. package/dist/esm/core/slots/buildSystemPromptSlot.js +10 -0
  38. package/dist/esm/core/slots/buildSystemPromptSlot.js.map +1 -1
  39. package/dist/esm/core/slots/helpers.d.ts +11 -2
  40. package/dist/esm/core/slots/helpers.js +11 -9
  41. package/dist/esm/core/slots/helpers.js.map +1 -1
  42. package/dist/esm/embedders/index.js +11 -0
  43. package/dist/esm/embedders/index.js.map +1 -1
  44. package/dist/esm/events/payloads.d.ts +63 -0
  45. package/dist/esm/events/registry.d.ts +3 -1
  46. package/dist/esm/events/registry.js +2 -0
  47. package/dist/esm/events/registry.js.map +1 -1
  48. package/dist/esm/hosting/sqliteSessions.d.ts +7 -13
  49. package/dist/esm/hosting/sqliteSessions.js +8 -25
  50. package/dist/esm/hosting/sqliteSessions.js.map +1 -1
  51. package/dist/esm/index.d.ts +2 -1
  52. package/dist/esm/index.js +6 -1
  53. package/dist/esm/index.js.map +1 -1
  54. package/dist/esm/lib/fnv1a.d.ts +16 -0
  55. package/dist/esm/lib/fnv1a.js +24 -0
  56. package/dist/esm/lib/fnv1a.js.map +1 -0
  57. package/dist/esm/lib/injection-engine/types.d.ts +17 -0
  58. package/dist/esm/lib/injection-engine/types.js.map +1 -1
  59. package/dist/esm/lib/rag/defineRAG.d.ts +126 -26
  60. package/dist/esm/lib/rag/defineRAG.js +112 -25
  61. package/dist/esm/lib/rag/defineRAG.js.map +1 -1
  62. package/dist/esm/lib/rag/index.d.ts +1 -1
  63. package/dist/esm/lib/rag/index.js +1 -1
  64. package/dist/esm/lib/rag/index.js.map +1 -1
  65. package/dist/esm/lib/rag/indexDocuments.d.ts +26 -4
  66. package/dist/esm/lib/rag/indexDocuments.js +12 -1
  67. package/dist/esm/lib/rag/indexDocuments.js.map +1 -1
  68. package/dist/esm/lib/sqliteUnavailable.d.ts +55 -0
  69. package/dist/esm/lib/sqliteUnavailable.js +61 -0
  70. package/dist/esm/lib/sqliteUnavailable.js.map +1 -0
  71. package/dist/esm/memory/define.js +38 -2
  72. package/dist/esm/memory/define.js.map +1 -1
  73. package/dist/esm/memory/define.types.d.ts +93 -1
  74. package/dist/esm/memory/define.types.js +18 -0
  75. package/dist/esm/memory/define.types.js.map +1 -1
  76. package/dist/esm/memory/embedding/embedMessages.js +16 -0
  77. package/dist/esm/memory/embedding/embedMessages.js.map +1 -1
  78. package/dist/esm/memory/embedding/emitEmbedding.d.ts +38 -0
  79. package/dist/esm/memory/embedding/emitEmbedding.js +15 -0
  80. package/dist/esm/memory/embedding/emitEmbedding.js.map +1 -0
  81. package/dist/esm/memory/embedding/loadRelevant.d.ts +49 -15
  82. package/dist/esm/memory/embedding/loadRelevant.js +150 -7
  83. package/dist/esm/memory/embedding/loadRelevant.js.map +1 -1
  84. package/dist/esm/memory/embedding/mockEmbedder.js +4 -0
  85. package/dist/esm/memory/embedding/mockEmbedder.js.map +1 -1
  86. package/dist/esm/memory/embedding/types.d.ts +24 -0
  87. package/dist/esm/memory/index.d.ts +2 -1
  88. package/dist/esm/memory/index.js +2 -1
  89. package/dist/esm/memory/index.js.map +1 -1
  90. package/dist/esm/memory/pipeline/semantic.d.ts +15 -0
  91. package/dist/esm/memory/pipeline/semantic.js +3 -1
  92. package/dist/esm/memory/pipeline/semantic.js.map +1 -1
  93. package/dist/esm/memory/retrieval/index.d.ts +10 -0
  94. package/dist/esm/memory/retrieval/index.js +3 -0
  95. package/dist/esm/memory/retrieval/index.js.map +1 -0
  96. package/dist/esm/memory/retrieval/provenance.d.ts +43 -0
  97. package/dist/esm/memory/retrieval/provenance.js +60 -0
  98. package/dist/esm/memory/retrieval/provenance.js.map +1 -0
  99. package/dist/esm/memory/retrieval/topK.d.ts +67 -0
  100. package/dist/esm/memory/retrieval/topK.js +53 -0
  101. package/dist/esm/memory/retrieval/topK.js.map +1 -0
  102. package/dist/esm/memory/retrieval/types.d.ts +189 -0
  103. package/dist/esm/memory/retrieval/types.js +2 -0
  104. package/dist/esm/memory/retrieval/types.js.map +1 -0
  105. package/dist/esm/memory/stages/formatDefault.d.ts +52 -26
  106. package/dist/esm/memory/stages/formatDefault.js +118 -28
  107. package/dist/esm/memory/stages/formatDefault.js.map +1 -1
  108. package/dist/esm/memory/stages/pickByBudget.js +53 -3
  109. package/dist/esm/memory/stages/pickByBudget.js.map +1 -1
  110. package/dist/esm/memory/stages/types.d.ts +15 -0
  111. package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +25 -0
  112. package/dist/esm/memory/wire/mountMemoryPipeline.js +11 -2
  113. package/dist/esm/memory/wire/mountMemoryPipeline.js.map +1 -1
  114. package/dist/esm/memory-providers.d.ts +2 -0
  115. package/dist/esm/memory-providers.js +8 -0
  116. package/dist/esm/memory-providers.js.map +1 -1
  117. package/dist/esm/observe.d.ts +2 -0
  118. package/dist/esm/observe.js +2 -0
  119. package/dist/esm/observe.js.map +1 -1
  120. package/dist/esm/recorders/core/EmbeddingRecorder.d.ts +19 -0
  121. package/dist/esm/recorders/core/EmbeddingRecorder.js +24 -0
  122. package/dist/esm/recorders/core/EmbeddingRecorder.js.map +1 -0
  123. package/dist/events/registry.js +2 -0
  124. package/dist/events/registry.js.map +1 -1
  125. package/dist/hosting/sqliteSessions.js +10 -27
  126. package/dist/hosting/sqliteSessions.js.map +1 -1
  127. package/dist/index.js +8 -1
  128. package/dist/index.js.map +1 -1
  129. package/dist/lib/fnv1a.js +28 -0
  130. package/dist/lib/fnv1a.js.map +1 -0
  131. package/dist/lib/injection-engine/types.js.map +1 -1
  132. package/dist/lib/rag/defineRAG.js +113 -26
  133. package/dist/lib/rag/defineRAG.js.map +1 -1
  134. package/dist/lib/rag/index.js +2 -1
  135. package/dist/lib/rag/index.js.map +1 -1
  136. package/dist/lib/rag/indexDocuments.js +12 -1
  137. package/dist/lib/rag/indexDocuments.js.map +1 -1
  138. package/dist/lib/sqliteUnavailable.js +65 -0
  139. package/dist/lib/sqliteUnavailable.js.map +1 -0
  140. package/dist/memory/define.js +38 -2
  141. package/dist/memory/define.js.map +1 -1
  142. package/dist/memory/define.types.js +21 -1
  143. package/dist/memory/define.types.js.map +1 -1
  144. package/dist/memory/embedding/embedMessages.js +16 -0
  145. package/dist/memory/embedding/embedMessages.js.map +1 -1
  146. package/dist/memory/embedding/emitEmbedding.js +19 -0
  147. package/dist/memory/embedding/emitEmbedding.js.map +1 -0
  148. package/dist/memory/embedding/loadRelevant.js +152 -8
  149. package/dist/memory/embedding/loadRelevant.js.map +1 -1
  150. package/dist/memory/embedding/mockEmbedder.js +4 -0
  151. package/dist/memory/embedding/mockEmbedder.js.map +1 -1
  152. package/dist/memory/index.js +5 -1
  153. package/dist/memory/index.js.map +1 -1
  154. package/dist/memory/pipeline/semantic.js +2 -0
  155. package/dist/memory/pipeline/semantic.js.map +1 -1
  156. package/dist/memory/retrieval/index.js +9 -0
  157. package/dist/memory/retrieval/index.js.map +1 -0
  158. package/dist/memory/retrieval/provenance.js +65 -0
  159. package/dist/memory/retrieval/provenance.js.map +1 -0
  160. package/dist/memory/retrieval/topK.js +57 -0
  161. package/dist/memory/retrieval/topK.js.map +1 -0
  162. package/dist/memory/retrieval/types.js +3 -0
  163. package/dist/memory/retrieval/types.js.map +1 -0
  164. package/dist/memory/stages/formatDefault.js +118 -28
  165. package/dist/memory/stages/formatDefault.js.map +1 -1
  166. package/dist/memory/stages/pickByBudget.js +53 -3
  167. package/dist/memory/stages/pickByBudget.js.map +1 -1
  168. package/dist/memory/wire/mountMemoryPipeline.js +11 -2
  169. package/dist/memory/wire/mountMemoryPipeline.js.map +1 -1
  170. package/dist/memory-providers.js +13 -1
  171. package/dist/memory-providers.js.map +1 -1
  172. package/dist/observe.js +4 -1
  173. package/dist/observe.js.map +1 -1
  174. package/dist/recorders/core/EmbeddingRecorder.js +28 -0
  175. package/dist/recorders/core/EmbeddingRecorder.js.map +1 -0
  176. package/dist/types/adapters/memory/sqliteVector.d.ts +252 -0
  177. package/dist/types/adapters/memory/sqliteVector.d.ts.map +1 -0
  178. package/dist/types/core/Agent.d.ts.map +1 -1
  179. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  180. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  181. package/dist/types/core/agent/memoryRecallInjections.d.ts +13 -3
  182. package/dist/types/core/agent/memoryRecallInjections.d.ts.map +1 -1
  183. package/dist/types/core/agent/stages/deliver.d.ts +6 -3
  184. package/dist/types/core/agent/stages/deliver.d.ts.map +1 -1
  185. package/dist/types/core/slots/buildSystemPromptSlot.d.ts.map +1 -1
  186. package/dist/types/core/slots/helpers.d.ts +11 -2
  187. package/dist/types/core/slots/helpers.d.ts.map +1 -1
  188. package/dist/types/embedders/index.d.ts.map +1 -1
  189. package/dist/types/events/payloads.d.ts +63 -0
  190. package/dist/types/events/payloads.d.ts.map +1 -1
  191. package/dist/types/events/registry.d.ts +3 -1
  192. package/dist/types/events/registry.d.ts.map +1 -1
  193. package/dist/types/hosting/sqliteSessions.d.ts +7 -13
  194. package/dist/types/hosting/sqliteSessions.d.ts.map +1 -1
  195. package/dist/types/index.d.ts +2 -1
  196. package/dist/types/index.d.ts.map +1 -1
  197. package/dist/types/lib/fnv1a.d.ts +17 -0
  198. package/dist/types/lib/fnv1a.d.ts.map +1 -0
  199. package/dist/types/lib/injection-engine/types.d.ts +17 -0
  200. package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
  201. package/dist/types/lib/rag/defineRAG.d.ts +126 -26
  202. package/dist/types/lib/rag/defineRAG.d.ts.map +1 -1
  203. package/dist/types/lib/rag/index.d.ts +1 -1
  204. package/dist/types/lib/rag/index.d.ts.map +1 -1
  205. package/dist/types/lib/rag/indexDocuments.d.ts +26 -4
  206. package/dist/types/lib/rag/indexDocuments.d.ts.map +1 -1
  207. package/dist/types/lib/sqliteUnavailable.d.ts +56 -0
  208. package/dist/types/lib/sqliteUnavailable.d.ts.map +1 -0
  209. package/dist/types/memory/define.d.ts.map +1 -1
  210. package/dist/types/memory/define.types.d.ts +93 -1
  211. package/dist/types/memory/define.types.d.ts.map +1 -1
  212. package/dist/types/memory/embedding/embedMessages.d.ts.map +1 -1
  213. package/dist/types/memory/embedding/emitEmbedding.d.ts +39 -0
  214. package/dist/types/memory/embedding/emitEmbedding.d.ts.map +1 -0
  215. package/dist/types/memory/embedding/loadRelevant.d.ts +49 -15
  216. package/dist/types/memory/embedding/loadRelevant.d.ts.map +1 -1
  217. package/dist/types/memory/embedding/mockEmbedder.d.ts.map +1 -1
  218. package/dist/types/memory/embedding/types.d.ts +24 -0
  219. package/dist/types/memory/embedding/types.d.ts.map +1 -1
  220. package/dist/types/memory/index.d.ts +2 -1
  221. package/dist/types/memory/index.d.ts.map +1 -1
  222. package/dist/types/memory/pipeline/semantic.d.ts +15 -0
  223. package/dist/types/memory/pipeline/semantic.d.ts.map +1 -1
  224. package/dist/types/memory/retrieval/index.d.ts +11 -0
  225. package/dist/types/memory/retrieval/index.d.ts.map +1 -0
  226. package/dist/types/memory/retrieval/provenance.d.ts +44 -0
  227. package/dist/types/memory/retrieval/provenance.d.ts.map +1 -0
  228. package/dist/types/memory/retrieval/topK.d.ts +68 -0
  229. package/dist/types/memory/retrieval/topK.d.ts.map +1 -0
  230. package/dist/types/memory/retrieval/types.d.ts +190 -0
  231. package/dist/types/memory/retrieval/types.d.ts.map +1 -0
  232. package/dist/types/memory/stages/formatDefault.d.ts +52 -26
  233. package/dist/types/memory/stages/formatDefault.d.ts.map +1 -1
  234. package/dist/types/memory/stages/pickByBudget.d.ts.map +1 -1
  235. package/dist/types/memory/stages/types.d.ts +15 -0
  236. package/dist/types/memory/stages/types.d.ts.map +1 -1
  237. package/dist/types/memory/wire/mountMemoryPipeline.d.ts +25 -0
  238. package/dist/types/memory/wire/mountMemoryPipeline.d.ts.map +1 -1
  239. package/dist/types/memory-providers.d.ts +2 -0
  240. package/dist/types/memory-providers.d.ts.map +1 -1
  241. package/dist/types/observe.d.ts +2 -0
  242. package/dist/types/observe.d.ts.map +1 -1
  243. package/dist/types/recorders/core/EmbeddingRecorder.d.ts +20 -0
  244. package/dist/types/recorders/core/EmbeddingRecorder.d.ts.map +1 -0
  245. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"sqliteSessions.js","sourceRoot":"","sources":["../../../src/hosting/sqliteSessions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AA2FpD,wEAAwE;AAExE;;;;;;;;;;GAUG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACtC,IAAI,GAAG,wBAAiC,CAAC;IAClD,gDAAgD;IACvC,WAAW,CAAS;IAE7B,YAAY,WAAmB,EAAE,MAAc;QAC7C,KAAK,CACH,kFAAkF;YAChF,iBAAiB,WAAW,uBAAuB,MAAM,KAAK;YAC9D,+EAA+E;YAC/E,8EAA8E;YAC9E,yEAAyE;YACzE,6EAA6E;YAC7E,+EAA+E;YAC/E,iFAAiF;YACjF,wBAAwB,CAC3B,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,IAAI,GAAG,6BAAsC,CAAC;IACvD,iCAAiC;IACxB,IAAI,CAAS;IACtB,wCAAwC;IAC/B,OAAO,CAAoD;IAEpE,YAAY,IAAY,EAAE,OAA8C,EAAE,MAAc;QACtF,KAAK,CACH,mCAAmC,IAAI,qBAAq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C;AACH,CAAC;AAED,kFAAkF;AAClF,SAAS,QAAQ,CAAC,GAAY;IAC5B,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC"}
@@ -53,4 +53,5 @@ export { workflow, Workflow, type NextStepInput, type WorkflowOptions, } from '.
53
53
  export { graph, Graph, type GraphEdge, type GraphInput, type GraphNode, type GraphOptions, type GraphOutput, } from './core-flow/Graph.js';
54
54
  export { providerFromEnv, type ProviderKind, type CreateProviderOptions, type ProviderFromEnv, } from './adapters/llm/createProvider.js';
55
55
  export * from './patterns/index.js';
56
- export { defineRAG, type DefineRAGOptions, indexDocuments, type IndexDocumentsOptions, type RagDocument, } from './lib/rag/index.js';
56
+ export { defineRAG, DEFAULT_CORPUS_IDENTITY, type DefineRAGOptions, indexDocuments, type IndexDocumentsOptions, type RagDocument, } from './lib/rag/index.js';
57
+ export { topK, type TopKOptions, type RetrievalStrategy, type RetrievalEvidence, type RetrievedCandidate, type RetrievalRejectReason, } from './memory/retrieval/index.js';
package/dist/esm/index.js CHANGED
@@ -173,7 +173,12 @@ export * from './patterns/index.js';
173
173
  // RAG — retrieval-augmented generation as a context-engineering flavor.
174
174
  // Thin sugar over `defineMemory({ type: SEMANTIC, strategy: TOP_K })`
175
175
  // plus the `indexDocuments` helper for seeding the corpus at startup.
176
- export { defineRAG, indexDocuments, } from './lib/rag/index.js';
176
+ export { defineRAG, DEFAULT_CORPUS_IDENTITY, indexDocuments, } from './lib/rag/index.js';
177
+ // The retrieval seam (8.8.0) — what a retrieval considered, and the rule
178
+ // that decided what it kept. `topK` is the rule every release before this
179
+ // one applied without naming it. The record types are here because a
180
+ // consumer reading `agentfootprint.memory.retrieved` needs them.
181
+ export { topK, } from './memory/retrieval/index.js';
177
182
  // MCP + tool dispatch. Tool sources — `mcpClient` / `mockMcpClient`,
178
183
  // which connect to a Model Context Protocol server and expose its tools
179
184
  // as agentfootprint `Tool[]` for `agent.tools(...)` — and the dispatch
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oEAAoE;AACpE,8DAA8D;AAC9D,uEAAuE;AACvE,kEAAkE;AAClE,sEAAsE;AACtE,sDAAsD;AACtD,OAAO,8CAA8C,CAAC;AACtD,OAAO,2CAA2C,CAAC;AACnD,OAAO,4CAA4C,CAAC;AAsCpD,6BAA6B;AAC7B,cAAc,qBAAqB,CAAC;AAEpC,yEAAyE;AACzE,uDAAuD;AACvD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc;AAEd,yEAAyE;AACzE,wEAAwE;AACxE,yEAAyE;AACzE,gBAAgB;AAChB,SAAS;AAET,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,6DAA6D;AAC7D,YAAY,GAGb,MAAM,kBAAkB,CAAC;AAC1B,oEAAoE;AACpE,yEAAyE;AACzE,wEAAwE;AACxE,qEAAqE;AACrE,kDAAkD;AAClD,OAAO,EACL,gBAAgB,GAMjB,MAAM,2BAA2B,CAAC;AAKnC,yCAAyC;AACzC,EAAE;AACF,yEAAyE;AACzE,kEAAkE;AAClE,oEAAoE;AACpE,qEAAqE;AACrE,2EAA2E;AAC3E,8EAA8E;AAC9E,0DAA0D;AAC1D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,GAKjB,MAAM,wCAAwC,CAAC;AAIhD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAO7D,sEAAsE;AACtE,wEAAwE;AACxE,iEAAiE;AACjE,sEAAsE;AACtE,uEAAuE;AACvE,OAAO,EACL,SAAS,EACT,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,cAAc,EACd,UAAU,GAGX,MAAM,iBAAiB,CAAC;AAEzB,mEAAmE;AACnE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hB,MAAM,kCAAkC,CAAC;AAE1C,+DAA+D;AAE/D,oEAAoE;AACpE,gEAAgE;AAEhE,qEAAqE;AACrE,0DAA0D;AAC1D,cAAc,qBAAqB,CAAC;AAEpC,uEAAuE;AACvE,uEAAuE;AACvE,oEAAoE;AACpE,sEAAsE;AACtE,8CAA8C;AAE9C,wEAAwE;AACxE,sEAAsE;AACtE,sEAAsE;AACtE,OAAO,EACL,SAAS,EACT,uBAAuB,EAEvB,cAAc,GAGf,MAAM,oBAAoB,CAAC;AAE5B,yEAAyE;AACzE,0EAA0E;AAC1E,qEAAqE;AACrE,iEAAiE;AACjE,OAAO,EACL,IAAI,GAML,MAAM,6BAA6B,CAAC;AAErC,qEAAqE;AACrE,wEAAwE;AACxE,uEAAuE;AACvE,oEAAoE;AACpE,8DAA8D;AAC9D,wEAAwE;AACxE,gDAAgD;AAChD,wEAAwE;AACxE,gEAAgE;AAEhE,wEAAwE;AACxE,wEAAwE;AACxE,uDAAuD;AAEvD,mEAAmE;AACnE,oEAAoE;AACpE,sDAAsD"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * fnv1a — the one 32-bit content hash this library uses.
3
+ *
4
+ * Pattern: leaf utility (imports nothing).
5
+ * Role: shared by the slot composers (`core/slots/helpers.ts`, which
6
+ * re-exports it under the same name) and by the memory layer's
7
+ * retrieval record. It lives here rather than in either of them
8
+ * because `memory/` must not import `core/` — `core/` already
9
+ * imports `memory/`, and a second hash implementation is how two
10
+ * recordings of the same bytes end up disagreeing about their id.
11
+ * Emits: N/A.
12
+ *
13
+ * Not cryptographic and not meant to be: this identifies content for
14
+ * dedup and correlation inside one recording, never for authentication.
15
+ */
16
+ export declare function fnv1a(input: string): string;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * fnv1a — the one 32-bit content hash this library uses.
3
+ *
4
+ * Pattern: leaf utility (imports nothing).
5
+ * Role: shared by the slot composers (`core/slots/helpers.ts`, which
6
+ * re-exports it under the same name) and by the memory layer's
7
+ * retrieval record. It lives here rather than in either of them
8
+ * because `memory/` must not import `core/` — `core/` already
9
+ * imports `memory/`, and a second hash implementation is how two
10
+ * recordings of the same bytes end up disagreeing about their id.
11
+ * Emits: N/A.
12
+ *
13
+ * Not cryptographic and not meant to be: this identifies content for
14
+ * dedup and correlation inside one recording, never for authentication.
15
+ */
16
+ export function fnv1a(input) {
17
+ let h = 2166136261;
18
+ for (let i = 0; i < input.length; i++) {
19
+ h ^= input.charCodeAt(i);
20
+ h = Math.imul(h, 16777619);
21
+ }
22
+ return (h >>> 0).toString(16);
23
+ }
24
+ //# sourceMappingURL=fnv1a.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fnv1a.js","sourceRoot":"","sources":["../../../src/lib/fnv1a.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,IAAI,CAAC,GAAG,UAAU,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC"}
@@ -271,6 +271,23 @@ export interface ActiveInjection {
271
271
  * decision's own `?? 'never'` default then applies, as it always did.
272
272
  */
273
273
  readonly cache?: import('../../cache/types.js').CachePolicy;
274
+ /**
275
+ * Why THIS piece of retrieved content earned its place (8.8.0).
276
+ *
277
+ * Present only on injections a retrieval produced — one per admitted
278
+ * chunk, carrying that chunk's own similarity score, its rank in the
279
+ * candidate pool, and the floor it had to clear. The slot composer
280
+ * copies these onto the `InjectionRecord`, which is what finally fills
281
+ * `ContextInjectedPayload.retrievalScore` / `.rankPosition` /
282
+ * `.threshold` — three fields declared since 2.x that nothing has ever
283
+ * written, because until the recall was split per chunk there was no
284
+ * single score for a record to carry.
285
+ */
286
+ readonly retrieval?: {
287
+ readonly score: number;
288
+ readonly rank: number;
289
+ readonly threshold?: number;
290
+ };
274
291
  readonly inject: {
275
292
  readonly systemPrompt?: string;
276
293
  readonly messages?: ReadonlyArray<{
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA6RH,wEAAwE;AACxE,MAAM,UAAU,sBAAsB,CAAC,GAAc;IACnD,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,MAAM,IAAI,GAAG,GAAG,CAAC,QAEJ,CAAC;IACd,MAAM,GAAG,GAAoB;QAC3B,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,GAAG,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC;QACxD,GAAG,CAAC,IAAI,EAAE,WAAW,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAA6C,EAAE,CAAC;QAC7F,GAAG,CAAC,IAAI,EAAE,YAAY,IAAI;YACxB,YAAY,EAAE,IAAI,CAAC,YAA+C;SACnE,CAAC;QACF,0EAA0E;QAC1E,2EAA2E;QAC3E,yEAAyE;QACzE,GAAG,CAAC,IAAI,EAAE,KAAK,KAAK,SAAS,IAAI;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAiC;SAC9C,CAAC;QACF,MAAM,EAAE;YACN,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACzE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,QAAQ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AiC;SAC9C,CAAC;QACF,MAAM,EAAE;YACN,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACzE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACpF,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI;gBACtB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBAClC,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE;oBACvB,WAAW,EAAE,GAAG,CAAC,EAAE;iBACpB,CAAC,CAAC;aACJ,CAAC;SACH;KACF,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,23 +1,66 @@
1
1
  /**
2
- * defineRAG — sugar factory for retrieval-augmented generation.
2
+ * defineRAG — retrieval-augmented generation over a document corpus.
3
3
  *
4
- * RAG is a context-engineering flavor: embed the user's question,
5
- * retrieve top-K semantically similar chunks from a vector store,
6
- * inject those chunks into the system-prompt slot of the next LLM call.
7
- * It's the same plumbing as `defineMemory({ type: SEMANTIC,
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 with RAG-specific defaults
16
- * (topK=3, threshold=0.7, no LLM-extract)
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 event type.
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: Indirectly — the underlying memory pipeline emits
29
- * `agentfootprint.context.injected` when retrieved chunks
30
- * land in the system-prompt slot.
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 { * Agent, defineRAG, indexDocuments, * } from 'agentfootprint'
39
- import { InMemoryStore, mockEmbedder } from 'agentfootprint/memory'
40
- import { mock } from 'agentfootprint/llm-providers';
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 store once at startup
91
+ * // Seed the corpus once at startup (defaults to the '_global' namespace).
46
92
  * await indexDocuments(store, embedder, [
47
- * { id: 'doc1', content: 'Refunds are processed within 3 business days.' },
48
- * { id: 'doc2', content: 'Pro plan costs $20/month.' },
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
- * `pgvector` / Pinecone / Qdrant adapters in production.
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 `name`) that was used for indexing
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. If you see frequent zero-result silent skips,
110
- * lower to ~0.5 and observe the `agentfootprint.context.injected`
111
- * stream. OpenAI `text-embedding-3-*` and Cohere embed-v3 typically
112
- * sit comfortably with 0.7.
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 — sugar factory for retrieval-augmented generation.
2
+ * defineRAG — retrieval-augmented generation over a document corpus.
3
3
  *
4
- * RAG is a context-engineering flavor: embed the user's question,
5
- * retrieve top-K semantically similar chunks from a vector store,
6
- * inject those chunks into the system-prompt slot of the next LLM call.
7
- * It's the same plumbing as `defineMemory({ type: SEMANTIC,
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 with RAG-specific defaults
16
- * (topK=3, threshold=0.7, no LLM-extract)
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 event type.
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: Indirectly — the underlying memory pipeline emits
29
- * `agentfootprint.context.injected` when retrieved chunks
30
- * land in the system-prompt slot.
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 { * Agent, defineRAG, indexDocuments, * } from 'agentfootprint'
39
- import { InMemoryStore, mockEmbedder } from 'agentfootprint/memory'
40
- import { mock } from 'agentfootprint/llm-providers';
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 store once at startup
91
+ * // Seed the corpus once at startup (defaults to the '_global' namespace).
46
92
  * await indexDocuments(store, embedder, [
47
- * { id: 'doc1', content: 'Refunds are processed within 3 business days.' },
48
- * { id: 'doc2', content: 'Pro plan costs $20/month.' },
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
- kind: MEMORY_STRATEGIES.TOP_K,
100
- topK: opts.topK ?? 3,
101
- threshold: opts.threshold ?? 0.7,
102
- embedder: opts.embedder,
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
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iB,CAAC,KAAK;gBAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;aACtE;YACH,CAAC,CAAC;gBACE,IAAI,EAAE,iBAAiB,CAAC,KAAK;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;AAClE,OAAO,EAAE,cAAc,EAAgD,MAAM,qBAAqB,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"}