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,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/locales — Message Catalog Pattern.
|
|
3
|
+
*
|
|
4
|
+
* The Block D piece. agentfootprint emits user-facing prose at two
|
|
5
|
+
* audience levels:
|
|
6
|
+
*
|
|
7
|
+
* - **Commentary** — third-person prose for the bottom panel of any
|
|
8
|
+
* viewer (Lens, CLI tail, log files). "The agent dispatched the
|
|
9
|
+
* refund tool, which returned successfully."
|
|
10
|
+
* - **Thinking** — first-person status for chat-bubble UIs.
|
|
11
|
+
* "Looking up your order…"
|
|
12
|
+
*
|
|
13
|
+
* v2.4 shipped these as `defaultCommentaryTemplates` and
|
|
14
|
+
* `defaultThinkingTemplates` (flat `Record<string, string>` maps with
|
|
15
|
+
* `{{var}}` substitution). The names worked but the framing was
|
|
16
|
+
* generic — "templates" collides with TypeScript / templating-engine
|
|
17
|
+
* terminology, and there was no first-class place to ship locale
|
|
18
|
+
* packs.
|
|
19
|
+
*
|
|
20
|
+
* **Block D formalizes this as the Message Catalog Pattern:**
|
|
21
|
+
*
|
|
22
|
+
* - `defaultCommentaryMessages` / `defaultThinkingMessages` —
|
|
23
|
+
* canonical English bundles. Aliases of the v2.4 names; symbol
|
|
24
|
+
* identity preserved (`defaultCommentaryMessages ===
|
|
25
|
+
* defaultCommentaryTemplates`).
|
|
26
|
+
* - `composeMessages(defaults, overrides)` — spread overrides on
|
|
27
|
+
* top of defaults; missing keys fall back to the default bundle.
|
|
28
|
+
* - `validateMessages(catalog, requiredKeys)` — assert every
|
|
29
|
+
* required key is present (and non-empty). Catches drift between
|
|
30
|
+
* a consumer's locale pack and the framework's required key set.
|
|
31
|
+
*
|
|
32
|
+
* The natural consumer pattern is to ship locale packs alongside the
|
|
33
|
+
* agent code:
|
|
34
|
+
*
|
|
35
|
+
* import { defaultCommentaryMessages, composeMessages } from 'agentfootprint/locales';
|
|
36
|
+
* import { esCommentaryMessages } from './locales/es.js';
|
|
37
|
+
*
|
|
38
|
+
* const merged = composeMessages(defaultCommentaryMessages, esCommentaryMessages);
|
|
39
|
+
*
|
|
40
|
+
* const agent = Agent.create({...})
|
|
41
|
+
* .commentaryTemplates(merged)
|
|
42
|
+
* .build();
|
|
43
|
+
*
|
|
44
|
+
* Pattern: i18n locale resolution (Resource Bundle, Fowler 2002) +
|
|
45
|
+
* plain object merge for overrides. No catalog inheritance
|
|
46
|
+
* chain — overrides win OR fall back to defaults.
|
|
47
|
+
*
|
|
48
|
+
* @example Locale pack drop-in
|
|
49
|
+
* const esThinking = composeMessages(defaultThinkingMessages, {
|
|
50
|
+
* 'stream.llm_start.iter1': '{{appName}} está pensando...',
|
|
51
|
+
* 'stream.tool_start': 'Llamando a {{toolName}}...',
|
|
52
|
+
* });
|
|
53
|
+
* const agent = Agent.create({...}).thinkingTemplates(esThinking).build();
|
|
54
|
+
*
|
|
55
|
+
* @example Validate a locale pack against the framework's required keys
|
|
56
|
+
* import { defaultCommentaryMessages, validateMessages } from 'agentfootprint/locales';
|
|
57
|
+
*
|
|
58
|
+
* const myCatalog = composeMessages(defaultCommentaryMessages, customOverrides);
|
|
59
|
+
* validateMessages(myCatalog, Object.keys(defaultCommentaryMessages));
|
|
60
|
+
* // throws on first missing OR empty key — fail-fast at boot
|
|
61
|
+
*/
|
|
62
|
+
import { defaultCommentaryTemplates } from '../recorders/observability/commentary/commentaryTemplates.js';
|
|
63
|
+
import { defaultThinkingTemplates } from '../recorders/observability/thinking/thinkingTemplates.js';
|
|
64
|
+
/**
|
|
65
|
+
* Canonical English commentary bundle. Alias of v2.4's
|
|
66
|
+
* `defaultCommentaryTemplates` — same symbol, friendlier framing.
|
|
67
|
+
*
|
|
68
|
+
* Keys mirror agentfootprint event types; values may contain
|
|
69
|
+
* `{{var}}` placeholders for runtime substitution.
|
|
70
|
+
*/
|
|
71
|
+
export const defaultCommentaryMessages = defaultCommentaryTemplates;
|
|
72
|
+
/**
|
|
73
|
+
* Canonical English thinking bundle. Alias of v2.4's
|
|
74
|
+
* `defaultThinkingTemplates`.
|
|
75
|
+
*
|
|
76
|
+
* Keys mirror agentfootprint event types; values may contain
|
|
77
|
+
* `{{var}}` placeholders for runtime substitution.
|
|
78
|
+
*/
|
|
79
|
+
export const defaultThinkingMessages = defaultThinkingTemplates;
|
|
80
|
+
/**
|
|
81
|
+
* Spread `overrides` on top of `defaults` so every key in `defaults`
|
|
82
|
+
* has a value (the override or the original). The result is a fresh
|
|
83
|
+
* object — neither input is mutated.
|
|
84
|
+
*
|
|
85
|
+
* Missing override keys fall back to the default; extra override
|
|
86
|
+
* keys are preserved (forward-compat for consumer-defined keys).
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* const merged = composeMessages(defaultCommentaryMessages, {
|
|
90
|
+
* 'stream.llm_start.iter1': 'My custom thinking line',
|
|
91
|
+
* });
|
|
92
|
+
*/
|
|
93
|
+
export function composeMessages(defaults, overrides = {}) {
|
|
94
|
+
return Object.freeze({ ...defaults, ...overrides });
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Assert that every key in `requiredKeys` is present in `catalog`.
|
|
98
|
+
* Throws an Error listing every missing key — batched so consumers
|
|
99
|
+
* fix all at once instead of error-by-error.
|
|
100
|
+
*
|
|
101
|
+
* Useful at boot to catch drift between a consumer's locale pack and
|
|
102
|
+
* the framework's required key set.
|
|
103
|
+
*
|
|
104
|
+
* Empty-string values are VALID by default — the framework's default
|
|
105
|
+
* catalogs use `''` to signal "render nothing for this event."
|
|
106
|
+
* Pass `{ forbidEmpty: true }` to also reject empty values.
|
|
107
|
+
*
|
|
108
|
+
* @param catalog The (composed) message catalog to validate.
|
|
109
|
+
* @param requiredKeys The keys consumers must define. Typically
|
|
110
|
+
* `Object.keys(defaultCommentaryMessages)` or
|
|
111
|
+
* `Object.keys(defaultThinkingMessages)`.
|
|
112
|
+
* @param opts Optional `{ label, forbidEmpty }` (or a bare
|
|
113
|
+
* string label for back-compat with simple use).
|
|
114
|
+
*
|
|
115
|
+
* @throws Error when any required key is missing (or empty under
|
|
116
|
+
* `forbidEmpty`).
|
|
117
|
+
*/
|
|
118
|
+
export function validateMessages(catalog, requiredKeys, opts = {}) {
|
|
119
|
+
const resolved = typeof opts === 'string' ? { label: opts } : opts;
|
|
120
|
+
const label = resolved.label ?? 'message catalog';
|
|
121
|
+
const forbidEmpty = resolved.forbidEmpty ?? false;
|
|
122
|
+
const missing = [];
|
|
123
|
+
const empty = [];
|
|
124
|
+
for (const key of requiredKeys) {
|
|
125
|
+
const value = catalog[key];
|
|
126
|
+
if (value === undefined) {
|
|
127
|
+
missing.push(key);
|
|
128
|
+
}
|
|
129
|
+
else if (forbidEmpty && value.length === 0) {
|
|
130
|
+
empty.push(key);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (missing.length === 0 && empty.length === 0)
|
|
134
|
+
return;
|
|
135
|
+
const parts = [];
|
|
136
|
+
if (missing.length > 0) {
|
|
137
|
+
parts.push(`missing keys: ${missing.join(', ')}`);
|
|
138
|
+
}
|
|
139
|
+
if (empty.length > 0) {
|
|
140
|
+
parts.push(`empty values: ${empty.join(', ')}`);
|
|
141
|
+
}
|
|
142
|
+
throw new Error(`validateMessages(${label}): ${parts.join('; ')}.`);
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/locales/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,8DAA8D,CAAC;AAC1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAA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EAAE,CAAC;IAC3B,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,iBAAiB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,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"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/memory-providers — memory store adapters (canonical subpath).
|
|
3
|
+
*
|
|
4
|
+
* The Block B canonical name. Mirrors the parallel structure shipped in
|
|
5
|
+
* v2.5:
|
|
6
|
+
*
|
|
7
|
+
* agentfootprint/llm-providers ← LLM provider adapters
|
|
8
|
+
* agentfootprint/tool-providers ← tool dispatch + tool sources
|
|
9
|
+
* agentfootprint/memory-providers ← memory store adapters (this file)
|
|
10
|
+
* agentfootprint/security ← cross-cutting authorization
|
|
11
|
+
*
|
|
12
|
+
* One subpath that grows — RedisStore, AgentCoreStore, and future
|
|
13
|
+
* stores (DynamoDB, Postgres, Pinecone, …) all live here. No more
|
|
14
|
+
* adding `agentfootprint/memory-<vendor>` per-adapter subpath each
|
|
15
|
+
* time a new store ships.
|
|
16
|
+
*
|
|
17
|
+
* Per-adapter aliases (`agentfootprint/memory-redis`,
|
|
18
|
+
* `agentfootprint/memory-agentcore`) stay available through the v2.x
|
|
19
|
+
* line — they point at the same files. New code SHOULD import from
|
|
20
|
+
* `agentfootprint/memory-providers`:
|
|
21
|
+
*
|
|
22
|
+
* import { RedisStore, AgentCoreStore } from 'agentfootprint/memory-providers';
|
|
23
|
+
*
|
|
24
|
+
* Pattern: Adapter (GoF) — each store translates the `MemoryStore`
|
|
25
|
+
* interface onto a specific backend (Redis, DynamoDB-style
|
|
26
|
+
* AWS Bedrock AgentCore Memory, etc.).
|
|
27
|
+
* Role: Outer ring (Hexagonal). All store adapters lazy-require
|
|
28
|
+
* their vendor SDKs at construction time, so importing this
|
|
29
|
+
* barrel costs ZERO peer-dep load — only the stores you
|
|
30
|
+
* actually instantiate pull their SDK in.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // New canonical import
|
|
34
|
+
* import { RedisStore } from 'agentfootprint/memory-providers';
|
|
35
|
+
*
|
|
36
|
+
* // Legacy per-adapter alias (still works through v2.x)
|
|
37
|
+
* import { RedisStore } from 'agentfootprint/memory-redis';
|
|
38
|
+
*/
|
|
39
|
+
// Lazy-required peer-dep stores. Both adapters defer their vendor SDK
|
|
40
|
+
// `require()` to constructor time; importing this barrel doesn't load
|
|
41
|
+
// `ioredis` or `@aws-sdk/client-bedrock-agent-runtime`.
|
|
42
|
+
export { RedisStore, } from './adapters/memory/redis.js';
|
|
43
|
+
export { AgentCoreStore, } from './adapters/memory/agentcore.js';
|
|
44
|
+
//# 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,OAAO,EACL,UAAU,GAIX,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,cAAc,GAGf,MAAM,gCAAgC,CAAC"}
|
package/dist/esm/providers.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* agentfootprint/providers — LLM provider adapters.
|
|
3
3
|
*
|
|
4
|
+
* **DEPRECATION NOTICE (v2.5):** This subpath is now the legacy alias.
|
|
5
|
+
* The canonical name in v2.5+ is `agentfootprint/llm-providers`,
|
|
6
|
+
* matching the parallel structure (`tool-providers` /
|
|
7
|
+
* `memory-providers` / `security`). Existing imports keep working
|
|
8
|
+
* unchanged through the v2.x line; the alias is removed in v3.0.
|
|
9
|
+
*
|
|
10
|
+
* // Old (still works through v2.x):
|
|
11
|
+
* import { mock } from 'agentfootprint/providers';
|
|
12
|
+
* // New canonical:
|
|
13
|
+
* import { mock } from 'agentfootprint/llm-providers';
|
|
14
|
+
*
|
|
4
15
|
* Pattern: Adapter (GoF) — concrete `LLMProvider` implementations that
|
|
5
16
|
* translate the agentfootprint port to a specific vendor SDK.
|
|
6
17
|
* Role: Outer ring (Hexagonal). Swappable at runtime; the Agent
|
|
@@ -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,OAAO,EACL,YAAY,EACZ,IAAI,GAGL,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,SAAS,EACT,iBAAiB,GAElB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EACL,MAAM,EACN,cAAc,EACd,MAAM,GAEP,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,OAAO,EACP,eAAe,GAEhB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,gBAAgB,EAChB,wBAAwB,GAEzB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EACL,aAAa,EACb,qBAAqB,GAEtB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EACL,cAAc,GAGf,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* contextEngineering(agent) — first-class handle on the engineered
|
|
3
|
+
* subset of `context.injected` events.
|
|
4
|
+
*
|
|
5
|
+
* The Block A8 piece. agentfootprint already emits `context.injected`
|
|
6
|
+
* for EVERY piece of content that lands in a slot — including the
|
|
7
|
+
* baseline flow (the user message, every tool result, the static
|
|
8
|
+
* system prompt). For a developer who wants to inspect what their
|
|
9
|
+
* RAG / Skills / Memory / Instructions / Steering / Facts ARE
|
|
10
|
+
* INJECTING (the actual context-engineering work), the baseline flow
|
|
11
|
+
* is noise.
|
|
12
|
+
*
|
|
13
|
+
* `contextEngineering(agent)` filters the stream to ONLY the
|
|
14
|
+
* engineered injections and gives consumers two cleaner subscriptions:
|
|
15
|
+
*
|
|
16
|
+
* - `onEngineered(cb)` — fires for `source` ∈ {rag, skill, memory,
|
|
17
|
+
* instructions, steering, fact, custom}. The actual
|
|
18
|
+
* context-engineering work.
|
|
19
|
+
* - `onBaseline(cb)` — fires for `source` ∈ {user, tool-result,
|
|
20
|
+
* assistant, base, registry}. The baseline message-history flow.
|
|
21
|
+
*
|
|
22
|
+
* Use cases:
|
|
23
|
+
* - **Lens UI**: render only engineered injections in the "context
|
|
24
|
+
* bin"; show the baseline flow as edges between iterations.
|
|
25
|
+
* - **Eval pipelines**: count how many RAG chunks vs Memory entries
|
|
26
|
+
* vs Skill bodies entered the prompt for an eval-set query.
|
|
27
|
+
* - **Cost attribution**: sum tokens by `source` to know what
|
|
28
|
+
* fraction of spend is RAG vs Skills vs baseline.
|
|
29
|
+
* - **Debug logging**: tail just the engineered signals to spot
|
|
30
|
+
* surprising activations during dev.
|
|
31
|
+
*
|
|
32
|
+
* Pattern: Strategy + Filter (GoF) — pure classifier function over
|
|
33
|
+
* the existing `context.injected` event payload, paired with
|
|
34
|
+
* a thin subscription helper.
|
|
35
|
+
*
|
|
36
|
+
* Role: Layer-2 (event taxonomy) consumer-side helper. Doesn't
|
|
37
|
+
* emit new events; doesn't change the agent's flowchart.
|
|
38
|
+
* Pure observation.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* import { contextEngineering } from 'agentfootprint';
|
|
42
|
+
*
|
|
43
|
+
* const ce = contextEngineering(agent);
|
|
44
|
+
* ce.onEngineered((e) => {
|
|
45
|
+
* console.log(`[${e.payload.source}] ${e.payload.contentSummary}`);
|
|
46
|
+
* });
|
|
47
|
+
* ce.onBaseline((e) => {
|
|
48
|
+
* console.log(`[baseline:${e.payload.source}]`);
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* await agent.run({ message: 'help me' });
|
|
52
|
+
* // ... runs; engineered + baseline streams fire separately
|
|
53
|
+
*
|
|
54
|
+
* ce.detach(); // stops both subscriptions; the agent itself is fine
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* Public set of "engineered" sources — the context-engineering
|
|
58
|
+
* primitives that consumers configure (RAG, Skills, Memory,
|
|
59
|
+
* Instructions, Steering, Facts) plus user-defined `custom`.
|
|
60
|
+
*
|
|
61
|
+
* Frozen so consumers can `.has(value)` directly without copy.
|
|
62
|
+
*/
|
|
63
|
+
export const ENGINEERED_SOURCES = new Set([
|
|
64
|
+
'rag',
|
|
65
|
+
'skill',
|
|
66
|
+
'memory',
|
|
67
|
+
'instructions',
|
|
68
|
+
'steering',
|
|
69
|
+
'fact',
|
|
70
|
+
'custom',
|
|
71
|
+
]);
|
|
72
|
+
/**
|
|
73
|
+
* Public set of "baseline" sources — the message-history flow that
|
|
74
|
+
* exists regardless of context engineering: user input, tool results,
|
|
75
|
+
* assistant outputs, the always-on system prompt anchor (`base`), and
|
|
76
|
+
* the agent's static tool registry advertisement (`registry`).
|
|
77
|
+
*/
|
|
78
|
+
export const BASELINE_SOURCES = new Set([
|
|
79
|
+
'user',
|
|
80
|
+
'tool-result',
|
|
81
|
+
'assistant',
|
|
82
|
+
'base',
|
|
83
|
+
'registry',
|
|
84
|
+
]);
|
|
85
|
+
/**
|
|
86
|
+
* Pure classifier: given a `ContextSource`, is it engineered?
|
|
87
|
+
*
|
|
88
|
+
* Useful for ad-hoc filtering on a raw `agent.on('agentfootprint.context.injected', ...)`
|
|
89
|
+
* subscription when you don't need the wrapper helper.
|
|
90
|
+
*/
|
|
91
|
+
export function isEngineeredSource(source) {
|
|
92
|
+
return ENGINEERED_SOURCES.has(source);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Pure classifier: given a `ContextSource`, is it baseline?
|
|
96
|
+
*/
|
|
97
|
+
export function isBaselineSource(source) {
|
|
98
|
+
return BASELINE_SOURCES.has(source);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Wrap a runner's `agentfootprint.context.injected` stream into two
|
|
102
|
+
* filtered subscriptions: engineered + baseline. Multiple listeners
|
|
103
|
+
* per stream are allowed; `detach()` removes all of them.
|
|
104
|
+
*
|
|
105
|
+
* The classifier inspects `event.payload.source`. Unknown sources
|
|
106
|
+
* (forward-compat: `ContextSource` is open-extensible) are routed
|
|
107
|
+
* to NEITHER stream — preferring under-firing over miscategorizing.
|
|
108
|
+
* Use `agent.on('agentfootprint.context.injected', ...)` directly
|
|
109
|
+
* if you need to observe sources that aren't (yet) classified.
|
|
110
|
+
*/
|
|
111
|
+
export function contextEngineering(agent) {
|
|
112
|
+
const unsubscribers = [];
|
|
113
|
+
function onEngineered(listener) {
|
|
114
|
+
const wrapped = (e) => {
|
|
115
|
+
if (isEngineeredSource(e.payload.source))
|
|
116
|
+
listener(e);
|
|
117
|
+
};
|
|
118
|
+
const unsub = agent.on('agentfootprint.context.injected', wrapped);
|
|
119
|
+
unsubscribers.push(unsub);
|
|
120
|
+
return () => {
|
|
121
|
+
unsub();
|
|
122
|
+
const idx = unsubscribers.indexOf(unsub);
|
|
123
|
+
if (idx >= 0)
|
|
124
|
+
unsubscribers.splice(idx, 1);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function onBaseline(listener) {
|
|
128
|
+
const wrapped = (e) => {
|
|
129
|
+
if (isBaselineSource(e.payload.source))
|
|
130
|
+
listener(e);
|
|
131
|
+
};
|
|
132
|
+
const unsub = agent.on('agentfootprint.context.injected', wrapped);
|
|
133
|
+
unsubscribers.push(unsub);
|
|
134
|
+
return () => {
|
|
135
|
+
unsub();
|
|
136
|
+
const idx = unsubscribers.indexOf(unsub);
|
|
137
|
+
if (idx >= 0)
|
|
138
|
+
unsubscribers.splice(idx, 1);
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function detach() {
|
|
142
|
+
for (const unsub of unsubscribers) {
|
|
143
|
+
try {
|
|
144
|
+
unsub();
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
// Defensive: a misbehaving subscription's throw should not
|
|
148
|
+
// prevent detaching the rest.
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
unsubscribers.length = 0;
|
|
152
|
+
}
|
|
153
|
+
return { onEngineered, onBaseline, detach };
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=contextEngineering.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextEngineering.js","sourceRoot":"","sources":["../../../../src/recorders/core/contextEngineering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAKH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA+B,IAAI,GAAG,CAAgB;IACnF,KAAK;IACL,OAAO;IACP,QAAQ;IACR,cAAc;IACd,UAAU;IACV,MAAM;IACN,QAAQ;CACT,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA+B,IAAI,GAAG,CAAgB;IACjF,MAAM;IACN,aAAa;IACb,WAAW;IACX,MAAM;IACN,UAAU;CACX,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAqB;IACtD,OAAO,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAqB;IACpD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AAG,EAAE,CAAC,CAAC,CAAC;QAC7C,CAAC,CAAC;IACJ,CAAC;IAED,SAAS,MAAM;QACb,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;YAClC,IAAI,CAAC;gBACH,KAAK,EAAE,CAAC;YACV,CAAC;YAAC,MAAM,CAAC;gBACP,2DAA2D;gBAC3D,8BAA8B;YAChC,CAAC;QACH,CAAC;QACD,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -70,7 +70,12 @@ export const defaultCommentaryTemplates = {
|
|
|
70
70
|
'context.injected.rag': '{{appName}} retrieved relevant content and added it to the conversation.',
|
|
71
71
|
'context.injected.skill': '{{appName}} activated a skill — its body went into the system prompt, and its tools became available to the LLM.',
|
|
72
72
|
'context.injected.memory': '{{appName}} pulled prior content from memory and added it to the conversation.',
|
|
73
|
-
|
|
73
|
+
// Generic — fits always-on rules + on-tool-return predicates uniformly.
|
|
74
|
+
// Specialized variants below disambiguate when the trigger metadata
|
|
75
|
+
// is available on the event.
|
|
76
|
+
'context.injected.instructions': '{{appName}} added a rule to the system prompt: {{descClause}}.',
|
|
77
|
+
'context.injected.instructions.onToolReturn': '{{appName}} added a tool-specific reminder after `{{lastToolName}}` returned: {{descClause}}.',
|
|
78
|
+
'context.injected.instructions.alwaysOn': '{{appName}} added an always-on rule to the system prompt: {{descClause}}.',
|
|
74
79
|
'context.injected.custom': '{{appName}} injected a custom piece of context.',
|
|
75
80
|
'skill.activated': '{{appName}} turned on a skill — its tools and instructions are now available.',
|
|
76
81
|
'skill.deactivated': '{{appName}} turned off a skill.',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commentaryTemplates.js","sourceRoot":"","sources":["../../../../../src/recorders/observability/commentary/commentaryTemplates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAUH;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAwB;IAC7D,kBAAkB,EAAE,2CAA2C;IAE/D,wBAAwB,EAAE,2CAA2C;IACrE,wBAAwB,EAAE,8DAA8D;IAExF,sBAAsB,EAAE,qEAAqE;IAC7F,yBAAyB,EAAE,qEAAqE;IAEhG,mEAAmE;IACnE,iEAAiE;IACjE,iEAAiE;IACjE,8DAA8D;IAC9D,gDAAgD;IAChD,mEAAmE;IACnE,iDAAiD;IACjD,6DAA6D;IAC7D,6CAA6C;IAC7C,iEAAiE;IACjE,iEAAiE;IACjE,iBAAiB,EAAE,0BAA0B;IAC7C,sBAAsB,EAAE,wCAAwC;IAEhE,mBAAmB,EACjB,+IAA+I;IACjJ,wBAAwB,EAAE,6BAA6B;IACvD,0BAA0B,EAAE,EAAE;IAE9B,iBAAiB,EAAE,4EAA4E;IAE/F,sBAAsB,EACpB,0EAA0E;IAC5E,wBAAwB,EACtB,kHAAkH;IACpH,yBAAyB,EACvB,gFAAgF;IAClF,+BAA+B,
|
|
1
|
+
{"version":3,"file":"commentaryTemplates.js","sourceRoot":"","sources":["../../../../../src/recorders/observability/commentary/commentaryTemplates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAUH;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAwB;IAC7D,kBAAkB,EAAE,2CAA2C;IAE/D,wBAAwB,EAAE,2CAA2C;IACrE,wBAAwB,EAAE,8DAA8D;IAExF,sBAAsB,EAAE,qEAAqE;IAC7F,yBAAyB,EAAE,qEAAqE;IAEhG,mEAAmE;IACnE,iEAAiE;IACjE,iEAAiE;IACjE,8DAA8D;IAC9D,gDAAgD;IAChD,mEAAmE;IACnE,iDAAiD;IACjD,6DAA6D;IAC7D,6CAA6C;IAC7C,iEAAiE;IACjE,iEAAiE;IACjE,iBAAiB,EAAE,0BAA0B;IAC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based authorization for tool dispatch.
|
|
3
|
+
*
|
|
4
|
+
* Closes Neo gap #2 (of 8). Permissions are CROSS-CUTTING — they're not
|
|
5
|
+
* context engineering, they're a guard ON context-engineering operations
|
|
6
|
+
* (tool dispatch, skill activation, memory writes, output emission).
|
|
7
|
+
* That's why this lives in `agentfootprint/security`, parallel to the
|
|
8
|
+
* provider subpaths.
|
|
9
|
+
*
|
|
10
|
+
* Two surfaces, one primitive:
|
|
11
|
+
* 1. `PermissionPolicy.fromRoles({...}, activeRole)` — declarative,
|
|
12
|
+
* data-driven, auditable. Production governance.
|
|
13
|
+
* 2. The PermissionPolicy instance satisfies BOTH:
|
|
14
|
+
* - `PermissionChecker` interface (async check; consumed by Agent
|
|
15
|
+
* constructor's `permissionChecker` field)
|
|
16
|
+
* - sync `isAllowed(toolId)` method (consumed by `gatedTools(...)`
|
|
17
|
+
* from `agentfootprint/tool-providers`)
|
|
18
|
+
*
|
|
19
|
+
* Pattern: Strategy (GoF) for the role-allowlist policy + Adapter
|
|
20
|
+
* (matches `PermissionChecker` interface so it composes with
|
|
21
|
+
* existing v2.4 Agent constructor).
|
|
22
|
+
*
|
|
23
|
+
* Role: Layer-3 cross-cutting guard. Not Injection. Not provider.
|
|
24
|
+
* Lives in its own subpath (`agentfootprint/security`).
|
|
25
|
+
*
|
|
26
|
+
* @example Read-only role for a support agent
|
|
27
|
+
* const policy = PermissionPolicy.fromRoles(
|
|
28
|
+
* {
|
|
29
|
+
* readonly: ['lookup_order', 'get_status', 'list_skills', 'read_skill'],
|
|
30
|
+
* support: ['lookup_order', 'get_status', 'process_refund', 'list_skills', 'read_skill'],
|
|
31
|
+
* },
|
|
32
|
+
* 'readonly',
|
|
33
|
+
* );
|
|
34
|
+
*
|
|
35
|
+
* policy.isAllowed('lookup_order'); // → true
|
|
36
|
+
* policy.isAllowed('process_refund'); // → false (not in readonly role)
|
|
37
|
+
*
|
|
38
|
+
* // As a tool-dispatch gate (composes with gatedTools)
|
|
39
|
+
* const provider = gatedTools(staticTools(allTools), (name) => policy.isAllowed(name));
|
|
40
|
+
*
|
|
41
|
+
* // As an Agent permissionChecker (the v2.4 surface)
|
|
42
|
+
* const agent = Agent.create({ provider, model, permissionChecker: policy }).build();
|
|
43
|
+
*
|
|
44
|
+
* @example Per-identity role switching at runtime
|
|
45
|
+
* const policy = PermissionPolicy.fromRoles({
|
|
46
|
+
* readonly: [...],
|
|
47
|
+
* admin: [...],
|
|
48
|
+
* }, 'readonly');
|
|
49
|
+
*
|
|
50
|
+
* const adminPolicy = policy.withActiveRole('admin');
|
|
51
|
+
* // Same allowlist data; different active role.
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* Data-driven role-based permission policy. Satisfies the v2.4
|
|
55
|
+
* `PermissionChecker` interface AND exposes a sync `isAllowed` method
|
|
56
|
+
* for use with `gatedTools` from `agentfootprint/tool-providers`.
|
|
57
|
+
*/
|
|
58
|
+
export class PermissionPolicy {
|
|
59
|
+
opts;
|
|
60
|
+
name = 'PermissionPolicy';
|
|
61
|
+
constructor(opts) {
|
|
62
|
+
this.opts = opts;
|
|
63
|
+
if (!opts.roles[opts.activeRole]) {
|
|
64
|
+
throw new Error(`PermissionPolicy: activeRole '${opts.activeRole}' is not defined in roles. Available: ${Object.keys(opts.roles).join(', ') || '(none)'}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Factory: build a role-based policy from a role → tool-ids map and
|
|
69
|
+
* the role active for this instance.
|
|
70
|
+
*
|
|
71
|
+
* Throws if `activeRole` isn't a key in `roles` — fail loud at
|
|
72
|
+
* config time, not at first denied call.
|
|
73
|
+
*/
|
|
74
|
+
static fromRoles(roles, activeRole) {
|
|
75
|
+
return new PermissionPolicy({ roles, activeRole });
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Sync allowlist check. Use as a predicate with `gatedTools`:
|
|
79
|
+
*
|
|
80
|
+
* gatedTools(staticTools(allTools), (toolId) => policy.isAllowed(toolId))
|
|
81
|
+
*
|
|
82
|
+
* Returns true iff `toolId` is in the active role's allowlist.
|
|
83
|
+
* Closes-fail by design: missing role membership = denied.
|
|
84
|
+
*/
|
|
85
|
+
isAllowed(toolId) {
|
|
86
|
+
return (this.opts.roles[this.opts.activeRole] ?? []).includes(toolId);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Async check matching the `PermissionChecker` interface — consumed
|
|
90
|
+
* by `Agent.create({ permissionChecker })`. Wraps `isAllowed` with
|
|
91
|
+
* the structured `PermissionDecision` envelope (allow / deny + a
|
|
92
|
+
* `policyRuleId` so observability can trace which role decided).
|
|
93
|
+
*
|
|
94
|
+
* Today the policy only checks the tool name (request.target).
|
|
95
|
+
* Future work: also gate by capability ('memory_write', etc.) when
|
|
96
|
+
* the role allowlist is widened to capability-by-id.
|
|
97
|
+
*/
|
|
98
|
+
async check(request) {
|
|
99
|
+
const toolId = request.target ?? request.capability;
|
|
100
|
+
if (this.isAllowed(toolId)) {
|
|
101
|
+
return {
|
|
102
|
+
result: 'allow',
|
|
103
|
+
policyRuleId: `${this.opts.activeRole}.allowlist`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
result: 'deny',
|
|
108
|
+
policyRuleId: `${this.opts.activeRole}.allowlist.miss`,
|
|
109
|
+
rationale: `Tool '${toolId}' is not in the '${this.opts.activeRole}' role allowlist.`,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Derive a sibling policy with a different active role. Same role
|
|
114
|
+
* map; different active role. Useful for per-identity routing
|
|
115
|
+
* (one policy instance per request, varying active role per caller).
|
|
116
|
+
*
|
|
117
|
+
* Returns a NEW PermissionPolicy — original is unchanged.
|
|
118
|
+
*/
|
|
119
|
+
withActiveRole(activeRole) {
|
|
120
|
+
return new PermissionPolicy({ roles: this.opts.roles, activeRole });
|
|
121
|
+
}
|
|
122
|
+
/** The role name currently active. Useful for observability. */
|
|
123
|
+
get activeRole() {
|
|
124
|
+
return this.opts.activeRole;
|
|
125
|
+
}
|
|
126
|
+
/** All defined role names. Stable order = registration order. */
|
|
127
|
+
get roles() {
|
|
128
|
+
return Object.keys(this.opts.roles);
|
|
129
|
+
}
|
|
130
|
+
/** All tool ids allowed under the current active role. */
|
|
131
|
+
allowedToolIds() {
|
|
132
|
+
return [...(this.opts.roles[this.opts.activeRole] ?? [])];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=PermissionPolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PermissionPolicy.js","sourceRoot":"","sources":["../../../src/security/PermissionPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AA6BH;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAGU;IAF5B,IAAI,GAAG,kBAAkB,CAAC;IAEnC,YAAqC,IAA6B;QAA7B,SAAI,GAAJ,IAAI,CAAyB;QAChE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CACb,iCAAiC,IAAI,CAAC,UAAU,yCAC9C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QACxC,EAAE,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CAAC,KAAoB,EAAE,UAAkB;QACvD,OAAO,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,MAAc;QACtB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,KAAK,CAAC,OAA0B;QACpC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,UAAU,CAAC;QACpD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3B,OAAO;gBACL,MAAM,EAAE,OAAO;gBACf,YAAY,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,YAAY;aAClD,CAAC;QACJ,CAAC;QACD,OAAO;YACL,MAAM,EAAE,MAAM;YACd,YAAY,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,iBAAiB;YACtD,SAAS,EAAE,SAAS,MAAM,oBAAoB,IAAI,CAAC,IAAI,CAAC,UAAU,mBAAmB;SACtF,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,cAAc,CAAC,UAAkB;QAC/B,OAAO,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,gEAAgE;IAChE,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;IAC9B,CAAC;IAED,iEAAiE;IACjE,IAAI,KAAK;QACP,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,0DAA0D;IAC1D,cAAc;QACZ,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/security — cross-cutting authorization + governance.
|
|
3
|
+
*
|
|
4
|
+
* Permissions are NOT context engineering — they're a guard ON
|
|
5
|
+
* context-engineering operations (tool dispatch, skill activation,
|
|
6
|
+
* memory writes, output emission). That's why this lives in its own
|
|
7
|
+
* subpath, parallel to `agentfootprint/tool-providers` and the
|
|
8
|
+
* `agentfootprint/memory-*` and `agentfootprint/providers` subpaths.
|
|
9
|
+
*
|
|
10
|
+
* Today's surface is small and data-driven on purpose: one role
|
|
11
|
+
* allowlist primitive that satisfies BOTH the v2.4 `PermissionChecker`
|
|
12
|
+
* interface AND a sync `isAllowed(toolId)` predicate for use with
|
|
13
|
+
* `gatedTools` from `agentfootprint/tool-providers`.
|
|
14
|
+
*
|
|
15
|
+
* Future additions (capability gating, gate_open flows, audit logs)
|
|
16
|
+
* land here without expanding the public root barrel.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* import { PermissionPolicy } from 'agentfootprint/security';
|
|
20
|
+
* import { gatedTools, staticTools } from 'agentfootprint/tool-providers';
|
|
21
|
+
*
|
|
22
|
+
* const policy = PermissionPolicy.fromRoles(
|
|
23
|
+
* {
|
|
24
|
+
* readonly: ['lookup', 'list_skills', 'read_skill'],
|
|
25
|
+
* admin: ['lookup', 'list_skills', 'read_skill', 'write', 'delete'],
|
|
26
|
+
* },
|
|
27
|
+
* 'readonly',
|
|
28
|
+
* );
|
|
29
|
+
*
|
|
30
|
+
* const provider = gatedTools(
|
|
31
|
+
* staticTools(allTools),
|
|
32
|
+
* (name) => policy.isAllowed(name),
|
|
33
|
+
* );
|
|
34
|
+
*
|
|
35
|
+
* const agent = Agent.create({ provider, model, permissionChecker: policy }).build();
|
|
36
|
+
*/
|
|
37
|
+
export { PermissionPolicy } from './PermissionPolicy.js';
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gatedTools — wrap any ToolProvider with a per-tool gating predicate.
|
|
3
|
+
*
|
|
4
|
+
* The DECORATOR for tool providers. Filters the inner provider's
|
|
5
|
+
* output by running the predicate against each tool name. Composes
|
|
6
|
+
* freely:
|
|
7
|
+
*
|
|
8
|
+
* gatedTools(
|
|
9
|
+
* gatedTools(staticTools(allTools), readOnlyPredicate),
|
|
10
|
+
* skillGatePredicate,
|
|
11
|
+
* )
|
|
12
|
+
*
|
|
13
|
+
* Reads as: "static list of all tools, filtered by readonly policy,
|
|
14
|
+
* then further filtered by the active skill's tool set." Each gate
|
|
15
|
+
* is one concern; composition handles the rest.
|
|
16
|
+
*
|
|
17
|
+
* Pattern: Decorator (GoF) — wraps any ToolProvider with an additional
|
|
18
|
+
* filter. Mirrors `withRetry` / `withFallback` over LLMProvider.
|
|
19
|
+
*
|
|
20
|
+
* @example Read-only enforcement
|
|
21
|
+
* const readOnly = gatedTools(
|
|
22
|
+
* staticTools([read, write]),
|
|
23
|
+
* (toolName) => toolName.startsWith('read_'),
|
|
24
|
+
* );
|
|
25
|
+
* readOnly.list(ctx); // → [read]
|
|
26
|
+
*
|
|
27
|
+
* @example Skill-gated dispatch (autoActivate use case)
|
|
28
|
+
* const skillGated = gatedTools(
|
|
29
|
+
* staticTools(allTools),
|
|
30
|
+
* (toolName, ctx) => ctx.activeSkillId
|
|
31
|
+
* ? skillToolMap[ctx.activeSkillId].includes(toolName)
|
|
32
|
+
* : alwaysVisible.includes(toolName),
|
|
33
|
+
* );
|
|
34
|
+
*/
|
|
35
|
+
// #region gatedTools
|
|
36
|
+
export function gatedTools(inner, predicate) {
|
|
37
|
+
return {
|
|
38
|
+
id: 'gated',
|
|
39
|
+
list(ctx) {
|
|
40
|
+
// Pull from the inner provider first; each recomputation sees
|
|
41
|
+
// the freshest state from any nested gates.
|
|
42
|
+
const innerTools = inner.list(ctx);
|
|
43
|
+
// Filter by predicate — tool name from `tool.schema.name`.
|
|
44
|
+
// Predicates throwing escape: a buggy predicate should crash
|
|
45
|
+
// loudly, not silently allow tools through. Per the
|
|
46
|
+
// permission-as-defense-in-depth principle.
|
|
47
|
+
return innerTools.filter((t) => predicate(t.schema.name, ctx));
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// #endregion gatedTools
|
|
52
|
+
//# sourceMappingURL=gatedTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gatedTools.js","sourceRoot":"","sources":["../../../src/tool-providers/gatedTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAIH,qBAAqB;AACrB,MAAM,UAAU,UAAU,CAAC,KAAmB,EAAE,SAA4B;IAC1E,OAAO;QACL,EAAE,EAAE,OAAO;QACX,IAAI,CAAC,GAAwB;YAC3B,8DAA8D;YAC9D,4CAA4C;YAC5C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnC,2DAA2D;YAC3D,6DAA6D;YAC7D,oDAAoD;YACpD,4CAA4C;YAC5C,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,CAAC;AACD,wBAAwB"}
|