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.
- package/AGENTS.md +12 -4
- package/CLAUDE.md +7 -3
- 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/adapters/memory/sqliteVector.js +875 -0
- package/dist/adapters/memory/sqliteVector.js.map +1 -0
- package/dist/core/Agent.js +6 -0
- package/dist/core/Agent.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/helpers.js +12 -10
- package/dist/core/slots/helpers.js.map +1 -1
- package/dist/embedders/index.js +11 -0
- package/dist/embedders/index.js.map +1 -1
- package/dist/esm/adapters/memory/sqliteVector.d.ts +251 -0
- package/dist/esm/adapters/memory/sqliteVector.js +869 -0
- package/dist/esm/adapters/memory/sqliteVector.js.map +1 -0
- package/dist/esm/core/Agent.js +6 -0
- package/dist/esm/core/Agent.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/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/embedders/index.js +11 -0
- package/dist/esm/embedders/index.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +63 -0
- package/dist/esm/events/registry.d.ts +3 -1
- package/dist/esm/events/registry.js +2 -0
- package/dist/esm/events/registry.js.map +1 -1
- package/dist/esm/hosting/sqliteSessions.d.ts +7 -13
- package/dist/esm/hosting/sqliteSessions.js +8 -25
- package/dist/esm/hosting/sqliteSessions.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/types.d.ts +17 -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/lib/rag/indexDocuments.d.ts +26 -4
- package/dist/esm/lib/rag/indexDocuments.js +12 -1
- package/dist/esm/lib/rag/indexDocuments.js.map +1 -1
- package/dist/esm/lib/sqliteUnavailable.d.ts +55 -0
- package/dist/esm/lib/sqliteUnavailable.js +61 -0
- package/dist/esm/lib/sqliteUnavailable.js.map +1 -0
- 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/embedMessages.js +16 -0
- package/dist/esm/memory/embedding/embedMessages.js.map +1 -1
- package/dist/esm/memory/embedding/emitEmbedding.d.ts +38 -0
- package/dist/esm/memory/embedding/emitEmbedding.js +15 -0
- package/dist/esm/memory/embedding/emitEmbedding.js.map +1 -0
- package/dist/esm/memory/embedding/loadRelevant.d.ts +49 -15
- package/dist/esm/memory/embedding/loadRelevant.js +150 -7
- package/dist/esm/memory/embedding/loadRelevant.js.map +1 -1
- package/dist/esm/memory/embedding/mockEmbedder.js +4 -0
- package/dist/esm/memory/embedding/mockEmbedder.js.map +1 -1
- package/dist/esm/memory/embedding/types.d.ts +24 -0
- 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/memory-providers.d.ts +2 -0
- package/dist/esm/memory-providers.js +8 -0
- package/dist/esm/memory-providers.js.map +1 -1
- package/dist/esm/observe.d.ts +2 -0
- package/dist/esm/observe.js +2 -0
- package/dist/esm/observe.js.map +1 -1
- package/dist/esm/recorders/core/EmbeddingRecorder.d.ts +19 -0
- package/dist/esm/recorders/core/EmbeddingRecorder.js +24 -0
- package/dist/esm/recorders/core/EmbeddingRecorder.js.map +1 -0
- package/dist/events/registry.js +2 -0
- package/dist/events/registry.js.map +1 -1
- package/dist/hosting/sqliteSessions.js +10 -27
- package/dist/hosting/sqliteSessions.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/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/lib/rag/indexDocuments.js +12 -1
- package/dist/lib/rag/indexDocuments.js.map +1 -1
- package/dist/lib/sqliteUnavailable.js +65 -0
- package/dist/lib/sqliteUnavailable.js.map +1 -0
- 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/embedMessages.js +16 -0
- package/dist/memory/embedding/embedMessages.js.map +1 -1
- package/dist/memory/embedding/emitEmbedding.js +19 -0
- package/dist/memory/embedding/emitEmbedding.js.map +1 -0
- package/dist/memory/embedding/loadRelevant.js +152 -8
- package/dist/memory/embedding/loadRelevant.js.map +1 -1
- package/dist/memory/embedding/mockEmbedder.js +4 -0
- package/dist/memory/embedding/mockEmbedder.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/memory-providers.js +13 -1
- package/dist/memory-providers.js.map +1 -1
- package/dist/observe.js +4 -1
- package/dist/observe.js.map +1 -1
- package/dist/recorders/core/EmbeddingRecorder.js +28 -0
- package/dist/recorders/core/EmbeddingRecorder.js.map +1 -0
- package/dist/types/adapters/memory/sqliteVector.d.ts +252 -0
- package/dist/types/adapters/memory/sqliteVector.d.ts.map +1 -0
- package/dist/types/core/Agent.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/helpers.d.ts +11 -2
- package/dist/types/core/slots/helpers.d.ts.map +1 -1
- package/dist/types/embedders/index.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +63 -0
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/registry.d.ts +3 -1
- package/dist/types/events/registry.d.ts.map +1 -1
- package/dist/types/hosting/sqliteSessions.d.ts +7 -13
- package/dist/types/hosting/sqliteSessions.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/types.d.ts +17 -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/lib/rag/indexDocuments.d.ts +26 -4
- package/dist/types/lib/rag/indexDocuments.d.ts.map +1 -1
- package/dist/types/lib/sqliteUnavailable.d.ts +56 -0
- package/dist/types/lib/sqliteUnavailable.d.ts.map +1 -0
- 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/embedMessages.d.ts.map +1 -1
- package/dist/types/memory/embedding/emitEmbedding.d.ts +39 -0
- package/dist/types/memory/embedding/emitEmbedding.d.ts.map +1 -0
- 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/embedding/mockEmbedder.d.ts.map +1 -1
- package/dist/types/memory/embedding/types.d.ts +24 -0
- package/dist/types/memory/embedding/types.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/memory-providers.d.ts +2 -0
- package/dist/types/memory-providers.d.ts.map +1 -1
- package/dist/types/observe.d.ts +2 -0
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/recorders/core/EmbeddingRecorder.d.ts +20 -0
- package/dist/types/recorders/core/EmbeddingRecorder.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
import type { LLMProvider } from '../adapters/types.js';
|
|
42
42
|
import type { Embedder } from './embedding/index.js';
|
|
43
43
|
import type { MemoryStore } from './store/index.js';
|
|
44
|
+
import type { MemoryIdentity } from './identity/index.js';
|
|
45
|
+
import type { RetrievalStrategy } from './retrieval/types.js';
|
|
44
46
|
/**
|
|
45
47
|
* What shape of memory you're keeping.
|
|
46
48
|
*
|
|
@@ -152,12 +154,44 @@ export interface SummarizeStrategy {
|
|
|
152
154
|
* STRICT threshold: when no entry meets the threshold, return EMPTY.
|
|
153
155
|
* No fallback — garbage in context is worse than no memory.
|
|
154
156
|
*/
|
|
155
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Top-K retrieval, in either of its two spellings — and never both.
|
|
159
|
+
*
|
|
160
|
+
* The arms EXCLUDE (8.8.0). `{ topK, threshold }` is the shorthand;
|
|
161
|
+
* `{ retrieval }` is the same rule written as a {@link RetrievalStrategy},
|
|
162
|
+
* which is also how a different rule gets in. Accepting both would mean
|
|
163
|
+
* one of two `k`s silently loses and the recording would name a `k` the
|
|
164
|
+
* run did not use — so the type refuses it at the keystroke, and
|
|
165
|
+
* `defineMemory` refuses it again at runtime for JavaScript callers.
|
|
166
|
+
*/
|
|
167
|
+
export type TopKStrategy = TopKShorthandStrategy | TopKRetrievalStrategy;
|
|
168
|
+
/** The historical spelling: two loose numbers. Unchanged since 2.x. */
|
|
169
|
+
export interface TopKShorthandStrategy {
|
|
156
170
|
readonly kind: typeof MEMORY_STRATEGIES.TOP_K;
|
|
157
171
|
readonly topK: number;
|
|
158
172
|
/** Min cosine similarity. Strict — no fallback below this. Default 0.7. */
|
|
159
173
|
readonly threshold?: number;
|
|
160
174
|
readonly embedder: Embedder;
|
|
175
|
+
/**
|
|
176
|
+
* Stable id of the embedder, filtered against `MemoryEntry.embeddingModel`
|
|
177
|
+
* at search time so a later embedder swap cannot silently mix two vector
|
|
178
|
+
* spaces. Pair it with the same value passed to `indexDocuments`.
|
|
179
|
+
*
|
|
180
|
+
* Wired in 8.8.0. `defineRAG` has accepted an `embedderId` since 7.x and
|
|
181
|
+
* never forwarded it — an option the run did not read.
|
|
182
|
+
*/
|
|
183
|
+
readonly embedderId?: string;
|
|
184
|
+
readonly retrieval?: never;
|
|
185
|
+
}
|
|
186
|
+
/** The spelled-out rule (8.8.0) — and the seam a re-ranker will arrive through. */
|
|
187
|
+
export interface TopKRetrievalStrategy {
|
|
188
|
+
readonly kind: typeof MEMORY_STRATEGIES.TOP_K;
|
|
189
|
+
readonly embedder: Embedder;
|
|
190
|
+
readonly retrieval: RetrievalStrategy;
|
|
191
|
+
/** See {@link TopKShorthandStrategy.embedderId}. */
|
|
192
|
+
readonly embedderId?: string;
|
|
193
|
+
readonly topK?: never;
|
|
194
|
+
readonly threshold?: never;
|
|
161
195
|
}
|
|
162
196
|
/**
|
|
163
197
|
* Extract — on WRITE, an LLM (or pattern matcher) distills entries from
|
|
@@ -234,7 +268,34 @@ export interface MemoryDefinition<T = unknown> {
|
|
|
234
268
|
readonly redact?: MemoryRedactionPolicy;
|
|
235
269
|
/** Snapshot projection — only meaningful when `type === CAUSAL`. */
|
|
236
270
|
readonly projection?: SnapshotProjection;
|
|
271
|
+
/**
|
|
272
|
+
* The namespace this memory reads and writes (8.8.0).
|
|
273
|
+
*
|
|
274
|
+
* Absent — the historical behaviour, and still the right one for
|
|
275
|
+
* conversation memory — means "whatever identity the run was given",
|
|
276
|
+
* so each conversation remembers its own turns.
|
|
277
|
+
*
|
|
278
|
+
* Present means "always this namespace, whoever is asking", which is
|
|
279
|
+
* what a shared document corpus is: a corpus does not belong to a
|
|
280
|
+
* conversation, and reading it under a per-run conversation id is why
|
|
281
|
+
* `defineRAG`'s own documented example retrieved nothing at all before
|
|
282
|
+
* 8.8.0. `defineRAG` defaults it to `{ conversationId: '_global' }`,
|
|
283
|
+
* matching `indexDocuments`'s default so the two sides meet.
|
|
284
|
+
*/
|
|
285
|
+
readonly corpus?: MemoryIdentity;
|
|
286
|
+
/**
|
|
287
|
+
* Which claim this memory's injected block makes (8.8.0). `'memory'`
|
|
288
|
+
* is conversation recall; `'rag'` is corpus retrieval, and it is the
|
|
289
|
+
* value that reaches the recording as `ContextInjectedPayload.source`.
|
|
290
|
+
*
|
|
291
|
+
* The event vocabulary has carried a `'rag'` source since 2.x and
|
|
292
|
+
* nothing ever emitted it — a declared value no run can produce is a
|
|
293
|
+
* gap in the contract, not a spare.
|
|
294
|
+
*/
|
|
295
|
+
readonly flavor?: MemoryFlavor;
|
|
237
296
|
}
|
|
297
|
+
/** What an injected memory block is claiming to be. */
|
|
298
|
+
export type MemoryFlavor = 'memory' | 'rag';
|
|
238
299
|
/**
|
|
239
300
|
* Opaque tag for the compiled flowchart the factory hands back.
|
|
240
301
|
* The actual type is `FlowChart<MemoryState>` from footprintjs but we
|
|
@@ -256,6 +317,23 @@ export interface DefineMemoryOptionsBase {
|
|
|
256
317
|
readonly strategy: Strategy;
|
|
257
318
|
readonly timing?: MemoryTiming;
|
|
258
319
|
readonly redact?: MemoryRedactionPolicy;
|
|
320
|
+
/**
|
|
321
|
+
* Read and write under THIS namespace instead of the run's identity
|
|
322
|
+
* (8.8.0). See {@link MemoryDefinition.corpus}.
|
|
323
|
+
*/
|
|
324
|
+
readonly corpus?: MemoryIdentity;
|
|
325
|
+
/**
|
|
326
|
+
* Build a read-only memory (8.8.0): no write subflow is compiled, so
|
|
327
|
+
* nothing this memory sees is ever stored back.
|
|
328
|
+
*
|
|
329
|
+
* The reason it exists: a retrieval corpus and a conversation log are
|
|
330
|
+
* two different things sharing one pipeline. Writing the conversation
|
|
331
|
+
* into the corpus makes the user's own question the best-scoring
|
|
332
|
+
* "document" in it. `defineRAG` sets this.
|
|
333
|
+
*/
|
|
334
|
+
readonly readOnly?: boolean;
|
|
335
|
+
/** Which claim the injected block makes. See {@link MemoryDefinition.flavor}. */
|
|
336
|
+
readonly flavor?: MemoryFlavor;
|
|
259
337
|
}
|
|
260
338
|
export interface DefineEpisodicOptions extends DefineMemoryOptionsBase {
|
|
261
339
|
readonly type: typeof MEMORY_TYPES.EPISODIC;
|
|
@@ -286,4 +364,18 @@ export declare function isSnapshotProjection(value: string): value is SnapshotPr
|
|
|
286
364
|
export declare const MEMORY_INJECTION_KEY_PREFIX: "memoryInjection_";
|
|
287
365
|
export declare function memoryInjectionKey(id: string): string;
|
|
288
366
|
export declare function isMemoryInjectionKey(key: string): boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Scope-key prefix for the retrieval record a memory lifts to the parent
|
|
369
|
+
* scope (8.8.0), one key per memory id — the same layering rule as
|
|
370
|
+
* `memoryInjection_`.
|
|
371
|
+
*
|
|
372
|
+
* This key is the reason a backward slice can now reach a passage. It is
|
|
373
|
+
* ORDINARY root state, so `sliceForKey('finalContent')` walks the
|
|
374
|
+
* system-prompt write, and the record naming every candidate id and score
|
|
375
|
+
* is one hop away. Before 8.8.0 the scores existed only inside the memory
|
|
376
|
+
* subflow, which the root commit log never sees.
|
|
377
|
+
*/
|
|
378
|
+
export declare const RETRIEVAL_EVIDENCE_KEY_PREFIX: "retrievalEvidence_";
|
|
379
|
+
export declare function retrievalEvidenceKey(id: string): string;
|
|
380
|
+
export declare function isRetrievalEvidenceKey(key: string): boolean;
|
|
289
381
|
//# sourceMappingURL=define.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.types.d.ts","sourceRoot":"","sources":["../../../src/memory/define.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"define.types.d.ts","sourceRoot":"","sources":["../../../src/memory/define.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI9D;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAC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@@
|
|
|
1
|
+
/**
|
|
2
|
+
* emitEmbedding — one place that reports an embedding call.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: leaf helper over the emit channel.
|
|
5
|
+
* Role: memory/ layer. Both halves of the two-phase cost model go through
|
|
6
|
+
* it — `embedMessages` reports `'document'`, `loadRelevant` reports
|
|
7
|
+
* `'query'` — so the two can never drift into describing the same
|
|
8
|
+
* fact two different ways.
|
|
9
|
+
* Emits: `agentfootprint.embedding.generated`.
|
|
10
|
+
*
|
|
11
|
+
* ── Why this event matters more than it looks ───────────────────────────────
|
|
12
|
+
* Embedding cost is not one number. **Index time** embeds the corpus: it
|
|
13
|
+
* happens once, and its cost scales with how much you store. **Query time**
|
|
14
|
+
* embeds the user's question: it happens per retrieval, and its cost scales
|
|
15
|
+
* with traffic. `inputKind` is the field that separates them, and separating
|
|
16
|
+
* them is what makes "should this corpus live in a file?" a question with an
|
|
17
|
+
* arithmetic answer instead of a feeling.
|
|
18
|
+
*
|
|
19
|
+
* The payload has been declared since 2.x and nothing emitted it, so any
|
|
20
|
+
* dashboard built against it has been reading a flat line that meant "not
|
|
21
|
+
* wired", not "no cost".
|
|
22
|
+
*
|
|
23
|
+
* Telemetry rides the EMIT channel, never a commit payload — a cost report is
|
|
24
|
+
* an observation about a stage, not state the next stage reads.
|
|
25
|
+
*/
|
|
26
|
+
import type { TypedScope } from 'footprintjs';
|
|
27
|
+
import type { EmbeddingGeneratedPayload } from '../../events/payloads.js';
|
|
28
|
+
/**
|
|
29
|
+
* Fire the event when the scope has an emit channel, and do nothing when it
|
|
30
|
+
* does not.
|
|
31
|
+
*
|
|
32
|
+
* A memory pipeline can be mounted outside an Agent (`mountMemoryRead` on a
|
|
33
|
+
* bare flowchart), and a stage that threw because nobody was listening would
|
|
34
|
+
* make observability a requirement rather than an option.
|
|
35
|
+
*/
|
|
36
|
+
export declare function emitEmbedding(scope: TypedScope<Record<string, unknown>> | {
|
|
37
|
+
$emit?: unknown;
|
|
38
|
+
}, payload: EmbeddingGeneratedPayload): void;
|
|
39
|
+
//# sourceMappingURL=emitEmbedding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitEmbedding.d.ts","sourceRoot":"","sources":["../../../../src/memory/embedding/emitEmbedding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAE1E;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,EAChE,OAAO,EAAE,yBAAyB,GACjC,IAAI,CAKN"}
|
|
@@ -1,29 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* loadRelevant — read-side stage that embeds a query and fetches the
|
|
3
|
-
*
|
|
3
|
+
* most similar entries from a vector-capable `MemoryStore`.
|
|
4
4
|
*
|
|
5
|
-
* Reads from scope: `identity`, `
|
|
6
|
-
* Writes to scope: `loaded` (MemoryEntry[], ordered best-first —
|
|
7
|
-
*
|
|
5
|
+
* Reads from scope: `identity`, `messages` (or `newMessages`, or custom queryFrom)
|
|
6
|
+
* Writes to scope: `loaded` (MemoryEntry[], ordered best-first — narrowed
|
|
7
|
+
* by `pickByBudget` downstream)
|
|
8
|
+
* `retrieved` (RetrievalEvidence — what was considered,
|
|
9
|
+
* what was admitted, and why about each one)
|
|
8
10
|
*
|
|
9
11
|
* Query derivation:
|
|
10
|
-
* Default: the last user message
|
|
11
|
-
*
|
|
12
|
-
* for custom retrieval (e.g., compose user + assistant content,
|
|
13
|
-
* pull a summary, etc.).
|
|
12
|
+
* Default: the last user message. That's the natural "what is the user
|
|
13
|
+
* asking about?" signal. Override with `queryFrom` for custom retrieval.
|
|
14
14
|
*
|
|
15
15
|
* Empty behavior:
|
|
16
|
-
* No query text → no search → `loaded = []`. Downstream
|
|
17
|
-
*
|
|
16
|
+
* No query text → no search → `loaded = []`. Downstream `pickByBudget`
|
|
17
|
+
* picks nothing and the formatter emits nothing — safe, and now
|
|
18
|
+
* RECORDED: the evidence still lands, saying the query was empty.
|
|
18
19
|
*
|
|
19
20
|
* Feature detection:
|
|
20
|
-
* Throws at stage build time if the store doesn't implement
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* Throws at stage build time if the store doesn't implement `search()`.
|
|
22
|
+
* Fail-loud — a semantic pipeline configured against a non-vector store
|
|
23
|
+
* is a config bug, not a runtime condition.
|
|
24
|
+
*
|
|
25
|
+
* ─── Why the threshold moved out of the store (8.8.0) ──────────────────
|
|
26
|
+
*
|
|
27
|
+
* Until 8.8.0 the quality floor was passed to `store.search({ minScore })`,
|
|
28
|
+
* so every candidate that failed it was filtered INSIDE the store and never
|
|
29
|
+
* came back. The consequence was not a small one: a retrieval that injected
|
|
30
|
+
* nothing left no trace of what it nearly injected, and "why did the agent
|
|
31
|
+
* not read that passage" had no answer anywhere in the recording.
|
|
32
|
+
*
|
|
33
|
+
* The floor is now applied here, over a pool of `k + rejectWindow`. **This
|
|
34
|
+
* does not change which entries are admitted, ever.** Proof: `search`
|
|
35
|
+
* returns score-descending, and the pool is at least `k`. Either
|
|
36
|
+
*
|
|
37
|
+
* (a) every entry in the pool clears the floor — then the admitted set is
|
|
38
|
+
* the first `k` of them, which is exactly what `{ minScore, k }` would
|
|
39
|
+
* have returned; or
|
|
40
|
+
* (b) some entry at position p fails the floor — then every entry after p
|
|
41
|
+
* fails it too, so the pool already contains EVERY entry in the
|
|
42
|
+
* namespace that clears the floor, and admitting all of them (capped
|
|
43
|
+
* at `k`) is again exactly what `{ minScore, k }` would have returned.
|
|
44
|
+
*
|
|
45
|
+
* `rejectWindow` therefore only controls how many near-misses we can SHOW.
|
|
46
|
+
* It cannot change what the model sees.
|
|
23
47
|
*/
|
|
24
48
|
import type { TypedScope } from 'footprintjs';
|
|
25
49
|
import type { MemoryStore } from '../store/index.js';
|
|
26
50
|
import type { MemoryState } from '../stages/index.js';
|
|
51
|
+
import type { RetrievalStrategy } from '../retrieval/types.js';
|
|
27
52
|
import type { Embedder } from './types.js';
|
|
28
53
|
export interface LoadRelevantConfig {
|
|
29
54
|
/** The vector-capable store. Must implement `search()`. */
|
|
@@ -43,10 +68,19 @@ export interface LoadRelevantConfig {
|
|
|
43
68
|
/** Filter results by tier. */
|
|
44
69
|
readonly tiers?: ReadonlyArray<'hot' | 'warm' | 'cold'>;
|
|
45
70
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
71
|
+
* The rule that decides which candidates reach the prompt. Defaults to
|
|
72
|
+
* `topK({ k, threshold: minScore })` — i.e. `k` and `minScore` above are
|
|
73
|
+
* the shorthand, and this is the same rule spelled out. Pass a strategy
|
|
74
|
+
* to replace the rule entirely.
|
|
75
|
+
*/
|
|
76
|
+
readonly retrieval?: RetrievalStrategy;
|
|
77
|
+
/**
|
|
78
|
+
* Extract the query text from scope. Default: the last user message.
|
|
79
|
+
* Override for custom retrieval signals.
|
|
48
80
|
*/
|
|
49
81
|
readonly queryFrom?: (scope: TypedScope<MemoryState>) => string;
|
|
50
82
|
}
|
|
51
83
|
export declare function loadRelevant(config: LoadRelevantConfig): (scope: TypedScope<MemoryState>) => Promise<void>;
|
|
84
|
+
/** Test seam — the once-per-process warning is per PROCESS, which tests must be able to reset. */
|
|
85
|
+
export declare function __resetEmptyCorpusWarnings(): void;
|
|
52
86
|
//# sourceMappingURL=loadRelevant.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadRelevant.d.ts","sourceRoot":"","sources":["../../../../src/memory/embedding/loadRelevant.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"loadRelevant.d.ts","sourceRoot":"","sources":["../../../../src/memory/embedding/loadRelevant.ts"],"names":[],"m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oot":"","sources":["../../../../src/memory/embedding/mockEmbedder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,QAAQ,EAA6B,MAAM,YAAY,CAAC;AAYtE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,QAAQ,
|
|
1
|
+
{"version":3,"file":"mockEmbedder.d.ts","sourceRoot":"","sources":["../../../../src/memory/embedding/mockEmbedder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,QAAQ,EAA6B,MAAM,YAAY,CAAC;AAYtE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,QAAQ,CAmBxE"}
|
|
@@ -35,6 +35,30 @@ export interface EmbedBatchArgs {
|
|
|
35
35
|
export interface Embedder {
|
|
36
36
|
/** Vector length. Constant per embedder instance. */
|
|
37
37
|
readonly dimensions: number;
|
|
38
|
+
/**
|
|
39
|
+
* Stable name of the embedding space this instance produces (8.9.0).
|
|
40
|
+
*
|
|
41
|
+
* Together with `dimensions` it forms the fingerprint a durable store
|
|
42
|
+
* records per vector — `'<id>@<dims>'` — and refuses on when it changes.
|
|
43
|
+
* Cosine similarity between two embedding spaces is not a weak signal; it
|
|
44
|
+
* is not a signal, and it comes back as a confident number in the same
|
|
45
|
+
* range as a real one. A store that can name the space can refuse the mix;
|
|
46
|
+
* one that cannot has to let it through.
|
|
47
|
+
*
|
|
48
|
+
* Optional, because an `Embedder` is a structural interface and every
|
|
49
|
+
* hand-written one predates this field. When it is absent the store falls
|
|
50
|
+
* back to comparing `dimensions` alone, which catches the arithmetically
|
|
51
|
+
* impossible case and not the merely wrong one.
|
|
52
|
+
*
|
|
53
|
+
* Every shipped embedder sets it, and it is what you pass as `embedderId`:
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* const embedder = staticEmbedder();
|
|
57
|
+
* await indexDocuments(store, embedder, docs, { embedderId: embedder.id });
|
|
58
|
+
* defineRAG({ id: 'docs', store, embedder, embedderId: embedder.id });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
readonly id?: string;
|
|
38
62
|
/** Embed a single text into a vector of length `dimensions`. */
|
|
39
63
|
embed(args: EmbedArgs): Promise<number[]>;
|
|
40
64
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/memory/embedding/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,SAAS;IACxB,yBAAyB;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,qDAAqD;IACrD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,gEAAgE;IAChE,KAAK,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAE1C;;;;OAIG;IACH,UAAU,CAAC,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;CACxD"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/memory/embedding/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,SAAS;IACxB,yBAAyB;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,qDAAqD;IACrD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAErB,gEAAgE;IAChE,KAAK,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAE1C;;;;OAIG;IACH,UAAU,CAAC,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;CACxD"}
|
|
@@ -15,7 +15,8 @@ export * from './pipeline/index.js';
|
|
|
15
15
|
export * from './stages/index.js';
|
|
16
16
|
export * from './store/index.js';
|
|
17
17
|
export * from './wire/index.js';
|
|
18
|
-
export
|
|
18
|
+
export * from './retrieval/index.js';
|
|
19
|
+
export { MEMORY_TYPES, MEMORY_STRATEGIES, MEMORY_TIMING, SNAPSHOT_PROJECTIONS, MEMORY_INJECTION_KEY_PREFIX, RETRIEVAL_EVIDENCE_KEY_PREFIX, isMemoryType, isMemoryStrategyKind, isMemoryTiming, isSnapshotProjection, memoryInjectionKey, isMemoryInjectionKey, retrievalEvidenceKey, isRetrievalEvidenceKey, type MemoryType, type MemoryStrategyKind, type MemoryTiming, type SnapshotProjection, type Strategy, type MemoryWindowStrategy, type BudgetStrategy, type SummarizeStrategy, type TopKStrategy, type TopKShorthandStrategy, type TopKRetrievalStrategy, type MemoryFlavor, type ExtractStrategy, type DecayStrategy, type HybridStrategy, type MemoryDefinition, type DefineMemoryOptions, type DefineEpisodicOptions, type DefineSemanticOptions, type DefineNarrativeOptions, type DefineCausalOptions, type MemoryRedactionPolicy, } from './define.types.js';
|
|
19
20
|
/**
|
|
20
21
|
* @deprecated Since 7.27.1 — use `MemoryWindowStrategy`.
|
|
21
22
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/memory/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/memory/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AAGrC,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,2BAA2B,EAC3B,6BAA6B,EAC7B,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,GAC3B,MAAM,mBAAmB,CAAC;AAC3B;;;;;;;;GAQG;AACH,YAAY,EAAE,oBAAoB,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type MemoryFormatFlavor } from '../stages/formatDefault.js';
|
|
2
|
+
import type { RetrievalStrategy } from '../retrieval/types.js';
|
|
1
3
|
import type { MemoryStore } from '../store/index.js';
|
|
2
4
|
import type { MemoryPipeline } from './types.js';
|
|
3
5
|
import type { Embedder } from '../embedding/types.js';
|
|
@@ -29,6 +31,19 @@ export interface SemanticPipelineConfig {
|
|
|
29
31
|
/** Forwarded to `formatDefault`. */
|
|
30
32
|
readonly formatHeader?: string;
|
|
31
33
|
readonly formatFooter?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The retrieval rule (8.8.0). Replaces `k` + `minScore` above; see
|
|
36
|
+
* {@link RetrievalStrategy}. When absent, `topK({ k, threshold: minScore })`
|
|
37
|
+
* is built from those two — the same rule, spelled the old way.
|
|
38
|
+
*/
|
|
39
|
+
readonly retrieval?: RetrievalStrategy;
|
|
40
|
+
/**
|
|
41
|
+
* Which claim the injected block makes (8.8.0). `'rag'` renders each
|
|
42
|
+
* entry as a citable `<source>` with its document, page and score;
|
|
43
|
+
* `'memory'` (default) keeps the conversation-recall `<memory>` shape
|
|
44
|
+
* byte for byte.
|
|
45
|
+
*/
|
|
46
|
+
readonly flavor?: MemoryFormatFlavor;
|
|
32
47
|
}
|
|
33
48
|
/**
|
|
34
49
|
* Build the semantic read + write pipelines sharing a single store.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semantic.d.ts","sourceRoot":"","sources":["../../../../src/memory/pipeline/semantic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"semantic.d.ts","sourceRoot":"","sources":["../../../../src/memory/pipeline/semantic.ts"],"names":[],"mappings":"AAwCA,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAQjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,WAAW,sBAAsB;IACrC,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAE5B,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAE5B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B,8EAA8E;IAC9E,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAEpB,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B,iCAAiC;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC;IAExD,+BAA+B;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IAE7C,oDAAoD;IACpD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B,mCAAmC;IACnC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B,oCAAoC;IACpC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAEvC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,cAAc,CAsE/E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memory/retrieval — what a retrieval considered, and the seam that
|
|
3
|
+
* decides what it keeps.
|
|
4
|
+
*
|
|
5
|
+
* @see ./types.ts the record + the strategy interface
|
|
6
|
+
* @see ./topK.ts the strategy 8.7.0 had, now written down as one
|
|
7
|
+
*/
|
|
8
|
+
export type { RetrievalEvidence, RetrievalRejectReason, RetrievalStrategy, RetrievalVerdict, RetrievedCandidate, ScoredCandidate, } from './types.js';
|
|
9
|
+
export { topK, type TopKOptions } from './topK.js';
|
|
10
|
+
export { chunkProvenance, chunkText, type ChunkProvenance } from './provenance.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/memory/retrieval/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,YAAY,EACV,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* provenance — read a stored entry's coordinates back out of it.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: pure projection.
|
|
5
|
+
* Role: memory/ layer. One place that knows which metadata keys mean
|
|
6
|
+
* "which document", "which page", "which section", so the
|
|
7
|
+
* retrieval record and the citation the model sees can never
|
|
8
|
+
* disagree about a chunk's origin.
|
|
9
|
+
* Emits: N/A.
|
|
10
|
+
*
|
|
11
|
+
* The keys are the ones `indexDocuments` already accepts on
|
|
12
|
+
* `RagDocument.metadata`, and the ones a document splitter will write.
|
|
13
|
+
* Nothing is invented: an entry that carries no metadata simply has no
|
|
14
|
+
* coordinates, and the record says so by omitting the fields rather than
|
|
15
|
+
* by guessing a filename from an id.
|
|
16
|
+
*/
|
|
17
|
+
/** The document coordinates a chunk can carry. All optional — absence is honest. */
|
|
18
|
+
export interface ChunkProvenance {
|
|
19
|
+
/** Which document this text came from. Read from `docUri`, else `source`. */
|
|
20
|
+
readonly docUri?: string;
|
|
21
|
+
/** Which page, for paginated formats. */
|
|
22
|
+
readonly page?: number;
|
|
23
|
+
/** Which section heading the splitter cut under. */
|
|
24
|
+
readonly heading?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Pull the coordinates out of a stored value.
|
|
28
|
+
*
|
|
29
|
+
* Accepts metadata at the value's `metadata` key (where `indexDocuments`
|
|
30
|
+
* puts it) or directly on the value, so a hand-built entry works too.
|
|
31
|
+
*/
|
|
32
|
+
export declare function chunkProvenance(value: unknown): ChunkProvenance;
|
|
33
|
+
/**
|
|
34
|
+
* The text a stored value carries.
|
|
35
|
+
*
|
|
36
|
+
* Two shapes reach the formatter through the same pipeline: a chat
|
|
37
|
+
* `Message` (`{ role, content }`) from conversation memory, and a
|
|
38
|
+
* document (`{ id, content, metadata }`) from `indexDocuments`. Both
|
|
39
|
+
* keep their text on `content`, which is why one accessor serves both —
|
|
40
|
+
* but only the message shape has a meaningful `role`, which is why the
|
|
41
|
+
* corpus formatter does not print one.
|
|
42
|
+
*/
|
|
43
|
+
export declare function chunkText(value: unknown): string;
|
|
44
|
+
//# sourceMappingURL=provenance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provenance.d.ts","sourceRoot":"","sources":["../../../../src/memory/retrieval/provenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,oFAAoF;AACpF,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAQD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAmB/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAIhD"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* topK — the retrieval strategy agentfootprint has always used, now
|
|
3
|
+
* written down as one.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: Strategy (one of {@link RetrievalStrategy}).
|
|
6
|
+
* Role: memory/ layer. Extracted in 8.8.0 from the two numbers that
|
|
7
|
+
* used to live loose on `defineRAG` (`topK`, `threshold`), so
|
|
8
|
+
* that a different rule can be written without touching a stage.
|
|
9
|
+
* Emits: N/A — the stage that calls it does the emitting.
|
|
10
|
+
*
|
|
11
|
+
* Behaviour is byte-for-byte what 8.7.0 did: take the highest-scoring
|
|
12
|
+
* candidates that clear `threshold`, at most `k` of them, and inject
|
|
13
|
+
* nothing at all when none clear it.
|
|
14
|
+
*
|
|
15
|
+
* **The threshold is strict, and strict means silent-by-design becomes
|
|
16
|
+
* loud-by-record.** When nothing clears the floor, no context is
|
|
17
|
+
* injected — a weak match in the prompt makes a confident wrong answer
|
|
18
|
+
* more likely, not less. What 8.8.0 changes is that the near-misses are
|
|
19
|
+
* now IN the record with their scores, so "the agent answered from
|
|
20
|
+
* nothing" is a readable outcome instead of an absence.
|
|
21
|
+
*/
|
|
22
|
+
import type { RetrievalStrategy } from './types.js';
|
|
23
|
+
export interface TopKOptions {
|
|
24
|
+
/**
|
|
25
|
+
* How many chunks may reach the prompt. Default 3 — enough for more
|
|
26
|
+
* than one perspective, few enough that the middle of a long context
|
|
27
|
+
* does not swallow the answer.
|
|
28
|
+
*/
|
|
29
|
+
readonly k?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Minimum similarity to admit, in the store's score space ([-1, 1]
|
|
32
|
+
* cosine for every shipped store). Default 0.7.
|
|
33
|
+
*
|
|
34
|
+
* 0.7 is a high bar for some embedders. Sentence-transformer relatives
|
|
35
|
+
* (`all-MiniLM-L6-v2` and family, which `localEmbedder` uses by
|
|
36
|
+
* default) often score 0.4–0.6 on genuinely relevant chunks; OpenAI
|
|
37
|
+
* `text-embedding-3-*` sits comfortably at 0.7. If retrievals come back
|
|
38
|
+
* empty, read the `agentfootprint.memory.retrieved` event: it now
|
|
39
|
+
* carries the rejected candidates and their scores, so the right
|
|
40
|
+
* threshold is a number you can see rather than one you guess.
|
|
41
|
+
*
|
|
42
|
+
* Pass `null` for no floor — every candidate up to `k` is admitted.
|
|
43
|
+
*/
|
|
44
|
+
readonly threshold?: number | null;
|
|
45
|
+
/**
|
|
46
|
+
* How many extra candidates to pull past `k` so that rejected ones can
|
|
47
|
+
* be reported. Default 10. Raising it costs one larger read and shows
|
|
48
|
+
* more near-misses; it can never change which candidates are admitted.
|
|
49
|
+
*/
|
|
50
|
+
readonly rejectWindow?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Build the top-K strategy.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { defineRAG } from 'agentfootprint';
|
|
58
|
+
* import { topK } from 'agentfootprint/memory';
|
|
59
|
+
*
|
|
60
|
+
* const docs = defineRAG({
|
|
61
|
+
* id: 'product-docs',
|
|
62
|
+
* store, embedder,
|
|
63
|
+
* retrieval: topK({ k: 5, threshold: 0.55 }),
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function topK(options?: TopKOptions): RetrievalStrategy;
|
|
68
|
+
//# sourceMappingURL=topK.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topK.d.ts","sourceRoot":"","sources":["../../../../src/memory/retrieval/topK.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,YAAY,CAAC;AAEvF,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,iBAAiB,CA6CjE"}
|