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,100 @@
1
+ /**
2
+ * Instructions — types.
3
+ *
4
+ * An Instruction is a declarative rule for conditional system-prompt
5
+ * injection. The agent evaluates each Instruction's `activeWhen`
6
+ * predicate at the start of every iteration; matching instructions'
7
+ * `prompt` text is prepended to the system prompt for that iteration.
8
+ *
9
+ * This is the rule-based flavor of the unified context-engineering
10
+ * model: slot=system-prompt, role=system, timing=per-iteration,
11
+ * decision=rule. (Compare with Skills: timing=on-activation,
12
+ * decision=LLM-guided.)
13
+ *
14
+ * Pattern: Strategy (GoF) — each Instruction is a strategy for
15
+ * "should I add this prompt to the next iteration?"
16
+ * Role: Consumer-facing shape. Agent.create(...).instruction(...).
17
+ * Emits: `agentfootprint.context.injected` with source='instruction'
18
+ * when an instruction activates.
19
+ */
20
+ import type { Tool } from '../../core/tools.js';
21
+ /**
22
+ * Read-only snapshot of the agent's state that an Instruction can
23
+ * inspect to decide activation. Includes only the fields a predicate
24
+ * can safely depend on — internal mutable state is hidden.
25
+ */
26
+ export interface InstructionContext {
27
+ /** Current ReAct iteration (1-based). */
28
+ readonly iteration: number;
29
+ /** The current user message that started this turn. */
30
+ readonly userMessage: string;
31
+ /**
32
+ * Conversation history up to (but not including) the current
33
+ * iteration's LLM call. Includes system / user / assistant / tool
34
+ * messages from prior iterations of the same turn.
35
+ */
36
+ readonly history: ReadonlyArray<{
37
+ readonly role: 'system' | 'user' | 'assistant' | 'tool';
38
+ readonly content: string;
39
+ readonly toolName?: string;
40
+ }>;
41
+ /**
42
+ * The most recent tool result, if the previous iteration ended in a
43
+ * tool call. Undefined on the first iteration of a turn.
44
+ */
45
+ readonly lastToolResult?: {
46
+ readonly toolName: string;
47
+ readonly result: string;
48
+ };
49
+ /** Custom decision-scope state the consumer placed via Agent options. */
50
+ readonly decision?: Readonly<Record<string, unknown>>;
51
+ }
52
+ /**
53
+ * A single declarative instruction.
54
+ *
55
+ * @example
56
+ * const calmTone = defineInstruction({
57
+ * id: 'calm-tone',
58
+ * description: 'Use a calm, empathetic tone after the user expresses frustration.',
59
+ * activeWhen: (ctx) => ctx.userMessage.includes('frustrated')
60
+ * || ctx.userMessage.includes('angry'),
61
+ * prompt: 'The user is upset. Respond calmly. Acknowledge feelings before facts.',
62
+ * });
63
+ *
64
+ * const agent = Agent.create({ provider }).instruction(calmTone).build();
65
+ */
66
+ export interface Instruction {
67
+ /** Unique id — used for observability + de-duplication. */
68
+ readonly id: string;
69
+ /** Human-readable description (Lens / docs / debug). */
70
+ readonly description?: string;
71
+ /**
72
+ * Predicate to decide activation. Synchronous; side-effect free.
73
+ * If omitted, the instruction is always active. Predicates that
74
+ * throw are skipped (fail-open) and the error is surfaced via the
75
+ * emit channel for observability — they don't crash the run.
76
+ */
77
+ readonly activeWhen?: (ctx: InstructionContext) => boolean;
78
+ /** Text appended to the next iteration's system prompt when active. */
79
+ readonly prompt?: string;
80
+ /**
81
+ * Tools to add to the agent's tool registry when the instruction is
82
+ * active. Merged with the agent's base tools (later instructions win
83
+ * on duplicate ids). Empty by default.
84
+ */
85
+ readonly tools?: readonly Tool[];
86
+ }
87
+ /**
88
+ * @internal
89
+ * Branded result returned by `evaluateInstructions()`. Lets the
90
+ * agent's pre-LLM stage consume the projection without re-running
91
+ * the predicates.
92
+ */
93
+ export interface InstructionEvaluation {
94
+ readonly active: readonly Instruction[];
95
+ readonly skipped: ReadonlyArray<{
96
+ readonly id: string;
97
+ readonly error: string;
98
+ }>;
99
+ }
100
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/instructions/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAC9B,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;QACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC,CAAC;IACH;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE;QACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvD;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,OAAO,CAAC;IAC3D,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC;CAClC;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClF"}
@@ -5,5 +5,6 @@
5
5
  * use case, not yet shipped).
