agentfootprint 2.4.0 → 2.5.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/README.md +21 -3
- package/dist/adapters/llm/AnthropicProvider.js +2 -2
- package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
- package/dist/adapters/llm/BedrockProvider.js +2 -2
- package/dist/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/adapters/llm/BrowserAnthropicProvider.js +96 -28
- package/dist/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
- package/dist/adapters/llm/OpenAIProvider.js +2 -2
- package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/adapters/memory/agentcore.js +9 -3
- package/dist/adapters/memory/agentcore.js.map +1 -1
- package/dist/adapters/memory/redis.js +9 -3
- package/dist/adapters/memory/redis.js.map +1 -1
- package/dist/core/Agent.js +477 -79
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/flowchartAsTool.js +188 -0
- package/dist/core/flowchartAsTool.js.map +1 -0
- package/dist/core/outputSchema.js +119 -0
- package/dist/core/outputSchema.js.map +1 -0
- package/dist/core/slots/buildSystemPromptSlot.js +8 -0
- package/dist/core/slots/buildSystemPromptSlot.js.map +1 -1
- package/dist/core/slots/buildToolsSlot.js +56 -5
- package/dist/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/esm/adapters/llm/AnthropicProvider.js +2 -2
- package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
- package/dist/esm/adapters/llm/BedrockProvider.js +2 -2
- package/dist/esm/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.js +96 -28
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
- package/dist/esm/adapters/llm/OpenAIProvider.js +2 -2
- package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/esm/adapters/memory/agentcore.js +9 -3
- package/dist/esm/adapters/memory/agentcore.js.map +1 -1
- package/dist/esm/adapters/memory/redis.js +9 -3
- package/dist/esm/adapters/memory/redis.js.map +1 -1
- package/dist/esm/core/Agent.js +476 -78
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/flowchartAsTool.js +184 -0
- package/dist/esm/core/flowchartAsTool.js.map +1 -0
- package/dist/esm/core/outputSchema.js +113 -0
- package/dist/esm/core/outputSchema.js.map +1 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.js +8 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.js.map +1 -1
- package/dist/esm/core/slots/buildToolsSlot.js +56 -5
- package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/esm/index.js +34 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/SkillRegistry.js +98 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.js.map +1 -1
- package/dist/esm/lib/injection-engine/factories/defineSkill.js +1 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.js.map +1 -1
- package/dist/esm/lib/injection-engine/index.js +7 -0
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillTools.js +125 -0
- package/dist/esm/lib/injection-engine/skillTools.js.map +1 -0
- package/dist/esm/lib/injection-engine/types.js +8 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/lazyRequire.js +33 -0
- package/dist/esm/lib/lazyRequire.js.map +1 -0
- package/dist/esm/lib/mcp/mcpClient.js +4 -6
- package/dist/esm/lib/mcp/mcpClient.js.map +1 -1
- package/dist/esm/llm-providers.js +31 -0
- package/dist/esm/llm-providers.js.map +1 -0
- package/dist/esm/locales/index.js +144 -0
- package/dist/esm/locales/index.js.map +1 -0
- package/dist/esm/memory-providers.js +44 -0
- package/dist/esm/memory-providers.js.map +1 -0
- package/dist/esm/providers.js +11 -0
- package/dist/esm/providers.js.map +1 -1
- package/dist/esm/recorders/core/contextEngineering.js +155 -0
- package/dist/esm/recorders/core/contextEngineering.js.map +1 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.js +6 -1
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
- package/dist/esm/security/PermissionPolicy.js +135 -0
- package/dist/esm/security/PermissionPolicy.js.map +1 -0
- package/dist/esm/security/index.js +38 -0
- package/dist/esm/security/index.js.map +1 -0
- package/dist/esm/tool-providers/gatedTools.js +52 -0
- package/dist/esm/tool-providers/gatedTools.js.map +1 -0
- package/dist/esm/tool-providers/index.js +43 -0
- package/dist/esm/tool-providers/index.js.map +1 -0
- package/dist/esm/tool-providers/skillScopedTools.js +63 -0
- package/dist/esm/tool-providers/skillScopedTools.js.map +1 -0
- package/dist/esm/tool-providers/staticTools.js +33 -0
- package/dist/esm/tool-providers/staticTools.js.map +1 -0
- package/dist/esm/tool-providers/types.js +53 -0
- package/dist/esm/tool-providers/types.js.map +1 -0
- package/dist/index.js +55 -12
- package/dist/index.js.map +1 -1
- package/dist/lib/injection-engine/SkillRegistry.js +98 -0
- package/dist/lib/injection-engine/SkillRegistry.js.map +1 -1
- package/dist/lib/injection-engine/factories/defineSkill.js +1 -0
- package/dist/lib/injection-engine/factories/defineSkill.js.map +1 -1
- package/dist/lib/injection-engine/index.js +11 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillTools.js +130 -0
- package/dist/lib/injection-engine/skillTools.js.map +1 -0
- package/dist/lib/injection-engine/types.js +8 -0
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/lib/lazyRequire.js +37 -0
- package/dist/lib/lazyRequire.js.map +1 -0
- package/dist/lib/mcp/mcpClient.js +4 -6
- package/dist/lib/mcp/mcpClient.js.map +1 -1
- package/dist/llm-providers.js +47 -0
- package/dist/llm-providers.js.map +1 -0
- package/dist/locales/index.js +149 -0
- package/dist/locales/index.js.map +1 -0
- package/dist/memory-providers.js +49 -0
- package/dist/memory-providers.js.map +1 -0
- package/dist/providers.js +11 -0
- package/dist/providers.js.map +1 -1
- package/dist/recorders/core/contextEngineering.js +161 -0
- package/dist/recorders/core/contextEngineering.js.map +1 -0
- package/dist/recorders/observability/commentary/commentaryTemplates.js +6 -1
- package/dist/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
- package/dist/security/PermissionPolicy.js +139 -0
- package/dist/security/PermissionPolicy.js.map +1 -0
- package/dist/security/index.js +42 -0
- package/dist/security/index.js.map +1 -0
- package/dist/tool-providers/gatedTools.js +56 -0
- package/dist/tool-providers/gatedTools.js.map +1 -0
- package/dist/tool-providers/index.js +51 -0
- package/dist/tool-providers/index.js.map +1 -0
- package/dist/tool-providers/skillScopedTools.js +67 -0
- package/dist/tool-providers/skillScopedTools.js.map +1 -0
- package/dist/tool-providers/staticTools.js +37 -0
- package/dist/tool-providers/staticTools.js.map +1 -0
- package/dist/tool-providers/types.js +54 -0
- package/dist/tool-providers/types.js.map +1 -0
- package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/BedrockProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
- package/dist/types/adapters/memory/agentcore.d.ts +7 -1
- package/dist/types/adapters/memory/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/memory/redis.d.ts +7 -1
- package/dist/types/adapters/memory/redis.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +202 -2
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/flowchartAsTool.d.ts +161 -0
- package/dist/types/core/flowchartAsTool.d.ts.map +1 -0
- package/dist/types/core/outputSchema.d.ts +128 -0
- package/dist/types/core/outputSchema.d.ts.map +1 -0
- package/dist/types/core/slots/buildSystemPromptSlot.d.ts.map +1 -1
- package/dist/types/core/slots/buildToolsSlot.d.ts +10 -0
- package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/SkillRegistry.d.ts +98 -0
- package/dist/types/lib/injection-engine/SkillRegistry.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/factories/defineSkill.d.ts +33 -6
- package/dist/types/lib/injection-engine/factories/defineSkill.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/index.d.ts +5 -3
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillTools.d.ts +73 -0
- package/dist/types/lib/injection-engine/skillTools.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/types.d.ts +18 -0
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/lib/lazyRequire.d.ts +30 -0
- package/dist/types/lib/lazyRequire.d.ts.map +1 -0
- package/dist/types/lib/mcp/mcpClient.d.ts.map +1 -1
- package/dist/types/llm-providers.d.ts +31 -0
- package/dist/types/llm-providers.d.ts.map +1 -0
- package/dist/types/locales/index.d.ts +133 -0
- package/dist/types/locales/index.d.ts.map +1 -0
- package/dist/types/memory-providers.d.ts +41 -0
- package/dist/types/memory-providers.d.ts.map +1 -0
- package/dist/types/providers.d.ts +11 -0
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/recorders/core/contextEngineering.d.ts +137 -0
- package/dist/types/recorders/core/contextEngineering.d.ts.map +1 -0
- package/dist/types/recorders/observability/commentary/commentaryTemplates.d.ts.map +1 -1
- package/dist/types/security/PermissionPolicy.d.ts +125 -0
- package/dist/types/security/PermissionPolicy.d.ts.map +1 -0
- package/dist/types/security/index.d.ts +40 -0
- package/dist/types/security/index.d.ts.map +1 -0
- package/dist/types/tool-providers/gatedTools.d.ts +37 -0
- package/dist/types/tool-providers/gatedTools.d.ts.map +1 -0
- package/dist/types/tool-providers/index.d.ts +42 -0
- package/dist/types/tool-providers/index.d.ts.map +1 -0
- package/dist/types/tool-providers/skillScopedTools.d.ts +46 -0
- package/dist/types/tool-providers/skillScopedTools.d.ts.map +1 -0
- package/dist/types/tool-providers/staticTools.d.ts +22 -0
- package/dist/types/tool-providers/staticTools.d.ts.map +1 -0
- package/dist/types/tool-providers/types.d.ts +103 -0
- package/dist/types/tool-providers/types.d.ts.map +1 -0
- package/package.json +36 -2
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Skill-tool builders — shared source of truth for `list_skills` and
|
|
4
|
+
* `read_skill` tools used by the Agent's auto-attach path AND by
|
|
5
|
+
* `SkillRegistry.toTools()` (explicit composition path).
|
|
6
|
+
*
|
|
7
|
+
* Both tools work over the SAME catalog (a list of `Injection` skills).
|
|
8
|
+
* Pulling them out of `core/Agent.ts` removes the v2.4 duplication
|
|
9
|
+
* risk: the Agent auto-attaches its own `read_skill`, the registry
|
|
10
|
+
* builds a sibling — they MUST agree on schema + execute semantics.
|
|
11
|
+
*
|
|
12
|
+
* Pattern: pure builder functions over an `Injection[]` catalog.
|
|
13
|
+
* Tool execute is identity-style (returns confirmation
|
|
14
|
+
* string); the agent's tool-calls subflow inspects the
|
|
15
|
+
* tool name + args and updates `scope.activatedInjectionIds`
|
|
16
|
+
* so the next iteration's InjectionEngine sees the new
|
|
17
|
+
* activation.
|
|
18
|
+
*
|
|
19
|
+
* Closes Neo gap #3 (of 8) by making the LLM-facing skill discovery
|
|
20
|
+
* surface composable — consumers can plug `listSkills` / `readSkill`
|
|
21
|
+
* into their own ToolProvider chain (e.g., gatedTools → permission
|
|
22
|
+
* filter → static + skill-tools).
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.buildReadSkillTool = exports.buildListSkillsTool = void 0;
|
|
26
|
+
const tools_js_1 = require("../../core/tools.js");
|
|
27
|
+
/**
|
|
28
|
+
* Build the `list_skills` tool — a no-arg tool that returns the
|
|
29
|
+
* registered skills as `{ id, description }[]`. Lets the LLM discover
|
|
30
|
+
* skills without paying the prompt-token cost of embedding the
|
|
31
|
+
* catalog into every system prompt.
|
|
32
|
+
*
|
|
33
|
+
* Pairs with `read_skill` (which actually activates a skill by id).
|
|
34
|
+
*
|
|
35
|
+
* Returns `undefined` when there are no skills — callers should
|
|
36
|
+
* guard or filter undefined out of their tool list.
|
|
37
|
+
*/
|
|
38
|
+
function buildListSkillsTool(skills) {
|
|
39
|
+
if (skills.length === 0)
|
|
40
|
+
return undefined;
|
|
41
|
+
// Capture a stable snapshot — the registry/agent calls this at
|
|
42
|
+
// build time, so the tool reflects the catalog as of registration.
|
|
43
|
+
const catalog = skills.map((s) => ({
|
|
44
|
+
id: s.id,
|
|
45
|
+
description: s.description ?? '(no description)',
|
|
46
|
+
}));
|
|
47
|
+
return (0, tools_js_1.defineTool)({
|
|
48
|
+
name: 'list_skills',
|
|
49
|
+
description: 'List all available skills with their ids and descriptions. ' +
|
|
50
|
+
'Use this to discover what skills exist before calling read_skill.',
|
|
51
|
+
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
|
|
52
|
+
execute: () => {
|
|
53
|
+
// Return as a JSON-serialized string so the LLM can parse easily.
|
|
54
|
+
return JSON.stringify(catalog, null, 2);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.buildListSkillsTool = buildListSkillsTool;
|
|
59
|
+
/**
|
|
60
|
+
* Build the `read_skill` tool — activates a skill for the next
|
|
61
|
+
* iteration. The LLM picks WHICH skill via the `id` argument.
|
|
62
|
+
*
|
|
63
|
+
* Tool execute() returns a confirmation string. The actual bookkeeping
|
|
64
|
+
* (appending the requested skill id to `scope.activatedInjectionIds`)
|
|
65
|
+
* is handled by the Agent's tool-calls subflow, which inspects every
|
|
66
|
+
* `read_skill` tool call by name. The next iteration's InjectionEngine
|
|
67
|
+
* matches Skills with `trigger.kind: 'llm-activated'` by id and
|
|
68
|
+
* includes them in the active set; slot subflows then inject the body
|
|
69
|
+
* + tools.
|
|
70
|
+
*
|
|
71
|
+
* The tool's description lists each Skill's `id` + `description` so
|
|
72
|
+
* the LLM can choose meaningfully without first calling `list_skills`
|
|
73
|
+
* (a perf trade-off — small registries can afford the inline catalog;
|
|
74
|
+
* large ones should use `list_skills` for discovery and rely on the
|
|
75
|
+
* shorter `read_skill` description.) See `surfaceMode` (Block A4) for
|
|
76
|
+
* tunable trade-offs.
|
|
77
|
+
*
|
|
78
|
+
* Returns `undefined` when there are no skills — callers should
|
|
79
|
+
* guard or filter undefined out of their tool list.
|
|
80
|
+
*/
|
|
81
|
+
function buildReadSkillTool(skills) {
|
|
82
|
+
if (skills.length === 0)
|
|
83
|
+
return undefined;
|
|
84
|
+
const skillIds = skills.map((s) => s.id);
|
|
85
|
+
const skillCatalog = skills
|
|
86
|
+
.map((s) => ` - ${s.id}: ${s.description ?? '(no description)'}`)
|
|
87
|
+
.join('\n');
|
|
88
|
+
const byId = new Map();
|
|
89
|
+
for (const s of skills) {
|
|
90
|
+
const meta = s.metadata;
|
|
91
|
+
byId.set(s.id, {
|
|
92
|
+
body: s.inject.systemPrompt ?? '',
|
|
93
|
+
surfaceMode: meta?.surfaceMode ?? 'auto',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return (0, tools_js_1.defineTool)({
|
|
97
|
+
name: 'read_skill',
|
|
98
|
+
description: `Activate a skill for the next iteration. Available skills:\n${skillCatalog}\n\n` +
|
|
99
|
+
`Pass the skill's id. The skill's body becomes part of the system prompt and any ` +
|
|
100
|
+
`gated tools become available on the next call.`,
|
|
101
|
+
inputSchema: {
|
|
102
|
+
type: 'object',
|
|
103
|
+
properties: {
|
|
104
|
+
id: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
enum: skillIds,
|
|
107
|
+
description: 'The skill id to activate.',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
required: ['id'],
|
|
111
|
+
},
|
|
112
|
+
execute: ({ id }) => {
|
|
113
|
+
const entry = byId.get(id);
|
|
114
|
+
if (!entry) {
|
|
115
|
+
return `Unknown skill '${id}'. Available: ${skillIds.join(', ')}`;
|
|
116
|
+
}
|
|
117
|
+
// Block C — per-mode tool-result dispatch:
|
|
118
|
+
// - 'tool-only' / 'both' → return body verbatim (recency-first
|
|
119
|
+
// delivery; LLM sees it as the most recent tool result).
|
|
120
|
+
// - 'system-prompt' / 'auto' / unspecified → return confirmation
|
|
121
|
+
// only; body lands via system slot on the next iteration.
|
|
122
|
+
if ((entry.surfaceMode === 'tool-only' || entry.surfaceMode === 'both') && entry.body) {
|
|
123
|
+
return entry.body;
|
|
124
|
+
}
|
|
125
|
+
return `Skill '${id}' activated for the next iteration.`;
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
exports.buildReadSkillTool = buildReadSkillTool;
|
|
130
|
+
//# sourceMappingURL=skillTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skillTools.js","sourceRoot":"","sources":["../../../src/lib/injection-engine/skillTools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAEH,kDAAiD;AAIjD;;;;;;;;;;GAUG;AACH,SAAgB,mBAAmB,CAAC,MAA4B;IAC9D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAE1C,+DAA+D;IAC/D,mEAAmE;IACnE,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACjC,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,kBAAkB;KACjD,CAAC,CAAC,CAAC;IAEJ,OAAO,IAAA,qBAAU,EAAgC;QAC/C,IAAI,EAAE,aAAa;QACnB,WAAW,EACT,6DAA6D;YAC7D,mEAAmE;QACrE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE;QAC5E,OAAO,EAAE,GAAG,EAAE;YACZ,kEAAkE;YAClE,O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ACD,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;YAClB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC3B,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO,kBAAkB,EAAE,iBAAiB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACpE,CAAC;YACD,2CAA2C;YAC3C,iEAAiE;YACjE,6DAA6D;YAC7D,mEAAmE;YACnE,8DAA8D;YAC9D,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,IAAI,KAAK,CAAC,WAAW,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;gBACtF,OAAO,KAAK,CAAC,IAAI,CAAC;YACpB,CAAC;YACD,OAAO,UAAU,EAAE,qCAAqC,CAAC;QAC3D,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAxDD,gDAwDC"}
|
|
@@ -21,10 +21,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.projectActiveInjection = void 0;
|
|
22
22
|
/** Project a full Injection (with functions) into a scope-safe POJO. */
|
|
23
23
|
function projectActiveInjection(inj) {
|
|
24
|
+
// Project per-skill metadata that slot subflows need to dispatch on.
|
|
25
|
+
// `surfaceMode` drives the system-prompt-suppression decision (Block C).
|
|
26
|
+
// `autoActivate` is reserved for runtime tool gating (forward-compat).
|
|
27
|
+
const meta = inj.metadata;
|
|
24
28
|
const out = {
|
|
25
29
|
id: inj.id,
|
|
26
30
|
flavor: inj.flavor,
|
|
27
31
|
...(inj.description && { description: inj.description }),
|
|
32
|
+
...(meta?.surfaceMode && { surfaceMode: meta.surfaceMode }),
|
|
33
|
+
...(meta?.autoActivate && {
|
|
34
|
+
autoActivate: meta.autoActivate,
|
|
35
|
+
}),
|
|
28
36
|
inject: {
|
|
29
37
|
...(inj.inject.systemPrompt && { systemPrompt: inj.inject.systemPrompt }),
|
|
30
38
|
...(inj.inject.messages && { messages: inj.inject.messages.map((m) => ({ ...m })) }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/injection-engine/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/injection-engine/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAuMH,wEAAwE;AACxE,SAAgB,sBAAsB,CAAC,GAAc;IACnD,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,MAAM,IAAI,GAAG,GAAG,CAAC,QAAuE,CAAC;IACzF,MAAM,GAAG,GAAoB;QAC3B,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,GAAG,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC;QACxD,GAAG,CAAC,IAAI,EAAE,WAAW,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAA6C,EAAE,CAAC;QAC7F,GAAG,CAAC,IAAI,EAAE,YAAY,IAAI;YACxB,YAAY,EAAE,IAAI,CAAC,YAA+C;SACnE,CAAC;QACF,MAAM,EAAE;YACN,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACzE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACpF,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI;gBACtB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBAClC,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE;oBACvB,WAAW,EAAE,GAAG,CAAC,EAAE;iBACpB,CAAC,CAAC;aACJ,CAAC;SACH;KACF,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC;AAzBD,wDAyBC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lazyRequire = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* lazyRequire — module-path-indirect `require()` wrapper for lazy
|
|
6
|
+
* peer-dep loading.
|
|
7
|
+
*
|
|
8
|
+
* Why a wrapper: bundlers (Vite, esbuild, webpack, Rollup) statically
|
|
9
|
+
* analyze `require('literal-string')` calls and try to resolve the
|
|
10
|
+
* dependency at BUILD time — even when the function is never called
|
|
11
|
+
* at runtime. For optional peer-deps (`@modelcontextprotocol/sdk`,
|
|
12
|
+
* `@anthropic-ai/sdk`, `ioredis`, `@aws-sdk/client-bedrock-*`), this
|
|
13
|
+
* means consumers who never instantiate the matching adapter still
|
|
14
|
+
* get a build error if the peer-dep isn't installed.
|
|
15
|
+
*
|
|
16
|
+
* Wrapping the call in a function with a string PARAMETER hides the
|
|
17
|
+
* specifier from static analysis. At runtime this is exactly the
|
|
18
|
+
* same as inline `require()`, including the throwing behavior when
|
|
19
|
+
* the peer-dep isn't installed.
|
|
20
|
+
*
|
|
21
|
+
* Pattern: indirect require — used by Node's `createRequire`-style
|
|
22
|
+
* fallbacks for the same reason.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* try {
|
|
26
|
+
* const mod = lazyRequire<typeof import('ioredis')>('ioredis');
|
|
27
|
+
* this._client = new mod.default(...);
|
|
28
|
+
* } catch {
|
|
29
|
+
* throw new Error('install ioredis to use RedisStore');
|
|
30
|
+
* }
|
|
31
|
+
*/
|
|
32
|
+
function lazyRequire(specifier) {
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
34
|
+
return require(specifier);
|
|
35
|
+
}
|
|
36
|
+
exports.lazyRequire = lazyRequire;
|
|
37
|
+
//# sourceMappingURL=lazyRequire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazyRequire.js","sourceRoot":"","sources":["../../src/lib/lazyRequire.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,WAAW,CAAc,SAAiB;IACxD,iEAAiE;IACjE,OAAO,OAAO,CAAC,SAAS,CAAM,CAAC;AACjC,CAAC;AAHD,kCAGC"}
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
*/
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.mcpClient = void 0;
|
|
39
|
+
const lazyRequire_js_1 = require("../lazyRequire.js");
|
|
39
40
|
// Version-less identity. The MCP `clientInfo` field is informational
|
|
40
41
|
// (server logs it); a hardcoded number drifts every release. Consumers
|
|
41
42
|
// who care about wire-level identity pass `clientInfo` explicitly.
|
|
@@ -95,8 +96,7 @@ exports.mcpClient = mcpClient;
|
|
|
95
96
|
async function resolveClient(transport, clientInfo) {
|
|
96
97
|
let mod;
|
|
97
98
|
try {
|
|
98
|
-
|
|
99
|
-
mod = require('@modelcontextprotocol/sdk/client/index.js');
|
|
99
|
+
mod = (0, lazyRequire_js_1.lazyRequire)('@modelcontextprotocol/sdk/client/index.js');
|
|
100
100
|
}
|
|
101
101
|
catch {
|
|
102
102
|
throw new Error('mcpClient requires @modelcontextprotocol/sdk.\n' +
|
|
@@ -114,8 +114,7 @@ async function buildTransport(t) {
|
|
|
114
114
|
if (t.transport === 'stdio') {
|
|
115
115
|
let stdioMod;
|
|
116
116
|
try {
|
|
117
|
-
|
|
118
|
-
stdioMod = require('@modelcontextprotocol/sdk/client/stdio.js');
|
|
117
|
+
stdioMod = (0, lazyRequire_js_1.lazyRequire)('@modelcontextprotocol/sdk/client/stdio.js');
|
|
119
118
|
}
|
|
120
119
|
catch {
|
|
121
120
|
throw new Error('mcpClient(stdio) requires @modelcontextprotocol/sdk/client/stdio.js — ' +
|
|
@@ -131,8 +130,7 @@ async function buildTransport(t) {
|
|
|
131
130
|
// http transport
|
|
132
131
|
let httpMod;
|
|
133
132
|
try {
|
|
134
|
-
|
|
135
|
-
httpMod = require('@modelcontextprotocol/sdk/client/streamableHttp.js');
|
|
133
|
+
httpMod = (0, lazyRequire_js_1.lazyRequire)('@modelcontextprotocol/sdk/client/streamableHttp.js');
|
|
136
134
|
}
|
|
137
135
|
catch {
|
|
138
136
|
throw new Error('mcpClient(http) requires @modelcontextprotocol/sdk/client/streamableHttp.js — ' +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpClient.js","sourceRoot":"","sources":["../../../src/lib/mcp/mcpClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;
|
|
1
|
+
{"version":3,"file":"mcpClient.js","sourceRoot":"","sources":["../../../src/lib/mcp/mcpClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;AAIH,sDAAgD;AAEhD,qEAAqE;AACrE,uEAAuE;AACvE,mEAAmE;AACnE,MAAM,mBAAmB,GAAG;IAC1B,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,OAAO;CACjB,CAAC;AAEF;;;;;;;;GAQG;AACI,KAAK,UAAU,SAAS,CAAC,IAAsB;IACpD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,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AAI,GAAG,MAAM,CAAC,OAAO;iBACxB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;iBAClE,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CACb,aAAa,GAAG,CAAC,IAAI,cAAc,UAAU,yBAAyB,IAAI,EAAE,CAC7E,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* agentfootprint/llm-providers — LLM provider adapters (canonical subpath).
|
|
4
|
+
*
|
|
5
|
+
* The Block B canonical name. Mirrors the parallel structure shipped in
|
|
6
|
+
* v2.5:
|
|
7
|
+
*
|
|
8
|
+
* agentfootprint/llm-providers ← LLM provider adapters (this file)
|
|
9
|
+
* agentfootprint/tool-providers ← tool dispatch + tool sources
|
|
10
|
+
* agentfootprint/memory-providers ← memory store adapters
|
|
11
|
+
* agentfootprint/security ← cross-cutting authorization
|
|
12
|
+
*
|
|
13
|
+
* The legacy `agentfootprint/providers` subpath stays available as an
|
|
14
|
+
* alias through the v2.x line — it points at the same exports. New
|
|
15
|
+
* code SHOULD import from `agentfootprint/llm-providers` for clarity:
|
|
16
|
+
* grep'ing for "llm-providers" finds every LLM-side import in one
|
|
17
|
+
* shot, parallel to "tool-providers" and "memory-providers".
|
|
18
|
+
*
|
|
19
|
+
* Pattern: Adapter (GoF) — concrete `LLMProvider` implementations that
|
|
20
|
+
* translate the agentfootprint port to a specific vendor SDK.
|
|
21
|
+
* Role: Outer ring (Hexagonal). Swappable at runtime; the Agent
|
|
22
|
+
* knows nothing about vendor specifics.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // New canonical import
|
|
26
|
+
* import { mock, AnthropicProvider } from 'agentfootprint/llm-providers';
|
|
27
|
+
*
|
|
28
|
+
* // Legacy alias (still works through v2.x)
|
|
29
|
+
* import { mock, AnthropicProvider } from 'agentfootprint/providers';
|
|
30
|
+
*/
|
|
31
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
32
|
+
if (k2 === undefined) k2 = k;
|
|
33
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
34
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
35
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
36
|
+
}
|
|
37
|
+
Object.defineProperty(o, k2, desc);
|
|
38
|
+
}) : (function(o, m, k, k2) {
|
|
39
|
+
if (k2 === undefined) k2 = k;
|
|
40
|
+
o[k2] = m[k];
|
|
41
|
+
}));
|
|
42
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
43
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
__exportStar(require("./providers.js"), exports);
|
|
47
|
+
//# sourceMappingURL=llm-providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-providers.js","sourceRoot":"","sources":["../src/llm-providers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;;;;;;;;;;;;;;AAEH,iDAA+B"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* agentfootprint/locales — Message Catalog Pattern.
|
|
4
|
+
*
|
|
5
|
+
* The Block D piece. agentfootprint emits user-facing prose at two
|
|
6
|
+
* audience levels:
|
|
7
|
+
*
|
|
8
|
+
* - **Commentary** — third-person prose for the bottom panel of any
|
|
9
|
+
* viewer (Lens, CLI tail, log files). "The agent dispatched the
|
|
10
|
+
* refund tool, which returned successfully."
|
|
11
|
+
* - **Thinking** — first-person status for chat-bubble UIs.
|
|
12
|
+
* "Looking up your order…"
|
|
13
|
+
*
|
|
14
|
+
* v2.4 shipped these as `defaultCommentaryTemplates` and
|
|
15
|
+
* `defaultThinkingTemplates` (flat `Record<string, string>` maps with
|
|
16
|
+
* `{{var}}` substitution). The names worked but the framing was
|
|
17
|
+
* generic — "templates" collides with TypeScript / templating-engine
|
|
18
|
+
* terminology, and there was no first-class place to ship locale
|
|
19
|
+
* packs.
|
|
20
|
+
*
|
|
21
|
+
* **Block D formalizes this as the Message Catalog Pattern:**
|
|
22
|
+
*
|
|
23
|
+
* - `defaultCommentaryMessages` / `defaultThinkingMessages` —
|
|
24
|
+
* canonical English bundles. Aliases of the v2.4 names; symbol
|
|
25
|
+
* identity preserved (`defaultCommentaryMessages ===
|
|
26
|
+
* defaultCommentaryTemplates`).
|
|
27
|
+
* - `composeMessages(defaults, overrides)` — spread overrides on
|
|
28
|
+
* top of defaults; missing keys fall back to the default bundle.
|
|
29
|
+
* - `validateMessages(catalog, requiredKeys)` — assert every
|
|
30
|
+
* required key is present (and non-empty). Catches drift between
|
|
31
|
+
* a consumer's locale pack and the framework's required key set.
|
|
32
|
+
*
|
|
33
|
+
* The natural consumer pattern is to ship locale packs alongside the
|
|
34
|
+
* agent code:
|
|
35
|
+
*
|
|
36
|
+
* import { defaultCommentaryMessages, composeMessages } from 'agentfootprint/locales';
|
|
37
|
+
* import { esCommentaryMessages } from './locales/es.js';
|
|
38
|
+
*
|
|
39
|
+
* const merged = composeMessages(defaultCommentaryMessages, esCommentaryMessages);
|
|
40
|
+
*
|
|
41
|
+
* const agent = Agent.create({...})
|
|
42
|
+
* .commentaryTemplates(merged)
|
|
43
|
+
* .build();
|
|
44
|
+
*
|
|
45
|
+
* Pattern: i18n locale resolution (Resource Bundle, Fowler 2002) +
|
|
46
|
+
* plain object merge for overrides. No catalog inheritance
|
|
47
|
+
* chain — overrides win OR fall back to defaults.
|
|
48
|
+
*
|
|
49
|
+
* @example Locale pack drop-in
|
|
50
|
+
* const esThinking = composeMessages(defaultThinkingMessages, {
|
|
51
|
+
* 'stream.llm_start.iter1': '{{appName}} está pensando...',
|
|
52
|
+
* 'stream.tool_start': 'Llamando a {{toolName}}...',
|
|
53
|
+
* });
|
|
54
|
+
* const agent = Agent.create({...}).thinkingTemplates(esThinking).build();
|
|
55
|
+
*
|
|
56
|
+
* @example Validate a locale pack against the framework's required keys
|
|
57
|
+
* import { defaultCommentaryMessages, validateMessages } from 'agentfootprint/locales';
|
|
58
|
+
*
|
|
59
|
+
* const myCatalog = composeMessages(defaultCommentaryMessages, customOverrides);
|
|
60
|
+
* validateMessages(myCatalog, Object.keys(defaultCommentaryMessages));
|
|
61
|
+
* // throws on first missing OR empty key — fail-fast at boot
|
|
62
|
+
*/
|
|
63
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
+
exports.validateMessages = exports.composeMessages = exports.defaultThinkingMessages = exports.defaultCommentaryMessages = void 0;
|
|
65
|
+
const commentaryTemplates_js_1 = require("../recorders/observability/commentary/commentaryTemplates.js");
|
|
66
|
+
const thinkingTemplates_js_1 = require("../recorders/observability/thinking/thinkingTemplates.js");
|
|
67
|
+
/**
|
|
68
|
+
* Canonical English commentary bundle. Alias of v2.4's
|
|
69
|
+
* `defaultCommentaryTemplates` — same symbol, friendlier framing.
|
|
70
|
+
*
|
|
71
|
+
* Keys mirror agentfootprint event types; values may contain
|
|
72
|
+
* `{{var}}` placeholders for runtime substitution.
|
|
73
|
+
*/
|
|
74
|
+
exports.defaultCommentaryMessages = commentaryTemplates_js_1.defaultCommentaryTemplates;
|
|
75
|
+
/**
|
|
76
|
+
* Canonical English thinking bundle. Alias of v2.4's
|
|
77
|
+
* `defaultThinkingTemplates`.
|
|
78
|
+
*
|
|
79
|
+
* Keys mirror agentfootprint event types; values may contain
|
|
80
|
+
* `{{var}}` placeholders for runtime substitution.
|
|
81
|
+
*/
|
|
82
|
+
exports.defaultThinkingMessages = thinkingTemplates_js_1.defaultThinkingTemplates;
|
|
83
|
+
/**
|
|
84
|
+
* Spread `overrides` on top of `defaults` so every key in `defaults`
|
|
85
|
+
* has a value (the override or the original). The result is a fresh
|
|
86
|
+
* object — neither input is mutated.
|
|
87
|
+
*
|
|
88
|
+
* Missing override keys fall back to the default; extra override
|
|
89
|
+
* keys are preserved (forward-compat for consumer-defined keys).
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* const merged = composeMessages(defaultCommentaryMessages, {
|
|
93
|
+
* 'stream.llm_start.iter1': 'My custom thinking line',
|
|
94
|
+
* });
|
|
95
|
+
*/
|
|
96
|
+
function composeMessages(defaults, overrides = {}) {
|
|
97
|
+
return Object.freeze({ ...defaults, ...overrides });
|
|
98
|
+
}
|
|
99
|
+
exports.composeMessages = composeMessages;
|
|
100
|
+
/**
|
|
101
|
+
* Assert that every key in `requiredKeys` is present in `catalog`.
|
|
102
|
+
* Throws an Error listing every missing key — batched so consumers
|
|
103
|
+
* fix all at once instead of error-by-error.
|
|
104
|
+
*
|
|
105
|
+
* Useful at boot to catch drift between a consumer's locale pack and
|
|
106
|
+
* the framework's required key set.
|
|
107
|
+
*
|
|
108
|
+
* Empty-string values are VALID by default — the framework's default
|
|
109
|
+
* catalogs use `''` to signal "render nothing for this event."
|
|
110
|
+
* Pass `{ forbidEmpty: true }` to also reject empty values.
|
|
111
|
+
*
|
|
112
|
+
* @param catalog The (composed) message catalog to validate.
|
|
113
|
+
* @param requiredKeys The keys consumers must define. Typically
|
|
114
|
+
* `Object.keys(defaultCommentaryMessages)` or
|
|
115
|
+
* `Object.keys(defaultThinkingMessages)`.
|
|
116
|
+
* @param opts Optional `{ label, forbidEmpty }` (or a bare
|
|
117
|
+
* string label for back-compat with simple use).
|
|
118
|
+
*
|
|
119
|
+
* @throws Error when any required key is missing (or empty under
|
|
120
|
+
* `forbidEmpty`).
|
|
121
|
+
*/
|
|
122
|
+
function validateMessages(catalog, requiredKeys, opts = {}) {
|
|
123
|
+
const resolved = typeof opts === 'string' ? { label: opts } : opts;
|
|
124
|
+
const label = resolved.label ?? 'message catalog';
|
|
125
|
+
const forbidEmpty = resolved.forbidEmpty ?? false;
|
|
126
|
+
const missing = [];
|
|
127
|
+
const empty = [];
|
|
128
|
+
for (const key of requiredKeys) {
|
|
129
|
+
const value = catalog[key];
|
|
130
|
+
if (value === undefined) {
|
|
131
|
+
missing.push(key);
|
|
132
|
+
}
|
|
133
|
+
else if (forbidEmpty && value.length === 0) {
|
|
134
|
+
empty.push(key);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (missing.length === 0 && empty.length === 0)
|
|
138
|
+
return;
|
|
139
|
+
const parts = [];
|
|
140
|
+
if (missing.length > 0) {
|
|
141
|
+
parts.push(`missing keys: ${missing.join(', ')}`);
|
|
142
|
+
}
|
|
143
|
+
if (empty.length > 0) {
|
|
144
|
+
parts.push(`empty values: ${empty.join(', ')}`);
|
|
145
|
+
}
|
|
146
|
+
throw new Error(`validateMessages(${label}): ${parts.join('; ')}.`);
|
|
147
|
+
}
|
|
148
|
+
exports.validateMessages = validateMessages;
|
|
149
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/locales/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;;;AAEH,yGAA0G;AAC1G,mGAAoG;AAIpG;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,mDAA0B,CAAC;AAEpE;;;;;;GAMG;AACU,QAAA,uBAAuB,GAAG,+CAAwB,CAAC;AAEhE;;;;;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CAAC;IACpD,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,KAAK,CAAC,IAAI,CAAC,iBAAiB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,KAAK,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtE,CAAC;AA5BD,4CA4BC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* agentfootprint/memory-providers — memory store adapters (canonical subpath).
|
|
4
|
+
*
|
|
5
|
+
* The Block B canonical name. Mirrors the parallel structure shipped in
|
|
6
|
+
* v2.5:
|
|
7
|
+
*
|
|
8
|
+
* agentfootprint/llm-providers ← LLM provider adapters
|
|
9
|
+
* agentfootprint/tool-providers ← tool dispatch + tool sources
|
|
10
|
+
* agentfootprint/memory-providers ← memory store adapters (this file)
|
|
11
|
+
* agentfootprint/security ← cross-cutting authorization
|
|
12
|
+
*
|
|
13
|
+
* One subpath that grows — RedisStore, AgentCoreStore, and future
|
|
14
|
+
* stores (DynamoDB, Postgres, Pinecone, …) all live here. No more
|
|
15
|
+
* adding `agentfootprint/memory-<vendor>` per-adapter subpath each
|
|
16
|
+
* time a new store ships.
|
|
17
|
+
*
|
|
18
|
+
* Per-adapter aliases (`agentfootprint/memory-redis`,
|
|
19
|
+
* `agentfootprint/memory-agentcore`) stay available through the v2.x
|
|
20
|
+
* line — they point at the same files. New code SHOULD import from
|
|
21
|
+
* `agentfootprint/memory-providers`:
|
|
22
|
+
*
|
|
23
|
+
* import { RedisStore, AgentCoreStore } from 'agentfootprint/memory-providers';
|
|
24
|
+
*
|
|
25
|
+
* Pattern: Adapter (GoF) — each store translates the `MemoryStore`
|
|
26
|
+
* interface onto a specific backend (Redis, DynamoDB-style
|
|
27
|
+
* AWS Bedrock AgentCore Memory, etc.).
|
|
28
|
+
* Role: Outer ring (Hexagonal). All store adapters lazy-require
|
|
29
|
+
* their vendor SDKs at construction time, so importing this
|
|
30
|
+
* barrel costs ZERO peer-dep load — only the stores you
|
|
31
|
+
* actually instantiate pull their SDK in.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // New canonical import
|
|
35
|
+
* import { RedisStore } from 'agentfootprint/memory-providers';
|
|
36
|
+
*
|
|
37
|
+
* // Legacy per-adapter alias (still works through v2.x)
|
|
38
|
+
* import { RedisStore } from 'agentfootprint/memory-redis';
|
|
39
|
+
*/
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.AgentCoreStore = exports.RedisStore = void 0;
|
|
42
|
+
// Lazy-required peer-dep stores. Both adapters defer their vendor SDK
|
|
43
|
+
// `require()` to constructor time; importing this barrel doesn't load
|
|
44
|
+
// `ioredis` or `@aws-sdk/client-bedrock-agent-runtime`.
|
|
45
|
+
var redis_js_1 = require("./adapters/memory/redis.js");
|
|
46
|
+
Object.defineProperty(exports, "RedisStore", { enumerable: true, get: function () { return redis_js_1.RedisStore; } });
|
|
47
|
+
var agentcore_js_1 = require("./adapters/memory/agentcore.js");
|
|
48
|
+
Object.defineProperty(exports, "AgentCoreStore", { enumerable: true, get: function () { return agentcore_js_1.AgentCoreStore; } });
|
|
49
|
+
//# sourceMappingURL=memory-providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-providers.js","sourceRoot":"","sources":["../src/memory-providers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;;;AAEH,sEAAsE;AACtE,sEAAsE;AACtE,wDAAwD;AACxD,uDAKoC;AAJlC,sGAAA,UAAU,OAAA;AAMZ,+DAIwC;AAHtC,8GAAA,cAAc,OAAA"}
|
package/dist/providers.js
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* agentfootprint/providers — LLM provider adapters.
|
|
4
4
|
*
|
|
5
|
+
* **DEPRECATION NOTICE (v2.5):** This subpath is now the legacy alias.
|
|
6
|
+
* The canonical name in v2.5+ is `agentfootprint/llm-providers`,
|
|
7
|
+
* matching the parallel structure (`tool-providers` /
|
|
8
|
+
* `memory-providers` / `security`). Existing imports keep working
|
|
9
|
+
* unchanged through the v2.x line; the alias is removed in v3.0.
|
|
10
|
+
*
|
|
11
|
+
* // Old (still works through v2.x):
|
|
12
|
+
* import { mock } from 'agentfootprint/providers';
|
|
13
|
+
* // New canonical:
|
|
14
|
+
* import { mock } from 'agentfootprint/llm-providers';
|
|
15
|
+
*
|
|
5
16
|
* Pattern: Adapter (GoF) — concrete `LLMProvider` implementations that
|
|
6
17
|
* translate the agentfootprint port to a specific vendor SDK.
|
|
7
18
|
* Role: Outer ring (Hexagonal). Swappable at runtime; the Agent
|
package/dist/providers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAEH,kEAKwC;AAJtC,+GAAA,YAAY,OAAA;AACZ,uGAAA,IAAI,OAAA;AAKN,4EAI6C;AAH3C,iHAAA,SAAS,OAAA;AACT,yHAAA,iBAAiB,OAAA;AAInB,sEAK0C;AAJxC,2GAAA,MAAM,OAAA;AACN,mHAAA,cAAc,OAAA;AACd,2GAAA,MAAM,OAAA;AAIR,wEAI2C;AAHzC,6GAAA,OAAO,OAAA;AACP,qHAAA,eAAe,OAAA;AAIjB,0FAIoD;AAHlD,+HAAA,gBAAgB,OAAA;AAChB,uIAAA,wBAAwB,OAAA;AAI1B,oFAIiD;AAH/C,yHAAA,aAAa,OAAA;AACb,iIAAA,qBAAqB,OAAA;AAIvB,sEAI0C;AAHxC,mHAAA,cAAc,OAAA"}
|