agentfootprint 2.2.0 → 2.3.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 (154) hide show
  1. package/AGENTS.md +52 -0
  2. package/CLAUDE.md +52 -0
  3. package/README.md +49 -0
  4. package/README.proposed.md +258 -0
  5. package/ai-instructions/claude-code/SKILL.md +24 -5
  6. package/ai-instructions/clinerules +22 -5
  7. package/ai-instructions/copilot-instructions.md +22 -5
  8. package/ai-instructions/cursor/agentfootprint.md +22 -5
  9. package/ai-instructions/kiro/agentfootprint.md +22 -5
  10. package/ai-instructions/windsurfrules +22 -5
  11. package/dist/adapters/llm/AnthropicProvider.js +0 -31
  12. package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
  13. package/dist/adapters/llm/BedrockProvider.js +2 -28
  14. package/dist/adapters/llm/BedrockProvider.js.map +1 -1
  15. package/dist/adapters/llm/BrowserAnthropicProvider.js +1 -31
  16. package/dist/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  17. package/dist/adapters/llm/BrowserOpenAIProvider.js +1 -11
  18. package/dist/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  19. package/dist/adapters/llm/MockProvider.js +35 -1
  20. package/dist/adapters/llm/MockProvider.js.map +1 -1
  21. package/dist/adapters/llm/OpenAIProvider.js +3 -29
  22. package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
  23. package/dist/adapters/memory/agentcore.js +305 -0
  24. package/dist/adapters/memory/agentcore.js.map +1 -0
  25. package/dist/adapters/memory/redis.js +287 -0
  26. package/dist/adapters/memory/redis.js.map +1 -0
  27. package/dist/esm/adapters/llm/AnthropicProvider.js +0 -31
  28. package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
  29. package/dist/esm/adapters/llm/BedrockProvider.js +2 -28
  30. package/dist/esm/adapters/llm/BedrockProvider.js.map +1 -1
  31. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js +1 -31
  32. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  33. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +1 -11
  34. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  35. package/dist/esm/adapters/llm/MockProvider.js +35 -1
  36. package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
  37. package/dist/esm/adapters/llm/OpenAIProvider.js +3 -29
  38. package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
  39. package/dist/esm/adapters/memory/agentcore.js +301 -0
  40. package/dist/esm/adapters/memory/agentcore.js.map +1 -0
  41. package/dist/esm/adapters/memory/redis.js +283 -0
  42. package/dist/esm/adapters/memory/redis.js.map +1 -0
  43. package/dist/esm/index.js +2 -2
  44. package/dist/esm/index.js.map +1 -1
  45. package/dist/esm/lib/injection-engine/index.js +0 -54
  46. package/dist/esm/lib/injection-engine/index.js.map +1 -1
  47. package/dist/esm/lib/mcp/index.js +1 -0
  48. package/dist/esm/lib/mcp/index.js.map +1 -1
  49. package/dist/esm/lib/mcp/mcpClient.js +29 -24
  50. package/dist/esm/lib/mcp/mcpClient.js.map +1 -1
  51. package/dist/esm/lib/mcp/mockMcpClient.js +97 -0
  52. package/dist/esm/lib/mcp/mockMcpClient.js.map +1 -0
  53. package/dist/esm/lib/rag/defineRAG.js +0 -18
  54. package/dist/esm/lib/rag/defineRAG.js.map +1 -1
  55. package/dist/esm/lib/rag/indexDocuments.js +39 -4
  56. package/dist/esm/lib/rag/indexDocuments.js.map +1 -1
  57. package/dist/esm/memory/causal/loadSnapshot.js +1 -1
  58. package/dist/esm/memory/define.js +0 -14
  59. package/dist/esm/memory/define.js.map +1 -1
  60. package/dist/esm/memory/define.types.js +0 -10
  61. package/dist/esm/memory/define.types.js.map +1 -1
  62. package/dist/esm/resilience/index.js +0 -44
  63. package/dist/esm/resilience/index.js.map +1 -1
  64. package/dist/esm/stream.js +0 -29
  65. package/dist/esm/stream.js.map +1 -1
  66. package/dist/index.js +2 -1
  67. package/dist/index.js.map +1 -1
  68. package/dist/instructions.js +21 -0
  69. package/dist/instructions.js.map +1 -0
  70. package/dist/lib/injection-engine/index.js +0 -54
  71. package/dist/lib/injection-engine/index.js.map +1 -1
  72. package/dist/lib/instructions/defineInstruction.js +35 -0
  73. package/dist/lib/instructions/defineInstruction.js.map +1 -0
  74. package/dist/lib/instructions/evaluator.js +38 -0
  75. package/dist/lib/instructions/evaluator.js.map +1 -0
  76. package/dist/lib/instructions/index.js +48 -0
  77. package/dist/lib/instructions/index.js.map +1 -0
  78. package/dist/lib/instructions/types.js +22 -0
  79. package/dist/lib/instructions/types.js.map +1 -0
  80. package/dist/lib/mcp/index.js +3 -1
  81. package/dist/lib/mcp/index.js.map +1 -1
  82. package/dist/lib/mcp/mcpClient.js +29 -24
  83. package/dist/lib/mcp/mcpClient.js.map +1 -1
  84. package/dist/lib/mcp/mockMcpClient.js +101 -0
  85. package/dist/lib/mcp/mockMcpClient.js.map +1 -0
  86. package/dist/lib/rag/defineRAG.js +0 -18
  87. package/dist/lib/rag/defineRAG.js.map +1 -1
  88. package/dist/lib/rag/indexDocuments.js +39 -4
  89. package/dist/lib/rag/indexDocuments.js.map +1 -1
  90. package/dist/memory/causal/loadSnapshot.js +1 -1
  91. package/dist/memory/conversationHelpers.js +39 -0
  92. package/dist/memory/conversationHelpers.js.map +1 -0
  93. package/dist/memory/define.js +0 -14
  94. package/dist/memory/define.js.map +1 -1
  95. package/dist/memory/define.types.js +0 -10
  96. package/dist/memory/define.types.js.map +1 -1
  97. package/dist/resilience/index.js +0 -44
  98. package/dist/resilience/index.js.map +1 -1
  99. package/dist/stream.js +0 -29
  100. package/dist/stream.js.map +1 -1
  101. package/dist/types/adapters/llm/AnthropicProvider.d.ts +0 -31
  102. package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
  103. package/dist/types/adapters/llm/BedrockProvider.d.ts +2 -28
  104. package/dist/types/adapters/llm/BedrockProvider.d.ts.map +1 -1
  105. package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts +1 -31
  106. package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts.map +1 -1
  107. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +1 -11
  108. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts.map +1 -1
  109. package/dist/types/adapters/llm/MockProvider.d.ts +45 -0
  110. package/dist/types/adapters/llm/MockProvider.d.ts.map +1 -1
  111. package/dist/types/adapters/llm/OpenAIProvider.d.ts +3 -29
  112. package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
  113. package/dist/types/adapters/memory/agentcore.d.ts +157 -0
  114. package/dist/types/adapters/memory/agentcore.d.ts.map +1 -0
  115. package/dist/types/adapters/memory/redis.d.ts +126 -0
  116. package/dist/types/adapters/memory/redis.d.ts.map +1 -0
  117. package/dist/types/index.d.ts +2 -2
  118. package/dist/types/index.d.ts.map +1 -1
  119. package/dist/types/instructions.d.ts +5 -0
  120. package/dist/types/instructions.d.ts.map +1 -0
  121. package/dist/types/lib/injection-engine/index.d.ts +0 -54
  122. package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
  123. package/dist/types/lib/instructions/defineInstruction.d.ts +22 -0
  124. package/dist/types/lib/instructions/defineInstruction.d.ts.map +1 -0
  125. package/dist/types/lib/instructions/evaluator.d.ts +11 -0
  126. package/dist/types/lib/instructions/evaluator.d.ts.map +1 -0
  127. package/dist/types/lib/instructions/index.d.ts +44 -0
  128. package/dist/types/lib/instructions/index.d.ts.map +1 -0
  129. package/dist/types/lib/instructions/types.d.ts +100 -0
  130. package/dist/types/lib/instructions/types.d.ts.map +1 -0
  131. package/dist/types/lib/mcp/index.d.ts +1 -0
  132. package/dist/types/lib/mcp/index.d.ts.map +1 -1
  133. package/dist/types/lib/mcp/mcpClient.d.ts +0 -17
  134. package/dist/types/lib/mcp/mcpClient.d.ts.map +1 -1
  135. package/dist/types/lib/mcp/mockMcpClient.d.ts +66 -0
  136. package/dist/types/lib/mcp/mockMcpClient.d.ts.map +1 -0
  137. package/dist/types/lib/mcp/types.d.ts +2 -0
  138. package/dist/types/lib/mcp/types.d.ts.map +1 -1
  139. package/dist/types/lib/rag/defineRAG.d.ts +18 -21
  140. package/dist/types/lib/rag/defineRAG.d.ts.map +1 -1
  141. package/dist/types/lib/rag/indexDocuments.d.ts +30 -1
  142. package/dist/types/lib/rag/indexDocuments.d.ts.map +1 -1
  143. package/dist/types/memory/causal/loadSnapshot.d.ts +1 -1
  144. package/dist/types/memory/conversationHelpers.d.ts +19 -0
  145. package/dist/types/memory/conversationHelpers.d.ts.map +1 -0
  146. package/dist/types/memory/define.d.ts +0 -14
  147. package/dist/types/memory/define.d.ts.map +1 -1
  148. package/dist/types/memory/define.types.d.ts +2 -12
  149. package/dist/types/memory/define.types.d.ts.map +1 -1
  150. package/dist/types/resilience/index.d.ts +0 -44
  151. package/dist/types/resilience/index.d.ts.map +1 -1
  152. package/dist/types/stream.d.ts +0 -29
  153. package/dist/types/stream.d.ts.map +1 -1
  154. package/package.json +20 -1
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+ /**
3
+ * AgentCoreStore — AWS Bedrock AgentCore Memory adapter (peer-dep
4
+ * `@aws-sdk/client-bedrock-agent-runtime`).
5
+ *
6
+ * Subpath import: `agentfootprint/memory-agentcore`.
7
+ *
8
+ * import { AgentCoreStore } from 'agentfootprint/memory-agentcore';
9
+ * const store = new AgentCoreStore({
10
+ * memoryId: 'arn:aws:bedrock:us-east-1:...:memory/my-mem',
11
+ * region: 'us-east-1',
12
+ * });
13
+ *
14
+ * Pattern: Adapter (GoF) — translates the `MemoryStore` interface onto
15
+ * AgentCore Memory's session/event model:
16
+ * MemoryIdentity ↔ AgentCore session (sessionId derived
17
+ * from the identity tuple)
18
+ * MemoryEntry ↔ AgentCore event payload (JSON
19
+ * envelope keyed by entry id)
20
+ * putIfVersion ↔ unsupported by AgentCore natively;
21
+ * emulated via list+CAS at adapter level
22
+ * seen / signatures ↔ in-process LRU shadow (AgentCore has
23
+ * no built-in dedup primitive)
24
+ * feedback ↔ in-process accumulator (AgentCore
25
+ * doesn't expose a feedback metric API)
26
+ * search ↔ NOT exposed in v2.3 — AgentCore's
27
+ * retrieve API is opaque (server-side
28
+ * retrieval pipeline). Will land as
29
+ * `agentcoreRetrieve()` in a later release.
30
+ *
31
+ * Role: Outer ring. Lazy-requires the AWS SDK; no runtime cost when
32
+ * another adapter is in use.
33
+ * Emits: N/A (storage adapters don't emit; recorders observe the
34
+ * memory pipeline that calls them).
35
+ *
36
+ * **Caveats** — call out before adopting:
37
+ * 1. AgentCore is session/event-based with built-in summarization.
38
+ * Mixing `defineMemory({ strategy: SUMMARIZE })` on top will
39
+ * double-compress. Pick one summarizer.
40
+ * 2. Optimistic-concurrency `putIfVersion` is emulated; under high
41
+ * concurrent write rates the CAS window is wider than RedisStore.
42
+ * Single-writer scenarios (one server process per session) are
43
+ * fine.
44
+ * 3. seen/feedback are in-process — they don't survive process restart.
45
+ * For durable recognition, implement at a higher layer or use Redis.
46
+ * 4. AWS rate limits apply. Production deployments should wrap with
47
+ * `withRetry` and budget calls per session.
48
+ */
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.AgentCoreStore = void 0;
51
+ const index_js_1 = require("../../memory/identity/index.js");
52
+ /**
53
+ * AgentCore Memory-backed `MemoryStore`. Implements every method
54
+ * except `search()`. Vector retrieval via AgentCore's native API
55
+ * lands as a separate read-side helper in a later release.
56
+ *
57
+ * @throws when `@aws-sdk/client-bedrock-agent-runtime` is not
58
+ * installed and no `_client` is supplied.
59
+ */
60
+ class AgentCoreStore {
61
+ client;
62
+ memoryId;
63
+ pageSize;
64
+ closed = false;
65
+ // In-process shadow state for things AgentCore doesn't surface
66
+ // natively — see file-level docstring for caveats.
67
+ signatures = new Map();
68
+ feedbackBag = new Map();
69
+ constructor(options) {
70
+ if (!options.memoryId) {
71
+ throw new Error('AgentCoreStore requires `memoryId`.');
72
+ }
73
+ this.memoryId = options.memoryId;
74
+ this.pageSize = options.pageSize ?? 50;
75
+ if (options._client) {
76
+ this.client = options._client;
77
+ }
78
+ else if (options.client) {
79
+ this.client = options.client;
80
+ }
81
+ else {
82
+ this.client = createAgentCoreClient(options.region);
83
+ }
84
+ }
85
+ // Identity → AgentCore session id. Stable, deterministic, isolating.
86
+ sessionId(identity) {
87
+ return `afp:${(0, index_js_1.identityNamespace)(identity)}`;
88
+ }
89
+ // Shadow-state keys (in-process Maps)
90
+ shadowKey(identity) {
91
+ return (0, index_js_1.identityNamespace)(identity);
92
+ }
93
+ feedbackKey(identity, id) {
94
+ return `${(0, index_js_1.identityNamespace)(identity)}::${id}`;
95
+ }
96
+ // ── MemoryStore implementation ──────────────────────────────────
97
+ async get(identity, id) {
98
+ this.ensureOpen('get');
99
+ const r = await this.client.getEvent({
100
+ memoryId: this.memoryId,
101
+ sessionId: this.sessionId(identity),
102
+ eventId: id,
103
+ });
104
+ if (!r || !r.payload)
105
+ return null;
106
+ const entry = parseEntry(r.payload);
107
+ if (!entry)
108
+ return null;
109
+ if (entry.ttl !== undefined && entry.ttl <= Date.now())
110
+ return null;
111
+ return entry;
112
+ }
113
+ async put(identity, entry) {
114
+ this.ensureOpen('put');
115
+ if (entry.ttl !== undefined && entry.ttl <= Date.now())
116
+ return;
117
+ await this.client.putEvent({
118
+ memoryId: this.memoryId,
119
+ sessionId: this.sessionId(identity),
120
+ eventId: entry.id,
121
+ payload: JSON.stringify(entry),
122
+ });
123
+ }
124
+ async putMany(identity, entries) {
125
+ this.ensureOpen('putMany');
126
+ if (entries.length === 0)
127
+ return;
128
+ // AgentCore has no batch-write API; sequentialize and let AWS SDK
129
+ // retry policy handle backoff. Production callers should set a
130
+ // sane `maxConcurrency` upstream rather than parallelizing here
131
+ // (per-session events are conceptually ordered).
132
+ for (const entry of entries) {
133
+ await this.put(identity, entry);
134
+ }
135
+ }
136
+ /**
137
+ * Emulated optimistic concurrency. AgentCore's PutEvent overwrites
138
+ * unconditionally. We read-then-write inside a JS critical section
139
+ * — adequate for single-writer-per-session deployments. For multi-
140
+ * writer correctness on AgentCore, layer your own coordination.
141
+ */
142
+ async putIfVersion(identity, entry, expectedVersion) {
143
+ this.ensureOpen('putIfVersion');
144
+ const current = await this.get(identity, entry.id);
145
+ if (current === null) {
146
+ if (expectedVersion !== 0)
147
+ return { applied: false };
148
+ }
149
+ else if (current.version !== expectedVersion) {
150
+ return { applied: false, currentVersion: current.version };
151
+ }
152
+ await this.put(identity, entry);
153
+ return { applied: true };
154
+ }
155
+ async list(identity, options = {}) {
156
+ this.ensureOpen('list');
157
+ const page = await this.client.listEvents({
158
+ memoryId: this.memoryId,
159
+ sessionId: this.sessionId(identity),
160
+ ...(options.cursor !== undefined && { nextToken: options.cursor }),
161
+ maxResults: options.limit ?? this.pageSize,
162
+ });
163
+ const out = [];
164
+ for (const ev of page.events) {
165
+ const entry = parseEntry(ev.payload);
166
+ if (!entry)
167
+ continue;
168
+ if (entry.ttl !== undefined && entry.ttl <= Date.now())
169
+ continue;
170
+ if (options.tiers && (!entry.tier || !options.tiers.includes(entry.tier)))
171
+ continue;
172
+ out.push(entry);
173
+ }
174
+ return page.nextToken ? { entries: out, cursor: page.nextToken } : { entries: out };
175
+ }
176
+ async delete(identity, id) {
177
+ this.ensureOpen('delete');
178
+ await this.client.deleteEvent({
179
+ memoryId: this.memoryId,
180
+ sessionId: this.sessionId(identity),
181
+ eventId: id,
182
+ });
183
+ this.feedbackBag.delete(this.feedbackKey(identity, id));
184
+ }
185
+ async seen(identity, signature) {
186
+ this.ensureOpen('seen');
187
+ return this.signatures.get(this.shadowKey(identity))?.has(signature) ?? false;
188
+ }
189
+ async recordSignature(identity, signature) {
190
+ this.ensureOpen('recordSignature');
191
+ const key = this.shadowKey(identity);
192
+ const set = this.signatures.get(key) ?? new Set();
193
+ set.add(signature);
194
+ this.signatures.set(key, set);
195
+ }
196
+ async feedback(identity, id, usefulness) {
197
+ this.ensureOpen('feedback');
198
+ if (!Number.isFinite(usefulness))
199
+ return;
200
+ const clamped = Math.max(-1, Math.min(1, usefulness));
201
+ const key = this.feedbackKey(identity, id);
202
+ const cur = this.feedbackBag.get(key) ?? { sum: 0, count: 0 };
203
+ this.feedbackBag.set(key, { sum: cur.sum + clamped, count: cur.count + 1 });
204
+ }
205
+ async getFeedback(identity, id) {
206
+ this.ensureOpen('getFeedback');
207
+ const cur = this.feedbackBag.get(this.feedbackKey(identity, id));
208
+ if (!cur || cur.count === 0)
209
+ return null;
210
+ return { average: cur.sum / cur.count, count: cur.count };
211
+ }
212
+ async forget(identity) {
213
+ this.ensureOpen('forget');
214
+ await this.client.deleteSession({
215
+ memoryId: this.memoryId,
216
+ sessionId: this.sessionId(identity),
217
+ });
218
+ // Drop shadow state too — the GDPR contract is "everything for
219
+ // this identity, gone."
220
+ const shadowKey = this.shadowKey(identity);
221
+ this.signatures.delete(shadowKey);
222
+ for (const key of [...this.feedbackBag.keys()]) {
223
+ if (key.startsWith(`${shadowKey}::`))
224
+ this.feedbackBag.delete(key);
225
+ }
226
+ }
227
+ /**
228
+ * Mark the store closed. Subsequent calls throw cleanly. Idempotent.
229
+ * AgentCore is stateless from the client perspective so there's no
230
+ * connection to tear down — the close gate is purely defensive.
231
+ */
232
+ async close() {
233
+ if (this.closed)
234
+ return;
235
+ this.closed = true;
236
+ }
237
+ ensureOpen(op) {
238
+ if (this.closed) {
239
+ throw new Error(`AgentCoreStore.${op}() called after close().`);
240
+ }
241
+ }
242
+ }
243
+ exports.AgentCoreStore = AgentCoreStore;
244
+ // Helpers
245
+ function parseEntry(raw) {
246
+ try {
247
+ return JSON.parse(raw);
248
+ }
249
+ catch {
250
+ return null;
251
+ }
252
+ }
253
+ /**
254
+ * Build a thin shim over the AWS SDK that conforms to AgentCoreLikeClient.
255
+ *
256
+ * Note on SDK API stability: AgentCore Memory's command names may
257
+ * evolve. The shim depends only on the request/response shapes our
258
+ * adapter needs; if AWS renames commands, only this function needs
259
+ * an update.
260
+ */
261
+ function createAgentCoreClient(region) {
262
+ let mod;
263
+ try {
264
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
265
+ mod = require('@aws-sdk/client-bedrock-agent-runtime');
266
+ }
267
+ catch {
268
+ throw new Error('AgentCoreStore requires the `@aws-sdk/client-bedrock-agent-runtime` peer dependency.\n' +
269
+ ' Install: npm install @aws-sdk/client-bedrock-agent-runtime\n' +
270
+ ' Or pass `_client` for test injection.');
271
+ }
272
+ if (!mod.BedrockAgentRuntimeClient) {
273
+ throw new Error('AgentCoreStore: `@aws-sdk/client-bedrock-agent-runtime` is installed but ' +
274
+ '`BedrockAgentRuntimeClient` was not found. Update the SDK to a version that ' +
275
+ 'exports the AgentCore Memory commands.');
276
+ }
277
+ const sdkClient = new mod.BedrockAgentRuntimeClient({ ...(region && { region }) });
278
+ const dispatch = async (CommandCtor, input) => {
279
+ if (!CommandCtor) {
280
+ throw new Error('AgentCoreStore: this version of `@aws-sdk/client-bedrock-agent-runtime` ' +
281
+ 'does not expose the required Memory command. Upgrade the SDK.');
282
+ }
283
+ const cmd = new CommandCtor(input);
284
+ return await sdkClient.send(cmd);
285
+ };
286
+ return {
287
+ async putEvent(input) {
288
+ await dispatch(mod.PutMemoryEventCommand, input);
289
+ },
290
+ async getEvent(input) {
291
+ const r = (await dispatch(mod.GetMemoryEventCommand, input));
292
+ return r ?? null;
293
+ },
294
+ async listEvents(input) {
295
+ return (await dispatch(mod.ListMemoryEventsCommand, input));
296
+ },
297
+ async deleteEvent(input) {
298
+ await dispatch(mod.DeleteMemoryEventCommand, input);
299
+ },
300
+ async deleteSession(input) {
301
+ await dispatch(mod.DeleteMemorySessionCommand, input);
302
+ },
303
+ };
304
+ }
305
+ //# sourceMappingURL=agentcore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../src/adapters/memory/agentcore.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;;;AAUH,6DAAmE;AAuDnE;;;;;;;GAOG;A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C;IACnC,CAAC,CAAC;IAEF,OAAO;QACL,KAAK,CAAC,QAAQ,CAAC,KAAK;YAClB,MAAM,QAAQ,CAAC,GAAG,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;QACnD,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,KAAK;YAClB,MAAM,CAAC,GAAG,CAAC,MAAM,QAAQ,CAAC,GAAG,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAgC,CAAC;YAC5F,OAAO,CAAC,IAAI,IAAI,CAAC;QACnB,CAAC;QACD,KAAK,CAAC,UAAU,CAAC,KAAK;YACpB,OAAO,CAAC,MAAM,QAAQ,CAAC,GAAG,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAGzD,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,KAAK;YACrB,MAAM,QAAQ,CAAC,GAAG,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QACtD,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,KAAK;YACvB,MAAM,QAAQ,CAAC,GAAG,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;QACxD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,287 @@
1
+ "use strict";
2
+ /**
3
+ * RedisStore — Redis-backed `MemoryStore` adapter (peer-dep `ioredis`).
4
+ *
5
+ * Subpath import: `agentfootprint/memory-redis`.
6
+ *
7
+ * import { RedisStore } from 'agentfootprint/memory-redis';
8
+ * const store = new RedisStore({ url: 'redis://localhost:6379' });
9
+ *
10
+ * Pattern: Adapter (GoF) — translates the `MemoryStore` interface onto
11
+ * Redis primitives (key/value for entries, set for signatures,
12
+ * hash for feedback aggregates).
13
+ * Role: Outer ring. Lazy-requires `ioredis`; no runtime cost when
14
+ * another adapter is in use.
15
+ * Emits: N/A (storage adapters don't emit; recorders observe the
16
+ * memory pipeline that calls them).
17
+ *
18
+ * Vector search (`search()`) is NOT implemented in this adapter — RedisSearch
19
+ * is a separate Redis module with its own API surface. A `RedisSearchStore`
20
+ * may ship in a future release. RAG users with v2.3 should use
21
+ * `InMemoryStore` until the search-capable adapter lands.
22
+ *
23
+ * Concurrency model:
24
+ * - `put` / `putMany` use simple SET / pipelined SET (last-write-wins).
25
+ * - `putIfVersion` uses a small Lua script for atomic version compare-and-swap.
26
+ * - Multi-writer correctness ⇒ prefer `putIfVersion` in stage code.
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.RedisStore = void 0;
30
+ const index_js_1 = require("../../memory/identity/index.js");
31
+ /**
32
+ * Redis-backed `MemoryStore`. Implements every method except `search()`.
33
+ *
34
+ * @throws when `ioredis` is not installed and no `_client` is supplied.
35
+ */
36
+ class RedisStore {
37
+ client;
38
+ prefix;
39
+ scanCount;
40
+ ownsClient;
41
+ closed = false;
42
+ constructor(options = {}) {
43
+ this.prefix = options.prefix ?? 'agentfootprint';
44
+ this.scanCount = options.scanCount ?? 100;
45
+ if (options._client) {
46
+ this.client = options._client;
47
+ this.ownsClient = false;
48
+ }
49
+ else if (options.client) {
50
+ this.client = options.client;
51
+ this.ownsClient = false;
52
+ }
53
+ else if (options.url) {
54
+ this.client = createIoredis(options.url);
55
+ this.ownsClient = true;
56
+ }
57
+ else {
58
+ throw new Error('RedisStore requires `url` or `client` (or `_client` for tests).');
59
+ }
60
+ }
61
+ // Key helpers
62
+ nsKey(identity, suffix) {
63
+ return `${this.prefix}:${(0, index_js_1.identityNamespace)(identity)}:${suffix}`;
64
+ }
65
+ entryKey(identity, id) {
66
+ return this.nsKey(identity, `e:${id}`);
67
+ }
68
+ indexKey(identity) {
69
+ return this.nsKey(identity, 'idx');
70
+ }
71
+ sigKey(identity) {
72
+ return this.nsKey(identity, 'sig');
73
+ }
74
+ feedbackKey(identity, id) {
75
+ return this.nsKey(identity, `fb:${id}`);
76
+ }
77
+ // MemoryStore implementation
78
+ async get(identity, id) {
79
+ this.ensureOpen('get');
80
+ const raw = await this.client.get(this.entryKey(identity, id));
81
+ if (raw === null)
82
+ return null;
83
+ const entry = parseEntry(raw);
84
+ if (!entry)
85
+ return null;
86
+ if (entry.ttl !== undefined && entry.ttl <= Date.now())
87
+ return null;
88
+ return entry;
89
+ }
90
+ async put(identity, entry) {
91
+ this.ensureOpen('put');
92
+ const payload = JSON.stringify(entry);
93
+ const eKey = this.entryKey(identity, entry.id);
94
+ if (entry.ttl !== undefined) {
95
+ const pxMs = Math.max(0, entry.ttl - Date.now());
96
+ if (pxMs <= 0)
97
+ return;
98
+ await this.client.set(eKey, payload, 'PX', pxMs);
99
+ }
100
+ else {
101
+ await this.client.set(eKey, payload);
102
+ }
103
+ await this.client.sadd(this.indexKey(identity), entry.id);
104
+ }
105
+ async putMany(identity, entries) {
106
+ this.ensureOpen('putMany');
107
+ if (entries.length === 0)
108
+ return;
109
+ const pipeline = this.client.pipeline();
110
+ const ids = [];
111
+ const now = Date.now();
112
+ for (const entry of entries) {
113
+ const payload = JSON.stringify(entry);
114
+ const eKey = this.entryKey(identity, entry.id);
115
+ if (entry.ttl !== undefined) {
116
+ const pxMs = Math.max(0, entry.ttl - now);
117
+ if (pxMs <= 0)
118
+ continue;
119
+ pipeline.set(eKey, payload, 'PX', pxMs);
120
+ }
121
+ else {
122
+ pipeline.set(eKey, payload);
123
+ }
124
+ ids.push(entry.id);
125
+ }
126
+ if (ids.length > 0)
127
+ pipeline.sadd(this.indexKey(identity), ...ids);
128
+ await pipeline.exec();
129
+ }
130
+ /**
131
+ * Optimistic concurrency via a small Lua script — atomic
132
+ * compare-and-swap on the JSON-encoded `version` field.
133
+ */
134
+ async putIfVersion(identity, entry, expectedVersion) {
135
+ this.ensureOpen('putIfVersion');
136
+ const eKey = this.entryKey(identity, entry.id);
137
+ const idxKey = this.indexKey(identity);
138
+ const payload = JSON.stringify(entry);
139
+ const px = entry.ttl !== undefined ? Math.max(0, entry.ttl - Date.now()).toString() : '';
140
+ const result = (await this.client.eval(PUT_IF_VERSION_LUA, 2, eKey, idxKey, String(expectedVersion), payload, entry.id, px));
141
+ const applied = result[0] === 1;
142
+ if (applied)
143
+ return { applied: true };
144
+ return result[1] !== undefined
145
+ ? { applied: false, currentVersion: result[1] }
146
+ : { applied: false };
147
+ }
148
+ async list(identity, options = {}) {
149
+ this.ensureOpen('list');
150
+ const idxKey = this.indexKey(identity);
151
+ const ids = await this.client.smembers(idxKey);
152
+ if (ids.length === 0)
153
+ return { entries: [] };
154
+ const entries = [];
155
+ for (const id of ids) {
156
+ const raw = await this.client.get(this.entryKey(identity, id));
157
+ if (raw === null)
158
+ continue;
159
+ const entry = parseEntry(raw);
160
+ if (!entry)
161
+ continue;
162
+ if (entry.ttl !== undefined && entry.ttl <= Date.now())
163
+ continue;
164
+ if (options.tiers && (!entry.tier || !options.tiers.includes(entry.tier)))
165
+ continue;
166
+ entries.push(entry);
167
+ }
168
+ const start = options.cursor ? parseInt(options.cursor, 10) : 0;
169
+ const limit = options.limit ?? entries.length;
170
+ const page = entries.slice(start, start + limit);
171
+ const next = start + limit;
172
+ return next < entries.length ? { entries: page, cursor: String(next) } : { entries: page };
173
+ }
174
+ async delete(identity, id) {
175
+ this.ensureOpen('delete');
176
+ await this.client.del(this.entryKey(identity, id), this.feedbackKey(identity, id));
177
+ await this.client.srem(this.indexKey(identity), id);
178
+ }
179
+ async seen(identity, signature) {
180
+ this.ensureOpen('seen');
181
+ const result = await this.client.sismember(this.sigKey(identity), signature);
182
+ return result === 1;
183
+ }
184
+ async recordSignature(identity, signature) {
185
+ this.ensureOpen('recordSignature');
186
+ await this.client.sadd(this.sigKey(identity), signature);
187
+ }
188
+ async feedback(identity, id, usefulness) {
189
+ this.ensureOpen('feedback');
190
+ if (!Number.isFinite(usefulness))
191
+ return;
192
+ const clamped = Math.max(-1, Math.min(1, usefulness));
193
+ const fbKey = this.feedbackKey(identity, id);
194
+ await this.client.eval(FEEDBACK_LUA, 1, fbKey, String(clamped));
195
+ }
196
+ async getFeedback(identity, id) {
197
+ this.ensureOpen('getFeedback');
198
+ const fb = await this.client.hgetall(this.feedbackKey(identity, id));
199
+ if (!fb || !fb.count || parseInt(fb.count, 10) === 0)
200
+ return null;
201
+ const count = parseInt(fb.count, 10);
202
+ const sum = parseFloat(fb.sum ?? '0');
203
+ return { average: sum / count, count };
204
+ }
205
+ /**
206
+ * GDPR — drop every key under this identity's namespace.
207
+ */
208
+ async forget(identity) {
209
+ this.ensureOpen('forget');
210
+ const pattern = `${this.prefix}:${(0, index_js_1.identityNamespace)(identity)}:*`;
211
+ let cursor = '0';
212
+ do {
213
+ const [next, keys] = await this.client.scan(cursor, 'MATCH', pattern, 'COUNT', this.scanCount);
214
+ cursor = next;
215
+ if (keys.length > 0)
216
+ await this.client.del(...keys);
217
+ } while (cursor !== '0');
218
+ }
219
+ /**
220
+ * Close the underlying Redis connection — only when this adapter
221
+ * owns it. Borrowed clients (passed via `client` option) are left to
222
+ * the caller. Idempotent.
223
+ */
224
+ async close() {
225
+ if (this.closed)
226
+ return;
227
+ this.closed = true;
228
+ if (this.ownsClient)
229
+ await this.client.quit();
230
+ }
231
+ ensureOpen(op) {
232
+ if (this.closed) {
233
+ throw new Error(`RedisStore.${op}() called after close().`);
234
+ }
235
+ }
236
+ }
237
+ exports.RedisStore = RedisStore;
238
+ // Helpers
239
+ function parseEntry(raw) {
240
+ try {
241
+ return JSON.parse(raw);
242
+ }
243
+ catch {
244
+ return null;
245
+ }
246
+ }
247
+ const PUT_IF_VERSION_LUA = `
248
+ local current = redis.call('GET', KEYS[1])
249
+ local expected = tonumber(ARGV[1])
250
+ if current == false then
251
+ if expected ~= 0 then
252
+ return {0}
253
+ end
254
+ else
255
+ local cur_version = tonumber(string.match(current, '"version":(%d+)'))
256
+ if cur_version ~= expected then
257
+ return {0, cur_version}
258
+ end
259
+ end
260
+ if ARGV[4] ~= '' then
261
+ redis.call('SET', KEYS[1], ARGV[2], 'PX', tonumber(ARGV[4]))
262
+ else
263
+ redis.call('SET', KEYS[1], ARGV[2])
264
+ end
265
+ redis.call('SADD', KEYS[2], ARGV[3])
266
+ return {1}
267
+ `;
268
+ const FEEDBACK_LUA = `
269
+ redis.call('HINCRBYFLOAT', KEYS[1], 'sum', ARGV[1])
270
+ redis.call('HINCRBY', KEYS[1], 'count', 1)
271
+ return 1
272
+ `;
273
+ function createIoredis(url) {
274
+ let mod;
275
+ try {
276
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
277
+ mod = require('ioredis');
278
+ }
279
+ catch {
280
+ throw new Error('RedisStore requires the `ioredis` peer dependency.\n' +
281
+ ' Install: npm install ioredis\n' +
282
+ ' Or pass `_client` for test injection.');
283
+ }
284
+ const Ctor = mod.default ?? mod;
285
+ return new Ctor(url);
286
+ }
287
+ //# sourceMappingURL=redis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis.js","sourceRoot":"","sources":["../../../src/adapters/memory/redis.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAUH,6DAAmE;AAiEnE;;;;GAIG;AACH,MAAa,UAAU;IACJ,MAAM,CAAkB;IACxB,MAAM,CAAS;IACf,SAAS,CAAS;IAClB,UAAU,CAAU;IAC7B,MAAM,GAAG,KAAK,CAAC;IAEvB,YAAY,UAA6B,EAAE;QACzC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,gBAAgB,CAAC;QACjD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,GAAG,CAAC;QAE1C,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;YAC9B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QAC1B,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YAC1B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAC7B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QAC1B,CAAC;aAAM,IAAI,OAAO,CAAC,GAAG,EAAE,CAA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recorders observe via Agent.
9
9
  *
