agentfootprint 2.2.0 → 2.4.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 +52 -0
- package/CLAUDE.md +52 -0
- package/README.md +286 -209
- package/ai-instructions/claude-code/SKILL.md +24 -5
- package/ai-instructions/clinerules +22 -5
- package/ai-instructions/copilot-instructions.md +22 -5
- package/ai-instructions/cursor/agentfootprint.md +22 -5
- package/ai-instructions/kiro/agentfootprint.md +22 -5
- package/ai-instructions/windsurfrules +22 -5
- package/dist/adapters/llm/AnthropicProvider.js +0 -31
- package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
- package/dist/adapters/llm/BedrockProvider.js +2 -28
- package/dist/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/adapters/llm/BrowserAnthropicProvider.js +1 -31
- package/dist/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
- package/dist/adapters/llm/BrowserOpenAIProvider.js +1 -11
- package/dist/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
- package/dist/adapters/llm/MockProvider.js +35 -1
- package/dist/adapters/llm/MockProvider.js.map +1 -1
- package/dist/adapters/llm/OpenAIProvider.js +3 -29
- package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/adapters/memory/agentcore.js +305 -0
- package/dist/adapters/memory/agentcore.js.map +1 -0
- package/dist/adapters/memory/redis.js +287 -0
- package/dist/adapters/memory/redis.js.map +1 -0
- package/dist/core/Agent.js +16 -0
- package/dist/core/Agent.js.map +1 -1
- package/dist/esm/adapters/llm/AnthropicProvider.js +0 -31
- package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
- package/dist/esm/adapters/llm/BedrockProvider.js +2 -28
- package/dist/esm/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.js +1 -31
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +1 -11
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
- package/dist/esm/adapters/llm/MockProvider.js +35 -1
- package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
- package/dist/esm/adapters/llm/OpenAIProvider.js +3 -29
- package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/esm/adapters/memory/agentcore.js +301 -0
- package/dist/esm/adapters/memory/agentcore.js.map +1 -0
- package/dist/esm/adapters/memory/redis.js +283 -0
- package/dist/esm/adapters/memory/redis.js.map +1 -0
- package/dist/esm/core/Agent.js +16 -0
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/SkillRegistry.js +83 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.js.map +1 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.js +34 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.js.map +1 -1
- package/dist/esm/lib/injection-engine/index.js +2 -55
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/mcp/index.js +1 -0
- package/dist/esm/lib/mcp/index.js.map +1 -1
- package/dist/esm/lib/mcp/mcpClient.js +29 -24
- package/dist/esm/lib/mcp/mcpClient.js.map +1 -1
- package/dist/esm/lib/mcp/mockMcpClient.js +97 -0
- package/dist/esm/lib/mcp/mockMcpClient.js.map +1 -0
- package/dist/esm/lib/rag/defineRAG.js +0 -18
- package/dist/esm/lib/rag/defineRAG.js.map +1 -1
- package/dist/esm/lib/rag/indexDocuments.js +39 -4
- package/dist/esm/lib/rag/indexDocuments.js.map +1 -1
- package/dist/esm/memory/causal/loadSnapshot.js +1 -1
- package/dist/esm/memory/define.js +0 -14
- package/dist/esm/memory/define.js.map +1 -1
- package/dist/esm/memory/define.types.js +0 -10
- package/dist/esm/memory/define.types.js.map +1 -1
- package/dist/esm/resilience/index.js +0 -44
- package/dist/esm/resilience/index.js.map +1 -1
- package/dist/esm/stream.js +0 -29
- package/dist/esm/stream.js.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/injection-engine/SkillRegistry.js +87 -0
- package/dist/lib/injection-engine/SkillRegistry.js.map +1 -0
- package/dist/lib/injection-engine/factories/defineSkill.js +36 -1
- package/dist/lib/injection-engine/factories/defineSkill.js.map +1 -1
- package/dist/lib/injection-engine/index.js +4 -55
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/lib/mcp/index.js +3 -1
- package/dist/lib/mcp/index.js.map +1 -1
- package/dist/lib/mcp/mcpClient.js +29 -24
- package/dist/lib/mcp/mcpClient.js.map +1 -1
- package/dist/lib/mcp/mockMcpClient.js +101 -0
- package/dist/lib/mcp/mockMcpClient.js.map +1 -0
- package/dist/lib/rag/defineRAG.js +0 -18
- package/dist/lib/rag/defineRAG.js.map +1 -1
- package/dist/lib/rag/indexDocuments.js +39 -4
- package/dist/lib/rag/indexDocuments.js.map +1 -1
- package/dist/memory/causal/loadSnapshot.js +1 -1
- package/dist/memory/define.js +0 -14
- package/dist/memory/define.js.map +1 -1
- package/dist/memory/define.types.js +0 -10
- package/dist/memory/define.types.js.map +1 -1
- package/dist/resilience/index.js +0 -44
- package/dist/resilience/index.js.map +1 -1
- package/dist/stream.js +0 -29
- package/dist/stream.js.map +1 -1
- package/dist/types/adapters/llm/AnthropicProvider.d.ts +0 -31
- package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/BedrockProvider.d.ts +2 -28
- package/dist/types/adapters/llm/BedrockProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts +1 -31
- package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +1 -11
- package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/MockProvider.d.ts +45 -0
- package/dist/types/adapters/llm/MockProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/OpenAIProvider.d.ts +3 -29
- package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
- package/dist/types/adapters/memory/agentcore.d.ts +157 -0
- package/dist/types/adapters/memory/agentcore.d.ts.map +1 -0
- package/dist/types/adapters/memory/redis.d.ts +126 -0
- package/dist/types/adapters/memory/redis.d.ts.map +1 -0
- package/dist/types/core/Agent.d.ts +14 -0
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/SkillRegistry.d.ts +50 -0
- package/dist/types/lib/injection-engine/SkillRegistry.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/factories/defineSkill.d.ts +72 -0
- package/dist/types/lib/injection-engine/factories/defineSkill.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/index.d.ts +2 -55
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +10 -0
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/lib/mcp/index.d.ts +1 -0
- package/dist/types/lib/mcp/index.d.ts.map +1 -1
- package/dist/types/lib/mcp/mcpClient.d.ts +0 -17
- package/dist/types/lib/mcp/mcpClient.d.ts.map +1 -1
- package/dist/types/lib/mcp/mockMcpClient.d.ts +66 -0
- package/dist/types/lib/mcp/mockMcpClient.d.ts.map +1 -0
- package/dist/types/lib/mcp/types.d.ts +2 -0
- package/dist/types/lib/mcp/types.d.ts.map +1 -1
- package/dist/types/lib/rag/defineRAG.d.ts +18 -21
- package/dist/types/lib/rag/defineRAG.d.ts.map +1 -1
- package/dist/types/lib/rag/indexDocuments.d.ts +30 -1
- package/dist/types/lib/rag/indexDocuments.d.ts.map +1 -1
- package/dist/types/memory/causal/loadSnapshot.d.ts +1 -1
- package/dist/types/memory/define.d.ts +0 -14
- package/dist/types/memory/define.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +2 -12
- package/dist/types/memory/define.types.d.ts.map +1 -1
- package/dist/types/resilience/index.d.ts +0 -44
- package/dist/types/resilience/index.d.ts.map +1 -1
- package/dist/types/stream.d.ts +0 -29
- package/dist/types/stream.d.ts.map +1 -1
- package/package.json +39 -1
|
@@ -28,6 +28,55 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import type { Injection } from '../types.js';
|
|
30
30
|
import type { Tool } from '../../../core/tools.js';
|
|
31
|
+
/**
|
|
32
|
+
* Where the Skill's body lands when activated.
|
|
33
|
+
*
|
|
34
|
+
* - `'system-prompt'` — body appended to the system slot on the
|
|
35
|
+
* iteration after activation. Best on Claude ≥ 3.5 (training-time
|
|
36
|
+
* adherence to system-prompt instructions is strong).
|
|
37
|
+
* - `'tool-only'` — body delivered ONLY via the `read_skill` tool's
|
|
38
|
+
* result. Recency-first by protocol; doesn't rely on the model's
|
|
39
|
+
* training to honor system-prompt anchoring. Default for every
|
|
40
|
+
* non-Claude provider.
|
|
41
|
+
* - `'both'` — body lands in both the system slot AND the tool result.
|
|
42
|
+
* Belt-and-suspenders for high-stakes Skills on long-context runs.
|
|
43
|
+
* - `'auto'` — the library picks per provider via `resolveSurfaceMode`.
|
|
44
|
+
* `'both'` on Claude ≥ 3.5; `'tool-only'` everywhere else.
|
|
45
|
+
*
|
|
46
|
+
* **Today's behavior:** all four modes route through the recency-first
|
|
47
|
+
* path the essay describes as cross-provider-correct (the activation +
|
|
48
|
+
* next-iteration injection pattern). Full per-mode routing diversity
|
|
49
|
+
* (suppress system-prompt for `'tool-only'`, e.g.) is a v2.5 polish.
|
|
50
|
+
* Consumers express intent today; runtime behavior tightens later
|
|
51
|
+
* without API change.
|
|
52
|
+
*/
|
|
53
|
+
export type SurfaceMode = 'auto' | 'system-prompt' | 'tool-only' | 'both';
|
|
54
|
+
/**
|
|
55
|
+
* When (if ever) to re-deliver a Skill's body in long-running runs.
|
|
56
|
+
*
|
|
57
|
+
* Even on providers with strong system-prompt adherence, attention to
|
|
58
|
+
* the system slot decays past long contexts. `refreshPolicy` re-injects
|
|
59
|
+
* the body via tool result past a token threshold so the LLM sees it
|
|
60
|
+
* fresh again.
|
|
61
|
+
*
|
|
62
|
+
* **v2.4 status:** the field is reserved + typed; the runtime hook
|
|
63
|
+
* lands in v2.5 as part of the long-context attention work. Specifying
|
|
64
|
+
* `refreshPolicy` today is non-breaking — the engine ignores it until
|
|
65
|
+
* the hook is implemented.
|
|
66
|
+
*/
|
|
67
|
+
export interface RefreshPolicy {
|
|
68
|
+
/**
|
|
69
|
+
* Re-inject the Skill body once the run has consumed this many input
|
|
70
|
+
* tokens since the Skill was last surfaced. Recommended: 50_000 for
|
|
71
|
+
* 200k-context models; 20_000 for 32k-context models.
|
|
72
|
+
*/
|
|
73
|
+
readonly afterTokens: number;
|
|
74
|
+
/**
|
|
75
|
+
* How to re-inject. `'tool-result'` synthesizes a fresh tool result
|
|
76
|
+
* carrying the body text (recency-first). Other modes reserved.
|
|
77
|
+
*/
|
|
78
|
+
readonly via: 'tool-result';
|
|
79
|
+
}
|
|
31
80
|
export interface DefineSkillOptions {
|
|
32
81
|
readonly id: string;
|
|
33
82
|
/** Visible to the LLM via the activation tool's description. */
|
|
@@ -42,6 +91,29 @@ export interface DefineSkillOptions {
|
|
|
42
91
|
* the LLM picks WHICH skill via the tool's argument.
|
|
43
92
|
*/
|
|
44
93
|
readonly viaToolName?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Where the body lands when activated. See `SurfaceMode`. Default
|
|
96
|
+
* `'auto'` — the library resolves per provider via `resolveSurfaceMode`.
|
|
97
|
+
*/
|
|
98
|
+
readonly surfaceMode?: SurfaceMode;
|
|
99
|
+
/**
|
|
100
|
+
* Re-deliver the body past a token threshold to defend against
|
|
101
|
+
* long-context attention decay. Default: undefined (no refresh).
|
|
102
|
+
*/
|
|
103
|
+
readonly refreshPolicy?: RefreshPolicy;
|
|
45
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Resolve `surfaceMode: 'auto'` to a concrete mode based on provider
|
|
107
|
+
* + model. The defaults match the per-provider attention profile
|
|
108
|
+
* documented in the Skills, explained essay:
|
|
109
|
+
*
|
|
110
|
+
* - Claude >= 3.5 → 'both' (cheap to cache, high adherence)
|
|
111
|
+
* - Claude pre-3.5 → 'tool-only' (recency-first more reliable)
|
|
112
|
+
* - OpenAI / Bedrock / Ollama / Mock / unknown → 'tool-only'
|
|
113
|
+
*
|
|
114
|
+
* Pure function — no side effects. Consumers can call directly to
|
|
115
|
+
* inspect what `'auto'` will resolve to in their stack.
|
|
116
|
+
*/
|
|
117
|
+
export declare function resolveSurfaceMode(provider: string, model?: string): SurfaceMode;
|
|
46
118
|
export declare function defineSkill(opts: DefineSkillOptions): Injection;
|
|
47
119
|
//# sourceMappingURL=defineSkill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineSkill.d.ts","sourceRoot":"","sources":["../../../../../src/lib/injection-engine/factories/defineSkill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"defineSkill.d.ts","sourceRoot":"","sources":["../../../../../src/lib/injection-engine/factories/defineSkill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,eAAe,GAAG,WAAW,GAAG,MAAM,CAAC;AAE1E;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;CACxC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CAahF;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,SAAS,CAiC/D"}
|
|
@@ -4,66 +4,13 @@
|
|
|
4
4
|
* The unifying primitive of agentfootprint context engineering.
|
|
5
5
|
* One `Injection` type. One `InjectionEngine` subflow. N typed sugar
|
|
6
6
|
* factories. See `README.md` in this folder for the full concept.
|
|
7
|
-
*
|
|
8
|
-
* ─── 7-panel design review (2026-04-28) ─────────────────────────────
|
|
9
|
-
*
|
|
10
|
-
* LLM-AI system design ✓ ONE primitive replaces N feature-specific
|
|
11
|
-
* subsystems. Skill, Steering, Instruction,
|
|
12
|
-
* Context (and RAG, Memory, Guardrail)
|
|
13
|
-
* are typed sugar producing the same shape.
|
|
14
|
-
* Engine is shared; observability is shared;
|
|
15
|
-
* Lens chips are shared.
|
|
16
|
-
*
|
|
17
|
-
* Performance ✓ Trigger evaluation O(N) per iteration.
|
|
18
|
-
* Subflow ceremony ~50µs per iteration.
|
|
19
|
-
* Negligible. Active set materialized once,
|
|
20
|
-
* consumed by 3 slot subflows.
|
|
21
|
-
*
|
|
22
|
-
* Scalability ✓ Adding a flavor = adding a sugar factory
|
|
23
|
-
* file. Zero engine change. Library scales
|
|
24
|
-
* to 50+ flavors without bloating the
|
|
25
|
-
* engine. The "narrow waist" pattern.
|
|
26
|
-
*
|
|
27
|
-
* Research alignment ✓ Maps to "Augmented LM" framing
|
|
28
|
-
* (Mialon et al. 2023): every external
|
|
29
|
-
* input is an augmentation; agentfootprint
|
|
30
|
-
* calls them Injections. Factory names
|
|
31
|
-
* preserve research vocabulary (Skill, RAG,
|
|
32
|
-
* Memory, Steering) at the API surface.
|
|
33
|
-
*
|
|
34
|
-
* Flexibility ✓ Discriminated `trigger` union handles
|
|
35
|
-
* always / rule / on-tool-return /
|
|
36
|
-
* llm-activated. New trigger kinds extend
|
|
37
|
-
* cleanly. Multi-slot per Injection covers
|
|
38
|
-
* Skills (system-prompt + tools).
|
|
39
|
-
*
|
|
40
|
-
* Abstraction-modular ✓ Engine = subflow (drill-able). Factories
|
|
41
|
-
* = small files (one per flavor). Slot
|
|
42
|
-
* subflows are unchanged consumers.
|
|
43
|
-
* Textbook narrow-waist architecture.
|
|
44
|
-
*
|
|
45
|
-
* Software engineering ✓ Predicate exceptions caught + reported
|
|
46
|
-
* via `skipped[]`, never propagate. Frozen
|
|
47
|
-
* Injections. Validation in factories.
|
|
48
|
-
* 7-pattern test coverage. Subpath export
|
|
49
|
-
* for tree-shake.
|
|
50
|
-
*
|
|
51
|
-
* Plus footprintjs integration check ✓ — uses existing slot subflow
|
|
52
|
-
* convention (writes activeInjections to scope; slots filter by
|
|
53
|
-
* targeted slot) + ContextRecorder picks up source field zero-change.
|
|
54
|
-
*
|
|
55
|
-
* Plus TypeScript engineer check ✓ — discriminated union, no `any`,
|
|
56
|
-
* frozen returns, exhaustiveness check on trigger kind.
|
|
57
|
-
*
|
|
58
|
-
* ─── 7-pattern test coverage ────────────────────────────────────────
|
|
59
|
-
*
|
|
60
|
-
* See `test/lib/injection-engine/*.test.ts`.
|
|
61
7
|
*/
|
|
62
8
|
export type { Injection, InjectionTrigger, InjectionContent, InjectionContext, InjectionEvaluation, } from './types.js';
|
|
63
9
|
export { evaluateInjections } from './evaluator.js';
|
|
64
10
|
export { buildInjectionEngineSubflow, type InjectionEngineConfig, } from './buildInjectionEngineSubflow.js';
|
|
65
11
|
export { defineInstruction, type DefineInstructionOptions } from './factories/defineInstruction.js';
|
|
66
|
-
export { defineSkill, type DefineSkillOptions } from './factories/defineSkill.js';
|
|
12
|
+
export { defineSkill, resolveSurfaceMode, type DefineSkillOptions, type SurfaceMode, type RefreshPolicy, } from './factories/defineSkill.js';
|
|
13
|
+
export { SkillRegistry } from './SkillRegistry.js';
|
|
67
14
|
export { defineSteering, type DefineSteeringOptions } from './factories/defineSteering.js';
|
|
68
15
|
export { defineFact, type DefineFactOptions } from './factories/defineFact.js';
|
|
69
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/injection-engine/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/injection-engine/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EACL,2BAA2B,EAC3B,KAAK,qBAAqB,GAC3B,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAEpG,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAE3F,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -131,6 +131,16 @@ export interface Injection {
|
|
|
131
131
|
readonly trigger: InjectionTrigger;
|
|
132
132
|
/** WHAT to contribute (one or more slots). */
|
|
133
133
|
readonly inject: InjectionContent;
|
|
134
|
+
/**
|
|
135
|
+
* Optional flavor-specific metadata. Engine ignores keys it doesn't
|
|
136
|
+
* recognize; flavor factories use this for opt-in fields without
|
|
137
|
+
* widening the Injection contract.
|
|
138
|
+
*
|
|
139
|
+
* Known keys:
|
|
140
|
+
* - `surfaceMode` (Skill) — `'auto' | 'system-prompt' | 'tool-only' | 'both'`
|
|
141
|
+
* - `refreshPolicy` (Skill) — `{ afterTokens, via }`
|
|
142
|
+
*/
|
|
143
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
134
144
|
}
|
|
135
145
|
/**
|
|
136
146
|
* Returned by `evaluateInjections()`. Slot subflows consume `active`;
|
|
@@ -1 +1 @@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,CAAC;YAChC,QAAQ,CAAC,IAAI,EAAE,OAAO,uBAAuB,EAAE,WAAW,CAAC;YAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;SAC1B,CAAC,CAAC;QACH,uEAAuE;QACvE,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;YAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,yBAAyB,EAAE,aAAa,CAAC;YACjE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;SAC9B,CAAC,CAAC;KACJ,CAAC;CACH;AAED,wEAAwE;AACxE,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,SAAS,GAAG,eAAe,CAiBtE"}
|
|
@@ -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
|
|
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,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C3C,SAAS,IAAI,OAAO,CAAC;QACnB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;YAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YACtB,QAAQ,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'
|
|
127
|
-
*
|
|
128
|
-
*
|
|
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
|
|
1
|
+
{"version":3,"file":"defineRAG.d.ts","sourceRoot":"","sources":["../../../../src/lib/rag/defineRAG.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAIrE,MAAM,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.
|
|
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,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,qBAAqB;IACpC
|
|
1
|
+
{"version":3,"file":"indexDocuments.d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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.
|
|
15
|
+
* no context.
|
|
16
16
|
*
|
|
17
17
|
* Empty-query handling:
|
|
18
18
|
* No user message → no embedding → no search → empty result.
|
|
@@ -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
|
|
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.
|
|
197
|
-
*
|
|
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
|
|
1
|
+
{"version":3,"file":"define.types.d.ts","sourceRoot":"","sources":["../../../src/memory/define.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AACX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE1E;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;CAQpB,CAAC;AACX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE5F;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE9E;;;;;;;;GAQG;AACH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YAAY,CAAC,SAAS,CAAC;CAC9C;AAED,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IAClE,QAAQ,CAAC,IAAI,EAAE,OAAO,YAAY,CAAC,MAAM,CAAC;IAC1C,4DAA4D;IAC5D,QAAQ,CAAC,UAAU,CAAC,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
|
|
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"}
|