6
6
  */
7
7
  export { mcpClient } from './mcpClient.js';
8
+ export { mockMcpClient, type MockMcpClientOptions, type MockMcpTool } from './mockMcpClient.js';
8
9
  export type { McpClient, McpClientOptions, McpHttpTransport, McpStdioTransport, McpTransport, McpSdkClient, } from './types.js';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,YAAY,GACb,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChG,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,YAAY,GACb,MAAM,YAAY,CAAC"}
@@ -29,23 +29,6 @@
29
29
  * `McpClientOptions` so observability surfaces can group
30
30
  * tool calls by server.
31
31
  *
32
- * 7-panel review (2026-04-29):
33
- * - LLM Systems ✅ inputSchema preserved verbatim — the LLM sees
34
- * the same tool schema MCP advertised
35
- * - Architect ✅ pure adapter; no engine code. New tool sources
36
- * slot in via the same `Tool` interface
37
- * - API Designer ✅ three methods (.tools / .refresh / .close)
38
- * mirror the MCP SDK lifecycle
39
- * - Performance ✅ tool list cached after first fetch; .refresh
40
- * is opt-in. callTool round-trip is one network
41
- * hop per tool call (same as direct LLM-tool flow)
42
- * - Privacy ✅ no implicit logging; consumer controls auth
43
- * via transport headers
44
- * - SoftEng ✅ lazy-required SDK + friendly install error;
45
- * mock injection point for tests
46
- * - TS Engineer ✅ structural McpSdkClient shim — works against
47
- * any future SDK version with the same shape
48
- *
49
32
  * Lazy-require pattern: the `@modelcontextprotocol/sdk` peer-dep
50
33
  * loads only when a consumer actually constructs a client. Tests
51
34
  * inject `_client` and skip the import path entirely.