10
- * ─── 7-panel design review (2026-04-28) ─────────────────────────────
11
- *
12
- * LLM-AI system design ✓ Native tool_use blocks. Round-trips
13
- * assistant tool_calls via the new
14
- * `LLMMessage.toolCalls` field — preserves
15
- * multi-iteration ReAct correctness.
16
- * Performance ✓ Single SDK call per `complete()`. Stream
17
- * uses SDK's native iterator; no buffering.
18
- * Scalability ✓ Stateless adapter. Concurrent runs share
19
- * one provider instance freely.
20
- * Research alignment ✓ Mirrors v1 AnthropicAdapter's tested
21
- * message-conversion logic (origin/main
22
- * `c6e11d0`); tool-result merge follows the
23
- * documented Anthropic API expectation.
24
- * Flexibility ✓ `_client` injection point for tests.
25
- * `apiKey` falls back to env. `maxTokens`
26
- * override per-construction or per-request.
27
- * Abstraction-modular ✓ Two converters (toAnthropicMessages,
28
- * fromAnthropicResponse) isolate the
29
- * shape-shifting; `complete()` and
30
- * `stream()` reuse them.
31
- * Software engineering ✓ Duck-typed SDK shape (no hard import).
32
- * Errors wrapped with provider tag for
33
- * uniform downstream handling. Tests cover
34
- * unit + scenario + integration + property
35
- * + security + performance + ROI.
36
- *
37
10
  * ─── Limitations ────────────────────────────────────────────────────
38
11
  *
39
12
  * • Multi-modal content (images, video) NOT supported — the framework's
@@ -42,10 +15,6 @@
42
15
  * in lockstep.
43
16
  * • `responseFormat` (JSON-Schema-coerced output) NOT exposed
44
17
  * — consumers can pass schema instructions via `systemPrompt`.
45
- *
46
- * ─── 7-pattern test coverage ────────────────────────────────────────
47
- *
48
- * See `test/adapters/llm/AnthropicProvider/*.test.ts`.
49
18
  */
50
19
  /**
51
20
  * Build an `LLMProvider` backed by Anthropic's Messages API.