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,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/llm-providers — LLM provider 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 (this file)
|
|
8
|
+
* agentfootprint/tool-providers ← tool dispatch + tool sources
|
|
9
|
+
* agentfootprint/memory-providers ← memory store adapters
|
|
10
|
+
* agentfootprint/security ← cross-cutting authorization
|
|
11
|
+
*
|
|
12
|
+
* The legacy `agentfootprint/providers` subpath stays available as an
|
|
13
|
+
* alias through the v2.x line — it points at the same exports. New
|
|
14
|
+
* code SHOULD import from `agentfootprint/llm-providers` for clarity:
|
|
15
|
+
* grep'ing for "llm-providers" finds every LLM-side import in one
|
|
16
|
+
* shot, parallel to "tool-providers" and "memory-providers".
|
|
17
|
+
*
|
|
18
|
+
* Pattern: Adapter (GoF) — concrete `LLMProvider` implementations that
|
|
19
|
+
* translate the agentfootprint port to a specific vendor SDK.
|
|
20
|
+
* Role: Outer ring (Hexagonal). Swappable at runtime; the Agent
|
|
21
|
+
* knows nothing about vendor specifics.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // New canonical import
|
|
25
|
+
* import { mock, AnthropicProvider } from 'agentfootprint/llm-providers';
|
|
26
|
+
*
|
|
27
|
+
* // Legacy alias (still works through v2.x)
|
|
28
|
+
* import { mock, AnthropicProvider } from 'agentfootprint/providers';
|
|
29
|
+
*/
|
|
30
|
+
export * from './providers.js';
|
|
31
|
+
//# sourceMappingURL=llm-providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-providers.d.ts","sourceRoot":"","sources":["../../src/llm-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
export type { CommentaryTemplates as MessageCatalog } from '../recorders/observability/commentary/commentaryTemplates.js';
|
|
63
|
+
/**
|
|
64
|
+
* Canonical English commentary bundle. Alias of v2.4's
|
|
65
|
+
* `defaultCommentaryTemplates` — same symbol, friendlier framing.
|
|
66
|
+
*
|
|
67
|
+
* Keys mirror agentfootprint event types; values may contain
|
|
68
|
+
* `{{var}}` placeholders for runtime substitution.
|
|
69
|
+
*/
|
|
70
|
+
export declare const defaultCommentaryMessages: Readonly<Record<string, string>>;
|
|
71
|
+
/**
|
|
72
|
+
* Canonical English thinking bundle. Alias of v2.4's
|
|
73
|
+
* `defaultThinkingTemplates`.
|
|
74
|
+
*
|
|
75
|
+
* Keys mirror agentfootprint event types; values may contain
|
|
76
|
+
* `{{var}}` placeholders for runtime substitution.
|
|
77
|
+
*/
|
|
78
|
+
export declare const defaultThinkingMessages: Readonly<Record<string, string>>;
|
|
79
|
+
/**
|
|
80
|
+
* Spread `overrides` on top of `defaults` so every key in `defaults`
|
|
81
|
+
* has a value (the override or the original). The result is a fresh
|
|
82
|
+
* object — neither input is mutated.
|
|
83
|
+
*
|
|
84
|
+
* Missing override keys fall back to the default; extra override
|
|
85
|
+
* keys are preserved (forward-compat for consumer-defined keys).
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* const merged = composeMessages(defaultCommentaryMessages, {
|
|
89
|
+
* 'stream.llm_start.iter1': 'My custom thinking line',
|
|
90
|
+
* });
|
|
91
|
+
*/
|
|
92
|
+
export declare function composeMessages<T extends Readonly<Record<string, string>>>(defaults: T, overrides?: Readonly<Record<string, string>>): Readonly<Record<string, string>>;
|
|
93
|
+
/**
|
|
94
|
+
* Validation options for `validateMessages`.
|
|
95
|
+
*/
|
|
96
|
+
export interface ValidateMessagesOptions {
|
|
97
|
+
/**
|
|
98
|
+
* Optional label for the error message (e.g., `'es-MX commentary'`).
|
|
99
|
+
* Defaults to `'message catalog'`.
|
|
100
|
+
*/
|
|
101
|
+
readonly label?: string;
|
|
102
|
+
/**
|
|
103
|
+
* When `true`, empty-string values FAIL validation (treated like a
|
|
104
|
+
* missing key). When `false` (default), empty strings are valid —
|
|
105
|
+
* the framework's default catalogs intentionally use empty values
|
|
106
|
+
* for events the consumer should skip rendering for.
|
|
107
|
+
*/
|
|
108
|
+
readonly forbidEmpty?: boolean;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Assert that every key in `requiredKeys` is present in `catalog`.
|
|
112
|
+
* Throws an Error listing every missing key — batched so consumers
|
|
113
|
+
* fix all at once instead of error-by-error.
|
|
114
|
+
*
|
|
115
|
+
* Useful at boot to catch drift between a consumer's locale pack and
|
|
116
|
+
* the framework's required key set.
|
|
117
|
+
*
|
|
118
|
+
* Empty-string values are VALID by default — the framework's default
|
|
119
|
+
* catalogs use `''` to signal "render nothing for this event."
|
|
120
|
+
* Pass `{ forbidEmpty: true }` to also reject empty values.
|
|
121
|
+
*
|
|
122
|
+
* @param catalog The (composed) message catalog to validate.
|
|
123
|
+
* @param requiredKeys The keys consumers must define. Typically
|
|
124
|
+
* `Object.keys(defaultCommentaryMessages)` or
|
|
125
|
+
* `Object.keys(defaultThinkingMessages)`.
|
|
126
|
+
* @param opts Optional `{ label, forbidEmpty }` (or a bare
|
|
127
|
+
* string label for back-compat with simple use).
|
|
128
|
+
*
|
|
129
|
+
* @throws Error when any required key is missing (or empty under
|
|
130
|
+
* `forbidEmpty`).
|
|
131
|
+
*/
|
|
132
|
+
export declare function validateMessages(catalog: Readonly<Record<string, string>>, requiredKeys: readonly string[], opts?: ValidateMessagesOptions | string): void;
|
|
133
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/locales/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAKH,YAAY,EAAE,mBAAmB,IAAI,cAAc,EAAE,MAAM,8DAA8D,CAAC;AAE1H;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,kCAA6B,CAAC;AAEpE;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,kCAA2B,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACxE,QAAQ,EAAE,CAAC,EACX,SAAS,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,GAC/C,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAElC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACzC,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,IAAI,GAAE,uBAAuB,GAAG,MAAW,GAC1C,IAAI,CAwBN"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
export { RedisStore, type RedisStoreOptions, type RedisLikeClient, type RedisLikePipeline, } from './adapters/memory/redis.js';
|
|
40
|
+
export { AgentCoreStore, type AgentCoreStoreOptions, type AgentCoreLikeClient, } from './adapters/memory/agentcore.js';
|
|
41
|
+
//# sourceMappingURL=memory-providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-providers.d.ts","sourceRoot":"","sources":["../../src/memory-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAKH,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,gCAAgC,CAAC"}
|
|
@@ -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.d.ts","sourceRoot":"","sources":["../../src/providers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,KAAK,mBAAmB,EACxB,KAAK,SAAS,GACf,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EACL,MAAM,EACN,cAAc,EACd,MAAM,EACN,KAAK,qBAAqB,GAC3B,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,OAAO,EACP,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,+BAA+B,GACrC,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,KAAK,4BAA4B,GAClC,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EACL,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,qBAAqB,GAC3B,MAAM,kCAAkC,CAAC;AAE1C,YAAY,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,aAAa,GACd,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
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
|
+
import type { AgentfootprintEventMap } from '../../events/registry.js';
|
|
57
|
+
import type { ContextSource } from '../../events/types.js';
|
|
58
|
+
/**
|
|
59
|
+
* Public set of "engineered" sources — the context-engineering
|
|
60
|
+
* primitives that consumers configure (RAG, Skills, Memory,
|
|
61
|
+
* Instructions, Steering, Facts) plus user-defined `custom`.
|
|
62
|
+
*
|
|
63
|
+
* Frozen so consumers can `.has(value)` directly without copy.
|
|
64
|
+
*/
|
|
65
|
+
export declare const ENGINEERED_SOURCES: ReadonlySet<ContextSource>;
|
|
66
|
+
/**
|
|
67
|
+
* Public set of "baseline" sources — the message-history flow that
|
|
68
|
+
* exists regardless of context engineering: user input, tool results,
|
|
69
|
+
* assistant outputs, the always-on system prompt anchor (`base`), and
|
|
70
|
+
* the agent's static tool registry advertisement (`registry`).
|
|
71
|
+
*/
|
|
72
|
+
export declare const BASELINE_SOURCES: ReadonlySet<ContextSource>;
|
|
73
|
+
/**
|
|
74
|
+
* Pure classifier: given a `ContextSource`, is it engineered?
|
|
75
|
+
*
|
|
76
|
+
* Useful for ad-hoc filtering on a raw `agent.on('agentfootprint.context.injected', ...)`
|
|
77
|
+
* subscription when you don't need the wrapper helper.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isEngineeredSource(source: ContextSource): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Pure classifier: given a `ContextSource`, is it baseline?
|
|
82
|
+
*/
|
|
83
|
+
export declare function isBaselineSource(source: ContextSource): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The shape of the event passed to `onEngineered` / `onBaseline`
|
|
86
|
+
* callbacks. Same as `agentfootprint.context.injected`'s envelope —
|
|
87
|
+
* we don't transform it, just route by source.
|
|
88
|
+
*/
|
|
89
|
+
export type ContextInjectedEvent = AgentfootprintEventMap['agentfootprint.context.injected'];
|
|
90
|
+
/** Listener signature for the wrapper helper. */
|
|
91
|
+
export type ContextInjectedListener = (event: ContextInjectedEvent) => void;
|
|
92
|
+
/** Unsubscribe handle. */
|
|
93
|
+
export type ContextEngineeringUnsubscribe = () => void;
|
|
94
|
+
/**
|
|
95
|
+
* Minimal subset of the agent surface this helper depends on.
|
|
96
|
+
* Lets us accept any runner (Agent, LLMCall, Sequence, etc.) that
|
|
97
|
+
* implements the typed `on(type, cb)` subscription API.
|
|
98
|
+
*/
|
|
99
|
+
interface RunnerWithEvents {
|
|
100
|
+
on(type: 'agentfootprint.context.injected', listener: ContextInjectedListener): ContextEngineeringUnsubscribe;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Handle returned by `contextEngineering(agent)`. Lets consumers
|
|
104
|
+
* subscribe to engineered / baseline streams and detach cleanly.
|
|
105
|
+
*/
|
|
106
|
+
export interface ContextEngineeringHandle {
|
|
107
|
+
/**
|
|
108
|
+
* Fires for `context.injected` events whose source is in
|
|
109
|
+
* `ENGINEERED_SOURCES`. Returns an unsubscribe function.
|
|
110
|
+
*/
|
|
111
|
+
onEngineered(listener: ContextInjectedListener): ContextEngineeringUnsubscribe;
|
|
112
|
+
/**
|
|
113
|
+
* Fires for `context.injected` events whose source is in
|
|
114
|
+
* `BASELINE_SOURCES`. Returns an unsubscribe function.
|
|
115
|
+
*/
|
|
116
|
+
onBaseline(listener: ContextInjectedListener): ContextEngineeringUnsubscribe;
|
|
117
|
+
/**
|
|
118
|
+
* Detach all subscriptions registered through this handle. After
|
|
119
|
+
* calling, no further callbacks will fire. Idempotent (safe to
|
|
120
|
+
* call multiple times).
|
|
121
|
+
*/
|
|
122
|
+
detach(): void;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Wrap a runner's `agentfootprint.context.injected` stream into two
|
|
126
|
+
* filtered subscriptions: engineered + baseline. Multiple listeners
|
|
127
|
+
* per stream are allowed; `detach()` removes all of them.
|
|
128
|
+
*
|
|
129
|
+
* The classifier inspects `event.payload.source`. Unknown sources
|
|
130
|
+
* (forward-compat: `ContextSource` is open-extensible) are routed
|
|
131
|
+
* to NEITHER stream — preferring under-firing over miscategorizing.
|
|
132
|
+
* Use `agent.on('agentfootprint.context.injected', ...)` directly
|
|
133
|
+
* if you need to observe sources that aren't (yet) classified.
|
|
134
|
+
*/
|
|
135
|
+
export declare function contextEngineering(agent: RunnerWithEvents): ContextEngineeringHandle;
|
|
136
|
+
export {};
|
|
137
|
+
//# sourceMappingURL=contextEngineering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextEngineering.d.ts","sourceRoot":"","sources":["../../../../src/recorders/core/contextEngineering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,aAAa,CAQxD,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,aAAa,CAMtD,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAEjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAE/D;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,sBAAsB,CAAC,iCAAiC,CAAC,CAAC;AAE7F,iDAAiD;AACjD,MAAM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;AAE5E,0BAA0B;AAC1B,MAAM,MAAM,6BAA6B,GAAG,MAAM,IAAI,CAAC;AAEvD;;;;GAIG;AACH,UAAU,gBAAgB;IACxB,EAAE,CACA,IAAI,EAAE,iCAAiC,EACvC,QAAQ,EAAE,uBAAuB,GAChC,6BAA6B,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,YAAY,CAAC,QAAQ,EAAE,uBAAuB,GAAG,6BAA6B,CAAC;IAC/E;;;OAGG;IACH,UAAU,CAAC,QAAQ,EAAE,uBAAuB,GAAG,6BAA6B,CAAC;IAC7E;;;;OAIG;IACH,MAAM,IAAI,IAAI,CAAC;CAChB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,wBAAwB,CA0CpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commentaryTemplates.d.ts","sourceRoot":"","sources":["../../../../../src/recorders/observability/commentary/commentaryTemplates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE;;;2EAG2E;AAC3E,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,
|
|
1
|
+
{"version":3,"file":"commentaryTemplates.d.ts","sourceRoot":"","sources":["../../../../../src/recorders/observability/commentary/commentaryTemplates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE;;;2EAG2E;AAC3E,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,mBAyDxC,CAAC;AAEF;;6CAE6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC;6EACyE;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;2EAGuE;IACvE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CACxE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CA8EzF;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,mBAAmB,EAC1B,GAAG,EAAE,iBAAiB,EACtB,SAAS,GAAE,mBAAgD,GAC1D,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwBxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAEvF"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PermissionPolicy — data-driven role-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
|
+
import type { PermissionChecker, PermissionRequest, PermissionDecision } from '../adapters/types.js';
|
|
54
|
+
/**
|
|
55
|
+
* Map of role name → list of tool ids that role is allowed to invoke.
|
|
56
|
+
* The shape consumers extend over time as new tools / roles arrive.
|
|
57
|
+
*/
|
|
58
|
+
export type RoleAllowlist = Readonly<Record<string, readonly string[]>>;
|
|
59
|
+
export interface PermissionPolicyOptions {
|
|
60
|
+
/**
|
|
61
|
+
* The role allowlist. Each role maps to the tool ids it can invoke.
|
|
62
|
+
* Tool ids match the `name` field of `Tool.schema.name` exactly.
|
|
63
|
+
*/
|
|
64
|
+
readonly roles: RoleAllowlist;
|
|
65
|
+
/**
|
|
66
|
+
* Which role is active for this policy instance. Calls to
|
|
67
|
+
* `.isAllowed(toolId)` check against this role's allowlist.
|
|
68
|
+
* Use `.withActiveRole(name)` to derive a sibling policy with a
|
|
69
|
+
* different active role.
|
|
70
|
+
*/
|
|
71
|
+
readonly activeRole: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Data-driven role-based permission policy. Satisfies the v2.4
|
|
75
|
+
* `PermissionChecker` interface AND exposes a sync `isAllowed` method
|
|
76
|
+
* for use with `gatedTools` from `agentfootprint/tool-providers`.
|
|
77
|
+
*/
|
|
78
|
+
export declare class PermissionPolicy implements PermissionChecker {
|
|
79
|
+
private readonly opts;
|
|
80
|
+
readonly name = "PermissionPolicy";
|
|
81
|
+
private constructor();
|
|
82
|
+
/**
|
|
83
|
+
* Factory: build a role-based policy from a role → tool-ids map and
|
|
84
|
+
* the role active for this instance.
|
|
85
|
+
*
|
|
86
|
+
* Throws if `activeRole` isn't a key in `roles` — fail loud at
|
|
87
|
+
* config time, not at first denied call.
|
|
88
|
+
*/
|
|
89
|
+
static fromRoles(roles: RoleAllowlist, activeRole: string): PermissionPolicy;
|
|
90
|
+
/**
|
|
91
|
+
* Sync allowlist check. Use as a predicate with `gatedTools`:
|
|
92
|
+
*
|
|
93
|
+
* gatedTools(staticTools(allTools), (toolId) => policy.isAllowed(toolId))
|
|
94
|
+
*
|
|
95
|
+
* Returns true iff `toolId` is in the active role's allowlist.
|
|
96
|
+
* Closes-fail by design: missing role membership = denied.
|
|
97
|
+
*/
|
|
98
|
+
isAllowed(toolId: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Async check matching the `PermissionChecker` interface — consumed
|
|
101
|
+
* by `Agent.create({ permissionChecker })`. Wraps `isAllowed` with
|
|
102
|
+
* the structured `PermissionDecision` envelope (allow / deny + a
|
|
103
|
+
* `policyRuleId` so observability can trace which role decided).
|
|
104
|
+
*
|
|
105
|
+
* Today the policy only checks the tool name (request.target).
|
|
106
|
+
* Future work: also gate by capability ('memory_write', etc.) when
|
|
107
|
+
* the role allowlist is widened to capability-by-id.
|
|
108
|
+
*/
|
|
109
|
+
check(request: PermissionRequest): Promise<PermissionDecision>;
|
|
110
|
+
/**
|
|
111
|
+
* Derive a sibling policy with a different active role. Same role
|
|
112
|
+
* map; different active role. Useful for per-identity routing
|
|
113
|
+
* (one policy instance per request, varying active role per caller).
|
|
114
|
+
*
|
|
115
|
+
* Returns a NEW PermissionPolicy — original is unchanged.
|
|
116
|
+
*/
|
|
117
|
+
withActiveRole(activeRole: string): PermissionPolicy;
|
|
118
|
+
/** The role name currently active. Useful for observability. */
|
|
119
|
+
get activeRole(): string;
|
|
120
|
+
/** All defined role names. Stable order = registration order. */
|
|
121
|
+
get roles(): readonly string[];
|
|
122
|
+
/** All tool ids allowed under the current active role. */
|
|
123
|
+
allowedToolIds(): readonly string[];
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=PermissionPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PermissionPolicy.d.ts","sourceRoot":"","sources":["../../../src/security/PermissionPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;AAExE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,iBAAiB;IAGpC,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFzC,QAAQ,CAAC,IAAI,sBAAsB;IAEnC,OAAO;IAUP;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,GAAG,gBAAgB;IAI5E;;;;;;;OAOG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAIlC;;;;;;;;;OASG;IACG,KAAK,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAepE;;;;;;OAMG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB;IAIpD,gEAAgE;IAChE,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,iEAAiE;IACjE,IAAI,KAAK,IAAI,SAAS,MAAM,EAAE,CAE7B;IAED,0DAA0D;IAC1D,cAAc,IAAI,SAAS,MAAM,EAAE;CAGpC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
export type { RoleAllowlist, PermissionPolicyOptions } from './PermissionPolicy.js';
|
|
39
|
+
export type { PermissionChecker, PermissionRequest, PermissionDecision, } from '../adapters/types.js';
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAMpF,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
import type { ToolProvider, ToolGatePredicate } from './types.js';
|
|
36
|
+
export declare function gatedTools(inner: ToolProvider, predicate: ToolGatePredicate): ToolProvider;
|
|
37
|
+
//# sourceMappingURL=gatedTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gatedTools.d.ts","sourceRoot":"","sources":["../../../src/tool-providers/gatedTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAuB,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGvF,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,GAAG,YAAY,CAc1F"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/tool-providers — chainable tool dispatch + tool sources.
|
|
3
|
+
*
|
|
4
|
+
* Two layers under one subpath:
|
|
5
|
+
*
|
|
6
|
+
* 1. Tool dispatch (this folder)
|
|
7
|
+
* - `staticTools(arr)` — wrap a flat tool list
|
|
8
|
+
* - `gatedTools(inner, predicate)` — decorator that filters
|
|
9
|
+
* - `ToolProvider` interface — the contract
|
|
10
|
+
* - `ToolDispatchContext` — read-only context per iteration
|
|
11
|
+
*
|
|
12
|
+
* 2. Tool sources (re-exported from existing modules)
|
|
13
|
+
* - `mcpClient(opts)` — connect to an MCP server (real)
|
|
14
|
+
* - `mockMcpClient({ tools })` — in-memory MCP source for dev / tests
|
|
15
|
+
*
|
|
16
|
+
* Compose freely. The dispatch layer is decorator-shaped (mirroring
|
|
17
|
+
* `withRetry` / `withFallback` over LLMProvider). Tool sources produce
|
|
18
|
+
* `Tool[]` that flow into a `staticTools(arr)` provider, which can
|
|
19
|
+
* then be wrapped by `gatedTools(...)` for permission gating or
|
|
20
|
+
* per-skill filtering.
|
|
21
|
+
*
|
|
22
|
+
* @example Static (90% case — what `agent.tools(arr)` does today)
|
|
23
|
+
* const provider = staticTools([weatherTool, lookupTool]);
|
|
24
|
+
*
|
|
25
|
+
* @example Read-only enforcement
|
|
26
|
+
* const readOnly = gatedTools(
|
|
27
|
+
* staticTools(allTools),
|
|
28
|
+
* (name) => policy.isAllowed(name),
|
|
29
|
+
* );
|
|
30
|
+
*
|
|
31
|
+
* @example MCP source + permission gate
|
|
32
|
+
* const slack = await mcpClient({ transport: ... });
|
|
33
|
+
* const slackTools = await slack.tools();
|
|
34
|
+
* const provider = gatedTools(staticTools(slackTools), (name) => allowed(name));
|
|
35
|
+
*/
|
|
36
|
+
export { staticTools } from './staticTools.js';
|
|
37
|
+
export { gatedTools } from './gatedTools.js';
|
|
38
|
+
export { skillScopedTools } from './skillScopedTools.js';
|
|
39
|
+
export type { ToolProvider, ToolDispatchContext, ToolGatePredicate } from './types.js';
|
|
40
|
+
export { mcpClient, mockMcpClient } from '../lib/mcp/index.js';
|
|
41
|
+
export type { McpClient, McpClientOptions, McpTransport, McpStdioTransport, McpHttpTransport, MockMcpClientOptions, MockMcpTool, } from '../lib/mcp/index.js';
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tool-providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKvF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,GACZ,MAAM,qBAAqB,CAAC"}
|