@@ -1 +1 @@
1
- {"version":3,"file":"mcpClient.d.ts","sourceRoot":"","sources":["../../../../src/lib/mcp/mcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAA8B,MAAM,YAAY,CAAC;AAO1F;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CA4B1E"}
1
+ {"version":3,"file":"mcpClient.d.ts","sourceRoot":"","sources":["../../../../src/lib/mcp/mcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAA8B,MAAM,YAAY,CAAC;AAU1F;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAyC1E"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * mockMcpClient — in-memory MCP client for development and tests.
3
+ *
4
+ * const slack = mockMcpClient({
5
+ * tools: [
6
+ * {
7
+ * name: 'send_message',
8
+ * description: 'Post a message to a channel',
9
+ * inputSchema: { type: 'object' },
10
+ * handler: async ({ text }) => `Posted: ${text}`,
11
+ * },
12
+ * ],
13
+ * });
14
+ *
15
+ * const agent = Agent.create({ provider: mock({ reply: 'ok' }) })
16
+ * .tools(await slack.tools())
17
+ * .build();
18
+ *
19
+ * Pattern: Adapter (GoF) — produces an `McpClient` with the same shape
20
+ * as `mcpClient(opts)` but driven by an in-memory tool table
21
+ * instead of the MCP SDK + transport. Drop-in for development:
22
+ * start with `mockMcpClient`, swap to `mcpClient` once the
23
+ * real server is ready.
24
+ *
25
+ * Why public: `mcpClient`'s `_client` injection is `@internal` because
26
+ * the SDK shape isn't a stable public surface. `mockMcpClient` exposes
27
+ * a curated tool-handler shape that's tied to OUR Tool contract instead
28
+ * — stable, documented, and the right level of abstraction for
29
+ * mock-first development.
30
+ */
31
+ import type { McpClient } from './types.js';
32
+ /** A scripted tool exposed by the mock MCP server. */
33
+ export interface MockMcpTool {
34
+ /** Tool name as the LLM sees it. */
35
+ readonly name: string;
36
+ /** Description surfaced to the LLM via the tool schema. */
37
+ readonly description?: string;
38
+ /**
39
+ * JSON-schema-like input schema. Passed through to the agent's tool
40
+ * registry verbatim — same as a real MCP server's `listTools()`.
41
+ */
42
+ readonly inputSchema: Readonly<Record<string, unknown>>;
43
+ /**
44
+ * Async handler that runs when the agent calls this tool. Receives
45
+ * the args the LLM produced; returns the string result the agent
46
+ * sees as the tool-result message.
47
+ *
48
+ * Defaults to `async () => '[mock result]'` when omitted — useful
49
+ * when the consumer cares about wiring not behavior.
50
+ */
51
+ readonly handler?: (args: Record<string, unknown>) => Promise<string>;
52
+ }
53
+ export interface MockMcpClientOptions {
54
+ /** Logical server name. Surfaces in observability + error messages. */
55
+ readonly name?: string;
56
+ /** Tools exposed by the mock server. */
57
+ readonly tools: readonly MockMcpTool[];
58
+ }
59
+ /**
60
+ * Build an in-memory `McpClient`. Useful when you want to develop
61
+ * against MCP semantics without spawning subprocesses, hitting the
62
+ * network, or installing `@modelcontextprotocol/sdk`. Same `McpClient`
63
+ * shape as `mcpClient(opts)` — code that consumes one accepts the other.
64
+ */
65
+ export declare function mockMcpClient(options: MockMcpClientOptions): McpClient;
66
+ //# sourceMappingURL=mockMcpClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockMcpClient.d.ts","sourceRoot":"","sources":["../../../../src/lib/mcp/mockMcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxD;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACvE;AAED,MAAM,WAAW,oBAAoB;IACnC,uEAAuE;IACvE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;CACxC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS,CAoCtE"}
@@ -120,6 +120,8 @@ export interface McpSdkClient {
120
120
  callTool(args: {
121
121
  readonly name: string;
122
122
  readonly arguments?: Readonly<Record<string, unknown>>;
123
+ /** Forwarded from `McpClientOptions.signal` so consumers can cancel hung tool calls. */
124
+ readonly signal?: AbortSignal;
123
125
  }): Promise<{
124
126
  readonly content: ReadonlyArray<{
125
127
  readonly type: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/mcp/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAIhD;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,+CAA+C;IAC/C,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,4CAA4C;IAC5C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE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AQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;YAC9B,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;SACzD,CAAC,CAAC;KACJ,CAAC,CAAC;IACH,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACvD,wFAAwF;QACxF,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;KAC/B,GAAG,OAAO,CAAC;QACV,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;YAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;SACxB,CAAC,CAAC;QACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;KAC5B,CAAC,CAAC;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
@@ -29,24 +29,6 @@
29
29
  * `agentfootprint.context.injected` when retrieved chunks
30
30
  * land in the messages slot.
31
31
  *
32
- * 7-panel review (2026-04-29):
33
- * - LLM Systems ✅ injects as 'user' role by default — RAG chunks
34
- * land where the LLM treats them as authoritative
35
- * retrieved context, not behavior rules
36
- * - Architect ✅ composition over defineMemory; zero new engine
37
- * code; multi-RAG layering works via per-id keys
38
- * - API Designer ✅ one factory, mirrors defineMemory shape; consumer
39
- * ergonomics: `agent.rag(defineRAG({...}))`
40
- * - Performance ✅ embedding cost is one call per turn (TURN_START
41
- * timing, default); strict threshold prevents
42
- * injecting low-confidence noise
43
- * - Privacy ✅ multi-tenant via MemoryIdentity tuple; doc
44
- * content never crosses tenant boundaries
45
- * - ML / IR ✅ embedder version pinned via `embedderId`; cosine
46
- * score semantics inherited from MemoryStore
47
- * - SoftEng ✅ thin file (this one); existing memory tests
48
- * cover the underlying pipeline
49
- *
50
32
  * @see ./indexDocuments.ts for the seeding helper
51
33
  * @see ../../memory/define.ts for the underlying factory
52
34
  *
@@ -119,13 +101,28 @@ export interface DefineRAGOptions {
119
101
  * Minimum cosine similarity to inject. **Strict** — when no chunk
120
102
  * meets the threshold, NO injection happens (no fallback that would
121
103
  * pollute the prompt with weak matches). Default 0.7.
104
+ *
105
+ * Tuning note: 0.7 is a high bar for some embedders. Sentence-BERT
106
+ * relatives (`all-MiniLM-L6-v2`, etc.) often score 0.4–0.6 even on
107
+ * relevant chunks. If you see frequent zero-result silent skips,
108
+ * lower to ~0.5 and observe the `agentfootprint.context.injected`
109
+ * stream. OpenAI `text-embedding-3-*` and Cohere embed-v3 typically
110
+ * sit comfortably with 0.7.
122
111
  */
123
112
  readonly threshold?: number;
124
113
  /**
125
114
  * Role to use when injecting retrieved chunks into the messages
126
- * slot. Default `'user'` — RAG chunks are most often treated as
127
- * "context the user provided" by LLMs. Use `'system'` for
128
- * authoritative reference docs that should outweigh user instruction.
115
+ * slot. Default `'user'`.
116
+ *
117
+ * Why `'user'`: in tool-using ReAct loops, retrieved chunks
118
+ * conceptually "augment what the user asked." Anthropic's tool-use
119
+ * cookbook and OpenAI's RAG cookbook both show retrieved context
120
+ * inside user-turn messages.
121
+ *
122
+ * Use `'system'` for authoritative reference docs that should
123
+ * outweigh user instruction (policy / compliance / brand-voice
124
+ * corpora). Use `'assistant'` only if you've persisted prior agent
125
+ * turns as context — rare.
129
126
  */
130
127
  readonly asRole?: ContextRole;
131
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"defineRAG.d.ts","sourceRoot":"","sources":["../../../../src/lib/rag/defineRAG.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAA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AM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAE5B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAE5B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CA8BlE"}
@@ -41,7 +41,20 @@ export interface IndexDocumentsOptions {
41
41
  /**
42
42
  * Identity scope to write under. Default: a single shared
43
43
  * `{ conversationId: '_global' }` namespace, suitable for app-wide
44
- * corpora. Override for per-tenant document partitions.
44
+ * corpora.
45
+ *
46
+ * **Multi-tenant footgun:** the read side (`agent.run({ identity })`)
47
+ * queries within whichever identity is passed at request time.
48
+ * If you index here under `_global` but query under
49
+ * `{ tenant: 'acme' }`, you'll get ZERO results — silently. Either:
50
+ * 1. Index every document under each tenant's identity (duplicated
51
+ * storage, but isolated), or
52
+ * 2. Index under `_global` AND query under `_global` (shared
53
+ * corpus across tenants — fine for product docs, NOT for
54
+ * tenant-private data), or
55
+ * 3. Use a vector store adapter that supports multi-namespace
56
+ * reads at query time (Pinecone, Qdrant — outside this helper's
57
+ * scope).
45
58
  */
46
59
  readonly identity?: MemoryIdentity;
47
60
  /**
@@ -67,11 +80,27 @@ export interface IndexDocumentsOptions {
67
80
  * this through to abort batch indexing on shutdown / timeout.
68
81
  */
69
82
  readonly signal?: AbortSignal;
83
+ /**
84
+ * Max number of concurrent embed calls when the embedder doesn't
85
+ * implement `embedBatch`. Default `8`. Without this cap, a 10K-doc
86
+ * corpus would fire 10K parallel embed calls and trigger rate limits.
87
+ * Ignored when `embedBatch` is available (the embedder controls
88
+ * its own batching).
89
+ */
90
+ readonly maxConcurrency?: number;
70
91
  }
71
92
  /**
72
93
  * Embed + persist documents. Returns the count actually indexed
73
94
  * (skips duplicates if the store rejects them). Throws on embedder
74
95
  * failure or store error — fail loud at startup is desirable.
96
+ *
97
+ * **Re-indexing semantics:** entries are written with `version: 1` and
98
+ * `putMany` (most adapters: last-write-wins). Re-running this helper
99
+ * after the store has been mutated by other writers may stomp their
100
+ * versions. For idempotent corpus refresh, either delete-then-index
101
+ * or use a custom upsert via `store.putIfVersion()` per document. A
102
+ * first-class `mode: 'upsert' | 'replace'` API is planned for a
103
+ * future release.
75
104
  */
76
105
  export declare function indexDocuments(store: MemoryStore, embedder: Embedder, documents: readonly RagDocument[], options?: IndexDocumentsOptions): Promise<number>;
77
106
  //# sourceMappingURL=indexDocuments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"indexDocuments.d.ts","sourceRoot":"","sources":["../../../../src/lib/rag/indexDocuments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,4EAA4E;AAC5E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,C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AQ,CAAC,EAAE,cAAc,CAAC;IAEnC;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IAExC;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAE9B;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAID;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,WAAW,EAAE,EACjC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,MAAM,CAAC,CA6CjB"}
@@ -12,7 +12,7 @@
12
12
  * Strict-threshold semantics:
13
13
  * When `minScore` is set and no past snapshot meets it, returns an
14
14
  * empty `formatted`. NO fallback — garbage past context is worse than
15
- * no context. Aligns with the LLM-systems panel verdict in the design.
15
+ * no context.
16
16
  *
17
17
  * Empty-query handling:
18
18
  * No user message → no embedding → no search → empty result.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Pure functions for conversation message management.
3
+ * No state — just transformations on message arrays.
4
+ */
5
+ import type { Message, AssistantMessage, ToolResultMessage } from '../types';
6
+ /** Append a message to the conversation. Returns new array. */
7
+ export declare function appendMessage(messages: Message[], message: Message): Message[];
8
+ /** Get the last message in the conversation. */
9
+ export declare function lastMessage(messages: Message[]): Message | undefined;
10
+ /** Get the last assistant message. */
11
+ export declare function lastAssistantMessage(messages: Message[]): AssistantMessage | undefined;
12
+ /** Check if the last assistant message has tool calls. */
13
+ export declare function lastMessageHasToolCalls(messages: Message[]): boolean;
14
+ /** Create tool result messages from a map of tool call ID → result. */
15
+ export declare function createToolResults(results: Array<{
16
+ toolCallId: string;
17
+ content: string;
18
+ }>): ToolResultMessage[];
19
+ //# sourceMappingURL=conversationHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversationHelpers.d.ts","sourceRoot":"","sources":["../../../src/memory/conversationHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7E,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,CAE9E;AAED,gDAAgD;AAChD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,GAAG,SAAS,CAEpE;AAED,sCAAsC;AACtC,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,gBAAgB,GAAG,SAAS,CAKtF;AAED,0DAA0D;AAC1D,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAGpE;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,KAAK,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GACtD,iBAAiB,EAAE,CAErB"}
@@ -23,22 +23,8 @@
23
23
  * `agentfootprint.context.injected` with `source: 'memory'`
24
24
  * when their formatter writes to the messages slot.
25
25
  *
26
- * 8-panel review (2026-04-28):
27
- * - LLM Systems ✅ asRole knob honored when present, defaults to 'system'
28
- * - Architect ✅ per-id scope keys (`memoryInjectionKey(id)`)
29
- * - API Designer ✅ one factory; CAUSAL stays here, no separate snapshotMemory
30
- * - Performance ✅ default `MEMORY_TIMING.TURN_START`; pipelines compiled once
31
- * - Privacy ✅ redact field passes through
32
- * - ML / IR ✅ threshold maps to semantic.minScore strictly; no fallback
33
- * - SoftEng ✅ unsupported combos throw with clear remediation hint
34
- * - TS Engineer ✅ discriminated union narrowing preserved across switches
35
- *
36
- * Book reference: AI Agents — The Definitive Guide, Ch 10 (Memory,
37
- * Autonomy, Long-Horizon Use — chapter still unavailable in pre-pub).
38
- *
39
26
  * @see ./define.types.ts for the const-objects + types
40
27
  * @see ./pipeline/*.ts for the existing pipeline factories this dispatches to
41
- * @see MEMORY.md load-bearing design memory
42
28
  */
43
29
  import { type DefineMemoryOptions } from './define.types.js';
44
30
  import type { MemoryDefinition, ReadonlyMemoryFlowChart } from './define.types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../../src/memory/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAaH,OAAO,EAIL,KAAK,mBAAmB,EAYzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAInF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,gBAAgB,CAqB3E;AA6RD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAAG,OAAO,CAErF"}
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../../src/memory/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAaH,OAAO,EAIL,KAAK,mBAAmB,EAYzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAInF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,gBAAgB,CAqB3E;AA6RD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAAG,OAAO,CAErF"}
@@ -32,16 +32,6 @@
32
32
  * `agentfootprint.context.injected` event with `source: 'memory'`
33
33
  * when its read subflow places content into the messages slot.
34
34
  *
35
- * 8-panel review (2026-04-28):
36
- * - LLM Systems ✅ asRole knob added so memories can land as user/system/assistant
37
- * - Architect ✅ per-id scope keys (`memoryInjection_${id}`) — multi-memory layering safe
38
- * - API Designer ✅ ONE factory for all four types incl. Causal (no separate `snapshotMemory`)
39
- * - Performance ✅ default `MEMORY_TIMING.TURN_START` (was per-iteration — perf trap)
40
- * - Privacy ✅ `redact?` API hook reserved
41
- * - ML / IR ✅ causal snapshots tagged with original query for retrieval embedding
42
- * - SoftEng ✅ discriminated union with `kind` discriminator → full TS narrowing
43
- * - TS Engineer ✅ generic over `MemoryEntry<T>` payload preserves type-safety
44
- *
45
35
  * @see ./define.ts for the `defineMemory()` factory itself
46
36
  * @see ../../docs-site for guides + the 7 strategy examples
47
37
  * @see MEMORY.md for the load-bearing design memory
@@ -193,8 +183,8 @@ export type Strategy = WindowStrategy | BudgetStrategy | SummarizeStrategy | Top
193
183
  /**
194
184
  * Reserved API surface for content redaction before memory writes.
195
185
  * Impl is deferred; the field exists now so adding redaction later
196
- * is non-breaking. Privacy panel review: snapshot/episodic writes may
197
- * carry PII — this is the integration point.
186
+ * is non-breaking. Snapshot/episodic writes may carry PII — this is
187
+ * the integration point.
198
188
  */
199
189
  export interface MemoryRedactionPolicy {
200
190
  /** Patterns to mask in stored content. */
@@ -1 +1 @@
1
- {"version":3,"file":"define.types.d.ts","sourceRoot":"","sources":["../../../src/memory/define.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW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AC,EAAE,kBAAkB,CAAC;CAC1C;AAED,2EAA2E;AAC3E,MAAM,MAAM,mBAAmB,GAC3B,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,mBAAmB,CAAC;AAIxB,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,UAAU,CAE/D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,kBAAkB,CAE/E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,YAAY,CAEnE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,kBAAkB,CAE/E;AAID;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,oBAA8B,CAAC;AAEvE,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEzD"}
@@ -14,50 +14,6 @@
14
14
  *
15
15
  * Reads as: try anthropic; on failure fall back to openai; the whole
16
16
  * chain is wrapped in retry with 5 attempts.
17
- *
18
- * ─── 7-panel design review (2026-04-28) ────────────────────────────
19
- *
20
- * LLM-AI system design ✓ Decorator pattern around the existing
21
- * `LLMProvider` port — no new contract.
22
- * Stacks naturally; observation hooks
23
- * (`onRetry`, `onFallback`) keep the
24
- * recorder ecosystem informed.
25
- * Performance ✓ Zero overhead on success path (one
26
- * `try/await` per call). Backoff delays
27
- * use AbortSignal-aware sleep — no busy
28
- * wait, no leaked timers.
29
- * Scalability ✓ Per-call state only. Composition is
30
- * constant-time per attempt; chain depth
31
- * doesn't grow runtime cost.
32
- * Research alignment ✓ Right-fold of `withFallback` matches
33
- * the standard chain-of-responsibility
34
- * shape. No exotic resumption — once a
35
- * stream yields, it commits.
36
- * Flexibility ✓ Predicates (`shouldRetry`,
37
- * `shouldFallback`) and hooks
38
- * (`onRetry`, `onFallback`) make every
39
- * policy decision overridable. Default
40
- * policies match common real-world signals
41
- * (4xx skip, 429 retry, AbortError pass).
42
- * Abstraction-modular ✓ Three primitives, one purpose each.
43
- * `fallbackProvider` is sugar over chained
44
- * `withFallback`. No surprises.
45
- * Software engineering ✓ Pure decorators — no shared state.
46
- * Every option has a documented default.
47
- * Tests cover unit + scenario + integration
48
- * + property + security + performance + ROI.
49
- *
50
- * ─── 7-pattern test coverage ───────────────────────────────────────
51
- *
52
- * Unit test/resilience/unit/withRetry.test.ts
53
- * test/resilience/unit/withFallback.test.ts
54
- * test/resilience/unit/fallbackProvider.test.ts
55
- * Scenario resilience-patterns.test.ts → "production recipes"
56
- * Integration resilience-patterns.test.ts → "Agent + resilient provider"
57
- * Property resilience-patterns.test.ts → "invariants"
58
- * Security resilience-patterns.test.ts → "hostile inputs"
59
- * Performance resilience-patterns.test.ts → "performance"
60
- * ROI resilience-patterns.test.ts → "realistic SLO budgets"
61
17
  */
62
18
  export { withRetry, type WithRetryOptions } from './withRetry.js';
63
19
  export { withFallback, type WithFallbackOptions } from './withFallback.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/resilience/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/resilience/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -7,35 +7,6 @@
7
7
  * framework that accepts an async iterable response body
8
8
  * (Fetch Response, Express res.write, Hono streaming, etc.).
9
9
  * Emits: N/A — observes only.
10
- *
11
- * ─── 7-panel design review (2026-04-28) ─────────────────────────────
12
- *
13
- * LLM-AI system design ✓ One-line-per-event SSE format. Each
14
- * event = one observation; each chunk
15
- * includes the `runtimeStageId` for
16
- * cross-view binding.
17
- * Performance ✓ AsyncIterable<string> — no buffering;
18
- * yields each event as it arrives. Stops
19
- * naturally when the run completes.
20
- * Scalability ✓ Per-run instance. No shared state;
21
- * many concurrent SSE streams safe.
22
- * Research alignment ✓ Standard SSE wire format
23
- * (text/event-stream). Browsers'
24
- * native EventSource API consumes directly.
25
- * Flexibility ✓ `format` option for full event payload
26
- * vs slim text-only mode (chat UIs that
27
- * only want token deltas). `filter`
28
- * predicate gates events.
29
- * Abstraction-modular ✓ One function (`toSSE`) + one class
30
- * (`SSEFormatter`); class is sugar for
31
- * consumers who prefer .pipeTo() shape.
32
- * Software engineering ✓ Pure observer. No global state. Tests
33
- * cover unit + scenario + property +
34
- * security + performance.
35
- *
36
- * ─── 7-pattern test coverage ────────────────────────────────────────
37
- *
38
- * See `test/stream/unit/SSEFormatter.test.ts`.
39
10
  */
40
11
  import type { AgentfootprintEvent } from './events/registry.js';
41
12
  import type { RunnerBase } from './core/RunnerBase.js';
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAA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;;;;;;;;GAmBG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC;IAC1D;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,MAAM,CAAC;IAC5D;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAuB,KAAK,CAAC,GAAG,EAAE,IAAI,EACpC,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,EAC7B,OAAO,GAAE,YAAiB,GACzB,aAAa,CAAC,MAAM,CAAC,CA0EvB;AAED;;;GAGG;AACH,qBAAa,YAAY,CAAC,GAAG,GAAG,OAAO,EAAE,IAAI,GAAG,OAAO;IAEnD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,EAC7B,OAAO,GAAE,YAAiB;IAG7C,8DAA8D;IAC9D,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC;CAGhC;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAMrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentfootprint",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "The explainable agent framework — build AI agents you can explain, audit, and trust. Built on footprintjs.",
5
5
  "license": "MIT",
6
6
  "author": "Sanjay Krishna Anbalagan",
@@ -114,12 +114,31 @@
114
114
  "types": "./dist/types/injection-engine.d.ts",
115
115
  "import": "./dist/esm/injection-engine.js",
116
116
  "require": "./dist/injection-engine.js"
117
+ },
118
+ "./memory-redis": {
119
+ "types": "./dist/types/adapters/memory/redis.d.ts",
120
+ "import": "./dist/esm/adapters/memory/redis.js",
121
+ "require": "./dist/adapters/memory/redis.js"
122
+ },
123
+ "./memory-agentcore": {
124
+ "types": "./dist/types/adapters/memory/agentcore.d.ts",
125
+ "import": "./dist/esm/adapters/memory/agentcore.js",
126
+ "require": "./dist/adapters/memory/agentcore.js"
117
127
  }
118
128
  },
119
129
  "sideEffects": false,
120
130
  "peerDependencies": {
121
131
  "footprintjs": ">=4.14.0"
122
132
  },
133
+ "peerDependenciesMeta": {
134
+ "@anthropic-ai/sdk": { "optional": true },
135
+ "openai": { "optional": true },
136
+ "@aws-sdk/client-bedrock-runtime": { "optional": true },
137
+ "@aws-sdk/client-bedrock-agent-runtime": { "optional": true },
138
+ "@modelcontextprotocol/sdk": { "optional": true },
139
+ "ioredis": { "optional": true },
140
+ "zod": { "optional": true }
141
+ },
123
142
  "devDependencies": {
124
143
  "@types/node": "^25.5.2",
125
144
  "@typescript-eslint/eslint-plugin": "^5.61.0",